-
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
AmiciObjective: check that sensitivities wrt all relevant parameters … #1416
base: develop
Are you sure you want to change the base?
Changes from all commits
638e80b
6397f3e
74ba61f
ecf00db
838a73f
19e99bf
5a69d70
5dd6c00
31db016
e865f8c
f107c48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -447,6 +447,9 @@ def create_objective( | |
Returns | ||
------- | ||
A :class:`pypesto.objective.AmiciObjective` for the model and the data. | ||
This object is expected to be passed to | ||
:class:`PetabImporter.create_problem` to correctly handle fixed | ||
parameters. | ||
Comment on lines
+450
to
+452
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have a test to check the expected behavior if one does not pass it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that we don't know the expected behaviour if one does not pass it to |
||
""" | ||
# get simulation conditions | ||
simulation_conditions = petab.get_simulation_conditions( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,16 +167,19 @@ def test_max_sensi_order(): | |
"""Test that the AMICI objective created via PEtab exposes derivatives | ||
correctly.""" | ||
model_name = "Boehm_JProteomeRes2014" | ||
problem = pypesto.petab.PetabImporter.from_yaml( | ||
importer = pypesto.petab.PetabImporter.from_yaml( | ||
os.path.join(models.MODELS_DIR, model_name, model_name + ".yaml") | ||
) | ||
problem = importer.create_problem() | ||
|
||
# define test parameter | ||
par = problem.petab_problem.x_nominal_scaled | ||
npar = len(par) | ||
par = np.asarray(importer.petab_problem.x_nominal_scaled)[ | ||
problem.x_free_indices | ||
] | ||
npar = problem.dim | ||
|
||
# auto-computed max_sensi_order and fim_for_hess | ||
objective = problem.create_objective() | ||
objective = problem.objective | ||
hess = objective(par, sensi_orders=(2,)) | ||
assert hess.shape == (npar, npar) | ||
assert (hess != 0).any() | ||
|
@@ -190,18 +193,24 @@ def test_max_sensi_order(): | |
) | ||
|
||
# fix max_sensi_order to 1 | ||
objective = problem.create_objective(max_sensi_order=1) | ||
objective = importer.create_problem( | ||
objective=importer.create_objective(max_sensi_order=1) | ||
).objective | ||
Comment on lines
+196
to
+198
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be a minor thing, but i find this a really unintuitive way of creating the objective function correctly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is, that petab fixed parameters are only handled in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well both the importer and the problem should be aware of fixes parameters, so I agree that one should naturally expect |
||
objective(par, sensi_orders=(1,)) | ||
with pytest.raises(ValueError): | ||
objective(par, sensi_orders=(2,)) | ||
|
||
# do not use FIM | ||
objective = problem.create_objective(fim_for_hess=False) | ||
objective = importer.create_problem( | ||
objective=importer.create_objective(fim_for_hess=False) | ||
).objective | ||
with pytest.raises(ValueError): | ||
objective(par, sensi_orders=(2,)) | ||
|
||
# only allow computing function values | ||
objective = problem.create_objective(max_sensi_order=0) | ||
objective = importer.create_problem( | ||
objective=importer.create_objective(max_sensi_order=0) | ||
).objective | ||
objective(par) | ||
with pytest.raises(ValueError): | ||
objective(par, sensi_orders=(1,)) | ||
|
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.