From 579004d2f16c9727abf30d20c37cd3832b1e4a0c Mon Sep 17 00:00:00 2001 From: "d.a.bunin" Date: Mon, 11 Apr 2022 10:10:13 +0300 Subject: [PATCH 1/3] Add logging to TSDataset.inverse_transform --- etna/datasets/tsdataset.py | 1 + tests/test_loggers/test_console_logger.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/etna/datasets/tsdataset.py b/etna/datasets/tsdataset.py index 19a7652ab..206ef430e 100644 --- a/etna/datasets/tsdataset.py +++ b/etna/datasets/tsdataset.py @@ -396,6 +396,7 @@ def inverse_transform(self): """ if self.transforms is not None: for transform in reversed(self.transforms): + tslogger.log(f"Inverse transform {repr(transform)} is applied to dataset") self.df = transform.inverse_transform(self.df) @property diff --git a/tests/test_loggers/test_console_logger.py b/tests/test_loggers/test_console_logger.py index cd739b69e..44844cfde 100644 --- a/tests/test_loggers/test_console_logger.py +++ b/tests/test_loggers/test_console_logger.py @@ -64,6 +64,18 @@ def test_tsdataset_make_future_logging(example_tsds: TSDataset): tslogger.remove(idx) +def test_tsdataset_inverse_transform_logging(example_tsds: TSDataset): + """Check working of logging inside `TSDataset.inverse_transform`.""" + transforms = [LagTransform(lags=5, in_column="target"), AddConstTransform(value=5, in_column="target")] + file = NamedTemporaryFile() + _logger.add(file.name) + example_tsds.fit_transform(transforms=transforms) + idx = tslogger.add(ConsoleLogger()) + example_tsds.inverse_transform() + check_logged_transforms(log_file=file.name, transforms=transforms) + tslogger.remove(idx) + + def test_backtest_logging(example_tsds: TSDataset): """Check working of logging inside backtest.""" file = NamedTemporaryFile() From 1255add97ba77250534dbf55de7afd0d1dcc69b8 Mon Sep 17 00:00:00 2001 From: "d.a.bunin" Date: Mon, 11 Apr 2022 10:12:18 +0300 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5b6db3a..3765488d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - - - Add in_column to plot_anomalies, plot_anomalies_interactive ([#618](https://github.com/tinkoff-ai/etna/pull/618)) -- +- Add logging to TSDataset.inverse_transform ([#642](https://github.com/tinkoff-ai/etna/pull/642)) ### Fixed - From 02bd888247ee9d0b7e518a686ed92f65c3b4900b Mon Sep 17 00:00:00 2001 From: "d.a.bunin" Date: Mon, 11 Apr 2022 10:30:08 +0300 Subject: [PATCH 3/3] Fix tests for inverse transform logging --- tests/test_loggers/test_console_logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_loggers/test_console_logger.py b/tests/test_loggers/test_console_logger.py index 44844cfde..c1e19ad08 100644 --- a/tests/test_loggers/test_console_logger.py +++ b/tests/test_loggers/test_console_logger.py @@ -72,7 +72,7 @@ def test_tsdataset_inverse_transform_logging(example_tsds: TSDataset): example_tsds.fit_transform(transforms=transforms) idx = tslogger.add(ConsoleLogger()) example_tsds.inverse_transform() - check_logged_transforms(log_file=file.name, transforms=transforms) + check_logged_transforms(log_file=file.name, transforms=transforms[::-1]) tslogger.remove(idx)