Skip to content

Commit

Permalink
adding deprecate messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hayesla committed Apr 24, 2024
1 parent cfa0117 commit 12f59f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sunpy/map/mapbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def __init__(self, data, header, plot_settings=None, **kwargs):
# TODO: This should be a function of the header, not of the map
self._validate_meta()

if self.dtype == np.uint8:
if self.data.dtype == np.uint8:
norm = None
else:
# Put import here to reduce sunpy.map import time
Expand Down Expand Up @@ -286,7 +286,7 @@ def _text_summary(self):
meas=measurement, wave=wave,
date=self.date.strftime(TIME_FORMAT),
dt=dt,
dim=u.Quantity(self.dimensions),
dim=u.Quantity(self.shape),
scale=u.Quantity(self.scale),
coord=self._coordinate_frame_name,
refpix=u.Quantity(self.reference_pixel),
Expand Down
16 changes: 9 additions & 7 deletions sunpy/map/mixins/mapdeprecate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,55 @@ class MapDeprecateMixin:
"""

# Some numpy extraction
@deprecated(since="6.1", message="this will be removed.", alternative="sunpy.map.GenericMap.shape")

@property
@deprecated(since="6.1", message=".dimension will be removed in 6.1. Use sunpy.map.GenericMap.shape instead")
def dimensions(self):
"""
The dimensions of the array (x axis first, y axis second).
"""
return PixelPair(*u.Quantity(np.flipud(self.data.shape), 'pixel'))


@deprecated(since="6.1", message="this will be removed.", alternative="sunpy.map.GenericMap.data.dtype")
@property
@deprecated(since="6.1", message="sunpy.map.GenericMap.dtype will be removed in 6.1, use sunpy.map.GenericMap.data.dtype instead")
def dtype(self):
"""
The `numpy.dtype` of the array of the map.
"""
return self.data.dtype

@deprecated(since="6.1", message="this will be removed.", alternative="sunpy.map.GenericMap.data.ndim()")
@property
@deprecated(since="6.1", message="sunpy.map.GenericMap.ndim will be removed in 6.1, use sunpy.map.GenericMap.data.ndim() instead")
def ndim(self):
"""
The value of `numpy.ndarray.ndim` of the data array of the map.
"""
return self.data.ndim

@deprecated(since="6.1", message="this will be removed.", alternative="sunpy.map.GenericMap.data.std()")

@deprecated(since="6.1", message="sunpy.map.GenericMap.std() will be removed in 6.1, use sunpy.map.GenericMap.data.std() instead")
def std(self, *args, **kwargs):
"""
Calculate the standard deviation of the data array, ignoring NaNs.
"""
return np.nanstd(self.data, *args, **kwargs)

@deprecated(since="6.1", message="this will be removed.", alternative="sunpy.map.GenericMap.data.mean()")
@deprecated(since="6.1", message="sunpy.map.GenericMap.mean() will be removed in 6.1, use sunpy.map.GenericMap.data.mean() instead")
def mean(self, *args, **kwargs):
"""
Calculate the mean of the data array, ignoring NaNs.
"""
return np.nanmean(self.data, *args, **kwargs)

@deprecated(since="6.1", message="this will be removed.", alternative="sunpy.map.GenericMap.data.min()")
@deprecated(since="6.1", message="sunpy.map.GenericMap.min() will be removed in 6.1, use sunpy.map.GenericMap.data.min() instead")
def min(self, *args, **kwargs):
"""
Calculate the minimum value of the data array, ignoring NaNs.
"""
return np.nanmin(self.data, *args, **kwargs)

@deprecated(since="6.1", message="this will be removed.", alternative="sunpy.map.GenericMap.data.max()")
@deprecated(since="6.1", message="sunpy.map.GenericMap.max() will be removed in 6.1, use sunpy.map.GenericMap.data.max() instead")
def max(self, *args, **kwargs):
"""
Calculate the maximum value of the data array, ignoring NaNs.
Expand Down

0 comments on commit 12f59f9

Please sign in to comment.