Skip to content

coerce shape of an Array #250

@lheagy

Description

@lheagy

I have an array that internally, I would like to treat it as a vector with shape (3,), but I would like to allow the user to input something that is (3,1). I realize this could be achieved with a validator, but this case comes up quite a bit (and is easy to forget about). Without a validator, the user will get the error
image

Would it make sense to add a coerce_shape=True keyword to the Array property (eg. it tries to flatten a 1D array to a vector if the shape is ('*',) or, alternatively, if a 2D array was expected and a vector input, it performs a np.atleast_2d on it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions