From 5b3c119a5368c3d4717e6d3e872d9d70a7274603 Mon Sep 17 00:00:00 2001 From: "d.a.bunin" Date: Tue, 18 Apr 2023 14:13:19 +0300 Subject: [PATCH 1/2] fix: warning during creation of ResampleWithDistributionTransform --- etna/transforms/missing_values/resample.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/etna/transforms/missing_values/resample.py b/etna/transforms/missing_values/resample.py index 48b55bb5d..c81c8121c 100644 --- a/etna/transforms/missing_values/resample.py +++ b/etna/transforms/missing_values/resample.py @@ -140,26 +140,30 @@ def __init__( self.in_column = in_column self.distribution_column = distribution_column self.inplace = inplace - self.out_column = self._get_out_column(out_column) + self.out_column = out_column self.in_column_regressor: Optional[bool] = None + + if self.inplace and out_column: + warnings.warn("Transformation will be applied inplace, out_column param will be ignored") + super().__init__( transform=_OneSegmentResampleWithDistributionTransform( in_column=in_column, distribution_column=distribution_column, inplace=inplace, - out_column=self.out_column, + out_column=self._get_column_name(), ), required_features=[in_column, distribution_column], ) - def _get_out_column(self, out_column: Optional[str]) -> str: + def _get_column_name( + self, + ) -> str: """Get the `out_column` depending on the transform's parameters.""" - if self.inplace and out_column: - warnings.warn("Transformation will be applied inplace, out_column param will be ignored") if self.inplace: return self.in_column - if out_column: - return out_column + if self.out_column: + return self.out_column return self.__repr__() def get_regressors_info(self) -> List[str]: @@ -168,7 +172,7 @@ def get_regressors_info(self) -> List[str]: raise ValueError("Fit the transform to get the correct regressors info!") if self.inplace: return [] - return [self.out_column] if self.in_column_regressor else [] + return [self._get_column_name()] if self.in_column_regressor else [] def fit(self, ts: TSDataset) -> "ResampleWithDistributionTransform": """Fit the transform.""" From fd265e96c1a382d77705ab9ea108660efd2d948b Mon Sep 17 00:00:00 2001 From: "d.a.bunin" Date: Tue, 18 Apr 2023 14:15:41 +0300 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7f0593e8..251e1c19d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - - - -- +- Fix warning during creation of `ResampleWithDistributionTransform` ([#1230](https://github.com/tinkoff-ai/etna/pull/1230)) ## [2.0.0] - 2023-04-11 ### Added