diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 81006c4e..a65cac0d 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -146,6 +146,19 @@ def estimate(self, y_true: NDArray, y_proxy: NDArray, power_tuning: bool = True) def estimate(self, y_true: NDArray, y_proxy: NDArray, *, power_tuning: bool = True) -> ...: ... ``` +### Zip Strictness + +Every `zip()` call must pass an explicit `strict=` argument (ruff `B905`). Use `strict=True` whenever the iterables are expected to have the same length, so a mismatch raises instead of silently truncating; use `strict=False` only when truncation is intended. This applies to library code, tests and notebook code cells alike. + +```python +# BAD +for estimate, label in zip(estimates, labels): ... + + +# GOOD +for estimate, label in zip(estimates, labels, strict=True): ... +``` + ### Type Conversions Do not use needless type conversions like `float()` or `int()` unless required by the caller or for debugging purposes. diff --git a/docs/deep_dive/case_studies/memerag.ipynb b/docs/deep_dive/case_studies/memerag.ipynb index 576e5e62..503da59f 100644 --- a/docs/deep_dive/case_studies/memerag.ipynb +++ b/docs/deep_dive/case_studies/memerag.ipynb @@ -338,7 +338,7 @@ "fig, ax = plt.subplots(figsize=(11, 5.5))\n", "y_pos = [2, 1, 0]\n", "\n", - "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates):\n", + "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates, strict=True):\n", " ax.plot([lo, hi], [y, y], color=color, linewidth=4, solid_capstyle=\"round\", zorder=3)\n", " for xc in [lo, hi]:\n", " ax.plot([xc, xc], [y - 0.2, y + 0.2], color=color, linewidth=2.5, zorder=3)\n", @@ -571,7 +571,7 @@ ], "metadata": { "kernelspec": { - "display_name": "glide-py (3.12.12.final.0)", + "display_name": "glide-py (3.12.12)", "language": "python", "name": "python3" }, diff --git a/docs/deep_dive/case_studies/spider.ipynb b/docs/deep_dive/case_studies/spider.ipynb index 60252b2c..8fb4761e 100644 --- a/docs/deep_dive/case_studies/spider.ipynb +++ b/docs/deep_dive/case_studies/spider.ipynb @@ -231,7 +231,7 @@ "fig, ax = plt.subplots(figsize=(11, 5.5))\n", "y_pos = [2, 1, 0]\n", "\n", - "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates):\n", + "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates, strict=True):\n", " ax.plot([lo, hi], [y, y], color=color, linewidth=4, solid_capstyle=\"round\", zorder=3)\n", " for xc in [lo, hi]:\n", " ax.plot([xc, xc], [y - 0.2, y + 0.2], color=color, linewidth=2.5, zorder=3)\n", diff --git a/docs/deep_dive/scientific_validation/estimators/asi.ipynb b/docs/deep_dive/scientific_validation/estimators/asi.ipynb index 9be0875d..e5f660e8 100644 --- a/docs/deep_dive/scientific_validation/estimators/asi.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/asi.ipynb @@ -375,7 +375,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"ASI\": \"darkorange\", \"Proxy only\": \"red\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/deep_dive/scientific_validation/estimators/clustered_ppi.ipynb b/docs/deep_dive/scientific_validation/estimators/clustered_ppi.ipynb index 3d6f17c9..eca9efca 100644 --- a/docs/deep_dive/scientific_validation/estimators/clustered_ppi.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/clustered_ppi.ipynb @@ -284,7 +284,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"Clustered PPI++\": \"darkorange\", \"Proxy only\": \"red\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/deep_dive/scientific_validation/estimators/clustered_ptd.ipynb b/docs/deep_dive/scientific_validation/estimators/clustered_ptd.ipynb index e6172672..e398cab6 100644 --- a/docs/deep_dive/scientific_validation/estimators/clustered_ptd.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/clustered_ptd.ipynb @@ -284,7 +284,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"Clustered PTD\": \"darkorange\", \"Proxy only\": \"red\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/deep_dive/scientific_validation/estimators/ipwptd.ipynb b/docs/deep_dive/scientific_validation/estimators/ipwptd.ipynb index 6ae422bd..353cc81e 100644 --- a/docs/deep_dive/scientific_validation/estimators/ipwptd.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/ipwptd.ipynb @@ -375,7 +375,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"IPW PTD\": \"darkorange\", \"Proxy only\": \"red\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/deep_dive/scientific_validation/estimators/multi_ppi.ipynb b/docs/deep_dive/scientific_validation/estimators/multi_ppi.ipynb index 9aa30688..9cee78c5 100644 --- a/docs/deep_dive/scientific_validation/estimators/multi_ppi.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/multi_ppi.ipynb @@ -304,7 +304,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"Multi-PPI++\": \"darkorange\", \"Proxy 1 only\": \"red\", \"Proxy 2 only\": \"firebrick\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/deep_dive/scientific_validation/estimators/multi_ptd.ipynb b/docs/deep_dive/scientific_validation/estimators/multi_ptd.ipynb index 48551fc1..222c90e0 100644 --- a/docs/deep_dive/scientific_validation/estimators/multi_ptd.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/multi_ptd.ipynb @@ -304,7 +304,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"Multi-PTD\": \"darkorange\", \"Proxy 1 only\": \"red\", \"Proxy 2 only\": \"firebrick\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/deep_dive/scientific_validation/estimators/ppi.ipynb b/docs/deep_dive/scientific_validation/estimators/ppi.ipynb index 30b8dd98..7bfdd637 100644 --- a/docs/deep_dive/scientific_validation/estimators/ppi.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/ppi.ipynb @@ -278,7 +278,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"PPI++\": \"darkorange\", \"Proxy only\": \"red\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/deep_dive/scientific_validation/estimators/ptd.ipynb b/docs/deep_dive/scientific_validation/estimators/ptd.ipynb index 05543638..cd7c24e9 100644 --- a/docs/deep_dive/scientific_validation/estimators/ptd.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/ptd.ipynb @@ -278,7 +278,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"PTD\": \"darkorange\", \"Proxy only\": \"red\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/deep_dive/scientific_validation/estimators/stratified_ppi.ipynb b/docs/deep_dive/scientific_validation/estimators/stratified_ppi.ipynb index 717b7794..b6ce3309 100644 --- a/docs/deep_dive/scientific_validation/estimators/stratified_ppi.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/stratified_ppi.ipynb @@ -304,7 +304,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"Stratified PPI++\": \"darkorange\", \"Proxy only\": \"red\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/deep_dive/scientific_validation/estimators/stratified_ptd.ipynb b/docs/deep_dive/scientific_validation/estimators/stratified_ptd.ipynb index 2c778a55..91a8f682 100644 --- a/docs/deep_dive/scientific_validation/estimators/stratified_ptd.ipynb +++ b/docs/deep_dive/scientific_validation/estimators/stratified_ptd.ipynb @@ -305,7 +305,7 @@ "fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)\n", "colors = {\"True only\": \"steelblue\", \"Stratified PTD\": \"darkorange\", \"Proxy only\": \"red\"}\n", "\n", - "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels):\n", + "for ax, correlation, label in zip(axes, correlations_lmh, corr_labels, strict=True):\n", " ax.plot(confidence_levels, confidence_levels, color=\"black\", lw=1.5, linestyle=\"--\", label=\"Ideal\")\n", " for method in METHODS:\n", " mean_ci = np.array([coverages_confidence_intervals[correlation][cl][method] for cl in confidence_levels])\n", diff --git a/docs/tutorials/estimators/asi.ipynb b/docs/tutorials/estimators/asi.ipynb index 40ba9742..176d772a 100644 --- a/docs/tutorials/estimators/asi.ipynb +++ b/docs/tutorials/estimators/asi.ipynb @@ -406,7 +406,7 @@ "fig, ax = plt.subplots(figsize=(11, 5.5))\n", "y_pos = [2, 1, 0]\n", "\n", - "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates):\n", + "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates, strict=True):\n", " ax.plot([lo, hi], [y, y], color=color, linewidth=4, solid_capstyle=\"round\", zorder=3)\n", " for xc in [lo, hi]:\n", " ax.plot([xc, xc], [y - 0.2, y + 0.2], color=color, linewidth=2.5, zorder=3)\n", diff --git a/docs/tutorials/estimators/clustered_ppi.ipynb b/docs/tutorials/estimators/clustered_ppi.ipynb index b9d196d5..30c68c3d 100644 --- a/docs/tutorials/estimators/clustered_ppi.ipynb +++ b/docs/tutorials/estimators/clustered_ppi.ipynb @@ -265,7 +265,7 @@ "\n", "ax.bar(x_pos, bar_vals, color=bar_colors, width=0.45, edgecolor=\"white\", linewidth=2, zorder=3)\n", "\n", - "for xi, val, c in zip(x_pos, bar_vals, bar_colors):\n", + "for xi, val, c in zip(x_pos, bar_vals, bar_colors, strict=True):\n", " ax.text(xi, val + 0.005, f\"{val:.1%}\", ha=\"center\", fontsize=14, fontweight=\"bold\", color=c)\n", "\n", "ax.annotate(\n", @@ -390,7 +390,7 @@ "fig, ax = plt.subplots(figsize=(11, 5.5))\n", "y_pos = [2, 1, 0]\n", "\n", - "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates):\n", + "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates, strict=True):\n", " # Confidence interval line\n", " ax.plot([lo, hi], [y, y], color=color, linewidth=4, solid_capstyle=\"round\", zorder=3)\n", " # Cap marks\n", diff --git a/docs/tutorials/estimators/cost_optimal.ipynb b/docs/tutorials/estimators/cost_optimal.ipynb index b5b80914..4c30a4a6 100644 --- a/docs/tutorials/estimators/cost_optimal.ipynb +++ b/docs/tutorials/estimators/cost_optimal.ipynb @@ -416,7 +416,7 @@ "fig, ax = plt.subplots(figsize=(11, 5.5))\n", "y_pos = [2, 1, 0]\n", "\n", - "for y, (label, mean, lo, hi, color) in zip(y_pos, baseline_estimates):\n", + "for y, (label, mean, lo, hi, color) in zip(y_pos, baseline_estimates, strict=True):\n", " ax.plot([lo, hi], [y, y], color=color, linewidth=4, solid_capstyle=\"round\", zorder=3)\n", " for xc in [lo, hi]:\n", " ax.plot([xc, xc], [y - 0.2, y + 0.2], color=color, linewidth=2.5, zorder=3)\n", diff --git a/docs/tutorials/estimators/cost_optimal_random.ipynb b/docs/tutorials/estimators/cost_optimal_random.ipynb index 8153c8b8..e9a8f100 100644 --- a/docs/tutorials/estimators/cost_optimal_random.ipynb +++ b/docs/tutorials/estimators/cost_optimal_random.ipynb @@ -409,7 +409,7 @@ "fig, ax = plt.subplots(figsize=(11, 5.5))\n", "y_pos = [2, 1, 0]\n", "\n", - "for y, (label, mean, lo, hi, color) in zip(y_pos, baseline_estimates):\n", + "for y, (label, mean, lo, hi, color) in zip(y_pos, baseline_estimates, strict=True):\n", " ax.plot([lo, hi], [y, y], color=color, linewidth=4, solid_capstyle=\"round\", zorder=3)\n", " for xc in [lo, hi]:\n", " ax.plot([xc, xc], [y - 0.2, y + 0.2], color=color, linewidth=2.5, zorder=3)\n", diff --git a/docs/tutorials/estimators/multi_ppi.ipynb b/docs/tutorials/estimators/multi_ppi.ipynb index 3d4349ad..cf581c45 100644 --- a/docs/tutorials/estimators/multi_ppi.ipynb +++ b/docs/tutorials/estimators/multi_ppi.ipynb @@ -281,10 +281,10 @@ "\n", "ax.bar(x_pos, bar_vals, color=bar_colors, width=0.45, edgecolor=\"white\", linewidth=2, zorder=3)\n", "\n", - "for xi_pos, val, c in zip(x_pos, bar_vals, bar_colors):\n", + "for xi_pos, val, c in zip(x_pos, bar_vals, bar_colors, strict=True):\n", " ax.text(xi_pos, val + 0.004, f\"{val:.1%}\", ha=\"center\", fontsize=14, fontweight=\"bold\", color=c)\n", "\n", - "for xi_pos, bias in zip([0, 1], [gemini_bias, claude_bias]):\n", + "for xi_pos, bias in zip([0, 1], [gemini_bias, claude_bias], strict=True):\n", " ax.text(\n", " xi_pos,\n", " t_mean + 0.055,\n", @@ -410,7 +410,7 @@ "fig, ax = plt.subplots(figsize=(11, 7))\n", "y_pos = [3, 2, 1, 0]\n", "\n", - "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates):\n", + "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates, strict=True):\n", " ax.plot([lo, hi], [y, y], color=color, linewidth=4, solid_capstyle=\"round\", zorder=3)\n", " for xc in [lo, hi]:\n", " ax.plot([xc, xc], [y - 0.2, y + 0.2], color=color, linewidth=2.5, zorder=3)\n", diff --git a/docs/tutorials/estimators/ppi.ipynb b/docs/tutorials/estimators/ppi.ipynb index 22b0acad..2d73e438 100644 --- a/docs/tutorials/estimators/ppi.ipynb +++ b/docs/tutorials/estimators/ppi.ipynb @@ -258,7 +258,7 @@ "\n", "ax.bar(x_pos, bar_vals, color=bar_colors, width=0.45, edgecolor=\"white\", linewidth=2, zorder=3)\n", "\n", - "for xi, val, c in zip(x_pos, bar_vals, bar_colors):\n", + "for xi, val, c in zip(x_pos, bar_vals, bar_colors, strict=True):\n", " ax.text(xi, val + 0.005, f\"{val:.1%}\", ha=\"center\", fontsize=14, fontweight=\"bold\", color=c)\n", "\n", "ax.annotate(\n", @@ -381,7 +381,7 @@ "fig, ax = plt.subplots(figsize=(11, 5.5))\n", "y_pos = [2, 1, 0]\n", "\n", - "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates):\n", + "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates, strict=True):\n", " # Confidence interval line\n", " ax.plot([lo, hi], [y, y], color=color, linewidth=4, solid_capstyle=\"round\", zorder=3)\n", " # Cap marks\n", diff --git a/docs/tutorials/estimators/stratified_ppi.ipynb b/docs/tutorials/estimators/stratified_ppi.ipynb index 4fd32d0c..8f8e3cb8 100644 --- a/docs/tutorials/estimators/stratified_ppi.ipynb +++ b/docs/tutorials/estimators/stratified_ppi.ipynb @@ -347,7 +347,7 @@ ")\n", "\n", "# Annotate biases\n", - "for i, (j_mean, h_mean, bias) in enumerate(zip(judge_means, human_means, biases)):\n", + "for i, (j_mean, h_mean, bias) in enumerate(zip(judge_means, human_means, biases, strict=True)):\n", " max_y = max(j_mean, h_mean)\n", " ax.annotate(\n", " \"\",\n", @@ -473,7 +473,7 @@ "fig, ax = plt.subplots(figsize=(12, 6))\n", "y_pos = [2, 1, 0]\n", "\n", - "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates):\n", + "for y, (label, mean, lo, hi, color) in zip(y_pos, estimates, strict=True):\n", " # Confidence interval line\n", " ax.plot([lo, hi], [y, y], color=color, linewidth=5, solid_capstyle=\"round\", zorder=3)\n", " # Cap marks\n", diff --git a/glide/simulators/multi_binary.py b/glide/simulators/multi_binary.py index 19e9f0a0..c0a2caf3 100644 --- a/glide/simulators/multi_binary.py +++ b/glide/simulators/multi_binary.py @@ -129,7 +129,8 @@ def generate_multi_binary_dataset( min_correlations = np.maximum(-p_t * p_p, p_p + p_t - 1 - p_t * p_p) / D max_correlations = np.minimum(p_t * (1 - p_p), p_p * (1 - p_t)) / D - for m, (rho, lo, hi, proxy_mean) in enumerate(zip(correlations_arr, min_correlations, max_correlations, p_p)): + bounds = zip(correlations_arr, min_correlations, max_correlations, p_p, strict=True) + for m, (rho, lo, hi, proxy_mean) in enumerate(bounds): if rho < lo or rho > hi: raise ValueError( f"Proxy {m}: impossible combination of 'true_mean'={true_mean!r}, " diff --git a/pyproject.toml b/pyproject.toml index 909e6e39..e5837035 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ default-groups = ["dev"] [tool.ruff] line-length = 120 fix = true -lint.select = ["E", "F", "FBT001", "FBT002", "I", "RUF001", "RUF002", "RUF003", "D102", "D105", "B028"] +lint.select = ["E", "F", "FBT001", "FBT002", "I", "RUF001", "RUF002", "RUF003", "D102", "D105", "B028", "B905"] [tool.ty.analysis] respect-type-ignore-comments = true diff --git a/tests/unit/engines/test_clustered_ppi.py b/tests/unit/engines/test_clustered_ppi.py index ed5867e8..5dff5369 100644 --- a/tests/unit/engines/test_clustered_ppi.py +++ b/tests/unit/engines/test_clustered_ppi.py @@ -65,7 +65,7 @@ def test_fit_tuning_parameter_delegates_to_ppi_engine(engine, dataset): tuning_parameter = engine._fit_tuning_parameter(dataset, power_tuning=False) mock_fit_tuning_parameter.assert_called_once() - for received, expected in zip(mock_fit_tuning_parameter.call_args[0][0], dataset): + for received, expected in zip(mock_fit_tuning_parameter.call_args[0][0], dataset, strict=True): np.testing.assert_array_equal(received, expected) assert mock_fit_tuning_parameter.call_args.kwargs == {"power_tuning": False} assert tuning_parameter == 0.5 @@ -80,7 +80,7 @@ def test_compute_mean_and_std_delegates_to_ppi_engine(engine, dataset): mean, std = engine._compute_mean_and_std(dataset, tuning_parameter=0.5) mock_compute_mean_and_std.assert_called_once() - for received, expected in zip(mock_compute_mean_and_std.call_args[0][0], dataset): + for received, expected in zip(mock_compute_mean_and_std.call_args[0][0], dataset, strict=True): np.testing.assert_array_equal(received, expected) assert mock_compute_mean_and_std.call_args[0][1] == 0.5 assert (mean, std) == (1.5, 0.25) diff --git a/tests/unit/simulators/test_batched_clustered_binary.py b/tests/unit/simulators/test_batched_clustered_binary.py index 34528862..7ec2010a 100644 --- a/tests/unit/simulators/test_batched_clustered_binary.py +++ b/tests/unit/simulators/test_batched_clustered_binary.py @@ -56,7 +56,7 @@ def test_generate_batched_clustered_binary_dataset_delegates_to_validation(datas def test_generate_batched_clustered_binary_dataset_reproducibility(dataset_params): output1 = generate_batched_clustered_binary_dataset(**dataset_params, random_seed=42) output2 = generate_batched_clustered_binary_dataset(**dataset_params, random_seed=42) - for array1, array2 in zip(output1, output2): + for array1, array2 in zip(output1, output2, strict=True): np.testing.assert_array_equal(array1, array2)