Skip to content
Draft
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
4 changes: 1 addition & 3 deletions dp_wizard/utils/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions tests/utils/test_code_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
21 changes: 20 additions & 1 deletion tests/utils/test_shared.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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()
Loading