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

Added function to replace variables by their default values #41

Merged

Conversation

schymans
Copy link
Collaborator

Equations often contain variables with default values (e.g. physical constants) and variables without. If we substitute the dictionary with default values into an expression, e.g. demo_fall.xreplace(Variable.__defaults__), we obtain the RHS of the equation with inconsistent units, as the dictionary does not contain the units: 4.9*t**2
To simplify substitution of default values with their appropriate units into equations, I created the function replace_defaults() to variables/utils.py. Usage example:

>>> replace_defaults(demo_fall)
Eq(demo_d, 4.9*t**2*meter/second**2)

@schymans
Copy link
Collaborator Author

Alright, this did not work, as I tested it locally on sympy-1.1.2.dev0, but the current master of sympy has undergone a major refactoring of quantities and units. Need to decide whether to adapt to the new sympy master or back to sympy 1.1.1.

@jirikuncar jirikuncar merged commit 84cd47e into environmentalscience:master Mar 1, 2018
@schymans schymans deleted the utils_replace-defaults branch March 1, 2018 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants