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

Explicitly calling numpy asanyarray over the inputs. #2050

Merged
merged 2 commits into from
May 24, 2022

Conversation

axnsantana
Copy link
Contributor

Applying asanyarray to x, y, u, v, and all possible scalars to allow the
use of objects that implements a __array__, like xarray.DataArray.

Rationale

Cartopy was falling when non-ndarray inputs like xarray.DataArray is used.
More details on issue #2049

Applying asanyarray to x, y, u, v, and all possible scalars to allow the 
use of objects that implements a __array__, like xarray.DataArray.
Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a test, does passing lists to this fail currently with trying to call [1, 2, 3].ravel()? That might be a way to test and make sure this handles that case too.

Looks good though, thanks!

The test is a replica of the test test_with_scalar_field but all inputs 
are converted to lists.
@axnsantana
Copy link
Contributor Author

axnsantana commented May 24, 2022

Just added a test following your idea, thanks!

@greglucas greglucas merged commit c184ead into SciTools:main May 24, 2022
@greglucas
Copy link
Contributor

Thanks, @axnsantana, hope to see some more contributions from you!

@QuLogic QuLogic added this to the 0.21 milestone May 25, 2022
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

Successfully merging this pull request may close these issues.

3 participants