Skip to content
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

Fix/ Allow empty TimeSeries #1359

Merged
merged 6 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion darts/tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_timeseries_constructor_error_log(self):
(
"darts.timeseries",
"ERROR",
"ValueError: The time series array must not be empty.",
"ValueError: TimeSeries require DataArray of dimensionality 3 (('time', 'component', 'sample')).",
)
)

Expand Down
5 changes: 4 additions & 1 deletion darts/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def __init__(self, xa: xr.DataArray):
"TimeSeries.from_times_and_values(), etc...).",
logger,
)
raise_if_not(xa.size > 0, "The time series array must not be empty.", logger)
raise_if_not(
len(xa.shape) == 3,
f"TimeSeries require DataArray of dimensionality 3 ({DIMS}).",
Expand Down Expand Up @@ -293,6 +292,10 @@ def __init__(self, xa: xr.DataArray):
# Store static covariates and hierarchy in attributes (potentially storing None)
self._xa = _xarray_with_attrs(self._xa, static_covariates, hierarchy)

# at the end since other exceptions can prevent the creation of the time serie
if not xa.size > 0:
logger.warning("TimeSeries is empty.")

"""
Factory Methods
===============
Expand Down