Hi,

I noticed that I can index into a dtype when I take an element
of a rank-1 array but not if I make a rank-0 array directly. This seems
inconsistent. A bug?

Nils


In [76]: np.version.version
Out[76]: '1.5.1'

In [78]: dt = np.dtype([('x', '<f8'), ('y', '<f8')])

In [80]: a_rank_1 = np.zeros((1,), dtype=dt)

In [81]: a_rank_0 = np.zeros((), dtype=dt)

In [83]: a_rank_1[0]
Out[83]: (0.0, 0.0)

In [84]: a_rank_1[0] == a_rank_0
Out[84]: True

In [85]: a_rank_1[0][0]
Out[85]: 0.0

In [86]: a_rank_0[0]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)

/home/pabra/ramp/testramp/<ipython console> in <module>()

IndexError: 0-d arrays can't be indexed

In [87]: a_rank_0['x']
Out[87]: array(0.0)
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to