-
Notifications
You must be signed in to change notification settings - Fork 5
feat: join #870
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
Merged
feat: join #870
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
1b37cd6
issue #750 regularization strength for logistic classifier
4081bca
first try
4fdface
finished ISSUE 745 join
7fb0b7a
import warning fixed
08ffdb2
linter problems solved
c02dce6
Merge branch 'main' into 745-join
zogomii 509c07d
linter problems
440a89f
linter fixes #2
bf990a5
linter fixes #3
44f3210
linter fixes #4
f6ce318
style: apply automated linter fixes
megalinter-bot 76561ec
style: apply automated linter fixes
megalinter-bot 3ce2aca
Merge branch 'refs/heads/main' into 745-join
lars-reimann ac6b862
perf: use lazy frames instead of data frames
lars-reimann 22faea8
documentation for join
af60c7e
style: apply automated linter fixes
megalinter-bot 7119cf5
small changes in documentation - join
b54ea09
test doc join
2251f9f
test rückgängig
9224097
small changes
0776679
Merge branch 'main' into 745-join
4abd576
changed None to null in documentation
86a110b
formatierung
d550f95
Validation
3e96f55
formatierungsfehler gefixed
bbb3576
style: apply automated linter fixes
megalinter-bot eab9833
tests for validation
099aaff
correction
55d5d2f
linter
1e7af57
literal mode
2b2962b
removed mode
524df73
style: apply automated linter fixes
megalinter-bot eafb51c
columnNotFound
10b26fa
import columnNotFoundError
4148512
style: apply automated linter fixes
megalinter-bot ce8aa8d
docstrings are not redundant anymore
57abcee
tests for check column exists
de5de4c
tests were already there so we deleted the redundant tests
2bf76fc
style: apply automated linter fixes
megalinter-bot 0d5edc6
test: rename tests to match convention
lars-reimann f65f20e
test: parametrize test
lars-reimann 172bbb8
test: parametrize test
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| from typing import Literal | ||
|
|
||
| import pytest | ||
| from safeds.data.tabular.containers import Table | ||
| from safeds.exceptions import ColumnNotFoundError | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("table_left", "table_right", "left_names", "right_names", "mode", "table_expected"), | ||
| [ | ||
| ( | ||
| Table({"a": [1, 2], "b": [3, 4]}), | ||
| Table({"d": [1, 5], "e": [5, 6]}), | ||
| ["a"], | ||
| ["d"], | ||
| "outer", | ||
| Table({"a": [1, None, 2], "b": [3, None, 4], "d": [1, 5, None], "e": [5, 6, None]}), | ||
| ), | ||
| ( | ||
| Table({"a": [1, 2], "b": [3, 4]}), | ||
| Table({"d": [1, 5], "e": [5, 6]}), | ||
| ["a"], | ||
| ["d"], | ||
| "left", | ||
| Table({"a": [1, 2], "b": [3, 4], "e": [5, None]}), | ||
| ), | ||
| ( | ||
| Table({"a": [1, 2], "b": [3, 4]}), | ||
| Table({"d": [1, 5], "e": [5, 6]}), | ||
| ["a"], | ||
| ["d"], | ||
| "inner", | ||
| Table({"a": [1], "b": [3], "e": [5]}), | ||
| ), | ||
| ( | ||
| Table({"a": [1, 2], "b": [3, 4], "c": [5, 6]}), | ||
| Table({"d": [1, 5], "e": [5, 6], "g": [7, 9]}), | ||
| ["a", "c"], | ||
| ["d", "e"], | ||
| "inner", | ||
| Table({"a": [1], "b": [3], "c": [5], "g": [7]}), | ||
| ), | ||
| ( | ||
| Table({"a": [1, 2], "b": [3, 4]}), | ||
| Table({"d": [1, 5], "e": [5, 6]}), | ||
| ["b"], | ||
| ["e"], | ||
| "inner", | ||
| Table({"a": [], "b": [], "d": []}), | ||
| ), | ||
| ], | ||
| ) | ||
| def test_should_join_two_tables( | ||
| table_left: Table, | ||
| table_right: Table, | ||
| left_names: list[str], | ||
| right_names: list[str], | ||
| mode: Literal["inner", "left", "outer"], | ||
| table_expected: Table, | ||
| ) -> None: | ||
| assert table_left.join(table_right, left_names, right_names, mode=mode) == table_expected | ||
|
|
||
|
|
||
| def test_should_raise_if_columns_are_mismatched() -> None: | ||
| table_left = Table({"a": [1, 2], "b": [3, 4]}) | ||
| table_right = Table({"d": [1, 5], "e": [5, 6]}) | ||
| left_names = ["a"] | ||
| right_names = ["d", "e"] | ||
| with pytest.raises(ValueError, match="The number of columns to join on must be the same in both tables."): | ||
| table_left.join(table_right, left_names, right_names) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("table_left", "table_right", "left_names", "right_names"), | ||
| [ | ||
| (Table({"a": [1, 2], "b": [3, 4]}), Table({"d": [1, 5], "e": [5, 6]}), ["c"], ["d"]), | ||
| (Table({"a": [1, 2], "b": [3, 4]}), Table({"d": [1, 5], "e": [5, 6]}), ["a"], ["f"]), | ||
| ], | ||
| ids=[ | ||
| "wrong_left_name", | ||
| "wrong_right_name", | ||
| ], | ||
| ) | ||
| def test_should_raise_if_columns_are_missing( | ||
| table_left: Table, | ||
| table_right: Table, | ||
| left_names: list[str], | ||
| right_names: list[str], | ||
| ) -> None: | ||
| with pytest.raises(ColumnNotFoundError): | ||
| table_left.join(table_right, left_names=left_names, right_names=right_names) |
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.