-
Notifications
You must be signed in to change notification settings - Fork 5
feat: implement violin plots #900
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
ac7ddf8
added new folders and files for violin plots
Muellersen 6eddbea
added docs for violin plots (column- and table plotter) and updated d…
Muellersen 22eac91
Merge branch 'main' into 867-violin-plots-on-table--column
Muellersen 69e7f0a
fix mega linter error
Muellersen f098ab3
style: apply automated linter fixes
megalinter-bot 56cedd6
added darkmode to violin plots
Muellersen 14a4cca
Merge branch 'main' into 867-violin-plots-on-table--column
Muellersen f221cfa
style: apply automated linter fixes
megalinter-bot 7e95888
Merge branch 'main' into 867-violin-plots-on-table--column and added …
Muellersen 54a0c31
fixed missing space
Muellersen 0d2de2b
parameters are now keyword only
Muellersen 3d211e8
fixed linter error
Muellersen 7ed7086
style: apply automated linter fixes
megalinter-bot 9d63afd
refactor: rename file
lars-reimann f19bc3b
removed unnecessary line of violinplot for table and updated snapshots
Muellersen 12cfc68
Merge branch 'main' into 867-violin-plots-on-table--column
Muellersen 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Binary file added
BIN
+8.6 KB
.../__snapshots__/test_plot_violin_plot/test_should_match_dark_snapshot[empty].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
+12 KB
...hots__/test_plot_violin_plot/test_should_match_dark_snapshot[multiple rows].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
+8.32 KB
..._snapshots__/test_plot_violin_plot/test_should_match_dark_snapshot[one row].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
+8.95 KB
...olumn/__snapshots__/test_plot_violin_plot/test_should_match_snapshot[empty].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
+11.9 KB
...snapshots__/test_plot_violin_plot/test_should_match_snapshot[multiple rows].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
+8.56 KB
...umn/__snapshots__/test_plot_violin_plot/test_should_match_snapshot[one row].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions
46
tests/safeds/data/tabular/containers/_column/test_plot_violin_plot.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,46 @@ | ||
| import pytest | ||
| from safeds.data.tabular.containers import Column | ||
| from safeds.exceptions import ColumnTypeError | ||
| from syrupy import SnapshotAssertion | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "column", | ||
| [ | ||
| Column("a", []), | ||
| Column("a", [0]), | ||
| Column("a", [0, 1]), | ||
| ], | ||
| ids=[ | ||
| "empty", | ||
| "one row", | ||
| "multiple rows", | ||
| ], | ||
| ) | ||
| def test_should_match_snapshot(column: Column, snapshot_png_image: SnapshotAssertion) -> None: | ||
| violin_plot = column.plot.violin_plot() | ||
| assert violin_plot == snapshot_png_image | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "column", | ||
| [ | ||
| Column("a", []), | ||
| Column("a", [0]), | ||
| Column("a", [0, 1]), | ||
| ], | ||
| ids=[ | ||
| "empty", | ||
| "one row", | ||
| "multiple rows", | ||
| ], | ||
| ) | ||
| def test_should_match_dark_snapshot(column: Column, snapshot_png_image: SnapshotAssertion) -> None: | ||
| violin_plot = column.plot.violin_plot(theme="dark") | ||
| assert violin_plot == snapshot_png_image | ||
|
|
||
|
|
||
| def test_should_raise_if_column_contains_non_numerical_values() -> None: | ||
| column = Column("a", ["A", "B", "C"]) | ||
| with pytest.raises(ColumnTypeError): | ||
| column.plot.violin_plot() |
Binary file added
BIN
+17.7 KB
...ot_violin_plots/test_should_match_dark_snapshot[four columns (all numeric)].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
+20.9 KB
...olin_plots/test_should_match_dark_snapshot[four columns (some non-numeric)].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
+15.5 KB
...pshots__/test_plot_violin_plots/test_should_match_dark_snapshot[one column].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
+17.7 KB
...st_plot_violin_plots/test_should_match_snapshot[four columns (all numeric)].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
+20.9 KB
...ot_violin_plots/test_should_match_snapshot[four columns (some non-numeric)].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
+15.4 KB
...__snapshots__/test_plot_violin_plots/test_should_match_snapshot[one column].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
+17.7 KB
...lot_violinplots/test_should_match_dark_snapshot[four columns (all numeric)].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
+20.9 KB
...iolinplots/test_should_match_dark_snapshot[four columns (some non-numeric)].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
+15.5 KB
...apshots__/test_plot_violinplots/test_should_match_dark_snapshot[one column].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
+17.7 KB
...est_plot_violinplots/test_should_match_snapshot[four columns (all numeric)].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
+20.9 KB
...lot_violinplots/test_should_match_snapshot[four columns (some non-numeric)].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
+15.4 KB
.../__snapshots__/test_plot_violinplots/test_should_match_snapshot[one column].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions
49
tests/safeds/data/tabular/plotting/test_plot_violin_plots.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,49 @@ | ||
| import pytest | ||
| from safeds.data.tabular.containers import Table | ||
| from safeds.exceptions import NonNumericColumnError | ||
| from syrupy import SnapshotAssertion | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "table", | ||
| [ | ||
| Table({"A": [1, 2, 3]}), | ||
| Table({"A": [1, 2, 3], "B": ["A", "A", "Bla"], "C": [True, True, False], "D": [1.0, 2.1, 4.5]}), | ||
| Table({"A": [1, 2, 3], "B": [1.0, 2.1, 4.5], "C": [1, 2, 3], "D": [1.0, 2.1, 4.5]}), | ||
| ], | ||
| ids=["one column", "four columns (some non-numeric)", "four columns (all numeric)"], | ||
| ) | ||
| def test_should_match_snapshot(table: Table, snapshot_png_image: SnapshotAssertion) -> None: | ||
| violinplots = table.plot.violin_plots() | ||
| assert violinplots == snapshot_png_image | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "table", | ||
| [ | ||
| Table({"A": [1, 2, 3]}), | ||
| Table({"A": [1, 2, 3], "B": ["A", "A", "Bla"], "C": [True, True, False], "D": [1.0, 2.1, 4.5]}), | ||
| Table({"A": [1, 2, 3], "B": [1.0, 2.1, 4.5], "C": [1, 2, 3], "D": [1.0, 2.1, 4.5]}), | ||
| ], | ||
| ids=["one column", "four columns (some non-numeric)", "four columns (all numeric)"], | ||
| ) | ||
| def test_should_match_dark_snapshot(table: Table, snapshot_png_image: SnapshotAssertion) -> None: | ||
| violinplots = table.plot.violin_plots(theme="dark") | ||
| assert violinplots == snapshot_png_image | ||
|
|
||
|
|
||
| def test_should_raise_if_column_contains_non_numerical_values() -> None: | ||
| table = Table.from_dict({"A": ["1", "2", "3.5"], "B": ["0.2", "4", "77"]}) | ||
| with pytest.raises( | ||
| NonNumericColumnError, | ||
| match=( | ||
| r"Tried to do a numerical operation on one or multiple non-numerical columns: \nThis table contains only" | ||
| r" non-numerical columns." | ||
| ), | ||
| ): | ||
| table.plot.violin_plots() | ||
|
|
||
|
|
||
| def test_should_fail_on_empty_table() -> None: | ||
| with pytest.raises(NonNumericColumnError): | ||
| Table().plot.violin_plots() |
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.