Closed 3fon3fonov closed 2 years ago
Objects saved on disk will never be compatible between versions. I.e. if you look at classifiers in sklearn, or scipy triangulations etc, there are no guarantee that those pickled objects will be compatible, so I do not agree that we have to guarantee that pickled objects should be restorable in other versions.
Regarding the reasons to go away from a pure dictionary -- it was to ensure that Results object are coherent, to enable figuring out whether the results object came from the static run or dynamic runs, and to not having to deal with Results objects created in one way and then having half of their attributes replaced.
Regarding helping backward compatibility I think if you take object results and do this dict(results.items()) that'll work perfectly well in current and previous versions of dynesty and you'll be able to modify the dictionary as you wish.
Obviously the choice of changing the Results API was a choice. I do think it is the right one and it helped to simplify a lot of logic in dynesty, but feedback is certainly welcome.
I certainly could remove the code that prohibits the modification of attributes, that's easy, but I think you just should not rely on modifying the Results object. If you want to do that, create a dictionary.
Thanks for your fast reply!
dict(results.items()) seems a good option, but what I did for backward compatibility was to "monkeyjack" the Results class with the old Results class, which I named dynesty_patch.py, and I left it in the Exo-striker /lib directory. Then:
import dynesty
import dynesty_patch
dynesty.results = dynesty_patch
Did the job.
BTW, please push dynesty==1.2 to pypi !
Before, Results() was a dict object and one could modify it. For example, one could add bi-products on the posteriors, add labels, and more.... Everything was stored in one place and accessible to the user at any time.
Forgive me if I don't understand why you had to break the API, and why now Results() should not be modified. Perhaps you had a reason, still, you should allow for some backward compatibility with versions <1.1 or some solution for old dynesty samplers saved on disk.