-
Notifications
You must be signed in to change notification settings - Fork 44
Issue #761 better diff for apex reference check #765
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
Merged
dsamaey
merged 10 commits into
master
from
761-apex-reference-check-needs-better-representation-ascii-art-diff-diff-image-statistics
May 13, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bdb906b
Issue #761 better diff for apex reference check
e723729
Issue #761 better diff for apex reference check (added scipy dependency)
a25597b
Issue #761 better diff for apex reference check (added ascii art diff)
d88a124
Issue #761 better diff for apex reference check (added ascii art diff)
916b868
Issue #761 better diff for apex reference check (more robust xy/yx gr…
ce0cc5f
Issue #761 better diff for apex reference check (fixed boundary value…
3e8860f
Issue #761 better diff for apex reference check (default ascii_art ma…
ce58771
Issue #761 better diff for apex reference check (deps fix)
5bcc5e7
Issue #761 better diff for apex reference check
fcad19e
Issue #761 better diff for apex reference check (replaced convex hull…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
from openeo.testing.results import ( | ||
_compare_xarray_dataarray, | ||
assert_job_results_allclose, | ||
assert_xarray_allclose, | ||
assert_xarray_dataarray_allclose, | ||
assert_xarray_dataset_allclose, | ||
) | ||
|
@@ -351,6 +350,110 @@ def test_allclose_minimal_success(self, tmp_path, actual_dir, expected_dir): | |
ds.to_netcdf(actual_dir / "data.nc") | ||
assert_job_results_allclose(actual=actual_dir, expected=expected_dir, tmp_path=tmp_path) | ||
|
||
def test_allclose_xy_success(self, tmp_path, actual_dir, expected_dir): | ||
expected_ds = xarray.Dataset( | ||
{ | ||
"b1": xarray.Variable(dims=["t", "x", "y"], data=2 * numpy.ones((3, 4, 5))), | ||
"b2": xarray.Variable(dims=["t", "x", "y"], data=3 * numpy.ones((3, 4, 5))), | ||
}, | ||
coords={ | ||
"t": range(0, 3), | ||
"x": range(4, 8), | ||
"y": range(5, 10), | ||
}, | ||
) | ||
expected_ds.to_netcdf(expected_dir / "data.nc") | ||
actual_ds = xarray.Dataset( | ||
{ | ||
"b1": xarray.Variable(dims=["t", "x", "y"], data=1 * numpy.ones((3, 4, 5))), | ||
"b2": xarray.Variable(dims=["t", "x", "y"], data=3 * numpy.ones((3, 4, 5))), | ||
}, | ||
coords={ | ||
"t": range(0, 3), | ||
"x": range(4, 8), | ||
"y": range(5, 10), | ||
}, | ||
) | ||
actual_ds.to_netcdf(actual_dir / "data.nc") | ||
assert_job_results_allclose(actual=actual_dir, expected=expected_dir, tmp_path=tmp_path, rtol=1) | ||
|
||
def test_allclose_minimal_xy_different(self, tmp_path, actual_dir, expected_dir): | ||
expected_ds = xarray.Dataset( | ||
{ | ||
"b1": xarray.Variable(dims=["t", "x", "y"], data=2 * numpy.ones((3, 4, 5))), | ||
"b2": xarray.Variable(dims=["t", "x", "y"], data=3 * numpy.ones((3, 4, 5))), | ||
}, | ||
coords={ | ||
"t": range(0, 3), | ||
"x": range(4, 8), | ||
"y": range(5, 10), | ||
}, | ||
) | ||
expected_ds.to_netcdf(expected_dir / "data.nc") | ||
actual_ds = xarray.Dataset( | ||
{ | ||
"b1": xarray.Variable(dims=["t", "x", "y"], data=1 * numpy.ones((3, 4, 5))), | ||
"b2": xarray.Variable(dims=["t", "x", "y"], data=3 * numpy.ones((3, 4, 5))), | ||
}, | ||
coords={ | ||
"t": range(0, 3), | ||
"x": range(4, 8), | ||
"y": range(5, 10), | ||
}, | ||
) | ||
actual_ds.to_netcdf(actual_dir / "data.nc") | ||
with raises_assertion_error_or_not( | ||
r"Issues for file 'data.nc'.*" | ||
r"Issues for variable 'b1'.*" | ||
r"Left and right DataArray objects are not close.*Differing values:.*" | ||
r"t 0: value difference exceeds tolerance \(rtol 1e-06, atol 1e-06\), min:1.0, max: 1.0, mean: 1.0, var: 0.0.*" | ||
r"t 0: differing pixels: 20/20 \(100.0%\), bbox \(\(4, 5\), \(7, 9\)\) - 100.0% of the area.*" | ||
r"t 1: value difference exceeds tolerance \(rtol 1e-06, atol 1e-06\), min:1.0, max: 1.0, mean: 1.0, var: 0.0.*" | ||
r"t 1: differing pixels: 20/20 \(100.0%\), bbox \(\(4, 5\), \(7, 9\)\) - 100.0% of the area.*" | ||
r"t 2: value difference exceeds tolerance \(rtol 1e-06, atol 1e-06\), min:1.0, max: 1.0, mean: 1.0, var: 0.0.*" | ||
r"t 2: differing pixels: 20/20 \(100.0%\), bbox \(\(4, 5\), \(7, 9\)\) - 100.0% of the area" | ||
): | ||
assert_job_results_allclose(actual=actual_dir, expected=expected_dir, tmp_path=tmp_path) | ||
|
||
def test_allclose_minimal_xy_different_small_area(self, tmp_path, actual_dir, expected_dir): | ||
expected_ds = xarray.Dataset( | ||
{ | ||
"b1": xarray.Variable(dims=["t", "x", "y"], data=2 * numpy.ones((3, 4, 5))), | ||
"b2": xarray.Variable(dims=["t", "x", "y"], data=3 * numpy.ones((3, 4, 5))), | ||
}, | ||
coords={ | ||
"t": range(0, 3), | ||
"x": range(4, 8), | ||
"y": range(5, 10), | ||
}, | ||
) | ||
expected_ds.to_netcdf(expected_dir / "data.nc") | ||
b2_modified_data = 3 * numpy.ones((3, 4, 5)) | ||
b2_modified_data[2][2][2] *= 15 | ||
b2_modified_data[2][2][3] *= 14 | ||
b2_modified_data[2][3][2] *= 13 | ||
b2_modified_data[2][3][3] *= 12 | ||
actual_ds = xarray.Dataset( | ||
{ | ||
"b1": xarray.Variable(dims=["t", "x", "y"], data=2 * numpy.ones((3, 4, 5))), | ||
"b2": xarray.Variable(dims=["t", "x", "y"], data=b2_modified_data), | ||
}, | ||
coords={ | ||
"t": range(0, 3), | ||
"x": range(4, 8), | ||
"y": range(5, 10), | ||
}, | ||
) | ||
actual_ds.to_netcdf(actual_dir / "data.nc") | ||
with raises_assertion_error_or_not( | ||
r"Issues for file 'data.nc'.*" | ||
r"Issues for variable 'b2'.*" | ||
r"Left and right DataArray objects are not close.*Differing values:.*" | ||
r"t 2: value difference exceeds tolerance \(rtol 1e-06, atol 1e-06\), min:33.0, max: 42.0, mean: 37.5, var: 11.2.*" | ||
r"t 2: differing pixels: 4/20 \(20.0%\), bbox \(\(6, 7\), \(7, 8\)\) - 8.3% of the area" | ||
): | ||
assert_job_results_allclose(actual=actual_dir, expected=expected_dir, tmp_path=tmp_path) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a simple test for |
||
def test_allclose_basic_fail(self, tmp_path, actual_dir, expected_dir): | ||
expected_ds = xarray.Dataset({"a": (["time"], [1, 2, 3])}, coords={"time": [11, 22, 33]}) | ||
expected_ds.to_netcdf(expected_dir / "data.nc") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you document what the difference is with the existing
_compare_xarray_dataarray
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or isn't it possible to integrate this feature in the existing
_compare_xarray_dataarray
instead of duplicating most of it?