Commit d37ac4eb authored by Michael Williams's avatar Michael Williams
Browse files

Merge changes from master

parents c9e379e0 6681ce04
......@@ -10,11 +10,12 @@
# before the next stage begins
stages:
- initial
- test
- deploy
.test-python: &test-python
stage: test
stage: initial
image: python
before_script:
# this is required because pytables doesn't use a wheel on py37
......@@ -55,15 +56,30 @@ python-3.7:
- coverage html
- coverage-badge -o coverage_badge.svg -f
artifacts:
paths:
- coverage_badge.svg
- htmlcov/
docs:
stage: initial
image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
script:
# Make the documentation
- apt-get -yqq install pandoc
- python -m pip install .
- cd docs
- pip install ipykernel ipython jupyter
- cp ../examples/tutorials/*.ipynb ./
- rm basic_ptmcmc_tutorial.ipynb
- rm compare_samplers.ipynb
- rm visualising_the_results.ipynb
- jupyter nbconvert --to notebook --execute *.ipynb --inplace
- make clean
- make html
artifacts:
paths:
- htmlcov/
- coverage_badge.svg
- docs/_build/html/
# test example on python 3.8
......@@ -105,7 +121,7 @@ python-3.6-samplers:
# Test containers are up to date
containers:
stage: test
stage: initial
image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
script:
- cd containers
......@@ -139,7 +155,7 @@ plotting:
- pytest test/gw/plot_test.py
authors:
stage: test
stage: initial
image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
script:
- python test/check_author_list.py
......@@ -147,6 +163,7 @@ authors:
pages:
stage: deploy
dependencies:
- docs
- python-3.7
script:
- mkdir public/
......@@ -176,7 +193,7 @@ deploy_release:
precommits-py3.7:
stage: test
stage: initial
image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
script:
- source activate python37
......
......@@ -14,7 +14,7 @@ def grid_file_name(outdir, label, gzip=False):
""" Returns the standard filename used for a grid file
Parameters
----------
==========
outdir: str
Name of the output directory
label: str
......@@ -23,7 +23,7 @@ def grid_file_name(outdir, label, gzip=False):
Set to True to append `.gz` to the extension for saving in gzipped format
Returns
-------
=======
str: File name of the output file
"""
if gzip:
......@@ -39,7 +39,7 @@ class Grid(object):
"""
Parameters
----------
==========
likelihood: bilby.likelihood.Likelihood
priors: bilby.prior.PriorDict
grid_size: int, list, dict
......@@ -112,7 +112,7 @@ class Grid(object):
Marginalize over a list of parameters.
Parameters
----------
==========
log_array: array_like
A :class:`numpy.ndarray` of log likelihood/posterior values.
parameters: list, str
......@@ -123,7 +123,7 @@ class Grid(object):
the set of parameter to *not* marginalize over.
Returns
-------
=======
out_array: array_like
An array containing the marginalized log likelihood/posterior.
"""
......@@ -162,7 +162,7 @@ class Grid(object):
Marginalize the log likelihood/posterior over a single given parameter.
Parameters
----------
==========
log_array: array_like
A :class:`numpy.ndarray` of log likelihood/posterior values.
name: str
......@@ -171,7 +171,7 @@ class Grid(object):
A list of parameter names that have not been marginalized over.
Returns
-------
=======
out: array_like
An array containing the marginalized log likelihood/posterior.
"""
......@@ -218,14 +218,14 @@ class Grid(object):
ln likelihood will be fully marginalized over.
Parameters
----------
==========
parameters: str, list, optional
Name of, or list of names of, the parameter(s) to marginalize over.
not_parameters: str, optional
Name of, or list of names of, the parameter(s) to not marginalize over.
Returns
-------
=======
array-like:
The marginalized ln likelihood.
"""
......@@ -239,14 +239,14 @@ class Grid(object):
ln posterior will be fully marginalized over.
Parameters
----------
==========
parameters: str, list, optional
Name of, or list of names of, the parameter(s) to marginalize over.
not_parameters: str, optional
Name of, or list of names of, the parameter(s) to not marginalize over.
Returns
-------
=======
array-like:
The marginalized ln posterior.
"""
......@@ -260,14 +260,14 @@ class Grid(object):
likelihood will be fully marginalized over.
Parameters
----------
==========
parameters: str, list, optional
Name of, or list of names of, the parameter(s) to marginalize over.
not_parameters: str, optional
Name of, or list of names of, the parameter(s) to not marginalize over.
Returns
-------
=======
array-like:
The marginalized likelihood.
"""
......@@ -283,14 +283,14 @@ class Grid(object):
posterior will be fully marginalized over.
Parameters
----------
==========
parameters: str, list, optional
Name of, or list of names of, the parameter(s) to marginalize over.
not_parameters: str, optional
Name of, or list of names of, the parameter(s) to not marginalize over.
Returns
-------
=======
array-like:
The marginalized posterior.
"""
......@@ -375,7 +375,7 @@ class Grid(object):
Writes the Grid to a file.
Parameters
----------
==========
filename: str, optional
Filename to write to (overwrites the default)
overwrite: bool, optional
......@@ -418,7 +418,7 @@ class Grid(object):
""" Read in a saved .json grid file
Parameters
----------
==========
filename: str
If given, try to load from this filename
outdir, label: str
......@@ -429,11 +429,11 @@ class Grid(object):
extension)
Returns
-------
=======
grid: bilby.core.grid.Grid
Raises
-------
=======
ValueError: If no filename is given and either outdir or label is None
If no bilby.core.grid.Grid is found in the path
......
......@@ -13,7 +13,7 @@ class Likelihood(object):
"""Empty likelihood class to be subclassed by other likelihoods
Parameters
----------
==========
parameters: dict
A dictionary of the parameter names and associated values
"""
......@@ -28,7 +28,7 @@ class Likelihood(object):
"""
Returns
-------
=======
float
"""
return np.nan
......@@ -37,7 +37,7 @@ class Likelihood(object):
"""
Returns
-------
=======
float
"""
return np.nan
......@@ -46,7 +46,7 @@ class Likelihood(object):
"""Difference between log likelihood and noise log likelihood
Returns
-------
=======
float
"""
return self.log_likelihood() - self.noise_log_likelihood()
......@@ -71,7 +71,7 @@ class ZeroLikelihood(Likelihood):
""" A special test-only class which already returns zero likelihood
Parameters
----------
==========
likelihood: bilby.core.likelihood.Likelihood
A likelihood object to mimic
......@@ -98,7 +98,7 @@ class Analytical1DLikelihood(Likelihood):
parameters are inferred from the arguments of function
Parameters
----------
==========
x, y: array_like
The data to analyse
func:
......@@ -174,7 +174,7 @@ class GaussianLikelihood(Analytical1DLikelihood):
parameters are inferred from the arguments of function
Parameters
----------
==========
x, y: array_like
The data to analyse
func:
......@@ -235,7 +235,7 @@ class PoissonLikelihood(Analytical1DLikelihood):
inferred from the arguments of function, which provides a rate.
Parameters
----------
==========
x: array_like
A dependent variable at which the Poisson rates will be calculated
......@@ -291,7 +291,7 @@ class ExponentialLikelihood(Analytical1DLikelihood):
An exponential likelihood function.
Parameters
----------
==========
x, y: array_like
The data to analyse
......@@ -338,7 +338,7 @@ class StudentTLikelihood(Analytical1DLikelihood):
https://en.wikipedia.org/wiki/Student%27s_t-distribution#Generalized_Student's_t-distribution
Parameters
----------
==========
x, y: array_like
The data to analyse
func:
......@@ -410,7 +410,7 @@ class Multinomial(Likelihood):
"""
Parameters
----------
==========
data: array-like
The number of objects in each class
n_dimensions: int
......@@ -454,7 +454,7 @@ class AnalyticalMultidimensionalCovariantGaussian(Likelihood):
with known analytic solution.
Parameters
----------
==========
mean: array_like
Array with the mean values of distribution
cov: array_like
......@@ -484,7 +484,7 @@ class AnalyticalMultidimensionalBimodalCovariantGaussian(Likelihood):
with known analytic solution.
Parameters
----------
==========
mean_1: array_like
Array with the mean value of the first mode
mean_2: array_like
......@@ -523,7 +523,7 @@ class JointLikelihood(Likelihood):
set consistently
Parameters
----------
==========
*likelihoods: bilby.core.likelihood.Likelihood
likelihoods to be combined parsed as arguments
"""
......
......@@ -13,7 +13,7 @@ class DeltaFunction(Prior):
"""Dirac delta function prior, this always returns peak.
Parameters
----------
==========
peak: float
Peak value of the delta function
name: str
......@@ -33,11 +33,11 @@ class DeltaFunction(Prior):
"""Rescale everything to the peak with the correct shape.
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Rescaled probability, equivalent to peak
"""
self.test_valid_for_rescaling(val)
......@@ -47,11 +47,11 @@ class DeltaFunction(Prior):
"""Return the prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
Union[float, array_like]: np.inf if val = peak, 0 otherwise
"""
......@@ -69,7 +69,7 @@ class PowerLaw(Prior):
"""Power law with bounds and alpha, spectral index
Parameters
----------
==========
alpha: float
Power law exponent parameter
minimum: float
......@@ -97,12 +97,12 @@ class PowerLaw(Prior):
This maps to the inverse CDF. This has been analytically solved for this case.
Parameters
----------
==========
val: Union[float, int, array_like]
Uniform probability
Returns
-------
=======
Union[float, array_like]: Rescaled probability
"""
self.test_valid_for_rescaling(val)
......@@ -116,11 +116,11 @@ class PowerLaw(Prior):
"""Return the prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Prior probability of val
"""
if self.alpha == -1:
......@@ -134,11 +134,11 @@ class PowerLaw(Prior):
"""Return the logarithmic prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float:
"""
......@@ -170,7 +170,7 @@ class Uniform(Prior):
"""Uniform prior with bounds
Parameters
----------
==========
minimum: float
See superclass
maximum: float
......@@ -195,12 +195,12 @@ class Uniform(Prior):
This maps to the inverse CDF. This has been analytically solved for this case.
Parameters
----------
==========
val: Union[float, int, array_like]
Uniform probability
Returns
-------
=======
Union[float, array_like]: Rescaled probability
"""
self.test_valid_for_rescaling(val)
......@@ -210,11 +210,11 @@ class Uniform(Prior):
"""Return the prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Prior probability of val
"""
return ((val >= self.minimum) & (val <= self.maximum)) / (self.maximum - self.minimum)
......@@ -223,11 +223,11 @@ class Uniform(Prior):
"""Return the log prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: log probability of val
"""
return xlogy(1, (val >= self.minimum) & (val <= self.maximum)) - xlogy(1, self.maximum - self.minimum)
......@@ -246,7 +246,7 @@ class LogUniform(PowerLaw):
"""Log-Uniform prior with bounds
Parameters
----------
==========
minimum: float
See superclass
maximum: float
......@@ -278,7 +278,7 @@ class SymmetricLogUniform(Prior):
maximum].
Parameters
----------
==========
minimum: float
See superclass
maximum: float
......@@ -303,12 +303,12 @@ class SymmetricLogUniform(Prior):
This maps to the inverse CDF. This has been analytically solved for this case.
Parameters
----------
==========
val: Union[float, int, array_like]
Uniform probability
Returns
-------
=======
Union[float, array_like]: Rescaled probability
"""
self.test_valid_for_rescaling(val)
......@@ -330,11 +330,11 @@ class SymmetricLogUniform(Prior):
"""Return the prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Prior probability of val
"""
val = np.abs(val)
......@@ -345,11 +345,11 @@ class SymmetricLogUniform(Prior):
"""Return the logarithmic prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float:
"""
......@@ -375,7 +375,7 @@ class Cosine(Prior):
"""Cosine prior with bounds
Parameters
----------
==========
minimum: float
See superclass
maximum: float
......@@ -406,11 +406,11 @@ class Cosine(Prior):
"""Return the prior probability of val. Defined over [-pi/2, pi/2].
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Prior probability of val
"""
return np.cos(val) / 2 * self.is_in_prior_range(val)
......@@ -430,7 +430,7 @@ class Sine(Prior):
"""Sine prior with bounds
Parameters
----------
==========
minimum: float
See superclass
maximum: float
......@@ -461,11 +461,11 @@ class Sine(Prior):
"""Return the prior probability of val. Defined over [0, pi].
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
Union[float, array_like]: Prior probability of val
"""
return np.sin(val) / 2 * self.is_in_prior_range(val)
......@@ -484,7 +484,7 @@ class Gaussian(Prior):
"""Gaussian prior with mean mu and width sigma
Parameters
----------
==========
mu: float
Mean of the Gaussian prior
sigma:
......@@ -507,7 +507,7 @@ class Gaussian(Prior):
'Rescale' a sample from the unit line element to the appropriate Gaussian prior.
Parameters
----------
==========
val: Union[float, int, array_like]
This maps to the inverse CDF. This has been analytically solved for this case.
......@@ -519,11 +519,11 @@ class Gaussian(Prior):
"""Return the prior probability of val.
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
Union[float, array_like]: Prior probability of val
"""
return np.exp(-(self.mu - val) ** 2 / (2 * self.sigma ** 2)) / (2 * np.pi) ** 0.5 / self.sigma
......@@ -532,11 +532,11 @@ class Gaussian(Prior):
"""Return the Log prior probability of val.
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
Union[float, array_like]: Prior probability of val