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

call np.cross with 3D vectors only #8993

Merged
merged 3 commits into from
May 3, 2024
Merged

call np.cross with 3D vectors only #8993

merged 3 commits into from
May 3, 2024

Conversation

keewis
Copy link
Collaborator

@keewis keewis commented May 2, 2024

In the tests, we've been calling np.cross with vectors of 2 or 3 dimensions, numpy>=2 will deprecate 2D vectors (plus, we're now raising on warnings). Thus, we 0-pad the inputs before generating the expected result (which generally should not change the outcome of the tests).

For a later PR: add tests to check if xr.cross works if more than a single dimension is present, and pre-compute the expected result. Also, for property-based testing: the cross-product of two vectors is perpendicular to both input vectors (use the dot product to check that), and its length (l2-norm) is the product of the lengths of the input vectors.

@keewis keewis added the run-upstream Run upstream CI label May 2, 2024
@dcherian
Copy link
Contributor

dcherian commented May 3, 2024

Thanks for all your work here @keewis !

@dcherian dcherian merged commit aaa778c into pydata:main May 3, 2024
26 of 28 checks passed
@keewis keewis deleted the cross branch May 3, 2024 15:56
andersy005 added a commit that referenced this pull request May 3, 2024
* origin/main:
  call `np.cross` with 3D vectors only (#8993)
  Mark `test_use_cftime_false_standard_calendar_in_range` as an expected failure (#8996)
  Migration of datatree/ops.py -> datatree_ops.py (#8976)
  avoid a couple of warnings in `polyfit` (#8939)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-upstream Run upstream CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants