Re: [Numpy-discussion] asanyarray vs. asarray

2018-10-29 Thread Eric Wieser
The latter - changing the behavior of multiplication breaks the principle.

But this is not the main reason for deprecating matrix - almost all of the
problems I’ve seen have been caused by the way that matrices behave when
sliced. The way that m[i][j] and m[i,j] are different is just one example
of this, the fact that they must be 2d is another.

Matrices behaving differently on multiplication isn’t super different in my
mind to how string arrays fail to multiply at all.

Eric

On Mon, 29 Oct 2018 at 20:54 Ralf Gommers  wrote:

On Mon, Oct 29, 2018 at 4:31 PM Chris Barker  wrote:
>
>> On Fri, Oct 26, 2018 at 7:12 PM, Travis Oliphant 
>> wrote:
>>
>>
>>>  agree that we can stop bashing subclasses in general.   The problem
>>> with numpy subclasses is that they were made without adherence to SOLID:
>>> https://en.wikipedia.org/wiki/SOLID.  In particular the Liskov
>>> substitution principle:
>>> https://en.wikipedia.org/wiki/Liskov_substitution_principle .
>>>
>>
>> ...
>>
>>
>>> did not properly apply them in creating np.matrix which clearly violates
>>> the substitution principle.
>>>
>>
>> So -- could a matrix subclass be made "properly"? or is that an example
>> of something that should not have been a subclass?
>>
>
> The latter - changing the behavior of multiplication breaks the principle.
>
> Ralf
>
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
​
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] asanyarray vs. asarray

2018-10-29 Thread Ralf Gommers
On Mon, Oct 29, 2018 at 4:31 PM Chris Barker  wrote:

> On Fri, Oct 26, 2018 at 7:12 PM, Travis Oliphant 
> wrote:
>
>
>>  agree that we can stop bashing subclasses in general.   The problem with
>> numpy subclasses is that they were made without adherence to SOLID:
>> https://en.wikipedia.org/wiki/SOLID.  In particular the Liskov
>> substitution principle:
>> https://en.wikipedia.org/wiki/Liskov_substitution_principle .
>>
>
> ...
>
>
>> did not properly apply them in creating np.matrix which clearly violates
>> the substitution principle.
>>
>
> So -- could a matrix subclass be made "properly"? or is that an example of
> something that should not have been a subclass?
>

The latter - changing the behavior of multiplication breaks the principle.

Ralf
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] asanyarray vs. asarray

2018-10-29 Thread Chris Barker
On Fri, Oct 26, 2018 at 7:12 PM, Travis Oliphant 
wrote:


>  agree that we can stop bashing subclasses in general.   The problem with
> numpy subclasses is that they were made without adherence to SOLID:
> https://en.wikipedia.org/wiki/SOLID.  In particular the Liskov
> substitution principle:  https://en.wikipedia.org/wiki/
> Liskov_substitution_principle .
>

...


> did not properly apply them in creating np.matrix which clearly violates
> the substitution principle.
>

So -- could a matrix subclass be made "properly"? or is that an example of
something that should not have been a subclass?

-CHB


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion