Skip to content

Commit

Permalink
added some coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ettel authored and Ettel committed Dec 20, 2023
1 parent c61fd57 commit 6a7fb44
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
Empty file removed src/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions src/safeds/data/tabular/containers/_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ def add_column(self, column: Column) -> TimeSeries:
ColumnSizeError
If the size of the column does not match the number of rows.
"""
new_tagged_table = super().add_column(column)
return TimeSeries._from_tagged_table(
new_tagged_table,
super().add_column(column),
time_name=self.time.name,
)

Expand Down Expand Up @@ -542,6 +541,7 @@ def remove_columns_with_missing_values(self) -> TimeSeries:
if len(set(self.features.column_names).intersection(set(table.column_names))) == 0:
raise IllegalSchemaModificationError("You cannot remove every feature column.")
if self.time.name not in table.column_names:
print("hi")
raise ColumnIsTimeError(self.time.name)
return TimeSeries._from_tagged_table(
TaggedTable._from_table(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ def test_add_columns_as_features(
columns: list[Column] | Table,
time_series_with_new_columns: TimeSeries,
) -> None:
print(time_series.add_columns_as_features(columns).features.column_names)
print(time_series_with_new_columns.features.column_names)
assert_that_time_series_are_equal(time_series.add_columns_as_features(columns), time_series_with_new_columns)
@pytest.mark.parametrize(
("time_series", "columns", "error_msg"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Table, TimeSeries
from safeds.exceptions import ColumnIsTargetError, IllegalSchemaModificationError
from safeds.exceptions import ColumnIsTargetError, IllegalSchemaModificationError, ColumnIsTimeError

from tests.helpers import assert_that_time_series_are_equal

Expand Down Expand Up @@ -199,12 +199,24 @@ def test_should_remove_columns(table: TimeSeries, columns: list[str], expected:
IllegalSchemaModificationError,
r"Illegal schema modification: You cannot remove every feature column.",
),
(
TimeSeries._from_table_to_time_series(
Table({"time": [0, 1, 2], "feat": [1, 2, 3], "non_feat": [1, 2, 3], "target": [4, 5, 6]}),
"target",
"time",
["feat"],
),
["time"],
ColumnIsTimeError,
r'Illegal schema modification: Column "time" is the time column and cannot be removed.',
),
],
ids=[
"remove_only_target",
"remove_non_feat_and_target",
"remove_all_features",
"remove_non_feat_and_all_features",
"remove_time_column",
],
)
def test_should_raise_in_remove_columns(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_should_remove_columns_with_non_numerical_values(table: TimeSeries, expe
{
"time": [0, 1, 2],
"feature": [0, 1, 2],
"non_feature": [1, None, 3],
"non_feature": [1, 2, 3],
"target": [3, 4, None],
},
"target",
Expand Down Expand Up @@ -219,3 +219,4 @@ def test_should_raise_in_remove_columns_with_missing_values(
match=error_msg,
):
table.remove_columns_with_missing_values()

Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@
def test_should_remove_rows_with_missing_values(table: TimeSeries, expected: TimeSeries) -> None:
new_table = table.remove_rows_with_missing_values()
assert_that_time_series_are_equal(new_table, expected)

0 comments on commit 6a7fb44

Please sign in to comment.