From 6d5f699c9b4e5be4dfc91b6edb9776e9243bdd43 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 19 May 2023 15:56:21 +0200 Subject: [PATCH] added test to test_range_scaler.py to check if the minimum and maximum parameters work correctly --- .../transformation/test_range_scaler.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/safeds/data/tabular/transformation/test_range_scaler.py b/tests/safeds/data/tabular/transformation/test_range_scaler.py index 6693b5853..e85399b8e 100644 --- a/tests/safeds/data/tabular/transformation/test_range_scaler.py +++ b/tests/safeds/data/tabular/transformation/test_range_scaler.py @@ -126,6 +126,47 @@ def test_should_return_transformed_table( ) -> None: assert RangeScaler().fit_and_transform(table, column_names) == expected + @pytest.mark.parametrize( + ("table", "column_names", "expected"), + [ + ( + Table( + { + "col1": [0.0, 5.0, 5.0, 10.0], + }, + ), + None, + Table( + { + "col1": [-10.0, 0.0, 0.0, 10.0], + }, + ), + ), + ( + Table( + { + "col1": [0.0, 5.0, 5.0, 10.0], + "col2": [0.0, 5.0, 5.0, 10.0], + }, + ), + ["col1"], + Table( + { + "col1": [-10.0, 0.0, 0.0, 10.0], + "col2": [0.0, 5.0, 5.0, 10.0], + }, + ), + ), + ], + ) + def test_should_return_transformed_table_with_correct_range( + self, + table: Table, + column_names: list[str] | None, + expected: Table, + ) -> None: + assert RangeScaler(minimum=-10.0, maximum=10.0).fit_and_transform(table, column_names) == expected + def test_should_not_change_original_table(self) -> None: table = Table( {