MutaFix run: more-itertools-007
ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory
- return int(value not in self) (injected bug)+ return int(value in self) (original)retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore yes
Trace
failing tests and errors
tests/test_more.py::NumericRangeTests::test_contains_items_with_inexact_step tests/test_more.py::NumericRangeTests::test_counttests/test_more.py::NumericRangeTests::test_contains_items_with_inexact_step
E AssertionError: 1 != 0tests/test_more.py::NumericRangeTests::test_count
E AssertionError: 1 != 0
tests/test_more.py::NumericRangeTests::test_contains_items_with_inexact_step in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.candidates in retriever order
more_itertools/more.py::numeric_range.countmore_itertools/more.py::numeric_range.__contains__more_itertools/more.py::numeric_range.indexmore_itertools/more.py::numeric_range._index_nearmore_itertools/more.py::numeric_range._get_by_indexmore_itertools/more.py::numeric_range._before_stopmore_itertools/more.py::numeric_range._lenmore_itertools/more.py::numeric_range.__getitem__more_itertools/more.py::numeric_range.__init__more_itertools/more.py::numeric_range.__iter__more_itertools/more.py::numeric_range.__repr__more_itertools/more.py::numeric_range.__reduce__more_itertools/more.py::numeric_range.__eq__more_itertools/more.py::numeric_range.__hash__more_itertools/more.py::numeric_range.__reversed__more_itertools/more.py::numeric_range.__bool__more_itertools/more.py::numeric_range.__len__more_itertools/more.py::_islice_helpermore_itertools/more.py::locatemore_itertools/more.py::is_sorted
more_itertools/more.py::numeric_range.countmore_itertools/more.py::numeric_range.__contains__more_itertools/more.py::numeric_range.indexmore_itertools/more.py::numeric_range._index_nearmore_itertools/more.py::numeric_range._get_by_index
read more_itertools/more.py::numeric_range.count
The failing tests involve `count` and `contains` assertions failing with `1 != 0`, indicating that `count` is returning incorrect results for inexact steps. Candidate 1 is `numeric_range.count`, which directly implements the `count` method and is ranked highest for failing tests. The current implementation `return int(value not in self)` is logically inverted—it returns `1` when the value is *not* in the range, but the test expects `1` when the value *is* in the range (as `r.count(v)` should count occurrences of `v` in `r`). This explains why `assertEqual(1, r.count(v))` fails: `count` returns `0` when `v` is present due to the inverted logic.
The current implementation returns `int(value not in self)`, which evaluates to `1` when `value` is NOT in the range and `0` when it IS. However, the `count` method should return the number of occurrences of `value` in the range, which is `1` when present (since duplicates are not expected in a range) and `0` otherwise. The logic is inverted, causing `count` to return `0` for values that are actually present (as seen in the test failure `1 != 0`). Flipping the condition to `int(value in self)` fixes this: it returns `1` when the value is present (matching the test's expectation) and `0` when absent.
--- a/more_itertools/more.py+++ b/more_itertools/more.py@@ -2466,5 +2466,5 @@ def count(self, value):- return int(value not in self)+ return int(value in self) def index(self, value):
tests: all tests pass
Final patch
--- a/more_itertools/more.py+++ b/more_itertools/more.py@@ -2466,5 +2466,5 @@ def count(self, value):- return int(value not in self)+ return int(value in self) def index(self, value):