Skip to content

Commit

Permalink
check for None
Browse files Browse the repository at this point in the history
  • Loading branch information
wgifford committed Jul 11, 2024
1 parent 0842387 commit ea4dd6e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tsfm_public/toolkit/time_series_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,15 @@ def get_frequency_token(self, token_name: str):
try:
token_name_offs = to_offset(token_name).freqstr
token = self.frequency_mapping.get(token_name_offs, None)
return token
if token is not None:
return token
except ValueError:
# lastly try to map the timedelta to a frequency string
token_name_td = pd._libs.tslibs.timedeltas.Timedelta(token_name)
token_name_offs = to_offset(token_name_td).freqstr
token = self.frequency_mapping.get(token_name_offs, None)
return token
if token is not None:
return token

warn(f"Frequency token {token_name} was not found in the frequncy token mapping.")
token = self.frequency_mapping["oov"]
Expand Down

0 comments on commit ea4dd6e

Please sign in to comment.