Skip to content

Commit dc70aa1

Browse files
authored
Merge pull request #588 from briochh/hotfix_srdict
casting get_xy arg to tuple regardless -- think it is safe
2 parents 34c84e1 + 6575fbb commit dc70aa1

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

autotest/pst_from_tests.py

+34-2
Original file line numberDiff line numberDiff line change
@@ -6191,6 +6191,38 @@ def arrayskip_test(tmp_path):
61916191
pass
61926192

61936193

6194+
def test_sr_dict(tmp_path):
6195+
xs = np.arange(1000, 2000, 10)
6196+
ys = np.arange(2000, 3000, 10)
6197+
sr_dict = {(i, j): (x,y) for i, y in enumerate(ys) for j, x in enumerate(xs)}
6198+
gs = pyemu.geostats.GeoStruct(variograms=pyemu.geostats.ExpVario(contribution=1, a=250))
6199+
6200+
parfile = pd.DataFrame(sr_dict.keys(), columns=['i', 'j'])
6201+
parfile['q'] = range(len(parfile.index))
6202+
6203+
md = Path(tmp_path, 'eg')
6204+
md.mkdir(parents=True, exist_ok=True)
6205+
parfile.to_csv(Path(md, "parfile.csv"), index=False, header=False)
6206+
parfile.to_csv(Path(md, "obsfile.csv"), index=False, header=True)
6207+
pf = PstFrom(original_d=md, new_d=Path(tmp_path, 'template'),
6208+
remove_existing=True,
6209+
longnames=True, spatial_reference=sr_dict,
6210+
zero_based=True)
6211+
pf.add_parameters("parfile.csv",
6212+
par_type="grid",
6213+
index_cols=[0, 1],
6214+
use_cols=[2],
6215+
geostruct=gs)
6216+
pf.add_observations("obsfile.csv",
6217+
insfile="obsfile.csv.ins",
6218+
prefix="obs_file",
6219+
index_cols=['i','j'],
6220+
use_cols='q',
6221+
ofile_sep=',')
6222+
pass
6223+
6224+
6225+
61946226

61956227
if __name__ == "__main__":
61966228
#add_py_function_test('.')
@@ -6235,9 +6267,9 @@ def arrayskip_test(tmp_path):
62356267
# # pstfrom_profile()
62366268
# mf6_freyberg_arr_obs_and_headerless_test()
62376269
#usg_freyberg_test(".")
6238-
#vertex_grid_test()
6270+
# vertex_grid_test('.')
62396271
#direct_quickfull_test()
6240-
#list_float_int_index_test()
6272+
# list_float_int_index_test('.')
62416273
#freyberg_test()
62426274

62436275

pyemu/utils/pst_from.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,7 @@ def _generic_get_xy(self, args, **kwargs):
371371
return i, j
372372

373373
def _dict_get_xy(self, arg, **kwargs):
374-
if isinstance(arg, list):
375-
arg = tuple(arg)
374+
arg = tuple(arg)
376375
if len(arg) == 1:
377376
arg = arg[0]
378377
xy = self._spatial_reference.get(arg, None)

0 commit comments

Comments
 (0)