[Numpy-discussion] asarray/anyarray; matrix/subclass

Stephan Hoyer shoyer at gmail.com
Sat Nov 10 17:39:15 EST 2018


On Sat, Nov 10, 2018 at 2:22 PM Hameer Abbasi <einstein.edison at gmail.com>
wrote:

> To summarize, I think these are our options:
>
> 1. Change the behavior of np.anyarray() to check for an __anyarray__()
> protocol. Change np.matrix.__anyarray__() to return a base numpy array
> (this is a minor backwards compatibility break, but probably for the best).
> Start issuing a FutureWarning for any MaskedArray operations that violate
> Liskov and add a skipna argument that in the future will default to
> skipna=False.
>
> 2. Introduce a new coercion function, e.g., np.duckarray(). This is the
> easiest option because we don't need to cleanup NumPy's existing ndarray
> subclasses.
>
>
> My vote is still for 1. I don’t have an issue for PyData/Sparse depending
> on recent-ish NumPy versions — It’ll need a lot of the recent protocols
> anyway, although I could be convinced otherwise if major package devs
> (scikits, SciPy, Dask) were to weigh in and say they’ll jump on it (which
> seems unlikely given SciPy’s policy to support old NumPy versions).
>

I agree that option (1) is fine for PyData/sparse. The bigger issue is that
this change should be conditional on making breaking changes (at least
raising FutureWarning for now) to np.ma.MaskedArray.

I don't know how people who currently use MaskedArray would feel about
that. I would love to hear their thoughts.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20181110/203d5ab0/attachment.html>


More information about the NumPy-Discussion mailing list