Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lscsoft
bilby
Commits
21a337a4
Commit
21a337a4
authored
4 years ago
by
Moritz Huebner
Browse files
Options
Downloads
Patches
Plain Diff
Added CDF explicitly to conditional priors
parent
82872fe5
No related branches found
No related tags found
1 merge request
!882
Added CDF explicitly to conditional priors
Pipeline
#160070
passed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bilby/core/prior/conditional.py
+32
-0
32 additions, 0 deletions
bilby/core/prior/conditional.py
test/core/prior/conditional_test.py
+16
-1
16 additions, 1 deletion
test/core/prior/conditional_test.py
with
48 additions
and
1 deletion
bilby/core/prior/conditional.py
+
32
−
0
View file @
21a337a4
...
...
@@ -110,9 +110,41 @@ def conditional_prior_factory(prior_class):
return
super
(
ConditionalPrior
,
self
).
prob
(
val
)
def
ln_prob
(
self
,
val
,
**
required_variables
):
"""
Return the natural log prior probability of val.
Parameters
----------
val: Union[float, int, array_like]
See superclass
required_variables:
Any required variables that this prior depends on
Returns
-------
float: Natural log prior probability of val
"""
self
.
update_conditions
(
**
required_variables
)
return
super
(
ConditionalPrior
,
self
).
ln_prob
(
val
)
def
cdf
(
self
,
val
,
**
required_variables
):
"""
Return the cdf of val.
Parameters
----------
val: Union[float, int, array_like]
See superclass
required_variables:
Any required variables that this prior depends on
Returns
-------
float: CDF of val
"""
self
.
update_conditions
(
**
required_variables
)
return
super
(
ConditionalPrior
,
self
).
cdf
(
val
)
def
update_conditions
(
self
,
**
required_variables
):
"""
This method updates the conditional parameters (depending on the parent class
...
...
This diff is collapsed.
Click to expand it.
test/core/prior/conditional_test.py
+
16
−
1
View file @
21a337a4
...
...
@@ -110,7 +110,7 @@ class TestConditionalPrior(unittest.TestCase):
test_parameter_2
=
self
.
test_variable_2
,
)
def
test_
rescale_prob
_update_conditions
(
self
):
def
test_
prob_calls
_update_conditions
(
self
):
with
mock
.
patch
.
object
(
self
.
prior
,
"
update_conditions
"
)
as
m
:
self
.
prior
.
prob
(
1
,
...
...
@@ -138,6 +138,21 @@ class TestConditionalPrior(unittest.TestCase):
]
m
.
assert_has_calls
(
calls
)
def
test_cdf_calls_update_conditions
(
self
):
self
.
prior
=
bilby
.
core
.
prior
.
ConditionalUniform
(
condition_func
=
self
.
condition_func
,
minimum
=
self
.
minimum
,
maximum
=
self
.
maximum
)
with
mock
.
patch
.
object
(
self
.
prior
,
"
update_conditions
"
)
as
m
:
self
.
prior
.
cdf
(
1
,
test_parameter_1
=
self
.
test_variable_1
,
test_parameter_2
=
self
.
test_variable_2
,
)
m
.
assert_called_with
(
test_parameter_1
=
self
.
test_variable_1
,
test_parameter_2
=
self
.
test_variable_2
,
)
def
test_reset_to_reference_parameters
(
self
):
self
.
prior
.
minimum
=
10
self
.
prior
.
maximum
=
20
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment