Skip to content

Commit

Permalink
Added test for infinite issue with power_method
Browse files Browse the repository at this point in the history
  • Loading branch information
AryazE authored and miso-belica committed Aug 11, 2023
1 parent 8d29125 commit 4f06a6c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_summarizers/test_lex_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,16 @@ def test_power_method_should_return_different_scores_for_sentences():
scores = LexRankSummarizer.power_method(matrix, LexRankSummarizer.epsilon)

assert len(frozenset(scores.tolist())) > 1

def test_power_method_should_return_finite():
"""See https://github.com/miso-belica/sumy/issues/187"""
matrix = numpy.array([
[0.1, 0.2, 0.3, 0.6, 0.9],
[0.45, 0, 0.3, 0.6, 0],
[0.5, 0.6, 0.3, 1, 0.9],
[0.7, 0, 0, 0.6, 0],
[0.5, 0.123, 0, 0.111, 0.9],
])
scores = LexRankSummarizer.power_method(matrix, LexRankSummarizer.epsilon)

assert all(numpy.isfinite(scores))

0 comments on commit 4f06a6c

Please sign in to comment.