astropy / pyregion

ds9 region parser for python
https://pyregion.readthedocs.io
MIT License
39 stars 38 forks source link

Failure to properly parse DS9 region files that contain RGB colors such as "#6a8" #106

Closed will-henney closed 7 years ago

will-henney commented 7 years ago

Hi,

There seems to be a bug with the parsing of DS9 regions if the color has a hash sign in it. Here is an example:

import pyregion
badstring = 'fk5;ellipse(5:34:26.665,-5:26:16.18,6.62208",12.3556",345) # color=#6a8 width=4 text={4267-616 (-55)} tag={Fast blue}'
goodstring = badstring.replace('#6a8', '6a8')

badregion, =  pyregion.parse(badstring)
goodregion, = pyregion.parse(goodstring)

print('pyregion version', pyregion.__version__)
print('Bad region:', badregion.attr)
print('Good region:', goodregion.attr)

which gives me the following output

pyregion version 2.0.dev275
Bad region: (['color'], {})
Good region: ([], {'width': '4 ', 'text': '4267-616 (-55)', 'color': '6a8', 'tag': {'Fast blue'}})

I tried the new astropy.regions and that did not show the same problem. However, it doesn't seem to support masks yet, which I make extensive use of.

I can work around the problem by filtering out the hash signs before parsing with pyregion, so it is not such a big deal.

Will

keflavich commented 7 years ago

@deprecated Thanks for the report. astropy-regions will have masks for some subset of regions soon: https://github.com/astropy/regions/pull/71.

This probably indicates a genuine bug in the pyregion parser, but it's unlikely anyone will fix that; instead, we'll try to get astropy.regions up and running.

will-henney commented 7 years ago

OK, thanks for the response. I'll certainly keep on eye on the progress of that PR then. Elliptical and rectangular regions would be enough for me.

cdeil commented 7 years ago

I think @leejjoon fixed this in #112. Closing the issue now.

@deprecated - If there still is an issue, please re-open or file a new one!