diff --git a/fletcher/base.py b/fletcher/base.py index 19b41554..90bed7f7 100644 --- a/fletcher/base.py +++ b/fletcher/base.py @@ -20,7 +20,6 @@ from pandas.core.dtypes.dtypes import ExtensionDtype, register_extension_dtype from fletcher._algorithms import ( - extract_isnull_bytemap, kurt_op, max_op, median_op, @@ -432,14 +431,6 @@ def __len__(self) -> int: """ return self.shape[0] - def isna(self) -> np.ndarray: - """ - Boolean NumPy array indicating if each value is missing. - - This should return a 1-D array the same length as 'self'. - """ - return extract_isnull_bytemap(self.data) - @property def base(self) -> Union[pa.Array, pa.ChunkedArray]: """Return base object of the underlying data.""" @@ -531,6 +522,13 @@ def __array_ufunc__(self, ufunc, method: str, *inputs, **kwargs): raise NotImplementedError( f"Only method == '__call__' is supported in ufuncs, not '{method}'" ) + if len(inputs) == 1: + if getattr(ufunc, "__name__") == "isnan": + return self.isna() + else: + raise NotImplementedError( + f"ufunc with single input not supported: {ufunc}" + ) if len(inputs) != 2: raise NotImplementedError("Only ufuncs with a second input are supported") if len(kwargs) > 0: @@ -843,6 +841,14 @@ def value_counts(self, dropna: bool = True) -> "pd.Series": return pd.Series(counts, index=index) + def isna(self) -> np.ndarray: + """ + Boolean NumPy array indicating if each value is missing. + + This should return a 1-D array the same length as 'self'. + """ + return np.array(self.data.is_null()) + class FletcherContinuousArray(FletcherBaseArray): """Pandas ExtensionArray implementation backed by Apache Arrow's pyarrow.Array."""