Spaces:
Sleeping
Sleeping
| from __future__ import annotations | |
| import numpy as np | |
| from app.analysis.summaries import ( | |
| compute_incoming_importance, | |
| compute_outgoing_importance, | |
| compute_top_edges, | |
| ) | |
| def test_summary_metrics_follow_upper_triangle() -> None: | |
| matrix = np.array( | |
| [ | |
| [0.0, 0.0, 0.0], | |
| [1.0, 0.0, 0.0], | |
| [2.0, 3.0, 0.0], | |
| ], | |
| dtype=np.float32, | |
| ) | |
| outgoing = compute_outgoing_importance(matrix) | |
| incoming = compute_incoming_importance(matrix) | |
| top_edges = compute_top_edges(matrix, top_k=2) | |
| assert outgoing == [1.5, 3.0, 0.0] | |
| assert incoming == [0.0, 1.0, 2.5] | |
| assert [(edge.source_sentence_idx, edge.target_sentence_idx) for edge in top_edges] == [ | |
| (1, 2), | |
| (0, 2), | |
| ] | |