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

Fix PositionD parsing in config from strings like '123.1, 234.2', which had been doing the wrong thing. #1300

Merged
merged 5 commits into from
Jul 10, 2024

Conversation

rmjarvis
Copy link
Member

@rmjarvis rmjarvis commented Jul 9, 2024

@jmeyers314 noticed in #1299 that a string like '123.4, 567.8' doesn't get parsed correctly. This PR fixes the implementation to work correctly.

@rmjarvis rmjarvis added bug report Bug report config Related to the config-processing functionality. labels Jul 9, 2024
@rmjarvis rmjarvis changed the base branch from main to releases/2.5 July 9, 2024 12:46
@rmjarvis rmjarvis force-pushed the #1299 branch 2 times, most recently from 01e9405 to 2fdb9db Compare July 9, 2024 12:47
Copy link
Member

@jmeyers314 jmeyers314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@jmeyers314
Copy link
Member

Although, it just occurred to me this will still fail if given:

pos : 12

=> PositionD(1.0, 2.0).

Maybe that's bizarre enough to not bother defending against though.

@rmjarvis
Copy link
Member Author

rmjarvis commented Jul 9, 2024

pos : 12

That will give an appropriate error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Mike/GalSim/galsim/config/value.py", line 206, in ParseValue
    val = _GetPositionValue(param)
  File "/Users/Mike/GalSim/galsim/config/value.py", line 463, in _GetPositionValue
    raise GalSimConfigError("Unable to parse %s as a PositionD. Caught %s"%(param,e))
galsim.errors.GalSimConfigError: Unable to parse 12 as a PositionD. Caught 'int' object has no attribute 'split'

The one that will work inappropriately is

pos : "12"

which I think is probably bizarre enough not to bother defending against.

@jmeyers314
Copy link
Member

Ah, right. Yaml sees that as an int, not a str, so all is well.

@rmjarvis
Copy link
Member Author

Is there any urgency in getting this into a bugfix release? Or should we let this sit until we have more bugs fixed?

@rmjarvis rmjarvis merged commit f6499ba into releases/2.5 Jul 10, 2024
10 checks passed
@rmjarvis rmjarvis deleted the #1299 branch July 10, 2024 06:58
@jmeyers314
Copy link
Member

No urgency I think. The original workaround you proposed seems fine.

@rmjarvis rmjarvis added this to the v2.6 milestone Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Bug report config Related to the config-processing functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

comma/space delimited PositionD string parsed incorrectly in config layer
2 participants