Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

Commit

Permalink
Merge pull request #202 from astrofrog/fix-empty-array-wcs
Browse files Browse the repository at this point in the history
Fix a bug that caused WCSAxes to crash when trying to transform arrays with zero coordinates
  • Loading branch information
astrofrog committed May 24, 2016
2 parents 2d49942 + 277233b commit e63379a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

- Added property getters for color and linewidth in BaseFrame. [#203]

- Fix a bug that caused WCSAxes to crash when trying to transform arrays with
zero coordinates. [#202]

0.7 (2016-05-06)
----------------

Expand Down
10 changes: 8 additions & 2 deletions wcsaxes/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ def transform(self, world):
if world.shape[1] != self.wcs.wcs.naxis:
raise ValueError("Second dimension of input values should match number of WCS coordinates")

pixel = self.wcs.wcs_world2pix(world, 1) - 1
if world.shape[0] == 0:
pixel = np.zeros((0, 2))
else:
pixel = self.wcs.wcs_world2pix(world, 1) - 1

if self.slice is None:
return pixel
Expand Down Expand Up @@ -162,7 +165,10 @@ def transform(self, pixel):

pixel_full += 1

world = self.wcs.wcs_pix2world(pixel_full, 1)
if pixel_full.shape[0] == 0:
world = np.zeros((0, 2))
else:
world = self.wcs.wcs_pix2world(pixel_full, 1)

# At the moment, one has to manually check that the transformation
# round-trips, otherwise it should be considered invalid.
Expand Down

0 comments on commit e63379a

Please sign in to comment.