From 1d4282ee82e88af376fc1b5378b7126c469536b2 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Wed, 29 Nov 2023 13:27:55 -0500 Subject: [PATCH] fix(gridgen): only add suffix for generated shpfiles --- flopy/utils/gridgen.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/flopy/utils/gridgen.py b/flopy/utils/gridgen.py index 0e6596c292..9a0ab7730d 100644 --- a/flopy/utils/gridgen.py +++ b/flopy/utils/gridgen.py @@ -406,7 +406,7 @@ def add_refinement_features(self, features, featuretype, level, layers): """ Parameters ---------- - features : str, list, or collection object + features : str or list, or collection object features can be a string containing the name of a shapefile a list of points, lines, or polygons @@ -435,15 +435,17 @@ def add_refinement_features(self, features, featuretype, level, layers): # Create shapefile or set shapefile to feature rfname = f"rf{len(self._rfdict)}" - if isinstance(features, list): + if isinstance(features, (str, os.PathLike)): + shapefile = features + elif isinstance(features, (list, tuple, np.ndarray)): rfname_w_path = os.path.join(self.model_ws, rfname) features_to_shapefile(features, featuretype, rfname_w_path) - shapefile = rfname + shapefile = f"{rfname}.shp" else: - shapefile = features + raise ValueError(f"Features must be path-like or array-like") self._rfdict[rfname] = [shapefile, featuretype, level] - sn = os.path.join(self.model_ws, f"{shapefile}.shp") + sn = os.path.join(self.model_ws, shapefile) assert os.path.isfile(sn), f"Shapefile does not exist: {sn}" for k in layers: