Skip to content

Commit

Permalink
style: apply automated linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann authored and github-actions[bot] committed Mar 30, 2023
1 parent a624465 commit eee1d9e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 34 deletions.
33 changes: 12 additions & 21 deletions tests/safeds/ml/classification/test_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
import pandas as pd
import pytest
from _pytest.fixtures import FixtureRequest

from safeds.data.tabular.containers import Column, Table, TaggedTable
from safeds.exceptions import LearningError, PredictionError
from safeds.ml.classification import Classifier, AdaBoost, DecisionTree, GradientBoosting, KNearestNeighbors, \
LogisticRegression, RandomForest
from safeds.ml.classification import (
AdaBoost,
Classifier,
DecisionTree,
GradientBoosting,
KNearestNeighbors,
LogisticRegression,
RandomForest,
)


def classifiers() -> list[Classifier]:
Expand All @@ -23,14 +29,7 @@ def classifiers() -> list[Classifier]:
The list of classifiers to test.
"""

return [
AdaBoost(),
DecisionTree(),
GradientBoosting(),
KNearestNeighbors(2),
LogisticRegression(),
RandomForest()
]
return [AdaBoost(), DecisionTree(), GradientBoosting(), KNearestNeighbors(2), LogisticRegression(), RandomForest()]


@pytest.fixture()
Expand All @@ -57,11 +56,7 @@ def invalid_data() -> TaggedTable:
).tag_columns(target_name="target", feature_names=["feat1", "feat2"])


@pytest.mark.parametrize(
"classifier",
classifiers(),
ids=lambda x: x.__class__.__name__
)
@pytest.mark.parametrize("classifier", classifiers(), ids=lambda x: x.__class__.__name__)
class TestFit:
def test_should_succeed_on_valid_data(self, classifier: Classifier, valid_data: TaggedTable) -> None:
classifier.fit(valid_data)
Expand All @@ -78,11 +73,7 @@ def test_should_raise_on_invalid_data(self, classifier: Classifier, invalid_data
classifier.fit(invalid_data)


@pytest.mark.parametrize(
"classifier",
classifiers(),
ids=lambda x: x.__class__.__name__
)
@pytest.mark.parametrize("classifier", classifiers(), ids=lambda x: x.__class__.__name__)
class TestPredict:
def test_should_include_features_of_input_table(self, classifier: Classifier, valid_data: TaggedTable) -> None:
fitted_classifier = classifier.fit(valid_data)
Expand Down
28 changes: 15 additions & 13 deletions tests/safeds/ml/regression/test_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
import pandas as pd
import pytest
from _pytest.fixtures import FixtureRequest

from safeds.data.tabular.containers import Column, Table, TaggedTable
from safeds.exceptions import ColumnLengthMismatchError, LearningError, PredictionError
from safeds.ml.regression import Regressor, AdaBoost, DecisionTree, ElasticNetRegression, GradientBoosting, \
KNearestNeighbors, LassoRegression, LinearRegression, RandomForest, RidgeRegression
from safeds.ml.regression import (
AdaBoost,
DecisionTree,
ElasticNetRegression,
GradientBoosting,
KNearestNeighbors,
LassoRegression,
LinearRegression,
RandomForest,
Regressor,
RidgeRegression,
)

# noinspection PyProtectedMember
from safeds.ml.regression._regressor import _check_metrics_preconditions

Expand Down Expand Up @@ -62,11 +72,7 @@ def invalid_data() -> TaggedTable:
).tag_columns(target_name="target", feature_names=["feat1", "feat2"])


@pytest.mark.parametrize(
"regressor",
regressors(),
ids=lambda x: x.__class__.__name__
)
@pytest.mark.parametrize("regressor", regressors(), ids=lambda x: x.__class__.__name__)
class TestFit:
def test_should_succeed_on_valid_data(self, regressor: Regressor, valid_data: TaggedTable) -> None:
regressor.fit(valid_data)
Expand All @@ -83,11 +89,7 @@ def test_should_raise_on_invalid_data(self, regressor: Regressor, invalid_data:
regressor.fit(invalid_data)


@pytest.mark.parametrize(
"regressor",
regressors(),
ids=lambda x: x.__class__.__name__
)
@pytest.mark.parametrize("regressor", regressors(), ids=lambda x: x.__class__.__name__)
class TestPredict:
def test_should_include_features_of_input_table(self, regressor: Regressor, valid_data: TaggedTable) -> None:
fitted_regressor = regressor.fit(valid_data)
Expand Down

0 comments on commit eee1d9e

Please sign in to comment.