-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix return_dict
when an AmiciObjective
is inside AggregatedObjective
#1424
Conversation
…dict` with amici posterior
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #1424 +/- ##
===========================================
+ Coverage 83.33% 83.35% +0.01%
===========================================
Files 161 161
Lines 13226 13235 +9
===========================================
+ Hits 11022 11032 +10
+ Misses 2204 2203 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test for this would be good as well ensuring it works as intended?
@@ -458,18 +439,23 @@ def call_unprocessed( | |||
|
|||
x_dct = self.par_arr_to_dct(x) | |||
|
|||
# only ask amici to compute required quantities | |||
amici_reporting = ( | |||
self.amici_reporting | |||
if amici_reporting is None | |||
else amici_reporting | |||
) | |||
if amici_reporting is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be made clear in the documentation that amici_reporting takes precedence over return_dict imo.
pypesto/objective/base.py
Outdated
if self.share_return_dict: | ||
kwargs["return_dict"] = return_dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if return_dict
is in kwargs already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It cannot be, since return_dict
is it's own kwarg in this method's argument list.
pypesto/objective/aggregated.py
Outdated
if objective_.share_return_dict: | ||
objective_kwargs["return_dict"] = return_dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in the base objective (see above or below comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually argue that the outer return_dict
should take precedence over inner return_dict
and that we don't need the if objective_.share_return_dict:
check at all.
pypesto/objective/base.py
Outdated
@@ -178,6 +183,8 @@ def __call__( | |||
x_full = self.pre_post_processor.preprocess(x=x) | |||
|
|||
# compute result | |||
if self.share_return_dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise there might be some argument error, because return_dict
is not in every custom user objective.call_unprocessed
signature. But I'll switch to Daniel's suggestion now
pypesto/objective/aggregated.py
Outdated
if objective_.share_return_dict: | ||
objective_kwargs["return_dict"] = return_dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually argue that the outer return_dict
should take precedence over inner return_dict
and that we don't need the if objective_.share_return_dict:
check at all.
I think this would make sense. Your current implementation would already enable issuing a DeprecationWarning and updating things accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, many thanks for providing this fix.
Thanks, I decided to simply switch to it by default now, with a |
AmiciObjective
previously returned all AMICI RData information whenreturn_dict=True
. However, this was handled via__call__
. If the PEtab problem has a prior, then anAggregatedObjective
is created, with anAmiciObjective
and the prior inside. TheAggregatedObjective
callscall_unprocessed
of each internal objective, skippingAmiciObjective.__call__
and hence one would see something like:This PR changes the above to
i.e., rdatas are now "full" and e.g. plotting is now possible.
An alternative fix would be to always pass
return_dict
tocall_unprocessed
. This would be fine for me, but might break someone's custom objective.