From 9544f4e20d95220576886f243531ea793cb738b6 Mon Sep 17 00:00:00 2001 From: autopep8 bot Date: Thu, 13 Jun 2024 12:25:36 +0000 Subject: [PATCH] Automated autopep8 fixes --- fedot_ind/tools/uml/uml.py | 23 ++++++++------ tests/unit/core/models/test_ssa_forecaster.py | 31 ++++++++++++++----- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/fedot_ind/tools/uml/uml.py b/fedot_ind/tools/uml/uml.py index 47dff49f1..b0ac8e4d4 100644 --- a/fedot_ind/tools/uml/uml.py +++ b/fedot_ind/tools/uml/uml.py @@ -4,9 +4,12 @@ from fedot_ind.api.utils.path_lib import DEFAULT_PATH_MODELS with open(DEFAULT_PATH_MODELS, 'r') as file: - file_content = [string for string in file.read().split("\n") if not string.startswith("from")] -file_content = file_content[:next((i for i, line in enumerate(file_content) if line.startswith("def")), None)] -file_content = file_content[next((i for i, line in enumerate(file_content) if line == '}'), None) + 1:] + file_content = [string for string in file.read().split( + "\n") if not string.startswith("from")] +file_content = file_content[:next( + (i for i, line in enumerate(file_content) if line.startswith("def")), None)] +file_content = file_content[next( + (i for i, line in enumerate(file_content) if line == '}'), None) + 1:] pattern = re.compile(r'\b[A-Z_]+\b') @@ -16,7 +19,8 @@ substrings.extend(matches) substrings = list(set(substrings)) -res = ["@startuml", "'https://plantuml.com/sequence-diagram", "", "class AtomizedModel {", " Enum", "}", ""] +res = ["@startuml", "'https://plantuml.com/sequence-diagram", + "", "class AtomizedModel {", " Enum", "}", ""] for ind in substrings: res += ["abstract " + ind] res += ["", ""] @@ -31,13 +35,14 @@ "NEURAL_MODEL -> AtomizedModel", ""] for ind in substrings: - start_index = next((i for i, line in enumerate(file_content) if line.endswith(ind + " = {")), None) - end_index = next((i for i, line in enumerate(file_content[start_index:]) if line.endswith("}")), - None) + 1 + start_index + start_index = next((i for i, line in enumerate( + file_content) if line.endswith(ind + " = {")), None) + end_index = next((i for i, line in enumerate( + file_content[start_index:]) if line.endswith("}")), None) + 1 + start_index list_of_strings = file_content[start_index:end_index] pattern = re.compile(r"': ([^']*)") - formatted_strings = [pattern.search(string).group(1) if pattern.search(string) else "" - for string in list_of_strings] + formatted_strings = [pattern.search(string).group( + 1) if pattern.search(string) else "" for string in list_of_strings] res = res + ["abstract " + ind + " {"] + [string for string in formatted_strings if string.strip() and string.strip() != "{"] + ["}", ""] diff --git a/tests/unit/core/models/test_ssa_forecaster.py b/tests/unit/core/models/test_ssa_forecaster.py index bba307475..de65da904 100644 --- a/tests/unit/core/models/test_ssa_forecaster.py +++ b/tests/unit/core/models/test_ssa_forecaster.py @@ -3,6 +3,7 @@ from fedot.core.data.data import InputData from fedot_ind.core.models.ts_forecasting.ssa_forecaster import SSAForecasterImplementation + class TestSSAForecasterImplementation(unittest.TestCase): def test_default_initialization(self): forecaster = SSAForecasterImplementation() @@ -10,7 +11,11 @@ def test_default_initialization(self): self.assertEqual(forecaster.window_size_method, None) self.assertEqual(forecaster.history_lookback, 100) self.assertEqual(forecaster.low_rank_approximation, False) - self.assertEqual(forecaster.tuning_params, {'tuning_iterations': 100, 'tuning_timeout': 20, 'tuning_early_stop': 20, 'tuner': 'SimultaneousTuner'}) + self.assertEqual(forecaster.tuning_params, + {'tuning_iterations': 100, + 'tuning_timeout': 20, + 'tuning_early_stop': 20, + 'tuner': 'SimultaneousTuner'}) self.assertEqual(forecaster.component_model, 'topological') self.assertEqual(forecaster.mode, 'channel_independent') @@ -19,16 +24,23 @@ def test_custom_initialization(self): 'window_size_method': 'hac', 'history_lookback': 50, 'low_rank_approximation': True, - 'tuning_params': {'tuning_iterations': 50, 'tuning_timeout': 10, 'tuning_early_stop': 10, 'tuner': 'OptunaTuner'}, + 'tuning_params': { + 'tuning_iterations': 50, + 'tuning_timeout': 10, + 'tuning_early_stop': 10, + 'tuner': 'OptunaTuner'}, 'component_model': 'ar', - 'mode': 'one_dimensional' - } + 'mode': 'one_dimensional'} forecaster = SSAForecasterImplementation(params) self.assertIsInstance(forecaster, SSAForecasterImplementation) self.assertEqual(forecaster.window_size_method, 'hac') self.assertEqual(forecaster.history_lookback, 50) self.assertEqual(forecaster.low_rank_approximation, True) - self.assertEqual(forecaster.tuning_params, {'tuning_iterations': 50, 'tuning_timeout': 10, 'tuning_early_stop': 10, 'tuner': 'OptunaTuner'}) + self.assertEqual(forecaster.tuning_params, + {'tuning_iterations': 50, + 'tuning_timeout': 10, + 'tuning_early_stop': 10, + 'tuner': 'OptunaTuner'}) self.assertEqual(forecaster.component_model, 'ar') self.assertEqual(forecaster.mode, 'one_dimensional') @@ -41,7 +53,8 @@ def test_predict_one_dimensional(self): self.assertEqual(forecast.predict.shape, (forecaster.horizon,)) def test_predict_channel_independent(self): - forecaster = SSAForecasterImplementation({'mode': 'channel_independent'}) + forecaster = SSAForecasterImplementation( + {'mode': 'channel_independent'}) time_series = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) input_data = InputData(features=time_series, target=time_series) forecast = forecaster.predict(input_data) @@ -66,9 +79,11 @@ def test_predict_invalid_input(self): with self.assertRaises(ValueError): forecaster.predict(input_data) - input_data = InputData(features=np.array([1, 2, 3]), target=np.array([1, 2])) + input_data = InputData(features=np.array( + [1, 2, 3]), target=np.array([1, 2])) with self.assertRaises(ValueError): forecaster.predict(input_data) + if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main()