From d7edbc61febda718254a33bbfc14e39ed8059173 Mon Sep 17 00:00:00 2001 From: jlarsen-usgs Date: Tue, 12 May 2026 13:46:38 -0700 Subject: [PATCH 1/3] update(intersect): update days calculation to fix dropped precision * replace timedelta.days with timedelta.total_seconds() / 86400 --- flopy/discretization/modeltime.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/flopy/discretization/modeltime.py b/flopy/discretization/modeltime.py index f072d11070..2e92453031 100644 --- a/flopy/discretization/modeltime.py +++ b/flopy/discretization/modeltime.py @@ -618,15 +618,14 @@ def intersect( "objects, set time units or use totim for intersection" ) - elif self.time_units == "days": - totim = timedelta.days - - elif self.time_units in {"hours", "minutes", "seconds"}: + elif self.time_units in {"days", "hours", "minutes", "seconds"}: totim = timedelta.total_seconds() if self.time_units == "minutes": totim /= 60 elif self.time_units == "hours": totim /= 3600 + elif self.time_units == "days": + totim /= 86400. else: # years condition @@ -647,7 +646,7 @@ def intersect( ) timedelta = datetime_obj - dt_iyear - days = timedelta.days + days = timedelta.total_seconds() / 86400. yr_frac = days / ndays totim += yr_frac From 8d2811b25f59946e4a659f9581b05eff4f1054d0 Mon Sep 17 00:00:00 2001 From: jlarsen-usgs Date: Tue, 12 May 2026 14:36:36 -0700 Subject: [PATCH 2/3] linting --- flopy/discretization/modeltime.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flopy/discretization/modeltime.py b/flopy/discretization/modeltime.py index 2e92453031..2056c0110f 100644 --- a/flopy/discretization/modeltime.py +++ b/flopy/discretization/modeltime.py @@ -625,7 +625,7 @@ def intersect( elif self.time_units == "hours": totim /= 3600 elif self.time_units == "days": - totim /= 86400. + totim /= 86400.0 else: # years condition @@ -646,7 +646,7 @@ def intersect( ) timedelta = datetime_obj - dt_iyear - days = timedelta.total_seconds() / 86400. + days = timedelta.total_seconds() / 86400.0 yr_frac = days / ndays totim += yr_frac From 523991459a32ebc7d4dbd26208e4ff731588cc89 Mon Sep 17 00:00:00 2001 From: jlarsen-usgs Date: Tue, 12 May 2026 15:57:06 -0700 Subject: [PATCH 3/3] update test_modeltime.py, remove note in hfb_util.py --- autotest/test_modeltime.py | 4 ++-- flopy/utils/hfb_util.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/autotest/test_modeltime.py b/autotest/test_modeltime.py index 966d21d6be..fbdb54e335 100644 --- a/autotest/test_modeltime.py +++ b/autotest/test_modeltime.py @@ -270,7 +270,7 @@ def test_mf2005_modeltime(): raise AssertionError("start_datetime improperly stored") result = modeltime.intersect("3/06/2024 23:59:59") - if result != (2, 0): + if result != (2, 1): raise AssertionError("ModelTime intersect not working correctly") @@ -317,7 +317,7 @@ def test_mf6_modeltime(): raise AssertionError("start_datetime improperly stored") result = modeltime.intersect("3/06/2024 23:59:59") - if result != (2, 0): + if result != (2, 1): raise AssertionError("ModelTime intersect not working correctly") diff --git a/flopy/utils/hfb_util.py b/flopy/utils/hfb_util.py index 97d6c83983..036d33c87d 100644 --- a/flopy/utils/hfb_util.py +++ b/flopy/utils/hfb_util.py @@ -232,7 +232,6 @@ def make_hfb_array(modelgrid, geom): for record in result: node = record.cellid ixshp = record.ixshapes - # todo: numpy array this and Transpose coords = np.array(ixshp.coords.xy).T x0, y0 = coords[0, 0], coords[0, 1] x1, y1 = coords[-1, 0], coords[-1, 1]