Skip to content

dtype ctor allows "align" kwargs even when unapplicable #8158

@anntzer

Description

@anntzer

The doc for the np.dtype ctor documents its second arg as

align : bool, optional
Add padding to the fields to match what a C compiler would output for a similar C-struct.
Can be True only if obj is a dictionary or a comma-separated string. If a struct dtype is
being created, this also sets a sticky alignment flag isalignedstruct.

but in fact:

In [1]: np.dtype(float, 3)
Out[1]: dtype('float64')

i.e. align is ignored when not applicable. Error'ing in such a case would help catching typos, as the user more likely intended to write

In [2]: np.dtype((float, 3))
Out[2]: dtype(('<f8', (3,)))

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