MutaFix run: sortedcontainers-012
ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory
- return 1 if value not in self._set else 0 (injected bug)+ return 1 if value in self._set else 0 (original)retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore yes
Trace
failing tests and errors
tests/test_coverage_sortedset.py::test_count tests/test_stress_sortedset.py::test_stresstests/test_coverage_sortedset.py::test_count
E assert False E + where False = all(<generator object test_count.<locals>.<genexpr> at 0x000001B2FED07BC0>)tests/test_stress_sortedset.py::test_stress
E assert 0 == 1 E + where 0 = count(2) E + where count = SortedSet([2, 3, 6, 10, 14, 30, 32, 43, 44, 47, 50, 52, 55, 71, 79, 81, 102, 104, 105, 106, 108, 111, 112, 114, 115, 1...902, 1907, 1912, 1914, 1921, 1928, 1938, 1940, 1942, 1943, 1947, 1950, 1953, 1957, 1958, 1973, 1981, 1995, 1997, 1999]).count
tests/test_coverage_sortedset.py::test_count in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.candidates in retriever order
src/sortedcontainers/sortedset.py::SortedSet.countsrc/sortedcontainers/sortedset.py::SortedSet.__contains__src/sortedcontainers/sortedset.py::SortedSet.__reversed__src/sortedcontainers/sortedset.py::SortedSet.removesrc/sortedcontainers/sortedlist.py::SortedList.__reversed__src/sortedcontainers/sortedlist.py::SortedList.indexsrc/sortedcontainers/sortedlist.py::SortedList.popsrc/sortedcontainers/sortedset.py::SortedSet.popsrc/sortedcontainers/sortedset.py::SortedSet.intersection_updatesrc/sortedcontainers/sortedset.py::SortedSet.symmetric_difference_updatesrc/sortedcontainers/sortedset.py::SortedSet.__repr__src/sortedcontainers/sortedset.py::SortedSet.difference_updatesrc/sortedcontainers/sortedset.py::SortedSet.copysrc/sortedcontainers/sortedset.py::SortedSet.__delitem__src/sortedcontainers/sortedlist.py::SortedList.__delitem__src/sortedcontainers/sortedlist.py::SortedList._locsrc/sortedcontainers/sortedset.py::SortedSet.discardsrc/sortedcontainers/sortedlist.py::SortedList.removesrc/sortedcontainers/sortedset.py::SortedSet._checksrc/sortedcontainers/sortedlist.py::SortedList._check
src/sortedcontainers/sortedset.py::SortedSet.countsrc/sortedcontainers/sortedset.py::SortedSet.__contains__src/sortedcontainers/sortedset.py::SortedSet.__reversed__src/sortedcontainers/sortedset.py::SortedSet.removesrc/sortedcontainers/sortedlist.py::SortedList.__reversed__
read src/sortedcontainers/sortedset.py::SortedSet.count
The test failure shows that `count` returns a generator object instead of an integer, which matches the assertion error in test_count. The candidate SortedSet.count is the only function that directly implements the `count` method, and its current implementation returns `1 if value not in self._set else 0`, which is logically inverted and would cause incorrect counting behavior. This is the most likely source of the bug.
The current implementation incorrectly returns 1 when the value is NOT in the set and 0 when it IS in the set, which inverts the expected count. The test expects 1 for present values and 0 for absent values, so the condition must be flipped to return 1 when the value is in the set.
--- a/src/sortedcontainers/sortedset.py+++ b/src/sortedcontainers/sortedset.py@@ -374,5 +374,5 @@ """- return 1 if value not in self._set else 0+ return 1 if value in self._set else 0 def discard(self, value):
tests: all tests pass
Final patch
--- a/src/sortedcontainers/sortedset.py+++ b/src/sortedcontainers/sortedset.py@@ -374,5 +374,5 @@ """- return 1 if value not in self._set else 0+ return 1 if value in self._set else 0 def discard(self, value):