Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Stefan Reiterer

Yeah Im aware of that, thats the reason why I suggested a warning level as an alternative.

Setting no warnings as default would avoid breaking existing code.


Gesendet:Sonntag, 08. Februar 2015 um 22:08 Uhr
Von:Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
An:Discussion of Numerical Python numpy-discussion@scipy.org
Betreff:Re: [Numpy-discussion] Silent Broadcasting considered harmful

I personally use Octave and/or Numpy for several years now and never ever needed braodcasting.

But since it is still there there will be many users who need it, there will be some use for it.



Uhm, yeah, there is some use for it. Im all for explicit over implicit, but personally current broadcasting rules have never bothered me, certainly not to the extent of justifying massive backwards compatibility violations. Take It from someone who relies on broadcasting for every other line of code.





___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread josef.pktd
On Sun, Feb 8, 2015 at 4:08 PM, Eelco Hoogendoorn
hoogendoorn.ee...@gmail.com wrote:
 I personally use Octave and/or Numpy  for several years now and never ever
 needed braodcasting.
 But since it is still there there will be many users who need it, there will
 be some use for it.

 Uhm, yeah, there is some use for it. Im all for explicit over implicit, but
 personally current broadcasting rules have never bothered me, certainly not
 to the extent of justifying massive backwards compatibility violations. Take
 It from someone who relies on broadcasting for every other line of code.


 On Sun, Feb 8, 2015 at 10:03 PM, Stefan Reiterer dom...@gmx.net wrote:

 Hi!

 As shortly discussed on github:
 https://github.com/numpy/numpy/issues/5541

 I personally think that silent Broadcasting is not a good thing. I had
 recently a lot
 of trouble with row and column vectors which got bradcastet toghether
 altough it was
 more annoying than useful, especially since I had to search deep down into
 the code to find out
 that the problem was nothing else than Broadcasting...

 I personally use Octave and/or Numpy  for several years now and never ever
 needed braodcasting.
 But since it is still there there will be many users who need it, there
 will be some use for it.

 So I suggest that the best would be to throw warnings when arrays get
 Broadcasted like
 Octave do. Python warnings can be catched and handled, that would be a
 great benefit.

 Another idea would to provide warning levels for braodcasting, e.g
 0 = Never, 1=Warn once, 2=Warn always, 3 = Forbid aka throw exception,
 with 0 as default.
 This would avoid breaking other code, and give the user some control over
 braodcasting.

 Kind regards,
 Stefan


Numpy broadcasting is the greatest feature of numpy !!!

It just takes a bit of getting used to coming from another matrix language.


Josef
what 3!?





 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion



 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Charles R Harris
On Sun, Feb 8, 2015 at 2:14 PM, Stefan Reiterer dom...@gmx.net wrote:

 Yeah I'm aware of that, that's the reason why I suggested a warning level
 as an alternative.
 Setting no warnings as default would avoid breaking existing code.
  *Gesendet:* Sonntag, 08. Februar 2015 um 22:08 Uhr
 *Von:* Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
 *An:* Discussion of Numerical Python numpy-discussion@scipy.org
 *Betreff:* Re: [Numpy-discussion] Silent Broadcasting considered harmful
  I personally use Octave and/or Numpy  for several years now and never
 ever needed braodcasting.
 But since it is still there there will be many users who need it, there
 will be some use for it.

 Uhm, yeah, there is some use for it. Im all for explicit over implicit,
 but personally current broadcasting rules have never bothered me, certainly
 not to the extent of justifying massive backwards compatibility violations.
 Take It from someone who relies on broadcasting for every other line of
 code.



It's how numpy works. It would be like getting into your car and being
warned that it has wheels.

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Stefan Reiterer
I dont think this is a good comparison, especially since broadcasting is a feature not a necessity...

Its more like turning off/on driving assistance.



And as already mentioned: other matrix languages also allow it, but they warn about its usage.

This has indeed its merits.



Gesendet:Sonntag, 08. Februar 2015 um 22:17 Uhr
Von:Charles R Harris charlesr.har...@gmail.com
An:Discussion of Numerical Python numpy-discussion@scipy.org
Betreff:Re: [Numpy-discussion] Silent Broadcasting considered harmful




On Sun, Feb 8, 2015 at 2:14 PM, Stefan Reiterer dom...@gmx.net wrote:





Yeah Im aware of that, thats the reason why I suggested a warning level as an alternative.

Setting no warnings as default would avoid breaking existing code.


Gesendet:Sonntag, 08. Februar 2015 um 22:08 Uhr
Von:Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
An:Discussion of Numerical Python numpy-discussion@scipy.org
Betreff:Re: [Numpy-discussion] Silent Broadcasting considered harmful

I personally use Octave and/or Numpy for several years now and never ever needed braodcasting. 

But since it is still there there will be many users who need it, there will be some use for it.
 


 

Uhm, yeah, there is some use for it. Im all for explicit over implicit, but personally current broadcasting rules have never bothered me, certainly not to the extent of justifying massive backwards compatibility violations. Take It from someone who relies on broadcasting for every other line of code.
 


 








Its how numpy works. It would be like getting into your car and being warned that it has wheels.


Chuck



___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion


___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Matthew Brett
Hi,

On Sun, Feb 8, 2015 at 1:24 PM, Stefan Reiterer dom...@gmx.net wrote:
 I don't think this is a good comparison, especially since broadcasting is a
 feature not a necessity ...
 It's more like turning off/on driving assistance.

 And as already mentioned: other matrix languages also allow it, but they
 warn about it's usage.
 This has indeed it's merits.
 Gesendet: Sonntag, 08. Februar 2015 um 22:17 Uhr
 Von: Charles R Harris charlesr.har...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful


 On Sun, Feb 8, 2015 at 2:14 PM, Stefan Reiterer dom...@gmx.net wrote:

 Yeah I'm aware of that, that's the reason why I suggested a warning level
 as an alternative.
 Setting no warnings as default would avoid breaking existing code.
 Gesendet: Sonntag, 08. Februar 2015 um 22:08 Uhr
 Von: Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful
  I personally use Octave and/or Numpy  for several years now and never
  ever needed braodcasting.
 But since it is still there there will be many users who need it, there
 will be some use for it.

 Uhm, yeah, there is some use for it. Im all for explicit over implicit,
 but personally current broadcasting rules have never bothered me, certainly
 not to the extent of justifying massive backwards compatibility violations.
 Take It from someone who relies on broadcasting for every other line of
 code.



 It's how numpy works. It would be like getting into your car and being
 warned that it has wheels.

I agree.  I knew about broadcasting as soon as I started using numpy,
so I can honestly say this has never surprised me.

There are other major incompatibilities between Matlab and numpy, such
as 0-based indices, and array views.

I think the matrix class would solve this for you, although most of us
don't use that very much.

It would be a major change to warn about broadcasting by default, and
it would be odd, because we encourage broadcasting in our docs and
common code, rightly I think.   The naive user would not know to turn
on this warning.   I could imagine a non-default warning, but I doubt
it would be much used.

Cheers,

Matthew
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Simon Wood
On Sun, Feb 8, 2015 at 4:24 PM, Stefan Reiterer dom...@gmx.net wrote:

 I don't think this is a good comparison, especially since broadcasting is
 a feature not a necessity ...
 It's more like turning off/on driving assistance.

 And as already mentioned: other matrix languages also allow it, but they
 warn about it's usage.
 This has indeed it's merits.
  *Gesendet:* Sonntag, 08. Februar 2015 um 22:17 Uhr
 *Von:* Charles R Harris charlesr.har...@gmail.com
 *An:* Discussion of Numerical Python numpy-discussion@scipy.org
 *Betreff:* Re: [Numpy-discussion] Silent Broadcasting considered harmful


 On Sun, Feb 8, 2015 at 2:14 PM, Stefan Reiterer dom...@gmx.net wrote:

   Yeah I'm aware of that, that's the reason why I suggested a warning
 level as an alternative.
 Setting no warnings as default would avoid breaking existing code.
  *Gesendet:* Sonntag, 08. Februar 2015 um 22:08 Uhr
 *Von:* Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
 *An:* Discussion of Numerical Python numpy-discussion@scipy.org
 *Betreff:* Re: [Numpy-discussion] Silent Broadcasting considered harmful
  I personally use Octave and/or Numpy  for several years now and never
 ever needed braodcasting.
 But since it is still there there will be many users who need it, there
 will be some use for it.

  Uhm, yeah, there is some use for it. Im all for explicit over implicit,
 but personally current broadcasting rules have never bothered me, certainly
 not to the extent of justifying massive backwards compatibility violations.
 Take It from someone who relies on broadcasting for every other line of
 code.



 It's how numpy works. It would be like getting into your car and being
 warned that it has wheels.

 Chuck
   ___ NumPy-Discussion
 mailing list NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


I agree, I do not think this is a good comparison. All cars have wheels,
there are no surprises there. This is more like a car that decides to do
something completely different from everything that you learned about in
driving school.

I find the broadcasting aspect of Numpy a turn off. If I go to add a 1x3
vector to a 3x1 vector, I want the program to warn me or error out. I don't
want it to do something under the covers that has no mathematical basis or
definition. Also, Octave may provide a warning, but Matlab errors
out...Matrix dimensions must agree. Which they must, at least in my world.
___

 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Warren Focke
On Sun, 8 Feb 2015, Stefan Reiterer wrote:

 And as already mentioned: other matrix languages also allow it, but they warn 
 about it's usage.
 This has indeed it's merits.

numpy isn't a matrix language. They're arrays. Storing numbers that you are 
thinking of as a vector in an array doesn't turn the array into a vector. There 
are linear algebra modules; I haven't used them.

w

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Matthew Brett
Hi,

On Sun, Feb 8, 2015 at 1:39 PM, Simon Wood sgwoo...@gmail.com wrote:


 On Sun, Feb 8, 2015 at 4:24 PM, Stefan Reiterer dom...@gmx.net wrote:

 I don't think this is a good comparison, especially since broadcasting is
 a feature not a necessity ...
 It's more like turning off/on driving assistance.

 And as already mentioned: other matrix languages also allow it, but they
 warn about it's usage.
 This has indeed it's merits.
 Gesendet: Sonntag, 08. Februar 2015 um 22:17 Uhr
 Von: Charles R Harris charlesr.har...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful


 On Sun, Feb 8, 2015 at 2:14 PM, Stefan Reiterer dom...@gmx.net wrote:

 Yeah I'm aware of that, that's the reason why I suggested a warning level
 as an alternative.
 Setting no warnings as default would avoid breaking existing code.
 Gesendet: Sonntag, 08. Februar 2015 um 22:08 Uhr
 Von: Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful
  I personally use Octave and/or Numpy  for several years now and never
  ever needed braodcasting.
 But since it is still there there will be many users who need it, there
 will be some use for it.

 Uhm, yeah, there is some use for it. Im all for explicit over implicit,
 but personally current broadcasting rules have never bothered me, certainly
 not to the extent of justifying massive backwards compatibility violations.
 Take It from someone who relies on broadcasting for every other line of
 code.



 It's how numpy works. It would be like getting into your car and being
 warned that it has wheels.

 Chuck
 ___ NumPy-Discussion mailing
 list NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


 I agree, I do not think this is a good comparison. All cars have wheels,
 there are no surprises there. This is more like a car that decides to do
 something completely different from everything that you learned about in
 driving school.

 I find the broadcasting aspect of Numpy a turn off. If I go to add a 1x3
 vector to a 3x1 vector, I want the program to warn me or error out. I don't
 want it to do something under the covers that has no mathematical basis or
 definition. Also, Octave may provide a warning, but Matlab errors
 out...Matrix dimensions must agree. Which they must, at least in my world.

In a previous life, many of us were very serious users of Matlab,
myself included.

Matlab / Octave have a model of the array as being a matrix, but numpy
does not have this model.   There is a Matrix class that implements
this model, but usually experienced numpy users either never use this,
or stop using it.

I can only say - subjectively I know - that I did not personally
suffer from this when I switched to numpy from Matlab, partly because
I was fully aware that I was going to have to change the way I thought
about arrays, for various reasons.  After a short while getting used
to it, broadcasting seemed like a huge win.  I guess the fact that
other languages have adopted it means that others have had the same
experience.

So, numpy is not a straight replacement of Matlab, in terms of design.

To pursue the analogy, you have learned to drive an automatic car.
Numpy is a stick-shift car.  There are good reasons to prefer a
stick-shift, but it does mean that someone trained on an automatic is
bound to feel that a stick-shift is uncomfortable for a while.

Best,

Matthew
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Stefan Reiterer
Hi!



As shortly discussed on github:

https://github.com/numpy/numpy/issues/5541



I personally think that silent Broadcasting is not a good thing. I had recently a lot

of trouble with row and column vectors which got bradcastet toghether altough it was

more annoying than useful, especially since I had to search deep down into the code to find out

that the problem was nothing else than Broadcasting...



I personally use Octave and/or Numpy for several years now and never ever needed braodcasting.

But since it is still there there will be many users who need it, there will be some use for it.



So I suggest that the best would be to throw warnings when arrays get Broadcasted like

Octave do. Python warnings can be catched and handled, that would be a great benefit.



Another idea would to provide warning levels for braodcasting, e.g

0 = Never, 1=Warn once, 2=Warn always, 3 = Forbid aka throw exception,

with 0 as default.

This would avoid breaking other code, and give the user some control over braodcasting.



Kind regards,

Stefan




___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Eelco Hoogendoorn
 I personally use Octave and/or Numpy  for several years now and never
ever needed braodcasting.
But since it is still there there will be many users who need it, there
will be some use for it.

Uhm, yeah, there is some use for it. Im all for explicit over implicit, but
personally current broadcasting rules have never bothered me, certainly not
to the extent of justifying massive backwards compatibility violations.
Take It from someone who relies on broadcasting for every other line of
code.


On Sun, Feb 8, 2015 at 10:03 PM, Stefan Reiterer dom...@gmx.net wrote:

 Hi!

 As shortly discussed on github:
 https://github.com/numpy/numpy/issues/5541

 I personally think that silent Broadcasting is not a good thing. I had
 recently a lot
 of trouble with row and column vectors which got bradcastet toghether
 altough it was
 more annoying than useful, especially since I had to search deep down into
 the code to find out
 that the problem was nothing else than Broadcasting...

 I personally use Octave and/or Numpy  for several years now and never
 ever needed braodcasting.
 But since it is still there there will be many users who need it, there
 will be some use for it.

 So I suggest that the best would be to throw warnings when arrays get
 Broadcasted like
 Octave do. Python warnings can be catched and handled, that would be a
 great benefit.

 Another idea would to provide warning levels for braodcasting, e.g
 0 = Never, 1=Warn once, 2=Warn always, 3 = Forbid aka throw exception,
 with 0 as default.
 This would avoid breaking other code, and give the user some control over
 braodcasting.

 Kind regards,
 Stefan



 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Stefan Reiterer
Actually I use numpy for several years now, and I love it.

The reason that I think silent broadcasting of sums is bad

comes simply from the fact, that I had moretrouble with it, than it helped me.



I wont stop using numpy because of that, but I think this behavior may backfire,

and thats the reason I started this discussion. Till now the only way out of the misery

is to make proper unit tests, and to be careful as hell with dimensions and shape checks.



Providing optional warnings just would be an elegant way out of this.



Cheers,

Stefan



Gesendet:Sonntag, 08. Februar 2015 um 22:56 Uhr
Von:Matthew Brett matthew.br...@gmail.com
An:Discussion of Numerical Python numpy-discussion@scipy.org
Betreff:Re: [Numpy-discussion] Silent Broadcasting considered harmful

Hi,

On Sun, Feb 8, 2015 at 1:39 PM, Simon Wood sgwoo...@gmail.com wrote:


 On Sun, Feb 8, 2015 at 4:24 PM, Stefan Reiterer dom...@gmx.net wrote:

 I dont think this is a good comparison, especially since broadcasting is
 a feature not a necessity ...
 Its more like turning off/on driving assistance.

 And as already mentioned: other matrix languages also allow it, but they
 warn about its usage.
 This has indeed its merits.
 Gesendet: Sonntag, 08. Februar 2015 um 22:17 Uhr
 Von: Charles R Harris charlesr.har...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful


 On Sun, Feb 8, 2015 at 2:14 PM, Stefan Reiterer dom...@gmx.net wrote:

 Yeah Im aware of that, thats the reason why I suggested a warning level
 as an alternative.
 Setting no warnings as default would avoid breaking existing code.
 Gesendet: Sonntag, 08. Februar 2015 um 22:08 Uhr
 Von: Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful
  I personally use Octave and/or Numpy for several years now and never
  ever needed braodcasting.
 But since it is still there there will be many users who need it, there
 will be some use for it.

 Uhm, yeah, there is some use for it. Im all for explicit over implicit,
 but personally current broadcasting rules have never bothered me, certainly
 not to the extent of justifying massive backwards compatibility violations.
 Take It from someone who relies on broadcasting for every other line of
 code.



 Its how numpy works. It would be like getting into your car and being
 warned that it has wheels.

 Chuck
 ___ NumPy-Discussion mailing
 list NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


 I agree, I do not think this is a good comparison. All cars have wheels,
 there are no surprises there. This is more like a car that decides to do
 something completely different from everything that you learned about in
 driving school.

 I find the broadcasting aspect of Numpy a turn off. If I go to add a 1x3
 vector to a 3x1 vector, I want the program to warn me or error out. I dont
 want it to do something under the covers that has no mathematical basis or
 definition. Also, Octave may provide a warning, but Matlab errors
 out...Matrix dimensions must agree. Which they must, at least in my world.

In a previous life, many of us were very serious users of Matlab,
myself included.

Matlab / Octave have a model of the array as being a matrix, but numpy
does not have this model. There is a Matrix class that implements
this model, but usually experienced numpy users either never use this,
or stop using it.

I can only say - subjectively I know - that I did not personally
suffer from this when I switched to numpy from Matlab, partly because
I was fully aware that I was going to have to change the way I thought
about arrays, for various reasons. After a short while getting used
to it, broadcasting seemed like a huge win. I guess the fact that
other languages have adopted it means that others have had the same
experience.

So, numpy is not a straight replacement of Matlab, in terms of design.

To pursue the analogy, you have learned to drive an automatic car.
Numpy is a stick-shift car. There are good reasons to prefer a
stick-shift, but it does mean that someone trained on an automatic is
bound to feel that a stick-shift is uncomfortable for a while.

Best,

Matthew
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread josef.pktd
On Sun, Feb 8, 2015 at 4:56 PM, Matthew Brett matthew.br...@gmail.com wrote:
 Hi,

 On Sun, Feb 8, 2015 at 1:39 PM, Simon Wood sgwoo...@gmail.com wrote:


 On Sun, Feb 8, 2015 at 4:24 PM, Stefan Reiterer dom...@gmx.net wrote:

 I don't think this is a good comparison, especially since broadcasting is
 a feature not a necessity ...
 It's more like turning off/on driving assistance.

 And as already mentioned: other matrix languages also allow it, but they
 warn about it's usage.
 This has indeed it's merits.
 Gesendet: Sonntag, 08. Februar 2015 um 22:17 Uhr
 Von: Charles R Harris charlesr.har...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful


 On Sun, Feb 8, 2015 at 2:14 PM, Stefan Reiterer dom...@gmx.net wrote:

 Yeah I'm aware of that, that's the reason why I suggested a warning level
 as an alternative.
 Setting no warnings as default would avoid breaking existing code.
 Gesendet: Sonntag, 08. Februar 2015 um 22:08 Uhr
 Von: Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful
  I personally use Octave and/or Numpy  for several years now and never
  ever needed braodcasting.
 But since it is still there there will be many users who need it, there
 will be some use for it.

 Uhm, yeah, there is some use for it. Im all for explicit over implicit,
 but personally current broadcasting rules have never bothered me, certainly
 not to the extent of justifying massive backwards compatibility violations.
 Take It from someone who relies on broadcasting for every other line of
 code.



 It's how numpy works. It would be like getting into your car and being
 warned that it has wheels.

 Chuck
 ___ NumPy-Discussion mailing
 list NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


 I agree, I do not think this is a good comparison. All cars have wheels,
 there are no surprises there. This is more like a car that decides to do
 something completely different from everything that you learned about in
 driving school.

 I find the broadcasting aspect of Numpy a turn off. If I go to add a 1x3
 vector to a 3x1 vector, I want the program to warn me or error out. I don't
 want it to do something under the covers that has no mathematical basis or
 definition. Also, Octave may provide a warning, but Matlab errors
 out...Matrix dimensions must agree. Which they must, at least in my world.

 In a previous life, many of us were very serious users of Matlab,
 myself included.

 Matlab / Octave have a model of the array as being a matrix, but numpy
 does not have this model.   There is a Matrix class that implements
 this model, but usually experienced numpy users either never use this,
 or stop using it.

 I can only say - subjectively I know - that I did not personally
 suffer from this when I switched to numpy from Matlab, partly because
 I was fully aware that I was going to have to change the way I thought
 about arrays, for various reasons.  After a short while getting used
 to it, broadcasting seemed like a huge win.  I guess the fact that
 other languages have adopted it means that others have had the same
 experience.

 So, numpy is not a straight replacement of Matlab, in terms of design.

 To pursue the analogy, you have learned to drive an automatic car.
 Numpy is a stick-shift car.  There are good reasons to prefer a
 stick-shift, but it does mean that someone trained on an automatic is
 bound to feel that a stick-shift is uncomfortable for a while.


I think the analogy is Python printing at the start and all the time a warning
We use indentation, not braces, brackets or `end` to indicate blocks of code.

Josef




 Best,

 Matthew
 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread josef.pktd
On Sun, Feb 8, 2015 at 5:17 PM, Stefan Reiterer dom...@gmx.net wrote:
 Actually I use numpy for several years now, and I love it.
 The reason that I think silent broadcasting of sums is bad
 comes simply from the fact, that I had more trouble with it, than it helped
 me.

 I won't stop using numpy because of that, but I think this behavior may
 backfire,
 and thats the reason I started this discussion. Till now the only way out of
 the misery
 is to make proper unit tests, and to be careful as hell with dimensions and
 shape checks.

I fully agree with the last part. We need a lot more checks and be a
lot more careful in numpy than in matlab. But that's a fundamental
difference between the array versus matrix approach.

For me the main behavior I had to adjust to was loosing a dimension in
any reduce operation, mean, sum, ...

if x is 2d
x - x.mean(1)
we loose a dimension, and it doesn't broadcast in the right direction

x - x.mean(0)
perfect, no `repeat` needed, it just broadcasts the way we need.

Josef


 Providing optional warnings just would be an elegant way out of this.

 Cheers,
 Stefan
 Gesendet: Sonntag, 08. Februar 2015 um 22:56 Uhr
 Von: Matthew Brett matthew.br...@gmail.com

 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful
 Hi,

 On Sun, Feb 8, 2015 at 1:39 PM, Simon Wood sgwoo...@gmail.com wrote:


 On Sun, Feb 8, 2015 at 4:24 PM, Stefan Reiterer dom...@gmx.net wrote:

 I don't think this is a good comparison, especially since broadcasting is
 a feature not a necessity ...
 It's more like turning off/on driving assistance.

 And as already mentioned: other matrix languages also allow it, but they
 warn about it's usage.
 This has indeed it's merits.
 Gesendet: Sonntag, 08. Februar 2015 um 22:17 Uhr
 Von: Charles R Harris charlesr.har...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful


 On Sun, Feb 8, 2015 at 2:14 PM, Stefan Reiterer dom...@gmx.net wrote:

 Yeah I'm aware of that, that's the reason why I suggested a warning
 level
 as an alternative.
 Setting no warnings as default would avoid breaking existing code.
 Gesendet: Sonntag, 08. Februar 2015 um 22:08 Uhr
 Von: Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
 An: Discussion of Numerical Python numpy-discussion@scipy.org
 Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful
  I personally use Octave and/or Numpy for several years now and never
  ever needed braodcasting.
 But since it is still there there will be many users who need it, there
 will be some use for it.

 Uhm, yeah, there is some use for it. Im all for explicit over implicit,
 but personally current broadcasting rules have never bothered me,
 certainly
 not to the extent of justifying massive backwards compatibility
 violations.
 Take It from someone who relies on broadcasting for every other line of
 code.



 It's how numpy works. It would be like getting into your car and being
 warned that it has wheels.

 Chuck
 ___ NumPy-Discussion mailing
 list NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


 I agree, I do not think this is a good comparison. All cars have wheels,
 there are no surprises there. This is more like a car that decides to do
 something completely different from everything that you learned about in
 driving school.

 I find the broadcasting aspect of Numpy a turn off. If I go to add a 1x3
 vector to a 3x1 vector, I want the program to warn me or error out. I
 don't
 want it to do something under the covers that has no mathematical basis or
 definition. Also, Octave may provide a warning, but Matlab errors
 out...Matrix dimensions must agree. Which they must, at least in my
 world.

 In a previous life, many of us were very serious users of Matlab,
 myself included.

 Matlab / Octave have a model of the array as being a matrix, but numpy
 does not have this model. There is a Matrix class that implements
 this model, but usually experienced numpy users either never use this,
 or stop using it.

 I can only say - subjectively I know - that I did not personally
 suffer from this when I switched to numpy from Matlab, partly because
 I was fully aware that I was going to have to change the way I thought
 about arrays, for various reasons. After a short while getting used
 to it, broadcasting seemed like a huge win. I guess the fact that
 other languages have adopted it means that others have had the same
 experience.

 So, numpy is not a straight replacement of Matlab, in terms of design.

 To pursue the analogy, you have learned to drive an automatic car.
 Numpy is a stick-shift car. There are good reasons to prefer a
 stick-shift, but it does mean that someone trained on an automatic is
 bound to feel that a stick-shift is uncomfortable for a while.

 Best,

 Matthew
 

Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Nathaniel Smith
On 8 Feb 2015 13:39, Simon Wood sgwoo...@gmail.com wrote:

 I find the broadcasting aspect of Numpy a turn off. If I go to add a 1x3
vector to a 3x1 vector, I want the program to warn me or error out. I don't
want it to do something under the covers that has no mathematical basis or
definition. Also, Octave may provide a warning, but Matlab errors
out...Matrix dimensions must agree. Which they must, at least in my world.

There may be another matlab/numpy idiom clash here that's affecting this:
in MATLAB, vectors are always 1 x n or n x 1, because of the matrix focused
history. In numpy the idiomatic thing to do is to make vectors
one-dimensional, and then this confusion cannot arise. Indeed, the only
cases I'm thinking of where I even create a 3x1 or 1x3 vector in the first
place are when I'm about to do something clever with broadcasting.

-n
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Simon Wood
On Sun, Feb 8, 2015 at 5:28 PM, josef.p...@gmail.com wrote:

 On Sun, Feb 8, 2015 at 4:56 PM, Matthew Brett matthew.br...@gmail.com
 wrote:
  Hi,
 
  On Sun, Feb 8, 2015 at 1:39 PM, Simon Wood sgwoo...@gmail.com wrote:
 
 
  On Sun, Feb 8, 2015 at 4:24 PM, Stefan Reiterer dom...@gmx.net wrote:
 
  I don't think this is a good comparison, especially since broadcasting
 is
  a feature not a necessity ...
  It's more like turning off/on driving assistance.
 
  And as already mentioned: other matrix languages also allow it, but
 they
  warn about it's usage.
  This has indeed it's merits.
  Gesendet: Sonntag, 08. Februar 2015 um 22:17 Uhr
  Von: Charles R Harris charlesr.har...@gmail.com
  An: Discussion of Numerical Python numpy-discussion@scipy.org
  Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful
 
 
  On Sun, Feb 8, 2015 at 2:14 PM, Stefan Reiterer dom...@gmx.net
 wrote:
 
  Yeah I'm aware of that, that's the reason why I suggested a warning
 level
  as an alternative.
  Setting no warnings as default would avoid breaking existing code.
  Gesendet: Sonntag, 08. Februar 2015 um 22:08 Uhr
  Von: Eelco Hoogendoorn hoogendoorn.ee...@gmail.com
  An: Discussion of Numerical Python numpy-discussion@scipy.org
  Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful
   I personally use Octave and/or Numpy  for several years now and
 never
   ever needed braodcasting.
  But since it is still there there will be many users who need it,
 there
  will be some use for it.
 
  Uhm, yeah, there is some use for it. Im all for explicit over
 implicit,
  but personally current broadcasting rules have never bothered me,
 certainly
  not to the extent of justifying massive backwards compatibility
 violations.
  Take It from someone who relies on broadcasting for every other line
 of
  code.
 
 
 
  It's how numpy works. It would be like getting into your car and being
  warned that it has wheels.
 
  Chuck
  ___ NumPy-Discussion
 mailing
  list NumPy-Discussion@scipy.org
  http://mail.scipy.org/mailman/listinfo/numpy-discussion
 
 
  I agree, I do not think this is a good comparison. All cars have wheels,
  there are no surprises there. This is more like a car that decides to do
  something completely different from everything that you learned about in
  driving school.
 
  I find the broadcasting aspect of Numpy a turn off. If I go to add a 1x3
  vector to a 3x1 vector, I want the program to warn me or error out. I
 don't
  want it to do something under the covers that has no mathematical basis
 or
  definition. Also, Octave may provide a warning, but Matlab errors
  out...Matrix dimensions must agree. Which they must, at least in my
 world.
 
  In a previous life, many of us were very serious users of Matlab,
  myself included.
 
  Matlab / Octave have a model of the array as being a matrix, but numpy
  does not have this model.   There is a Matrix class that implements
  this model, but usually experienced numpy users either never use this,
  or stop using it.
 
  I can only say - subjectively I know - that I did not personally
  suffer from this when I switched to numpy from Matlab, partly because
  I was fully aware that I was going to have to change the way I thought
  about arrays, for various reasons.  After a short while getting used
  to it, broadcasting seemed like a huge win.  I guess the fact that
  other languages have adopted it means that others have had the same
  experience.
 
  So, numpy is not a straight replacement of Matlab, in terms of design.
 
  To pursue the analogy, you have learned to drive an automatic car.
  Numpy is a stick-shift car.  There are good reasons to prefer a
  stick-shift, but it does mean that someone trained on an automatic is
  bound to feel that a stick-shift is uncomfortable for a while.


 I think the analogy is Python printing at the start and all the time a
 warning
 We use indentation, not braces, brackets or `end` to indicate blocks of
 code.

 Josef



Not quite the same. This is not so much about language semantics as
mathematical definitions. You (the Numpy community) have decided to
overload certain mathematical operators to act in a way that is not
consistent with linear algebra teachings. This can be a bit confusing for
people who develop and implement mathematical algorithms that have a strong
foundation in linear algebra, irrespective of the language they are
migrating from.

With that said, I do appreciate the comments by Matthew, Eelco and others.
Numpy is *not* a linear algebra package, so it does not adhere to the same
mathematical definitions. This realization has cleared some things up.

-Simon


 
  Best,
 
  Matthew
  ___
  NumPy-Discussion mailing list
  NumPy-Discussion@scipy.org
  http://mail.scipy.org/mailman/listinfo/numpy-discussion
 ___
 NumPy-Discussion mailing list
 

Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Sturla Molden
Simon Wood sgwoo...@gmail.com wrote:

 Not quite the same. This is not so much about language semantics as
 mathematical definitions. You (the Numpy community) have decided to
 overload certain mathematical operators to act in a way that is not
 consistent with linear algebra teachings.

We have overloaded the operators to make them work like Fortran 90. That is
about as hardcore numerical computing semantics as you get. 


 This can be a bit confusing for
 people who develop and implement mathematical algorithms that have a strong
 foundation in linear algebra, irrespective of the language they are
 migrating from.

Those who develop such algorithms are probably going to use BLAS and
LAPACK. Then by deduction they know about Fortran, and then by deduction
they know about array broadcasting.


Sturla

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Sturla Molden
On 08/02/15 23:17, Stefan Reiterer wrote:

 Actually I use numpy for several years now, and I love it.
 The reason that I think silent broadcasting of sums is bad
 comes simply from the fact, that I had more trouble with it, than it
 helped me.

In Fortran 90, broadcasting allows us to write concise expressions which 
are compiled into very efficient machine code. This would be very 
difficult for the compiler if the code used explicit repeats and 
reshapes instead of broadcasting.

In NumPy and Matlab, this aspect is not equally important. But 
broadcasting makes array expressions more terse, and is save some 
redundant array copies. NumPy code tends to be memory bound; 
broadcasting can therefore improve performance, particularly when arrays 
are large. But the effect is not as dramatic as it is in Fortran.

Readability is also important. Vectorized Matlab code quickly 
degenerates into a mess of reshapes and repmats, and can be very hard to 
read. NumPy and Fortran 90 codes do not loose the readability like this 
even in the most complicated array expressions.


Sturla

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Stefan Reiterer

Ok that are indeed some good reasons to keep the status quo, especially since performance is crucial for numpy.



Its a dillemma: Using the matrix class for linear algebra would be the correct way for such thing,

but the matrix API is not that powerful and beautiful as the one of arrays.

On the other hand arrays are beautiful, but not exactly intended to use for linear algebra.



So maybe the better way would be not to add warnings to braodcasting operations, but to overhaul the matrix class

to make it more attractive for numerical linear algebra(?)




Cheers,

Stefan


Gesendet:Sonntag, 08. Februar 2015 um 23:52 Uhr
Von:Nathaniel Smith n...@pobox.com
An:Discussion of Numerical Python numpy-discussion@scipy.org
Betreff:Re: [Numpy-discussion] Silent Broadcasting considered harmful


On 8 Feb 2015 13:04, Stefan Reiterer dom...@gmx.net wrote:

 So I suggest that the best would be to throw warnings when arrays get Broadcasted like
 Octave do. Python warnings can be catched and handled, that would be a great benefit.
 
 Another idea would to provide warning levels for braodcasting, e.g
 0 = Never, 1=Warn once, 2=Warn always, 3 = Forbid aka throw exception,
 with 0 as default.
 This would avoid breaking other code, and give the user some control over braodcasting.

Unfortunately adding warnings is a non-starter for technical reasons, even before we get into the more subjective debate about ideal API design: issuing a warning is extremely slow (relative to typical array operations), EVEN IF the warning is disabled. (By the time you can figure out its disabled, its too late.) So this would cause massive slowdowns in existing code.

Note also that in numpy, even simple expressions like 2 * arr rely on broadcasting. Do you really want warnings for all these cases?

-n
___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion



___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Silent Broadcasting considered harmful

2015-02-08 Thread Eric Firing
On 2015/02/08 12:43 PM, josef.p...@gmail.com wrote:


 For me the main behavior I had to adjust to was loosing a dimension in
 any reduce operation, mean, sum, ...

 if x is 2d
 x - x.mean(1)
 we loose a dimension, and it doesn't broadcast in the right direction

Though you can use:

x_demeaned = x - np.mean(x, axis=1, keepdims=True)


 x - x.mean(0)
 perfect, no `repeat` needed, it just broadcasts the way we need.

 Josef

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion