diff --git a/README.md b/README.md index 493766e967..21f9b12354 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ For general modeling issues, please consult a modeling forum, such as the [MODFL Installation ----------------------------------------------- -FloPy requires **Python** 3.5 (or higher) and **NumPy** 1.9 (or higher). Dependencies for optional FloPy methods are summarized [here](docs/flopy_method_dependencies.md). +FloPy requires **Python** 3.7 (or higher) and **NumPy** 1.15 (or higher). Dependencies for optional FloPy methods are summarized [here](docs/flopy_method_dependencies.md). To install FloPy type: diff --git a/flopy/discretization/structuredgrid.py b/flopy/discretization/structuredgrid.py index 389b2938c9..7aed76ee2a 100644 --- a/flopy/discretization/structuredgrid.py +++ b/flopy/discretization/structuredgrid.py @@ -4,34 +4,6 @@ import numpy as np from .grid import Grid, CachedData -try: - from numpy.lib import NumpyVersion - - numpy115 = NumpyVersion(np.__version__) >= "1.15.0" -except ImportError: - numpy115 = False - -if not numpy115: - - def flip_numpy115(m, axis=None): - """Provide same behavior for np.flip since numpy 1.15.0.""" - import numpy.core.numeric as _nx - from numpy.core.numeric import asarray - - if not hasattr(m, "ndim"): - m = asarray(m) - if axis is None: - indexer = (np.s_[::-1],) * m.ndim - else: - axis = _nx.normalize_axis_tuple(axis, m.ndim) - indexer = [np.s_[:]] * m.ndim - for ax in axis: - indexer[ax] = np.s_[::-1] - indexer = tuple(indexer) - return m[indexer] - - np.flip = flip_numpy115 - def array_at_verts_basic2d(a): """ diff --git a/flopy/modflow/mfsfr2.py b/flopy/modflow/mfsfr2.py index 36cdc2dfcf..a4f0cc3b8d 100644 --- a/flopy/modflow/mfsfr2.py +++ b/flopy/modflow/mfsfr2.py @@ -18,19 +18,6 @@ except: pd = False -try: - from numpy.lib import NumpyVersion - - numpy114 = NumpyVersion(np.__version__) >= "1.14.0" -except ImportError: - numpy114 = False -if numpy114: - # use numpy's floating-point formatter (Dragon4) - default_float_format = "{!s}" -else: - # single-precision floats have ~7.2 decimal digits - default_float_format = "{:.8g}" - class ModflowSfr2(Package): """ @@ -3333,7 +3320,7 @@ def _get_item2_names(nstrm, reachinput, isfropt, structured=False): return names -def _fmt_string_list(array, float_format=default_float_format): +def _fmt_string_list(array, float_format="{!s}"): fmt_list = [] for name in array.dtype.names: vtype = array.dtype[name].str[1].lower() @@ -3358,13 +3345,11 @@ def _fmt_string_list(array, float_format=default_float_format): return fmt_list -def _fmt_string(array, float_format=default_float_format): +def _fmt_string(array, float_format="{!s}"): return " ".join(_fmt_string_list(array, float_format)) -def _print_rec_array( - array, cols=None, delimiter=" ", float_format=default_float_format -): +def _print_rec_array(array, cols=None, delimiter=" ", float_format="{!s}"): """ Print out a numpy record array to string, with column names. diff --git a/flopy/utils/modpathfile.py b/flopy/utils/modpathfile.py index 23cd73630b..5a86077b88 100644 --- a/flopy/utils/modpathfile.py +++ b/flopy/utils/modpathfile.py @@ -1028,53 +1028,8 @@ def _add_particleid(self): shaped = self._data.shape[0] pids = np.arange(1, shaped + 1, 1, dtype=np.int32) - # determine numpy version - npv = np.__version__ - v = [int(s) for s in npv.split(".")] - if self.verbose: - print("numpy version {}".format(npv)) - # for numpy version 1.14 and higher - if v[0] > 1 or (v[0] == 1 and v[1] > 13): - self._data = append_fields(self._data, "particleid", pids) - # numpy versions prior to 1.14 - else: - if self.verbose: - print(self._data.dtype) - - # convert pids to structured array - pids = np.array( - pids, dtype=np.dtype([("particleid", np.int32)]) - ) - - # create new dtype - dtype = self._get_mp35_dtype(add_id=True) - if self.verbose: - print(dtype) - - # create new array with new dtype and fill with available data - data = np.zeros(shaped, dtype=dtype) - if self.verbose: - print("new data shape {}".format(data.shape)) - print("\nFilling new structured data array") - - # add particle id to new array - if self.verbose: - print( - "writing particleid (pids) to new " - "structured data array" - ) - data["particleid"] = pids["particleid"] - - # add remaining data to the new array - if self.verbose: - msg = "writing remaining data to new structured data array" - print(msg) - for name in self._data.dtype.names: - data[name] = self._data[name] - if self.verbose: - print("replacing data with copy of new data array") - self._data = data.copy() + self._data = append_fields(self._data, "particleid", pids) return def get_maxid(self): diff --git a/flopy/utils/util_list.py b/flopy/utils/util_list.py index cc2d24abf7..e559e1bd6f 100644 --- a/flopy/utils/util_list.py +++ b/flopy/utils/util_list.py @@ -13,13 +13,6 @@ from ..datbase import DataInterface, DataListInterface, DataType from ..utils.recarray_utils import create_empty_recarray -try: - from numpy.lib import NumpyVersion - - numpy114 = NumpyVersion(np.__version__) >= "1.14.0" -except ImportError: - numpy114 = False - class MfList(DataInterface, DataListInterface): """ @@ -279,11 +272,7 @@ def fmt_string(self): fmts.append("%10d") elif vtype == "f": if use_free: - if numpy114: - # Use numpy's floating-point formatter (Dragon4) - fmts.append("%15s") - else: - fmts.append("%15.7E") + fmts.append("%15s") else: fmts.append("%10G") elif vtype == "o": @@ -745,7 +734,7 @@ def write_transient(self, f, single_per=None, forceInternal=False): if kper_vtype == np.recarray: name = f.name - if self.__binary or not numpy114: + if self.__binary: f.close() # switch file append mode to binary with open(name, "ab+") as f: