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

feat: IMPLEMENTS CHECKING FOR VARIABLE MATES #237

Merged
merged 5 commits into from
Nov 16, 2020
Merged

feat: IMPLEMENTS CHECKING FOR VARIABLE MATES #237

merged 5 commits into from
Nov 16, 2020

Conversation

fraserwg
Copy link
Contributor

On a latlon LLC grid some variables have mates. This commit will produce a meaningful error if attempting to use get_dataset or faces_dataset_to_latlon to load a variable without its mate.

See Github issue #234

On a latlon grid some variables have mates. This commit will produce
a meaningful error if attempting to use `get_dataset` or
`faces_dataset_to_latlon` to load a variable without its mate.

See Github issue #234
@fraserwg fraserwg changed the title feat: IMPLEMENTS CHAECKING FOR VARIABLE MATES feat: IMPLEMENTS CHECKING FOR VARIABLE MATES Nov 12, 2020
Copy link
Member

@rabernat rabernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thank you so much.

We will just need a test for this scenario. It would go in here:

Something like

def test_vector_mate_error(local_llc90_store):
    store = local_llc90_store
    model = llcreader.LLC90Model(store)
    with pyest.raises(ValueError, match=r".* must also be .*"):
        ds_latlon = model.get_dataset(type='latlon', varnames=['U'], iter_start=0, iter_stop=9, iter_step=8)

vnames.remove(mate)
except ValueError:
msg = 'If {} in varnames, {} must also be in varnames'.format(vname, mate)
raise ValueError(msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR makes me realize we have some duplicative code paths in here. I'm trying to understand why we need to implement this in both _all_facets_to_latlon and faces_dataset_to_latlon. I think that faces_dataset_to_latlon should probably be refactored to call _all_facets_to_latlon. However, that is not your problem.

@rabernat rabernat mentioned this pull request Nov 12, 2020
6 tasks
@fraserwg
Copy link
Contributor Author

I've added the test function but am now getting test fails on the Xarray-master build, details below:

=========================== short test summary info ============================
257
FAILED xmitgcm/test/test_llcreader.py::test_ecco_portal_load[2160] - ValueErr...
258
FAILED xmitgcm/test/test_llcreader.py::test_ecco_portal_load[4320] - ValueErr...
259
====== 2 failed, 276 passed, 3 skipped, 124 warnings in 106.82s (0:01:46) ======

The tests weren't failing for the previous commit and I haven't changed the tests that are now failing. Also the other builds are passing (as are the tests on my local machine) -- could this be a problem with a new commit on the Xarray-master branch? Any ideas for where to start with debugging would be appreciated, I'm relatively new to the world of CI and pytest!

removed test for vector mate error to determine whether CI problems are
coming from the test or an xarray-master commit
@fraserwg
Copy link
Contributor Author

Have just added a new commit with the test removed again. Looks like everything's passed suggesting the problem is indeed with my test function.

@fraserwg
Copy link
Contributor Author

Ok, all the problems have been sorted, it was just a missing pair of brackets :)

@rabernat
Copy link
Member

Fantastic! Thanks so much. I appreciate your patience to sort out the CI failures.

@rabernat rabernat merged commit 66b1198 into MITgcm:master Nov 16, 2020
@fraserwg fraserwg deleted the latlon_mate_test branch November 16, 2020 09:48
fraserwg added a commit to fraserwg/xmitgcm that referenced this pull request Nov 23, 2021
* feat: IMPLEMENTS CHAECKING FOR VARIABLE MATES

On a latlon grid some variables have mates. This commit will produce
a meaningful error if attempting to use `get_dataset` or
`faces_dataset_to_latlon` to load a variable without its mate.

See Github issue MITgcm#234

* test: ADDED TEST FOR THE MATE ERROR

* test: REMOVED TEST FOR VECTOR MATE ERROR

removed test for vector mate error to determine whether CI problems are
coming from the test or an xarray-master commit

* fix: ADDED TEST BACK AND CHANGED ARGUMENTS
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.

2 participants