Skip to content
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

implement support for parameterScale{Normal,Laplace} #520

Merged
merged 16 commits into from
Nov 30, 2020

Conversation

FFroehlich
Copy link
Contributor

No description provided.

@jvanhoefer
Copy link
Member

I added some documentation, support of parameterScaleUniform and adapted the tests, such that the new parts are tested as well :)

@jvanhoefer
Copy link
Member

Hence I will not review, since it now is also code of mine, but this looks fine to me :)

@FFroehlich
Copy link
Contributor Author

remaining flake issue is already solved in #519

Copy link
Member

@dilpath dilpath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

pypesto/objective/priors.py Show resolved Hide resolved
pypesto/objective/priors.py Outdated Show resolved Hide resolved
pypesto/objective/priors.py Outdated Show resolved Hide resolved
pypesto/objective/priors.py Outdated Show resolved Hide resolved
pypesto/objective/priors.py Outdated Show resolved Hide resolved
pypesto/objective/priors.py Show resolved Hide resolved
@@ -13,20 +13,21 @@
from pypesto.objective import NegLogParameterPriors
from pypesto.objective.priors import get_parameter_prior_dict

scales = ['lin', 'log', 'log10']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, these and other string constants in this file could be replaced with petab.C constants

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make the pypesto API dependent on petab, which I would rather avoid. It should be possible to use these functions without petab and we don't want that functionality to break just because petab changed some of its literals.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it might be worthwhile for pyPESTO to maintain its own set of constants (no need now).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed!

@@ -68,8 +72,8 @@ def test_derivatives():
Tests the finite gradients and second order derivatives.
"""

scales = ['lin', 'log', 'log10']
prior_types = ['uniform', 'normal', 'laplace', 'logNormal']
prior_types = ['normal', 'laplace', 'logNormal', 'parameterScaleUniform',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should 'uniform' be added here? If not, then if prior_type == 'uniform' could be removed (a few lines below this).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored all of the test, uniform was added to that list, but the optimization test doesn't make too much sense since a flat function doesn't have local minima :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends who you ask 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, well, it doesn't have a strict local minimum.

Copy link
Member

@dilpath dilpath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor 👍

pypesto/objective/priors.py Outdated Show resolved Hide resolved
assert abs(prior_dict['density_fun'](lin_to_scaled(1.5, scale))
- math.log(1)) < 1e-8
assert abs(prior_list[0]['density_fun'](
lin_to_scaled(1.5, scale)) - math.log(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lin_to_scaled(1.5, scale)) - math.log(1)
lin_to_scaled(1.5, scale))

assert abs(prior_dict['density_fun'](lin_to_scaled(.5, scale))
- 0) < 1e-8
assert abs(prior_list[0]['density_fun'](
lin_to_scaled(.5, scale)) - 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lin_to_scaled(.5, scale)) - 0
lin_to_scaled(.5, scale))

Are these - 0 or - math.log(1) from the old code intended?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best to check via "diff < ...".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you are suggesting here.

assert abs(prior_dict['density_fun'](lin_to_scaled(2.5, scale))
- 0) < 1e-8
assert abs(prior_list[0]['density_fun'](
lin_to_scaled(2.5, scale)) - 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lin_to_scaled(2.5, scale)) - 0
lin_to_scaled(2.5, scale))

pypesto/objective/priors.py Outdated Show resolved Hide resolved
pypesto/objective/priors.py Outdated Show resolved Hide resolved
pypesto/objective/priors.py Outdated Show resolved Hide resolved
pypesto/objective/priors.py Show resolved Hide resolved
assert abs(prior_dict['density_fun'](lin_to_scaled(.5, scale))
- 0) < 1e-8
assert abs(prior_list[0]['density_fun'](
lin_to_scaled(.5, scale)) - 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best to check via "diff < ...".

FFroehlich and others added 3 commits November 26, 2020 12:35
@codecov-io
Copy link

codecov-io commented Nov 30, 2020

Codecov Report

Merging #520 (28f0991) into develop (ec20071) will increase coverage by 2.96%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #520      +/-   ##
===========================================
+ Coverage    87.74%   90.71%   +2.96%     
===========================================
  Files           65       65              
  Lines         4212     4212              
===========================================
+ Hits          3696     3821     +125     
+ Misses         516      391     -125     
Impacted Files Coverage Δ
pypesto/objective/priors.py 80.45% <100.00%> (ø)
pypesto/sample/geweke_test.py 91.54% <0.00%> (-2.82%) ⬇️
pypesto/objective/function.py 75.00% <0.00%> (+0.92%) ⬆️
pypesto/objective/amici.py 90.85% <0.00%> (+1.21%) ⬆️
pypesto/objective/amici_calculator.py 93.33% <0.00%> (+5.00%) ⬆️
pypesto/objective/amici_util.py 84.82% <0.00%> (+10.71%) ⬆️
pypesto/optimize/optimizer.py 90.83% <0.00%> (+29.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec20071...28f0991. Read the comment docs.

@FFroehlich FFroehlich merged commit c807d4b into develop Nov 30, 2020
@FFroehlich FFroehlich deleted the support_parameterScale_priors branch November 30, 2020 16:08
@yannikschaelte yannikschaelte mentioned this pull request Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants