[Numpy-discussion] Short-hand array creation in `numpy.mat` style

Charles G. Waldman charles at crunch.io
Fri Jul 18 14:42:22 EDT 2014


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.

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

Just my €0.02,

   - C




On Fri, Jul 18, 2014 at 10:05 AM, Alan G Isaac <alan.isaac at 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 at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list