Skip to content

Commit

Permalink
Fix data deletion tests for image rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Oct 25, 2023
1 parent 786a13a commit fd9d67d
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions jdaviz/configs/imviz/tests/test_delete_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,40 @@ def test_delete_with_subset_wcs(self):

assert len(self.imviz.app.data_collection.subset_groups) == 2

# by default the parent will be the reference data layer, which
# is the "Default Orientation" WCS-only layer since Imviz is
# WCS-linked here. Let's reparent to a layer that we can
# delete to test the machinery:
for subset in self.imviz.app.data_collection.subset_groups:
self.imviz.app._reparent_subsets(
subset.subset_state.xatt.parent.label,
"has_wcs_1[SCI,1]"
)

subset1 = self.imviz.app.data_collection.subset_groups[0]
subset2 = self.imviz.app.data_collection.subset_groups[1]
assert subset1.subset_state.xatt.parent.label == "has_wcs_1[SCI,1]"
assert_allclose(subset1.subset_state.center(), (2, 2))
assert_allclose(subset1.subset_state.center(), (2.25, 2.25))

assert subset2.subset_state.xatt.parent.label == "has_wcs_1[SCI,1]"
assert_allclose(subset2.subset_state.roi.xmin, 0)
assert_allclose(subset2.subset_state.roi.ymin, 0)
assert_allclose(subset2.subset_state.roi.xmax, 2)
assert_allclose(subset2.subset_state.roi.ymax, 2)
assert_allclose(subset2.subset_state.roi.xmin, 0.25)
assert_allclose(subset2.subset_state.roi.ymin, 0.25)
assert_allclose(subset2.subset_state.roi.xmax, 2.25)
assert_allclose(subset2.subset_state.roi.ymax, 2.25)

# We have to remove the data from the viewer before deleting the data from the app.
self.imviz.app.remove_data_from_viewer("imviz-0", "has_wcs_1[SCI,1]")
self.imviz.app.vue_data_item_remove({"item_name": "has_wcs_1[SCI,1]"})

# Make sure we re-linked images 2 and 3
assert len(self.imviz.app.data_collection.external_links) == 1
# Make sure we re-linked images 2 and 3 (plus WCS-only reference data layer)
assert len(self.imviz.app.data_collection.external_links) == 2

# Check that the reparenting and coordinate recalculations happened
assert subset1.subset_state.xatt.parent.label == "has_wcs_2[SCI,1]"
assert_allclose(subset1.subset_state.center(), (3, 2))
assert_allclose(subset1.subset_state.center(), (3.25, 2.25))

assert subset2.subset_state.xatt.parent.label == "has_wcs_2[SCI,1]"
assert_allclose(subset2.subset_state.roi.xmin, 1, atol=1e-6)
assert_allclose(subset2.subset_state.roi.ymin, 0, atol=1e-6)
assert_allclose(subset2.subset_state.roi.xmax, 3, atol=1e-6)
assert_allclose(subset2.subset_state.roi.ymax, 2, atol=1e-6)
assert_allclose(subset2.subset_state.roi.xmin, 1.25, atol=1e-6)
assert_allclose(subset2.subset_state.roi.ymin, 0.25, atol=1e-6)
assert_allclose(subset2.subset_state.roi.xmax, 3.25, atol=1e-6)
assert_allclose(subset2.subset_state.roi.ymax, 2.25, atol=1e-6)

0 comments on commit fd9d67d

Please sign in to comment.