-
Notifications
You must be signed in to change notification settings - Fork 128
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
feat: support treetime ambiguous date format #1305
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,12 @@ def get_numerical_date_from_value(value, fmt=None, min_max_year=None): | |
except InvalidDate as error: | ||
raise AugurError(str(error)) from error | ||
return [treetime.utils.numeric_date(d) for d in ambig_date] | ||
if value.startswith('[') and value.endswith(']') and len(value[1:-1].split(':'))==2: | ||
# Treetime ambiguous date format, e.g. [2019.5:2020.5] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious how you get the numerical dates in metadata. Is this a standard format outside of TreeTime, or do you run ISO dates through something like Asking because I think a good next step after this gets merged is to generalize for any |
||
try: | ||
return [float(x) for x in value[1:-1].split(':')] | ||
except ValueError as error: | ||
raise AugurError(str(error)) from error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: customize the error message. When given something like
It's obvious what this means to us as developers, but maybe not so obvious to users. Something like this might be more clear:
|
||
try: | ||
return treetime.utils.numeric_date(datetime.datetime.strptime(value, fmt)) | ||
except: | ||
|
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.
For added context, this is the corresponding logic in TreeTime: treetime/utils.py#L305-L312