BlueBrain / nmodl

Code Generation Framework For NEURON MODeling Language
https://bluebrain.github.io/nmodl/
Apache License 2.0
57 stars 15 forks source link

Add support for diffing against `sympy.Indexed` instances #1517

Closed JCGoran closed 1 month ago

JCGoran commented 1 month ago

If we have an expression (string) that contains an indexed variable (like x[0]), we should be able to differentiate w.r.t. it as well. As explained in the updated docstring, the way to do it is to pass a sympy.Indexed instance as the independent variable (not to be confused with an sympy.IndexedBase instance!). Note that we also need to pass an sympy.IndexedBase into the SymPy list of known symbols (i.e. as one of vars), otherwise the parser breaks.

For reference, we added mod files with indexed vars in #1504.