Skip to content

Commit 45b5fbc

Browse files
committed
minor: different import in Restriction based on numpy version
Allow Restriction using normalize_axis_index differently based on numpy version to enable using numpy2 whilst still using numpy1 for rtd.
1 parent 24848c4 commit 45b5fbc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pylops/basicoperators/restriction.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55

66
import numpy as np
77
import numpy.ma as np_ma
8-
from numpy.lib.array_utils import normalize_axis_index
8+
9+
# need to check numpy version since normalize_axis_index will be
10+
# soon moved from numpy.core.multiarray to from numpy.lib.array_utils
11+
np_version = np.__version__.split(".")
12+
if int(np_version[0]) < 2:
13+
from numpy.core.multiarray import normalize_axis_index
14+
else:
15+
from numpy.lib.array_utils import normalize_axis_index
916

1017
from pylops import LinearOperator
1118
from pylops.utils._internal import _value_or_sized_to_tuple

0 commit comments

Comments
 (0)