Skip to content

Remove import warnings during to_networkx_graph conversion - #7426

Merged
MridulS merged 1 commit into
networkx:mainfrom
dschult:pass_on_no_import
Apr 19, 2024
Merged

MridulS merged 1 commit into
networkx:mainfrom
dschult:pass_on_no_import

Conversation

@dschult

@dschult dschult commented Apr 19, 2024

Copy link
Copy Markdown
Member

Fixes #7401

This replaces the ImportWarnings with pass in the case when the environment doesn't have pandas or numpy or scipy installed. The idea is that this removes unwanted warnings without causing any surprises (the user could not be using an input that is a pandas/numpy/scipy object type because they library isn't installed).

Further improvements involve changing the order of consideration in to_networkx_graph so that common cases are caught first. That is a separate PR #7424

@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.

As discussed during the community meeting, it doesn't seem possible to hit the warning codepath without already having the corresponding package installed. +1 for this to resolve #7401 and reduce the warnings volume for users who use NX in context where the other scientific libraries are not installed!

@MridulS
MridulS merged commit cd5b8b7 into networkx:main Apr 19, 2024
@jarrodmillman jarrodmillman added this to the 3.4 milestone Apr 19, 2024
cvanelteren pushed a commit to cvanelteren/networkx that referenced this pull request Apr 22, 2024
…7426)

remove import warnings during to_networkx_graph conversion
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.

simple_cycles attempts to import multiple libraries on every call

4 participants