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

Daniel da Silva var.mail.daniel at gmail.com
Fri Jul 11 16:30:36 EDT 2014


I think the idea at hand is not that it would be used everyday, but it
would be there when needed. What people do everyday is with *real* data.
They are using functions to load the data. Where this would come in useful
would be presentations and tutorials.

If leading a presentation on scientific computing in Python to beginners,
which would look better on a bullet in a slide?

   -

   np.build('.2 .7 .1; .3 .5 .2; .1 .1 .9'))

   -

   np.array([[.2, .7, .1], [.3, .5, .2], [.1, .1, .9]])


The default way of defining contrived arrays by passing lists of lists is
awkward for beginners. While lists of lists are not a hard concept, it's
not something you want to force on someone who doesn't know the Python
language yet. The second bullet above doesn't represent the readability of
the Python world.

I would suggest that this be named np.build() (or np.helpers.build()) in
light of it providing a simple interface to building arrays. Again, when
you work with real data you are taking an extra step to think about how you
load that data. That's not what you need to think about when being
introduced to NumPy.






On Tue, Jul 8, 2014 at 9:09 AM, Pauli Virtanen <pav at iki.fi> wrote:

> 07.07.2014 21:32, Chris Barker - NOAA Federal kirjoitti:
> > If you are going to introduce this functionality, please don't call it
> > np.arr.
>
> It might be appropriate for pirate versions of Numpy.
>
>     ***
>
> Seriously though, having a variant of `mat` that returns arrays could be
> useful, so weak +0. Preferably, the name should be quite short to type.
>
> On the other hand, unlike r_ and c_, I haven't seen or used mat() in
> real code.
>
> --
> Pauli Virtanen
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140711/31d8f4ac/attachment.html>


More information about the NumPy-Discussion mailing list