Skip to content

Commit

Permalink
pull contributions into variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc committed Dec 19, 2024
1 parent 4260a30 commit 7175484
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion dp_wizard/app/components/column_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ def column_plot():
weighted_epsilon=epsilon * weight / weights_sum,
)
s = "s" if contributions > 1 else ""
title = f"Simulated {name}: normal distribution, {contributions} contribution{s} / invidual"
title = (
f"Simulated {name}: normal distribution, "
f"{contributions} contribution{s} / invidual"
)
return plot_histogram(
histogram,
error=accuracy,
Expand Down
3 changes: 2 additions & 1 deletion dp_wizard/utils/code_generators/no-tests/_privacy_unit.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
privacy_unit = dp.unit_of(contributions=CONTRIBUTIONS)
contributions = CONTRIBUTIONS
privacy_unit = dp.unit_of(contributions=contributions)
6 changes: 3 additions & 3 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def expect_no_error():
expect_not_visible(download_results_text)
page.get_by_label("Contributions").fill("42")
page.get_by_text("Code sample: Unit of Privacy").click()
expect_visible("dp.unit_of(contributions=42)")
expect_visible("contributions = 42")
expect_no_error()

# Button disabled until upload:
Expand Down Expand Up @@ -156,7 +156,7 @@ def expect_no_error():

script_download = script_download_info.value
script = script_download.path().read_text()
assert "privacy_unit = dp.unit_of(contributions=42)" in script
assert "contributions = 42" in script

# Notebook:
with page.expect_download() as notebook_download_info:
Expand All @@ -165,7 +165,7 @@ def expect_no_error():

notebook_download = notebook_download_info.value
notebook = notebook_download.path().read_text()
assert "privacy_unit = dp.unit_of(contributions=42)" in notebook
assert "contributions = 42" in notebook

# -- Feedback --
page.get_by_text("Feedback").click()
Expand Down

0 comments on commit 7175484

Please sign in to comment.