Skip to content

structured dtype descr method returns incorrect descriptor when void space is at the end of dtype built through a dict #6359

@ikehall

Description

@ikehall

Using python 2.7.10, numpy 1.9.2
If I define a structured dtype in the following manner:

>>>my_dtype = np.dtype({ 
    'names':['A', 'B'], 
    'formats':['f4', 'f4'], 
    'offsets'[0, 8], 
    'itemsize':16})

And I then try to create a new dtype from this dtypes descr:

>>>new_dtype = np.dtype(my_dtype.descr)

Then the two dtypes will not have the same itemsize

>>>my_dtype.itemsize
16
>>>new_dtype.itemsize
12

Examining the descr of my_dtype, we see that it is leaving off the 4 void bytes at the end

>>>my_dtype.descr
[('A', '<f4'), ('', '|V4'), ('B', '<f4')]

What should happen instead:

>>>my_dtype.descr
[('A', '<f4'), ('', '|V4'), ('B', '<f4'), ('', '|V4')]

This has relevance for use of structured arrays with IPython.parallel, as this is how structured arrays are reconstructed when serialized and sent to engines in IPython.parallel. A work-around for the user of course is to define some field that marks the end of the structured data, but it seems that this should not be necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions