Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coerce shape of an Array #250

Open
lheagy opened this issue Jul 4, 2018 · 0 comments
Open

coerce shape of an Array #250

lheagy opened this issue Jul 4, 2018 · 0 comments

Comments

@lheagy
Copy link
Contributor

lheagy commented Jul 4, 2018

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?

lheagy added a commit to simpeg/simpeg that referenced this issue Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant