-
Notifications
You must be signed in to change notification settings - Fork 54
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
Porting the converting decorators from v2 #179
Conversation
Codecov ReportBase: 39.03% // Head: 40.82% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## RC_v1.5.0 #179 +/- ##
=============================================
+ Coverage 39.03% 40.82% +1.78%
=============================================
Files 11 11
Lines 2262 2332 +70
=============================================
+ Hits 883 952 +69
- Misses 1379 1380 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Thanks for doing this, @snilsn . My initial review is to approve these without changes, but I do want to take the time to check what happens if we port a tobac function over using these. I do wonder if we want to automatically convert output to xarray? It would be nice in v1.5 or v1.6 to let things be an option (i.e., allow users to output as pandas while giving an xarray). That said, I think that's a different PR, and this one from v2.0-dev is important. Given that you were here first, I'm going to recommend merging this before #191, and I will update #191 to match. These functions are in |
Providing different options is a good idea @freemansw1. Partially this option with putting in xarray, but getting out pandas is already implemented with the diferent decorators, The last test I designed as an integration test, using one of the decorators to port the main |
Good point, @snilsn. And implementing these won't impact the user-facing code for now anyway, so I've approved the PR. |
I worked on a more streamlined testing approach for this, systematically checking a lot of input combinations. I found one bug, where the keys of a dict were accessed instead of the values. Fixed that for all decorators. More importantly, there is some inconsistent behavior: If a function is decorated to support a certain datatype, but the "old" datatype is used as input, there are cases where the output is converted to the new datatype, and others where it isn't. It depends on the presence of keyword arguments that are converted. I don't think we need to address this right now, since the conversion of the output should probably be optional as @freemansw1 said, but worth noting. |
Good points, and good change @snilsn ! I expect that we may modify these functions in 1.6+ as we start getting everything integrated, but good to start checking/integrating these now. I'm still happy with the changes. We can merge once @JuliaKukulies has time to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@snilsn @freemansw1 I tested the decorators using radar data and all seemed to flow as necessary. There is the example of use cases in the test file, but it would be useful/helpful to add an example in the utils.py file for the function. Something like:
Example usage:
get_spacings_xarray = tobac.utils.xarray_to_iris(tobac.utils.get_spacings)
dxy, dt = tobac.utils.get_spacings(data)
dxy_xarray, dt_xarray = get_spacings_xarray(data_xarray)
However, I realize this isn't standard in the utils.py and I'll defer to @freemansw1 opinion here.
Thanks very much for reviewing, @kelcyno! I think an example use would be helpful in the docs, but I would guess that the primary use would be as a decorator, so we would All that said, yes, I agree that we should put the basic use in the docs. Great suggestion! |
Totally see your point @kelcyno, I'm going to add something like this. Just wasn't sure if we are going to threat these decorators as purely internal utilities or not, but i guess it's also a good idea for testing and experimenting with them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're fine leaving them as internal functions, we can think about examples for other use cases in the future releases and document them as needed..
@freemansw1 @kelcyno I resolved the conflict and added examples for For the examples I followed the numpydocs styleguide and the result with the highlighted codesnippets looks actually quite nice: https://tobac--179.org.readthedocs.build/en/179/tobac.html#module-tobac.utils |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, great work @snilsn ! Now I also got the time to test your decorators and I have nothing to add. Just a small comment on the documentation, otherwise it looks all good!
I'm happy with the changes, so as long as @kelcyno approves your most recent changes, we can merge. |
@freemansw1 @snilsn I'm happy with the changes that have been made, glad to approve. |
Fantastic! @snilsn are you happy to merge? If so, I'll merge. |
Yes, please go ahead @freemansw1 |
I have ported the 4 converting decorators that enable a rudimentary xarray support from tobac v2 to 1.5. I also added some tests and fixed some bugs I found during this process.
Not yet, probably not needed