-
Notifications
You must be signed in to change notification settings - Fork 41
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
Rework mappers to be more general #174
Conversation
yes! something very similar see #175. I would use Can you unify the two PRs? |
Codecov Report
@@ Coverage Diff @@
## main #174 +/- ##
==========================================
+ Coverage 95.86% 95.91% +0.05%
==========================================
Files 11 11
Lines 1305 1347 +42
==========================================
+ Hits 1251 1292 +41
- Misses 54 55 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Should we try to use the new functions as much as possible? |
Yes I think that is right. You'll basically implement #165 too :) if you change all the calls to |
Sounds good! I started with |
Actually, the readthedocs action caught it. Should be |
I'm not following what's happening here: cf-xarray/cf_xarray/accessor.py Lines 813 to 837 in 425c472
I must use _get_coords in __call__ , otherwise this fails:
from cf_xarray.datasets import airds
airds.air.cf.weighted("area").mean(["latitude", "time"]).cf.plot(x="longitude") Error is ValueError: Cannot specify both x and y kwargs for line plots However,
|
Phew after some debugging...
Also
We were also missing one line plot case ( |
Should we merge cf-xarray/cf_xarray/accessor.py Line 631 in a3178b5
|
I'd like to keep them separate for now since they do different things. One optimization is to add We can do this later though. This is a nice change already. |
Mmmm, I don't think we are getting the right error here: from cf_xarray.datasets import popds
popds.cf.differentiate("longitude") ValueError: Coordinate longitude does not exist. The error should be raised before by
|
Should we somehow always set this True when using cf-xarray/cf_xarray/accessor.py Lines 176 to 177 in bc2b14d
|
Yes looks right |
Actually, I think we can still allow the case with no results. Let's use a very specific message here, so we know this one should always be raised, or an error different than KeyError? cf-xarray/cf_xarray/accessor.py Lines 409 to 412 in bc2b14d
|
KeyError seems right, what do you want to change? It looks like |
from cf_xarray.datasets import popds
popds.cf.differentiate("longitude") I think longitude is mapped to 2 variables, but cf-xarray/cf_xarray/accessor.py Lines 975 to 978 in bc2b14d
Error should be "Multiple results for 'longitude' found: ['ULONG', 'TLONG']. I expected only one." |
I say we raise ValueError in |
Sounds good |
in |
Yes that's my favorite solution but I think we need a slightly more specific error because "expected only one" is also used by |
Should be almost good to go. Unless you think we should add more tests to make sure we cover all signatures and their xarray functions, we can probably merge and explicitly add functions to the accessor later if we find conflicts. |
LGTM. Thanks @malmans2 |
@dcherian were you thinking something along these lines?
Currently
_get_dims/coords/indexes
use_get_axis_coord
and_get_with_standard_name
.We can probably get rid of
_get_axis_coord
and_get_with_standard_name
, I just wanted to check first whether that's the way to go as they are used in many places. Not sure if all_get_axis_coord
can be replaced by the same function (e.g.,_get_coords
) or it's not that simple.All tests are passing, I didn't add new tests yet.