MutaFix run: boltons-008

ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory

fixedoutcome
57swall time
4model calls
$0.0096API cost
Benchmark ground truth (hidden from the agent)
boltons/statsutils.py:456 · operator BINOP · function boltons/statsutils.py::Stats._calc_pearson_type
- c2 = ((2 + beta2)) - (3 * beta1) - 6   (injected bug)+ c2 = (2 * beta2) - (3 * beta1) - 6   (original)
retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore yes

Trace

reproduce
+2.99s
2 failing test(s) · 2 failed, 523 passed · 2.99s
failing tests and errors
tests/test_statsutils.py::test_pearson_type_covers_kappa_ge_zero
tests/test_statsutils.py::test_pearson_type_zero_denominator
tests/test_statsutils.py::test_pearson_type_covers_kappa_ge_zero
E   assert 3 == 4
E    +  where 3 = <boltons.statsutils.Stats object at 0x0000023B7E5D4140>.pearson_type
E    +    where <boltons.statsutils.Stats object at 0x0000023B7E5D4140> = Stats([8, 4, 4, 4, 5, 1, ...])
tests/test_statsutils.py::test_pearson_type_zero_denominator
E   assert 1 == 3
E    +  where 1 = <boltons.statsutils.Stats object at 0x0000023B7E5D5D30>.pearson_type
trace
+3.41s
re-ran 1 test file(s) with the trace plugin: 2 failing and 3 passing tests, 10 library functions ran in a failing test · 0.29s
tests/test_statsutils.py
retrieve
+3.41s
923 functions indexed, 36 reachable from tests/test_statsutils.py::test_pearson_type_covers_kappa_ge_zero in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.
candidates in retriever order
  1. boltons/statsutils.py::Stats._calc_pearson_type call depth - · Ochiai 1.00 (failing 2, passing 0)
  2. boltons/statsutils.py::Stats.__init__ call depth 1 · Ochiai 0.63 (failing 2, passing 3)
  3. boltons/statsutils.py::_StatsProperty.__get__ call depth 2 · Ochiai 0.63 (failing 2, passing 3)
  4. boltons/statsutils.py::Stats._calc_mean call depth - · Ochiai 0.50 (failing 1, passing 1)
  5. boltons/statsutils.py::Stats._calc_variance call depth - · Ochiai 0.50 (failing 1, passing 1)
  6. boltons/statsutils.py::Stats._calc_std_dev call depth - · Ochiai 0.50 (failing 1, passing 1)
  7. boltons/statsutils.py::Stats._calc_skewness call depth - · Ochiai 0.50 (failing 1, passing 1)
  8. boltons/statsutils.py::Stats._calc_kurtosis call depth - · Ochiai 0.50 (failing 1, passing 1)
  9. boltons/statsutils.py::Stats._get_pow_diffs call depth - · Ochiai 0.50 (failing 1, passing 1)
  10. boltons/statsutils.py::_get_conv_func.<locals>.stats_helper call depth - · Ochiai 0.41 (failing 1, passing 2)
  11. boltons/statsutils.py::Stats.__len__ call depth 1 · Ochiai 0.00 (failing 0, passing 0)
  12. boltons/statsutils.py::Stats.__iter__ call depth 1 · Ochiai 0.00 (failing 0, passing 0)
  13. boltons/ioutils.py::SpooledIOBase.len call depth 2 · Ochiai 0.00 (failing 0, passing 0)
  14. boltons/ioutils.py::SpooledBytesIO.len call depth 2 · Ochiai 0.00 (failing 0, passing 0)
  15. boltons/ioutils.py::SpooledStringIO.len call depth 2 · Ochiai 0.00 (failing 0, passing 0)
  16. boltons/statsutils.py::_StatsProperty.__init__ call depth 2 · Ochiai 0.00 (failing 0, passing 0)
  17. boltons/iterutils.py::partition call depth 3 · Ochiai 0.00 (failing 0, passing 0)
  18. boltons/ioutils.py::MultiFileReader.seek call depth 3 · Ochiai 0.00 (failing 0, passing 0)
  19. boltons/iterutils.py::partition.<locals>._make_key_func call depth 3 · Ochiai 0.00 (failing 0, passing 0)
  20. boltons/ioutils.py::MultiFileReader.read call depth 3 · Ochiai 0.00 (failing 0, passing 0)
rank
+3.41s
spectrum order kept (no model call)
  1. boltons/statsutils.py::Stats._calc_pearson_type
  2. boltons/statsutils.py::Stats.__init__
  3. boltons/statsutils.py::_StatsProperty.__get__
  4. boltons/statsutils.py::Stats._calc_mean
  5. boltons/statsutils.py::Stats._calc_variance
read
+5.19s
turn 1 · NVIDIA-Nemotron-3-Nano-30B-A3B · 2591 in / 146 out · 1.78s · $0.00019

read boltons/statsutils.py::Stats._calc_pearson_type

The failing tests assert that `Stats([8, 4, 4, 4, 5, 1, 6, 5]).pearson_type` equals 4 and `Stats([0, 0, 0, 0, 0, 0, -11, 17]).pearson_type` equals 6, but the current implementation returns 3 and 1 respectively. This points to a logic error in the `_calc_pearson_type` method where the rounding precision or the condition checks for determining the Pearson type are likely incorrect.

patch
+9.48s
turn 2 · NVIDIA-Nemotron-3-Nano-30B-A3B · 3380 in / 627 out · 3.98s · $0.00035

The original code uses `round(beta2, precision) == 3` to check if beta2 is exactly 3, which fails due to floating-point precision. Similarly, `c0 == 0` is replaced with `abs(c0) < 1e-10` to handle near-zero values. The condition `round(c1, precision) == 0` is left unchanged as it already uses rounding, but the beta2 and c0 checks need tolerance-based comparison to correctly classify edge cases.

--- a/boltons/statsutils.py+++ b/boltons/statsutils.py@@ -457,5 +457,5 @@          if round(c1, precision) == 0:-            if round(beta2, precision) == 3:+            if abs(beta2 - 3) < 1e-10:                 return 0  # Normal             else:@@ -467,5 +467,5 @@             return 3  # Gamma         else:-            if c0 == 0:+            if abs(c0) < 1e-10:                 # At exact zero, c2's sign selects the limiting Type I/VI.                 return 1 if c2 < 0 else 6

tests: 2 failing (target tests) 2 failed

tests/test_statsutils.py::test_pearson_type_covers_kappa_ge_zero
tests/test_statsutils.py::test_pearson_type_zero_denominator
invalid
+30.93s
turn 3 · nemotron-3-super-120b-a12b · 4255 in / 4096 out · 21.45s · $0.00496

invalid: {"action": "patch", "candidate": 1, "old": " if round(c1, precision) == 0:\n if round(beta2, precision) == 3:\n return 0 # Normal\n else:\n if beta2 < 3:\n return 2 # Symmetric Beta\n elif beta2 > 3:\

model reasoning (excerpt)
We have two failing tests:

1. test_pearson_type_covers_kappa_ge_zero expects pearson_type 4 for [8,4,4,4,5,1,6,5] but got 3.
2. test_pearson_type_zero_denominator expects pearson_type 3 for some input (not shown) but got 1.

Looking at the code, we see that the function `_calc_pearson_type` computes several quantities and then branches.

For the first test, we got 3 instead of 4. According to the code, returning 3 happens when `round(c2, precision) == 0` (line 466-467). So for the first dataset, c2 rounded to the given precision is 0, leading to Gamma (type 3). But we expect type 4 (Type IV).

For the second test, we got 1 instead of 3. Returning 1 happens in two places: when k<0 (line 473-474) or when c0==0 and c2<0 (line 469-471). Since we expected 3 (Gamma) but got 1, it means that the condition for Gamma (round(c2, precision)==0) was not met and we fell into the else branch and then either k<0 or (c0==0 and c2<0) returned 1.

Let's examine the second test name: "test_pearson_type_zero_denominator". This suggests that the denominator in the calculation of k (which is 4*c0*c2) is zero. Indeed, in the code we have a branch for when c0==0 (lines 469-471). So if c0 is zero, we return 1 or 6 depending on the sign of c2. The test expects 3 (Gamma) but we are returning 1, meaning that in the zero denominator case, we are taking the branch for c0==0 and returning 1 (because c2<0). However, the test expects Gamma (type 3). This indicates that when the denominator is zero, we shoul
patch
+57.2s
turn 4 · nemotron-3-super-120b-a12b · 4358 in / 3127 out · 22.69s · $0.00412

The formula for c2 was incorrect. According to the Pearson type system, c2 should be 2*beta2 - 3*beta1 - 6. The original formula beta2 - 3*beta1 - 4 led to misclassification. Changing this formula should cause the Gamma condition (c2≈0) to trigger correctly for exponential-like data and prevent false Gamma triggers for other distributions.

--- a/boltons/statsutils.py+++ b/boltons/statsutils.py@@ -454,5 +454,5 @@         c0 = (4 * beta2) - (3 * beta1)         c1 = skewness * (beta2 + 3)-        c2 = ((2 + beta2)) - (3 * beta1) - 6+        c2 = 2 * beta2 - 3 * beta1 - 6          if round(c1, precision) == 0:

tests: all tests pass 525 passed

model reasoning (excerpt)
We have two failing tests:

1. test_pearson_type_covers_kappa_ge_zero expects pearson_type==4 for [8,4,4,4,5,1,6,5] but got 3.
2. test_pearson_type_zero_denominator expects pearson_type==3 for some input (likely when denominator becomes zero) but got 1.

Looking at the provided code for _calc_pearson_type, we note:

- For the first case, the function returned 3 (Gamma) instead of 4 (Type IV).
- For the second case, the function returned 1 (Beta) instead of 3 (Gamma).

Let's analyze the conditions:

The function computes:
  beta1 = skewness^2
  beta2 = kurtosis
  c0 = 4*beta2 - 3*beta1
  c1 = skewness*(beta2+3)
  c2 = (2+beta2) - 3*beta1 - 6   [Note: there's a typo? Actually, it's written as ((2 + beta2)) - (3 * beta1) - 6]

Then:
  if round(c1, precision) == 0: ... (handles symmetric cases)
  elif round(c2, precision) == 0: return 3 (Gamma)
  else: ... (then checks c0, then k)

In the first failing test, we got 3, meaning it went into the `elif round(c2, precision) == 0:` branch and returned 3 (Gamma). But we expected 4 (Type IV). So for the data [8,4,4,4,5,1,6,5], the condition `round(c2, precision) == 0` was true, but it should not have been (or we should have gone to the else branch and then returned 4).

In the second failing test, we got 1 (Beta) but expected 3 (Gamma). That means it did not go into the `round(c2, precision)==0` branch, but instead went into the else branch and then returned 1 (Beta). So for that data, we expected to hit the Gamma condition (return 3) bu

Final patch

--- a/boltons/statsutils.py+++ b/boltons/statsutils.py@@ -454,5 +454,5 @@         c0 = (4 * beta2) - (3 * beta1)         c1 = skewness * (beta2 + 3)-        c2 = ((2 + beta2)) - (3 * beta1) - 6+        c2 = 2 * beta2 - 3 * beta1 - 6          if round(c1, precision) == 0: