Skip to content

Fix random_degree_sequence_graph when input is an iterator - #7979

Merged
MridulS merged 1 commit into
networkx:mainfrom
eriknw:fix_random_degree_sequence_graph_iterator
Apr 17, 2025
Merged

MridulS merged 1 commit into
networkx:mainfrom
eriknw:fix_random_degree_sequence_graph_iterator

Conversation

@eriknw

@eriknw eriknw commented Apr 16, 2025

Copy link
Copy Markdown
Contributor

The test test_random_degree_sequence_large was passing due to unintended behavior: the two generators d1 and d2 were both empty! So, I fixed that test (G2 was empty in that test), and added a regression test for the fix so random_degree_sequence_graph works as intended when the degree sequence is an iterator. The docstring says the degree sequence should be a list, which is probably recommended, but we should probably handle iterators and iterables in unsurprising ways too.

@rossbar, I encountered this when trying to unblock #7902.

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thanks @eriknw !

@MridulS
MridulS merged commit 3639ef4 into networkx:main Apr 17, 2025
@jarrodmillman jarrodmillman added this to the 3.5 milestone May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants