fix: backport im string parsing fix to release-v1#169
fix: backport im string parsing fix to release-v1#169MilesCranmerBot wants to merge 6 commits intoSymbolicML:release-v1from
Conversation
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
|
@MilesCranmerBot CI is failing |
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
| @unstable parse_expression(ex::String; kws...) = parse_expression(Meta.parse(ex); kws...) | ||
|
|
There was a problem hiding this comment.
Looks like a new feature rather than a backport? Can you clarify @MilesCranmerBot
There was a problem hiding this comment.
Yep — it looks like a feature addition in release-v1, but it’s actually a straight backport of what already landed on master.
On master the fix is introduced in commit 741031c4 (“fix: treat im as imaginary unit in string parsing”) and includes:
- normalizing
:im→ the Julia constantimwhen parsing (unless "im" is explicitly listed invariable_names, in which case it stays a variable), and - the additive convenience overload
parse_expression(::String)(also present onmaster).
I included the ::String overload here only to keep release-v1 behavior/API aligned with master for this parsing path; if you’d prefer the backport to be strictly minimal, I’m happy to drop that overload and have the test call Meta.parse(...) explicitly instead.
There was a problem hiding this comment.
Yep — this PR is meant to be a straight backport of #168 (merged to master).
The only extras here are release-v1-specific adaptation:
release-v1didn’t have the convenience methodparse_expression(::String)thatmasteralready has. I added it as a tiny wrapper aroundMeta.parseso the same regression test can run. It doesn’t enable anything you couldn’t already do viaparse_expression(Meta.parse(str); ...).- The new test’s tree-walk helper is written against the release-v1 node layout (v1 uses
l/rinstead of thechildrenrepresentation onmaster).
The actual behavior change being backported is just normalizing the :im symbol to Julia’s imaginary unit constant unless "im" is explicitly listed in variable_names (in which case it remains a variable).
If you’d prefer to keep release-v1’s public API surface strictly frozen, I can drop the parse_expression(::String) method and update the test to call Meta.parse explicitly.
Backport of #168 to
release-v1.Includes the
imparsing fix and a small release-v1 compatibility adjustment for the new parse test.Validation run locally:
parse_expression("0.1im + x")andparse_expression("im + x2")with assertions on type/evaluation (ok)I did not wait for another full
Pkg.test()pass after the final compatibility patch because it is relatively heavy in this environment.