[Numpy-discussion] indexing of rank-0 structured arrays: why not?
Nils Becker
n.becker at amolf.nl
Mon Jan 10 13:15:13 EST 2011
Robert,
your answer does work: after indexing with () I can then further index
into the datatype.
In [115]: a_rank_0[()][0]
Out[115]: 0.0
I guess I just found the fact confusing that a_rank_1[0] and a_rank_0
compare and print equal but behave differently under indexing.
More precisely if I do
In [117]: b = a_rank_1[0]
then
In [118]: b.shape
Out[118]: ()
and
In [120]: a_rank_0 == b
Out[120]: True
but
In [119]: b[0]
Out[119]: 0.0
works but a_rank_0[0] doesn't. I thought b is a rank-0 array which it
apparently is not since it can be indexed. So maybe b[0] should fail for
consistency?
N.
More information about the NumPy-Discussion
mailing list