Skip to content

Commit

Permalink
Adjust Mask class so that tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Nov 7, 2016
1 parent bd03250 commit 50a57eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions regions/core/mask.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import numpy as np

__all__ = ['Mask']


Expand All @@ -18,15 +20,12 @@ class Mask(object):
minimal bounding box.
"""

def __init__(self, mask, bbox_slice):
def __init__(self, mask, origin):

self.data = np.asanyarray(mask)
self.shape = mask.shape
self.slices = bbox_slice

dy = bbox_slice[0].stop - bbox_slice[0].start
dx = bbox_slice[1].stop - bbox_slice[1].start
if self.data.shape != (dy, dx):
raise ValueError('mask shape and bbox_slice do not agree.')
self.slices = (slice(origin[0], origin[0] + self.shape[0]),
slice(origin[1], origin[1] + self.shape[1]))

@property
def array(self):
Expand Down
2 changes: 1 addition & 1 deletion regions/shapes/tests/test_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ def test_to_mask():
center = PixCoord(3, 4)
reg = CirclePixelRegion(center, 2)
mask = reg.to_mask(mode='exact')
assert_allclose(np.sum(mask.mask), 4 * np.pi)
assert_allclose(np.sum(mask.data), 4 * np.pi)

0 comments on commit 50a57eb

Please sign in to comment.