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

Stephan Hoyer shoyer at gmail.com
Fri Nov 9 19:59:32 EST 2018


On Fri, Nov 9, 2018 at 6:46 PM Nathaniel Smith <njs at pobox.com> wrote:

> But matrix isn't the only problem with asanyarray. np.ma also violates
> Liskov. No doubt there are other problematic ndarray subclasses out
> there too...
>

Please forgive my ignorance (I don't really use mask arrays), but how
specifically do masked arrays violate Liskov? In most cases shouldn't they
work the same as base numpy arrays, except with operations keeping track of
masks?

I'm sure there are some cases where masked arrays have different semantics
than NumPy arrays, but are any of these intentional?

I would guess that the worst current violation is that there is a risk of
losing mask information in some operations, but implementing
__array_function__ would presumably make it possible to fix most of these.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20181109/b8e9b46c/attachment.html>


More information about the NumPy-Discussion mailing list