Skip to content

Commit

Permalink
MAINT: Enforce pre-2.0-style reprs for numpy scalars.
Browse files Browse the repository at this point in the history
This will silence doctest errors related to changes in the NumPy
scalar reprs per NEP 51.
The goal is to aid in transitioning to new numpy scalars with the
minimum possible churn in code.
In general, the transition plan would be something like:
 - Leave this PR in place to suppress doctest failures from
   changes in numpy scalar reprs. This way, all doctests can still
   be run.
 - Update / modify code and/or tests as needed to limit/replace the
  use of numpy scalars where appropriate.
 - When NumPy 2.0 becomes the minimum supported version for NetworkX,
   These 5 lines can be removed and any remaining issues related to
   scalar representations fixed (hopefully there aren't many left...
   see previous bullet).
  • Loading branch information
rossbar committed Aug 17, 2023
1 parent 9715d29 commit 30d6995
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions networkx/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ def set_warnings():
@pytest.fixture(autouse=True)
def add_nx(doctest_namespace):
doctest_namespace["nx"] = networkx
try:
import numpy as np

np.set_printoptions(legacy="1.21")
except ImportError:
pass


# What dependencies are installed?
Expand Down

0 comments on commit 30d6995

Please sign in to comment.