This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Utilities to convert a `dysts` dynamical system object's rhs to SymPy. | |
| This module inspects the source of an object's RHS method (by default | |
| named ``rhs``), parses the function using ``ast``, and converts the | |
| returned expression(s) into SymPy expressions. | |
| The conversion is intentionally conservative and aims to handle common | |
| patterns used in simple rhs implementations, e.g. returning a tuple/list | |
| of arithmetic expressions, using indexing into a state vector (``x[0]``), | |
| and calls to common ``numpy``/``math`` functions (``np.sin``, ``math.exp``, ...). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # import random | |
| def unsafe_unpacker(obj): | |
| """A generator that traverses an arbitrarily nested iterable of iterables. | |
| Parameters: | |
| obj (iterable): the nested iterables, e.g. a numpy array of lists of tuples | |
| Returns: | |
| A generator whose items are the ordered collection of any non-iterable found |