jbusecke / xMIP

Analysis ready CMIP6 data in python the easy way with pangeo tools.
https://cmip6-preprocessing.readthedocs.io/en/latest/?badge=latest
Apache License 2.0
197 stars 44 forks source link

Test interp nominal lon #365

Closed JoranAngevaare closed 2 months ago

JoranAngevaare commented 3 months ago

Fix test for _interp_nominal_lon

This PR is some leftover work from #296 (and #300)

PR checks

JoranAngevaare commented 2 months ago

@jbusecke of course value-errors result in failed tests and this syntax does trigger the tests:

(py39) aangevaare@surfclimahuge:~/software/xMIP$ pytest tests/test_preprocessing.py -k TestReplaceXYNominalLatLon
================================================= test session starts ==================================================
platform linux -- Python 3.9.0, pytest-8.2.2, pluggy-1.5.0 -- /home/aangevaare/miniconda3/envs/py39/bin/python
cachedir: .pytest_cache
rootdir: /home/aangevaare/software/xMIP
configfile: pyproject.toml
collected 140 items / 138 deselected / 2 selected

tests/test_preprocessing.py::TestReplaceXYNominalLatLon::test_old_fails PASSED                                   [ 50%]
tests/test_preprocessing.py::TestReplaceXYNominalLatLon::test_new_works PASSED                                   [100%]

=================================================== warnings summary ===================================================
xmip/preprocessing.py:4
  /home/aangevaare/software/xMIP/xmip/preprocessing.py:4: UserWarning: Import(s) unavailable to set up matplotlib support...skipping this portion of the setup.
    import cf_xarray.units  # noqa: F401

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================================== 2 passed, 138 deselected, 1 warning in 8.37s =====================================

But sure, let me write assert statements if that's more conform the way things are done for xmip

JoranAngevaare commented 2 months ago

@jbusecke as requested:

jbusecke commented 2 months ago

of course value-errors result in failed tests and this syntax does trigger the tests

Thanks for verifying this. And it obviously makes sense (Ill keep that in mind for future test designs, and thanks for teachibg me this!). I should have tested this myself (but am using gh on mobile so am a bit restricted here).