Skip to content

Commit

Permalink
bug fix for tied pars - f me
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwhite79 committed Oct 28, 2019
1 parent f0ec705 commit 52877d6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions autotest/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ def run_test():
# hfb_test()
# hfb_zn_mult_test()
#more_kl_test()
#zero_order_regul_test()
zero_order_regul_test()
# first_order_pearson_regul_test()
# master_and_workers()
# smp_to_ins_test()
Expand All @@ -1828,7 +1828,7 @@ def run_test():
# pp_to_shapefile_test()
# read_pval_test()
# read_hob_test()
setup_pp_test()
# setup_pp_test()
# pp_to_tpl_test()
# setup_ppcov_complex()
# ppcov_complex_test()
Expand Down
23 changes: 20 additions & 3 deletions pyemu/pst/pst_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,15 @@ def _cast_df_from_lines(section,lines, fieldnames, converters, defaults,alias_ma
df.loc[:, hard] = df.pop(easy)
dfs.append(df)


df = pd.concat(dfs,axis=0,ignore_index=True)

else:
extra = []
raw = []
for line in lines:
extra_lines = []
ntied = 0
for iline,line in enumerate(lines):
line = line.lower()
if '#' in line:
er = line.strip().split('#')
Expand All @@ -706,10 +709,23 @@ def _cast_df_from_lines(section,lines, fieldnames, converters, defaults,alias_ma
else:
r = line.strip().split()
extra.append(np.NaN)
if "tied" in line:
ntied += 1
raw.append(r)

found_fieldnames = fieldnames[:len(raw[0])]
df = pd.DataFrame(raw,columns=found_fieldnames)
df.loc[:, "extra"] = extra

df = pd.DataFrame(raw[:-ntied],columns=found_fieldnames)
# special handling for tied pars
if ntied > 0:
tied_names = [r[0] for r in raw[-ntied:]]
partied = [r[1] for r in raw[-ntied:] ]
# swap to name index for just a sec...
idx = df.index
df.index = df.parnme
df.loc[tied_names,"partied"] = partied
df.index = idx
df.loc[:, "extra"] = extra[:-ntied]


for col in fieldnames:
Expand Down Expand Up @@ -820,6 +836,7 @@ def _load_version2(self,filename):
self.parameter_data = self._cast_df_from_lines(last_section, section_lines, self.par_fieldnames,
self.par_converters, self.par_defaults,
self.par_alias_map,pst_path=pst_path)

self.parameter_data.index = self.parameter_data.parnme

elif "* observation data" in last_section.lower():
Expand Down

0 comments on commit 52877d6

Please sign in to comment.