code in hist

Eric, I've seen the comment "Why is the copy needed?" that you've added
to the axes' hist method. I think this was introduced by me some time
ago. Indeed, I think it is not really needed. If I remember correctly, I
had done the copying to avoid that the input x gets modified (I had bad
experience with that before), but I think we can avoid it?

Manuel

Manuel Metz wrote:

Eric, I've seen the comment "Why is the copy needed?" that you've added
to the axes' hist method. I think this was introduced by me some time
ago. Indeed, I think it is not really needed. If I remember correctly, I
had done the copying to avoid that the input x gets modified (I had bad
experience with that before), but I think we can avoid it?

Manuel,

It turns out the problem was that 1-D arrays were being converted to 2-D by assigning to the shape attribute. (This is something I often do, but now I will be more cautious about it.) When done on the original input argument, which was returned by "x = np.asarray(x)", this had the side effect of changing that argument. Copying was preventing that. To avoid the copy, one could either make a new view of the argument explicitly, or do it implicitly by using the reshape method instead of assigning to the shape attribute. I chose the second option.

Eric