Skip to content

Fix scipy FutureWarning in laplacian_matrix#685

Open
leotrs wants to merge 2 commits intomainfrom
fix-scipy-diags-warning
Open

Fix scipy FutureWarning in laplacian_matrix#685
leotrs wants to merge 2 commits intomainfrom
fix-scipy-diags-warning

Conversation

@leotrs
Copy link
Collaborator

@leotrs leotrs commented Feb 27, 2026

Summary

  • Fix FutureWarning from scipy's diags_array about implicit int-to-float dtype casting
  • Explicitly cast degree vectors to float before passing to diags_array in laplacian_matrix.py
  • Ensure edge weights are always float (not int) in weighted laplacian computation

Context

scipy >= 1.14 warns when diags_array receives integer data without an explicit dtype, since a future version will preserve integer dtype instead of casting to float. Our laplacian code relies on float arithmetic, so we now cast explicitly.

Test plan

  • All 393 tests pass
  • No more FutureWarning from scipy diags_array

🤖 Generated with Claude Code

scipy's diags_array now warns (FutureWarning) when int64 input is
silently cast to float64 output, and will change this behavior in a
future release. This would silently alter numerical results.

Ensure degree and weight arrays are explicitly float before passing
to diags_array in both laplacian() and normalized_hypergraph_laplacian().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.59%. Comparing base (cc32ef6) to head (d8fbf76).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #685   +/-   ##
=======================================
  Coverage   93.59%   93.59%           
=======================================
  Files          66       66           
  Lines        5123     5124    +1     
=======================================
+ Hits         4795     4796    +1     
  Misses        328      328           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Pandas now uses dtype='str' instead of dtype='object' for string Index
columns. Update the expected doctest output in IDStat.name accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@leotrs leotrs force-pushed the fix-scipy-diags-warning branch from d5c662d to d8fbf76 Compare February 27, 2026 15:04
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