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

comma/space delimited PositionD string parsed incorrectly in config layer #1299

Closed
jmeyers314 opened this issue Jul 9, 2024 · 1 comment · Fixed by #1300
Closed

comma/space delimited PositionD string parsed incorrectly in config layer #1299

jmeyers314 opened this issue Jul 9, 2024 · 1 comment · Fixed by #1300
Labels
bug report Bug report config Related to the config-processing functionality.
Milestone

Comments

@jmeyers314
Copy link
Member

According to https://galsim-developers.github.io/GalSim/_build/html/config_values.html#pos-value, I ought to be able to use:

...
image:
  image_pos: 123.4, 567.8

to set the image position for an object. But this gets parsed by _GetPositionValue to (1.0, 2.0) because strings are indexable.

Reproducer:

import galsim
config = {'image_pos': '123.4, 567.8'}
print(galsim.config.ParseValue(config, 'image_pos', config, galsim.PositionD)[0])
assert galsim.config.ParseValue(config, 'image_pos', config, galsim.PositionD)[0] == galsim.PositionD(123.4, 567.8)
@rmjarvis
Copy link
Member

rmjarvis commented Jul 9, 2024

Interesting. It seems to only be a problem if the first number is >= 10. Our unit test for this uses '0.1, 0.2'. But like you said, it fails if the first number is e.g. 123.4, since trying to parse the first two elements of the string succeeds.

FWIW, a workaround for now is to add $ at the front.

config = {'image_pos': '$123.4, 567.8'}

@rmjarvis rmjarvis added this to the v2.6 milestone Jul 24, 2024
@rmjarvis rmjarvis added bug report Bug report config Related to the config-processing functionality. labels 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
2 participants