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

Validator does not recognize years as being divisible into months #12

Open
uwagura opened this issue Aug 20, 2024 · 1 comment
Open

Comments

@uwagura
Copy link

uwagura commented Aug 20, 2024

Describe the bug
When you try to run fre pp validate with history_segment: P1M and pp_chunk_a: P1Y, you'll get an error that says that pp_chunk_a should be evenly divisible by the size of the history segment

To Reproduce
Add the above key value pairs to your pp yaml

Expected behavior
The validator should recognize months as being divisible by years and accept PXM as a history segment for any pp chunk of the form PNY if 12*N is divisible by X.

Additional context
This issue seems to stem from how the metomi.isodatetime.parser interprets months - it assumes all months are 30 days long, so when we try to check if a year (which metomi interprets as 365 days) is divisible by months, we get false in the following function:

def is_multiple_of(self, big_chunk, small_chunk):
'''Takes in chunk value e.g P1Y and the chunk reference value from HISTORY_SEGMENT, returns True or False based on the validation to check if the former is a multiple of the latter'''
big_chunk_days = big_chunk.get_days_and_seconds()[0]
small_chunk_days = small_chunk.get_days_and_seconds()[0]
if big_chunk_days % small_chunk_days == 0:
return True
else:
return False

@ceblanton
Copy link
Contributor

Thanks! Completely agree, great catch. @kiihne-noaa started looking at this in #21 and a solution looks straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants