ks905383 / xagg

Aggregating gridded data (xarray) to polygons
https://xagg.readthedocs.io/
GNU General Public License v3.0
82 stars 15 forks source link

Diag fig fix #73

Closed kerriegeil closed 2 months ago

kerriegeil commented 2 months ago

Fixing diag_fig to accept an xarray data array (in addition to dataset). The documentation says this is possible but it is not due to the direct call to create_raster_polygons which skips the wrapper where data arrays are converted to datasets. I've copied the dataset conversion lines to diag_fig from the pixel_overlaps wrapper.

I ran the tests and found 4 fails but they are unrelated to my edits as the fails were present beforehand. This PR includes a fix for two of the fails. They were related to trying to delete the test.nc temporary file while it is open in test_to_netcdf.

The other two fails are related to precision/tolerance, which I didn't look into. (platform win32 -- Python 3.12.4, pytest-8.2.2, pluggy-1.5.0)

FAILED tests/test_export.py::test_to_dataframe - AssertionError: MultiIndex level [0] are different
FAILED tests/test_export.py::test_to_dataframe_renamelocdim - AssertionError: MultiIndex level [0] are different
codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.48%. Comparing base (e637331) to head (6a3e621).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #73 +/- ## ========================================== + Coverage 90.49% 94.48% +3.99% ========================================== Files 15 14 -1 Lines 1136 1088 -48 ========================================== Hits 1028 1028 + Misses 108 60 -48 ``` | [Flag](https://app.codecov.io/gh/ks905383/xagg/pull/73/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kevin+Schwarzwald) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/ks905383/xagg/pull/73/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kevin+Schwarzwald) | `94.48% <100.00%> (+3.99%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kevin+Schwarzwald#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ks905383 commented 2 months ago

Great, thanks!

Odd that the tests are failing locally but not on the GitHub Actions, I wonder if there's something in a newer version of xarray or numpy that's changing tolerance behavior...