[Numpy-discussion] Non-writeable default for numpy.ndarray

Francesc Altet faltet at carabos.com
Fri Sep 29 10:23:26 CDT 2006


Is the next a bug a feature?

In [102]: f4=numpy.ndarray(buffer="a\x00b"*4, dtype="f4", shape=3)

In [103]: f4
Out[103]: array([  2.60561966e+20,   8.94319890e-39,   5.92050103e+20], 

In [104]: f4[2] = 2
<type 'exceptions.RuntimeError'>          Traceback (most recent call last)

/home/faltet/python.nobackup/numpy/<ipython console> in <module>()

<type 'exceptions.RuntimeError'>: array is not writeable

In [105]: f4.flags.writeable = True

In [106]: f4[2] = 2

In [107]: f4
Out[107]: array([  2.60561966e+20,   8.94319890e-39,   2.00000000e+00], 

i.e. in an array built from ndarray, the default is that it has to be 

>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data

More information about the Numpy-discussion mailing list