Skip to content

Commit

Permalink
Merge pull request #872 from uber/871-fit-method-fail-for-timezone-aw…
Browse files Browse the repository at this point in the history
…are-timeseries

Quick fix 871
  • Loading branch information
edwinnglabs authored Jul 9, 2024
2 parents 0aab3d7 + bd6f6d3 commit cde4167
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions orbit/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ def update_dict(original_dict, append_dict):


def is_ordered_datetime(array):
"""Returns True if array is ordered and non-repetitive"""
return np.all(np.diff(array).astype(float) > 0)
"""Returns True if array is ordered and non-repetitive
Use pandas .diff() method to take care of both tz and non-tz series consistently
By default pandas .diff() would generate a NaT for the first period
instead of skipping like np.diff. So dropna() to remove.
"""
diff = array.to_series().diff().dropna().values
return np.all(diff.astype(float) > 0)


def is_even_gap_datetime(array):
Expand Down

0 comments on commit cde4167

Please sign in to comment.