[IPython-user] numpy.array question (and ILeo plugging)

Fernando Perez fperez.net@gmail....
Wed Mar 12 18:04:24 CDT 2008


On Wed, Mar 12, 2008 at 9:10 AM, Ville M. Vainio <vivainio@gmail.com> wrote:

>  However, printing the array gives nicer formatting:
>
>  [C:opt/Console2]|22> print a
>  [[1 2 3]
>   [4 5 6]]
>
>  And I'd like to enable leo editing of numarrays in this syntax.
>
>  Is there a feature in numpy that allows me to import a string like
>  that as array, or do I have to write it myself?

No, to my knowledge that doesn't exist in numpy.  The closest I can
quickly think off is:

In [14]: np.core.defmatrix._convert_from_string('3 4; 5 6')
Out[14]: [[3, 4], [5, 6]]

this _convert_from_string is used by the np.matrix() constructor, but
NOT by the default array one.

You should keep in mind the issues that exist with potential loss of
precision when editing the text representation of floating point
numbers to convert them back into floats.

Cheers

f


More information about the IPython-user mailing list