Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • john-veitch/bilby
  • duncanmmacleod/bilby
  • colm.talbot/bilby
  • lscsoft/bilby
  • matthew-pitkin/bilby
  • salvatore-vitale/tupak
  • charlie.hoy/bilby
  • bfarr/bilby
  • virginia.demilio/bilby
  • vivien/bilby
  • eric-howell/bilby
  • sebastian-khan/bilby
  • rhys.green/bilby
  • moritz.huebner/bilby
  • joseph.mills/bilby
  • scott.coughlin/bilby
  • matthew.carney/bilby
  • hyungwon.lee/bilby
  • monica.rizzo/bilby
  • christopher-berry/bilby
  • lindsay.demarchi/bilby
  • kaushik.rao/bilby
  • charles.kimball/bilby
  • andrew.matas/bilby
  • juan.calderonbustillo/bilby
  • patrick-meyers/bilby
  • hannah.middleton/bilby
  • eve.chase/bilby
  • grant.meadors/bilby
  • khun.phukon/bilby
  • sumeet.kulkarni/bilby
  • daniel.reardon/bilby
  • cjhaster/bilby
  • sylvia.biscoveanu/bilby
  • james-clark/bilby
  • meg.millhouse/bilby
  • joshua.willis/bilby
  • nikhil.sarin/bilby
  • paul.easter/bilby
  • youngmin/bilby
  • daniel-williams/bilby
  • shanika.galaudage/bilby
  • bruce.edelman/bilby
  • avi.vajpeyi/bilby
  • isobel.romero-shaw/bilby
  • andrew.kim/bilby
  • dominika.zieba/bilby
  • jonathan.davies/bilby
  • marc.arene/bilby
  • srishti.tiwari/bilby-tidal-heating-eccentric
  • aditya.vijaykumar/bilby
  • michael.williams/bilby
  • cecilio.garcia-quiros/bilby
  • rory-smith/bilby
  • maite.mateu-lucena/bilby
  • wushichao/bilby
  • kaylee.desoto/bilby
  • brandon.piotrzkowski/bilby
  • rossella.gamba/bilby
  • hunter.gabbard/bilby
  • deep.chatterjee/bilby
  • tathagata.ghosh/bilby
  • arunava.mukherjee/bilby
  • philip.relton/bilby
  • reed.essick/bilby
  • pawan.gupta/bilby
  • francisco.hernandez/bilby
  • rhiannon.udall/bilby
  • leo.tsukada/bilby
  • will-farr/bilby
  • vijay.varma/bilby
  • jeremy.baier/bilby
  • joshua.brandt/bilby
  • ethan.payne/bilby
  • ka-lok.lo/bilby
  • antoni.ramos-buades/bilby
  • oliviastephany.wilk/bilby
  • jack.heinzel/bilby
  • samson.leong/bilby-psi4
  • viviana.caceres/bilby
  • nadia.qutob/bilby
  • michael-coughlin/bilby
  • hemantakumar.phurailatpam/bilby
  • boris.goncharov/bilby
  • sama.al-shammari/bilby
  • siqi.zhong/bilby
  • jocelyn-read/bilby
  • marc.penuliar/bilby
  • stephanie.letourneau/bilby
  • alexandresebastien.goettel/bilby
  • alec.gunny/bilby
  • serguei.ossokine/bilby
  • pratyusava.baral/bilby
  • sophie.hourihane/bilby
  • eunsub/bilby
  • james.hart/bilby
  • pratyusava.baral/bilby-tg
  • zhaozc/bilby
  • pratyusava.baral/bilby_SoG
  • tomasz.baka/bilby
  • nicogerardo.bers/bilby
  • soumen.roy/bilby
  • isaac.mcmahon/healpix-redundancy
  • asamakai.baker/bilby-frequency-dependent-antenna-pattern-functions
  • anna.puecher/bilby
  • pratyusava.baral/bilby-x-g
  • thibeau.wouters/bilby
  • christian.adamcewicz/bilby
  • raffi.enficiaud/bilby
109 results
Show changes
Commits on Source (18)
Showing
with 136 additions and 62 deletions
[run]
omit =
test/example_test.py
test/gw_example_test.py
test/noise_realisation_test.py
test/other_test.py
test/core/example_test.py
test/gw/example_test.py
test/gw/noise_realisation_test.py
test/gw/other_test.py
......@@ -91,8 +91,8 @@ python-3.7-samplers:
script:
- python -m pip install .
- pytest test/sampler_test.py --durations 10
- pytest test/sample_from_the_prior_test.py
- pytest test/core/sampler/sampler_run_test.py --durations 10
- pytest test/gw/sample_from_the_prior_test.py
# test samplers on python 3.6
python-3.6-samplers:
......@@ -101,7 +101,7 @@ python-3.6-samplers:
script:
- python -m pip install .
- pytest test/sampler_test.py
- pytest test/core/sampler/sampler_run_test.py
# Tests run at a fixed schedule rather than on push
scheduled-python-3.7:
......@@ -113,9 +113,9 @@ scheduled-python-3.7:
- python -m pip install .
# Run tests which are only done on schedule
- pytest test/example_test.py
- pytest test/gw_example_test.py
- pytest test/sample_from_the_prior_test.py
- pytest test/core/example_test.py
- pytest test/gw/example_test.py
- pytest test/gw/sample_from_the_prior_test.py
plotting:
stage: test
......@@ -126,7 +126,7 @@ plotting:
- python -m pip install .
- python -m pip install ligo.skymap
- pytest test/gw_plot_test.py
- pytest test/gw/plot_test.py
pages:
stage: deploy
......
......@@ -129,7 +129,7 @@ def conditional_prior_factory(prior_class):
"""
if sorted(list(required_variables)) == sorted(self.required_variables):
parameters = self.condition_func(self.reference_params, **required_variables)
parameters = self.condition_func(self.reference_params.copy(), **required_variables)
for key, value in parameters.items():
setattr(self, key, value)
elif len(required_variables) == 0:
......
......@@ -574,9 +574,10 @@ class Result(object):
'injection_parameters', 'meta_data', 'search_parameter_keys',
'fixed_parameter_keys', 'constraint_parameter_keys',
'sampling_time', 'sampler_kwargs', 'use_ratio',
'log_likelihood_evaluations', 'log_prior_evaluations', 'samples',
'nested_samples', 'walkers', 'nburn', 'parameter_labels',
'parameter_labels_with_unit', 'version']
'log_likelihood_evaluations', 'log_prior_evaluations',
'num_likelihood_evaluations', 'samples', 'nested_samples',
'walkers', 'nburn', 'parameter_labels', 'parameter_labels_with_unit',
'version']
dictionary = OrderedDict()
for attr in save_attrs:
try:
......
......@@ -756,7 +756,7 @@ def sample_rwalk_bilby(args):
# Check proposed point.
v_prop = prior_transform(np.array(u_prop))
logl_prop = loglikelihood(np.array(v_prop))
if logl_prop >= loglstar:
if logl_prop > loglstar:
u = u_prop
v = v_prop
logl = logl_prop
......
......@@ -13,7 +13,7 @@ import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from ..utils import logger
from ..utils import logger, check_directory_exists_and_if_not_mkdir
from .base_sampler import SamplerError, MCMCSampler
......@@ -517,6 +517,7 @@ class Ptemcee(MCMCSampler):
sys.exit(self.exit_code)
def write_current_state(self, plot=True):
check_directory_exists_and_if_not_mkdir(self.outdir)
checkpoint(
self.iteration,
self.outdir,
......
......@@ -19,6 +19,7 @@ import numpy as np
from scipy.interpolate import interp2d
from scipy.special import logsumexp
import pandas as pd
import matplotlib.pyplot as plt
logger = logging.getLogger('bilby')
......@@ -1160,27 +1161,67 @@ def safe_file_dump(data, filename, module):
def latex_plot_format(func):
"""
Wrap a plotting function to set rcParams so that text renders nicely with
latex and Computer Modern Roman font.
Wrap the plotting function to set rcParams dependent on environment variables
The rcparams can be set directly from the env. variable `BILBY_STYLE` to
point to a matplotlib style file. Or, if `BILBY_STYLE=default` (any case) a
default setup is used, this is enabled by default. To not use any rcParams,
set `BILBY_STYLE=none`. Occasionally, issues arrise with the latex
`mathdefault` command. A fix is to define this command in the rcParams. An
env. variable `BILBY_MATHDEFAULT` can be used to turn this fix on/off.
Setting `BILBY_MATHDEFAULT=1` will enable the fix, all other choices
(including undefined) will disable it. Additionally, the BILBY_STYLE and
BILBY_MATHDEFAULT arguments can be passed into any
latex_plot_format-wrapped plotting function and will be set directly.
"""
@functools.wraps(func)
def wrapper_decorator(*args, **kwargs):
from matplotlib import rcParams
_old_tex = rcParams["text.usetex"]
_old_serif = rcParams["font.serif"]
_old_family = rcParams["font.family"]
if find_executable("latex"):
rcParams["text.usetex"] = True
if "BILBY_STYLE" in kwargs:
bilby_style = kwargs.pop("BILBY_STYLE")
else:
bilby_style = os.environ.get("BILBY_STYLE", "default")
if "BILBY_MATHDEFAULT" in kwargs:
bilby_mathdefault = kwargs.pop("BILBY_MATHDEFAULT")
else:
bilby_mathdefault = int(os.environ.get("BILBY_MATHDEFAULT", "0"))
if bilby_mathdefault == 1:
logger.debug("Setting mathdefault in the rcParams")
rcParams['text.latex.preamble'] = r'\newcommand{\mathdefault}[1][]{}'
logger.debug("Using BILBY_STYLE={}".format(bilby_style))
if bilby_style.lower() == "none":
return func(*args, **kwargs)
elif os.path.isfile(bilby_style):
plt.style.use(bilby_style)
return func(*args, **kwargs)
elif bilby_style in plt.style.available:
plt.style.use(bilby_style)
return func(*args, **kwargs)
elif bilby_style.lower() == "default":
_old_tex = rcParams["text.usetex"]
_old_serif = rcParams["font.serif"]
_old_family = rcParams["font.family"]
if find_executable("latex"):
rcParams["text.usetex"] = True
else:
rcParams["text.usetex"] = False
rcParams["font.serif"] = "Computer Modern Roman"
rcParams["font.family"] = "serif"
rcParams["text.usetex"] = _old_tex
rcParams["font.serif"] = _old_serif
rcParams["font.family"] = _old_family
return func(*args, **kwargs)
else:
rcParams["text.usetex"] = False
rcParams["font.serif"] = "Computer Modern Roman"
rcParams["font.family"] = "serif"
value = func(*args, **kwargs)
rcParams["text.usetex"] = _old_tex
rcParams["font.serif"] = _old_serif
rcParams["font.family"] = _old_family
return value
logger.debug(
"Environment variable BILBY_STYLE={} not used"
.format(bilby_style)
)
return func(*args, **kwargs)
return wrapper_decorator
......
......@@ -788,10 +788,24 @@ class GravitationalWaveTransient(Likelihood):
@property
def lal_version(self):
try:
from lal import git_version
lal_version = str(git_version.verbose_msg).replace("\n", ";")
logger.info("Using LAL version {}".format(lal_version))
return lal_version
from lal import git_version, __version__
lal_version = str(__version__)
logger.info("Using lal version {}".format(lal_version))
lal_git_version = str(git_version.verbose_msg).replace("\n", ";")
logger.info("Using lal git version {}".format(lal_git_version))
return "lal_version={}, lal_git_version={}".format(lal_version, lal_git_version)
except (ImportError, AttributeError):
return "N/A"
@property
def lalsimulation_version(self):
try:
from lalsimulation import git_version, __version__
lalsim_version = str(__version__)
logger.info("Using lalsimulation version {}".format(lalsim_version))
lalsim_git_version = str(git_version.verbose_msg).replace("\n", ";")
logger.info("Using lalsimulation git version {}".format(lalsim_git_version))
return "lalsimulation_version={}, lalsimulation_git_version={}".format(lalsim_version, lalsim_git_version)
except (ImportError, AttributeError):
return "N/A"
......@@ -811,7 +825,8 @@ class GravitationalWaveTransient(Likelihood):
start_time=self.waveform_generator.start_time,
time_reference=self.time_reference,
reference_frame=self._reference_frame_str,
lal_version=self.lal_version)
lal_version=self.lal_version,
lalsimulation_version=self.lalsimulation_version)
class BasicGravitationalWaveTransient(Likelihood):
......
......@@ -630,7 +630,9 @@ Prior._default_latex_labels = {
'lambda_1': '$\\Lambda_1$',
'lambda_2': '$\\Lambda_2$',
'lambda_tilde': '$\\tilde{\\Lambda}$',
'delta_lambda_tilde': '$\\delta\\tilde{\\Lambda}$'}
'delta_lambda_tilde': '$\\delta\\tilde{\\Lambda}$',
'chi_1': '$\\chi_1$',
'chi_2': '$\\chi_2$'}
class CalibrationPriorDict(PriorDict):
......
......@@ -41,7 +41,7 @@ coverage-badge
RUN pip install corner lalsuite astropy gwpy theano
# Install samplers
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest dnest4
# Install pymultinest requirements
RUN apt-get install -y libblas3 libblas-dev liblapack3 liblapack-dev \
......@@ -55,7 +55,7 @@ ENV LD_LIBRARY_PATH $HOME/MultiNest/MultiNest_v3.11_CMake/multinest/lib:
# Install Polychord
RUN git clone https://github.com/PolyChord/PolyChordLite.git \
&& (cd PolyChordLite && make pypolychord MPI= && python setup.py install)
&& (cd PolyChordLite && python setup.py --no-mpi install)
# Install PTMCMCSampler
RUN git clone https://github.com/jellis18/PTMCMCSampler.git \
......
......@@ -48,7 +48,7 @@ RUN pip install sphinx numpydoc nbsphinx sphinx_rtd_theme sphinx-tabs
RUN pip install corner lalsuite astropy gwpy theano healpy
# Install samplers
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest dnest4
# Install pymultinest requirements
RUN apt-get install -y libblas3 libblas-dev liblapack3 liblapack-dev \
......@@ -62,7 +62,7 @@ ENV LD_LIBRARY_PATH $HOME/MultiNest/MultiNest_v3.11_CMake/multinest/lib:
# Install Polychord
RUN git clone https://github.com/PolyChord/PolyChordLite.git \
&& (cd PolyChordLite && make pypolychord MPI= && python setup.py install)
&& (cd PolyChordLite && python setup.py --no-mpi install)
# Install PTMCMCSampler
RUN git clone https://github.com/jellis18/PTMCMCSampler.git \
......
......@@ -35,7 +35,7 @@ RUN pip install sphinx numpydoc nbsphinx sphinx_rtd_theme sphinx-tabs autodoc
# Install dependencies and samplers
RUN pip install corner lalsuite theano healpy cython
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest dnest4
# Install multinest
RUN git clone https://github.com/farhanferoz/MultiNest.git \
......@@ -45,7 +45,7 @@ ENV LD_LIBRARY_PATH $HOME/MultiNest/MultiNest_v3.12_CMake/multinest/lib:
# Install Polychord
RUN git clone https://github.com/PolyChord/PolyChordLite.git \
&& (cd PolyChordLite && make pypolychord MPI= && python setup.py install)
&& (cd PolyChordLite && python setup.py --no-mpi install)
# Install PTMCMCSampler
RUN git clone https://github.com/jellis18/PTMCMCSampler.git \
......
......@@ -35,7 +35,7 @@ RUN pip install sphinx numpydoc nbsphinx sphinx_rtd_theme sphinx-tabs autodoc
# Install dependencies and samplers
RUN pip install corner lalsuite theano healpy cython
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest dnest4
# Install multinest
RUN git clone https://github.com/farhanferoz/MultiNest.git \
......@@ -45,7 +45,7 @@ ENV LD_LIBRARY_PATH $HOME/MultiNest/MultiNest_v3.12_CMake/multinest/lib:
# Install Polychord
RUN git clone https://github.com/PolyChord/PolyChordLite.git \
&& (cd PolyChordLite && make pypolychord MPI= && python setup.py install)
&& (cd PolyChordLite && python setup.py --no-mpi install)
# Install PTMCMCSampler
RUN git clone https://github.com/jellis18/PTMCMCSampler.git \
......
......@@ -35,7 +35,7 @@ RUN pip install sphinx numpydoc nbsphinx sphinx_rtd_theme sphinx-tabs autodoc
# Install dependencies and samplers
RUN pip install corner lalsuite theano healpy cython
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest dnest4
# Install multinest
RUN git clone https://github.com/farhanferoz/MultiNest.git \
......@@ -45,7 +45,7 @@ ENV LD_LIBRARY_PATH $HOME/MultiNest/MultiNest_v3.12_CMake/multinest/lib:
# Install Polychord
RUN git clone https://github.com/PolyChord/PolyChordLite.git \
&& (cd PolyChordLite && make pypolychord MPI= && python setup.py install)
&& (cd PolyChordLite && python setup.py --no-mpi install)
# Install PTMCMCSampler
RUN git clone https://github.com/jellis18/PTMCMCSampler.git \
......
......@@ -35,7 +35,7 @@ RUN pip install sphinx numpydoc nbsphinx sphinx_rtd_theme sphinx-tabs autodoc
# Install dependencies and samplers
RUN pip install corner lalsuite theano healpy cython
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest
RUN pip install cpnest dynesty emcee nestle ptemcee pymc3 pymultinest kombine ultranest dnest4
# Install multinest
RUN git clone https://github.com/farhanferoz/MultiNest.git \
......@@ -45,7 +45,7 @@ ENV LD_LIBRARY_PATH $HOME/MultiNest/MultiNest_v3.12_CMake/multinest/lib:
# Install Polychord
RUN git clone https://github.com/PolyChord/PolyChordLite.git \
&& (cd PolyChordLite && make pypolychord MPI= && python setup.py install)
&& (cd PolyChordLite && python setup.py --no-mpi install)
# Install PTMCMCSampler
RUN git clone https://github.com/jellis18/PTMCMCSampler.git \
......
=========================
Frequency Asked Questions
=========================
Plotting questions
------------------
I'm running into latex errors when :code:`bilby` tries to create plots, what should I do?
Matplotlib can be a little finicky. We wrap plotting commands in a function
which can set up the rcParams and we use environment variables to allow
configuration of this. See the docstring of this function for the allowed
configuration options
.. autofunction:: bilby.core.utils.latex_plot_format
......@@ -27,5 +27,6 @@ Welcome to bilby's documentation!
writing-documentation
hyperparameters
containers
faq
......@@ -5,12 +5,12 @@ ignore = E129 W503 W504 W605 E203 E402
[tool:pytest]
addopts =
--ignore test/other_test.py
--ignore test/gw_example_test.py
--ignore test/example_test.py
--ignore test/sample_from_the_prior_test.py
--ignore test/gw_plot_test.py
--ignore test/sampler_test.py
--ignore test/gw/other_test.py
--ignore test/gw/example_test.py
--ignore test/core/example_test.py
--ignore test/gw/sample_from_the_prior_test.py
--ignore test/gw/plot_test.py
--ignore test/core/sampler/sampler_run_test.py
[metadata]
license_file = LICENSE.md
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
import bilby # noqa