diff --git a/dp_wizard/utils/shared.py b/dp_wizard/utils/shared.py index b4b17bd4..5d8b7bf2 100644 --- a/dp_wizard/utils/shared.py +++ b/dp_wizard/utils/shared.py @@ -61,9 +61,7 @@ def df_to_columns(df: DataFrame): return transposed if transposed else (tuple(), tuple()) -def plot_bars( - df: DataFrame, error: float, cutoff: float, title: str -): # pragma: no cover +def plot_bars(df: DataFrame, error: float, cutoff: float, title: str): """ Given a Dataframe, make a bar plot of the data in the last column, with labels from the prior columns. diff --git a/tests/utils/test_code_generators.py b/tests/utils/test_code_generators.py index 7e92321c..9b4c9abf 100644 --- a/tests/utils/test_code_generators.py +++ b/tests/utils/test_code_generators.py @@ -204,6 +204,9 @@ def id_for_plan(plan: AnalysisPlan): @pytest.mark.parametrize("plan", plans, ids=id_for_plan) def test_make_notebook(plan): notebook = NotebookGenerator(plan).make_py() + + assert "no cover" not in notebook + print(number_lines(notebook)) globals = {} exec(notebook, globals) @@ -219,6 +222,8 @@ def test_make_script(plan): assert "# -" not in script assert "# +" not in script + assert "no cover" not in script + with NamedTemporaryFile(mode="w") as fp: fp.write(script) fp.flush() diff --git a/tests/utils/test_shared.py b/tests/utils/test_shared.py index c350cc4e..b66e8a36 100644 --- a/tests/utils/test_shared.py +++ b/tests/utils/test_shared.py @@ -1,4 +1,4 @@ -from dp_wizard.utils.shared import df_to_columns +from dp_wizard.utils.shared import df_to_columns, plot_bars import polars as pl @@ -55,3 +55,22 @@ def test_no_rows_df_to_columns(): tuple(), tuple(), ) + + +def test_plot_bars(): + # TODO: This test should be stronger, but wait until we move to plotly. + # https://github.com/opendp/dp-wizard/issues/552 + plot_bars( + df=pl.DataFrame( + { + "x": ["a", "b", "c"], + "y": [0, 20, 10], + } + ), + error=10, + cutoff=0, + title="Testing 123", + ) + import matplotlib.pyplot as plt + + plt.close()