From d011d09d28fa4d26ff40fafc96bab78a036930cd Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Wed, 30 Oct 2019 08:51:08 +1300 Subject: [PATCH] fix(flake8 code W605): invalid escape sequence '\s' (or similar) Some of these fixes were to paths to directories in docstring examples, which were updated to somewhat work with the current structure of directories and file names. --- flopy/modflow/mfsfr2.py | 8 ++++---- flopy/mt3d/mtlkt.py | 8 ++++---- flopy/mt3d/mtsft.py | 25 ++++++++++++------------- flopy/mt3d/mtuzt.py | 8 ++++---- flopy/utils/check.py | 4 ++-- flopy/utils/flopy_io.py | 4 ++-- flopy/utils/mtlistfile.py | 4 ++-- 7 files changed, 30 insertions(+), 31 deletions(-) diff --git a/flopy/modflow/mfsfr2.py b/flopy/modflow/mfsfr2.py index cab6be1e2e..ac43242eda 100644 --- a/flopy/modflow/mfsfr2.py +++ b/flopy/modflow/mfsfr2.py @@ -2829,9 +2829,9 @@ def _fmt_string(array, float_format='{!s}'): elif vtype == 'o': fmt_string += '{} ' elif vtype == 's': - raise Exception("MfList error: '\str\' type found it dtype." + \ + raise Exception("MfList error: 'str' type found in dtype." + \ " This gives unpredictable results when " + \ - "recarray to file - change to \'object\' type") + "recarray to file - change to 'object' type") else: raise Exception("MfList.fmt_string error: unknown vtype " + \ "in dtype:" + vtype) @@ -2851,9 +2851,9 @@ def _fmt_string_list(array, float_format='{!s}'): elif (vtype == 'o'): fmt_string += ['{}'] elif (vtype == 's'): - raise Exception("MfList error: '\str\' type found it dtype." + \ + raise Exception("MfList error: 'str' type found in dtype." + \ " This gives unpredictable results when " + \ - "recarray to file - change to \'object\' type") + "recarray to file - change to 'object' type") else: raise Exception("MfList.fmt_string error: unknown vtype " + \ "in dtype:" + vtype) diff --git a/flopy/mt3d/mtlkt.py b/flopy/mt3d/mtlkt.py index 959fedc241..a1d25dbad9 100644 --- a/flopy/mt3d/mtlkt.py +++ b/flopy/mt3d/mtlkt.py @@ -285,10 +285,10 @@ def load(f, model, nlak=None, nper=None, ncomp=None, ext_unit_dict=None): -------- >>> import flopy - >>> import os - >>> os.chdir(r'C:\temp\LKT') - >>> mt = flopy.mt3d.Mt3dms.load('lkt_mt.nam', exe_name = 'mt3d-usgs_1.0.00.exe', - >>> load_only='btn') + >>> datadir = 'examples/data/mt3d_test/mfnwt_mt3dusgs/lkt' + >>> mt = flopy.mt3d.Mt3dms.load( + ... 'lkt_mt.nam', exe_name='mt3d-usgs_1.0.00.exe', + ... model_ws=datadir, load_only='btn') >>> lkt = flopy.mt3d.Mt3dLkt.load('test.lkt', mt) """ diff --git a/flopy/mt3d/mtsft.py b/flopy/mt3d/mtsft.py index 8c37f30e61..26e9268041 100644 --- a/flopy/mt3d/mtsft.py +++ b/flopy/mt3d/mtsft.py @@ -167,19 +167,18 @@ class Mt3dSft(Package): Examples -------- - >>> mf = flopy.modflow.Modflow.load('CrnkNic_mf.nam', - >>> load_only=['dis', 'bas6']) + >>> import flopy + >>> datadir = 'examples/data/mt3d_test/mfnwt_mt3dusgs/sft_crnkNic' + >>> mf = flopy.modflow.Modflow.load( + ... 'CrnkNic.nam', model_ws=datadir, load_only=['dis', 'bas6']) >>> sfr = flopy.modflow.ModflowSfr2.load('CrnkNic.sfr2', mf) >>> chk = sfr.check() - >>> # initialize an MT3D-USGS model - >>> mt = flopy.mt3d.Mt3dms.load('CrnkNic_mt.nam', - >>> exe_name = 'mt3d-usgs_1.0.00.exe', - >>> model_ws = r'.\CrnkNic', - >>> load_only='btn') + >>> mt = flopy.mt3d.Mt3dms.load( + ... 'CrnkNic.mtnam', exe_name='mt3d-usgs_1.0.00.exe', + >>> model_ws=datadir, load_only='btn') >>> sft = flopy.mt3d.Mt3dSft.load(mt, 'CrnkNic.sft') - """ def __init__(self, model, nsfinit=0, mxsfbc=0, icbcsf=0, ioutobs=0, @@ -327,12 +326,12 @@ def write_file(self): Examples -------- - >>> mt = flopy.mt3d.Mt3dms.load('CrnkNic_mt.nam', - >>> exe_name = 'mt3d-usgs_1.0.00.exe', - >>> model_ws = r'C:\EDM_LT\GitHub\mt3d-usgs\autotest\temp\CrnkNic', - >>> verbose=True) + >>> import flopy + >>> datadir = .examples/data/mt3d_test/mfnwt_mt3dusgs/sft_crnkNic + >>> mt = flopy.mt3d.Mt3dms.load( + ... 'CrnkNic.mtnam', exe_name='mt3d-usgs_1.0.00.exe', + ... model_ws=datadir, verbose=True) >>> mt.name = 'CrnkNic_rewrite' - >>> >>> mt.sft.dispsf.fmtin = '(10F12.2)' >>> mt.write_input() diff --git a/flopy/mt3d/mtuzt.py b/flopy/mt3d/mtuzt.py index 74a8692501..16f400a3f0 100644 --- a/flopy/mt3d/mtuzt.py +++ b/flopy/mt3d/mtuzt.py @@ -124,10 +124,10 @@ class Mt3dUzt(Package): -------- >>> import flopy - >>> import os - >>> mt = flopy.mt3d.Mt3dms.load('Keat_UZF_mt.nam', - ... exe_name = 'mt3d-usgs_1.0.00.exe', - ... model_ws = r'C:\temp\Keating_UZF', load_only='btn') + >>> datadir = 'examples/data/mt3d_test/mfnwt_mt3dusgs/keat_uzf' + >>> mt = flopy.mt3d.Mt3dms.load( + ... 'Keat_UZF_mt.nam', exe_name='mt3d-usgs_1.0.00.exe', + ... model_ws=datadir, load_only='btn') >>> uzt = flopy.mt3d.Mt3dUzt('Keat_UZF.uzt', mt) """ diff --git a/flopy/utils/check.py b/flopy/utils/check.py index 24ccf5034a..5501506807 100644 --- a/flopy/utils/check.py +++ b/flopy/utils/check.py @@ -569,9 +569,9 @@ def _fmt_string_list(array, float_format='{}'): elif (vtype == 'o'): fmt_string += ['{}'] elif (vtype == 's'): - raise Exception("MfList error: '\str\' type found it dtype." + \ + raise Exception("MfList error: 'str' type found in dtype." + \ " This gives unpredictable results when " + \ - "recarray to file - change to \'object\' type") + "recarray to file - change to 'object' type") else: raise Exception("MfList.fmt_string error: unknown vtype " + \ "in dtype:" + vtype) diff --git a/flopy/utils/flopy_io.py b/flopy/utils/flopy_io.py index 531abc7ddf..f97703eab4 100755 --- a/flopy/utils/flopy_io.py +++ b/flopy/utils/flopy_io.py @@ -37,9 +37,9 @@ def _fmt_string(array, float_format='{}'): elif vtype == 'o': fmt_string += '{} ' elif vtype == 's': - raise Exception("MfList error: '\str\' type found it dtype." + \ + raise Exception("MfList error: 'str' type found in dtype." + \ " This gives unpredictable results when " + \ - "recarray to file - change to \'object\' type") + "recarray to file - change to 'object' type") else: raise Exception("MfList.fmt_string error: unknown vtype " + \ "in dtype:" + vtype) diff --git a/flopy/utils/mtlistfile.py b/flopy/utils/mtlistfile.py index 94787af7e4..96d2f75ecb 100644 --- a/flopy/utils/mtlistfile.py +++ b/flopy/utils/mtlistfile.py @@ -330,7 +330,7 @@ def _parse_gw(self, f, line): break def _parse_gw_line(self, line): raw = line.lower().split(':') - item = raw[0].strip().strip('[\|]').replace(' ', '_') + item = raw[0].strip().strip(r'[\|]').replace(' ', '_') idx_ival = 0 idx_oval = 1 if self.imm: @@ -445,7 +445,7 @@ def _parse_sw(self, f, line): def _parse_sw_line(self, line): # print(line) raw = line.strip().split('=') - citem = raw[0].strip().strip('[\|]').replace(" ", "_") + citem = raw[0].strip().strip(r'[\|]').replace(" ", "_") cval = float(raw[1].split()[0]) if len(raw) < 3: # deal with flow error if written fval = None