Le 18/07/2014 20:42, Charles G. Waldman a écrit :
> Well, if the goal is "shorthand", typing numpy.array(numpy.mat())
> won't please many users.
>
> But the more I think about it, the less I think Numpy should support
> this (non-Pythonic) input mode.  Too much molly-coddling of new users!
> When doing interactive work I usually just type:
>
>>>> np.array([[1,2,3],
> ...                   [4,5,6],
> ...                   [7,8,9]])
>
> which is (IMO) easier to read:  e.g. it's not totally obvious that
> "1,0,0;0,1,0;0,0,1" represents a 3x3 identity matrix, but
>
> [[1,0,0],
>    [0,1,0],
>    [0,0,1]]
>
> is pretty obvious.
>
Compare what's comparable:

[[1,0,0],
  [0,1,0],
  [0,0,1]]

vs

"1 0 0;"
"0 1 0;"
"0 0 1"

or

"""
1 0 0;
0 1 0;
0 0 1
"""

[[1,0,0], [0,1,0], [0,0,1]]
vs
"1 0 0; 0 1 0; 0 0 1"

> The difference in (non-whitespace) chars is 19 vs 25, so the
> "shorthand" doesn't seem to save that much.

Well, it's easier to type "" (twice the same character) than [], and you 
have no risk in swapping en opening and a closing bracket. In addition, 
you have to use AltGr on some keyboards to get the brackets. It doesn't 
boils down to a number of characters.

>
> Just my €0.02,
>
>     - C
>
>
>
>
> On Fri, Jul 18, 2014 at 10:05 AM, Alan G Isaac <alan.is...@gmail.com> wrote:
>> On 7/18/2014 12:45 PM, Mark Miller wrote:
>>> If the true goal is to just allow quick entry of a 2d array, why not just 
>>> advocate using
>>> a = numpy.array(numpy.mat("1 2 3; 4 5 6; 7 8 9"))
>>
>>
>> It's even simpler:
>> a = np.mat(' 1 2 3;4 5 6;7 8 9').A
>>
>> I'm not putting a dog in this race.  Still I would say that
>> the reason why such proposals miss the point is that
>> there are introductory settings where one would like
>> to explain as few complications as possible.  In
>> particular, one might prefer *not* to discuss the
>> existence of a matrix type.  As an additional downside,
>> this is only good for 2d, and there have been proposals
>> for the new array builder to handle other dimensions.
>>
>> fwiw,
>> Alan Isaac
>>
>> _______________________________________________
>> 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

Reply via email to