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
Structured array fields with str dtype have length 0, not 1 #4955
What seems to be going on is that, when using str as the field type, it is created with type S which apparently means S0, not S1. Assigning any length to the string field makes it work:
Of course. Anyway, I think the actual thing is, S0 does not exist and must not exist. The type should be S1 in the first place, and S0 in a structured type must be an error.
Or in other words, subtypes must not have a size of 0. Now one could argue S0 is valid, so maybe we can fix those places that assume that no S0 or 0-sized dtype exist (no idea how much that might actually be).
Good, we agree! My original thought was that 'a', or str should always be converted to 'S1', which does not seem to be the case in structured arrays. Will take a look at what is going on
Activity
jaimefrio commentedon Sep 10, 2014
Probably also related to this:
seberg commentedon Sep 10, 2014
maybe that is what you mean, note that:
a lot of numpy assumes S0 does not exist.
jaimefrio commentedon Sep 10, 2014
Try assigning anything to
a['y'], even though it reports it as|S1, values assigned to it bleed to the next int:seberg commentedon Sep 10, 2014
Of course. Anyway, I think the actual thing is, S0 does not exist and must not exist. The type should be S1 in the first place, and S0 in a structured type must be an error.
Or in other words, subtypes must not have a size of 0. Now one could argue S0 is valid, so maybe we can fix those places that assume that no S0 or 0-sized dtype exist (no idea how much that might actually be).
jaimefrio commentedon Sep 10, 2014
Good, we agree! My original thought was that
'a', orstrshould always be converted to'S1', which does not seem to be the case in structured arrays. Will take a look at what is going onBUG: Fix numerous bugs related to zero-width string arrays (numpy#473, …
ahaldane commentedon Jun 2, 2016
Fixed by #6430