[NumPy-Tickets] [NumPy] #1674: Problems outputting elements of ndarray
NumPy Trac
numpy-tickets@scipy....
Sun Nov 14 22:53:49 CST 2010
#1674: Problems outputting elements of ndarray
--------------------+-------------------------------------------------------
Reporter: pv00 | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 2.0.0
Component: Other | Version: 1.5.0
Keywords: |
--------------------+-------------------------------------------------------
Hi, what is the best way to print (to a file or to stdout)
formatted numerical values?
Numpy Documentation only discusses input *from* a file,
or output of entire arrays.
I just want tab or space-delimited output of formatted values.
I tried to follow python documentation and find errors. Below is ipython
-pylab transcript:
In [2] import numpy as np
In [3]: w = np.arange (1,5,dtype=np.int32).reshape((2,2))
In [4]: w
Out[4]:
array([[1, 2],
[3, 4]], dtype=int32)
In [5]: w[0,0]
Out[5]: 1
In [6]: w[0,0].__class__
Out[6]: <type 'numpy.int32'>
In [7]: print('{0:2d}'.format(w[0,0]))
---------------------------------------------------------------------------
ValueError Traceback (most recent call
last)
/home/p/o/dev/thesis/python/wavelet/<ipython console> in <module>()
ValueError: Unknown format code 'd' for object of type 'str'
In [8]:
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1674>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list