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

Subsample checks v2.0! #284

Merged
merged 18 commits into from
Dec 8, 2022
Merged

Conversation

Mikejmnez
Copy link
Collaborator

@Mikejmnez Mikejmnez commented Dec 8, 2022

Sorry about the repeated PR.

This PR addresses same issue #281 and has almost identical code as PR #282 .

I found a weird behavior that it never happens with the ECCO and LLC4320 datasets available through SciServer, but happens with the testing ECCO dataset and thus may happen with some other dataset, under the right combination of arguments.

The error is associated with the following line:

if type(ARCT[i][0]) == _datype:
    ARCT[i] = _xr.merge(ARCT[i])

where ARCT[i] is a list associated with the i-th face and whose elements are either 0 (int) or dataarrays (_datatype). When there are zeros (the negative of that if-statement) it means data within the i-th face does not survive the cutout. When the if-statement is True, data within that face must be transformed.

The bug:

The if statement above assumes the first element (the 0 element) is characteristic of all the elements, but that is not always true. In particular it gives a False positive when the 1st element, a variable or coordinate, doesn't initially have face as a dimension (for example the k, or time).

This situation happens with the test ECCO dataset but not with the data available through SciServer. Nonetheless, I decided to fix this bug just in case and wrote a test for this scenario.

Everything else is the same as the previous PR.

The solution

The bug is fixed by checking that ALL elements are non-zero (or non-integer). The new line is:

if all(type(item) != int for item in ARCT[i]):

This is the only difference between this PR and PR #282

@codecov
Copy link

codecov bot commented Dec 8, 2022

Codecov Report

Merging #284 (c37accc) into main (6f2f8de) will decrease coverage by 0.10%.
The diff coverage is 87.23%.

@@            Coverage Diff             @@
##             main     #284      +/-   ##
==========================================
- Coverage   95.11%   95.01%   -0.11%     
==========================================
  Files          10       10              
  Lines        3848     3888      +40     
  Branches      812      822      +10     
==========================================
+ Hits         3660     3694      +34     
- Misses        122      125       +3     
- Partials       66       69       +3     
Flag Coverage Δ
unittests 95.01% <87.23%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
oceanspy/llc_rearrange.py 88.40% <86.36%> (-0.36%) ⬇️
oceanspy/subsample.py 98.04% <100.00%> (+0.17%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Mikejmnez Mikejmnez merged commit 3b9d2cb into hainegroup:main Dec 8, 2022
@Mikejmnez Mikejmnez deleted the subsample_checks branch December 8, 2022 01:55
@Mikejmnez Mikejmnez mentioned this pull request Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant