brocksam / pycollo

General-purpose optimal control, trajectory optimisation and parameter optimisation using direct collocation
https://brocksam.github.io/pycollo/
MIT License
8 stars 3 forks source link

Add support for handling of Sympy number symbols #15

Closed brocksam closed 4 years ago

brocksam commented 4 years ago

Fixes a bug where production of the expression graph fails if a Sympy number symbol (e.g. sym.pi) is encountered. An additional check during node initialisation is conducted to see whether is_NumberSymbol for a node key is True after sympification. If this is the case then the symbol is added to the set of user constants. This then causes it to be treated as a ConstantNode object rather than an IntermediateNode. A further amendment to the ConstantNode._set_value static method is applied which defaults to trying to convert to symbol key to a float in the scenario where attempting to convert the supplied value argument to a float raises as TypeError.