Skip to content

Commit

Permalink
Implements deprecation warnings on dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
CyclingNinja authored and nabobalis committed Apr 24, 2024
1 parent 59d2e30 commit e186d53
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ndcube/ndcollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def aligned_dimensions(self):
If there are no aligned axes, returns None.
"""
if self.aligned_axes is not None:
return np.asanyarray(self[self._first_key].dimensions, dtype=object)[
return np.asanyarray(self[self._first_key].shape, dtype=object)[
np.array(self.aligned_axes[self._first_key])
]

Expand Down Expand Up @@ -178,7 +178,7 @@ def _generate_collection_getitems(self, item):
# and drop any aligned axes that are sliced out.

# First, define empty lists of slice items to be applied to each cube in collection.
collection_items = [[slice(None)] * len(self[key].dimensions) for key in self]
collection_items = [[slice(None)] * len(self[key].shape) for key in self]
# Define empty list to hold aligned axes dropped by the slicing.
drop_aligned_axes_indices = []

Expand Down Expand Up @@ -275,7 +275,7 @@ def update(self, *args):
first_old_aligned_axes = self.aligned_axes[self._first_key] if self.aligned_axes is not None else None
first_new_aligned_axes = new_aligned_axes[new_keys[0]] if new_aligned_axes is not None else None
collection_utils.assert_aligned_axes_compatible(
self[self._first_key].dimensions, new_data[0].dimensions,
self[self._first_key].shape, new_data[0].shape,
first_old_aligned_axes, first_new_aligned_axes
)
# Update collection
Expand Down
2 changes: 1 addition & 1 deletion ndcube/ndcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ def combined_wcs(self):
CompoundLowLevelWCS(self.wcs.low_level_wcs, self._extra_coords.wcs, mapping=mapping)
)

@deprecated(version='3.0.0', reason='Replaced by ndcube.NDCube.shape')
@property
def dimensions(self):
warnings.warn("Replaced by ndcube.NDCube.shape", NDCubeDeprecationWarning)
return u.Quantity(self.data.shape, unit=u.pix)

@property
Expand Down
3 changes: 3 additions & 0 deletions ndcube/ndcube_sequence.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import copy
import numbers
import textwrap
import warnings

import numpy as np

import astropy.units as u

from ndcube import utils
from ndcube.utils.exceptions import NDCubeDeprecationWarning
from ndcube.visualization.descriptor import PlotterDescriptor


Expand Down Expand Up @@ -46,6 +48,7 @@ def dimensions(self):
"""
The length of each axis including the sequence axis.
"""
warnings.warn("Replaced by ndcube.NDCubeSequence.shape", NDCubeDeprecationWarning)
return tuple([d * u.pix for d in self._shape])

@property
Expand Down

0 comments on commit e186d53

Please sign in to comment.