Skip to content

Commit

Permalink
_data should be the basic "original" data eventually; use consistent …
Browse files Browse the repository at this point in the history
…repr for all LDOs
  • Loading branch information
e-koch committed Sep 2, 2020
1 parent a591ea9 commit 13842d0
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions spectral_cube/lower_dimensional_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def value(self):
"""
Get a unitless numpy array with the mask applied.
"""
return np.asarray(self.filled_data[:])
# return np.asarray(self.filled_data[:])
return np.asarray(self)

def to(self, unit, equivalencies=[], freq=None):
"""
Expand Down Expand Up @@ -255,26 +256,33 @@ def _initial_set_mask(self, mask):
matters: ``self`` must have ``_wcs``, for example.
"""
if mask is None:
mask = BooleanArrayMask(np.isfinite(self.array),
self._wcs, shape=self.array.shape)
mask = BooleanArrayMask(np.isfinite(self._data),
self._wcs, shape=self._data.shape)

elif isinstance(mask, np.ndarray):
if mask.shape != self.array.shape:
if mask.shape != self._data.shape:
raise ValueError("Mask shape must match the {0} shape."
.format(self.__class__.__name__)
)
mask = BooleanArrayMask(mask, self._wcs, shape=self.array.shape)
mask = BooleanArrayMask(mask, self._wcs, shape=self._data.shape)
elif isinstance(mask, MaskBase):
pass
else:
raise TypeError("mask of type {} is not a supported mask "
"type.".format(type(mask)))

# Validate the mask before setting
mask._validate_wcs(new_data=self.array, new_wcs=self._wcs,
mask._validate_wcs(new_data=self._data, new_wcs=self._wcs,
wcs_tolerance=self._wcs_tolerance)

self._mask = mask

def __repr__(self):
prefixstr = '<' + self.__class__.__name__ + ' '
arrstr = np.array2string(self.filled_data[:].value, separator=',',
prefix=prefixstr)
return '{0}{1}{2:s}>'.format(prefixstr, arrstr, self._unitstr)


class Projection(LowerDimensionalObject, SpatialCoordMixinClass,
MaskableArrayMixinClass, BeamMixinClass):
Expand Down Expand Up @@ -677,12 +685,6 @@ def __new__(cls, value, unit=None, dtype=None, copy=True, wcs=None,

return self

def __repr__(self):
prefixstr = '<' + self.__class__.__name__ + ' '
arrstr = np.array2string(self.filled_data[:].value, separator=',',
prefix=prefixstr)
return '{0}{1}{2:s}>'.format(prefixstr, arrstr, self._unitstr)

@staticmethod
def from_hdu(hdu):
'''
Expand Down

0 comments on commit 13842d0

Please sign in to comment.