-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Column config UI, and template fixes (#87)
* reactive calc for column conf * column config; better templates * formatting * foldable code sample * get the name * Add underscores to emphasize that templates are private * cleaner template names * Move template.py to templates/ dir * move templates to lower dir, since I can not add a single file * add a privacy loss snippet * loss -> epsilon * move plot into column_module * dynamically recompute fake data * Bring over simple plot function, but do not use: expects different input * Lots of TODOs, but DP is connected to mock data * _df_to_dict doc test * much simpler! * better bins * better bins... but last commit was a regression * columns on chart match requested bins * round cutpoints * fix off-by-one * consolidate into doctest * pass name and contributions * update template to reflect new logic * calculated error bars * move DP details to helper function * Move DP details out * doctest of histogram * callbacks to get weights up to the top level * just three weight levels * weight default * when columns are removed, drop weight * avoid divide by zero * We dropped the top option * TODO is done * limit test * upload playwright artifact in CI * script to run tests with coverage * tracing=retain-on-failure, from playwright docs * ignore playwright report * Move Epsilon slider test above column test? * Pointers for trace.playwright * add note
- Loading branch information
Showing
29 changed files
with
506 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
# MacOS | ||
.DS_Store | ||
|
||
# Playwright | ||
test-results/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
coverage run -m pytest -v | ||
coverage report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,23 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
|
||
def plot_error_bars_with_cutoff( | ||
y_values, x_min_label="min", x_max_label="max", y_cutoff=0, y_error=0 | ||
): # pragma: no cover | ||
x_values = 0.5 + np.arange(len(y_values)) | ||
x_values_above = [] | ||
x_values_below = [] | ||
y_values_above = [] | ||
y_values_below = [] | ||
for x, y in zip(x_values, y_values): | ||
if y < y_cutoff: | ||
x_values_below.append(x) | ||
y_values_below.append(y) | ||
else: | ||
x_values_above.append(x) | ||
y_values_above.append(y) | ||
def _df_to_columns(df): | ||
""" | ||
>>> import polars as pl | ||
>>> df = pl.DataFrame({ | ||
... "bin": ["A", "B", "C"], | ||
... "len": [0, 10, 20], | ||
... }) | ||
>>> _df_to_columns(df) | ||
(['A', 'B', 'C'], [0, 10, 20]) | ||
""" | ||
return tuple(list(df[col]) for col in df.columns) | ||
|
||
figure, axes = plt.subplots() | ||
color = "skyblue" | ||
shared = { | ||
"width": 0.8, | ||
"edgecolor": color, | ||
"linewidth": 1, | ||
"yerr": y_error, | ||
} | ||
axes.bar(x_values_above, y_values_above, color=color, **shared) | ||
axes.bar(x_values_below, y_values_below, color="white", **shared) | ||
axes.hlines([y_cutoff], 0, len(y_values), colors=["black"], linestyles=["dotted"]) | ||
|
||
axes.set(xlim=(0, len(y_values)), ylim=(0, max(y_values))) | ||
axes.get_xaxis().set_ticks( | ||
ticks=[x_values[0], x_values[-1]], | ||
labels=[x_min_label, x_max_label], | ||
) | ||
axes.get_yaxis().set_ticks([]) | ||
|
||
return figure | ||
def plot_histogram(histogram_df, error, cutoff): # pragma: no cover | ||
labels, values = _df_to_columns(histogram_df) | ||
_figure, axes = plt.subplots() | ||
bar_colors = ["blue" if v > cutoff else "lightblue" for v in values] | ||
axes.bar(labels, values, color=bar_colors, yerr=error) | ||
axes.axhline(cutoff, color="lightgrey", zorder=-1) | ||
# TODO: Since this seems to return None, how does the information flow? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.