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
02fbf2d7
Commit
02fbf2d7
authored
4 years ago
by
Colm Talbot
Browse files
Options
Downloads
Patches
Plain Diff
Weaken prior equivalence tests to work with conditional priors.
parent
5645d4e4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!868
Allow sampling in aligned spin and spin magnitude
Pipeline
#193051
failed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bilby/core/prior/base.py
+37
-6
37 additions, 6 deletions
bilby/core/prior/base.py
with
37 additions
and
6 deletions
bilby/core/prior/base.py
+
37
−
6
View file @
02fbf2d7
...
...
@@ -63,21 +63,52 @@ class Prior(object):
return
self
.
sample
()
def
__eq__
(
self
,
other
):
"""
Test equality of two prior objects.
Returns true iff:
- The class of the two priors are the same
- Both priors have the same keys in the __dict__ attribute
- The instantiation arguments match
We don
'
t check that all entries the the __dict__ attribute
are equal as some attributes are variable for conditional
priors.
Parameters
==========
other: Prior
The prior to compare with
Returns
=======
bool
Whether the priors are equivalent
Notes
=====
A special case is made for :code `scipy.stats.beta`: instances.
It may be possible to remove this as we now only check instantiation
arguments.
"""
if
self
.
__class__
!=
other
.
__class__
:
return
False
if
sorted
(
self
.
__dict__
.
keys
())
!=
sorted
(
other
.
__dict__
.
keys
()):
return
False
for
key
in
self
.
__dict__
:
this_dict
=
self
.
get_instantiation_dict
()
other_dict
=
other
.
get_instantiation_dict
()
for
key
in
this_dict
:
if
key
==
"
least_recently_sampled
"
:
# ignore sample drawn from prior in comparison
continue
if
type
(
self
.
_
_dict
__
[
key
]
)
is
np
.
ndarray
:
if
not
np
.
array_equal
(
self
.
_
_dict
__
[
key
],
other
.
_
_dict
__
[
key
]):
if
isinstance
(
this
_dict
[
key
]
,
np
.
ndarray
)
:
if
not
np
.
array_equal
(
this
_dict
[
key
],
other_dict
[
key
]):
return
False
elif
isinstance
(
self
.
_
_dict
__
[
key
],
type
(
scipy
.
stats
.
beta
(
1.
,
1.
))):
elif
isinstance
(
this
_dict
[
key
],
type
(
scipy
.
stats
.
beta
(
1.
,
1.
))):
continue
else
:
if
not
self
.
_
_dict
__
[
key
]
==
other
.
_
_dict
__
[
key
]:
if
not
this
_dict
[
key
]
==
other_dict
[
key
]:
return
False
return
True
...
...
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