ICB-DCM / pyPESTO

python Parameter EStimation TOolbox
https://pypesto.readthedocs.io
BSD 3-Clause "New" or "Revised" License
217 stars 47 forks source link

Loading result from hierachical optimisation results in `AttributeError` #1309

Closed arrjon closed 7 months ago

arrjon commented 7 months ago

Bug description When loading a result object from hierachical optimisation and calling plot_splines_from_pypesto_result this results in AttributeError: 'Objective' object has no attribute 'calculator' even though it worked when working with the original results object.

Expected behavior After loading a result object plotting functions should still work. If think this is related to #1308.

To reproduce Minimal example using the example_semiquantitative petab problem: minimal_example.py.zip Run the script twice: first to produce a result object and store it. Everything works as expected. Rerun it, this will create the problem in the same way, but it will load the result object instead of creating it. The error appears then in the last function call.

Environment

dweindl commented 7 months ago

This is expected and unrelated to hierarchical optimization. See also this example. The objective is not saved, you'll have to set result.problem to the Problem used to generate the result. You should have seen a warning when loading from file. If not, this might be due to #1252 (fixed in amici>=v0.21.0).

arrjon commented 7 months ago

I thought I reloaded the problem, but it turns out I forgot to assign it to the result. Adding result.problem = problem solved it. Thanks!