How is base
determined for record arrays?
The docs seem to describe the same behavior as regular arrays, but that's not what it is.
Here's a simple array, and a record array created from it.
>>> arr = np.zeros(10, dtype=[('a', float), ('b', int), ('c', int)])
>>> rec = arr.view(np.recarray)
The base of the record array is correctly set
>>> arr is rec
False
>>> arr is rec.base
True
The base
is correctly set for field accesses of the regular array.
>>> arr['a'].base is arr
True
However, for the record array I can't determine what the base is. It's not the regular array, the record array, None
, or anything else that I've tried.
>>> rec['a'].base is arr
False
>>> rec['a'].base is rec
False
>>> rec['a'].base is None
False
>>> rec['a'].base is rec['a']
False
>>> rec['a'].base is rec['a'].base
False
>>> f = rec['a']
>>> f.base is f
False
It behaves as expected for indexing slices
>>> arr[:3].base is arr
True
>>> rec[:3].base is rec
True
And it definitely still points to the same memory
>>> arr[0]
(0., 0, 0)
>>> rec['a'] = 1
>>> arr[0]
(1., 0, 0)
So, how can the actual base of a record array be found?