GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
223 stars 105 forks source link

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

Closed jmeyers314 closed 1 month ago

jmeyers314 commented 1 month ago

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 commented 1 month ago

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'}