diff --git a/glue/core/tests/test_roi.py b/glue/core/tests/test_roi.py index e43b81257..aa8e1684d 100644 --- a/glue/core/tests/test_roi.py +++ b/glue/core/tests/test_roi.py @@ -325,15 +325,18 @@ class TestEllipse(object): def setup_method(self, method): self.roi_empty = EllipticalROI() self.roi = EllipticalROI(1, 2, 3, 4) + self.roi_rotated = EllipticalROI(1, 2, 3, 0.4, theta=np.pi / 6) def test_undefined_on_creation(self): assert not self.roi_empty.defined() assert self.roi.defined() + assert self.roi_rotated.defined() def test_contains_on_undefined_contains_raises(self): with pytest.raises(UndefinedROI): self.roi_empty.contains(1, 1) self.roi.contains(1, 1) + self.roi.contains(1, 1) def test_set_center(self): assert self.roi.contains(0, 0) @@ -366,6 +369,11 @@ def test_poly(self): assert poly.contains(0, 0) assert not poly.contains(10, 0) + x, y = self.roi_rotated.to_polygon() + poly = PolygonalROI(vx=x, vy=y) + assert poly.contains(0, 2.5) + assert not poly.contains(0, 0) + def test_poly_undefined(self): x, y = self.roi_empty.to_polygon() assert x == [] @@ -931,7 +939,7 @@ def test_circular_roi_representation(): # Case 2: linear-linear axes with non-square aspect ratio - ax.set_xlim(-40, 100) + ax.set_xlim(10, 100) ax.set_ylim(-2, 5) ax.set_xscale('linear') ax.set_yscale('linear') diff --git a/glue/core/tests/test_subset.py b/glue/core/tests/test_subset.py index e953efc0b..9effaed60 100644 --- a/glue/core/tests/test_subset.py +++ b/glue/core/tests/test_subset.py @@ -851,7 +851,8 @@ def test_roi_subset_state(self): roi = RectangularROI(xmin=0, xmax=3, ymin=1.1, ymax=1.4) subset = self.data.new_subset() - subset.subset_state = RoiSubsetState(xatt=self.data.id['a'], yatt=self.data.id['c'], roi=roi) + subset.subset_state = RoiSubsetState(xatt=self.data.id['a'], yatt=self.data.id['c'], + roi=roi) assert_equal(self.data.subsets[0].to_mask(), [0, 1, 0, 0]) data_clone = clone(self.data) @@ -871,6 +872,19 @@ def test_roi_subset_state_with_pretransform(self): assert_equal(data_clone.subsets[0].to_mask(), [0, 1, 0, 0]) + def test_roi_subset_state_rotated(self): + + roi = RectangularROI(xmin=0, xmax=3, ymin=1.1, ymax=1.4, theta=np.pi / 3) + + subset = self.data.new_subset() + subset.subset_state = RoiSubsetState(xatt=self.data.id['a'], yatt=self.data.id['c'], + roi=roi) + assert_equal(self.data.subsets[0].to_mask(), [0, 0, 0, 1]) + + data_clone = clone(self.data) + + assert_equal(data_clone.subsets[0].to_mask(), [0, 1, 0, 0]) + @requires_scipy def test_floodfill_subset_state():