From ec42a4c9e98c8731eacb68c917c2716299738776 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Wed, 15 May 2024 16:18:26 +0200 Subject: [PATCH] test: fix failing tests --- .../data/labeled/containers/_tabular_dataset.py | 2 +- src/safeds/data/tabular/containers/_column.py | 9 +-------- .../data/tabular/plotting/_table_plotter.py | 2 +- .../tabular/transformation/_one_hot_encoder.py | 15 ++++++++++----- src/safeds/data/tabular/typing/_polars_schema.py | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/safeds/data/labeled/containers/_tabular_dataset.py b/src/safeds/data/labeled/containers/_tabular_dataset.py index d34779b87..dc81919fd 100644 --- a/src/safeds/data/labeled/containers/_tabular_dataset.py +++ b/src/safeds/data/labeled/containers/_tabular_dataset.py @@ -53,7 +53,7 @@ class TabularDataset(Dataset): Examples -------- - >>> from safeds.data.labeled.containers import TabularDataset + >>> from safeds.data.tabular.containers import Table >>> table = Table( ... { ... "id": [1, 2, 3], diff --git a/src/safeds/data/tabular/containers/_column.py b/src/safeds/data/tabular/containers/_column.py index 16a64c08f..3dc1781e1 100644 --- a/src/safeds/data/tabular/containers/_column.py +++ b/src/safeds/data/tabular/containers/_column.py @@ -1009,14 +1009,7 @@ def mode( >>> from safeds.data.tabular.containers import Column >>> column = Column("test", [3, 1, 2, 1, 3]) >>> column.mode() - +------+ - | test | - | --- | - | i64 | - +======+ - | 1 | - | 3 | - +------+ + [1, 3] """ import polars as pl diff --git a/src/safeds/data/tabular/plotting/_table_plotter.py b/src/safeds/data/tabular/plotting/_table_plotter.py index b7bbf5dc6..c870e29a7 100644 --- a/src/safeds/data/tabular/plotting/_table_plotter.py +++ b/src/safeds/data/tabular/plotting/_table_plotter.py @@ -24,7 +24,7 @@ class TablePlotter: Examples -------- >>> from safeds.data.tabular.containers import Table - >>> table = Table("test", [1, 2, 3]) + >>> table = Table({"test": [1, 2, 3]}) >>> plotter = table.plot """ diff --git a/src/safeds/data/tabular/transformation/_one_hot_encoder.py b/src/safeds/data/tabular/transformation/_one_hot_encoder.py index ea019cde1..0d4bec1fa 100644 --- a/src/safeds/data/tabular/transformation/_one_hot_encoder.py +++ b/src/safeds/data/tabular/transformation/_one_hot_encoder.py @@ -53,11 +53,16 @@ class OneHotEncoder(InvertibleTableTransformer): >>> table = Table({"col1": ["a", "b", "c", "a"]}) >>> transformer = OneHotEncoder() >>> transformer.fit_and_transform(table, ["col1"])[1] - col1__a col1__b col1__c - 0 1.0 0.0 0.0 - 1 0.0 1.0 0.0 - 2 0.0 0.0 1.0 - 3 1.0 0.0 0.0 + +---------+---------+---------+ + | col1__a | col1__b | col1__c | + | --- | --- | --- | + | u8 | u8 | u8 | + +=============================+ + | 1 | 0 | 0 | + | 0 | 1 | 0 | + | 0 | 0 | 1 | + | 1 | 0 | 0 | + +---------+---------+---------+ """ # ------------------------------------------------------------------------------------------------------------------ diff --git a/src/safeds/data/tabular/typing/_polars_schema.py b/src/safeds/data/tabular/typing/_polars_schema.py index 483b00b49..fe9b585f9 100644 --- a/src/safeds/data/tabular/typing/_polars_schema.py +++ b/src/safeds/data/tabular/typing/_polars_schema.py @@ -37,7 +37,7 @@ def __eq__(self, other: object) -> bool: return self._schema == other._schema def __hash__(self) -> int: - return _structural_hash(str(self._schema)) + return _structural_hash(tuple(self._schema.keys()), [str(type_) for type_ in self._schema.values()]) def __repr__(self) -> str: return f"Schema({self!s})"