Skip to content

Commit

Permalink
apply suggestions from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisbader committed Nov 6, 2023
1 parent deb3903 commit 28424e3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion darts/dataprocessing/encoders/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ def __init__(
BoxCox(). The transformers will be fitted on the training dataset when calling calling `model.fit()`.
The training, validation and inference datasets are then transformed equally.
Supported time zone:
optionally, apply a time zone conversion with keyword 'tz'. This converts the time zone-naive index to a
Optionally, apply a time zone conversion with keyword 'tz'. This converts the time zone-naive index to a
timezone `'tz'` before applying the `'cyclic'` or `'datetime_attribute'` temporal encoders.
An example of a valid `add_encoders` dict for hourly data:
Expand Down
13 changes: 10 additions & 3 deletions darts/tests/utils/test_timeseries_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,25 @@ def helper_routine(idx, attr, vals_exp, **kwargs):
np.testing.assert_array_almost_equal(vals_act, vals_exp)

# no pd.DatetimeIndex
with pytest.raises(ValueError):
with pytest.raises(ValueError) as err:
helper_routine(
pd.RangeIndex(start=0, stop=len(idx)), "h", vals_exp=np.arange(len(idx))
)
assert str(err.value).startswith(
"`time_index` must be a pandas `DatetimeIndex`"
)

# invalid attribute
with pytest.raises(ValueError):
with pytest.raises(ValueError) as err:
helper_routine(idx, "h", vals_exp=np.arange(len(idx)))
assert str(err.value).startswith(
"attribute `h` needs to be an attribute of pd.DatetimeIndex."
)

# no time zone aware index
with pytest.raises(ValueError):
with pytest.raises(ValueError) as err:
helper_routine(idx.tz_localize("UTC"), "h", vals_exp=np.arange(len(idx)))
assert "`time_index` must be time zone naive." == str(err.value)

# ===> datetime attribute
# hour
Expand Down
4 changes: 2 additions & 2 deletions darts/utils/timeseries_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def holidays_timeseries(
Parameters
----------
time_index
Either a `pd.DatetimeIndex` or a `TimeSeries` for which to generate the holidays/
Either a `pd.DatetimeIndex` or a `TimeSeries` for which to generate the holidays.
country_code
The country ISO code.
prov
Expand All @@ -561,7 +561,7 @@ def holidays_timeseries(
Extend the time_index by add_length, should match or exceed forecasting window.
Set only one of until and add_length.
column_name
Optionally, the name of the value column for the returned TimeSeries/
Optionally, the name of the value column for the returned TimeSeries.
dtype
The desired NumPy dtype (np.float32 or np.float64) for the resulting series.
tz
Expand Down

0 comments on commit 28424e3

Please sign in to comment.