Skip to content

Commit

Permalink
Resolve DeprecationWarning by Scipy
Browse files Browse the repository at this point in the history
DeprecationWarning: "getrow" is deprecated and will be removed in v1.14.0; use "X[[0]]"" instead.
  • Loading branch information
juhoinkinen committed Feb 23, 2024
1 parent 71b79b0 commit 888a17e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions annif/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def ndcg_score(y_true: csr_array, y_pred: csr_array, limit: int | None = None) -

scores = np.ones(y_true.shape[0], dtype=np.float32)
for i in range(y_true.shape[0]):
true = y_true.getrow(i)
true = y_true[[i]]
idcg = dcg_score(true, true, limit)
if idcg > 0:
pred = y_pred.getrow(i)
pred = y_pred[[i]]
dcg = dcg_score(true, pred, limit)
scores[i] = dcg / idcg

Expand Down
2 changes: 1 addition & 1 deletion annif/suggestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def filter_suggestion(

data, rows, cols = [], [], []
for row in range(preds.shape[0]):
arow = preds.getrow(row)
arow = preds[[row]]
if limit is not None and limit < len(arow.data):
topk_idx = arow.data.argpartition(-limit)[-limit:]
else:
Expand Down

0 comments on commit 888a17e

Please sign in to comment.