-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Open
Labels
Description
MaskedArray's min/max methods will raise an exception if its dtype is object. However ndarray min/max methods will work just fine. For example,
>>> test = np.asarray([1,2,3], dtype='object')
>>> test.min()
1
>>> test = np.ma.masked_array([1,2,3], dtype='object', mask=[True, False, False])
>>> test.min()
AttributeError: 'int' object has no attribute 'view'
These methods are useful for cases when having to use Python objects as dtype because your data contains BigInteger and BigDouble (i.e. int and Decimal respectively).
The issue seems to lie in this line in np.ma.core.min
,
result = self.filled(fill_value).min(axis=axis, out=out, **kwargs).view(type(self))
The view call will fail when dtype is object, because min(...) will return e.g. int or Decimal, rather than some type of ndarray.