From 4f06a6cafdf3827ad76fffae1f9e844c32e5a375 Mon Sep 17 00:00:00 2001 From: Aryaz Eghbali Date: Thu, 10 Aug 2023 10:35:54 +0200 Subject: [PATCH] Added test for infinite issue with power_method --- tests/test_summarizers/test_lex_rank.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_summarizers/test_lex_rank.py b/tests/test_summarizers/test_lex_rank.py index 85f99999..1e9c0572 100644 --- a/tests/test_summarizers/test_lex_rank.py +++ b/tests/test_summarizers/test_lex_rank.py @@ -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)) \ No newline at end of file