From 112b73068189a4cdd42c31b663f72efde7cca65f Mon Sep 17 00:00:00 2001 From: Briochh Date: Wed, 25 Nov 2020 18:07:21 +1300 Subject: [PATCH 1/4] Dirty workaround for some string actions on pathlib obj. --- autotest/pst_from_tests.py | 6 +++--- pyemu/pst/pst_handler.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/autotest/pst_from_tests.py b/autotest/pst_from_tests.py index d4f0a7c60..87b2c27af 100644 --- a/autotest/pst_from_tests.py +++ b/autotest/pst_from_tests.py @@ -1083,7 +1083,7 @@ def mf6_freyberg_da_test(): print(pf.org_files) # build pest - pst = pf.build_pst('freyberg.pst') + pst = pf.build_pst('freyberg.pst', version=2) pst.write(os.path.join(template_ws,"freyberg6_da.pst"),version=2) @@ -2291,8 +2291,8 @@ def test_get_filepath(): #freyberg_prior_build_test() #mf6_freyberg_test() #mf6_freyberg_shortnames_test() - # mf6_freyberg_da_test() + mf6_freyberg_da_test() #mf6_freyberg_direct_test() #mf6_freyberg_varying_idomain() - xsec_test() + # xsec_test() diff --git a/pyemu/pst/pst_handler.py b/pyemu/pst/pst_handler.py index 3d6fce27b..1e2cacd4b 100644 --- a/pyemu/pst/pst_handler.py +++ b/pyemu/pst/pst_handler.py @@ -1488,6 +1488,7 @@ def sanity_checks(self): def _write_version2(self, new_filename, use_pst_path=True, pst_rel_path="."): pst_path = None + new_filename = os.path.join(new_filename) if use_pst_path: pst_path, _ = Pst._parse_path_agnostic(new_filename) if pst_rel_path == ".": From d3e3f35b560bd944d9e99d01fe7ab74fc2979394 Mon Sep 17 00:00:00 2001 From: Brioch Hemmings Date: Thu, 26 Nov 2020 08:51:40 +1300 Subject: [PATCH 2/4] use str() on path object --- pyemu/pst/pst_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyemu/pst/pst_handler.py b/pyemu/pst/pst_handler.py index 1e2cacd4b..264d18562 100644 --- a/pyemu/pst/pst_handler.py +++ b/pyemu/pst/pst_handler.py @@ -1488,7 +1488,7 @@ def sanity_checks(self): def _write_version2(self, new_filename, use_pst_path=True, pst_rel_path="."): pst_path = None - new_filename = os.path.join(new_filename) + new_filename = str(new_filename) # ensure convert to str if use_pst_path: pst_path, _ = Pst._parse_path_agnostic(new_filename) if pst_rel_path == ".": From f2c42d2efcd12c5d925c4a3f24aef0c0ece13d90 Mon Sep 17 00:00:00 2001 From: Briochh Date: Thu, 26 Nov 2020 09:14:45 +1300 Subject: [PATCH 3/4] more path to str tidy --- pyemu/pst/pst_handler.py | 2 +- pyemu/utils/pst_from.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pyemu/pst/pst_handler.py b/pyemu/pst/pst_handler.py index 1e2cacd4b..264d18562 100644 --- a/pyemu/pst/pst_handler.py +++ b/pyemu/pst/pst_handler.py @@ -1488,7 +1488,7 @@ def sanity_checks(self): def _write_version2(self, new_filename, use_pst_path=True, pst_rel_path="."): pst_path = None - new_filename = os.path.join(new_filename) + new_filename = str(new_filename) # ensure convert to str if use_pst_path: pst_path, _ = Pst._parse_path_agnostic(new_filename) if pst_rel_path == ".": diff --git a/pyemu/utils/pst_from.py b/pyemu/utils/pst_from.py index e42b82e1e..190741191 100644 --- a/pyemu/utils/pst_from.py +++ b/pyemu/utils/pst_from.py @@ -977,7 +977,7 @@ def add_observations( prefix (`str`): prefix for obsnmes ofile_skip (`int`): number of lines to skip in model output file ofile_sep (`str`): delimiter in output file - rebuild_pst (`bool`): (Re)Construct PstFrom.pst object after adding + rebuild_pst (`bool`): (Re)Construct PstFrom.pst object after addin new obs Returns: @@ -1345,7 +1345,7 @@ def add_parameters( par_data_cols = pyemu.pst_utils.pst_config["par_fieldnames"] self.logger.log( "adding {0} type {1} style parameters for file(s) {2}".format( - par_type, par_style, str(filenames) + par_type, par_style, [str(f) for f in filenames] ) ) if geostruct is not None: @@ -1875,8 +1875,9 @@ def add_parameters( # variograms=v) self.logger.log( - "adding {0} type {1} style parameters for file(s) {2}" - "".format(par_type, par_style, str(filenames)) + "adding {0} type {1} style parameters for file(s) {2}".format( + par_type, par_style, [str(f) for f in filenames] + ) ) if rebuild_pst: # may want to just update pst and rebuild From 959dda6dac51633097971fdb5f0dc24e00a891f2 Mon Sep 17 00:00:00 2001 From: Brioch Hemmings Date: Thu, 26 Nov 2020 09:55:53 +1300 Subject: [PATCH 4/4] undo typo introduction --- pyemu/utils/pst_from.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyemu/utils/pst_from.py b/pyemu/utils/pst_from.py index 190741191..ea040a78e 100644 --- a/pyemu/utils/pst_from.py +++ b/pyemu/utils/pst_from.py @@ -977,7 +977,7 @@ def add_observations( prefix (`str`): prefix for obsnmes ofile_skip (`int`): number of lines to skip in model output file ofile_sep (`str`): delimiter in output file - rebuild_pst (`bool`): (Re)Construct PstFrom.pst object after addin + rebuild_pst (`bool`): (Re)Construct PstFrom.pst object after adding new obs Returns: @@ -2910,4 +2910,4 @@ def get_relative_filepath(folder, filename): """Like :func:`~pyemu.utils.pst_from.get_filepath`, except return path for filename relative to folder. """ - return get_filepath(folder, filename).relative_to(folder) \ No newline at end of file + return get_filepath(folder, filename).relative_to(folder)