Skip to content

Commit

Permalink
Add test for slice vs submap
Browse files Browse the repository at this point in the history
  • Loading branch information
nabobalis committed May 1, 2024
1 parent fa61199 commit 30a4640
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions sunpy/map/tests/test_mapbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import sunpy.coordinates
import sunpy.map
import sunpy.sun
from ndcube.tests.helpers import assert_cubes_equal
from sunpy.coordinates import HeliographicCarrington, HeliographicStonyhurst, sun
from sunpy.data.test import get_dummy_map_from_header, get_test_filepath
from sunpy.image.transform import _rotation_registry
Expand Down Expand Up @@ -1865,3 +1866,21 @@ def test_set_wcs_modifies_crpix(aia171_test_map, aslice, dims):
aia171_test_map.meta["CRPIX2"])

assert np.allclose(sliced_ref_coord, ori_ref_coord)

def test_slicing_map_submap_same(aia171_test_map):
bl_coord = SkyCoord(-1000 * u.arcsec, 0 * u.arcsec, frame=aia171_test_map.coordinate_frame)
bottom_left = aia171_test_map.wcs.world_to_pixel(bl_coord)

Check warning on line 1872 in sunpy/map/tests/test_mapbase.py

View check run for this annotation

Codecov / codecov/patch

sunpy/map/tests/test_mapbase.py#L1871-L1872

Added lines #L1871 - L1872 were not covered by tests

tp_coord = SkyCoord(0 * u.arcsec, 1000 * u.arcsec, frame=aia171_test_map.coordinate_frame)
top_right = aia171_test_map.wcs.world_to_pixel(tp_coord)

Check warning on line 1875 in sunpy/map/tests/test_mapbase.py

View check run for this annotation

Codecov / codecov/patch

sunpy/map/tests/test_mapbase.py#L1874-L1875

Added lines #L1874 - L1875 were not covered by tests

bottom_left_x, bottom_left_y = map(int, bottom_left)
top_right_x, top_right_y = map(int, top_right)

Check warning on line 1878 in sunpy/map/tests/test_mapbase.py

View check run for this annotation

Codecov / codecov/patch

sunpy/map/tests/test_mapbase.py#L1877-L1878

Added lines #L1877 - L1878 were not covered by tests

submap = aia171_test_map.submap([bottom_left_x, bottom_left_y]*u.pix,

Check warning on line 1880 in sunpy/map/tests/test_mapbase.py

View check run for this annotation

Codecov / codecov/patch

sunpy/map/tests/test_mapbase.py#L1880

Added line #L1880 was not covered by tests
top_right=[top_right_x, top_right_y]*u.pix
)

sliced_map = aia171_test_map[bottom_left_y : top_right_y + 1, bottom_left_x: top_right_x + 1]

Check warning on line 1884 in sunpy/map/tests/test_mapbase.py

View check run for this annotation

Codecov / codecov/patch

sunpy/map/tests/test_mapbase.py#L1884

Added line #L1884 was not covered by tests

assert_cubes_equal(submap, sliced_map)

Check warning on line 1886 in sunpy/map/tests/test_mapbase.py

View check run for this annotation

Codecov / codecov/patch

sunpy/map/tests/test_mapbase.py#L1886

Added line #L1886 was not covered by tests

0 comments on commit 30a4640

Please sign in to comment.