Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Maintain tagging in methods inherited from Table class #332

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
0a5c611
Add exception classes
zzril May 29, 2023
615d10a
style: apply automated linter fixes
megalinter-bot May 29, 2023
2ab4c93
Add implementation for add_column
zzril May 29, 2023
1183c3e
Add test for overriden add_columns method
zzril May 29, 2023
09110ca
Add __init.py__ to _tagged_table test directory
zzril May 29, 2023
ce347fe
Add return type annotations
zzril May 29, 2023
24c6aef
style: apply automated linter fixes
megalinter-bot May 29, 2023
dc6de53
style: apply automated linter fixes
megalinter-bot May 29, 2023
fd5e6ab
Add specific tests for features and target
zzril May 29, 2023
e6da4d2
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril May 29, 2023
5370f9f
Add add_columns implementation
zzril May 29, 2023
6b2846b
Use public getter to access target column
zzril May 29, 2023
46aa81a
Add more implementations
zzril May 29, 2023
f9f302c
style: apply automated linter fixes
megalinter-bot May 29, 2023
18d37fb
Start keep_only_columns implementation
zzril May 29, 2023
30b85b6
style: apply automated linter fixes
megalinter-bot May 29, 2023
6a637a7
Start remove_columns implementation
zzril May 29, 2023
4f0fc80
Override remove_columns_with_missing_values
zzril May 29, 2023
c02a34a
Fix typo in todo comment
zzril May 29, 2023
ab44cf8
Catch correct exception
zzril May 29, 2023
e6621f3
Add tests
zzril May 29, 2023
973f907
style: apply automated linter fixes
megalinter-bot May 29, 2023
c8ecbef
Add test for ColumnIsTaggedError
zzril May 29, 2023
9f9e03a
style: apply automated linter fixes
megalinter-bot May 29, 2023
348ab72
style: apply automated linter fixes
megalinter-bot May 29, 2023
f111adf
Use try-catch for remove_columns
zzril May 29, 2023
eae61a9
Implement remove_columns_with_non_numerical_values
zzril May 29, 2023
2a0fac8
Implement more row removing functions
zzril May 29, 2023
f691f5b
Implement rename_column and add tests
zzril May 29, 2023
20b00de
style: apply automated linter fixes
megalinter-bot May 29, 2023
e4f9b19
Add test for filter_rows
zzril May 29, 2023
28474b8
style: apply automated linter fixes
megalinter-bot May 29, 2023
d71b572
Implement replace_column and parametrize tests
zzril May 29, 2023
ce68cc9
style: apply automated linter fixes
megalinter-bot May 29, 2023
c59f552
style: apply automated linter fixes
megalinter-bot May 29, 2023
d42a9b4
Implement shuffle_rows
zzril May 30, 2023
4b0a713
style: apply automated linter fixes
megalinter-bot May 30, 2023
1ccf1dd
Override slice_rows
zzril May 30, 2023
2d28696
Override sort_columns
zzril May 30, 2023
5df6fba
style: apply automated linter fixes
megalinter-bot May 30, 2023
34376ce
Override sort_rows
zzril May 30, 2023
4f1b19f
style: apply automated linter fixes
megalinter-bot May 30, 2023
20a4856
Override transform_column
zzril May 30, 2023
9dfab62
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 1, 2023
4ad330a
style: Drop unused keyword parameters
zzril Jun 1, 2023
71ed46a
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 1, 2023
319f44f
feat: Override transform_table
zzril Jun 1, 2023
0a23638
Move import to type checking block
zzril Jun 1, 2023
af72037
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 1, 2023
ab40aaa
style: apply automated linter fixes
megalinter-bot Jun 1, 2023
b42a8a9
style: apply automated linter fixes
megalinter-bot Jun 1, 2023
131bf7a
feat: add helper asserting TaggedTables are equal
zzril Jun 1, 2023
9b7919d
feat: Override inverse_transform_table
zzril Jun 1, 2023
1984707
style: apply automated linter fixes
megalinter-bot Jun 1, 2023
8925a17
docs: remove quotes in console examples
zzril Jun 1, 2023
f682b6a
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jun 1, 2023
2bf77fa
docs: fix indentation in transform_table
zzril Jun 1, 2023
ec37d56
docs: fix indentation in console examples
zzril Jun 1, 2023
b03aa01
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 2, 2023
4a30ca2
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 6, 2023
7619a0f
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 8, 2023
5545621
style: apply automated linter fixes
megalinter-bot Jun 8, 2023
22b57b6
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 9, 2023
3f00be6
Rename ColumnIsTaggedError to ColumnIsTargetError
zzril Jun 9, 2023
e5936b8
Document exceptions in parent class
zzril Jun 9, 2023
0d231f0
Override remove_columns
zzril Jun 9, 2023
599f8b9
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 9, 2023
0cdb4e1
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 9, 2023
7d5a574
Adapt tests to new replace_column signature
zzril Jun 9, 2023
d846885
style: apply automated linter fixes
megalinter-bot Jun 9, 2023
23cb5f8
style: apply automated linter fixes
megalinter-bot Jun 9, 2023
e3bcac2
Add replace_column testcases that would throw
zzril Jun 9, 2023
8cc8099
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jun 9, 2023
11fd2f6
style: apply automated linter fixes
megalinter-bot Jun 9, 2023
d219a4f
style: apply automated linter fixes
megalinter-bot Jun 9, 2023
eb09acc
feat: add remove_target_column to TaggedTable
zzril Jun 9, 2023
1809eb5
style: apply automated linter fixes
megalinter-bot Jun 9, 2023
925c100
Make test_classifier.py use remove_target_column
zzril Jun 9, 2023
b44e8a4
Make test_regressor.py use remove_target_column
zzril Jun 9, 2023
3ce32f7
Override remove_column
zzril Jun 9, 2023
ffe64f5
Comment-out currently unreachable lines
zzril Jun 9, 2023
de0dc57
Adapt signature of keep_only_columns
zzril Jun 9, 2023
a1d7fb1
style: Drop solved todo comment
zzril Jun 9, 2023
adbb9bd
style: drop unneeded format string
zzril Jun 9, 2023
1dd8256
Fix comments
zzril Jun 9, 2023
a3f431b
Add instanceof check to util_sklearn methods
zzril Jun 9, 2023
f08a8af
Do type check as early as possible
zzril Jun 9, 2023
f905b32
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 11, 2023
bdca892
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 13, 2023
d28763f
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 16, 2023
ed4baa1
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 23, 2023
6507824
Add to_table method to TaggedTable class
zzril Jun 23, 2023
76ed6ad
Drop remove_target_column method from TaggedTable
zzril Jun 23, 2023
c4185c9
Add test for to_table
zzril Jun 23, 2023
5696f91
style: apply automated linter fixes
megalinter-bot Jun 23, 2023
68dfc00
Make to_table an instance method
zzril Jun 23, 2023
8854c54
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jun 23, 2023
8af1153
Remove method calls on semi-initialized table
zzril Jun 23, 2023
94b0a18
Add type check to from_table method
zzril Jun 23, 2023
6cb25c5
Implement keep_only_columns
zzril Jun 23, 2023
1e21156
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 23, 2023
db1a22e
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 23, 2023
636a4d0
Add as_table method
zzril Jun 23, 2023
0e0e8f6
style: apply automated linter fixes
megalinter-bot Jun 23, 2023
67f694c
Rename to _as_table
zzril Jun 23, 2023
e722c91
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jun 23, 2023
813ca3f
Fix call in OneHotEncoder
zzril Jun 23, 2023
cbea9c3
style: apply automated linter fixes
megalinter-bot Jun 23, 2023
0d3eae1
Fix next call in OneHotEncoder
zzril Jun 23, 2023
32c427c
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jun 23, 2023
ddeebd3
Fix last call in OneHotEncoder
zzril Jun 23, 2023
1a9ece7
Add generic exceptions in docstrings of superclass
zzril Jun 23, 2023
256ba64
Add tests for keep_only_columns
zzril Jun 23, 2023
85125d7
style: apply automated linter fixes
megalinter-bot Jun 23, 2023
871460b
style: apply automated linter fixes
megalinter-bot Jun 23, 2023
66bcf8e
Fix name of test function
zzril Jun 23, 2023
01e09c8
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 23, 2023
e0f7587
feat: Added methods `TaggedTable.add_column_as_feature` and `Taggedta…
Marsmaennchen221 Jun 23, 2023
ed531d3
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
Marsmaennchen221 Jun 23, 2023
8e25c86
test: Corrected tests after merge
Marsmaennchen221 Jun 23, 2023
851a83a
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 23, 2023
1ca61c7
Apply suggestions from code review
zzril Jun 23, 2023
b29be63
refactor: Added changes for linters
Marsmaennchen221 Jun 23, 2023
8d335a3
refactor: Just testing if the linter will accept this
Marsmaennchen221 Jun 23, 2023
65e0e72
refactor: The linter should be happy now
Marsmaennchen221 Jun 23, 2023
bf42687
style: apply automated linter fixes
megalinter-bot Jun 23, 2023
da93e49
style: apply automated linter fixes
megalinter-bot Jun 23, 2023
e3a8ce5
Add tests for remove_column
zzril Jun 23, 2023
6bfad10
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jun 23, 2023
90a7255
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
Marsmaennchen221 Jun 23, 2023
9c2c750
style: apply automated linter fixes
megalinter-bot Jun 23, 2023
c4c00e1
Merge branch 'main' of https://github.com/Safe-DS/Stdlib into 58-in-t…
Marsmaennchen221 Jun 23, 2023
48ed202
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 30, 2023
3018b51
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 30, 2023
7437be1
docs: Removed unnecessary empty lines in comment
Marsmaennchen221 Jun 30, 2023
24dc166
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
Marsmaennchen221 Jun 30, 2023
75b3a23
feat: Using a table instead of super in `TaggedTable.__init__` becaus…
Marsmaennchen221 Jun 30, 2023
7c366dc
Fix _as_table
zzril Jun 30, 2023
a31769d
style: apply automated linter fixes
megalinter-bot Jun 30, 2023
711943e
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 30, 2023
f7219d5
Update tests for sort_rows
zzril Jun 30, 2023
c01f208
Update inplace test
zzril Jun 30, 2023
1ffe1c9
Update test for shuffle_rows
zzril Jun 30, 2023
0af1b01
style: apply automated linter fixes
megalinter-bot Jun 30, 2023
f38ccdc
Update tests for replace_column
zzril Jun 30, 2023
7b23f4d
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jun 30, 2023
e49ff3d
test: Moved tests from `test_tagged_table.py` to their own files in _…
Marsmaennchen221 Jun 30, 2023
6eac3fb
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
Marsmaennchen221 Jun 30, 2023
d50a943
Update test_rename_column.py
zzril Jun 30, 2023
72d8907
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jun 30, 2023
a4068c6
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jun 30, 2023
cc26bdf
style: apply automated linter fixes
megalinter-bot Jun 30, 2023
4c83491
style: apply automated linter fixes
megalinter-bot Jun 30, 2023
1562ba9
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jul 6, 2023
cff102f
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jul 6, 2023
c4d212e
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jul 7, 2023
447dd82
Update test_remove_rows_with_outliers.py
zzril Jul 7, 2023
1016eef
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
31c83f3
Add new testcase to test_remove_rows_with_outliers
zzril Jul 7, 2023
192d789
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jul 7, 2023
ae7a105
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
5e3c1d4
Update test_remove_rows_with_missing_values.py
zzril Jul 7, 2023
b352d53
Update test_remove_duplicate_rows.py
zzril Jul 7, 2023
8ef1442
Parametrize non_numerical tests
zzril Jul 7, 2023
6cffec3
Add testcases for non_numerical tests
zzril Jul 7, 2023
9212532
Update error test for non_numerical
zzril Jul 7, 2023
6ea0147
Update test_remove_columns_with_missing_values.py
zzril Jul 7, 2023
121f2a1
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jul 7, 2023
70f9e9b
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
09bbadb
Add testcases for remove_columns
zzril Jul 7, 2023
0c38d5a
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jul 7, 2023
aecf49a
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
03efb3c
Add testcases for error in remove_columns
zzril Jul 7, 2023
1313f2a
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jul 7, 2023
8e7f365
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
bffa974
Fix empty list case in test_remove_columns.py
zzril Jul 7, 2023
ec945cf
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
zzril Jul 7, 2023
0e761d4
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jul 7, 2023
7fb14a8
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
af7a716
test: added parametrization to tests for `TaggedTable` and finished t…
Marsmaennchen221 Jul 7, 2023
3f8f816
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
Marsmaennchen221 Jul 7, 2023
afbefab
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
3c6feb0
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
a00f440
feat: Improved error messages for `TaggedTable.remove_columns`, `Tagg…
Marsmaennchen221 Jul 7, 2023
7c36d64
Merge branch '58-in-taggedtable-override-methods-of-table-that-return…
Marsmaennchen221 Jul 7, 2023
c3bf71d
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
f7a8c6f
style: apply automated linter fixes
megalinter-bot Jul 7, 2023
a9e5851
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jul 7, 2023
0d159c2
Apply suggestions from code review
Marsmaennchen221 Jul 7, 2023
168891f
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jul 7, 2023
6e65b12
Update src/safeds/data/tabular/containers/_tagged_table.py
zzril Jul 8, 2023
d590824
Update tests/safeds/data/tabular/containers/_table/_tagged_table/test…
zzril Jul 8, 2023
fd2e1e3
Update tests/safeds/data/tabular/containers/_table/_tagged_table/test…
zzril Jul 8, 2023
d0f2451
Improve testcase naming in test_features.py
zzril Jul 8, 2023
ea1a46c
Update src/safeds/data/tabular/containers/_tagged_table.py
zzril Jul 8, 2023
f37586b
style: apply automated linter fixes
megalinter-bot Jul 8, 2023
0db7131
Merge branch 'main' into 58-in-taggedtable-override-methods-of-table-…
zzril Jul 8, 2023
ff3782b
Update src/safeds/data/tabular/containers/_tagged_table.py
zzril Jul 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions src/safeds/data/tabular/containers/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,22 @@ def summary(self) -> Table:
# Transformations
# ------------------------------------------------------------------------------------------------------------------

# This method is meant as a way to "cast" instances of subclasses of `Table` to a proper `Table`, dropping any
# additional constraints that might have to hold in the subclass.
# Override accordingly in subclasses.
def _as_table(self: Table) -> Table:
"""
Transform the table to an instance of the Table class.

The original table is not modified.

Returns
-------
table: Table
The table, as an instance of the Table class.
"""
return self

def add_column(self, column: Column) -> Table:
"""
Return the original table with the provided column attached at the end.
Expand Down Expand Up @@ -888,8 +904,9 @@ def add_row(self, row: Row) -> Table:
"""
Add a row to the table.

If the table happens to be empty beforehand, respective columns will be added automatically.

This table is not modified.
If the table happens to be empty beforehand, respective features will be added automatically.

Parameters
----------
Expand Down Expand Up @@ -1077,6 +1094,8 @@ def keep_only_columns(self, column_names: list[str]) -> Table:
------
UnknownColumnNameError
If any of the given columns does not exist.
IllegalSchemaModificationError
If removing the columns would violate an invariant in the subclass.

Examples
--------
Expand Down Expand Up @@ -1120,6 +1139,8 @@ def remove_columns(self, column_names: list[str]) -> Table:
------
UnknownColumnNameError
If any of the given columns does not exist.
IllegalSchemaModificationError
If removing the columns would violate an invariant in the subclass.

Examples
--------
Expand Down Expand Up @@ -1158,6 +1179,11 @@ def remove_columns_with_missing_values(self) -> Table:
table : Table
A table without the columns that contain missing values.

Raises
------
IllegalSchemaModificationError
If removing the columns would violate an invariant in the subclass.

Examples
--------
>>> from safeds.data.tabular.containers import Table
Expand All @@ -1182,6 +1208,11 @@ def remove_columns_with_non_numerical_values(self) -> Table:
table : Table
A table without the columns that contain non-numerical values.

Raises
------
IllegalSchemaModificationError
If removing the columns would violate an invariant in the subclass.

Examples
--------
>>> from safeds.data.tabular.containers import Table
Expand Down Expand Up @@ -1331,7 +1362,9 @@ def rename_column(self, old_name: str, new_name: str) -> Table:

def replace_column(self, old_column_name: str, new_columns: list[Column]) -> Table:
"""
Return a copy of the table with the specified old column replaced by a list of new columns. Keeps the order of columns.
Return a copy of the table with the specified old column replaced by a list of new columns.

The order of columns is kept.

This table is not modified.

Expand All @@ -1352,12 +1385,12 @@ def replace_column(self, old_column_name: str, new_columns: list[Column]) -> Tab
------
UnknownColumnNameError
If the old column does not exist.

DuplicateColumnNameError
If at least one of the new columns already exists and the existing column is not affected by the replacement.

ColumnSizeError
If the size of at least one of the new columns does not match the amount of rows.
IllegalSchemaModificationError
If replacing the column would violate an invariant in the subclass.

Examples
--------
Expand Down Expand Up @@ -1475,7 +1508,7 @@ def sort_columns(
"""
Sort the columns of a `Table` with the given comparator and return a new `Table`.

The original table is not modified. The comparator is a function that takes two columns `col1` and `col2` and
The comparator is a function that takes two columns `col1` and `col2` and
returns an integer:

* If `col1` should be ordered before `col2`, the function should return a negative number.
Expand Down Expand Up @@ -1519,7 +1552,7 @@ def sort_rows(self, comparator: Callable[[Row, Row], int]) -> Table:
"""
Sort the rows of a `Table` with the given comparator and return a new `Table`.

The original table is not modified. The comparator is a function that takes two rows `row1` and `row2` and
The comparator is a function that takes two rows `row1` and `row2` and
returns an integer:

* If `row1` should be ordered before `row2`, the function should return a negative number.
Expand Down Expand Up @@ -1695,6 +1728,8 @@ def transform_table(self, transformer: TableTransformer) -> Table:
------
TransformerNotFittedError
If the transformer has not been fitted yet.
IllegalSchemaModificationError
If replacing the column would violate an invariant in the subclass.

Examples
--------
Expand Down
Loading