Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/safeds/data/tabular/plotting/_table_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def line_plot(self, x_name: str, y_name: str) -> Image:
import polars as pl

grouped = (
self._table._lazy_frame.group_by(x_name, maintain_order=True)
self._table._lazy_frame.sort(x_name)
.group_by(x_name)
.agg(
mean=pl.mean(y_name),
count=pl.count(y_name),
Expand Down
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.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@
from syrupy import SnapshotAssertion


def test_should_match_snapshot(snapshot_png_image: SnapshotAssertion) -> None:
table = Table({"A": [1, 2, 3], "B": [2, 4, 7]})
lineplot = table.plot.line_plot("A", "B")
assert lineplot == snapshot_png_image
@pytest.mark.parametrize(
("table", "x_name", "y_name"),
[
(Table({"A": [1, 2, 3], "B": [2, 4, 7]}), "A", "B"),
(Table({"A": [1, 1, 2, 2], "B": [2, 4, 6, 8]}), "A", "B"),
(Table({"A": [2, 1, 3, 3, 1, 2], "B": [6, 2, 5, 5, 4, 8]}), "A", "B"),
],
ids=[
"functional",
"sorted grouped",
"unsorted grouped",
],
)
def test_should_match_snapshot(table: Table, x_name: str, y_name: str, snapshot_png_image: SnapshotAssertion) -> None:
line_plot = table.plot.line_plot(x_name, y_name)
assert line_plot == snapshot_png_image


@pytest.mark.parametrize(
Expand Down