From caa966a2b5bdca6f0e69be97c3d44ed71c098b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Sat, 4 Jan 2025 00:02:57 +0100 Subject: [PATCH] docstrings --- pytorch_forecasting/data/timeseries.py | 42 +++++++++++++++----------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/pytorch_forecasting/data/timeseries.py b/pytorch_forecasting/data/timeseries.py index b3f8a0a1..d5ca9496 100644 --- a/pytorch_forecasting/data/timeseries.py +++ b/pytorch_forecasting/data/timeseries.py @@ -1650,19 +1650,23 @@ def _construct_index(self, data: pd.DataFrame, predict_mode: bool) -> pd.DataFra return df_index def filter(self, filter_func: Callable, copy: bool = True) -> "TimeSeriesDataSet": - """ - Filter subsequences in dataset. + """Filter subsequences in dataset. Uses interpretable version of index :py:meth:`~decoded_index` to filter subsequences in dataset. - Args: - filter_func (Callable): function to filter. Should take :py:meth:`~decoded_index` - dataframe as only argument which contains group ids and time index columns. - copy (bool): if to return copy of dataset or filter inplace. + Parameters + ---------- + filter_func : Callable + function to filter. Should take :py:meth:`~decoded_index` + dataframe as only argument which contains group ids and time index columns. + copy : bool, optional, default=True + whether to return copy of dataset (True) or filter inplace (False). - Returns: - TimeSeriesDataSet: filtered dataset + Returns + ------- + TimeSeriesDataSet + filtered dataset """ # calculate filter filtered_index = self.index[np.asarray(filter_func(self.decoded_index))] @@ -1726,17 +1730,21 @@ def plot_randomization( length: int = None, min_length: int = None, ): - """ - Plot expected randomized length distribution. + """Plot expected randomized length distribution. - Args: - betas (Tuple[float, float], optional): Tuple of betas, e.g. ``(0.2, 0.05)`` to use for randomization. - Defaults to ``randomize_length`` of dataset. - length (int, optional): . Defaults to ``max_encoder_length``. - min_length (int, optional): [description]. Defaults to ``min_encoder_length``. + Parameters + ---------- + betas : Tuple[float, float], optional, default=randomize_length of dataset + Tuple of betas, e.g. ``(0.2, 0.05)`` to use for randomization. + length : int, optional, default=max_encoder_length of dataset + Length of sequence to plot. + min_length : int, optional, default=min_encoder_length of dataset + Minimum length of sequence to plot. - Returns: - Tuple[plt.Figure, torch.Tensor]: tuple of figure and histogram based on 1000 samples + Returns + ------- + Tuple[plt.Figure, torch.Tensor] + tuple of figure and histogram based on 1000 samples """ _check_matplotlib("plot_randomization")