Skip to content

Commit

Permalink
Automated autopep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autopep8 bot committed Jun 13, 2024
1 parent 15f96c4 commit 9544f4e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
23 changes: 14 additions & 9 deletions fedot_ind/tools/uml/uml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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 += ["", ""]
Expand All @@ -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() != "{"] + ["}", ""]

Expand Down
31 changes: 23 additions & 8 deletions tests/unit/core/models/test_ssa_forecaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
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()
self.assertIsInstance(forecaster, SSAForecasterImplementation)
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')

Expand All @@ -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')

Expand All @@ -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)
Expand All @@ -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()
unittest.main()

0 comments on commit 9544f4e

Please sign in to comment.