Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joleroi committed Mar 25, 2016
1 parent 66e7865 commit de602a9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions regions/io/read_ds9.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ def region_list_to_objects(region_list):
return output_list




def ds9_parser(filename):
"""
Parse a complete ds9 .reg file
Expand Down Expand Up @@ -196,7 +194,6 @@ def line_parser(line, coordsys=None):
coordsys_name_mapping[coordsys])

# Reset iterator for ellipse annulus
# (not needed for physical regions b/c coordinate = radius in that case)
if region_type == 'ellipse':
language_spec[region_type] = itertools.chain((coordinate, coordinate), itertools.cycle((radius, )))

Expand All @@ -217,6 +214,11 @@ def line_parser(line, coordsys=None):
parsed = [_.value for _ in parsed]
coord = PixCoord(parsed[0], parsed[1])
parsed_return = [coord]+parsed[2:]

# Reset iterator for ellipse annulus
if region_type == 'ellipse':
language_spec[region_type] = itertools.chain((coordinate, coordinate), itertools.cycle((radius, )))

return region_type, parsed_return, parsed_meta, composite


Expand Down
2 changes: 1 addition & 1 deletion regions/io/tests/data/fk5_reference.reg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
fk5
circle(202.49,47.21,3.96")
ellipse(202.48,47.20,7.93",3.96",2.40)
polygon(202.47, 47.20, 202.47, 47.20, 202.47, 47.20, 202.47, 47.20)
polygon(202.47,47.20,202.47,47.20,202.47,47.20,202.47,47.20)
2 changes: 1 addition & 1 deletion regions/io/tests/data/galactic_reference.reg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
galactic
circle(104.84,68.54,3.96")
ellipse(104.84,68.55,7.93",3.96",158.39)
polygon(104.85, 68.56, 104.86, 68.56, 104.86, 68.56, 104.85, 68.56)
polygon(104.85,68.56,104.86,68.56,104.86,68.56,104.85,68.56)
2 changes: 1 addition & 1 deletion regions/io/tests/data/physical_reference.reg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
physical
circle(331.00,1091.00,40.00)
ellipse(495.00,1057.00,80.00,40.00,45.00)
polygon(813.49, 1075.00, 889.00, 1150.51, 964.51, 1075.00, 889.00, 999.49)
polygon(813.49,1075.00,889.00,1150.51,964.51,1075.00,889.00,999.49)
4 changes: 2 additions & 2 deletions regions/io/write_ds9.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ def objects_to_ds9_string(obj_list, coordsys='fk5', fmt='.4f', radunit='deg'):
zip(v.spherical.lon, v.spherical.lat)]
val = "{:"+fmt+"}"
temp = [val.format(x) for _ in coords for x in _]
c = ", ".join(temp)
c = ",".join(temp)
output += ds9_strings['polygon'].format(**locals())
elif t == 'pixpolygon':
v = reg.vertices
coords = [(x, y) for x, y in zip(v.x, v.y)]
val = "{:"+fmt+"}"
temp = [val.format(x) for _ in coords for x in _]
c = ", ".join(temp)
c = ",".join(temp)
output += ds9_strings['polygon'].format(**locals())

return output
Expand Down

0 comments on commit de602a9

Please sign in to comment.