Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
28 changes: 0 additions & 28 deletions flopy/discretization/structuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
21 changes: 3 additions & 18 deletions flopy/modflow/mfsfr2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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()
Expand All @@ -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.

Expand Down
47 changes: 1 addition & 46 deletions flopy/utils/modpathfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 2 additions & 13 deletions flopy/utils/util_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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:
Expand Down