Repository navigation
Ignore labels absent from a cell in least_common
#78
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,11 +111,30 @@ def test_most_common(dummy_lc_data, dummy_target_grid): | |
|
|
||
|
|
||
| def test_least_common(dummy_lc_data, dummy_target_grid): | ||
| # Currently just test if the method runs: code is 99% the same as most_common | ||
|
Contributor
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. Might be nicer to keep this test but with a correct expected outcome rather than a new test that doesn't reuse the old fixtures. i.e.; expected_data = np.array(
[
[2, 2, 0, 0, 0, 0],
[0, 2, 2, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[3, 0, 0, 0, 0, 1],
],
dtype="uint8",
)This expected result will fail on main but is correct for this fixed branch.
Author
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. Done in f1592cc. |
||
| dummy_lc_data["lc"].regrid.least_common( | ||
| # Labels absent from a cell must not be selected. | ||
| expected_data = np.array( | ||
| [ | ||
| [2, 2, 0, 0, 0, 0], | ||
| [0, 2, 2, 0, 0, 0], | ||
| [0, 0, 0, 0, 0, 0], | ||
| [0, 0, 0, 0, 0, 0], | ||
| [0, 0, 0, 0, 0, 0], | ||
| [3, 0, 0, 0, 0, 1], | ||
| ], | ||
| dtype="uint8", | ||
| ) | ||
| input_data_int = dummy_lc_data["lc"].astype("uint8") | ||
|
|
||
| regrid_result = input_data_int.regrid.least_common( | ||
| dummy_target_grid, | ||
| values=EXP_LABELS, | ||
| ) | ||
| xr.testing.assert_equal( | ||
| regrid_result, | ||
| make_expected_ds(expected_data)["lc"], | ||
| ) | ||
|
|
||
| assert regrid_result.dtype == input_data_int.dtype | ||
|
|
||
|
|
||
| def test_oversized_most_common(dummy_lc_data, oversized_dummy_target_grid): | ||
|
|
||
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.
Thanks for catching this issue!