SURGroup / UQpy

UQpy (Uncertainty Quantification with python) is a general purpose Python toolbox for modeling uncertainty in physical and mathematical systems.
MIT License
271 stars 79 forks source link

Kriging surrogate object cannot be pickled #49

Closed jjramsey closed 2 years ago

jjramsey commented 5 years ago

I can successfully create and use a Kriging surrogate model in UQPy, but I can't save it to a pickle file. When I try, I get the following error message:

Traceback (most recent call last):
  File "./mk_gp_uqpy_fail_to_pickle.py", line 17, in <module>
    pickle.dump(gp, pkl_file)
AttributeError: Can't pickle local object 'Krig.init_krig.<locals>.regress.<locals>.r'

A workaround for this is to use the third-party module dill instead of the standard module pickle, but it would be nice to not need to do that.

mds2120 commented 3 years ago

We will look into this. Thank you.

mds2120 commented 3 years ago

Hi JJ, Upon investigation, it seems that the manner in which the Kriging class is coded makes it incompatible with pickle. I believe this is due to certain nested loops, but @mohitcek can provide a more detailed explanation. This is something we will be working to correct. We agree that it is important for Kriging objects to be pickleable, but it will take some time to restructure the code. Thank you. Michael

mds2120 commented 2 years ago

We have corrected this issue for the upcoming Version 4 release, so we are closing this issue.