-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scikit-image is a difficult dependency to manage (especially since it makes strong assumptions about pooch). Even an import of scikit-image mutates the users ~/.cache folder, which can lead to hard to debug permissions errors and other issues. We work around this via careful dependency pinning, but I still frequently run into this problem when e.g. updating versions. We only use two small functions from scikit-image, so it's easy to vendorize them in this repo. We can reimplement this using `xarray.coarsen` at another time (see #1048). Added public API: - vcm.testing.checksum_dataarray/checksum_dataarray_mapping/regression_data Significant internal changes: - rewired the coarening tests to use regression checksums instead. Requirement changes: - removed scikit-image - I would've liked to remove pooch too, but metpy uses it too, albeit only in one module that we probably don't import.
- Loading branch information
Showing
22 changed files
with
519 additions
and
250 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
13 changes: 13 additions & 0 deletions
13
...ests/_regtest_outputs/test_cubedsphere.test_xarray_block_reduce_dataarray[False-mean].out
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
919ca49721b5b0a8628f273067a8fb4f | ||
xarray.Dataset { | ||
dimensions: | ||
x = 2 ; | ||
y = 2 ; | ||
z = 2 ; | ||
|
||
variables: | ||
float32 a(x, y, z) ; | ||
a:units = m ; | ||
|
||
// global attributes: | ||
} |
13 changes: 13 additions & 0 deletions
13
...ts/_regtest_outputs/test_cubedsphere.test_xarray_block_reduce_dataarray[False-median].out
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
919ca49721b5b0a8628f273067a8fb4f | ||
xarray.Dataset { | ||
dimensions: | ||
x = 2 ; | ||
y = 2 ; | ||
z = 2 ; | ||
|
||
variables: | ||
float32 a(x, y, z) ; | ||
a:units = m ; | ||
|
||
// global attributes: | ||
} |
13 changes: 13 additions & 0 deletions
13
...tests/_regtest_outputs/test_cubedsphere.test_xarray_block_reduce_dataarray[True-mean].out
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
919ca49721b5b0a8628f273067a8fb4f | ||
xarray.Dataset { | ||
dimensions: | ||
x = 2 ; | ||
y = 2 ; | ||
z = 2 ; | ||
|
||
variables: | ||
float32 a(x, y, z) ; | ||
a:units = m ; | ||
|
||
// global attributes: | ||
} |
13 changes: 13 additions & 0 deletions
13
...sts/_regtest_outputs/test_cubedsphere.test_xarray_block_reduce_dataarray[True-median].out
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
919ca49721b5b0a8628f273067a8fb4f | ||
xarray.Dataset { | ||
dimensions: | ||
x = 2 ; | ||
y = 2 ; | ||
z = 2 ; | ||
|
||
variables: | ||
float32 a(x, y, z) ; | ||
a:units = m ; | ||
|
||
// global attributes: | ||
} |
1 change: 1 addition & 0 deletions
1
external/vcm/tests/_regtest_outputs/test_testing.test_checksum_dataarray.out
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
a9aa230ec5c5bf71f92e77753b13023d |
1 change: 1 addition & 0 deletions
1
external/vcm/tests/_regtest_outputs/test_testing.test_checksum_dataarray_mapping.out
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
[('one', 'a9aa230ec5c5bf71f92e77753b13023d'), ('two', '9a75cafb8e8600ef3aa16a87b7befc0c')] |
15 changes: 15 additions & 0 deletions
15
external/vcm/tests/_regtest_outputs/test_testing.test_regression_data_unchanged.out
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Array hash: | ||
a9aa230ec5c5bf71f92e77753b13023d | ||
Coordinate info: | ||
Coordinate x : [1] | ||
xarray.Dataset { | ||
dimensions: | ||
x = 1 ; | ||
|
||
variables: | ||
int64 x(x) ; | ||
int64 a(x) ; | ||
a:hello = world ; | ||
|
||
// global attributes: | ||
} |
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,10 +1,63 @@ | ||
from external.vcm.vcm.testing import regression_data | ||
import warnings | ||
import pytest | ||
|
||
from vcm import testing | ||
import xarray | ||
|
||
|
||
def test_no_warning(): | ||
with pytest.raises(AssertionError): | ||
with testing.no_warning(None): | ||
warnings.warn("Warning") | ||
|
||
|
||
def test_checksum_dataarray(regtest): | ||
"""If these checksums fail then some changed probably happened in | ||
joblib.hash | ||
""" | ||
array = xarray.DataArray([1], dims=["x"]) | ||
print(testing.checksum_dataarray(array), file=regtest) | ||
|
||
|
||
def test_checksum_dataarray_mapping(regtest): | ||
"""If these checksums fail then some changed probably happened in | ||
joblib.hash | ||
""" | ||
ds = xarray.Dataset({"one": ("x", [1]), "two": ("x", [2])}) | ||
print(testing.checksum_dataarray_mapping(ds), file=regtest) | ||
|
||
|
||
def test_regression_data_unchanged(regtest): | ||
"""This checks that the integration with regtests works and that the | ||
checksum report hasn't change | ||
""" | ||
a = xarray.DataArray([1], dims=["x"], coords={"x": [1]}, attrs={"hello": "world"}) | ||
print(regression_data(a), file=regtest) | ||
|
||
|
||
def test_regression_data_different_attrs(): | ||
a = xarray.DataArray([1], dims=["x"], attrs={"some": "attr"}) | ||
b = xarray.DataArray([1], dims=["x"], attrs={"another": "attr"}) | ||
|
||
assert testing.regression_data(a) != testing.regression_data(b) | ||
assert testing.regression_data(a, attrs=False) == testing.regression_data( | ||
b, attrs=False | ||
) | ||
|
||
|
||
def test_regression_data_different_coords(): | ||
a = xarray.DataArray([1], dims=["x"], coords={"x": [1]}) | ||
b = xarray.DataArray([1], dims=["x"], coords={"x": [2]}) | ||
|
||
assert testing.regression_data(a) != testing.regression_data(b) | ||
assert testing.regression_data(a, coords=False) == testing.regression_data( | ||
b, coords=False | ||
) | ||
|
||
|
||
def test_regression_data_different_array(): | ||
a = xarray.DataArray([2], dims=["x"]) | ||
b = xarray.DataArray([1], dims=["x"]) | ||
|
||
assert testing.regression_data(a) != testing.regression_data(b) |
Oops, something went wrong.