Skip to content

Fix Spearman correlation of CSR and symmetric input - #37

Merged
rcannood merged 1 commit into
masterfrom
fix/spearman-csr
Oct 27, 2026
Merged

rcannood merged 1 commit into
masterfrom
fix/spearman-csr

Conversation

@rcannood

Copy link
Copy Markdown
Member

spearman_rank_sparse() assumed its input was a general CSC matrix, so calculate_similarity() and calculate_distance() silently returned wrong Spearman correlations for:

Changes:

  • .process_input_matrices() converts all inputs to a dgCMatrix whose columns are the vectors to compare. For a dgRMatrix with margin = 1 it reuses the slots as-is, so no transpose is needed.
  • spearman_rank_sparse() uses the same conversion.
  • Added tests comparing dense, data frame, CSC, CSR, triplet and symmetric inputs for both margins and all methods.

Runtime is unchanged.

@rcannood
rcannood merged commit f8b6a95 into master Oct 27, 2026
6 checks passed
@rcannood
rcannood deleted the fix/spearman-csr branch October 27, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant