You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot get a view from a composite array with object data members #3253
I have the use case where I want to have two datatypes: some base type 'dt' and another type 'dtSuper' which is a fixed-size array of 'dt' elements. I'd like to cast a properly-sized array with dtype dt to a (1,) array with dtype 'dtSuper', like so:
dt = np.dtype([('a','O'),('b','f8')])
a = np.zeros((5,),dtype=dt)
dtSuper = np.dtype([('samples',dt,(5,))])
a.view(dtSuper)
Object types, I imagine, could be dangerous if we're allowed to re-interpret them as arbitrary data types, as that gives us direct access to memory addresses and suddenly we're programming in C, with enough rope to hang ourselves with :-). I'm speculating that this is the underlying reason why we are now seeing this error in 1.7.1.
However the use case I just described doesn't have this problem. It seems that it would make sense to special-case the code, or else (to be more general) somehow check to ensure that every object pointer in the old dtype maps to an object pointer in the new dtype.
Activity
imstochastic commentedon Nov 21, 2013
FWIW, still the case on "1.7.2.dev-3b1a809".
I have the use case where I want to have two datatypes: some base type 'dt' and another type 'dtSuper' which is a fixed-size array of 'dt' elements. I'd like to cast a properly-sized array with dtype dt to a (1,) array with dtype 'dtSuper', like so:
Object types, I imagine, could be dangerous if we're allowed to re-interpret them as arbitrary data types, as that gives us direct access to memory addresses and suddenly we're programming in C, with enough rope to hang ourselves with :-). I'm speculating that this is the underlying reason why we are now seeing this error in 1.7.1.
However the use case I just described doesn't have this problem. It seems that it would make sense to special-case the code, or else (to be more general) somehow check to ensure that every object pointer in the old dtype maps to an object pointer in the new dtype.
charris commentedon Feb 22, 2014
Still open in 1.9-devel. Note that is error occurs in
_internal.py, so might not be too difficult to fix.charris commentedon Feb 22, 2014
So labelled "easy fix" until proved otherwise ;)
ENH: structured datatype safety checks
ENH: structured datatype safety checks
ENH: structured datatype safety checks
ENH: structured datatype safety checks
ENH: structured datatype safety checks
ENH: structured datatype safety checks
ENH: structured datatype safety checks
ENH: structured datatype safety checks
ENH: structured datatype safety checks
ENH: structured datatype safety checks