Skip to content

Commit

Permalink
Add test coverage for new error raised by bad .plot slices
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenbrot committed Feb 6, 2025
1 parent 3ccf3b8 commit aba17ac
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dkist/dataset/tests/test_tiled_dataset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import copy

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -145,6 +146,28 @@ def test_tileddataset_plot_limit_swapping(swap_tile_limits):

return plt.gcf()

def test_tileddataset_plot_non2d_sliceindex():
from dkist.data.sample import VBI_AJQWW
ds = load_dataset(VBI_AJQWW)

Check warning on line 151 in dkist/dataset/tests/test_tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tests/test_tiled_dataset.py#L151

Added line #L151 was not covered by tests

newtiles = []
for tile in ds.flat:
newtiles.append(tile.rebin((1, 8, 8), operation=np.sum))

Check warning on line 155 in dkist/dataset/tests/test_tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tests/test_tiled_dataset.py#L153-L155

Added lines #L153 - L155 were not covered by tests
# ndcube 2.3.0 introduced a deepcopy for rebin, this broke our dataset validation
# https://github.com/sunpy/ndcube/issues/815
for tile in newtiles:
tile.meta["inventory"] = ds.inventory
ds = TiledDataset(np.array(newtiles).reshape(ds.shape), meta={"inventory": newtiles[0].inventory})

Check warning on line 160 in dkist/dataset/tests/test_tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tests/test_tiled_dataset.py#L158-L160

Added lines #L158 - L160 were not covered by tests

already_sliced_ds = ds.slice_tiles[0]

Check warning on line 162 in dkist/dataset/tests/test_tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tests/test_tiled_dataset.py#L162

Added line #L162 was not covered by tests

fig = plt.figure(figsize=(12, 15))
with pytest.warns(DKISTUserWarning,

Check warning on line 165 in dkist/dataset/tests/test_tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tests/test_tiled_dataset.py#L164-L165

Added lines #L164 - L165 were not covered by tests
match="The metadata ASDF file that produced this dataset is out of date and will result in "
"incorrect plots. Please re-download the metadata ASDF file."):
with pytest.raises(ValueError, match=re.escape("Applying slice '(0,)' to this dataset resulted in a 1 "

Check warning on line 168 in dkist/dataset/tests/test_tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tests/test_tiled_dataset.py#L168

Added line #L168 was not covered by tests
"dimensional dataset, you should pass a slice which results in a 2D dataset for each tile.")):
already_sliced_ds.plot(0, figure=fig)

Check warning on line 170 in dkist/dataset/tests/test_tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tests/test_tiled_dataset.py#L170

Added line #L170 was not covered by tests

@pytest.mark.accept_cli_tiled_dataset
def test_repr(simple_tiled_dataset):
Expand Down

0 comments on commit aba17ac

Please sign in to comment.