[Python-ideas] Python multi-dimensional array constructor

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Oct 19 20:13:24 EDT 2016


On Wed, Oct 19, 2016 at 7:48 PM, Chris Barker <chris.barker at noaa.gov> wrote:
>
>
> However, if you really don't like it, then you can pass a string to
aconfsturctor function instead:
>
> a = arr_from_string(" | 0, 1, 2 || 3, 4, 5 | ")
>
> yeah, you need to type the extra quotes, but that's not much.
>
> NOTE: I'm pretty sure numpy has something like this already, for folks
that like the MATLAB style -- though I can't find it at the moment.


You are probably thinking of the numpy.matrix constructor:

>>> a = np.matrix('1 2; 3 4')
>>> print(a)
[[1 2]
 [3 4]]

See <https://docs.scipy.org/doc/numpy/reference/generated/numpy.matrix.html
>.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161019/6530daaa/attachment-0001.html>


More information about the Python-ideas mailing list