lines 5-127 of file: lib/python/cppad_py/more_py.xrst {xrst_begin more.py} {xrst_spell adynamic def grep } Steps To Add More Python Functions ################################## Purpose ******* This section outlines the steps for adding more python functionality to cppad_py. This is done by example showing how the :ref:`py_fun_new_dynamic-name` was added. This example case was chosen because it required both changing one python function, :ref:`py_independent-name`, and adding a new python function, :ref:`py_fun_new_dynamic-name`. Documentation ************* independent =========== The python file ``lib/python/cppad_py/independent.py`` was edited to add the following syntax documentation: | |tab| ( *ax* , *adynamic* ) = ``cppad_py::independent`` ( *x* , *dynamic* ) and the extra return value was documented; see :ref:`adynamic`. new_dynamic =========== The :ref:`cpp_fun_new_dynamic-name` documentation was added in the file ``lib/python/cppad_py/fun_new_dynamic.py`` . In addition, this file was added to the file list in ``lib/python/cppad_py/fun.py`` . Example ======= The example file ``example/python/core/fun_dynamic_xam.py`` was added to the documentation, below the :ref:`py_independent-name` section. In addition, a reference to this example was added under the :ref:`example` heading in the ``independent`` documentation. Implementation ************** independent =========== The ``independent`` function in ``lib/python/cppad_py/independent.py`` was changed to handle dynamic parameters as follows: {xrst_literal lib/python/cppad_py/independent.py # BEGIN_INDEPENDENT_SOURCE # END_INDEPENDENT_SOURCE } new_dynamic =========== The following function declaration was added to the ``d_fun`` class in the ``lib/python/cppad_py/fun.py`` file: {xrst_code py} def new_dynamic(self, dynamic) : return cppad_py.d_fun_new_dynamic(self.f, dynamic) {xrst_code} A similar declaration was added to the ``a_fun`` class. fun_new_dynamic.py ================== The implementation of ``d_fun_new_dynamic`` and ``a_fun_new_dynamic`` were added to the file ``fun_new_dynamic.py`` __init__.py =========== The following code was added to the file ``lib/python/cppad_py/__init__.py`` : | ``from cppad_py.fun_new_dynamic import a_fun_new_dynamic`` | ``from cppad_py.fun_new_dynamic import d_fun_new_dynamic`` Example ******* The file ``example/python/core/fun_dynamic_xam.py`` was added with the following contents: :ref:`fun_dynamic_xam.py-name`. In addition, in the file | |tab| ``example/python/check_all.py.in`` the following text was added to the list of python example files. | |tab| ``'fun_dynamic_xam'`` , | ``%`` Testing ******* You must do a git add for all of the new files before running ``bin/check_all.sh`` After all the changes above were implemented, ``bin/check_all.sh`` was run and the changes were made until the warnings and errors were fixed. The command | |tab| ``grep 'fun_dynamic_xam' check_all.log`` was used to make sure that the new python example / test was run. Note that the python files in ``cppad_py`` are copies of the python files in ``lib/python`` . So when you fix errors during testing, you need to fix the ``lib/python`` file. Also note that if a particular step in ``bin/check_all.sh`` is failing, you can just re-run that step to see if a particular fix works. Once the tests were working, the changes where checked into using ``git`` . {xrst_end more.py}