-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
feat: add function to parse variable from string #3224
feat: add function to parse variable from string #3224
Conversation
""" | ||
$(TYPEDSIGNATURES) | ||
|
||
Return the variable in `sys` referred to by its string representation `str`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add it to the docs
src/systems/abstractsystem.jl
Outdated
maybe_dummy_var = namespacedvar | namespacedvar "(t)" | | ||
namespacedvar "(t)" "ˍ" ts | namespacedvar "ˍ" ts | | ||
namespacedvar "ˍ" ts "(t)" | ||
ts = "t" | "t" ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nameof(independent_variable(sys))
?
Codecov is at it again |
src/systems/abstractsystem.jl
Outdated
# I'd write a regex to validate `str`, but https://xkcd.com/1171/ | ||
str = strip(str) | ||
derivative_level = 0 | ||
while startswith(str, "D(") && endswith(str, ")") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to validate that D
is also the differential?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D
never shows up in expressions, it always prints as Differential(t)(x(t))
. In the interest of concision, I assumed that D
refers to the derivative with respect to the independent variable. I could also add a case that handles Differential(t)(x(t))
and validates that the independent variable matches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.