-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added
Table.plot_histograms
to plot a histogram for each colu…
…mn in the table (#252) Closes #157. ### Summary of Changes Added `Table.plot_histograms` to plot a histpogram for each column in the table Changed xticks in `Column.plot_histogram` to match `Table.plot_histograms` (the first and last xtick labels are outside of the value range) --------- Co-authored-by: sibre28 <[email protected]> Co-authored-by: Lars Reimann <[email protected]>
- Loading branch information
1 parent
01c3ad9
commit e27d410
Showing
10 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 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
24 changes: 24 additions & 0 deletions
24
tests/safeds/data/tabular/containers/_table/test_plot_histograms.py
This file contains 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,24 @@ | ||
import pytest | ||
from safeds.data.image.containers import Image | ||
from safeds.data.tabular.containers import Table | ||
|
||
from tests.helpers import resolve_resource_path | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("table", "path"), | ||
[ | ||
(Table({"A": [1, 2, 3]}), "./image/snapshot_histograms/one_column.png"), | ||
( | ||
Table({"A": [1, 2, 3], "B": ["A", "A", "Bla"], "C": [True, True, False], "D": [1.0, 2.1, 4.5]}), | ||
"./image/snapshot_histograms/four_columns.png", | ||
), | ||
], | ||
) | ||
def test_should_match_snapshot(table: Table, path: str) -> None: | ||
current = table.plot_histograms() | ||
snapshot = Image.from_png_file(resolve_resource_path(path)) | ||
|
||
# Inlining the expression into the assert causes pytest to hang if the assertion fails when run from PyCharm. | ||
assertion = snapshot._image.tobytes() == current._image.tobytes() | ||
assert assertion |
This file contains 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 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