<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 14, 2013 at 1:21 PM, Robert Kern <span dir="ltr"><<a href="mailto:robert.kern@gmail.com" target="_blank">robert.kern@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Fri, Jun 14, 2013 at 6:18 PM, Eric Firing <<a href="mailto:efiring@hawaii.edu">efiring@hawaii.edu</a>> wrote:<br>


> On 2013/06/14 5:15 AM, Alan G Isaac wrote:<br>
>> On 6/14/2013 9:27 AM, Aldcroft, Thomas wrote:<br>
>>> If I just saw np.values(..) in some code I would never guess what it is doing from the name<br>
>><br>
>> That suggests np.fromvalues.<br>
>> But more important than the name I think<br>
>> is allowing broadcasting of the values,<br>
>> based on NumPy's broadcasting rules.<br>
>> Broadcasting a scalar is then a special case,<br>
>> even if it is the case that has dominated this thread.<br>
><br>
> True, but this looks to me like mission creep.  All of this fuss is<br>
> about replacing two lines of user code with a single line.  If it can't<br>
> be kept simple, both in implementation and in documentation, it<br>
> shouldn't be done at all.  I'm not necessarily opposed to your<br>
> suggestion, but I'm skeptical.<br>
<br>
</div>It's another two-liner:<br>
<br>
[~]<br>
|1> x = np.empty([3,4,5])<br>
<br>
[~]<br>
|2> x[...] = np.arange(5)<br>
<br>
[~]<br>
|3> x<br>
array([[[ 0.,  1.,  2.,  3.,  4.],<br>
        [ 0.,  1.,  2.,  3.,  4.],<br>
        [ 0.,  1.,  2.,  3.,  4.],<br>
        [ 0.,  1.,  2.,  3.,  4.]],<br>
<br>
       [[ 0.,  1.,  2.,  3.,  4.],<br>
        [ 0.,  1.,  2.,  3.,  4.],<br>
        [ 0.,  1.,  2.,  3.,  4.],<br>
        [ 0.,  1.,  2.,  3.,  4.]],<br>
<br>
       [[ 0.,  1.,  2.,  3.,  4.],<br>
        [ 0.,  1.,  2.,  3.,  4.],<br>
        [ 0.,  1.,  2.,  3.,  4.],<br>
        [ 0.,  1.,  2.,  3.,  4.]]])<br>
<br>
It's wafer-thin!<br>
<br></blockquote><div><br></div><div>True, but wouldn't we rather want to encourage the use of broadcasting in the numerical operations rather than creating new arrays from broadcasted arrays?<br><br></div><div>a = np.arange(5) + np.ones((3, 4, 5))<br>

</div><div>b = np.filled((3, 4, 5), np.arange(5)) + np.ones((3, 4, 5))<br><br></div><div>The first one is much easier to read, and is more efficient than the second (theoretical) one because it needs to create two (3, 4, 5) arrays rather than just one.  That being said, one could make a similar argument against ones(), zeros(), etc.<br>

<br></div><div>Cheers!<br></div><div>Ben Root<br><br></div></div></div></div>