MutaFix run: more-itertools-006

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

fixedoutcome
35swall time
2model calls
$0.0007API cost
Benchmark ground truth (hidden from the agent)
more_itertools/recipes.py:1626 · operator NEGCOND · function more_itertools/recipes.py::random_derangement
- if not (not any(map(is_, start, perm))):   (injected bug)+ if not any(map(is_, start, perm)):   (original)
retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore yes

Trace

reproduce
+12.18s
1 failing test(s) · 1 failed, 767 passed · 12.18s
failing tests and errors
tests/test_recipes.py::TestRandomDerangement::test_basics
tests/test_recipes.py::TestRandomDerangement::test_basics
E   AssertionError: True is not false
trace
+19.34s
re-ran 1 test file(s) with the trace plugin: 1 failing and 147 passing tests, 1 library functions ran in a failing test · 7.1s
tests/test_recipes.py
retrieve
+19.34s
280 functions indexed, 2 reachable from tests/test_recipes.py::TestRandomDerangement::test_basics in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.
candidates in retriever order
  1. more_itertools/recipes.py::random_derangement call depth 1 · Ochiai 1.00 (failing 1, passing 0)
  2. more_itertools/more.py::derangements call depth 1 · Ochiai 0.00 (failing 0, passing 0)
  3. more_itertools/more.py::subfactorial call depth - · Ochiai 0.00 (failing 0, passing 0)
  4. more_itertools/more.py::set_partitions call depth - · Ochiai 0.00 (failing 0, passing 0)
  5. more_itertools/recipes.py::is_prime call depth - · Ochiai 0.00 (failing 0, passing 6)
  6. more_itertools/recipes.py::running_statistics call depth - · Ochiai 0.00 (failing 0, passing 3)
  7. more_itertools/recipes.py::multinomial call depth - · Ochiai 0.00 (failing 0, passing 1)
  8. more_itertools/more.py::outer_product call depth - · Ochiai 0.00 (failing 0, passing 0)
  9. more_itertools/recipes.py::running_mean call depth - · Ochiai 0.00 (failing 0, passing 5)
  10. more_itertools/more.py::nth_prime call depth - · Ochiai 0.00 (failing 0, passing 3)
  11. more_itertools/more.py::sample call depth - · Ochiai 0.00 (failing 0, passing 0)
  12. more_itertools/more.py::constrained_batches call depth - · Ochiai 0.00 (failing 0, passing 0)
  13. more_itertools/more.py::unique_to_each call depth - · Ochiai 0.00 (failing 0, passing 0)
  14. more_itertools/more.py::one call depth - · Ochiai 0.00 (failing 0, passing 0)
  15. more_itertools/more.py::windowed call depth - · Ochiai 0.00 (failing 0, passing 0)
  16. more_itertools/more.py::is_sorted call depth - · Ochiai 0.00 (failing 0, passing 0)
  17. more_itertools/recipes.py::_running_median_minheap_only call depth - · Ochiai 0.00 (failing 0, passing 3)
  18. more_itertools/more.py::_islice_helper call depth - · Ochiai 0.00 (failing 0, passing 0)
  19. more_itertools/more.py::gray_product call depth - · Ochiai 0.00 (failing 0, passing 0)
  20. more_itertools/recipes.py::sum_of_squares call depth - · Ochiai 0.00 (failing 0, passing 1)
rank
+19.34s
spectrum order kept (no model call)
  1. more_itertools/recipes.py::random_derangement
  2. more_itertools/more.py::derangements
  3. more_itertools/more.py::subfactorial
  4. more_itertools/more.py::set_partitions
  5. more_itertools/recipes.py::is_prime
read
+21.7s
turn 1 · NVIDIA-Nemotron-3-Nano-30B-A3B · 4850 in / 163 out · 2.36s · $0.00033

read more_itertools/recipes.py::random_derangement

The failing test checks that a derangement has no fixed points (no element at its original index). The bug is likely in the condition that verifies this property. In the current implementation the condition `if not (not any(map(is_, start, perm)))` is intended to ensure that no element stays in its original position, but it is inverted: it returns True when there *is* a fixed point, causing the loop to continue only when a derangement is found. This leads to the test asserting `True is not false` which fails. The fix is to invert the condition so that the loop continues only when a fixed point is present and returns the permutation when no fixed points exist.

patch
+35.2s
turn 2 · NVIDIA-Nemotron-3-Nano-30B-A3B · 5298 in / 127 out · 1.74s · $0.00035

The condition must be true only when there are no fixed points. The double negation in the original code inverts the logic, causing the function to return a permutation that still has fixed points. Removing the outer negation makes the check correctly return True when no element is in its original position, allowing the derangement to be returned.

--- a/more_itertools/recipes.py+++ b/more_itertools/recipes.py@@ -1624,4 +1624,4 @@     while True:         shuffle(perm)-        if not (not any(map(is_, start, perm))):+        if not any(map(is_, start, perm)):             return itemgetter(*perm)(seq)

tests: all tests pass 768 passed

Final patch

--- a/more_itertools/recipes.py+++ b/more_itertools/recipes.py@@ -1624,4 +1624,4 @@     while True:         shuffle(perm)-        if not (not any(map(is_, start, perm))):+        if not any(map(is_, start, perm)):             return itemgetter(*perm)(seq)