Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions flopy/utils/gridintersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,54 @@
import warnings
from distutils.version import LooseVersion

NUMPY_GE_121 = str(np.__version__) >= LooseVersion("1.21")

try:
import shapely

SHAPELY_GE_20 = str(shapely.__version__) >= LooseVersion("2.0")
except:
SHAPELY_LT_18 = str(shapely.__version__) < LooseVersion("1.8")
except ImportError:
shapely = None
SHAPELY_GE_20 = False
SHAPELY_LT_18 = False

try:
from shapely.errors import ShapelyDeprecationWarning as shapely_warning
except:
except ImportError:
shapely_warning = None

if shapely_warning is not None and not SHAPELY_GE_20:

@contextlib.contextmanager
def ignore_shapely_warnings_for_object_array():
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=shapely_warning)
warnings.filterwarnings(
"ignore",
"Iteration|The array interface|__len__",
shapely_warning,
)
if NUMPY_GE_121:
# warning from numpy for existing Shapely releases (this is
# fixed with Shapely 1.8)
warnings.filterwarnings(
"ignore",
"An exception was ignored while fetching",
DeprecationWarning,
)
yield


elif SHAPELY_LT_18 and NUMPY_GE_121:

@contextlib.contextmanager
def ignore_shapely_warnings_for_object_array():
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
"An exception was ignored while fetching",
DeprecationWarning,
)
yield


Expand Down