Skip to content

52 float cutoff - #152

Open
eriknw wants to merge 1 commit into
python-graphblas:34-nan-weightsfrom
eriknw:52-float-cutoff
Open

eriknw wants to merge 1 commit into
python-graphblas:34-nan-weightsfrom
eriknw:52-float-cutoff

Conversation

@eriknw

@eriknw eriknw commented Dec 3, 2026

Copy link
Copy Markdown
Member

This reads a bound on the levels of a breadth-first walk as NetworkX reads it. NetworkX steps on while cutoff > level, so a cutoff of 2.5 reaches nodes three edges out, and NaN, 0 or a negative cutoff reaches the source alone. The backend passed the bound to range, so a float cutoff raised TypeError where NetworkX answers. On the path 0-1-2-3-4-5, NetworkX's single_source_shortest_path_length from 0 with cutoff=2.5 gives {0: 0, 1: 1, 2: 2, 3: 3}, where the backend raised "'float' object cannot be interpreted as an integer".

  • single_source_shortest_path_length, single_target_shortest_path_length and all_pairs_shortest_path_length take a float, NaN, infinite or negative cutoff, in every batch width of the last.
  • bfs_edges and bfs_successors take a NaN or -inf depth_limit and yield no edges, as NetworkX does. Before, NaN raised TypeError and -inf raised OverflowError. A float limit already rounded up as NetworkX's does.
  • descendants_at_distance gives the layer whose index equals distance, as NetworkX does, so an empty set for 2.5, NaN, inf or a negative distance. Before, a float raised TypeError, and a negative int gave the source.
  • ego_graph follows NetworkX on a float or NaN radius. Without distance, the radius is a cutoff as above, so 2.5 reaches nodes three edges out and NaN reaches only the center; the backend raised TypeError for any float radius. With distance, NetworkX's Dijkstra drops a length greater than the radius, so a NaN radius drops none, where the backend could keep the center alone. Where the edges do not carry distance, each counts 1, so 2.5 reaches nodes two edges out. An int radius past every float no longer raises OverflowError.
  • A bound of another type, such as a str, Decimal, Fraction or numpy bool, is left to NetworkX, which compares it by its own rules. Before, a str raised TypeError with another message, and a Decimal or Fraction radius with distance raised where NetworkX answers. descendants_at_distance still serves any type, since it compares as NetworkX does.
  • A numpy float is read as a Python float, so no comparison casts the number of nodes, or the largest float, down to its type. numpy warns of such a cast, which -W error would turn into an exception NetworkX does not raise.
  • An int bound is read as before, so the walks other names make inside the backend are unchanged.

Stacked on #132.

NetworkX's breadth-first walks step on while `cutoff > level`, so a
cutoff of 2.5 reaches nodes three edges out, and NaN, 0 or a negative
cutoff the source alone. The backend passed the bound to `range`, which
raised TypeError for any float cutoff of
single_source_shortest_path_length, single_target_shortest_path_length
and all_pairs_shortest_path_length, for a float radius of ego_graph,
and for a NaN or -inf depth_limit of bfs_edges and bfs_successors.

descendants_at_distance gives the layer whose index equals `distance`,
so none for 2.5, NaN, inf or a negative distance. The backend raised
TypeError for a float and gave the source for a negative int.

ego_graph with `distance` follows NetworkX's Dijkstra, which drops a
length greater than the radius. A NaN radius drops none, where the
backend could keep the center alone. Where the edges do not carry
`distance`, each counts 1, so 2.5 reaches nodes two edges out. An int
radius past every float no longer raises OverflowError.

A bound of another type, such as a str, Decimal, Fraction or numpy
bool, is left to NetworkX, which compares it by its own rules. A numpy
float is read as a Python float, so no comparison casts a node count or
the largest float down to its type, which numpy would warn of.
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.10983% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.52%. Comparing base (f9c1c17) to head (82ad51f).

Additional details and impacted files
@@                Coverage Diff                 @@
##           34-nan-weights     #152      +/-   ##
==================================================
+ Coverage           93.28%   93.52%   +0.23%     
==================================================
  Files                 183      184       +1     
  Lines               11795    11953     +158     
  Branches             1339     1351      +12     
==================================================
+ Hits                11003    11179     +176     
+ Misses                544      523      -21     
- Partials              248      251       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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