Skip to content

Commit 3daf285

Browse files
Merge branch 'master' into feat/set-up-flake8
2 parents 31d1584 + 96125f8 commit 3daf285

27 files changed

+295
-274
lines changed

darts/dataprocessing/dtw/cost_matrix.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Tuple, Dict
1+
from typing import Tuple
22
import numpy as np
33

44
from .window import Window, CRWindow
@@ -117,8 +117,8 @@ def to_dense(self) -> np.ndarray:
117117

118118
# TODO express only in terms of numpy operations
119119
for i in range(1, self.n + 1):
120-
start = self.window.column_ranges[i * 2 + 0] - 1
121-
end = self.window.column_ranges[i * 2 + 1] - 1
120+
start = ranges[i * 2 + 0] - 1
121+
end = ranges[i * 2 + 1] - 1
122122
len = lengths[i]
123123
offset = self.offsets[i]
124124

@@ -150,7 +150,6 @@ def __setitem__(self, elem, value):
150150
i, j = elem
151151

152152
start = self.column_ranges[i * 2 + 0]
153-
end = self.column_ranges[i * 2 + 1]
154153

155154
self.dense[self.offsets[i] + j - start] = value
156155

darts/dataprocessing/dtw/window.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Iterable, Tuple
2-
from dataclasses import dataclass
31
import numpy as np
42
from darts.logging import raise_if_not, raise_if
53
from abc import ABC, abstractmethod

darts/dataprocessing/transformers/base_data_transformer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ def _transform_iterator(
109109
) -> Iterator[Tuple[TimeSeries]]:
110110
"""
111111
Return an ``Iterator`` object with tuples of inputs for each single call to :func:`ts_transform()`.
112-
Additional `args` and `kwargs` from :func:`transform()` (constant across all the calls to :func:`ts_transform()`)
113-
are already forwarded, and thus don't need to be included in this generator.
112+
Additional `args` and `kwargs` from :func:`transform()` (constant across all the calls to
113+
:func:`ts_transform()`) are already forwarded, and thus don't need to be included in this generator.
114114
115115
The basic implementation of this method returns ``zip(series)``, i.e., a generator of single-valued tuples,
116116
each containing one ``TimeSeries`` object.

darts/dataprocessing/transformers/boxcox.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ def __init__(
4444
name
4545
A specific name for the transformer
4646
lmbda
47-
The parameter :math:`\lambda` of the Box-Cox transform. If a single float is given, the same
48-
:math:`\lambda` value will be used for all dimensions of the series, for all the series.
47+
The parameter :math:`\\lambda` of the Box-Cox transform. If a single float is given, the same
48+
:math:`\\lambda` value will be used for all dimensions of the series, for all the series.
4949
If a sequence is given, there is one value per component in the series. If a sequence of sequence
5050
is given, there is one value per component for all series.
51-
If `None` given, will automatically find an optimal value of :math:`\lambda` (for each dimension
51+
If `None` given, will automatically find an optimal value of :math:`\\lambda` (for each dimension
5252
of the time series, for each time series) using :func:`scipy.stats.boxcox_normmax`
5353
with ``method=optim_method``.
5454
optim_method

darts/datasets/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ class TaylorDataset(DatasetLoaderCSV):
207207
208208
References
209209
----------
210-
.. [1] Taylor, J.W. (2003) Short-term electricity demand forecasting using double seasonal exponential smoothing. Journal of the Operational Research Society, 54, 799-805.
210+
.. [1] Taylor, J.W. (2003) Short-term electricity demand forecasting using double seasonal exponential smoothing.
211+
Journal of the Operational Research Society, 54, 799-805.
211212
212213
.. [2] https://www.rdocumentation.org/packages/forecast/versions/8.13/topics/taylor
213214
"""

darts/datasets/dataset_loaders.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from abc import ABC, abstractmethod
66

77
import pandas as pd
8-
import numpy as np
98
import requests
109

1110
from darts import TimeSeries

darts/metrics/metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
def multi_ts_support(func):
3131
"""
3232
This decorator further adapts the metrics that took as input two univariate/multivariate ``TimeSeries`` instances,
33-
adding support for equally-sized sequences of ``TimeSeries`` instances. The decorator computes the pairwise metric for
34-
``TimeSeries`` with the same indices, and returns a float value that is computed as a function of all the
33+
adding support for equally-sized sequences of ``TimeSeries`` instances. The decorator computes the pairwise metric
34+
for ``TimeSeries`` with the same indices, and returns a float value that is computed as a function of all the
3535
pairwise metrics using a `inter_reduction` subroutine passed as argument to the metric function.
3636
3737
If a 'Sequence[TimeSeries]' is passed as input, this decorator provides also parallelisation of the metric
@@ -1146,7 +1146,7 @@ def rho_risk(
11461146
where :math:`L_{\\rho} \\left( Z, \\hat{Z}_{\\rho} \\right)` is the :math:`\\rho`-loss function:
11471147
11481148
.. math:: L_{\\rho} \\left( Z, \\hat{Z}_{\\rho} \\right) = 2 \\left( Z - \\hat{Z}_{\\rho} \\right)
1149-
\\left( \\rho I_{\\hat{Z}_{\\rho} < Z} - \\left( 1 - \\rho \\right) I_{\\hat{Z}_{\\rho} \geq Z} \\right),
1149+
\\left( \\rho I_{\\hat{Z}_{\\rho} < Z} - \\left( 1 - \\rho \\right) I_{\\hat{Z}_{\\rho} \\geq Z} \\right),
11501150
11511151
where :math:`Z = \\sum_{t=1}^{T} y_t` (1) is the aggregated target value and :math:`\\hat{Z}_{\\rho}` is the
11521152
:math:`\\rho`-quantile of the predicted values. For this, each sample realization :math:`i \\in N` is first

darts/models/filtering/gaussian_process_filter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from sklearn.gaussian_process import GaussianProcessRegressor
1111
from sklearn.gaussian_process.kernels import Kernel
1212

13-
from darts.utils.utils import raise_if_not
1413
from darts.models.filtering.filtering_model import FilteringModel
1514

1615

darts/models/filtering/kalman_filter.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def __init__(self, dim_x: int = 1, kf: Optional[Kalman] = None):
3535
This implementation uses Kalman from the NFourSID package. More information can be found here:
3636
https://nfoursid.readthedocs.io/en/latest/source/kalman.html.
3737
38-
The dimensionality of the measurements z and optional control signal (covariates) u is automatically inferred upon
39-
calling `filter()`.
38+
The dimensionality of the measurements z and optional control signal (covariates) u is automatically inferred
39+
upon calling `filter()`.
4040
4141
Parameters
4242
----------
@@ -47,7 +47,7 @@ def __init__(self, dim_x: int = 1, kf: Optional[Kalman] = None):
4747
If this is provided, the parameter dim_x is ignored. This instance will be copied for every
4848
call to `filter()`, so the state is not carried over from one time series to another across several
4949
calls to `filter()`.
50-
The various dimensionalities of the filter must match those of the `TimeSeries` used when calling `filter()`.
50+
The dimensionalities of the filter must match those of the `TimeSeries` used when calling `filter()`.
5151
"""
5252
# TODO: Add support for x_init. Needs reimplementation of NFourSID.
5353

@@ -85,8 +85,8 @@ def fit(
8585
The series of outputs (observations) used to infer the underlying state space model.
8686
This must be a deterministic series (containing one sample).
8787
covariates : Optional[TimeSeries]
88-
An optional series of inputs (control signal) that will also be used to infer the underlying state space model.
89-
This must be a deterministic series (containing one sample).
88+
An optional series of inputs (control signal) that will also be used to infer the underlying state space
89+
model. This must be a deterministic series (containing one sample).
9090
num_block_rows : Optional[int]
9191
The number of block rows to use in the block Hankel matrices used in the N4SID algorithm.
9292
See the documentation of nfoursid.nfoursid.NFourSID for more information.
@@ -142,11 +142,11 @@ def filter(
142142
Parameters
143143
----------
144144
series : TimeSeries
145-
The series of outputs (observations) used to infer the underlying outputs according to the specified Kalman process.
146-
This must be a deterministic series (containing one sample).
145+
The series of outputs (observations) used to infer the underlying outputs according to the specified Kalman
146+
process. This must be a deterministic series (containing one sample).
147147
covariates : Optional[TimeSeries]
148-
An optional series of inputs (control signal), necessary if the Kalman filter was initialized with covariates.
149-
This must be a deterministic series (containing one sample).
148+
An optional series of inputs (control signal), necessary if the Kalman filter was initialized with
149+
covariates. This must be a deterministic series (containing one sample).
150150
num_samples : int, default: 1
151151
The number of samples to generate from the inferred distribution of the output z. If this is set to 1, the
152152
output is a `TimeSeries` containing a single sample using the mean of the distribution.

darts/models/forecasting/block_rnn_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ def __init__(
226226
Default: ``torch.nn.MSELoss()``.
227227
model_name
228228
Name of the model. Used for creating checkpoints and saving tensorboard data. If not specified,
229-
defaults to the following string ``"YYYY-mm-dd_HH:MM:SS_torch_model_run_PID"``, where the initial part of the
230-
name is formatted with the local date and time, while PID is the processed ID (preventing models spawned at
231-
the same time by different processes to share the same model_name). E.g.,
229+
defaults to the following string ``"YYYY-mm-dd_HH:MM:SS_torch_model_run_PID"``, where the initial part of
230+
the name is formatted with the local date and time, while PID is the processed ID (preventing models spawned
231+
at the same time by different processes to share the same model_name). E.g.,
232232
``"2021-06-14_09:53:32_torch_model_run_44607"``.
233233
work_dir
234234
Path of the working directory, where to save checkpoints and Tensorboard summaries.

0 commit comments

Comments
 (0)