Repository navigation
Conversation
eriknw
force-pushed
the
41-networkx-error-without-scipy
branch
from
October 19, 2026 07:55
571d77d to
f53eab1
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 29-io-config-coverage #644 +/- ##
=========================================================
- Coverage 98.78% 98.02% -0.77%
=========================================================
Files 105 105
Lines 30373 30355 -18
Branches 3534 3536 +2
=========================================================
- Hits 30004 29755 -249
- Misses 244 361 +117
- Partials 125 239 +114 🚀 New features to boost your workflow:
|
eriknw
force-pushed
the
41-networkx-error-without-scipy
branch
3 times, most recently
from
October 21, 2026 08:38
6113fd6 to
bbd4362
Compare
eriknw
force-pushed
the
41-networkx-error-without-scipy
branch
from
October 28, 2026 04:29
bbd4362 to
d507287
Compare
eriknw
force-pushed
the
41-networkx-error-without-scipy
branch
from
October 28, 2026 13:21
d507287 to
1d20b11
Compare
from_networkx builds its coo arrays directly, but for weights a matrix cannot hold (strings, objects, ints beyond 64 bits, uniform-length sequences) it still called nx.to_scipy_sparse_array, only so that scipy would raise. That made the error depend on scipy: ValueError since 1.15, a TypeError or a NetworkXError blaming the sparse format before (which abf6f62 restated as ValueError), and, with scipy not installed, a ModuleNotFoundError from inside networkx. The fallback never returned a matrix, so from_networkx otherwise had no use for scipy at all. Raise the ValueError directly, naming the attribute and what it gave: edge weights must be bool, int (at most 64 bits), float or complex scalars; attribute 'weight' gives dtype <U1 and drop _from_networkx_via_scipy. The docstring gains a Raises section for this and for the NetworkXError cases it shares with nx.to_scipy_sparse_array. Only the message changes for callers with scipy; callers without it get the ValueError instead of an ImportError. The rejection tests are folded into one that covers each kind of weight on all four graph classes, with scipy importable and with it blocked through sys.modules, so they no longer skip without scipy. The multigraph scipy-free test blocks scipy the same way instead of monkeypatching the removed fallback.
eriknw
force-pushed
the
41-networkx-error-without-scipy
branch
from
October 29, 2026 02:01
1d20b11 to
5f883b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For strings, objects, ints beyond 64 bits and uniform-length sequences,
from_networkxstill callednx.to_scipy_sparse_arrayonly so that scipy wouldraise. The error therefore depended on scipy: ValueError since 1.15, TypeError
or NetworkXError before, and ModuleNotFoundError from inside networkx with
scipy not installed. The fallback never returned a matrix, so it is removed and
the ValueError is raised directly:
from_networkxno longer touches scipy at all. The docstring gains a Raisessection. Tests: four weight kinds on four graph classes, with scipy importable
and with it blocked through
sys.modules(a small_block_scipy(monkeypatch)helper), replacing the tests that skipped without scipy, including the two
added by the PR below that exercised the removed fallback. Only the message
changes when scipy is installed.