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

defer to numpy for the expected result #7875

Merged
merged 4 commits into from
May 27, 2023
Merged

Conversation

keewis
Copy link
Collaborator

@keewis keewis commented May 25, 2023

numpy has recently changed the result of np.cos(0) by a very small value, which makes our tests break.

I'm not really sure what the best fix is, so I split the changes into two parts: the first commit uses

xr.testing.assert_allclose(a + 1, np.cos(a))

to test the result, while the second commit uses

expected = xr.full_like(a, fill_value=np.cos(0), dtype=float)
actual = np.cos(a)
xr.testing.assert_identical(actual, expected)

@Illviljan
Copy link
Contributor

Illviljan commented May 26, 2023

cos is a float operation so I would lean towards using a isclose-check: xr.testing.assert_allclose(a + 1, np.cos(a)).

@keewis keewis added the run-upstream Run upstream CI label May 27, 2023
@keewis keewis merged commit fcb8175 into pydata:main May 27, 2023
@keewis keewis deleted the numpy-unary branch May 27, 2023 19:53
dstansby pushed a commit to dstansby/xarray that referenced this pull request Jun 28, 2023
* simplify the test for unary funcs

* use `full_like` to construct the expected result

* Revert "use `full_like` to construct the expected result"

This reverts commit a14aeb5.
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.

2 participants