diff --git a/changelog/257.breaking.rst b/changelog/257.breaking.rst index 3bf9cef..a792283 100644 --- a/changelog/257.breaking.rst +++ b/changelog/257.breaking.rst @@ -1 +1 @@ -Increased the minimum version of Python to 3.10.0 \ No newline at end of file +Increased the minimum version of Python to 3.10.0 diff --git a/docs/data_types/spectrogram.rst b/docs/data_types/spectrogram.rst index 91bf85f..7240c7c 100644 --- a/docs/data_types/spectrogram.rst +++ b/docs/data_types/spectrogram.rst @@ -110,7 +110,7 @@ The `~sunraster.SpectrogramCube.dimensions` and `~sunraster.SpectrogramCube.arra .. code-block:: python - >>> my_spectrograms.shape + >>> my_spectrograms.dimensions >>> my_spectrograms.array_axis_physical_types [(np.str_('custom:pos.helioprojective.lat'), np.str_('custom:pos.helioprojective.lon')), (np.str_('custom:pos.helioprojective.lat'), np.str_('custom:pos.helioprojective.lon')), (np.str_('em.wl'),)] diff --git a/setup.cfg b/setup.cfg index 4c0d7d4..aba4cd1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -63,6 +63,8 @@ addopts = --doctest-rst --doctest-ignore-import-errors -p no:unraisableexception markers = online: marks this test function as needing online connectivity. remote_data_strict = True +doctest_subpackage_requires = + docs/* = ndcube<2.3.0 filterwarnings = error # Do not fail on pytest config issues (i.e. missing plugins) but do show them diff --git a/sunraster/instr/spice.py b/sunraster/instr/spice.py index 6e03315..48108ea 100644 --- a/sunraster/instr/spice.py +++ b/sunraster/instr/spice.py @@ -105,7 +105,9 @@ def read_spice_l2_fits(filenames, windows=None, memmap=True, read_dumbbells=Fals first_sequence = window_sequences[0][1] first_spectral_window = first_sequence[0].meta.spectral_window if all(window[1][0].meta.spectral_window == first_spectral_window for window in window_sequences): - aligned_axes = tuple(range(len(first_sequence.dimensions))) + aligned_axes = tuple( + range(len(first_sequence.shape if hasattr(first_sequence, "shape") else first_sequence.dimensions)) + ) else: aligned_axes = tuple( i for i, phys_type in enumerate(first_sequence.array_axis_physical_types) if "em.wl" not in phys_type diff --git a/sunraster/instr/tests/test_spice.py b/sunraster/instr/tests/test_spice.py index 67ad5ab..e03ec13 100644 --- a/sunraster/instr/tests/test_spice.py +++ b/sunraster/instr/tests/test_spice.py @@ -300,8 +300,10 @@ def test_read_spice_l2_fits_multiple_rasters_multiple_windows(spice_rasdb_filena assert isinstance(result, READ_SPICE_L2_FITS_RETURN_TYPE) assert set(result.aligned_axes.values()) == {(0, 2, 3)} assert len(result) == 2 - assert all(window.dimensions[0].value == len(filenames) for window in result.values()) - assert all(isinstance(window, RasterSequence) for window in result.values()) + for window in result.values(): + assert isinstance(window, RasterSequence) + data_length = window.shape[0] if hasattr(window, "shape") else window.dimensions[0].value + assert data_length == len(filenames) def test_read_spice_l2_fits_multiple_rasters_single_window(spice_rasdb_filename): @@ -310,8 +312,10 @@ def test_read_spice_l2_fits_multiple_rasters_single_window(spice_rasdb_filename) assert isinstance(result, READ_SPICE_L2_FITS_RETURN_TYPE) assert result.aligned_axes is None assert len(result) == 1 - assert all(window.dimensions[0].value == len(filenames) for window in result.values()) - assert all(isinstance(window, RasterSequence) for window in result.values()) + for window in result.values(): + assert isinstance(window, RasterSequence) + data_length = window.shape[0] if hasattr(window, "shape") else window.dimensions[0].value + assert data_length == len(filenames) def test_read_spice_l2_fits_multiple_sns_multiple_windows(spice_sns_filename): @@ -320,8 +324,10 @@ def test_read_spice_l2_fits_multiple_sns_multiple_windows(spice_sns_filename): assert isinstance(result, READ_SPICE_L2_FITS_RETURN_TYPE) assert set(result.aligned_axes.values()) == {(0, 2, 3)} assert len(result) == 2 - assert all(window.dimensions[0].value == len(filenames) for window in result.values()) - assert all(isinstance(window, SpectrogramSequence) for window in result.values()) + for window in result.values(): + assert isinstance(window, SpectrogramSequence) + data_length = window.shape[0] if hasattr(window, "shape") else window.dimensions[0].value + assert data_length == len(filenames) def test_read_spice_l2_fits_multiple_files_dumbbells(spice_rasdb_filename): @@ -330,8 +336,10 @@ def test_read_spice_l2_fits_multiple_files_dumbbells(spice_rasdb_filename): assert isinstance(result, READ_SPICE_L2_FITS_RETURN_TYPE) assert all(window[0].meta.contains_dumbbell for window in result.values()) assert set(result.aligned_axes.values()) == {tuple(range(4))} - assert all(window.dimensions[0].value == len(filenames) for window in result.values()) - assert all(isinstance(window, SpectrogramSequence) for window in result.values()) + for window in result.values(): + assert isinstance(window, SpectrogramSequence) + data_length = window.shape[0] if hasattr(window, "shape") else window.dimensions[0].value + assert data_length == len(filenames) def test_read_spice_l2_fits_incompatible_files(spice_rasdb_filename, spice_sns_filename): diff --git a/sunraster/spectrogram.py b/sunraster/spectrogram.py index 18a654e..8900afc 100644 --- a/sunraster/spectrogram.py +++ b/sunraster/spectrogram.py @@ -299,7 +299,7 @@ def __str__(self): {"".join(["-"] * len(self.__class__.__name__))} Time Period: {time_period} Instrument axes: {self.instrument_axes} - Pixel dimensions: {self.dimensions.astype(int)} + Pixel dimensions: {self.shape if hasattr(self, "shape") else self.dimensions.astype(int)} Longitude range: {lon_range} Latitude range: {lat_range} Spectral range: {spectral_range} diff --git a/sunraster/spectrogram_sequence.py b/sunraster/spectrogram_sequence.py index a0d13a2..d6931b8 100644 --- a/sunraster/spectrogram_sequence.py +++ b/sunraster/spectrogram_sequence.py @@ -228,7 +228,10 @@ def __init__(self, data_list, common_axis, meta=None): self._spectral_axis_name = SPECTRAL_AXIS_NAME self._set_single_scan_instrument_axes_types() - raster_dimensions = SpectrogramSequence.shape + # TODO: Compatibility with upcoming ndcube 2.3 + raster_dimensions = ( + SpectrogramSequence.shape if hasattr(SpectrogramSequence, "shape") else SpectrogramSequence.dimensions + ) sns_dimensions = SpectrogramSequence.cube_like_dimensions raster_array_axis_physical_types = SpectrogramSequence.array_axis_physical_types sns_array_axis_physical_types = SpectrogramSequence.cube_like_array_axis_physical_types