Hi Jens,

I don't have enough knowledge about the internal memory layout, but the
documentation ndarray.view
<http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.view.html>
says
that:

Views that change the dtype size (bytes per entry) should normally be
avoided on arrays defined by slices, transposes, fortran-ordering, etc.:

In your case, creating a *copy *of the slice and then calling *view *works.

>>>a
array([[ 1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j],
       [ 1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j]])
>>> a.view(float)
array([[ 1.,  0.,  1.,  0.,  1.,  0.,  1.,  0.],
       [ 1.,  0.,  1.,  0.,  1.,  0.,  1.,  0.]])
>>> b=a[:,:2].copy()
>>> b.view(float)
array([[ 1.,  0.,  1.,  0.],
       [ 1.,  0.,  1.,  0.]])
>>> c=a[:,:2]
>>> c.view(float)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: new type not compatible with array

Hope it helps :)

Cheers,
N.Maniteja.

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to