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

allow using constraint in the config which sets vector margin params #4868

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pycbc/inference/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,16 @@ def logprior(self):
def _logprior(self):
"""Calculates the log prior at the current parameters."""
logj = self.logjacobian
logp = self.prior_distribution(**self.current_params) + logj
# allow using constraint in the config which sets
Copy link
Member

Choose a reason for hiding this comment

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

This seems to leak the interface of the marginalization parameters so that it is coded in multiple places. Would it be better to have the DistMarg class perhaps just override this function instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you explain more?

# vector marginalized parameters
if hasattr(self, 'marginalize_vector_params'):
current_params_no_vec_margin = {
k: v for k, v in self.current_params.items()
if k not in self.marginalize_vector_params
}
else:
current_params_no_vec_margin = self.current_params
logp = self.prior_distribution(**current_params_no_vec_margin) + logj
if numpy.isnan(logp):
logp = -numpy.inf
return logp
Expand Down
Loading