From e50c3b0118825e33eef0e2a7073673603e316ee5 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Wed, 19 Apr 2023 14:33:12 +0200 Subject: [PATCH] feat: add `plot_` prefix back to plotting methods (#212) Closes #211. ### Summary of Changes Now that plotting functionality is implemented as methods of `Table` and `Column`, it makes sense to group them together by prepending `plot_` to the method names. --- docs/tutorials/data_visualization.ipynb | 10 +++++----- src/safeds/data/tabular/containers/_column.py | 4 ++-- src/safeds/data/tabular/containers/_table.py | 6 +++--- ...ll_values.py => test_count_missing_values.py} | 0 .../{test_boxplot.py => test_plot_boxplot.py} | 16 ++++++++-------- ...{test_histogram.py => test_plot_histogram.py} | 4 ++-- ...atmap.py => test_plot_correlation_heatmap.py} | 8 ++++---- ...test_scatterplot.py => test_plot_lineplot.py} | 8 ++++---- ...test_lineplot.py => test_plot_scatterplot.py} | 8 ++++---- 9 files changed, 32 insertions(+), 32 deletions(-) rename tests/safeds/data/tabular/containers/_column/{test_count_null_values.py => test_count_missing_values.py} (100%) rename tests/safeds/data/tabular/containers/_column/{test_boxplot.py => test_plot_boxplot.py} (60%) rename tests/safeds/data/tabular/containers/_column/{test_histogram.py => test_plot_histogram.py} (63%) rename tests/safeds/data/tabular/containers/_table/{test_correlation_heatmap.py => test_plot_correlation_heatmap.py} (57%) rename tests/safeds/data/tabular/containers/_table/{test_scatterplot.py => test_plot_lineplot.py} (67%) rename tests/safeds/data/tabular/containers/_table/{test_lineplot.py => test_plot_scatterplot.py} (66%) diff --git a/docs/tutorials/data_visualization.ipynb b/docs/tutorials/data_visualization.ipynb index 355e411ab..739dd1d05 100644 --- a/docs/tutorials/data_visualization.ipynb +++ b/docs/tutorials/data_visualization.ipynb @@ -102,7 +102,7 @@ "execution_count": null, "outputs": [], "source": [ - "titanic_numerical.correlation_heatmap()" + "titanic_numerical.plot_correlation_heatmap()" ], "metadata": { "collapsed": false, @@ -143,7 +143,7 @@ "execution_count": null, "outputs": [], "source": [ - "titanic_numerical.lineplot(\"survived\", \"fare\")" + "titanic_numerical.plot_lineplot(\"survived\", \"fare\")" ], "metadata": { "collapsed": false, @@ -176,7 +176,7 @@ "execution_count": null, "outputs": [], "source": [ - "titanic_numerical.get_column(\"age\").boxplot()" + "titanic_numerical.get_column(\"age\").plot_boxplot()" ], "metadata": { "collapsed": false, @@ -200,7 +200,7 @@ "execution_count": null, "outputs": [], "source": [ - "titanic_numerical.get_column(\"fare\").histogram()" + "titanic_numerical.get_column(\"fare\").plot_histogram()" ], "metadata": { "collapsed": false, @@ -224,7 +224,7 @@ "execution_count": null, "outputs": [], "source": [ - "titanic_numerical.scatterplot(\"age\", \"fare\")\n" + "titanic_numerical.plot_scatterplot(\"age\", \"fare\")\n" ], "metadata": { "collapsed": false, diff --git a/src/safeds/data/tabular/containers/_column.py b/src/safeds/data/tabular/containers/_column.py index 2a7f23712..6ed2038fd 100644 --- a/src/safeds/data/tabular/containers/_column.py +++ b/src/safeds/data/tabular/containers/_column.py @@ -473,7 +473,7 @@ def variance(self) -> float: # Plotting # ------------------------------------------------------------------------------------------------------------------ - def boxplot(self) -> Image: + def plot_boxplot(self) -> Image: """ Plot this column in a boxplot. This function can only plot real numerical data. @@ -507,7 +507,7 @@ def boxplot(self) -> Image: buffer.seek(0) return Image(buffer, ImageFormat.PNG) - def histogram(self) -> Image: + def plot_histogram(self) -> Image: """ Plot a column in a histogram. diff --git a/src/safeds/data/tabular/containers/_table.py b/src/safeds/data/tabular/containers/_table.py index 956ceb7d5..f9a4a115a 100644 --- a/src/safeds/data/tabular/containers/_table.py +++ b/src/safeds/data/tabular/containers/_table.py @@ -992,7 +992,7 @@ def transform_column(self, name: str, transformer: Callable[[Row], Any]) -> Tabl # Plotting # ------------------------------------------------------------------------------------------------------------------ - def correlation_heatmap(self) -> Image: + def plot_correlation_heatmap(self) -> Image: """ Plot a correlation heatmap for all numerical columns of this `Table`. @@ -1020,7 +1020,7 @@ def correlation_heatmap(self) -> Image: buffer.seek(0) return Image(buffer, format_=ImageFormat.PNG) - def lineplot(self, x_column_name: str, y_column_name: str) -> Image: + def plot_lineplot(self, x_column_name: str, y_column_name: str) -> Image: """ Plot two columns against each other in a lineplot. @@ -1070,7 +1070,7 @@ def lineplot(self, x_column_name: str, y_column_name: str) -> Image: buffer.seek(0) return Image(buffer, format_=ImageFormat.PNG) - def scatterplot(self, x_column_name: str, y_column_name: str) -> Image: + def plot_scatterplot(self, x_column_name: str, y_column_name: str) -> Image: """ Plot two columns against each other in a scatterplot. diff --git a/tests/safeds/data/tabular/containers/_column/test_count_null_values.py b/tests/safeds/data/tabular/containers/_column/test_count_missing_values.py similarity index 100% rename from tests/safeds/data/tabular/containers/_column/test_count_null_values.py rename to tests/safeds/data/tabular/containers/_column/test_count_missing_values.py diff --git a/tests/safeds/data/tabular/containers/_column/test_boxplot.py b/tests/safeds/data/tabular/containers/_column/test_plot_boxplot.py similarity index 60% rename from tests/safeds/data/tabular/containers/_column/test_boxplot.py rename to tests/safeds/data/tabular/containers/_column/test_plot_boxplot.py index 059ab78ad..dab15248c 100644 --- a/tests/safeds/data/tabular/containers/_column/test_boxplot.py +++ b/tests/safeds/data/tabular/containers/_column/test_plot_boxplot.py @@ -5,25 +5,25 @@ from safeds.data.tabular.exceptions import NonNumericColumnError -def test_boxplot_complex() -> None: +def test_plot_boxplot_complex() -> None: with pytest.raises(NotImplementedError): # noqa: PT012 table = Table.from_dict({"A": [1, 2, complex(1, -2)]}) - table.get_column("A").boxplot() + table.get_column("A").plot_boxplot() -def test_boxplot_non_numeric() -> None: +def test_plot_boxplot_non_numeric() -> None: table = Table.from_dict({"A": [1, 2, "A"]}) with pytest.raises(NonNumericColumnError): - table.get_column("A").boxplot() + table.get_column("A").plot_boxplot() -def test_boxplot_float(monkeypatch: _pytest.monkeypatch) -> None: +def test_plot_boxplot_float(monkeypatch: _pytest.monkeypatch) -> None: monkeypatch.setattr(plt, "show", lambda: None) table = Table.from_dict({"A": [1, 2, 3.5]}) - table.get_column("A").boxplot() + table.get_column("A").plot_boxplot() -def test_boxplot_int(monkeypatch: _pytest.monkeypatch) -> None: +def test_plot_boxplot_int(monkeypatch: _pytest.monkeypatch) -> None: monkeypatch.setattr(plt, "show", lambda: None) table = Table.from_dict({"A": [1, 2, 3]}) - table.get_column("A").boxplot() + table.get_column("A").plot_boxplot() diff --git a/tests/safeds/data/tabular/containers/_column/test_histogram.py b/tests/safeds/data/tabular/containers/_column/test_plot_histogram.py similarity index 63% rename from tests/safeds/data/tabular/containers/_column/test_histogram.py rename to tests/safeds/data/tabular/containers/_column/test_plot_histogram.py index dd6fc4f05..24da311f1 100644 --- a/tests/safeds/data/tabular/containers/_column/test_histogram.py +++ b/tests/safeds/data/tabular/containers/_column/test_plot_histogram.py @@ -3,7 +3,7 @@ from safeds.data.tabular.containers import Table -def test_histogram(monkeypatch: _pytest.monkeypatch) -> None: +def test_plot_histogram(monkeypatch: _pytest.monkeypatch) -> None: monkeypatch.setattr(plt, "show", lambda: None) table = Table.from_dict({"A": [1, 2, 3]}) - table.get_column("A").histogram() + table.get_column("A").plot_histogram() diff --git a/tests/safeds/data/tabular/containers/_table/test_correlation_heatmap.py b/tests/safeds/data/tabular/containers/_table/test_plot_correlation_heatmap.py similarity index 57% rename from tests/safeds/data/tabular/containers/_table/test_correlation_heatmap.py rename to tests/safeds/data/tabular/containers/_table/test_plot_correlation_heatmap.py index 7e579b189..7981acae0 100644 --- a/tests/safeds/data/tabular/containers/_table/test_correlation_heatmap.py +++ b/tests/safeds/data/tabular/containers/_table/test_plot_correlation_heatmap.py @@ -3,13 +3,13 @@ from safeds.data.tabular.containers import Table -def test_correlation_heatmap_non_numeric(monkeypatch: _pytest.monkeypatch) -> None: +def test_plot_correlation_heatmap_non_numeric(monkeypatch: _pytest.monkeypatch) -> None: monkeypatch.setattr(plt, "show", lambda: None) table = Table.from_dict({"A": [1, 2, "A"], "B": [1, 2, 3]}) - table.correlation_heatmap() + table.plot_correlation_heatmap() -def test_correlation_heatmap(monkeypatch: _pytest.monkeypatch) -> None: +def test_plot_correlation_heatmap(monkeypatch: _pytest.monkeypatch) -> None: monkeypatch.setattr(plt, "show", lambda: None) table = Table.from_dict({"A": [1, 2, 3.5], "B": [2, 4, 7]}) - table.correlation_heatmap() + table.plot_correlation_heatmap() diff --git a/tests/safeds/data/tabular/containers/_table/test_scatterplot.py b/tests/safeds/data/tabular/containers/_table/test_plot_lineplot.py similarity index 67% rename from tests/safeds/data/tabular/containers/_table/test_scatterplot.py rename to tests/safeds/data/tabular/containers/_table/test_plot_lineplot.py index 3879db603..f1314c6c2 100644 --- a/tests/safeds/data/tabular/containers/_table/test_scatterplot.py +++ b/tests/safeds/data/tabular/containers/_table/test_plot_lineplot.py @@ -5,13 +5,13 @@ from safeds.data.tabular.exceptions import UnknownColumnNameError -def test_scatterplot(monkeypatch: _pytest.monkeypatch) -> None: +def test_plot_lineplot(monkeypatch: _pytest.monkeypatch) -> None: monkeypatch.setattr(plt, "show", lambda: None) table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]}) - table.scatterplot("A", "B") + table.plot_lineplot("A", "B") -def test_scatterplot_wrong_column_name() -> None: +def test_plot_lineplot_wrong_column_name() -> None: table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]}) with pytest.raises(UnknownColumnNameError): - table.scatterplot("C", "A") + table.plot_lineplot("C", "A") diff --git a/tests/safeds/data/tabular/containers/_table/test_lineplot.py b/tests/safeds/data/tabular/containers/_table/test_plot_scatterplot.py similarity index 66% rename from tests/safeds/data/tabular/containers/_table/test_lineplot.py rename to tests/safeds/data/tabular/containers/_table/test_plot_scatterplot.py index c315c7286..21512f895 100644 --- a/tests/safeds/data/tabular/containers/_table/test_lineplot.py +++ b/tests/safeds/data/tabular/containers/_table/test_plot_scatterplot.py @@ -5,13 +5,13 @@ from safeds.data.tabular.exceptions import UnknownColumnNameError -def test_lineplot(monkeypatch: _pytest.monkeypatch) -> None: +def test_plot_scatterplot(monkeypatch: _pytest.monkeypatch) -> None: monkeypatch.setattr(plt, "show", lambda: None) table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]}) - table.lineplot("A", "B") + table.plot_scatterplot("A", "B") -def test_lineplot_wrong_column_name() -> None: +def test_plot_scatterplot_wrong_column_name() -> None: table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]}) with pytest.raises(UnknownColumnNameError): - table.lineplot("C", "A") + table.plot_scatterplot("C", "A")