diff --git a/flopy/discretization/structuredgrid.py b/flopy/discretization/structuredgrid.py index 0391ca9c5e..5608034a45 100644 --- a/flopy/discretization/structuredgrid.py +++ b/flopy/discretization/structuredgrid.py @@ -2,6 +2,34 @@ import numpy as np from .grid import Grid, CachedData +try: + from numpy.lib import NumpyVersion + + numpy115 = NumpyVersion(np.__version__) >= "1.15.0" +except ImportError: + numpy115 = False + +if not numpy115: + + def flip_numpy115(m, axis=None): + """Provide same behavior for np.flip since numpy 1.15.0.""" + import numpy.core.numeric as _nx + from numpy.core.numeric import asarray + + if not hasattr(m, "ndim"): + m = asarray(m) + if axis is None: + indexer = (np.s_[::-1],) * m.ndim + else: + axis = _nx.normalize_axis_tuple(axis, m.ndim) + indexer = [np.s_[:]] * m.ndim + for ax in axis: + indexer[ax] = np.s_[::-1] + indexer = tuple(indexer) + return m[indexer] + + np.flip = flip_numpy115 + def array_at_verts_basic2d(a): """