Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storing equations as graphs #716

Open
CagtayFabry opened this issue Mar 2, 2022 · 4 comments
Open

storing equations as graphs #716

CagtayFabry opened this issue Mar 2, 2022 · 4 comments
Labels
ASDF everything ASDF related (python + schemas) core weldx core classes and functions

Comments

@CagtayFabry
Copy link
Member

Currently we store the sympy equations as strings which is very accessible and simple to use

In case a more 'robust' solution is required in the future we could also think about storing the equation in graph form using sympy.dotprint https://docs.sympy.org/latest/tutorial/printing.html#dot

sympy -> dot -> networkx

It would be similiar to what asdf is doing in their schemas but might be more flexible overal

@CagtayFabry CagtayFabry added ASDF everything ASDF related (python + schemas) core weldx core classes and functions labels Mar 2, 2022
@marscher
Copy link
Collaborator

marscher commented Mar 3, 2022

That sounds interesting. What would be a use-case for storing the equations graph? What about forward compatibility, if we skip the parsing of the equation string and just rely that this graph will be future proof?
Currently I can only things which could cause trouble instead of any worth benefit.

@CagtayFabry
Copy link
Member Author

In my opinion the main benefit would be that you could make sure the equation is actually valid since there is no syntax check (before loading) on the strings in the schema
However the overhead is certainly large

certainly not something we need right now though😉

@marscher
Copy link
Collaborator

marscher commented Mar 4, 2022

Isn't the expression string cast into a Sympy expression before serialization? If so, it would already be checked to be valid, right?

@CagtayFabry
Copy link
Member Author

Isn't the expression string cast into a Sympy expression before serialization? If so, it would already be checked to be valid, right?

Yes on the python side everything should be checked when loading but there is no validation on an ASDF level

If you would create an ASDF file with an invalid expression you will end up with a sympy error when loading the file. Ideally in cases like these there should be a ValidationError before anyhting sympy related happens. (since the ASDF file should be valid independent from sympy or any other python implementation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASDF everything ASDF related (python + schemas) core weldx core classes and functions
Projects
None yet
Development

No branches or pull requests

2 participants