Skip to content

Commit

Permalink
Fix dispatch tests when using numpy 2 (networkx#7506)
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknw authored Jun 19, 2024
1 parent 82529f8 commit 6f951b7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions networkx/utils/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ def _convert_and_call_for_tests(
pytest.xfail(msg)

from collections.abc import Iterable, Iterator, Mapping
from copy import copy
from copy import copy, deepcopy
from io import BufferedReader, BytesIO, StringIO, TextIOWrapper
from itertools import tee
from random import Random
Expand All @@ -1226,10 +1226,10 @@ def _convert_and_call_for_tests(
else:
args1, args2 = zip(
*(
(arg, copy(arg))
if isinstance(
arg, BytesIO | StringIO | Random | Generator | RandomState
)
(arg, deepcopy(arg))
if isinstance(arg, RandomState)
else (arg, copy(arg))
if isinstance(arg, BytesIO | StringIO | Random | Generator)
else tee(arg)
if isinstance(arg, Iterator)
and not isinstance(arg, BufferedReader | TextIOWrapper)
Expand All @@ -1242,10 +1242,10 @@ def _convert_and_call_for_tests(
else:
kwargs1, kwargs2 = zip(
*(
((k, v), (k, copy(v)))
if isinstance(
v, BytesIO | StringIO | Random | Generator | RandomState
)
((k, v), (k, deepcopy(v)))
if isinstance(v, RandomState)
else ((k, v), (k, copy(v)))
if isinstance(v, BytesIO | StringIO | Random | Generator)
else ((k, (teed := tee(v))[0]), (k, teed[1]))
if isinstance(v, Iterator)
and not isinstance(v, BufferedReader | TextIOWrapper)
Expand Down

0 comments on commit 6f951b7

Please sign in to comment.