-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide a error summary for assert_allclose (#3847)
* allow passing a callable as compat to diff_{dataset,array}_repr * rewrite assert_allclose to provide a failure summary * make sure we're comparing variables * remove spurious comments * override test_aggregate_complex with a test compatible with pint * expect the asserts to raise * xfail the tests failing due to isclose not accepting non-quantity tolerances * mark top-level function tests as xfailing if they use assert_allclose * mark test_1d_math as runnable but xfail it * bump dask and distributed * entry to whats-new.rst * attempt to fix the failing py36-min-all-deps and py36-min-nep18 CI * conditionally xfail tests using assert_allclose with pint < 0.12 * xfail more tests depending on which pint version is used * try using numpy.testing.assert_allclose instead * try computing if the dask version is too old and dask.array[bool] * fix the dask version checking * convert all dask arrays to numpy when using a insufficient dask version
- Loading branch information
Showing
9 changed files
with
150 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
import pytest | ||
|
||
import xarray as xr | ||
|
||
|
||
def test_allclose_regression(): | ||
x = xr.DataArray(1.01) | ||
y = xr.DataArray(1.02) | ||
xr.testing.assert_allclose(x, y, atol=0.01) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"obj1,obj2", | ||
( | ||
pytest.param( | ||
xr.Variable("x", [1e-17, 2]), xr.Variable("x", [0, 3]), id="Variable", | ||
), | ||
pytest.param( | ||
xr.DataArray([1e-17, 2], dims="x"), | ||
xr.DataArray([0, 3], dims="x"), | ||
id="DataArray", | ||
), | ||
pytest.param( | ||
xr.Dataset({"a": ("x", [1e-17, 2]), "b": ("y", [-2e-18, 2])}), | ||
xr.Dataset({"a": ("x", [0, 2]), "b": ("y", [0, 1])}), | ||
id="Dataset", | ||
), | ||
), | ||
) | ||
def test_assert_allclose(obj1, obj2): | ||
with pytest.raises(AssertionError): | ||
xr.testing.assert_allclose(obj1, obj2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters