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

2018-11-10 Thread Eric Firing
On 2018/11/10 12:39 PM, Stephan Hoyer wrote: On Sat, Nov 10, 2018 at 2:22 PM Hameer Abbasi > wrote: To summarize, I think these are our options: 1. Change the behavior of np.anyarray() to check for an __anyarray__() protocol. Change np.m

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

2018-11-10 Thread Charles R Harris
On Sat, Nov 10, 2018 at 2:15 PM Eric Wieser wrote: > > If the only way MaskedArray violates Liskov is in terms of NA skipping > aggregations by default, then this might be viable > > One of the ways to fix these liskov substitution problems is just to > introduce more base classes - for instance,

Re: [Numpy-discussion] Should unique types of all arguments be passed on in __array_function__?

2018-11-10 Thread Hameer Abbasi
In that case, ignore my comment. :) Best Regards, Hameer Abbasi > On Saturday, Nov 10, 2018 at 11:52 PM, Stephan Hoyer (mailto:sho...@gmail.com)> wrote: > On Sat, Nov 10, 2018 at 2:08 PM Hameer Abbasi (mailto:einstein.edi...@gmail.com)> wrote: > > I agree with Stephan here, other than the fact

Re: [Numpy-discussion] Should unique types of all arguments be passed on in __array_function__?

2018-11-10 Thread Stephan Hoyer
On Sat, Nov 10, 2018 at 2:08 PM Hameer Abbasi wrote: > I agree with Stephan here, other than the fact that ndarray should be in > the list of types. I can think of many cases in PyData/Sparse where I dont > want to allow mixed inputs, but maybe that’s a tangential discussion. > To be clear: ndar

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

2018-11-10 Thread Marten van Kerkwijk
On Sat, Nov 10, 2018 at 5:39 PM Stephan Hoyer wrote: > On Sat, Nov 10, 2018 at 2:22 PM Hameer Abbasi > 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 ba

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

2018-11-10 Thread Stephan Hoyer
On Sat, Nov 10, 2018 at 2:22 PM Hameer Abbasi 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,

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

2018-11-10 Thread Hameer Abbasi
> On Saturday, Nov 10, 2018 at 9:16 PM, Stephan Hoyer (mailto:sho...@gmail.com)> wrote: > On Sat, Nov 10, 2018 at 9:49 AM Marten van Kerkwijk > mailto:m.h.vankerkw...@gmail.com)> wrote: > > Hi Hameer, > > > > I do not think we should change `asanyarray` itself to special-case matrix; > > rather

Re: [Numpy-discussion] Should unique types of all arguments be passed on in __array_function__?

2018-11-10 Thread Hameer Abbasi
> On Saturday, Nov 10, 2018 at 6:59 PM, Marten van Kerkwijk > mailto:m.h.vankerkw...@gmail.com)> wrote: > > > More broadly, it is only necessary to reject an argument type at the > > __array_function__ level if it defines __array_function__ itself, because > > that’s the only case where it woul

Re: [Numpy-discussion] Prep for NumPy 1.16.0 branch

2018-11-10 Thread Stephan Hoyer
On Tue, Nov 6, 2018 at 8:09 PM Stephan Hoyer wrote: > On Tue, Nov 6, 2018 at 6:08 PM Stefan van der Walt > wrote: > >> On Sun, 04 Nov 2018 17:16:12 -0800, Stephan Hoyer wrote: >> > On Sun, Nov 4, 2018 at 10:32 AM Marten van Kerkwijk < >> > m.h.vankerkw...@gmail.com> wrote: >> > >> > > For `__arr

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

2018-11-10 Thread Eric Wieser
> If the only way MaskedArray violates Liskov is in terms of NA skipping aggregations by default, then this might be viable One of the ways to fix these liskov substitution problems is just to introduce more base classes - for instance, if we had an `NDContainer` base class with only slicing suppo

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

2018-11-10 Thread Stephan Hoyer
On Sat, Nov 10, 2018 at 9:49 AM Marten van Kerkwijk < m.h.vankerkw...@gmail.com> wrote: > Hi Hameer, > > I do not think we should change `asanyarray` itself to special-case > matrix; rather, we could start converting `asarray` to `asanyarray` and > solve the problems that produces for matrices in

Re: [Numpy-discussion] Should unique types of all arguments be passed on in __array_function__?

2018-11-10 Thread Marten van Kerkwijk
> More broadly, it is only necessary to reject an argument type at the > __array_function__ level if it defines __array_function__ itself, because > that’s the only case where it would make a difference to return > NotImplemented rather than trying (and failing) to call the overriden > function imp

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

2018-11-10 Thread Marten van Kerkwijk
Hi Hameer, I do not think we should change `asanyarray` itself to special-case matrix; rather, we could start converting `asarray` to `asanyarray` and solve the problems that produces for matrices in `matrix` itself (e.g., by overriding the relevant function with `__array_function__`). I think th

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

2018-11-10 Thread Matti Picus
On 9/11/18 5:09 pm, Nathaniel Smith wrote: On Fri, Nov 9, 2018 at 4:59 PM, Stephan Hoyer wrote: On Fri, Nov 9, 2018 at 6:46 PM Nathaniel Smith wrote: But matrix isn't the only problem with asanyarray. np.ma also violates Liskov. No doubt there are other problematic ndarray subclasses out ther