Skip to content

Commit

Permalink
allow pd.Timestamp as start, stop
Browse files Browse the repository at this point in the history
  • Loading branch information
valpesendorfer committed Mar 19, 2024
1 parent f80bf11 commit 367cfeb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hdc/algo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def to_linspace(x) -> Tuple[np.ndarray, List[int]]:

def get_calibration_indices(
time: pd.DatetimeIndex,
start: str,
stop: str,
start: Union[str, pd.Timestamp],
stop: Union[str, pd.Timestamp],
groups: Optional[Iterable[Union[int, float, str]]] = None,
num_groups: Optional[int] = None,
) -> Union[Tuple[int, int], np.ndarray]:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def test_to_linspace(input_array, expected_output):

def test_get_calibration_indices():
tix = pd.date_range("2010-01-01", "2010-12-31")

assert get_calibration_indices(tix, tix[0], tix[-1]) == (0, 365)
assert get_calibration_indices(tix, "2010-01-01", "2010-12-31") == (0, 365)
assert get_calibration_indices(tix, "2010-01-15", "2010-12-15") == (14, 349)

Expand Down

0 comments on commit 367cfeb

Please sign in to comment.