Skip to content

Commit

Permalink
fix(numpy): aliases of builtin types is deprecated as of numpy 1.20 (#…
Browse files Browse the repository at this point in the history
…1052)

* fix(numpy): aliases of builtin types is deprecated as of numpy 1.20
* black
  • Loading branch information
mwtoews authored Feb 11, 2021
1 parent 3ac622a commit 943ace4
Show file tree
Hide file tree
Showing 103 changed files with 557 additions and 563 deletions.
2 changes: 1 addition & 1 deletion autotest/t018_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_tpl_constant():
mfpackage = 'lpf'
partype = 'hk'
parname = 'HK_LAYER_1'
idx = np.empty((nlay, nrow, ncol), dtype=np.bool)
idx = np.empty((nlay, nrow, ncol), dtype=bool)
idx[0] = True
idx[1:] = False

Expand Down
6 changes: 3 additions & 3 deletions autotest/t020_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def analyticalWaterTableSolution(h1, h2, z, R, K, L, x):
h = np.zeros((x.shape[0]), np.float)
h = np.zeros((x.shape[0]), float)
b1 = h1 - z
b2 = h2 - z
h = np.sqrt(b1 ** 2 - (x / L) * (b1 ** 2 - b2 ** 2) + (R * x / K) * (L - x)) + z
Expand Down Expand Up @@ -46,10 +46,10 @@ def test_mfnwt_run():
h2 = 11.

# ibound
ibound = np.ones((nlay, nrow, ncol), dtype=np.int)
ibound = np.ones((nlay, nrow, ncol), dtype=int)

# starting heads
strt = np.zeros((nlay, nrow, ncol), dtype=np.float)
strt = np.zeros((nlay, nrow, ncol), dtype=float)
strt[0, 0, 0] = h1
strt[0, 0, -1] = h2

Expand Down
18 changes: 9 additions & 9 deletions autotest/t031_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ def test_mpsim():
node_data = np.array(
[(3, 12, 12, 'well1', 'skin', -1, 0, 0, 0, 1., 2., 5., 6.2),
(4, 12, 12, 'well1', 'skin', -1, 0, 0, 0, 0.5, 2., 5., 6.2)],
dtype=[('k', np.int), ('i', np.int), ('j', np.int),
('wellid', np.object), ('losstype', np.object),
('pumploc', np.int), ('qlimit', np.int),
('ppflag', np.int), ('pumpcap', np.int),
('rw', np.float), ('rskin', np.float),
('kskin', np.float), ('zpump', np.float)]).view(np.recarray)
dtype=[('k', int), ('i', int), ('j', int),
('wellid', object), ('losstype', object),
('pumploc', int), ('qlimit', int),
('ppflag', int), ('pumpcap', int),
('rw', float), ('rskin', float),
('kskin', float), ('zpump', float)]).view(np.recarray)

stress_period_data = {0: np.array([(0, 'well1', -150000.0)],
dtype=[('per', np.int),
('wellid', np.object),
('qdes', np.float)])}
dtype=[('per', int),
('wellid', object),
('qdes', float)])}
m.remove_package('WEL')
mnw2 = flopy.modflow.ModflowMnw2(model=m, mnwmax=1,
node_data=node_data,
Expand Down
2 changes: 1 addition & 1 deletion autotest/t032_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_polygon_from_ij():
(0, 7, 8, .3, True, 's2')],
dtype=[('k', '<i8'), ('i', '<i8'), ('j', '<i8'),
('stuff', '<f4'), ('stuf', '|b1'),
('stf', np.object)]).view(np.recarray)
('stf', object)]).view(np.recarray)

# vertices for a model cell
geoms = [Polygon(m.modelgrid.get_cell_vertices(i, j)) for i, j in
Expand Down
8 changes: 4 additions & 4 deletions autotest/t039_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def read_zonebudget_file(fname):
vals = [float(i) for i in items[1:-1]]
row = (totim, kstp, kper, record,) + tuple(v for v in vals)
rows.append(row)
dtype_list = [('totim', np.float),
('time_step', np.int),
('stress_period', np.int),
dtype_list = [('totim', float),
('time_step', int),
('stress_period', int),
('name', '<U50')] + [(z, '<f8') for z in zonenames]
dtype = np.dtype(dtype_list)
return np.array(rows, dtype=dtype)
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_compare2zonebudget(rtol=1e-2):
# mflistrecs = mflistbud.get_data(idx=-1, incremental=True)
# print(repr(mflistrecs))
#
# zon = np.ones((3, 40, 20), dtype=np.int)
# zon = np.ones((3, 40, 20), dtype=int)
# cbc_fname = os.path.join(loadpth, 'freyberg.cbc')
# kstp, kper = CellBudgetFile(cbc_fname).get_kstpkper()[-1]
# zb = ZoneBudget(cbc_fname, zon, kstpkper=(kstp, kper))
Expand Down
2 changes: 1 addition & 1 deletion autotest/t040_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_subwt():
vka=[0.4, 0.4, 0.01, 0.4],
sy=0.3, ss=1.0e-6)

# temp_ib = np.ones((ml.nrow,ml.ncol),dtype=np.int)
# temp_ib = np.ones((ml.nrow,ml.ncol),dtype=int)
# np.savetxt('temp_ib.dat',temp_ib,fmt='%1d')
ibound = np.loadtxt(ibound_path)
ibound[ibound == 5] = -1
Expand Down
2 changes: 1 addition & 1 deletion autotest/t041_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_hob_simple():
nlay, nrow, ncol = 1, 11, 11
shape3d = (nlay, nrow, ncol)
shape2d = (nrow, ncol)
ib = np.ones(shape3d, dtype=np.int)
ib = np.ones(shape3d, dtype=int)
ib[0, 0, 0] = -1
m = flopy.modflow.Modflow(modelname=modelname, model_ws=pth,
verbose=False, exe_name=exe_name, )
Expand Down
2 changes: 1 addition & 1 deletion autotest/t047_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_namefile_entries(fpth):
except:
print('could not open...{}'.format(fpth))
return None
dtype = [('ftype', '|S12'), ('unit', np.int),
dtype = [('ftype', '|S12'), ('unit', int),
('filename', '|S128'), ('status', '|S10')]
lines = f.readlines()
data = []
Expand Down
2 changes: 1 addition & 1 deletion autotest/t051_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_mfcbc():
ml = flopy.modflow.Modflow(modelname='t1', model_ws=cpth, verbose=True)
dis = flopy.modflow.ModflowDis(ml, nlay=nlay, nrow=nrow, ncol=ncol, top=0,
botm=[-1., -2., -3.])
ibound = np.ones((nlay, nrow, ncol), dtype=np.int)
ibound = np.ones((nlay, nrow, ncol), dtype=int)
ibound[0, 1, 1] = 0
ibound[0, 0, -1] = -1
bas = flopy.modflow.ModflowBas(ml, ibound=ibound)
Expand Down
2 changes: 1 addition & 1 deletion autotest/t052_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_binary_well():
exe_name=exe_name)
dis = flopy.modflow.ModflowDis(ml, nlay=nlay, nrow=nrow, ncol=ncol, top=0,
botm=[-1., -2., -3.])
ibound = np.ones((nlay, nrow, ncol), dtype=np.int)
ibound = np.ones((nlay, nrow, ncol), dtype=int)
ibound[0, 1, 1] = 0
ibound[0, 0, -1] = -1
bas = flopy.modflow.ModflowBas(ml, ibound=ibound)
Expand Down
2 changes: 1 addition & 1 deletion autotest/t063_test_lgrutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_lgrutil():
delcp = 100.
topp = 100.
botmp = [-100, -200, -300, -400, -500]
idomainp = np.ones((nlayp, nrowp, ncolp), dtype=np.int)
idomainp = np.ones((nlayp, nrowp, ncolp), dtype=int)
idomainp[0:2, 1:4, 1:4] = 0
ncpp = 3
ncppl = [1, 1, 0, 0, 0]
Expand Down
4 changes: 2 additions & 2 deletions autotest/t065_test_gridintersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def get_tri_grid(angrot=0., xyoffset=0., triangle_exe=None):


def get_rect_grid(angrot=0., xyoffset=0., top=None, botm=None):
delc = 10 * np.ones(2, dtype=np.float)
delr = 10 * np.ones(2, dtype=np.float)
delc = 10 * np.ones(2, dtype=float)
delr = 10 * np.ones(2, dtype=float)
sgr = fgrid.StructuredGrid(
delc, delr, top=top, botm=botm, xoff=xyoffset, yoff=xyoffset,
angrot=angrot)
Expand Down
4 changes: 2 additions & 2 deletions autotest/t068_test_ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
def test_mt3d_ssm_with_nodata_in_1st_sp():

nlay, nrow, ncol = 3, 5, 5
perlen = np.zeros((10), dtype=np.float) + 10
perlen = np.zeros((10), dtype=float) + 10
nper = len(perlen)

ibound = np.ones((nlay,nrow,ncol), dtype=np.int)
ibound = np.ones((nlay,nrow,ncol), dtype=int)

botm = np.arange(-1,-4,-1)
top = 0.
Expand Down
4 changes: 2 additions & 2 deletions autotest/t075_ugridtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_unstructured_minimal_grid():
g = UnstructuredGrid(
vertices=vertices, iverts=iverts, xcenters=xcenters, ycenters=ycenters
)
assert np.allclose(g.ncpl, np.array([2], dtype=np.int))
assert np.allclose(g.ncpl, np.array([2], dtype=int))
assert g.nlay == 1
assert g.nnodes == 2
assert g.is_valid
Expand Down Expand Up @@ -117,7 +117,7 @@ def test_unstructured_complete_grid():
top=top,
botm=botm,
)
assert np.allclose(g.ncpl, np.array([1, 1], dtype=np.int))
assert np.allclose(g.ncpl, np.array([1, 1], dtype=int))
assert g.nlay == 2
assert g.nnodes == 2
assert g.is_valid
Expand Down
2 changes: 1 addition & 1 deletion autotest/t505_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ def test021_twri():
)

# build stress_period_data for drn package
conc = np.ones((15, 15), dtype=np.float) * 35.0
conc = np.ones((15, 15), dtype=float) * 35.0
auxdata = {0: [6, conc]}

stress_period_data = []
Expand Down
50 changes: 25 additions & 25 deletions examples/Notebooks/flopy3_MT3DMS_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@
" dis = flopy.modflow.ModflowDis(mf, nlay=nlay, nrow=nrow, ncol=ncol,\n",
" delr=delr, delc=delc, top=0., botm=[0 - delv],\n",
" perlen=perlen)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int)\n",
" ibound[0, 0, 0] = -1\n",
" ibound[0, 0, -1] = -1\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=np.float)\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=float)\n",
" h1 = q * Lx\n",
" strt[0, 0, 0] = h1\n",
" bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt)\n",
Expand All @@ -128,9 +128,9 @@
" mt = flopy.mt3d.Mt3dms(modelname=modelname_mt, model_ws=model_ws, \n",
" exe_name=exe_name_mt, modflowmodel=mf)\n",
" c0 = 1.\n",
" icbund = np.ones((nlay, nrow, ncol), dtype=np.int)\n",
" icbund = np.ones((nlay, nrow, ncol), dtype=int)\n",
" icbund[0, 0, 0] = -1\n",
" sconc = np.zeros((nlay, nrow, ncol), dtype=np.float)\n",
" sconc = np.zeros((nlay, nrow, ncol), dtype=float)\n",
" sconc[0, 0, 0] = c0\n",
" btn = flopy.mt3d.Mt3dBtn(mt, icbund=icbund, prsity=prsity, sconc=sconc)\n",
" dceps = 1.e-5\n",
Expand Down Expand Up @@ -358,10 +358,10 @@
" dis = flopy.modflow.ModflowDis(mf, nlay=nlay, nrow=nrow, ncol=ncol,\n",
" delr=delr, delc=delc, top=0., botm=[0 - delv],\n",
" perlen=perlen_mf)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int)\n",
" ibound[0, 0, 0] = -1\n",
" ibound[0, 0, -1] = -1\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=np.float)\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=float)\n",
" h1 = q * Lx\n",
" strt[0, 0, 0] = h1\n",
" bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt)\n",
Expand Down Expand Up @@ -580,10 +580,10 @@
" dis = flopy.modflow.ModflowDis(mf, nlay=nlay, nrow=nrow, ncol=ncol,\n",
" delr=delr, delc=delc, top=0., botm=[0 - delv],\n",
" perlen=perlen_mf)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int)\n",
" ibound[0, :, 0] = -1\n",
" ibound[0, :, -1] = -1\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=np.float)\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=float)\n",
" h1 = q * Lx\n",
" strt[0, :, 0] = h1\n",
" bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt)\n",
Expand Down Expand Up @@ -761,7 +761,7 @@
" dis = flopy.modflow.ModflowDis(mf, nlay=nlay, nrow=nrow, ncol=ncol,\n",
" delr=delr, delc=delc, top=0., botm=[0 - delv],\n",
" perlen=perlen_mf)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int) * -1\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int) * -1\n",
" ibound[:, 1:nrow - 1, 1:ncol-1] = 1\n",
"\n",
" # set strt as a linear gradient at a 45 degree angle\n",
Expand Down Expand Up @@ -995,7 +995,7 @@
" dis = flopy.modflow.ModflowDis(mf, nlay=nlay, nrow=nrow, ncol=ncol,\n",
" delr=delr, delc=delc, top=0., botm=[0 - delv],\n",
" perlen=perlen_mf)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int) * -1\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int) * -1\n",
" ibound[:, 1:nrow - 1, 1:ncol-1] = 1\n",
" strt = 0.\n",
"\n",
Expand Down Expand Up @@ -1183,7 +1183,7 @@
" dis = flopy.modflow.ModflowDis(mf, nlay=nlay, nrow=nrow, ncol=ncol,\n",
" delr=delr, delc=delc, top=0., botm=[0 - delv],\n",
" nper=2, perlen=perlen_mf)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int) * -1\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int) * -1\n",
" ibound[:, 1:nrow - 1, 1:ncol-1] = 1\n",
" strt = 0.\n",
"\n",
Expand Down Expand Up @@ -1337,10 +1337,10 @@
" delr=delr, delc=delc, top=0., \n",
" botm=[-delv * k for k in range(1, nlay + 1)],\n",
" perlen=perlen_mf)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int)\n",
" ibound[:, :, 0] = -1\n",
" ibound[:, :, -1] = -1\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=np.float)\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=float)\n",
" h1 = q * Lx\n",
" strt[:, :, 0] = h1\n",
" bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt)\n",
Expand Down Expand Up @@ -1487,7 +1487,7 @@
"\n",
" k1 = 5e-4 / 100. * 86400 # m/d\n",
" k2 = 1e-2 / 100. * 86400 # m/d\n",
" hk = k1 * np.ones((nlay, nrow, ncol), dtype=np.float)\n",
" hk = k1 * np.ones((nlay, nrow, ncol), dtype=float)\n",
" hk[11:19, :, 0:24] = k2\n",
" hk[11:19, :, 36:] = k2\n",
" laytyp = 6 * [1] + 21 * [0]\n",
Expand All @@ -1500,10 +1500,10 @@
" botm=[6.75 - delv * k for k in range(1, nlay + 1)],\n",
" perlen=perlen_mf)\n",
" f = open(os.path.join(datadir, 'p08shead.dat'))\n",
" strt = np.empty((nlay * ncol), dtype=np.float)\n",
" strt = np.empty((nlay * ncol), dtype=float)\n",
" strt = read1d(f, strt).reshape((nlay, nrow, ncol))\n",
" f.close()\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int)\n",
" ibound[5:, :, -1] = -1\n",
" ibound[strt < 0] = 0\n",
"\n",
Expand Down Expand Up @@ -1537,7 +1537,7 @@
" nlsink=nlsink, npsink=npsink, percel=percel, \n",
" itrack=itrack, wd=wd)\n",
" dsp = flopy.mt3d.Mt3dDsp(mt, al=al, trpt=trpt, trpv=trpv, dmcoef=dmcoef)\n",
" crch1 = np.zeros((nrow, ncol), dtype=np.float)\n",
" crch1 = np.zeros((nrow, ncol), dtype=float)\n",
" crch1[0, 9:18] = 1.\n",
" cnc0 = [(0, 0, j, 1, -1) for j in range(8, 16)]\n",
" cnc1 = [(0, 0, j, 0., -1) for j in range(8, 16)]\n",
Expand Down Expand Up @@ -1662,18 +1662,18 @@
" laytyp = 0\n",
" k1 = 1.474e-4\n",
" k2 = 1.474e-7\n",
" hk = k1 * np.ones((nlay, nrow, ncol), dtype=np.float)\n",
" hk = k1 * np.ones((nlay, nrow, ncol), dtype=float)\n",
" hk[:, 5:8, 1:8] = k2\n",
"\n",
" modelname_mf = dirname + '_mf'\n",
" mf = flopy.modflow.Modflow(modelname=modelname_mf, model_ws=model_ws, exe_name=exe_name_mf)\n",
" dis = flopy.modflow.ModflowDis(mf, nlay=nlay, nrow=nrow, ncol=ncol,\n",
" delr=delr, delc=delc, top=0., botm=[0 - delv],\n",
" perlen=perlen_mf)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int)\n",
" ibound[0, 0, :] = -1\n",
" ibound[0, -1, :] = -1\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=np.float)\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=float)\n",
" strt[0, 0, :] = 250.\n",
" xc = dis.sr.xcenter\n",
" for j in range(ncol):\n",
Expand Down Expand Up @@ -1898,7 +1898,7 @@
" delr=delr, delc=delc, top=top, \n",
" botm=botm,\n",
" perlen=perlen_mf)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=np.int)\n",
" ibound = np.ones((nlay, nrow, ncol), dtype=int)\n",
"\n",
" # left side\n",
" ibound[:, :, 0] = -1\n",
Expand All @@ -1910,10 +1910,10 @@
" ibound[:, -1, :] = -1\n",
"\n",
" f = open(os.path.join(datadir, 'p10shead.dat'))\n",
" s0 = np.empty((nrow * ncol), dtype=np.float)\n",
" s0 = np.empty((nrow * ncol), dtype=float)\n",
" s0 = read1d(f, s0).reshape((nrow, ncol))\n",
" f.close()\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=np.float)\n",
" strt = np.zeros((nlay, nrow, ncol), dtype=float)\n",
" for k in range(nlay):\n",
" strt[k] = s0\n",
" bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt)\n",
Expand All @@ -1940,10 +1940,10 @@
" mt = flopy.mt3d.Mt3dms(modelname=modelname_mt, model_ws=model_ws, \n",
" exe_name=exe_name_mt, modflowmodel=mf)\n",
" f = open(os.path.join(datadir, 'p10cinit.dat'))\n",
" c0 = np.empty((nrow * ncol), dtype=np.float)\n",
" c0 = np.empty((nrow * ncol), dtype=float)\n",
" c0 = read1d(f, c0).reshape((nrow, ncol))\n",
" f.close()\n",
" sconc = np.zeros((nlay, nrow, ncol), dtype=np.float)\n",
" sconc = np.zeros((nlay, nrow, ncol), dtype=float)\n",
" sconc[1] = 0.2 * c0\n",
" sconc[2] = c0\n",
" obs = [[3 - 1, 11 - 1, 29 - 1],\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/Notebooks/flopy3_PEST.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"mfpackage = 'lpf'\n",
"partype = 'hk'\n",
"parname = 'HK_LAYER_1'\n",
"idx = np.empty((nlay, nrow, ncol), dtype=np.bool)\n",
"idx = np.empty((nlay, nrow, ncol), dtype=bool)\n",
"idx[0] = True\n",
"idx[1:] = False\n",
"\n",
Expand Down Expand Up @@ -674,7 +674,7 @@
"transform = None\n",
"\n",
"# For a recharge index parameter, span['idx'] must be a boolean array or tuple of array indices\n",
"idx = np.empty((nrow, ncol), dtype=np.bool)\n",
"idx = np.empty((nrow, ncol), dtype=bool)\n",
"idx[0:3, 0:3] = True\n",
"span = {'kpers': [1], 'idx': idx}\n",
"p = flopy.pest.Params(mfpackage, partype, parname, startvalue,\n",
Expand Down
Loading

0 comments on commit 943ace4

Please sign in to comment.