-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reduce length of cftime resample tests #2879
Reduce length of cftime resample tests #2879
Conversation
Looks good to me. Thank you for looking into this promptly! Let's wait for @jwenfai to review before merging. |
Thanks for taking on the task of shortening test times! If the coverage is the same, I think the rewritten tests should be good. Just two things I feel I should mention:
Both of the problems I mentioned might have been from the earliest iteration of CFTimeIndex resampling so they might have no relevance now. |
Thanks for having a look @jwenfai! I updated my PR following your suggestions; this added some more tests so now the total time is around 9 seconds. I opted for listing the pairs of initial and resample frequencies explicitly rather than use a function to dynamically set one based on the other (I feel like it makes the tests easier to understand; also writing a function that converts one type of frequency to another similar-length-but-different-type frequency is messy). |
Wow, that's quick. The updated tests look fine to me so go ahead and merge it. |
I'm going to go ahead and merge this; we can revisit things again if we want to continue to speed these tests up. |
* master: (29 commits) Handle the character array dim name (pydata#2896) Partial fix for pydata#2841 to improve formatting. (pydata#2906) docs: Move quick overview one level up (pydata#2890) Manually specify chunks in open_zarr (pydata#2530) Minor improvement of docstring for Dataset (pydata#2904) Fix minor typos in docstrings (pydata#2903) Added docs example for `xarray.Dataset.get()` (pydata#2894) Bugfix for docs build instructions (pydata#2897) Return correct count for scalar datetime64 arrays (pydata#2892) Indexing with an empty array (pydata#2883) BUG: Fix pydata#2864 by adding the missing vrt parameters (pydata#2865) Reduce length of cftime resample tests (pydata#2879) WIP: type annotations (pydata#2877) decreased pytest verbosity (pydata#2881) Fix mypy typing error in cftime_offsets.py (pydata#2878) update links to https (pydata#2872) revert to 0.12.2 dev 0.12.1 release Various fixes for explicit Dataset.indexes (pydata#2858) Fix minor typo in docstring (pydata#2860) ...
The main issue is that we were resampling the same time indexes across a large range of frequencies, in some cases producing very long results, e.g. resampling an index that spans 27 years to a frequency of 12 hours.
This modifies the primary test so that it constructs time indexes whose ranges are based on the frequencies we resample to. Now in total the tests in
test_cftimeindex_resample.py
take around 6 seconds.@jwenfai I did some coverage analysis offline, and these tests produce the same coverage that we had before (I found it necessary to be sure to test cases where the reference index had either a shorter or longer frequency than the resample frequency). Do you think what I have here is sufficient? I think we could potentially shorten things even more, but I'm not sure if it's worth the effort.
See below for the new profiling results; now the longest cftime tests are no longer associated with resample.