Skip to content

Commit

Permalink
Revert "fixed UnknownError"
Browse files Browse the repository at this point in the history
This reverts commit 7437360.
  • Loading branch information
Gerhardsa0 committed Feb 27, 2024
1 parent e85b887 commit 3e08d06
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 86 deletions.
32 changes: 22 additions & 10 deletions src/safeds/data/tabular/containers/_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,14 +946,20 @@ def plot_time_series_lineplot(self, y_column_name: str | None = None, x_column_n
self._data.index.name = "index"
if y_column_name is None:
y_column_name = self.target.name
else:
if y_column_name not in self._data.columns:
raise UnknownColumnNameError([y_column_name])
if x_column_name is None:
x_column_name = "index"
else:
if x_column_name not in self._data.columns:
raise UnknownColumnNameError([x_column_name])
if not self.get_column(x_column_name).type.is_numeric():
raise NonNumericColumnError("The time series plotted column contains non-numerical columns.")
if not self.has_column(x_column_name) or not self.has_column(y_column_name):
similar_columns_x = self._get_similar_columns(x_column_name)
similar_columns_y = self._get_similar_columns(y_column_name)
raise UnknownColumnNameError(
([x_column_name] if not self.has_column(x_column_name) else [])
+ ([y_column_name] if not self.has_column(y_column_name) else []),
(similar_columns_x if not self.has_column(x_column_name) else [])
+ (similar_columns_y if not self.has_column(y_column_name) else []),
)
if not self.get_column(y_column_name).type.is_numeric():
raise NonNumericColumnError("The time series plotted column contains non-numerical columns.")

Expand Down Expand Up @@ -1020,14 +1026,20 @@ def plot_time_series_scatterplot(
self._data.index.name = "index"
if y_column_name is None:
y_column_name = self.target.name
else:
if y_column_name not in self._data.columns:
raise UnknownColumnNameError([y_column_name])
if x_column_name is None:
x_column_name = "index"
else:
if x_column_name not in self._data.columns:
raise UnknownColumnNameError([x_column_name])
if not self.get_column(x_column_name).type.is_numeric():
raise NonNumericColumnError("The time series plotted column contains non-numerical columns.")
if not self.has_column(x_column_name) or not self.has_column(y_column_name):
similar_columns_x = self._get_similar_columns(x_column_name)
similar_columns_y = self._get_similar_columns(y_column_name)
raise UnknownColumnNameError(
([x_column_name] if not self.has_column(x_column_name) else [])
+ ([y_column_name] if not self.has_column(y_column_name) else []),
(similar_columns_x if not self.has_column(x_column_name) else [])
+ (similar_columns_y if not self.has_column(y_column_name) else []),
)
if not self.get_column(y_column_name).type.is_numeric():
raise NonNumericColumnError("The time series plotted column contains non-numerical columns.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_should_raise_if_column_contains_non_numerical_values() -> None:
r" non-numerical columns."
),
):
table.plot_time_series_lineplot( x_column_name="target")
table.plot_time_series_lineplot()


@pytest.mark.parametrize(
Expand Down Expand Up @@ -227,40 +227,3 @@ def test_should_raise_error_optional_parameter_y(
match=error_msg,
):
time_series.plot_time_series_lineplot(y_column_name=name)
def test_should_raise_if_column_does_not_exist_x() -> None:
table = TimeSeries(
{
"time": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"feature_1": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"target": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
},
target_name="target",
time_name="time",
feature_names=None,
)
with pytest.raises(
UnknownColumnNameError,
match=(
"Could not find column\(s\) '2'."
),
):
table.plot_time_series_lineplot( x_column_name="target", y_column_name="2")

def test_should_raise_if_column_does_not_exist_y() -> None:
table = TimeSeries(
{
"time": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"feature_1": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"target": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
},
target_name="target",
time_name="time",
feature_names=None,
)
with pytest.raises(
UnknownColumnNameError,
match=(
"Could not find column\(s\) '2'."
),
):
table.plot_time_series_lineplot( x_column_name="2", y_column_name="target")
Original file line number Diff line number Diff line change
Expand Up @@ -227,41 +227,3 @@ def test_should_raise_error_optional_parameter_y(
match=error_msg,
):
time_series.plot_time_series_scatterplot(y_column_name=name)

def test_should_raise_if_column_does_not_exist_x() -> None:
table = TimeSeries(
{
"time": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"feature_1": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"target": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
},
target_name="target",
time_name="time",
feature_names=None,
)
with pytest.raises(
UnknownColumnNameError,
match=(
"Could not find column\(s\) '2'."
),
):
table.plot_time_series_scatterplot( x_column_name="target", y_column_name="2")

def test_should_raise_if_column_does_not_exist_y() -> None:
table = TimeSeries(
{
"time": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"feature_1": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"target": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
},
target_name="target",
time_name="time",
feature_names=None,
)
with pytest.raises(
UnknownColumnNameError,
match=(
"Could not find column\(s\) '2'."
),
):
table.plot_time_series_scatterplot( x_column_name="2", y_column_name="target")

0 comments on commit 3e08d06

Please sign in to comment.