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
593fc829
Commit
593fc829
authored
6 years ago
by
moritz
Browse files
Options
Downloads
Patches
Plain Diff
Moritz Huebner: Added some tests for the fill_prior function
parent
6b35c755
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
requirements.txt
+1
-0
1 addition, 0 deletions
requirements.txt
test/prior_tests.py
+37
-0
37 additions, 0 deletions
test/prior_tests.py
with
38 additions
and
0 deletions
requirements.txt
+
1
−
0
View file @
593fc829
...
...
@@ -13,3 +13,4 @@ NRSur7dq2
nestle
deepdish
ptemcee
mock
This diff is collapsed.
Click to expand it.
test/prior_tests.py
+
37
−
0
View file @
593fc829
from
context
import
tupak
import
unittest
from
mock
import
Mock
import
numpy
as
np
...
...
@@ -153,5 +154,41 @@ class TestPriorClasses(unittest.TestCase):
self
.
assertAlmostEqual
(
np
.
trapz
(
prior
.
prob
(
domain
),
domain
),
1
,
3
)
class
TestFillPrior
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
likelihood
=
Mock
()
self
.
likelihood
.
parameters
=
dict
(
a
=
0
,
b
=
0
,
c
=
0
,
d
=
0
,
asdf
=
0
,
ra
=
1
)
self
.
priors
=
dict
(
a
=
1
,
b
=
1.1
,
c
=
'
string
'
,
d
=
tupak
.
prior
.
Uniform
(
0
,
1
))
self
.
priors
=
tupak
.
prior
.
fill_priors
(
self
.
priors
,
self
.
likelihood
)
def
tearDown
(
self
):
del
self
.
likelihood
del
self
.
priors
def
test_prior_instances_are_not_changed_by_parsing
(
self
):
self
.
assertIsInstance
(
self
.
priors
[
'
d
'
],
tupak
.
prior
.
Uniform
)
def
test_parsing_ints_to_delta_priors_class
(
self
):
self
.
assertIsInstance
(
self
.
priors
[
'
a
'
],
tupak
.
prior
.
DeltaFunction
)
def
test_parsing_ints_to_delta_priors_with_right_value
(
self
):
self
.
assertEqual
(
self
.
priors
[
'
a
'
].
peak
,
1
)
def
test_parsing_floats_to_delta_priors_class
(
self
):
self
.
assertIsInstance
(
self
.
priors
[
'
b
'
],
tupak
.
prior
.
DeltaFunction
)
def
test_parsing_floats_to_delta_priors_with_right_value
(
self
):
self
.
assertAlmostEqual
(
self
.
priors
[
'
b
'
].
peak
,
1.1
,
1e-8
)
def
test_without_available_default_priors_no_prior_is_set
(
self
):
with
self
.
assertRaises
(
KeyError
):
print
(
self
.
priors
[
'
asdf
'
])
def
test_with_available_default_priors_a_default_prior_is_set
(
self
):
self
.
assertIsInstance
(
self
.
priors
[
'
ra
'
],
tupak
.
prior
.
Uniform
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
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