Skip to content

Commit 217951e

Browse files
committed
Don't save numpy types in WPPF parameters
The numpy types can make state files unloadable. Only save basic types in the state files. Signed-off-by: Patrick Avery <[email protected]>
1 parent 19d724b commit 217951e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

hexrdgui/calibration/wppf_options_dialog.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,13 +1642,21 @@ def generate_params(method, materials, peak_shape, bkgmethod, amorphous_model):
16421642

16431643

16441644
def param_to_dict(param):
1645-
return {
1645+
# Make sure these are non-numpy types
1646+
def _dict_to_basic(d):
1647+
for k, v in list(d.items()):
1648+
if isinstance(v, np.generic):
1649+
d[k] = v.item()
1650+
1651+
return d
1652+
1653+
return _dict_to_basic({
16461654
'name': param.name,
16471655
'value': param.value,
16481656
'min': param.min,
16491657
'max': param.max,
16501658
'vary': param.vary,
1651-
}
1659+
})
16521660

16531661

16541662
def dict_to_param(d):

0 commit comments

Comments
 (0)