-
Notifications
You must be signed in to change notification settings - Fork 5
feat: added 'histogram_2d' in TablePlotter #903
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
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ef965c9
feat: add histogram_2d method to TablePlotter
SamanHushi a813c6c
added darkmode for histogram_2d
SamanHushi 229d221
added test for histogram_2d
SamanHushi 2f4e8f2
consistant naming in test
SamanHushi 69ce282
style: apply automated linter fixes
megalinter-bot 5bbb946
skipping snapchot tests for mac
SamanHushi e4c152d
style: apply automated linter fixes
megalinter-bot dcb02b6
remove linux from snapshot test
SamanHushi 3c24f14
removed unused code
SamanHushi 39666be
added linux back to snapchot tests
SamanHushi 3c357bd
changed theme handling
timwirt 7b54140
removed numpy in example
SamanHushi 0df54b6
corrected OutOfBoundsError discription
SamanHushi 58efd39
Update tests/safeds/data/tabular/plotting/test_plot_histogram_2d.py
SamanHushi 8e5ec02
added theme to the discription
SamanHushi e6407d1
Merge branch '869-2d-histogram' of github.com:Safe-DS/Library into 86…
SamanHushi 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
Binary file added
BIN
+10.8 KB
...__snapshots__/test_plot_histogram_2d/test_should_match_snapshot[functional].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.21 KB
...g/__snapshots__/test_plot_histogram_2d/test_should_match_snapshot[multiple].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.21 KB
..._snapshots__/test_plot_histogram_2d/test_should_match_snapshot[overlapping].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.2 KB
...__/test_plot_histogram_2d/test_should_match_snapshot_dark_theme[dark_theme].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions
101
tests/safeds/data/tabular/plotting/test_plot_histogram_2d.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 |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import pytest | ||
| from safeds.data.tabular.containers import Table | ||
| from safeds.exceptions import ColumnNotFoundError, ColumnTypeError, OutOfBoundsError | ||
| from syrupy import SnapshotAssertion | ||
|
|
||
| from tests.helpers import os_mac, skip_if_os | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("table", "col1", "col2"), | ||
| [ | ||
| (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "A", "B"), | ||
| ( | ||
| Table( | ||
| { | ||
| "A": [1, 0.99, 0.99, 2], | ||
| "B": [1, 0.99, 1.01, 2], | ||
| }, | ||
| ), | ||
| "A", | ||
| "B", | ||
| ), | ||
| ( | ||
| Table( | ||
| {"A": [1, 0.99, 0.99, 2], "B": [1, 0.99, 1.01, 2], "C": [2, 2.99, 2.01, 3]}, | ||
| ), | ||
| "A", | ||
| "B", | ||
| ), | ||
| ], | ||
| ids=[ | ||
| "functional", | ||
| "overlapping", | ||
| "multiple", | ||
| ], | ||
| ) | ||
| def test_should_match_snapshot( | ||
| table: Table, | ||
| col1: str, | ||
| col2: str, | ||
| snapshot_png_image: SnapshotAssertion, | ||
| ) -> None: | ||
| skip_if_os([os_mac]) | ||
| histogram_2d = table.plot.histogram_2d(col1, col2) | ||
| assert histogram_2d == snapshot_png_image | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("table", "col1", "col2"), | ||
| [ | ||
| (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"), | ||
| ], | ||
| ids=[ | ||
| "First argument doesn't exist", | ||
| "Second argument doesn't exist", | ||
| "Both arguments do not exist", | ||
| "empty", | ||
| ], | ||
| ) | ||
| def test_should_raise_if_column_does_not_exist(table: Table, col1: str, col2: str) -> None: | ||
| with pytest.raises(ColumnNotFoundError): | ||
| table.plot.histogram_2d(col1, col2) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("table", "col1", "col2"), | ||
| [ | ||
| (Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "A", "B"), | ||
| ], | ||
| ids=["dark_theme"], | ||
| ) | ||
| def test_should_match_snapshot_dark_theme( | ||
| table: Table, | ||
| col1: str, | ||
| col2: str, | ||
| snapshot_png_image: SnapshotAssertion, | ||
| ) -> None: | ||
| skip_if_os([os_mac]) | ||
| histogram_2d = table.plot.histogram_2d(col1, col2, theme="dark") | ||
| assert histogram_2d == snapshot_png_image | ||
|
|
||
|
|
||
| def test_should_raise_if_value_not_in_range_x() -> None: | ||
| table = Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}) | ||
| with pytest.raises(OutOfBoundsError): | ||
| table.plot.histogram_2d("col1", "col2", x_max_bin_count=0) | ||
|
|
||
|
|
||
| def test_should_raise_if_value_not_in_range_y() -> None: | ||
| table = Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}) | ||
| with pytest.raises(OutOfBoundsError): | ||
| table.plot.histogram_2d("col1", "col2", y_max_bin_count=0) | ||
|
|
||
|
|
||
| def test_should_raise_if_column_is_not_numeric() -> None: | ||
| table = Table({"col1": ["a"], "col2": ["b"]}) | ||
| with pytest.raises(ColumnTypeError): | ||
| table.plot.histogram_2d("col1", "col2") |
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.