Skip to content

Commit 4e09064

Browse files
authored
refactor(mf6): deprecate mf6 checks (#2357)
Deprecate the MF6 check mechanism. The sense after discussion is that the checks have limited utility at the moment, a few relevance/correctness issues, and see little use. Consider either reworking/replacing them in 3.x in a backwards-compatible way, or removing them and making the .check() methods on simulation model/package base classes no-ops, pending a 4.x rework. Deprecating should help to determine if anyone is relying on them while we investigate how deeply they are woven into the existing framework.
1 parent acc5a5b commit 4e09064

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

flopy/mf6/mfmodel.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,12 @@ def check(self, f=None, verbose=True, level=1):
825825
"""
826826
Check model data for common errors.
827827
828+
Warning
829+
-------
830+
The MF6 check mechanism is deprecated pending reimplementation
831+
in a future release. While the checks API will remain in place
832+
through 3.x, it may be unstable, and will likely change in 4.x.
833+
828834
Parameters
829835
----------
830836
f : str or file handle
@@ -850,6 +856,7 @@ def check(self, f=None, verbose=True, level=1):
850856
>>> m = flopy.modflow.Modflow.load('model.nam')
851857
>>> m.check()
852858
"""
859+
853860
# check instance for model-level check
854861
chk = mf6check(self, f=f, verbose=verbose, level=level)
855862

@@ -1804,6 +1811,12 @@ def set_all_data_external(
18041811
):
18051812
"""Sets the model's list and array data to be stored externally.
18061813
1814+
Warning
1815+
-------
1816+
The MF6 check mechanism is deprecated pending reimplementation
1817+
in a future release. While the checks API will remain in place
1818+
through 3.x, it may be unstable, and will likely change in 4.x.
1819+
18071820
Parameters
18081821
----------
18091822
check_data : bool

flopy/mf6/mfpackage.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,12 @@ def set_all_data_external(
13321332
base_name is external file name's prefix, check_data determines
13331333
if data error checking is enabled during this process.
13341334
1335+
Warning
1336+
-------
1337+
The MF6 check mechanism is deprecated pending reimplementation
1338+
in a future release. While the checks API will remain in place
1339+
through 3.x, it may be unstable, and will likely change in 4.x.
1340+
13351341
Parameters
13361342
----------
13371343
base_name : str
@@ -1344,6 +1350,7 @@ def set_all_data_external(
13441350
Whether file will be stored as binary
13451351
13461352
"""
1353+
13471354
for key, dataset in self.datasets.items():
13481355
lst_data = isinstance(dataset, mfdatalist.MFList) or isinstance(
13491356
dataset, mfdataplist.MFPandasList
@@ -1397,12 +1404,19 @@ def set_all_data_internal(self, check_data=True):
13971404
check_data determines if data error checking is enabled during this
13981405
process.
13991406
1407+
Warning
1408+
-------
1409+
The MF6 check mechanism is deprecated pending reimplementation
1410+
in a future release. While the checks API will remain in place
1411+
through 3.x, it may be unstable, and will likely change in 4.x.
1412+
14001413
Parameters
14011414
----------
14021415
check_data : bool
14031416
Whether to do data error checking.
14041417
14051418
"""
1419+
14061420
for key, dataset in self.datasets.items():
14071421
if (
14081422
isinstance(dataset, mfdataarray.MFArray)
@@ -1644,7 +1658,9 @@ def is_allowed(self):
16441658
return True
16451659

16461660
def is_valid(self):
1647-
"""Returns true of the block is valid."""
1661+
"""
1662+
Returns true if the block is valid.
1663+
"""
16481664
# check data sets
16491665
for dataset in self.datasets.values():
16501666
# Non-optional datasets must be enabled
@@ -2130,7 +2146,16 @@ def _boundnames_active(self):
21302146
return False
21312147

21322148
def check(self, f=None, verbose=True, level=1, checktype=None):
2133-
"""Data check, returns True on success."""
2149+
"""
2150+
Data check, returns True on success.
2151+
2152+
Warning
2153+
-------
2154+
The MF6 check mechanism is deprecated pending reimplementation
2155+
in a future release. While the checks API will remain in place
2156+
through 3.x, it may be unstable, and will likely change in 4.x.
2157+
"""
2158+
21342159
if checktype is None:
21352160
checktype = mf6check
21362161
# do general checks

flopy/mf6/mfsimbase.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,12 @@ def check(
10941094
"""
10951095
Check model data for common errors.
10961096
1097+
Warning
1098+
-------
1099+
The MF6 check mechanism is deprecated pending reimplementation
1100+
in a future release. While the checks API will remain in place
1101+
through 3.x, it may be unstable, and will likely change in 4.x.
1102+
10971103
Parameters
10981104
----------
10991105
f : str or PathLike, optional
@@ -1120,6 +1126,7 @@ def check(
11201126
>>> m = flopy.modflow.Modflow.load('model.nam')
11211127
>>> m.check()
11221128
"""
1129+
11231130
# check instance for simulation-level check
11241131
chk_list = []
11251132

@@ -1586,6 +1593,12 @@ def set_all_data_external(
15861593
):
15871594
"""Sets the simulation's list and array data to be stored externally.
15881595
1596+
Warning
1597+
-------
1598+
The MF6 check mechanism is deprecated pending reimplementation
1599+
in a future release. While the checks API will remain in place
1600+
through 3.x, it may be unstable, and will likely change in 4.x.
1601+
15891602
Parameters
15901603
----------
15911604
check_data: bool
@@ -1600,6 +1613,7 @@ def set_all_data_external(
16001613
binary: bool
16011614
Whether file will be stored as binary
16021615
"""
1616+
16031617
# copy any files whose paths have changed
16041618
self.simulation_data.mfpath.copy_files()
16051619
# set data external for all packages in all models
@@ -1636,6 +1650,7 @@ def set_all_data_external(
16361650

16371651
def set_all_data_internal(self, check_data=True):
16381652
# set data external for all packages in all models
1653+
16391654
for model in self._models.values():
16401655
model.set_all_data_internal(check_data)
16411656
# set data external for solution packages

flopy/utils/check.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
2-
from pathlib import Path
32
from typing import Optional, Union
3+
from warnings import warn
44

55
import numpy as np
66
from numpy.lib import recfunctions
@@ -799,6 +799,15 @@ def fields_view(arr, fields):
799799

800800

801801
class mf6check(check):
802+
"""
803+
Check an mf6 package for common errors.
804+
805+
.. deprecated:: 3.9
806+
The MF6 check mechanism is deprecated pending reimplementation
807+
in a future release. While the checks API will remain in place
808+
through 3.x, it may be unstable, and will likely change in 4.x.
809+
"""
810+
802811
def __init__(
803812
self,
804813
package,
@@ -807,6 +816,12 @@ def __init__(
807816
level=1,
808817
property_threshold_values={},
809818
):
819+
warn(
820+
"The MF6 check mechanism is deprecated pending reimplementation "
821+
"in a future release. While the checks API will remain in place "
822+
"through 3.x, it may be unstable, and will likely change in 4.x.",
823+
category=DeprecationWarning,
824+
)
810825
super().__init__(package, f, verbose, level, property_threshold_values)
811826
if hasattr(package, "model_or_sim"):
812827
self.model = package.model_or_sim

0 commit comments

Comments
 (0)