[docs]@singledispatchdefis_masked(x:Any)->bool:""" Determine whether an array-like object contains masked values, equivalent to those in NumPy's ``MaskedArray`` class. Args: x: Any array-like object. Returns: Whether ``x`` contains masked values. """raiseNotImplementedError("'is_masked("+str(type(x))+")' has not yet been implemented")
# If scipy is installed, we add all the methods for the various scipy.sparse# matrices. Currently, it seems like scipy's sparse matrices are not intended# to be masked, seeing as how any subsetting discards the masks, e.g.,## >>> y = (scipy.sparse.random(1000, 200, 0.1)).tocsr()# >>> y.data = numpy.ma.MaskedArray(y.data, y.data > 0.5)# >>> y[0:5,:].data # gives back a regulary NumPy array.## So we won't bother capturing the mask state (as of scipy 1.11.1).ifis_package_installed("scipy"):importscipy.sparseassp