MutaFix run: boltons-008
ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory
- 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
failing tests and errors
tests/test_statsutils.py::test_pearson_type_covers_kappa_ge_zero tests/test_statsutils.py::test_pearson_type_zero_denominatortests/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
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
boltons/statsutils.py::Stats._calc_pearson_typeboltons/statsutils.py::Stats.__init__boltons/statsutils.py::_StatsProperty.__get__boltons/statsutils.py::Stats._calc_meanboltons/statsutils.py::Stats._calc_varianceboltons/statsutils.py::Stats._calc_std_devboltons/statsutils.py::Stats._calc_skewnessboltons/statsutils.py::Stats._calc_kurtosisboltons/statsutils.py::Stats._get_pow_diffsboltons/statsutils.py::_get_conv_func.<locals>.stats_helperboltons/statsutils.py::Stats.__len__boltons/statsutils.py::Stats.__iter__boltons/ioutils.py::SpooledIOBase.lenboltons/ioutils.py::SpooledBytesIO.lenboltons/ioutils.py::SpooledStringIO.lenboltons/statsutils.py::_StatsProperty.__init__boltons/iterutils.py::partitionboltons/ioutils.py::MultiFileReader.seekboltons/iterutils.py::partition.<locals>._make_key_funcboltons/ioutils.py::MultiFileReader.read
boltons/statsutils.py::Stats._calc_pearson_typeboltons/statsutils.py::Stats.__init__boltons/statsutils.py::_StatsProperty.__get__boltons/statsutils.py::Stats._calc_meanboltons/statsutils.py::Stats._calc_variance
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.
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)
tests/test_statsutils.py::test_pearson_type_covers_kappa_ge_zero tests/test_statsutils.py::test_pearson_type_zero_denominator
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
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
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: