tobac-project / tobac

Tracking and object-based analysis of clouds
BSD 3-Clause "New" or "Revised" License
99 stars 53 forks source link

Wrap decorators to preserve docstrings and move to separate module #359

Closed w-k-jones closed 10 months ago

w-k-jones commented 11 months ago

Resolves #356 and reorganises decorators to a separate module

codecov[bot] commented 11 months ago

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (5f096e3) 56.68% compared to head (c137f44) 56.77%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## RC_v1.5.x #359 +/- ## ============================================= + Coverage 56.68% 56.77% +0.08% ============================================= Files 19 20 +1 Lines 3426 3433 +7 ============================================= + Hits 1942 1949 +7 Misses 1484 1484 ``` | [Flag](https://app.codecov.io/gh/tobac-project/tobac/pull/359/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tobac-project) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/tobac-project/tobac/pull/359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tobac-project) | `56.77% <96.70%> (+0.08%)` | :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=tobac-project#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/tobac-project/tobac/pull/359?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tobac-project) | Coverage Δ | | |---|---|---| | [tobac/utils/bulk\_statistics.py](https://app.codecov.io/gh/tobac-project/tobac/pull/359?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tobac-project#diff-dG9iYWMvdXRpbHMvYnVsa19zdGF0aXN0aWNzLnB5) | `82.75% <100.00%> (ø)` | | | [tobac/utils/internal/basic.py](https://app.codecov.io/gh/tobac-project/tobac/pull/359?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tobac-project#diff-dG9iYWMvdXRpbHMvaW50ZXJuYWwvYmFzaWMucHk=) | `80.73% <100.00%> (-6.51%)` | :arrow_down: | | [tobac/utils/periodic\_boundaries.py](https://app.codecov.io/gh/tobac-project/tobac/pull/359?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tobac-project#diff-dG9iYWMvdXRpbHMvcGVyaW9kaWNfYm91bmRhcmllcy5weQ==) | `97.00% <100.00%> (ø)` | | | [tobac/utils/decorators.py](https://app.codecov.io/gh/tobac-project/tobac/pull/359?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tobac-project#diff-dG9iYWMvdXRpbHMvZGVjb3JhdG9ycy5weQ==) | `96.51% <96.51%> (ø)` | |

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

w-k-jones commented 11 months ago

Note that I wasn't able to use functools.wrap with the njit_if_available decorator because it works a bit differently to usual. If you have any ideas @freemansw1 let me know, but given that it's only used on internal functions I don't think the lack of docstrings when calling help is a problem, unlike with the xarray conversion decorators which wrap the main user functions

freemansw1 commented 10 months ago

Note that I wasn't able to use functools.wrap with the njit_if_available decorator because it works a bit differently to usual. If you have any ideas @freemansw1 let me know, but given that it's only used on internal functions I don't think the lack of docstrings when calling help is a problem, unlike with the xarray conversion decorators which wrap the main user functions

My guess is that this is done automagically through Numba because help returns the correct docstring; when I return func the correct docstring is also reported.

JuliaKukulies commented 10 months ago

Many thanks for this one, @w-k-jones! I went ahead and fixed the merge conflicts. When everything looks fine for you, please go ahead and merge :)

JuliaKukulies commented 10 months ago

Ready to merge @w-k-jones @freemansw1 ? :)