From 29fdefa3c038562f0c4d5b82f38d8d587f73b839 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Wed, 8 Jan 2025 16:30:32 +0100 Subject: [PATCH] feat: make `data` parameter of `Table` and `Column` required (#978) ### Summary of Changes The `data` parameter of `Table` and `Column` must now be specified. Being able to omit it was nice for tests, but also means that users might forget to specify their data. Since tables and columns are immutable, creating an empty table is rarely useful in practice. --------- Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> --- src/safeds/data/tabular/containers/_column.py | 5 +---- src/safeds/data/tabular/containers/_table.py | 11 ++++------- .../safeds/data/image/containers/test_image.py | 2 +- .../data/image/containers/test_image_list.py | 8 ++++---- .../containers/_tabular_dataset/test_eq.py | 3 ++- .../containers/_tabular_dataset/test_extras.py | 3 ++- .../containers/_time_series_dataset/test_eq.py | 3 ++- .../_time_series_dataset/test_extras.py | 3 ++- .../labeled/containers/test_image_dataset.py | 18 +++++++++--------- .../tabular/containers/_cell/test_equals.py | 3 ++- .../data/tabular/containers/_column/test_eq.py | 11 ++++++----- .../tabular/containers/_column/test_hash.py | 7 ++++--- .../tabular/containers/_column/test_init.py | 5 +---- .../containers/_row/test_column_count.py | 2 +- .../tabular/containers/_row/test_get_cell.py | 2 +- .../tabular/containers/_row/test_getitem.py | 2 +- .../tabular/containers/_row/test_has_column.py | 2 +- .../data/tabular/containers/_row/test_hash.py | 4 ++-- .../data/tabular/containers/_row/test_iter.py | 2 +- .../data/tabular/containers/_row/test_len.py | 2 +- .../tabular/containers/_row/test_schema.py | 2 +- .../containers/_string_cell/test_equals.py | 3 ++- .../containers/_table/test_add_column.py | 5 +++-- .../containers/_table/test_add_columns.py | 9 +++++---- .../containers/_table/test_column_count.py | 3 ++- .../containers/_table/test_column_names.py | 3 ++- .../containers/_table/test_dataframe.py | 3 ++- .../data/tabular/containers/_table/test_eq.py | 7 ++++--- .../containers/_table/test_from_columns.py | 3 ++- .../containers/_table/test_from_csv_file.py | 4 ++-- .../containers/_table/test_from_dict.py | 3 ++- .../containers/_table/test_from_json_file.py | 4 ++-- .../_table/test_from_polars_dataframe.py | 2 +- .../containers/_table/test_get_column.py | 3 ++- .../containers/_table/test_has_column.py | 3 ++- .../tabular/containers/_table/test_hash.py | 3 ++- .../tabular/containers/_table/test_init.py | 3 ++- .../containers/_table/test_remove_columns.py | 15 ++++++++------- .../_table/test_remove_columns_except.py | 9 +++++---- .../test_remove_columns_with_missing_values.py | 3 ++- .../_table/test_remove_duplicate_rows.py | 3 ++- .../_table/test_remove_non_numeric_columns.py | 3 ++- .../test_remove_rows_with_missing_values.py | 3 ++- .../_table/test_remove_rows_with_outliers.py | 3 ++- .../containers/_table/test_rename_column.py | 3 ++- .../containers/_table/test_replace_column.py | 3 ++- .../tabular/containers/_table/test_repr.py | 3 ++- .../containers/_table/test_repr_html.py | 7 ++++--- .../containers/_table/test_row_count.py | 3 ++- .../containers/_table/test_shuffle_rows.py | 3 ++- .../tabular/containers/_table/test_sizeof.py | 3 ++- .../containers/_table/test_slice_rows.py | 7 ++++--- .../containers/_table/test_sort_rows.py | 9 +++++---- .../containers/_table/test_split_rows.py | 3 ++- .../data/tabular/containers/_table/test_str.py | 3 ++- .../_table/test_summarize_statistics.py | 5 +++-- .../containers/_table/test_to_columns.py | 3 ++- .../containers/_table/test_to_csv_file.py | 6 +++--- .../tabular/containers/_table/test_to_dict.py | 3 ++- .../containers/_table/test_to_json_file.py | 5 +++-- .../containers/_table/test_transform_column.py | 3 ++- .../containers/_table/test_transform_table.py | 3 ++- .../containers/_temporal_cell/test_equals.py | 3 ++- .../safeds/data/tabular/containers/test_row.py | 2 +- .../tabular/plotting/test_plot_boxplots.py | 5 +++-- .../plotting/test_plot_correlation_heatmap.py | 5 +++-- .../tabular/plotting/test_plot_histogram_2d.py | 6 +++--- .../tabular/plotting/test_plot_histograms.py | 5 +++-- .../tabular/plotting/test_plot_lineplot.py | 6 +++--- .../tabular/plotting/test_plot_scatterplot.py | 5 +++-- .../tabular/plotting/test_plot_violin_plots.py | 5 +++-- .../tabular/transformation/test_discretizer.py | 5 +++-- .../converters/test_input_converter_image.py | 4 ++-- .../converters/test_input_converter_image_2.py | 3 ++- .../test_input_converter_time_series.py | 3 ++- .../safeds/ml/nn/layers/test_dropout_layer.py | 5 +++-- .../safeds/ml/nn/layers/test_flatten_layer.py | 5 +++-- .../ml/nn/layers/test_pooling2d_layer.py | 5 +++-- 78 files changed, 197 insertions(+), 150 deletions(-) diff --git a/src/safeds/data/tabular/containers/_column.py b/src/safeds/data/tabular/containers/_column.py index abe325726..0f18c8b27 100644 --- a/src/safeds/data/tabular/containers/_column.py +++ b/src/safeds/data/tabular/containers/_column.py @@ -68,12 +68,9 @@ def _from_polars_series(data: Series) -> Column: # Dunder methods # ------------------------------------------------------------------------------------------------------------------ - def __init__(self, name: str, data: Sequence[T_co] | None = None) -> None: + def __init__(self, name: str, data: Sequence[T_co]) -> None: import polars as pl - if data is None: - data = [] - self._series: pl.Series = pl.Series(name, data, strict=False) def __contains__(self, item: Any) -> bool: diff --git a/src/safeds/data/tabular/containers/_table.py b/src/safeds/data/tabular/containers/_table.py index df9c8d4ff..5ca59a53c 100644 --- a/src/safeds/data/tabular/containers/_table.py +++ b/src/safeds/data/tabular/containers/_table.py @@ -243,7 +243,7 @@ def from_json_file(path: str | Path) -> Table: return Table._from_polars_data_frame(pl.read_json(path)) except (pl.exceptions.PanicException, pl.exceptions.ComputeError): # Can happen if the JSON file is empty (https://github.com/pola-rs/polars/issues/10234) - return Table() + return Table({}) @staticmethod def from_parquet_file(path: str | Path) -> Table: @@ -304,12 +304,9 @@ def _from_polars_lazy_frame(data: pl.LazyFrame) -> Table: # Dunder methods # ------------------------------------------------------------------------------------------------------------------ - def __init__(self, data: Mapping[str, Sequence[Any]] | None = None) -> None: + def __init__(self, data: Mapping[str, Sequence[Any]]) -> None: import polars as pl - if data is None: - data = {} - # Validation expected_length: int | None = None for column_values in data.values(): @@ -487,7 +484,7 @@ def add_columns( except DuplicateError: # polars already validates this, so we don't need to do it again upfront (performance) _check_columns_dont_exist(self, [column.name for column in columns]) - return Table() # pragma: no cover + return Table({}) # pragma: no cover def add_computed_column( self, @@ -1837,7 +1834,7 @@ def summarize_statistics(self) -> Table: +----------------------+---------+ """ if self.column_count == 0: - return Table() + return Table({}) head = self.get_column(self.column_names[0]).summarize_statistics() tail = [self.get_column(name).summarize_statistics().get_column(name)._series for name in self.column_names[1:]] diff --git a/tests/safeds/data/image/containers/test_image.py b/tests/safeds/data/image/containers/test_image.py index 3959a5ab3..939930f7c 100644 --- a/tests/safeds/data/image/containers/test_image.py +++ b/tests/safeds/data/image/containers/test_image.py @@ -307,7 +307,7 @@ def test_should_not_be_equal(self, device: Device) -> None: def test_should_be_not_implemented(self, resource_path: str, device: Device) -> None: configure_test_with_device(device) image = Image.from_file(resolve_resource_path(resource_path)) - other = Table() + other = Table({}) assert (image.__eq__(other)) is NotImplemented diff --git a/tests/safeds/data/image/containers/test_image_list.py b/tests/safeds/data/image/containers/test_image_list.py index 27a4c52e9..81d85738c 100644 --- a/tests/safeds/data/image/containers/test_image_list.py +++ b/tests/safeds/data/image/containers/test_image_list.py @@ -121,7 +121,7 @@ def test_from_files(self, resource_path1: str, resource_path2: str, resource_pat assert image_list != image_list_unequal_1 assert image_list != image_list_unequal_2 assert image_list != image_list_unequal_3 - assert image_list.__eq__(Table()) is NotImplemented + assert image_list.__eq__(Table({})) is NotImplemented # Test hash assert hash(image_list) == hash(image_list_clone) @@ -746,7 +746,7 @@ def test_should_save_images_in_files(self, resource_path: list[str], device: Dev with tempfile.TemporaryDirectory() as tmp_parent_dir: tmp_files = [ - tempfile.NamedTemporaryFile(suffix=".jpg", prefix=str(i), dir=tmp_parent_dir) + tempfile.NamedTemporaryFile(suffix=".jpg", prefix=str(i), dir=tmp_parent_dir) # noqa: SIM115 for i in range(len(image_list)) ] for tmp_file in tmp_files: @@ -837,7 +837,7 @@ def test_should_save_images_in_files(self, resource_path: list[str], device: Dev with tempfile.TemporaryDirectory() as tmp_parent_dir: tmp_files = [ - tempfile.NamedTemporaryFile(suffix=".png", prefix=str(i), dir=tmp_parent_dir) + tempfile.NamedTemporaryFile(suffix=".png", prefix=str(i), dir=tmp_parent_dir) # noqa: SIM115 for i in range(len(image_list)) ] for tmp_file in tmp_files: @@ -1540,7 +1540,7 @@ def test_repr_png(self, device: Device) -> None: def test_eq(self, device: Device) -> None: configure_test_with_device(device) assert _EmptyImageList() == _EmptyImageList() - assert _EmptyImageList().__eq__(Table()) is NotImplemented + assert _EmptyImageList().__eq__(Table({})) is NotImplemented def test_hash(self, device: Device) -> None: configure_test_with_device(device) diff --git a/tests/safeds/data/labeled/containers/_tabular_dataset/test_eq.py b/tests/safeds/data/labeled/containers/_tabular_dataset/test_eq.py index e9f3236c2..0c1e095e4 100644 --- a/tests/safeds/data/labeled/containers/_tabular_dataset/test_eq.py +++ b/tests/safeds/data/labeled/containers/_tabular_dataset/test_eq.py @@ -1,6 +1,7 @@ from typing import Any import pytest + from safeds.data.labeled.containers import TabularDataset from safeds.data.tabular.containers import Table @@ -66,7 +67,7 @@ def test_should_return_whether_two_tabular_datasets_are_equal( ("table", "other"), [ (TabularDataset({"a": [1, 2, 3], "b": [4, 5, 6]}, "b"), None), - (TabularDataset({"a": [1, 2, 3], "b": [4, 5, 6]}, "b"), Table()), + (TabularDataset({"a": [1, 2, 3], "b": [4, 5, 6]}, "b"), Table({})), ], ids=[ "TabularDataset vs. None", diff --git a/tests/safeds/data/labeled/containers/_tabular_dataset/test_extras.py b/tests/safeds/data/labeled/containers/_tabular_dataset/test_extras.py index 001b15524..1c380af59 100644 --- a/tests/safeds/data/labeled/containers/_tabular_dataset/test_extras.py +++ b/tests/safeds/data/labeled/containers/_tabular_dataset/test_extras.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.labeled.containers import TabularDataset from safeds.data.tabular.containers import Table @@ -16,7 +17,7 @@ }, target_name="T", ), - Table(), + Table({}), ), ( TabularDataset( diff --git a/tests/safeds/data/labeled/containers/_time_series_dataset/test_eq.py b/tests/safeds/data/labeled/containers/_time_series_dataset/test_eq.py index 938714ceb..09ed375a1 100644 --- a/tests/safeds/data/labeled/containers/_time_series_dataset/test_eq.py +++ b/tests/safeds/data/labeled/containers/_time_series_dataset/test_eq.py @@ -1,6 +1,7 @@ from typing import Any import pytest + from safeds.data.labeled.containers import TimeSeriesDataset from safeds.data.tabular.containers import Table @@ -101,7 +102,7 @@ def test_should_return_whether_two_tabular_datasets_are_equal( ), ( TimeSeriesDataset({"a": [1, 2, 3], "b": [4, 5, 6], "c": [0, 0, 0]}, "b", window_size=1), - Table(), + Table({}), ), ], ids=[ diff --git a/tests/safeds/data/labeled/containers/_time_series_dataset/test_extras.py b/tests/safeds/data/labeled/containers/_time_series_dataset/test_extras.py index 6a1b2c0f8..3aae37aaa 100644 --- a/tests/safeds/data/labeled/containers/_time_series_dataset/test_extras.py +++ b/tests/safeds/data/labeled/containers/_time_series_dataset/test_extras.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.labeled.containers import TimeSeriesDataset from safeds.data.tabular.containers import Table @@ -17,7 +18,7 @@ target_name="T", window_size=1, ), - Table(), + Table({}), ), ( TimeSeriesDataset( diff --git a/tests/safeds/data/labeled/containers/test_image_dataset.py b/tests/safeds/data/labeled/containers/test_image_dataset.py index bd02f32ce..c38b5fa0b 100644 --- a/tests/safeds/data/labeled/containers/test_image_dataset.py +++ b/tests/safeds/data/labeled/containers/test_image_dataset.py @@ -5,6 +5,9 @@ import pytest import torch +from torch import Tensor +from torch.types import Device + from safeds._config import _get_device from safeds.data.image.containers import ImageList from safeds.data.image.containers._empty_image_list import _EmptyImageList @@ -20,9 +23,6 @@ OutputLengthMismatchError, TransformerNotFittedError, ) -from torch import Tensor -from torch.types import Device - from tests.helpers import ( configure_test_with_device, get_devices, @@ -43,11 +43,11 @@ class TestImageDatasetInit: [ ( _MultiSizeImageList(), - Table(), + Table({}), ValueError, r"The given input ImageList contains images of different sizes.", ), - (_EmptyImageList(), Table(), ValueError, r"The given input ImageList contains no images."), + (_EmptyImageList(), Table({}), ValueError, r"The given input ImageList contains no images."), ( ImageList.from_files(resolve_resource_path([plane_png_path, plane_png_path])), ImageList.from_files(resolve_resource_path([plane_png_path, white_square_png_path])), @@ -62,7 +62,7 @@ class TestImageDatasetInit: ), ( ImageList.from_files(resolve_resource_path(plane_png_path)), - Table(), + Table({}), OutputLengthMismatchError, r"The length of the output container differs", ), @@ -210,7 +210,7 @@ def test_should_not_be_equal( def test_should_be_not_implemented(self, device: Device) -> None: configure_test_with_device(device) image_dataset = ImageDataset(ImageList.from_files(resolve_resource_path(plane_png_path)), Column("images", [1])) - other = Table() + other = Table({}) assert image_dataset.__eq__(other) is NotImplemented @@ -510,7 +510,7 @@ def test_should_raise_from_tensor(self, tensor: Tensor, error_msg: str, device: def test_eq_should_be_not_implemented(self, device: Device) -> None: configure_test_with_device(device) - assert _TableAsTensor(Table()).__eq__(Table()) is NotImplemented + assert _TableAsTensor(Table({})).__eq__(Table({})) is NotImplemented @pytest.mark.parametrize("device", get_devices(), ids=get_devices_ids()) @@ -554,7 +554,7 @@ def test_should_raise_from_tensor( def test_eq_should_be_not_implemented(self, device: Device) -> None: configure_test_with_device(device) - assert _ColumnAsTensor(Column("column", [1])).__eq__(Table()) is NotImplemented + assert _ColumnAsTensor(Column("column", [1])).__eq__(Table({})) is NotImplemented def test_should_not_warn(self, device: Device) -> None: configure_test_with_device(device) diff --git a/tests/safeds/data/tabular/containers/_cell/test_equals.py b/tests/safeds/data/tabular/containers/_cell/test_equals.py index 3a859c08a..e5f1c01eb 100644 --- a/tests/safeds/data/tabular/containers/_cell/test_equals.py +++ b/tests/safeds/data/tabular/containers/_cell/test_equals.py @@ -2,6 +2,7 @@ import polars as pl import pytest + from safeds.data.tabular.containers import Cell, Table from safeds.data.tabular.containers._lazy_cell import _LazyCell @@ -30,7 +31,7 @@ def test_should_return_true_if_objects_are_identical() -> None: ("cell", "other"), [ (_LazyCell(pl.col("a")), None), - (_LazyCell(pl.col("a")), Table()), + (_LazyCell(pl.col("a")), Table({})), ], ids=[ "Cell vs. None", diff --git a/tests/safeds/data/tabular/containers/_column/test_eq.py b/tests/safeds/data/tabular/containers/_column/test_eq.py index 109ade51c..50f32808b 100644 --- a/tests/safeds/data/tabular/containers/_column/test_eq.py +++ b/tests/safeds/data/tabular/containers/_column/test_eq.py @@ -1,15 +1,16 @@ from typing import Any import pytest + from safeds.data.tabular.containers import Column, Table @pytest.mark.parametrize( ("column1", "column2", "expected"), [ - (Column("a"), Column("a"), True), + (Column("a", []), Column("a", []), True), (Column("a", [1, 2, 3]), Column("a", [1, 2, 3]), True), - (Column("a"), Column("b"), False), + (Column("a", []), Column("b", []), False), (Column("a", [1, 2, 3]), Column("a", [1, 2, 4]), False), (Column("a", [1, 2, 3]), Column("a", ["1", "2", "3"]), False), ], @@ -28,7 +29,7 @@ def test_should_return_whether_two_columns_are_equal(column1: Column, column2: C @pytest.mark.parametrize( "column", [ - Column("a"), + Column("a", []), Column("a", [1, 2, 3]), ], ids=[ @@ -43,8 +44,8 @@ def test_should_return_true_if_objects_are_identical(column: Column) -> None: @pytest.mark.parametrize( ("column", "other"), [ - (Column("a"), None), - (Column("a", [1, 2, 3]), Table()), + (Column("a", []), None), + (Column("a", [1, 2, 3]), Table({})), ], ids=[ "Column vs. None", diff --git a/tests/safeds/data/tabular/containers/_column/test_hash.py b/tests/safeds/data/tabular/containers/_column/test_hash.py index 0f6900bcd..8783118b6 100644 --- a/tests/safeds/data/tabular/containers/_column/test_hash.py +++ b/tests/safeds/data/tabular/containers/_column/test_hash.py @@ -1,11 +1,12 @@ import pytest + from safeds.data.tabular.containers import Column @pytest.mark.parametrize( ("column", "expected"), [ - (Column("a"), 1581717131331298536), + (Column("a", []), 1581717131331298536), (Column("a", [1, 2, 3]), 239695622656180157), ], ids=[ @@ -20,9 +21,9 @@ def test_should_be_deterministic(column: Column, expected: int) -> None: @pytest.mark.parametrize( ("column1", "column2", "expected"), [ - (Column("a"), Column("a"), True), + (Column("a", []), Column("a", []), True), (Column("a", [1, 2, 3]), Column("a", [1, 2, 3]), True), - (Column("a"), Column("b"), False), + (Column("a", []), Column("b", []), False), (Column("a", [1, 2, 3]), Column("a", [1, 2]), False), (Column("a", [1, 2, 3]), Column("a", ["1", "2", "3"]), False), # We don't use the column values in the hash calculation diff --git a/tests/safeds/data/tabular/containers/_column/test_init.py b/tests/safeds/data/tabular/containers/_column/test_init.py index e065924bd..d4c163557 100644 --- a/tests/safeds/data/tabular/containers/_column/test_init.py +++ b/tests/safeds/data/tabular/containers/_column/test_init.py @@ -1,6 +1,7 @@ from typing import Any import pytest + from safeds.data.tabular.containers import Column @@ -12,14 +13,10 @@ def test_should_store_the_name() -> None: @pytest.mark.parametrize( ("column", "expected"), [ - (Column("a"), []), - (Column("a", None), []), (Column("a", []), []), (Column("a", [1, 2, 3]), [1, 2, 3]), ], ids=[ - "none (implicit)", - "none (explicit)", "empty", "non-empty", ], diff --git a/tests/safeds/data/tabular/containers/_row/test_column_count.py b/tests/safeds/data/tabular/containers/_row/test_column_count.py index fb6dc98bb..c7a65c9e0 100644 --- a/tests/safeds/data/tabular/containers/_row/test_column_count.py +++ b/tests/safeds/data/tabular/containers/_row/test_column_count.py @@ -7,7 +7,7 @@ @pytest.mark.parametrize( ("table", "expected"), [ - (Table(), 0), + (Table({}), 0), (Table({"A": [1, 2, 3]}), 1), ], ids=[ diff --git a/tests/safeds/data/tabular/containers/_row/test_get_cell.py b/tests/safeds/data/tabular/containers/_row/test_get_cell.py index 4bd0214f1..aec1adf63 100644 --- a/tests/safeds/data/tabular/containers/_row/test_get_cell.py +++ b/tests/safeds/data/tabular/containers/_row/test_get_cell.py @@ -30,7 +30,7 @@ def test_should_get_correct_item(table_data: dict, column_name: str, target: int @pytest.mark.parametrize( ("table", "column_name"), [ - (Table(), "A"), + (Table({}), "A"), (Table({"A": ["a", "aa", "aaa"]}), "B"), (Table({"A": ["b", "aa", "aaa"], "C": ["b", "aa", "aaa"]}), "B"), ], diff --git a/tests/safeds/data/tabular/containers/_row/test_getitem.py b/tests/safeds/data/tabular/containers/_row/test_getitem.py index 0ad8eb349..2ca90d53c 100644 --- a/tests/safeds/data/tabular/containers/_row/test_getitem.py +++ b/tests/safeds/data/tabular/containers/_row/test_getitem.py @@ -30,7 +30,7 @@ def test_should_get_correct_item(table_data: dict, column_name: str, target: int @pytest.mark.parametrize( ("table", "column_name"), [ - (Table(), "A"), + (Table({}), "A"), (Table({"A": ["a", "aa", "aaa"]}), "B"), (Table({"A": ["b", "aa", "aaa"], "C": ["b", "aa", "aaa"]}), "B"), ], diff --git a/tests/safeds/data/tabular/containers/_row/test_has_column.py b/tests/safeds/data/tabular/containers/_row/test_has_column.py index f96c5a0d1..2fad69b81 100644 --- a/tests/safeds/data/tabular/containers/_row/test_has_column.py +++ b/tests/safeds/data/tabular/containers/_row/test_has_column.py @@ -7,7 +7,7 @@ @pytest.mark.parametrize( ("table", "column_name", "expected"), [ - (Table(), "A", False), + (Table({}), "A", False), (Table({"A": ["a", "aa", "aaa"]}), "A", True), (Table({"A": ["a", "aa", "aaa"]}), "B", False), ], diff --git a/tests/safeds/data/tabular/containers/_row/test_hash.py b/tests/safeds/data/tabular/containers/_row/test_hash.py index 638d201f3..7dacd8439 100644 --- a/tests/safeds/data/tabular/containers/_row/test_hash.py +++ b/tests/safeds/data/tabular/containers/_row/test_hash.py @@ -7,8 +7,8 @@ @pytest.mark.parametrize( ("table1", "table2", "expected"), [ - (Table(), Table({"A": ["a", "aa", "aaa"]}), False), - (Table(), Table(), True), + (Table({}), Table({"A": ["a", "aa", "aaa"]}), False), + (Table({}), Table({}), True), (Table({"A": ["a", "aa", "aaa"]}), Table({"A": ["a", "aa", "aaa"]}), True), (Table({"A": ["a", "aa", "aaa"]}), Table({"B": ["a", "aa", "aaa"]}), False), ], diff --git a/tests/safeds/data/tabular/containers/_row/test_iter.py b/tests/safeds/data/tabular/containers/_row/test_iter.py index a629e3d7e..ea74f3703 100644 --- a/tests/safeds/data/tabular/containers/_row/test_iter.py +++ b/tests/safeds/data/tabular/containers/_row/test_iter.py @@ -7,7 +7,7 @@ @pytest.mark.parametrize( ("table", "expected"), [ - (Table(), []), + (Table({}), []), (Table({"A": ["a", "aa", "aaa"]}), ["A"]), (Table({"A": ["a", "aa", "aaa"], "B": ["b", "bb", "bbb"], "C": ["c", "cc", "ccc"]}), ["A", "B", "C"]), ], diff --git a/tests/safeds/data/tabular/containers/_row/test_len.py b/tests/safeds/data/tabular/containers/_row/test_len.py index d03cfcc01..577018476 100644 --- a/tests/safeds/data/tabular/containers/_row/test_len.py +++ b/tests/safeds/data/tabular/containers/_row/test_len.py @@ -7,7 +7,7 @@ @pytest.mark.parametrize( ("table", "expected"), [ - (Table(), 0), + (Table({}), 0), (Table({"A": ["a", "aa", "aaa"]}), 1), (Table({"A": ["a", "aa", "aaa"], "B": ["b", "bb", "bbb"]}), 2), ], diff --git a/tests/safeds/data/tabular/containers/_row/test_schema.py b/tests/safeds/data/tabular/containers/_row/test_schema.py index e4a0956fb..8e9412bce 100644 --- a/tests/safeds/data/tabular/containers/_row/test_schema.py +++ b/tests/safeds/data/tabular/containers/_row/test_schema.py @@ -7,7 +7,7 @@ @pytest.mark.parametrize( ("table"), [ - (Table()), + (Table({})), (Table({"A": ["a", "aa", "aaa"]})), (Table({"A": ["a", "aa", "aaa"], "B": ["b", "bb", "bbb"]})), ], diff --git a/tests/safeds/data/tabular/containers/_string_cell/test_equals.py b/tests/safeds/data/tabular/containers/_string_cell/test_equals.py index 2f0ad4ad1..11bff4b38 100644 --- a/tests/safeds/data/tabular/containers/_string_cell/test_equals.py +++ b/tests/safeds/data/tabular/containers/_string_cell/test_equals.py @@ -2,6 +2,7 @@ import polars as pl import pytest + from safeds.data.tabular.containers import StringCell, Table from safeds.data.tabular.containers._lazy_string_cell import _LazyStringCell @@ -30,7 +31,7 @@ def test_should_return_true_if_objects_are_identical() -> None: ("cell", "other"), [ (_LazyStringCell(pl.col("a")), None), - (_LazyStringCell(pl.col("a")), Table()), + (_LazyStringCell(pl.col("a")), Table({})), ], ids=[ "Cell vs. None", diff --git a/tests/safeds/data/tabular/containers/_table/test_add_column.py b/tests/safeds/data/tabular/containers/_table/test_add_column.py index 8fce04860..2a12d3407 100644 --- a/tests/safeds/data/tabular/containers/_table/test_add_column.py +++ b/tests/safeds/data/tabular/containers/_table/test_add_column.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Column, Table from safeds.exceptions import DuplicateColumnError @@ -19,12 +20,12 @@ Table({"col1": [1, 2, 1], "col2": [1, 2, 4], "col3": [0, -1, -2]}), ), ( - Table(), + Table({}), Column("col3", []), Table({"col3": []}), ), ( - Table(), + Table({}), Column("col3", [1]), Table({"col3": [1]}), ), diff --git a/tests/safeds/data/tabular/containers/_table/test_add_columns.py b/tests/safeds/data/tabular/containers/_table/test_add_columns.py index f32f4e695..34f757695 100644 --- a/tests/safeds/data/tabular/containers/_table/test_add_columns.py +++ b/tests/safeds/data/tabular/containers/_table/test_add_columns.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Column, Table @@ -11,12 +12,12 @@ Table({"col1": [1, 2, 1], "col2": [1, 2, 4], "col3": [0, -1, -2], "col4": ["a", "b", "c"]}), ), ( - Table(), + Table({}), [Column("col3", []), Column("col4", [])], Table({"col3": [], "col4": []}), ), ( - Table(), + Table({}), [Column("col3", [1]), Column("col4", [2])], Table({"col3": [1], "col4": [2]}), ), @@ -37,10 +38,10 @@ def test_should_add_columns(table1: Table, columns: list[Column], expected: Tabl Table({"col3": [0, -1, -2], "col4": ["a", "b", "c"]}), Table({"col1": [1, 2, 1], "col2": [1, 2, 4], "col3": [0, -1, -2], "col4": ["a", "b", "c"]}), ), - (Table(), Table({"col1": [1, 2], "col2": [60, 2]}), Table({"col1": [1, 2], "col2": [60, 2]})), + (Table({}), Table({"col1": [1, 2], "col2": [60, 2]}), Table({"col1": [1, 2], "col2": [60, 2]})), ( Table({"col1": [1, 2], "col2": [60, 2]}), - Table(), + Table({}), Table({"col1": [1, 2], "col2": [60, 2]}), ), (Table({"yeet": [], "col": []}), Table({"gg": []}), Table({"yeet": [], "col": [], "gg": []})), diff --git a/tests/safeds/data/tabular/containers/_table/test_column_count.py b/tests/safeds/data/tabular/containers/_table/test_column_count.py index 0a037c954..ae0719d8a 100644 --- a/tests/safeds/data/tabular/containers/_table/test_column_count.py +++ b/tests/safeds/data/tabular/containers/_table/test_column_count.py @@ -1,11 +1,12 @@ import pytest + from safeds.data.tabular.containers import Table @pytest.mark.parametrize( ("table", "expected"), [ - (Table(), 0), + (Table({}), 0), (Table({"col1": []}), 1), (Table({"col1": [], "col2": []}), 2), ], diff --git a/tests/safeds/data/tabular/containers/_table/test_column_names.py b/tests/safeds/data/tabular/containers/_table/test_column_names.py index 2fde17dff..809ad7eec 100644 --- a/tests/safeds/data/tabular/containers/_table/test_column_names.py +++ b/tests/safeds/data/tabular/containers/_table/test_column_names.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table @@ -7,7 +8,7 @@ [ (Table({"col1": [1], "col2": [1]}), ["col1", "col2"]), (Table({"col": [], "gg": []}), ["col", "gg"]), - (Table(), []), + (Table({}), []), ], ids=["Integer", "rowless", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_dataframe.py b/tests/safeds/data/tabular/containers/_table/test_dataframe.py index 8d55e5505..b5e1d76c9 100644 --- a/tests/safeds/data/tabular/containers/_table/test_dataframe.py +++ b/tests/safeds/data/tabular/containers/_table/test_dataframe.py @@ -1,12 +1,13 @@ import pytest from polars import from_dataframe + from safeds.data.tabular.containers import Table @pytest.mark.parametrize( "table", [ - Table(), + Table({}), Table({"a": [1, 2], "b": [3, 4]}), ], ids=[ diff --git a/tests/safeds/data/tabular/containers/_table/test_eq.py b/tests/safeds/data/tabular/containers/_table/test_eq.py index 04a5256f3..ef9bcb116 100644 --- a/tests/safeds/data/tabular/containers/_table/test_eq.py +++ b/tests/safeds/data/tabular/containers/_table/test_eq.py @@ -1,13 +1,14 @@ from typing import Any import pytest + from safeds.data.tabular.containers import Column, Table @pytest.mark.parametrize( ("table1", "table2", "expected"), [ - (Table(), Table(), True), + (Table({}), Table({}), True), (Table({"a": [], "b": []}), Table({"a": [], "b": []}), True), (Table({"col1": [1]}), Table({"col1": [1]}), True), (Table({"col1": [1]}), Table({"col2": [1]}), False), @@ -29,7 +30,7 @@ def test_should_return_whether_two_tables_are_equal(table1: Table, table2: Table @pytest.mark.parametrize( "table", - [Table(), Table({"col1": [1]})], + [Table({}), Table({"col1": [1]})], ids=[ "empty", "non-empty", @@ -43,7 +44,7 @@ def test_should_return_true_if_objects_are_identical(table: Table) -> None: ("table", "other"), [ (Table({"col1": [1]}), None), - (Table({"col1": [1]}), Column("a")), + (Table({"col1": [1]}), Column("a", [])), ], ids=[ "Table vs. None", diff --git a/tests/safeds/data/tabular/containers/_table/test_from_columns.py b/tests/safeds/data/tabular/containers/_table/test_from_columns.py index 7c368625a..01762699b 100644 --- a/tests/safeds/data/tabular/containers/_table/test_from_columns.py +++ b/tests/safeds/data/tabular/containers/_table/test_from_columns.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Column, Table from safeds.exceptions import ColumnLengthMismatchError, DuplicateColumnError @@ -6,7 +7,7 @@ @pytest.mark.parametrize( ("columns", "expected"), [ - ([], Table()), + ([], Table({})), ( [ Column("A", [1, 2]), diff --git a/tests/safeds/data/tabular/containers/_table/test_from_csv_file.py b/tests/safeds/data/tabular/containers/_table/test_from_csv_file.py index da14c701a..d8971aa04 100644 --- a/tests/safeds/data/tabular/containers/_table/test_from_csv_file.py +++ b/tests/safeds/data/tabular/containers/_table/test_from_csv_file.py @@ -1,9 +1,9 @@ from pathlib import Path import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import FileExtensionError - from tests.helpers import resolve_resource_path @@ -12,7 +12,7 @@ [ ("table.csv", Table({"A": ["❔"], "B": [2]})), (Path("table.csv"), Table({"A": ["❔"], "B": [2]})), - ("emptytable.csv", Table()), + ("emptytable.csv", Table({})), ], ids=["by String", "by path", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_from_dict.py b/tests/safeds/data/tabular/containers/_table/test_from_dict.py index 78ec02d4a..aa579af2f 100644 --- a/tests/safeds/data/tabular/containers/_table/test_from_dict.py +++ b/tests/safeds/data/tabular/containers/_table/test_from_dict.py @@ -1,6 +1,7 @@ from typing import Any import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import ColumnLengthMismatchError @@ -10,7 +11,7 @@ [ ( {}, - Table(), + Table({}), ), ( { diff --git a/tests/safeds/data/tabular/containers/_table/test_from_json_file.py b/tests/safeds/data/tabular/containers/_table/test_from_json_file.py index a3ee51416..f884f4b8c 100644 --- a/tests/safeds/data/tabular/containers/_table/test_from_json_file.py +++ b/tests/safeds/data/tabular/containers/_table/test_from_json_file.py @@ -1,9 +1,9 @@ from pathlib import Path import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import FileExtensionError - from tests.helpers import resolve_resource_path @@ -12,7 +12,7 @@ [ ("table.json", Table({"A": ["❔"], "B": [2]})), (Path("table.json"), Table({"A": ["❔"], "B": [2]})), - (Path("emptytable.json"), Table()), + (Path("emptytable.json"), Table({})), ], ids=["by string", "by path", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_from_polars_dataframe.py b/tests/safeds/data/tabular/containers/_table/test_from_polars_dataframe.py index c3b880aa0..519cc7bb1 100644 --- a/tests/safeds/data/tabular/containers/_table/test_from_polars_dataframe.py +++ b/tests/safeds/data/tabular/containers/_table/test_from_polars_dataframe.py @@ -27,7 +27,7 @@ # Schema({"col1": String(), "col2": String()}), # Table({"col1": [0, 1.1], "col2": ["a", "b"]}), # ), -# (pd.DataFrame(), Schema({}), Schema({}), Table()), +# (pd.DataFrame(), Schema({}), Schema({}), Table({})), # ], # ids=["one row, one column", "one row, two columns", "two rows, one column", "two rows, two columns", "empty"], # ) diff --git a/tests/safeds/data/tabular/containers/_table/test_get_column.py b/tests/safeds/data/tabular/containers/_table/test_get_column.py index ed4c11bca..928e6c2ec 100644 --- a/tests/safeds/data/tabular/containers/_table/test_get_column.py +++ b/tests/safeds/data/tabular/containers/_table/test_get_column.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Column, Table from safeds.exceptions import ColumnNotFoundError @@ -18,7 +19,7 @@ def test_should_get_column(table1: Table, expected: Column) -> None: "table", [ (Table({"col1": ["col1_1"], "col2": ["col2_1"]})), - (Table()), + (Table({})), ], ids=["no col3", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_has_column.py b/tests/safeds/data/tabular/containers/_table/test_has_column.py index 90c6755b3..cacd180e2 100644 --- a/tests/safeds/data/tabular/containers/_table/test_has_column.py +++ b/tests/safeds/data/tabular/containers/_table/test_has_column.py @@ -1,10 +1,11 @@ import pytest + from safeds.data.tabular.containers import Table @pytest.mark.parametrize( ("table", "column", "expected"), - [(Table({"A": [1], "B": [2]}), "A", True), (Table({"A": [1], "B": [2]}), "C", False), (Table(), "C", False)], + [(Table({"A": [1], "B": [2]}), "A", True), (Table({"A": [1], "B": [2]}), "C", False), (Table({}), "C", False)], ids=["has column", "doesn't have column", "empty"], ) def test_should_return_if_column_is_in_table(table: Table, column: str, expected: bool) -> None: diff --git a/tests/safeds/data/tabular/containers/_table/test_hash.py b/tests/safeds/data/tabular/containers/_table/test_hash.py index e91543403..ba626061e 100644 --- a/tests/safeds/data/tabular/containers/_table/test_hash.py +++ b/tests/safeds/data/tabular/containers/_table/test_hash.py @@ -1,11 +1,12 @@ import pytest + from safeds.data.tabular.containers import Table @pytest.mark.parametrize( ("table1", "table2"), [ - (Table(), Table()), + (Table({}), Table({})), (Table({"a": [], "b": []}), Table({"a": [], "b": []})), (Table({"col1": [1]}), Table({"col1": [1]})), (Table({"col1": [1, 2, 3]}), Table({"col1": [1, 1, 3]})), diff --git a/tests/safeds/data/tabular/containers/_table/test_init.py b/tests/safeds/data/tabular/containers/_table/test_init.py index 870ca035c..eeafcb900 100644 --- a/tests/safeds/data/tabular/containers/_table/test_init.py +++ b/tests/safeds/data/tabular/containers/_table/test_init.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import ColumnLengthMismatchError @@ -6,7 +7,7 @@ # @pytest.mark.parametrize( # ("table", "expected"), # [ -# (Table(), Schema({})), +# (Table({}), Schema({})), # (Table({}), Schema({})), # (Table({"col1": [0]}), Schema({"col1": Integer()})), # ], diff --git a/tests/safeds/data/tabular/containers/_table/test_remove_columns.py b/tests/safeds/data/tabular/containers/_table/test_remove_columns.py index f65c29692..ce2534446 100644 --- a/tests/safeds/data/tabular/containers/_table/test_remove_columns.py +++ b/tests/safeds/data/tabular/containers/_table/test_remove_columns.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import ColumnNotFoundError @@ -8,19 +9,19 @@ ("table", "expected", "columns", "ignore_unknown_names"), [ (Table({"col1": [1, 2, 1], "col2": ["a", "b", "c"]}), Table({"col1": [1, 2, 1]}), ["col2"], True), - (Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), Table(), ["col1", "col2"], True), + (Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), Table({}), ["col1", "col2"], True), (Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), [], True), - (Table(), Table(), [], True), - (Table(), Table(), ["col1"], True), + (Table({}), Table({}), [], True), + (Table({}), Table({}), ["col1"], True), (Table({"col1": [1, 2, 1], "col2": ["a", "b", "c"]}), Table({"col1": [1, 2, 1]}), ["col2"], False), - (Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), Table(), ["col1", "col2"], False), + (Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), Table({}), ["col1", "col2"], False), ( Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), [], False, ), - (Table(), Table(), [], False), + (Table({}), Table({}), [], False), ], ids=[ "one column, ignore unknown names", @@ -50,8 +51,8 @@ def test_should_remove_table_columns_no_exception( @pytest.mark.parametrize( ("table", "columns", "ignore_unknown_names"), [ - (Table(), ["col1"], False), - (Table(), ["col12"], False), + (Table({}), ["col1"], False), + (Table({}), ["col12"], False), ], ids=[ "missing columns", diff --git a/tests/safeds/data/tabular/containers/_table/test_remove_columns_except.py b/tests/safeds/data/tabular/containers/_table/test_remove_columns_except.py index 9be466eca..2793e7748 100644 --- a/tests/safeds/data/tabular/containers/_table/test_remove_columns_except.py +++ b/tests/safeds/data/tabular/containers/_table/test_remove_columns_except.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import ColumnNotFoundError @@ -9,7 +10,7 @@ ( Table({"A": [1], "B": [2]}), [], - Table(), + Table({}), ), ( Table({"A": [1], "B": [2]}), @@ -33,9 +34,9 @@ Table({"C": [3], "A": [1]}), ), ( - Table(), + Table({}), [], - Table(), + Table({}), ), ], ids=["No Column Name", "First Column", "Second Column", "All columns", "Last and first columns", "empty"], @@ -48,7 +49,7 @@ def test_should_remove_all_except_listed_columns(table: Table, column_names: lis assert expected.row_count == 0 -@pytest.mark.parametrize("table", [Table({"A": [1], "B": [2]}), Table()], ids=["table", "empty"]) +@pytest.mark.parametrize("table", [Table({"A": [1], "B": [2]}), Table({})], ids=["table", "empty"]) def test_should_raise_error_if_column_name_unknown(table: Table) -> None: with pytest.raises(ColumnNotFoundError): table.remove_columns_except(["C"]) diff --git a/tests/safeds/data/tabular/containers/_table/test_remove_columns_with_missing_values.py b/tests/safeds/data/tabular/containers/_table/test_remove_columns_with_missing_values.py index e8a1c1cb2..4ae52436d 100644 --- a/tests/safeds/data/tabular/containers/_table/test_remove_columns_with_missing_values.py +++ b/tests/safeds/data/tabular/containers/_table/test_remove_columns_with_missing_values.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table @@ -23,7 +24,7 @@ ), ) ), - (Table(), Table()), + (Table({}), Table({})), ], ids=["some missing values", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_remove_duplicate_rows.py b/tests/safeds/data/tabular/containers/_table/test_remove_duplicate_rows.py index 186563154..c577f17de 100644 --- a/tests/safeds/data/tabular/containers/_table/test_remove_duplicate_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_remove_duplicate_rows.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table @@ -14,7 +15,7 @@ ), Table({"A": [1, 4], "B": [2, 5]}), ), - (Table(), Table()), + (Table({}), Table({})), (Table({"col1": []}), Table({"col1": []})), ], ids=["duplicate rows", "empty", "no rows"], diff --git a/tests/safeds/data/tabular/containers/_table/test_remove_non_numeric_columns.py b/tests/safeds/data/tabular/containers/_table/test_remove_non_numeric_columns.py index 48d167735..7158833dd 100644 --- a/tests/safeds/data/tabular/containers/_table/test_remove_non_numeric_columns.py +++ b/tests/safeds/data/tabular/containers/_table/test_remove_non_numeric_columns.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table @@ -18,7 +19,7 @@ }, ), ), - (Table(), Table()), + (Table({}), Table({})), ], ids=["numerical values", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_remove_rows_with_missing_values.py b/tests/safeds/data/tabular/containers/_table/test_remove_rows_with_missing_values.py index 0bb832a04..a30bbf9a7 100644 --- a/tests/safeds/data/tabular/containers/_table/test_remove_rows_with_missing_values.py +++ b/tests/safeds/data/tabular/containers/_table/test_remove_rows_with_missing_values.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table @@ -19,7 +20,7 @@ }, ), ), - (Table(), Table()), + (Table({}), Table({})), ], ids=["some missing values", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_remove_rows_with_outliers.py b/tests/safeds/data/tabular/containers/_table/test_remove_rows_with_outliers.py index 70642e501..180e2e756 100644 --- a/tests/safeds/data/tabular/containers/_table/test_remove_rows_with_outliers.py +++ b/tests/safeds/data/tabular/containers/_table/test_remove_rows_with_outliers.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table @@ -248,7 +249,7 @@ }, ), ), - (Table(), Table()), + (Table({}), Table({})), ], ids=[ "no outliers", diff --git a/tests/safeds/data/tabular/containers/_table/test_rename_column.py b/tests/safeds/data/tabular/containers/_table/test_rename_column.py index 05408f8c8..80217c667 100644 --- a/tests/safeds/data/tabular/containers/_table/test_rename_column.py +++ b/tests/safeds/data/tabular/containers/_table/test_rename_column.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import ColumnNotFoundError, DuplicateColumnError @@ -15,7 +16,7 @@ def test_should_rename_column(name_from: str, name_to: str, column_one: str, col assert renamed_table.column_names == [column_one, column_two] -@pytest.mark.parametrize("table", [Table({"A": [1], "B": [2]}), Table()], ids=["normal", "empty"]) +@pytest.mark.parametrize("table", [Table({"A": [1], "B": [2]}), Table({})], ids=["normal", "empty"]) def test_should_raise_if_old_column_does_not_exist(table: Table) -> None: with pytest.raises(ColumnNotFoundError): table.rename_column("C", "D") diff --git a/tests/safeds/data/tabular/containers/_table/test_replace_column.py b/tests/safeds/data/tabular/containers/_table/test_replace_column.py index 899c8159b..38e4be07c 100644 --- a/tests/safeds/data/tabular/containers/_table/test_replace_column.py +++ b/tests/safeds/data/tabular/containers/_table/test_replace_column.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Column, Table from safeds.exceptions import ( ColumnNotFoundError, @@ -116,4 +117,4 @@ def test_should_raise_error( def test_should_fail_on_empty_table() -> None: with pytest.raises(ColumnNotFoundError): - Table().replace_column("col", [Column("a", [1, 2])]) + Table({}).replace_column("col", [Column("a", [1, 2])]) diff --git a/tests/safeds/data/tabular/containers/_table/test_repr.py b/tests/safeds/data/tabular/containers/_table/test_repr.py index c1577acbc..f811cd689 100644 --- a/tests/safeds/data/tabular/containers/_table/test_repr.py +++ b/tests/safeds/data/tabular/containers/_table/test_repr.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table @@ -27,7 +28,7 @@ "+------+------+", ), ( - Table(), + Table({}), "++\n++\n++", ), ( diff --git a/tests/safeds/data/tabular/containers/_table/test_repr_html.py b/tests/safeds/data/tabular/containers/_table/test_repr_html.py index cfd3bfa90..c272d04d6 100644 --- a/tests/safeds/data/tabular/containers/_table/test_repr_html.py +++ b/tests/safeds/data/tabular/containers/_table/test_repr_html.py @@ -1,13 +1,14 @@ import re import pytest + from safeds.data.tabular.containers import Table @pytest.mark.parametrize( "table", [ - Table(), + Table({}), Table({"a": [1, 2], "b": [3, 4]}), ], ids=[ @@ -23,7 +24,7 @@ def test_should_contain_table_element(table: Table) -> None: @pytest.mark.parametrize( "table", [ - Table(), + Table({}), Table({"a": [1, 2], "b": [3, 4]}), ], ids=[ @@ -39,7 +40,7 @@ def test_should_contain_th_element_for_each_column_name(table: Table) -> None: @pytest.mark.parametrize( "table", [ - Table(), + Table({}), Table({"a": [1, 2], "b": [3, 4]}), ], ids=[ diff --git a/tests/safeds/data/tabular/containers/_table/test_row_count.py b/tests/safeds/data/tabular/containers/_table/test_row_count.py index fdfd6e510..4adf0c71e 100644 --- a/tests/safeds/data/tabular/containers/_table/test_row_count.py +++ b/tests/safeds/data/tabular/containers/_table/test_row_count.py @@ -1,11 +1,12 @@ import pytest + from safeds.data.tabular.containers import Table @pytest.mark.parametrize( ("table", "expected"), [ - (Table(), 0), + (Table({}), 0), (Table({"col1": [1]}), 1), (Table({"col1": [1, 2]}), 2), ], diff --git a/tests/safeds/data/tabular/containers/_table/test_shuffle_rows.py b/tests/safeds/data/tabular/containers/_table/test_shuffle_rows.py index d7ddf6d2b..616c9044f 100644 --- a/tests/safeds/data/tabular/containers/_table/test_shuffle_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_shuffle_rows.py @@ -1,11 +1,12 @@ import pytest + from safeds.data.tabular.containers import Table @pytest.mark.parametrize( ("table", "expected"), [ - (Table(), Table()), + (Table({}), Table({})), (Table({"col1": [1, 2, 3]}), Table({"col1": [3, 2, 1]})), (Table({"col1": [1, 2, 3], "col2": [4, 5, 6]}), Table({"col1": [3, 2, 1], "col2": [6, 5, 4]})), ], diff --git a/tests/safeds/data/tabular/containers/_table/test_sizeof.py b/tests/safeds/data/tabular/containers/_table/test_sizeof.py index 61e59e3e8..0f9bb8c27 100644 --- a/tests/safeds/data/tabular/containers/_table/test_sizeof.py +++ b/tests/safeds/data/tabular/containers/_table/test_sizeof.py @@ -1,13 +1,14 @@ import sys import pytest + from safeds.data.tabular.containers import Table @pytest.mark.parametrize( "table", [ - Table(), + Table({}), Table({"col1": [0]}), Table({"col1": [0, 1], "col2": ["a", "b"]}), ], diff --git a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py index f0cbad7a5..c9ce9035f 100644 --- a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import OutOfBoundsError @@ -7,10 +8,10 @@ ("table", "start", "length", "expected"), [ ( - Table(), + Table({}), 0, None, - Table(), + Table({}), ), ( Table({"col1": []}), @@ -78,6 +79,6 @@ def test_should_slice_rows(table: Table, start: int, length: int | None, expecte def test_should_raise_for_negative_length() -> None: - table: Table = Table() + table: Table = Table({}) with pytest.raises(OutOfBoundsError): table.slice_rows(0, -1) diff --git a/tests/safeds/data/tabular/containers/_table/test_sort_rows.py b/tests/safeds/data/tabular/containers/_table/test_sort_rows.py index 8d1492b31..897e305da 100644 --- a/tests/safeds/data/tabular/containers/_table/test_sort_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_sort_rows.py @@ -1,6 +1,7 @@ from collections.abc import Callable import pytest + from safeds.data.tabular.containers import Cell, Row, Table @@ -8,9 +9,9 @@ ("table", "key_selector", "expected"), [ ( - Table(), + Table({}), lambda row: row["col1"], - Table(), + Table({}), ), ( Table({"col1": [3, 2, 1]}), @@ -33,9 +34,9 @@ def test_should_return_sorted_table( ("table", "key_selector", "expected"), [ ( - Table(), + Table({}), lambda row: row["col1"], - Table(), + Table({}), ), ( Table({"col1": [3, 2, 1]}), diff --git a/tests/safeds/data/tabular/containers/_table/test_split_rows.py b/tests/safeds/data/tabular/containers/_table/test_split_rows.py index 0f65d1bc6..72d0b449c 100644 --- a/tests/safeds/data/tabular/containers/_table/test_split_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_split_rows.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import OutOfBoundsError @@ -53,6 +54,6 @@ def test_should_raise_if_value_not_in_range(percentage_in_first: float) -> None: def test_should_split_empty_table() -> None: - t1, t2 = Table().split_rows(0.4) + t1, t2 = Table({}).split_rows(0.4) assert t1.row_count == 0 assert t2.row_count == 0 diff --git a/tests/safeds/data/tabular/containers/_table/test_str.py b/tests/safeds/data/tabular/containers/_table/test_str.py index 37cfa8a0f..3c2306fd6 100644 --- a/tests/safeds/data/tabular/containers/_table/test_str.py +++ b/tests/safeds/data/tabular/containers/_table/test_str.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table @@ -27,7 +28,7 @@ "+------+------+", ), ( - Table(), + Table({}), "++\n++\n++", ), ( diff --git a/tests/safeds/data/tabular/containers/_table/test_summarize_statistics.py b/tests/safeds/data/tabular/containers/_table/test_summarize_statistics.py index 0b3fe5c66..eaf8390d7 100644 --- a/tests/safeds/data/tabular/containers/_table/test_summarize_statistics.py +++ b/tests/safeds/data/tabular/containers/_table/test_summarize_statistics.py @@ -1,6 +1,7 @@ from statistics import stdev import pytest + from safeds.data.tabular.containers import Table @@ -48,8 +49,8 @@ ), ), ( - Table(), - Table(), + Table({}), + Table({}), ), ( Table({"col": [], "gg": []}), diff --git a/tests/safeds/data/tabular/containers/_table/test_to_columns.py b/tests/safeds/data/tabular/containers/_table/test_to_columns.py index b87957bbf..20c7b9532 100644 --- a/tests/safeds/data/tabular/containers/_table/test_to_columns.py +++ b/tests/safeds/data/tabular/containers/_table/test_to_columns.py @@ -1,10 +1,11 @@ import pytest + from safeds.data.tabular.containers import Column, Table @pytest.mark.parametrize( ("table", "expected"), - [(Table({"A": [54, 74], "B": [90, 2010]}), [Column("A", [54, 74]), Column("B", [90, 2010])]), (Table(), [])], + [(Table({"A": [54, 74], "B": [90, 2010]}), [Column("A", [54, 74]), Column("B", [90, 2010])]), (Table({}), [])], ids=["normal", "empty"], ) def test_should_return_list_of_columns(table: Table, expected: list[Column]) -> None: diff --git a/tests/safeds/data/tabular/containers/_table/test_to_csv_file.py b/tests/safeds/data/tabular/containers/_table/test_to_csv_file.py index 7efa4b622..db5d54615 100644 --- a/tests/safeds/data/tabular/containers/_table/test_to_csv_file.py +++ b/tests/safeds/data/tabular/containers/_table/test_to_csv_file.py @@ -2,9 +2,9 @@ from tempfile import NamedTemporaryFile import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import FileExtensionError - from tests.helpers import resolve_resource_path @@ -12,7 +12,7 @@ "table", [ (Table({"col1": ["col1_1"], "col2": ["col2_1"]})), - (Table()), + (Table({})), ], ids=["by String", "empty"], ) @@ -35,7 +35,7 @@ def test_should_create_csv_file_from_table_by_str(table: Table) -> None: "table", [ (Table({"col1": ["col1_1"], "col2": ["col2_1"]})), - (Table()), + (Table({})), ], ids=["by String", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_to_dict.py b/tests/safeds/data/tabular/containers/_table/test_to_dict.py index 683ea5734..55f249051 100644 --- a/tests/safeds/data/tabular/containers/_table/test_to_dict.py +++ b/tests/safeds/data/tabular/containers/_table/test_to_dict.py @@ -1,6 +1,7 @@ from typing import Any import pytest + from safeds.data.tabular.containers import Table @@ -8,7 +9,7 @@ ("table", "expected"), [ ( - Table(), + Table({}), {}, ), ( diff --git a/tests/safeds/data/tabular/containers/_table/test_to_json_file.py b/tests/safeds/data/tabular/containers/_table/test_to_json_file.py index e8714b989..4569fc185 100644 --- a/tests/safeds/data/tabular/containers/_table/test_to_json_file.py +++ b/tests/safeds/data/tabular/containers/_table/test_to_json_file.py @@ -2,6 +2,7 @@ from tempfile import NamedTemporaryFile import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import FileExtensionError @@ -10,7 +11,7 @@ "table", [ (Table({"col1": ["col1_1"], "col2": ["col2_1"]})), - (Table()), + (Table({})), ], ids=["by String", "empty"], ) @@ -29,7 +30,7 @@ def test_should_create_json_file_from_table_by_str(table: Table) -> None: "table", [ (Table({"col1": ["col1_1"], "col2": ["col2_1"]})), - (Table()), + (Table({})), ], ids=["by String", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_transform_column.py b/tests/safeds/data/tabular/containers/_table/test_transform_column.py index fa9c3dadb..9ce90cde3 100644 --- a/tests/safeds/data/tabular/containers/_table/test_transform_column.py +++ b/tests/safeds/data/tabular/containers/_table/test_transform_column.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table from safeds.exceptions import ColumnNotFoundError @@ -30,7 +31,7 @@ def test_should_transform_column(table: Table, table_transformed: Table) -> None "C": ["a", "b", "c"], }, ), - Table(), + Table({}), ], ids=["column not found", "empty"], ) diff --git a/tests/safeds/data/tabular/containers/_table/test_transform_table.py b/tests/safeds/data/tabular/containers/_table/test_transform_table.py index ab980ccdb..fc12cfb76 100644 --- a/tests/safeds/data/tabular/containers/_table/test_transform_table.py +++ b/tests/safeds/data/tabular/containers/_table/test_transform_table.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table from safeds.data.tabular.transformation import OneHotEncoder from safeds.exceptions import ColumnNotFoundError, TransformerNotFittedError @@ -91,7 +92,7 @@ def test_should_return_transformed_table( "col1": ["a", "b", "c"], }, ), - Table(), + Table({}), ], ids=["non-empty table", "empty table"], ) diff --git a/tests/safeds/data/tabular/containers/_temporal_cell/test_equals.py b/tests/safeds/data/tabular/containers/_temporal_cell/test_equals.py index 369196114..1dfc9e181 100644 --- a/tests/safeds/data/tabular/containers/_temporal_cell/test_equals.py +++ b/tests/safeds/data/tabular/containers/_temporal_cell/test_equals.py @@ -2,6 +2,7 @@ import polars as pl import pytest + from safeds.data.tabular.containers import Table, TemporalCell from safeds.data.tabular.containers._lazy_temporal_cell import _LazyTemporalCell @@ -30,7 +31,7 @@ def test_should_return_true_if_objects_are_identical() -> None: ("cell", "other"), [ (_LazyTemporalCell(pl.col("a")), None), - (_LazyTemporalCell(pl.col("a")), Table()), + (_LazyTemporalCell(pl.col("a")), Table({})), ], ids=[ "Cell vs. None", diff --git a/tests/safeds/data/tabular/containers/test_row.py b/tests/safeds/data/tabular/containers/test_row.py index 4f4914d95..ffd3b8417 100644 --- a/tests/safeds/data/tabular/containers/test_row.py +++ b/tests/safeds/data/tabular/containers/test_row.py @@ -173,7 +173,7 @@ # ("row", "other"), # [ # (Row({"col1": 0}), None), -# (Row({"col1": 0}), Table()), +# (Row({"col1": 0}), Table({})), # ], # ids=[ # "Row vs. None", diff --git a/tests/safeds/data/tabular/plotting/test_plot_boxplots.py b/tests/safeds/data/tabular/plotting/test_plot_boxplots.py index 1867efe75..e8c26a923 100644 --- a/tests/safeds/data/tabular/plotting/test_plot_boxplots.py +++ b/tests/safeds/data/tabular/plotting/test_plot_boxplots.py @@ -1,7 +1,8 @@ import pytest +from syrupy import SnapshotAssertion + from safeds.data.tabular.containers import Table from safeds.exceptions import NonNumericColumnError -from syrupy import SnapshotAssertion @pytest.mark.parametrize( @@ -32,7 +33,7 @@ def test_should_raise_if_column_contains_non_numerical_values() -> None: def test_should_fail_on_empty_table() -> None: with pytest.raises(NonNumericColumnError): - Table().plot.box_plots() + Table({}).plot.box_plots() @pytest.mark.parametrize( diff --git a/tests/safeds/data/tabular/plotting/test_plot_correlation_heatmap.py b/tests/safeds/data/tabular/plotting/test_plot_correlation_heatmap.py index f2f04db96..bc706a0cf 100644 --- a/tests/safeds/data/tabular/plotting/test_plot_correlation_heatmap.py +++ b/tests/safeds/data/tabular/plotting/test_plot_correlation_heatmap.py @@ -1,7 +1,8 @@ import pytest -from safeds.data.tabular.containers import Table from syrupy import SnapshotAssertion +from safeds.data.tabular.containers import Table + @pytest.mark.parametrize( "table", @@ -21,7 +22,7 @@ def test_should_match_snapshot(table: Table, snapshot_png_image: SnapshotAsserti # UserWarning, # match=r"An empty table has been used. A correlation heatmap on an empty table will show nothing.", # ): -# Table().plot.correlation_heatmap() +# Table({}).plot.correlation_heatmap() @pytest.mark.parametrize( diff --git a/tests/safeds/data/tabular/plotting/test_plot_histogram_2d.py b/tests/safeds/data/tabular/plotting/test_plot_histogram_2d.py index 88fef9b5e..0f5e0f2c3 100644 --- a/tests/safeds/data/tabular/plotting/test_plot_histogram_2d.py +++ b/tests/safeds/data/tabular/plotting/test_plot_histogram_2d.py @@ -1,8 +1,8 @@ import pytest -from safeds.data.tabular.containers import Table -from safeds.exceptions import ColumnNotFoundError, ColumnTypeError, OutOfBoundsError from syrupy import SnapshotAssertion +from safeds.data.tabular.containers import Table +from safeds.exceptions import ColumnNotFoundError, ColumnTypeError, OutOfBoundsError from tests.helpers import os_mac, skip_if_os @@ -51,7 +51,7 @@ def test_should_match_snapshot( (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "C", "A"), (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "B", "C"), (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "C", "D"), - (Table(), "C", "D"), + (Table({}), "C", "D"), ], ids=[ "First argument doesn't exist", diff --git a/tests/safeds/data/tabular/plotting/test_plot_histograms.py b/tests/safeds/data/tabular/plotting/test_plot_histograms.py index 0e6f10a93..b18927a6b 100644 --- a/tests/safeds/data/tabular/plotting/test_plot_histograms.py +++ b/tests/safeds/data/tabular/plotting/test_plot_histograms.py @@ -1,7 +1,8 @@ import pytest -from safeds.data.tabular.containers import Table from syrupy import SnapshotAssertion +from safeds.data.tabular.containers import Table + @pytest.mark.parametrize( "table", @@ -73,7 +74,7 @@ def test_should_match_snapshot(table: Table, snapshot_png_image: SnapshotAsserti def test_should_fail_on_empty_table() -> None: with pytest.raises(ZeroDivisionError): - Table().plot.histograms() + Table({}).plot.histograms() @pytest.mark.parametrize( diff --git a/tests/safeds/data/tabular/plotting/test_plot_lineplot.py b/tests/safeds/data/tabular/plotting/test_plot_lineplot.py index 7ca2a2cbf..d79644b1a 100644 --- a/tests/safeds/data/tabular/plotting/test_plot_lineplot.py +++ b/tests/safeds/data/tabular/plotting/test_plot_lineplot.py @@ -1,8 +1,8 @@ import pytest -from safeds.data.tabular.containers import Table -from safeds.exceptions import ColumnNotFoundError from syrupy import SnapshotAssertion +from safeds.data.tabular.containers import Table +from safeds.exceptions import ColumnNotFoundError from tests.helpers import os_mac, skip_if_os @@ -47,7 +47,7 @@ def test_should_not_match_snapshot_without_confidence(snapshot_png_image: Snapsh [ (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "C", "A"), (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "A", "C"), - (Table(), "x", "y"), + (Table({}), "x", "y"), ], ids=["x column", "y column", "empty"], ) diff --git a/tests/safeds/data/tabular/plotting/test_plot_scatterplot.py b/tests/safeds/data/tabular/plotting/test_plot_scatterplot.py index 4a1452274..97f344a48 100644 --- a/tests/safeds/data/tabular/plotting/test_plot_scatterplot.py +++ b/tests/safeds/data/tabular/plotting/test_plot_scatterplot.py @@ -1,7 +1,8 @@ import pytest +from syrupy import SnapshotAssertion + from safeds.data.tabular.containers import Table from safeds.exceptions import ColumnNotFoundError, ColumnTypeError -from syrupy import SnapshotAssertion @pytest.mark.parametrize( @@ -86,7 +87,7 @@ def test_should_match_snapshot_dark( (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "C", "A"), (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "B", "C"), (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "C", "D"), - (Table(), "C", "D"), + (Table({}), "C", "D"), ], ids=["First argument doesn't exist", "Second argument doesn't exist", "Both arguments do not exist", "empty"], ) diff --git a/tests/safeds/data/tabular/plotting/test_plot_violin_plots.py b/tests/safeds/data/tabular/plotting/test_plot_violin_plots.py index d2da0fd93..bb8527dd3 100644 --- a/tests/safeds/data/tabular/plotting/test_plot_violin_plots.py +++ b/tests/safeds/data/tabular/plotting/test_plot_violin_plots.py @@ -1,7 +1,8 @@ import pytest +from syrupy import SnapshotAssertion + from safeds.data.tabular.containers import Table from safeds.exceptions import NonNumericColumnError -from syrupy import SnapshotAssertion @pytest.mark.parametrize( @@ -46,4 +47,4 @@ def test_should_raise_if_column_contains_non_numerical_values() -> None: def test_should_fail_on_empty_table() -> None: with pytest.raises(NonNumericColumnError): - Table().plot.violin_plots() + Table({}).plot.violin_plots() diff --git a/tests/safeds/data/tabular/transformation/test_discretizer.py b/tests/safeds/data/tabular/transformation/test_discretizer.py index 091100910..703f845e1 100644 --- a/tests/safeds/data/tabular/transformation/test_discretizer.py +++ b/tests/safeds/data/tabular/transformation/test_discretizer.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table from safeds.data.tabular.transformation import Discretizer from safeds.exceptions import ( @@ -42,7 +43,7 @@ class TestFit: ColumnNotFoundError, None, ), - (Table(), ["col2"], ValueError, "The Discretizer cannot be fitted because the table contains 0 rows"), + (Table({}), ["col2"], ValueError, "The Discretizer cannot be fitted because the table contains 0 rows"), ( Table( { @@ -105,7 +106,7 @@ class TestTransform: ColumnNotFoundError, None, ), - (Table(), ["col1", "col3"], ValueError, "The table cannot be transformed because it contains 0 rows"), + (Table({}), ["col1", "col3"], ValueError, "The table cannot be transformed because it contains 0 rows"), ( Table( { diff --git a/tests/safeds/ml/nn/converters/test_input_converter_image.py b/tests/safeds/ml/nn/converters/test_input_converter_image.py index f4e754fec..07f3fcad6 100644 --- a/tests/safeds/ml/nn/converters/test_input_converter_image.py +++ b/tests/safeds/ml/nn/converters/test_input_converter_image.py @@ -1,12 +1,12 @@ import sys import pytest + from safeds.data.image.containers import ImageList from safeds.data.image.typing import ImageSize from safeds.data.labeled.containers import ImageDataset from safeds.data.tabular.containers import Column, Table from safeds.ml.nn.converters import InputConversionImageToImage - from tests.helpers import images_all, resolve_resource_path _test_image_list = ImageList.from_files(resolve_resource_path(images_all())).resize(10, 10) @@ -107,7 +107,7 @@ def test_should_not_be_equal( def test_should_be_not_implemented(self) -> None: input_conversion_image = InputConversionImageToImage(ImageSize(1, 2, 3)) - other = Table() + other = Table({}) assert input_conversion_image.__eq__(other) is NotImplemented diff --git a/tests/safeds/ml/nn/converters/test_input_converter_image_2.py b/tests/safeds/ml/nn/converters/test_input_converter_image_2.py index 191adc45e..199e82855 100644 --- a/tests/safeds/ml/nn/converters/test_input_converter_image_2.py +++ b/tests/safeds/ml/nn/converters/test_input_converter_image_2.py @@ -2,6 +2,7 @@ import pytest import torch + from safeds.data.image.containers._multi_size_image_list import _MultiSizeImageList from safeds.data.image.containers._single_size_image_list import _SingleSizeImageList from safeds.data.image.typing import ImageSize @@ -51,7 +52,7 @@ def test_should_be_not_implemented(self) -> None: output_conversion_image_to_image = InputConversionImageToImage(ImageSize(1, 1, 1)) output_conversion_image_to_table = InputConversionImageToTable(ImageSize(1, 1, 1)) output_conversion_image_to_column = InputConversionImageToColumn(ImageSize(1, 1, 1)) - other = Table() + other = Table({}) assert output_conversion_image_to_image.__eq__(other) is NotImplemented assert output_conversion_image_to_image.__eq__(output_conversion_image_to_table) is NotImplemented assert output_conversion_image_to_image.__eq__(output_conversion_image_to_column) is NotImplemented diff --git a/tests/safeds/ml/nn/converters/test_input_converter_time_series.py b/tests/safeds/ml/nn/converters/test_input_converter_time_series.py index 58830a05c..7e2d8f1b6 100644 --- a/tests/safeds/ml/nn/converters/test_input_converter_time_series.py +++ b/tests/safeds/ml/nn/converters/test_input_converter_time_series.py @@ -1,6 +1,7 @@ import sys import pytest + from safeds.data.tabular.containers import Table from safeds.ml.nn import ( NeuralNetworkRegressor, @@ -55,7 +56,7 @@ def test_should_be_equal( [ ( InputConversionTimeSeries(), - Table(), + Table({}), ), ], ) diff --git a/tests/safeds/ml/nn/layers/test_dropout_layer.py b/tests/safeds/ml/nn/layers/test_dropout_layer.py index 5dad5f3a8..1988a5549 100644 --- a/tests/safeds/ml/nn/layers/test_dropout_layer.py +++ b/tests/safeds/ml/nn/layers/test_dropout_layer.py @@ -1,11 +1,12 @@ import sys import pytest +from torch import nn + from safeds.data.tabular.containers import Table from safeds.exceptions import OutOfBoundsError from safeds.ml.nn.layers import DropoutLayer from safeds.ml.nn.typing import ConstantImageSize -from torch import nn class TestProbability: @@ -49,7 +50,7 @@ def test_should_be_equal(self) -> None: assert DropoutLayer(0.5) == DropoutLayer(0.5) def test_should_be_not_implemented(self) -> None: - assert DropoutLayer(0.5).__eq__(Table()) is NotImplemented + assert DropoutLayer(0.5).__eq__(Table({})) is NotImplemented class TestHash: diff --git a/tests/safeds/ml/nn/layers/test_flatten_layer.py b/tests/safeds/ml/nn/layers/test_flatten_layer.py index 64db6127c..6e16d7cb5 100644 --- a/tests/safeds/ml/nn/layers/test_flatten_layer.py +++ b/tests/safeds/ml/nn/layers/test_flatten_layer.py @@ -1,11 +1,12 @@ import sys import pytest +from torch import nn + from safeds.data.image.typing import ImageSize from safeds.data.tabular.containers import Table from safeds.ml.nn.layers import FlattenLayer from safeds.ml.nn.typing import VariableImageSize -from torch import nn class TestFlattenLayer: @@ -42,7 +43,7 @@ def test_should_be_equal(self) -> None: assert FlattenLayer() == FlattenLayer() def test_should_be_not_implemented(self) -> None: - assert FlattenLayer().__eq__(Table()) is NotImplemented + assert FlattenLayer().__eq__(Table({})) is NotImplemented class TestHash: def test_hash_should_be_equal(self) -> None: diff --git a/tests/safeds/ml/nn/layers/test_pooling2d_layer.py b/tests/safeds/ml/nn/layers/test_pooling2d_layer.py index 4c5fcb6e3..08f2048b5 100644 --- a/tests/safeds/ml/nn/layers/test_pooling2d_layer.py +++ b/tests/safeds/ml/nn/layers/test_pooling2d_layer.py @@ -2,11 +2,12 @@ from typing import Literal import pytest +from torch import nn + from safeds.data.image.typing import ImageSize from safeds.data.tabular.containers import Table from safeds.ml.nn.layers import AveragePooling2DLayer, MaxPooling2DLayer from safeds.ml.nn.layers._pooling2d_layer import _Pooling2DLayer -from torch import nn class TestPooling2DLayer: @@ -105,7 +106,7 @@ def test_should_not_be_equal( def test_should_be_not_implemented(self) -> None: max_pooling_2d_layer = MaxPooling2DLayer(1) avg_pooling_2d_layer = AveragePooling2DLayer(1) - other = Table() + other = Table({}) assert max_pooling_2d_layer.__eq__(other) is NotImplemented assert max_pooling_2d_layer.__eq__(avg_pooling_2d_layer) is NotImplemented assert avg_pooling_2d_layer.__eq__(other) is NotImplemented