Skip to content
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

Implement kalendar module #189

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Implement kalendar module #189

wants to merge 3 commits into from

Conversation

caldwellst
Copy link
Contributor

Implements #106.

I brought in the kalendar library into our dates.py module. I think we still need our own module to allow for the broader implementation of the user inputted ISO dates/strings and wider work, but has made the implementation much simpler.

This has all been used on the backend for NDVI. However, I made the decision NOT to include the dekad class on the end output. I think that would make it confusing for end users if they potentially saw classes they weren't familiar with or had no desire to use, so rather kept the format of output files having year, dekad, and date columns.

Look forward to your review and thoughts!

@caldwellst caldwellst requested a review from turnerm March 23, 2023 16:08
@caldwellst caldwellst added the enhancement New feature or request with main implementation details already defined label Mar 23, 2023
@caldwellst caldwellst added this to the 1.1 milestone Mar 23, 2023
@codecov-commenter
Copy link

codecov-commenter commented Mar 23, 2023

Codecov Report

Merging #189 (bdf79c5) into develop (c50dab6) will decrease coverage by 0.39%.
The diff coverage is 83.07%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff             @@
##           develop     #189      +/-   ##
===========================================
- Coverage    90.77%   90.38%   -0.39%     
===========================================
  Files           19       19              
  Lines         1311     1300      -11     
===========================================
- Hits          1190     1175      -15     
- Misses         121      125       +4     
Impacted Files Coverage Δ
src/ochanticipy/datasources/usgs/ndvi_base.py 78.57% <82.35%> (+0.11%) ⬆️
src/ochanticipy/utils/dates.py 88.88% <83.33%> (-9.39%) ⬇️
src/ochanticipy/datasources/usgs/ndvi_products.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@turnerm turnerm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Seth, this is cool, I didn't know about @overload! I was reading a bit and I think the preferred way to do this in Python (which maybe could be applied to some other methods, also in Kalendar -- sorry I should have thought of this earlier!) is to use dispatching, see for example this article. Do you think it could work for this case?

@@ -102,15 +98,19 @@ def __init__(
self._data_variable_suffix = data_variable_suffix

# set dates for data download and processing
self._start_date = get_dekadal_date(
input_date=start_date, default_date=_EARLIEST_DATE
self._start_date = get_kalendar_date(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you keep get_dekadal_date here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahaha, because I am a dingus. I didn't have get_dekadal_date() at first.

) -> Tuple[int, int]:
"""Calculate dekadal date from general input.
@overload
def get_kalendar_date(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these two overloaded functions needed - looks like the last one takes care of everything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just for the typing really, but I think I was slightly misusing it. Will revisit after I do some learning on dispatching.

@turnerm turnerm modified the milestones: 1.1, 1.2 Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request with main implementation details already defined
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants