question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maximum recursion depth exceeded in comparison

See original GitHub issue

Hi there !

I’m writing a summariser of sorts, and to check the validity I’m computing the rouge score of system generated summary and the manual summary.

Now, this worked fine for about 800 documents, and for some unknown reason, the 801th document returned this error:

  File "rouge_letsum.py", line 57, in summary_letsum_looper
    scores[case] = rouge.get_scores(system_generated_summary, manual_summary)[0]
  File "/usr/lib/python3.7/site-packages/rouge/rouge.py", line 85, in get_scores
    return self._get_scores(hyps, refs)
  File "/usr/lib/python3.7/site-packages/rouge/rouge.py", line 97, in _get_scores
    sc = fn(hyp, ref)
  File "/usr/lib/python3.7/site-packages/rouge/rouge.py", line 58, in <lambda>
    rouge_score.rouge_l_summary_level(hyp, ref),
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 273, in rouge_l_summary_level
    prev_union=union)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 221, in _union_lcs
    lcs = set(_recon_lcs(reference_words, evaluated_words))
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 136, in _recon_lcs
    recon_tuple = tuple(map(lambda x: x[0], _recon(i, j)))
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  [Previous line repeated 10 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  [Previous line repeated 64 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 130, in _recon
    return _recon(i - 1, j - 1) + [(x[i - 1], i)]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  [Previous line repeated 7 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  [Previous line repeated 1 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 130, in _recon
    return _recon(i - 1, j - 1) + [(x[i - 1], i)]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  [Previous line repeated 248 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  [Previous line repeated 37 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 130, in _recon
    return _recon(i - 1, j - 1) + [(x[i - 1], i)]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  [Previous line repeated 291 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 130, in _recon
    return _recon(i - 1, j - 1) + [(x[i - 1], i)]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  [Previous line repeated 21 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  [Previous line repeated 19 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 130, in _recon
    return _recon(i - 1, j - 1) + [(x[i - 1], i)]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  [Previous line repeated 79 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  [Previous line repeated 6 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 130, in _recon
    return _recon(i - 1, j - 1) + [(x[i - 1], i)]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  [Previous line repeated 34 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  [Previous line repeated 26 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 130, in _recon
    return _recon(i - 1, j - 1) + [(x[i - 1], i)]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  [Previous line repeated 14 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 130, in _recon
    return _recon(i - 1, j - 1) + [(x[i - 1], i)]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 134, in _recon
    return _recon(i, j - 1)
  [Previous line repeated 25 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 132, in _recon
    return _recon(i - 1, j)
  [Previous line repeated 30 more times]
  File "/usr/lib/python3.7/site-packages/rouge/rouge_score.py", line 127, in _recon
    if i == 0 or j == 0:
RecursionError: maximum recursion depth exceeded in comparison

Any idea how I can resolve this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kaustubhhiwarecommented, Oct 2, 2018

Thanks for the help, that worked out just fine 😄

Closing the issue now.

1reaction
pltrdycommented, Oct 2, 2018

This algorithm really is recursive. The actual number of recursion maybe something like O(n x m) for sequences of length (n, m). The max recursion depth may be - by default - order of magnitude lower.

You can print/set it with:

print(sys.getrecursionlimit())
sys.setrecursionlimit(8735 * 2080 + 10)
Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the maximum recursion depth in Python, and how to ...
The recursion limit is usually 1000. – Boris Verkhovskiy. Apr 24, 2019 at 7:29. 4.
Read more >
Python: Maximum Recursion Depth Exceeded [How to Fix It]
This error says it all—maximum recursion depth exceeded in comparison. This tells you that Python's recursion depth limit of 1000 is reached.
Read more >
Python maximum recursion depth exceeded in comparison
The “maximum recursion depth exceeded in comparison” error is raised when you try to execute a function that exceeds Python's built in recursion...
Read more >
Python RecursionError: Maximum Recursion Depth Exceeded ...
A Python RecursionError exception is raised when the execution of your program exceeds the recursion limit of the Python interpreter. Two ways ...
Read more >
maximum recursion depth exceeded while calling a Python ...
When the interpreter detects that the maximum depth for recursion has reached, it throws the recursionerror ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found