-
Notifications
You must be signed in to change notification settings - Fork 5
feat: raise if remove_colums is called with unknown column by default
#852
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
Merged
lars-reimann
merged 17 commits into
main
from
807-feat-raise-if-remove_colums-is-called-with-unknown-column-by-default
Jun 28, 2024
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8b3d676
zwischenstand
saius02 f2c0c7f
fertig
saius02 0c471f3
Ruff Error fixed completely
saius02 33b7d1e
style: apply automated linter fixes
megalinter-bot 8ebf36a
style: apply automated linter fixes
megalinter-bot cd3b50a
some refactoring
TobiasPluecker 7f1bfba
style: apply automated linter fixes
megalinter-bot e57c5e3
Small details adjusted
TobiasPluecker d6c7fdb
removes empty line
saius02 c262362
style: apply automated linter fixes
megalinter-bot 200b237
Merge branch 'main' into 807-feat-raise-if-remove_colums-is-called-wi…
TellemHD ef6414c
update classification.ipynb
saius02 771dccc
remove_columns updated in other functions
saius02 b0da239
style: apply automated linter fixes
megalinter-bot 4038c19
Merge branch 'refs/heads/main' into 807-feat-raise-if-remove_colums-i…
lars-reimann f36fe41
docs: undo changes to classification tutorial
lars-reimann f69393f
docs: example with default behavior
lars-reimann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 50 additions & 9 deletions
59
tests/safeds/data/tabular/containers/_table/test_remove_columns.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,67 @@ | ||
| import pytest | ||
| from safeds.data.tabular.containers import Table | ||
| from safeds.exceptions import ColumnNotFoundError | ||
|
|
||
|
|
||
| # Test cases where no exception is expected | ||
| @pytest.mark.parametrize( | ||
| ("table", "expected", "columns"), | ||
| ("table", "expected", "columns", "ignore_unknown_names"), | ||
| [ | ||
| (Table({"col1": [1, 2, 1], "col2": ["a", "b", "c"]}), Table({"col1": [1, 2, 1]}), ["col2"]), | ||
| (Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), Table(), ["col1", "col2"]), | ||
| (Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}), []), | ||
| (Table(), Table(), []), | ||
| (Table(), Table(), ["col1"]), | ||
| (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": [1, 2, 1], "col2": [1, 2, 4]}), [], 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": [1, 2, 1], "col2": [1, 2, 4]}), | ||
| [], | ||
| False, | ||
| ), | ||
| (Table(), Table(), [], False), | ||
| ], | ||
| ids=[ | ||
| "one column, ignore unknown names", | ||
| "multiple columns, ignore unknown names", | ||
| "no columns, ignore unknown names", | ||
| "empty, ignore unknown names", | ||
| "missing columns, ignore unknown names", | ||
| "one column", | ||
| "multiple columns", | ||
| "no columns", | ||
| "empty", | ||
| "missing columns", | ||
| ], | ||
| ) | ||
| def test_should_remove_table_columns(table: Table, expected: Table, columns: list[str]) -> None: | ||
| table = table.remove_columns(columns) | ||
| def test_should_remove_table_columns_no_exception( | ||
| table: Table, | ||
| expected: Table, | ||
| columns: list[str], | ||
| ignore_unknown_names: bool, | ||
| ) -> None: | ||
| table = table.remove_columns(columns, ignore_unknown_names=ignore_unknown_names) | ||
| assert table.schema == expected.schema | ||
| assert table == expected | ||
| assert table.row_count == expected.row_count | ||
|
|
||
|
|
||
| # Test cases where an exception is expected | ||
| @pytest.mark.parametrize( | ||
| ("table", "columns", "ignore_unknown_names"), | ||
| [ | ||
| (Table(), ["col1"], False), | ||
| (Table(), ["col12"], False), | ||
| ], | ||
| ids=[ | ||
| "missing columns", | ||
| "missing columns", | ||
| ], | ||
| ) | ||
| def test_should_raise_error_for_unknown_columns( | ||
| table: Table, | ||
| columns: list[str], | ||
| ignore_unknown_names: bool, | ||
| ) -> None: | ||
| with pytest.raises(ColumnNotFoundError): | ||
| table.remove_columns(columns, ignore_unknown_names=ignore_unknown_names) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.