Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions flopy/discretization/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def __init__(

self._iverts = None
self._verts = None
self._laycbd = None

###################################
# access to basic grid properties
Expand Down Expand Up @@ -285,6 +286,13 @@ def botm(self):
def top_botm(self):
raise NotImplementedError("must define top_botm in child class")

@property
def laycbd(self):
if self._laycbd is None:
return None
else:
return self._laycbd

@property
def thick(self):
"""
Expand Down
6 changes: 3 additions & 3 deletions flopy/discretization/structuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def __init__(
else:
self.__nlay = nlay
if laycbd is not None:
self.__laycbd = laycbd
self._laycbd = laycbd
else:
self.__laycbd = np.zeros(self.__nlay or (), dtype=int)
self._laycbd = np.zeros(self.__nlay or (), dtype=int)

####################
# Properties
Expand Down Expand Up @@ -464,7 +464,7 @@ def xyzcellcenters(self):
z = np.empty((self.__nlay, self.__nrow, self.__ncol))
z[0, :, :] = (self._top[:, :] + self._botm[0, :, :]) / 2.0
ibs = np.arange(self.__nlay)
quasi3d = [cbd != 0 for cbd in self.__laycbd]
quasi3d = [cbd != 0 for cbd in self._laycbd]
if np.any(quasi3d):
ibs[1:] = ibs[1:] + np.cumsum(quasi3d)[: self.__nlay - 1]
for l, ib in enumerate(ibs[1:], 1):
Expand Down
2 changes: 1 addition & 1 deletion flopy/discretization/unstructuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def verts(self):
if self._vertices is None:
return self._vertices
else:
return np.array([t[1:] for t in self._vertices], dtype=float)
return np.array([list(t)[1:] for t in self._vertices], dtype=float)

@property
def ia(self):
Expand Down
6 changes: 3 additions & 3 deletions flopy/discretization/vertexgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

try:
from matplotlib.path import Path
except ImportError:
except (ImportError, RuntimeError):
Path = None

from .grid import Grid, CachedData
Expand Down Expand Up @@ -128,11 +128,11 @@ def nvert(self):

@property
def iverts(self):
return [[t[0]] + t[4:] for t in self._cell2d]
return [[t[0]] + list(t)[4:] for t in self._cell2d]

@property
def verts(self):
return np.array([t[1:] for t in self._vertices], dtype=float)
return np.array([list(t)[1:] for t in self._vertices], dtype=float)

@property
def shape(self):
Expand Down
2 changes: 1 addition & 1 deletion flopy/plot/crosssection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import matplotlib.pyplot as plt
import matplotlib.colors
from matplotlib.patches import Polygon
except (ImportError, ModuleNotFoundError):
except (ImportError, ModuleNotFoundError, RuntimeError):
plt = None

from flopy.plot import plotutil
Expand Down
2 changes: 1 addition & 1 deletion flopy/plot/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import matplotlib.colors
from matplotlib.collections import PathCollection, LineCollection
from matplotlib.path import Path
except (ImportError, ModuleNotFoundError):
except (ImportError, ModuleNotFoundError, RuntimeError):
plt = None

from . import plotutil
Expand Down
2 changes: 1 addition & 1 deletion flopy/plot/plotutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

try:
import matplotlib.pyplot as plt
except ImportError:
except (ImportError, RuntimeError):
plt = None

warnings.simplefilter("ignore", RuntimeWarning)
Expand Down
2 changes: 1 addition & 1 deletion flopy/plot/styles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
try:
import matplotlib.pyplot as plt
import matplotlib as mpl
except (ImportError, ModuleNotFoundError):
except (ImportError, ModuleNotFoundError, RuntimeError):
plt = None

import os
Expand Down
2 changes: 1 addition & 1 deletion flopy/utils/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def get_active(self, include_cbd=False):
"""
mg = self.model.modelgrid
if mg.grid_type == "structured":
nlaycbd = mg._StructuredGrid__laycbd.sum() if include_cbd else 0
nlaycbd = mg.laycbd.sum() if include_cbd else 0
inds = (mg.nlay + nlaycbd, mg.nrow, mg.ncol)
elif mg.grid_type == "vertex":
inds = (mg.nlay, mg.ncpl)
Expand Down
2 changes: 1 addition & 1 deletion flopy/utils/gridintersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

try:
import matplotlib.pyplot as plt
except ImportError:
except (ImportError, RuntimeError):
plt = None

from .geometry import transform
Expand Down
3 changes: 2 additions & 1 deletion flopy/utils/voronoi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Voronoi
from .cvfdutil import get_disv_gridprops

Expand Down Expand Up @@ -282,6 +281,8 @@ def plot(self, ax=None, plot_title=True, **kwargs):
axes that contains the voronoi model grid

"""
import matplotlib.pyplot as plt

if ax is None:
ax = plt.subplot(1, 1, 1, aspect="equal")
pc = self.get_patch_collection(ax, **kwargs)
Expand Down