Skip to content

Commit

Permalink
fix: restore Python 3.5 compatibility (ModuleNotFoundError -> ImportE…
Browse files Browse the repository at this point in the history
…rror) (#933)
  • Loading branch information
mwtoews authored Jul 9, 2020
1 parent f437e8b commit d16411d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion flopy/export/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ def export_contourf(filename, contours, fieldname='level', epsg=None,

try:
from shapely import geometry
except (ImportError, ModuleNotFoundError):
except ImportError:
raise ImportError('export_contourf requires python shapely package')

from ..utils.geometry import Polygon
Expand Down
16 changes: 8 additions & 8 deletions flopy/utils/gridintersect.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
try:
import matplotlib.pyplot as plt
except ModuleNotFoundError:
except ImportError:
plt = None

from .geometry import transform
Expand All @@ -13,7 +13,7 @@
from shapely.affinity import translate, rotate
from shapely.prepared import prep
shply = True
except ModuleNotFoundError:
except ImportError:
shply = False


Expand Down Expand Up @@ -107,7 +107,7 @@ def __init__(self, mfgrid, method=None, rtree=True):
msg = ("Shapely is needed for grid intersect operations! "
"Please install shapely if you need to use grid intersect "
"functionality.")
raise ModuleNotFoundError(msg)
raise ImportError(msg)

self.mfgrid = mfgrid
if method is None:
Expand Down Expand Up @@ -1240,16 +1240,16 @@ def plot_polygon(rec, ax=None, **kwargs):
"""
try:
from descartes import PolygonPatch
except ModuleNotFoundError:
except ImportError:
msg = 'descartes package needed for plotting polygons'
if plt is None:
msg = 'matplotlib and descartes packages needed for ' + \
'plotting polygons'
raise ModuleNotFoundError(msg)
raise ImportError(msg)

if plt is None:
msg = 'matplotlib package needed for plotting polygons'
raise ModuleNotFoundError(msg)
raise ImportError(msg)

if ax is None:
_, ax = plt.subplots()
Expand Down Expand Up @@ -1288,7 +1288,7 @@ def plot_linestring(rec, ax=None, **kwargs):
"""
if plt is None:
msg = 'matplotlib package needed for plotting polygons'
raise ModuleNotFoundError(msg)
raise ImportError(msg)

if ax is None:
_, ax = plt.subplots()
Expand Down Expand Up @@ -1333,7 +1333,7 @@ def plot_point(rec, ax=None, **kwargs):
"""
if plt is None:
msg = 'matplotlib package needed for plotting polygons'
raise ModuleNotFoundError(msg)
raise ImportError(msg)

if ax is None:
_, ax = plt.subplots()
Expand Down

0 comments on commit d16411d

Please sign in to comment.