Skip to content

Commit

Permalink
fix(intersect): update to raise error only when interface is called i…
Browse files Browse the repository at this point in the history
…mproperly (#1489)

* update intersect warning to raise error only when interface is called improperly
* update VertexGrid and UnstructuredGrid intersect routines
* remove "flopy" from hashFiles call in CI
  • Loading branch information
jlarsen-usgs authored Aug 11, 2022
1 parent 3b8eedb commit 7e690a2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
8 changes: 7 additions & 1 deletion flopy/discretization/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,11 @@ def _warn_intersect(self, module, lineno):
Should be be removed after a couple of releases. Added in 3.3.5
Updated in 3.3.6 to raise an error and exit if intersect interface
is called incorrectly.
Should be removed in flopy 3.3.7
Parameters
----------
module : str
Expand All @@ -698,7 +703,8 @@ def _warn_intersect(self, module, lineno):
"intersect(self, x, y, z=None, local=False, "
"forgive=False) interface instead."
)
warnings.warn_explicit(warning, UserWarning, module, lineno)

raise UserWarning(warning)

def set_coord_info(
self,
Expand Down
7 changes: 4 additions & 3 deletions flopy/discretization/structuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,10 @@ def intersect(self, x, y, z=None, local=False, forgive=False):
The column number
"""
# trigger interface change warning
frame_info = inspect.getframeinfo(inspect.currentframe())
self._warn_intersect(frame_info.filename, frame_info.lineno)
if isinstance(z, bool):
# trigger interface change warning
frame_info = inspect.getframeinfo(inspect.currentframe())
self._warn_intersect(frame_info.filename, frame_info.lineno)

# transform x and y to local coordinates
x, y = super().intersect(x, y, local, forgive)
Expand Down
5 changes: 3 additions & 2 deletions flopy/discretization/unstructuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,9 @@ def intersect(self, x, y, z=None, local=False, forgive=False):
The CELL2D number
"""
frame_info = inspect.getframeinfo(inspect.currentframe())
self._warn_intersect(frame_info.filename, frame_info.lineno)
if isinstance(z, bool):
frame_info = inspect.getframeinfo(inspect.currentframe())
self._warn_intersect(frame_info.filename, frame_info.lineno)

if local:
# transform x and y to real-world coordinates
Expand Down
5 changes: 3 additions & 2 deletions flopy/discretization/vertexgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ def intersect(self, x, y, z=None, local=False, forgive=False):
The CELL2D number
"""
frame_info = inspect.getframeinfo(inspect.currentframe())
self._warn_intersect(frame_info.filename, frame_info.lineno)
if isinstance(z, bool):
frame_info = inspect.getframeinfo(inspect.currentframe())
self._warn_intersect(frame_info.filename, frame_info.lineno)

if local:
# transform x and y to real-world coordinates
Expand Down

0 comments on commit 7e690a2

Please sign in to comment.