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
cf48d3c3
Commit
cf48d3c3
authored
2 years ago
by
Colm Talbot
Browse files
Options
Downloads
Patches
Plain Diff
Dirichlet Prior: Fix reading prior that has been written to file
parent
907dbf65
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1128
Dirichlet Prior: Fix reading prior that has been written to file
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bilby/core/prior/conditional.py
+1
-1
1 addition, 1 deletion
bilby/core/prior/conditional.py
test/core/prior/conditional_test.py
+31
-0
31 additions, 0 deletions
test/core/prior/conditional_test.py
with
32 additions
and
1 deletion
bilby/core/prior/conditional.py
+
1
−
1
View file @
cf48d3c3
...
...
@@ -371,7 +371,7 @@ class DirichletElement(ConditionalBeta):
self
.
_required_variables
=
[
label
+
str
(
ii
)
for
ii
in
range
(
order
)
]
self
.
__class__
.
__name__
=
'
Dirichlet
'
self
.
__class__
.
__name__
=
'
Dirichlet
Element
'
def
dirichlet_condition
(
self
,
reference_parms
,
**
kwargs
):
remaining
=
1
-
sum
(
...
...
This diff is collapsed.
Click to expand it.
test/core/prior/conditional_test.py
+
31
−
0
View file @
cf48d3c3
import
os
import
shutil
import
unittest
from
unittest
import
mock
import
numpy
as
np
import
pandas
as
pd
import
bilby
...
...
@@ -408,5 +411,33 @@ class TestConditionalPriorDict(unittest.TestCase):
print
(
res
)
class
TestDirichletPrior
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
priors
=
bilby
.
core
.
prior
.
DirichletPriorDict
(
5
)
def
tearDown
(
self
):
if
os
.
path
.
isdir
(
"
priors
"
):
shutil
.
rmtree
(
"
priors
"
)
def
test_samples_sum_to_less_than_one
(
self
):
"""
Test that the samples sum to less than one as required for the
Dirichlet distribution.
"""
samples
=
pd
.
DataFrame
(
self
.
priors
.
sample
(
10000
)).
values
self
.
assertLess
(
max
(
np
.
sum
(
samples
,
axis
=
1
)),
1
)
def
test_read_write_file
(
self
):
self
.
priors
.
to_file
(
outdir
=
"
priors
"
,
label
=
"
test
"
)
test
=
bilby
.
core
.
prior
.
PriorDict
(
filename
=
"
priors/test.prior
"
)
self
.
assertEqual
(
self
.
priors
,
test
)
def
test_read_write_json
(
self
):
self
.
priors
.
to_json
(
outdir
=
"
priors
"
,
label
=
"
test
"
)
test
=
bilby
.
core
.
prior
.
PriorDict
.
from_json
(
filename
=
"
priors/test_prior.json
"
)
self
.
assertEqual
(
self
.
priors
,
test
)
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