A unified framework for stochastic sampling packages and gravitational-wave inference in Python. Note that we are currently transitioning from git.ligo.org/lscsoft/bilby, please bear with us!
In GitLab by @git.ligo:colm.talbot on Mar 4, 2021, 15:38
Importing bilby is pretty horribly slow, sometimes taking O(s). This is due to the number of top-level imports we have.
Using len(sys.modules) as a proxy for the number of packages being imported when bilby imports shows that we're being pretty bad on imports. The following gives an idea of the number of things imported for a few reference modules.
We're about an order of magnitude above numpy and lal. This is probably why it takes so long to import bilby.
There are basically two choices we can make to reduce these, one is to not link everything internally, this would be one could not just do
import bilby
bilby.gw.prior.BBHPriorDict()
Specific modules would be imported individually. Given the amount of linkage between modules, I'm not sure how successful that would be.
The second choice would be to limit the packages that we import at the top level to e.g., just numpy. Removing matplotlib, gwpy, astropy would help a lot. pandas and scipy also contribute quite a bit, but are used very widely. I think tqdm and dill are relatively harmless, but we may want to also remove these from the top level. lal/lalsimulation just add one extra module each, I guess because they're SWIG wrappers, but I'd still vote for not importing them at the top level and just doing it inside the function. Built in packages don't really make a difference.
We could also define a decorator something like requires_import that checks the relevant packages can be imported, although we should check that doesn't hurt performance for things like source models.
For completeness, here's all of the imports in the package
In GitLab by @git.ligo:colm.talbot on Mar 4, 2021, 15:38
Importing
bilby
is pretty horribly slow, sometimes taking O(s). This is due to the number of top-level imports we have.Using
len(sys.modules)
as a proxy for the number of packages being imported whenbilby
imports shows that we're being pretty bad on imports. The following gives an idea of the number of things imported for a few reference modules.We're about an order of magnitude above
numpy
andlal
. This is probably why it takes so long to importbilby
.There are basically two choices we can make to reduce these, one is to not link everything internally, this would be one could not just do
Specific modules would be imported individually. Given the amount of linkage between modules, I'm not sure how successful that would be.
The second choice would be to limit the packages that we import at the top level to e.g., just
numpy
. Removingmatplotlib
,gwpy
,astropy
would help a lot.pandas
andscipy
also contribute quite a bit, but are used very widely. I thinktqdm
anddill
are relatively harmless, but we may want to also remove these from the top level.lal
/lalsimulation
just add one extra module each, I guess because they're SWIG wrappers, but I'd still vote for not importing them at the top level and just doing it inside the function. Built in packages don't really make a difference.We could also define a decorator something like
requires_import
that checks the relevant packages can be imported, although we should check that doesn't hurt performance for things like source models.For completeness, here's all of the imports in the package
Expand/collapse
```python $ grep import bilby/**.py (dev) bilby/__init__.py:import sys bilby/__init__.py:from . import core, gw, hyper bilby/__init__.py:from .core import utils, likelihood, prior, result, sampler bilby/__init__.py:from .core.sampler import run_sampler bilby/__init__.py:from .core.likelihood import Likelihood bilby/core/__init__.py:from . import grid, likelihood, prior, result, sampler, series, utils bilby/core/grid.py:import numpy as np bilby/core/grid.py:import os bilby/core/grid.py:import json bilby/core/grid.py:from collections import OrderedDict bilby/core/grid.py:from .prior import Prior, PriorDict bilby/core/grid.py:from .utils import (logtrapzexp, check_directory_exists_and_if_not_mkdir, bilby/core/grid.py:from .utils import BilbyJsonEncoder, load_json, move_old_file bilby/core/grid.py:from .result import FileMovedError bilby/core/grid.py: import gzip bilby/core/likelihood.py:import copy bilby/core/likelihood.py:import numpy as np bilby/core/likelihood.py:from scipy.special import gammaln, xlogy bilby/core/likelihood.py:from scipy.stats import multivariate_normal bilby/core/likelihood.py:from .utils import infer_parameters_from_function bilby/core/prior/__init__.py:from .analytical import * bilby/core/prior/__init__.py:from .base import * bilby/core/prior/__init__.py:from .conditional import * bilby/core/prior/__init__.py:from .dict import * bilby/core/prior/__init__.py:from .interpolated import * bilby/core/prior/__init__.py:from .joint import * bilby/core/prior/__init__.py:from .slabspike import * bilby/core/prior/analytical.py:import numpy as np bilby/core/prior/analytical.py:from scipy.special import erfinv bilby/core/prior/analytical.py:from scipy.special._ufuncs import xlogy, erf, log1p, stdtrit, gammaln, stdtr, \ bilby/core/prior/analytical.py:from .base import Prior bilby/core/prior/analytical.py:from bilby.core.utils import logger bilby/core/prior/base.py:from importlib import import_module bilby/core/prior/base.py:import json bilby/core/prior/base.py:import os bilby/core/prior/base.py:import re bilby/core/prior/base.py:import numpy as np bilby/core/prior/base.py:import scipy.stats bilby/core/prior/base.py:from scipy.integrate import cumtrapz bilby/core/prior/base.py:from scipy.interpolate import interp1d bilby/core/prior/base.py:from bilby.core.utils import infer_args_from_method, BilbyJsonEncoder, decode_bilby_json, logger, \ bilby/core/prior/base.py: kwargs[key] = getattr(import_module(module), name) bilby/core/prior/base.py: other_cls = getattr(import_module(module), other_cls) bilby/core/prior/conditional.py:import numpy as np bilby/core/prior/conditional.py:from .base import Prior, PriorException bilby/core/prior/conditional.py:from bilby.core.prior.interpolated import Interped bilby/core/prior/conditional.py:from bilby.core.prior.analytical import DeltaFunction, PowerLaw, Uniform, LogUniform, \ bilby/core/prior/conditional.py:from bilby.core.utils import infer_args_from_method, infer_parameters_from_function bilby/core/prior/dict.py:from importlib import import_module bilby/core/prior/dict.py:from io import open as ioopen bilby/core/prior/dict.py:import json bilby/core/prior/dict.py:import os bilby/core/prior/dict.py:from matplotlib.cbook import flatten bilby/core/prior/dict.py:import numpy as np bilby/core/prior/dict.py:from bilby.core.prior.analytical import DeltaFunction bilby/core/prior/dict.py:from bilby.core.prior.base import Prior, Constraint bilby/core/prior/dict.py:from bilby.core.prior.joint import JointPrior bilby/core/prior/dict.py:from bilby.core.utils import logger, check_directory_exists_and_if_not_mkdir, BilbyJsonEncoder, decode_bilby_json bilby/core/prior/dict.py: import_module(prior_dict["__module__"]), bilby/core/prior/dict.py: logger.debug("Cannot import prior module {}.{}".format( bilby/core/prior/dict.py: cls = getattr(import_module(module), cls, cls) bilby/core/prior/dict.py: import_module(val.get("__module__", "none")), bilby/core/prior/dict.py: logger.debug("Cannot import prior module {}.{}".format( bilby/core/prior/dict.py: from .conditional import DirichletElement bilby/core/prior/dict.py: import_module(prior_dict["__module__"]), bilby/core/prior/dict.py: logger.debug("Cannot import prior module {}.{}".format( bilby/core/prior/interpolated.py:import numpy as np bilby/core/prior/interpolated.py:from scipy.integrate import cumtrapz bilby/core/prior/interpolated.py:from scipy.interpolate import interp1d bilby/core/prior/interpolated.py:from .base import Prior bilby/core/prior/interpolated.py:from bilby.core.utils import logger bilby/core/prior/joint.py:import numpy as np bilby/core/prior/joint.py:import scipy.stats bilby/core/prior/joint.py:from scipy.special import erfinv bilby/core/prior/joint.py:from .base import Prior, PriorException bilby/core/prior/joint.py:from bilby.core.utils import logger, infer_args_from_method, get_dict_with_properties bilby/core/prior/slabspike.py:import numpy as np bilby/core/prior/slabspike.py:from bilby.core.prior.base import Prior bilby/core/prior/slabspike.py:from bilby.core.utils import logger bilby/core/result.py:import inspect bilby/core/result.py:import os bilby/core/result.py:from collections import OrderedDict, namedtuple bilby/core/result.py:from copy import copy bilby/core/result.py:from distutils.version import LooseVersion bilby/core/result.py:from importlib import import_module bilby/core/result.py:from itertools import product bilby/core/result.py:import corner bilby/core/result.py:import h5py bilby/core/result.py:import json bilby/core/result.py:import matplotlib bilby/core/result.py:import matplotlib.pyplot as plt bilby/core/result.py:from matplotlib import lines as mpllines bilby/core/result.py:import numpy as np bilby/core/result.py:import pandas as pd bilby/core/result.py:import scipy.stats bilby/core/result.py:from scipy.special import logsumexp bilby/core/result.py:from . import utils bilby/core/result.py:from .utils import ( bilby/core/result.py:from .prior import Prior, PriorDict, DeltaFunction bilby/core/result.py: import deepdish bilby/core/result.py: import dill bilby/core/result.py: cls = getattr(import_module(data['__module__']), data['__name__']) bilby/core/result.py: import gzip bilby/core/result.py: import dill bilby/core/result.py: import dill bilby/core/result.py: import arviz as az bilby/core/sampler/__init__.py:import inspect bilby/core/sampler/__init__.py:import sys bilby/core/sampler/__init__.py:import datetime bilby/core/sampler/__init__.py:from collections import OrderedDict bilby/core/sampler/__init__.py:import bilby bilby/core/sampler/__init__.py:from ..utils import command_line_args, logger, loaded_modules_dict bilby/core/sampler/__init__.py:from ..prior import PriorDict, DeltaFunction bilby/core/sampler/__init__.py:from .base_sampler import Sampler, SamplingMarginalisedParameterError bilby/core/sampler/__init__.py:from .cpnest import Cpnest bilby/core/sampler/__init__.py:from .dynamic_dynesty import DynamicDynesty bilby/core/sampler/__init__.py:from .dynesty import Dynesty bilby/core/sampler/__init__.py:from .emcee import Emcee bilby/core/sampler/__init__.py:from .kombine import Kombine bilby/core/sampler/__init__.py:from .nestle import Nestle bilby/core/sampler/__init__.py:from .polychord import PyPolyChord bilby/core/sampler/__init__.py:from .ptemcee import Ptemcee bilby/core/sampler/__init__.py:from .ptmcmc import PTMCMCSampler bilby/core/sampler/__init__.py:from .pymc3 import Pymc3 bilby/core/sampler/__init__.py:from .pymultinest import Pymultinest bilby/core/sampler/__init__.py:from .ultranest import Ultranest bilby/core/sampler/__init__.py:from .fake_sampler import FakeSampler bilby/core/sampler/__init__.py:from .dnest4 import DNest4 bilby/core/sampler/__init__.py:from . import proposal bilby/core/sampler/__init__.py: from . import IMPLEMENTED_SAMPLERS bilby/core/sampler/__init__.py: from bilby.core.likelihood import ZeroLikelihood bilby/core/sampler/base_sampler.py:import datetime bilby/core/sampler/base_sampler.py:import distutils.dir_util bilby/core/sampler/base_sampler.py:import numpy as np bilby/core/sampler/base_sampler.py:import os bilby/core/sampler/base_sampler.py:import tempfile bilby/core/sampler/base_sampler.py:from pandas import DataFrame bilby/core/sampler/base_sampler.py:from ..utils import logger, check_directory_exists_and_if_not_mkdir, command_line_args, Counter bilby/core/sampler/base_sampler.py:from ..prior import Prior, PriorDict, DeltaFunction, Constraint bilby/core/sampler/base_sampler.py:from ..result import Result, read_in_result bilby/core/sampler/base_sampler.py: skip_import_verification: bool bilby/core/sampler/base_sampler.py: use_ratio=False, plot=False, skip_import_verification=False, bilby/core/sampler/base_sampler.py: if not skip_import_verification: bilby/core/sampler/base_sampler.py: self.external_sampler = __import__(external_sampler_name) bilby/core/sampler/base_sampler.py: import emcee bilby/core/sampler/cpnest.py:import array bilby/core/sampler/cpnest.py:import copy bilby/core/sampler/cpnest.py:import numpy as np bilby/core/sampler/cpnest.py:from pandas import DataFrame bilby/core/sampler/cpnest.py:from .base_sampler import NestedSampler bilby/core/sampler/cpnest.py:from .proposal import Sample, JumpProposalCycle bilby/core/sampler/cpnest.py:from ..utils import logger, check_directory_exists_and_if_not_mkdir bilby/core/sampler/cpnest.py: from cpnest import model as cpmodel, CPNest bilby/core/sampler/cpnest.py: from cpnest.parameter import LivePoint bilby/core/sampler/cpnest.py: from cpnest.nest2pos import compute_weights bilby/core/sampler/cpnest.py: import sys bilby/core/sampler/cpnest.py: from cpnest.proposal import ProposalCycle bilby/core/sampler/cpnest.py: import cpnest.proposal bilby/core/sampler/cpnest.py: import cpnest.proposal bilby/core/sampler/dnest4.py:import os bilby/core/sampler/dnest4.py:import shutil bilby/core/sampler/dnest4.py:import distutils.dir_util bilby/core/sampler/dnest4.py:import signal bilby/core/sampler/dnest4.py:import time bilby/core/sampler/dnest4.py:import datetime bilby/core/sampler/dnest4.py:import sys bilby/core/sampler/dnest4.py:import numpy as np bilby/core/sampler/dnest4.py:import pandas as pd bilby/core/sampler/dnest4.py:from ..utils import check_directory_exists_and_if_not_mkdir, logger bilby/core/sampler/dnest4.py:from .base_sampler import NestedSampler bilby/core/sampler/dnest4.py: exit_code=77, skip_import_verification=False, temporary_directory=True, **kwargs): bilby/core/sampler/dnest4.py: use_ratio=use_ratio, plot=plot, skip_import_verification=skip_import_verification, bilby/core/sampler/dnest4.py: import dnest4 bilby/core/sampler/dnest4.py: import dnest4 bilby/core/sampler/dynamic_dynesty.py:import os bilby/core/sampler/dynamic_dynesty.py:import dill as pickle bilby/core/sampler/dynamic_dynesty.py:import signal bilby/core/sampler/dynamic_dynesty.py:import numpy as np bilby/core/sampler/dynamic_dynesty.py:from ..utils import logger, check_directory_exists_and_if_not_mkdir bilby/core/sampler/dynamic_dynesty.py:from .base_sampler import Sampler bilby/core/sampler/dynamic_dynesty.py:from .dynesty import Dynesty bilby/core/sampler/dynamic_dynesty.py: skip_import_verification: bool bilby/core/sampler/dynamic_dynesty.py: skip_import_verification=False, check_point=True, n_check_point=None, check_point_delta_t=600, bilby/core/sampler/dynamic_dynesty.py: plot=plot, skip_import_verification=skip_import_verification, bilby/core/sampler/dynamic_dynesty.py: import dynesty bilby/core/sampler/dynesty.py:import datetime bilby/core/sampler/dynesty.py:import dill bilby/core/sampler/dynesty.py:import os bilby/core/sampler/dynesty.py:import sys bilby/core/sampler/dynesty.py:import pickle bilby/core/sampler/dynesty.py:import signal bilby/core/sampler/dynesty.py:import time bilby/core/sampler/dynesty.py:from tqdm.auto import tqdm bilby/core/sampler/dynesty.py:import matplotlib.pyplot as plt bilby/core/sampler/dynesty.py:import numpy as np bilby/core/sampler/dynesty.py:from pandas import DataFrame bilby/core/sampler/dynesty.py:from ..utils import ( bilby/core/sampler/dynesty.py:from .base_sampler import Sampler, NestedSampler bilby/core/sampler/dynesty.py:from ..result import rejection_sample bilby/core/sampler/dynesty.py:from numpy import linalg bilby/core/sampler/dynesty.py:from dynesty.utils import unitcheck bilby/core/sampler/dynesty.py:import warnings bilby/core/sampler/dynesty.py: skip_import_verification: bool bilby/core/sampler/dynesty.py: use_ratio=False, plot=False, skip_import_verification=False, bilby/core/sampler/dynesty.py: plot=plot, skip_import_verification=skip_import_verification, bilby/core/sampler/dynesty.py: import multiprocessing bilby/core/sampler/dynesty.py: import dynesty bilby/core/sampler/dynesty.py: import dynesty bilby/core/sampler/dynesty.py: from ... import __version__ as bilby_version bilby/core/sampler/dynesty.py: from dynesty import __version__ as dynesty_version bilby/core/sampler/dynesty.py: from ... import __version__ as bilby_version bilby/core/sampler/dynesty.py: from dynesty import __version__ as dynesty_version bilby/core/sampler/dynesty.py: import dynesty.plotting as dyplot bilby/core/sampler/dynesty.py: from dynesty import plotting as dyplot bilby/core/sampler/dynesty.py: import dynesty bilby/core/sampler/dynesty.py: import pandas as pd bilby/core/sampler/emcee.py:from collections import namedtuple bilby/core/sampler/emcee.py:import os bilby/core/sampler/emcee.py:import signal bilby/core/sampler/emcee.py:import shutil bilby/core/sampler/emcee.py:from shutil import copyfile bilby/core/sampler/emcee.py:import sys bilby/core/sampler/emcee.py:import numpy as np bilby/core/sampler/emcee.py:from pandas import DataFrame bilby/core/sampler/emcee.py:from distutils.version import LooseVersion bilby/core/sampler/emcee.py:import dill as pickle bilby/core/sampler/emcee.py:from ..utils import logger, check_directory_exists_and_if_not_mkdir bilby/core/sampler/emcee.py:from .base_sampler import MCMCSampler, SamplerError bilby/core/sampler/emcee.py: use_ratio=False, plot=False, skip_import_verification=False, bilby/core/sampler/emcee.py: import emcee bilby/core/sampler/emcee.py: skip_import_verification=skip_import_verification, **kwargs) bilby/core/sampler/emcee.py: import emcee bilby/core/sampler/emcee.py: from tqdm.auto import tqdm bilby/core/sampler/fake_sampler.py:import numpy as np bilby/core/sampler/fake_sampler.py:from .base_sampler import Sampler bilby/core/sampler/fake_sampler.py:from ..result import read_in_result bilby/core/sampler/fake_sampler.py: use_ratio=False, plot=False, skip_import_verification=True, bilby/core/sampler/kombine.py:from ..utils import logger bilby/core/sampler/kombine.py:import numpy as np bilby/core/sampler/kombine.py:import os bilby/core/sampler/kombine.py:from .emcee import Emcee bilby/core/sampler/kombine.py: use_ratio=False, plot=False, skip_import_verification=False, bilby/core/sampler/kombine.py: use_ratio=use_ratio, plot=plot, skip_import_verification=skip_import_verification, bilby/core/sampler/kombine.py: import kombine bilby/core/sampler/kombine.py: from tqdm.auto import tqdm bilby/core/sampler/nestle.py:import numpy as np bilby/core/sampler/nestle.py:from pandas import DataFrame bilby/core/sampler/nestle.py:from .base_sampler import NestedSampler bilby/core/sampler/nestle.py: import nestle bilby/core/sampler/nestle.py: import nestle bilby/core/sampler/nestle.py: import nestle bilby/core/sampler/polychord.py:import numpy as np bilby/core/sampler/polychord.py:from .base_sampler import NestedSampler bilby/core/sampler/polychord.py: import pypolychord bilby/core/sampler/polychord.py: from pypolychord.settings import PolyChordSettings bilby/core/sampler/proposal.py:from collections import OrderedDict bilby/core/sampler/proposal.py:from inspect import isclass bilby/core/sampler/proposal.py:import numpy as np bilby/core/sampler/proposal.py:import random bilby/core/sampler/proposal.py:from ..prior import Uniform bilby/core/sampler/ptemcee.py:import os bilby/core/sampler/ptemcee.py:import datetime bilby/core/sampler/ptemcee.py:import copy bilby/core/sampler/ptemcee.py:import signal bilby/core/sampler/ptemcee.py:import sys bilby/core/sampler/ptemcee.py:import time bilby/core/sampler/ptemcee.py:import dill bilby/core/sampler/ptemcee.py:from collections import namedtuple bilby/core/sampler/ptemcee.py:import logging bilby/core/sampler/ptemcee.py:import numpy as np bilby/core/sampler/ptemcee.py:import pandas as pd bilby/core/sampler/ptemcee.py:import matplotlib.pyplot as plt bilby/core/sampler/ptemcee.py:import scipy.signal bilby/core/sampler/ptemcee.py:from ..utils import logger, check_directory_exists_and_if_not_mkdir bilby/core/sampler/ptemcee.py:from .base_sampler import SamplerError, MCMCSampler bilby/core/sampler/ptemcee.py: skip_import_verification=False, bilby/core/sampler/ptemcee.py: skip_import_verification=skip_import_verification, bilby/core/sampler/ptemcee.py: from scipy.optimize import minimize bilby/core/sampler/ptemcee.py: import ptemcee bilby/core/sampler/ptemcee.py: import schwimmbad bilby/core/sampler/ptemcee.py: import emcee bilby/core/sampler/ptmcmc.py:import glob bilby/core/sampler/ptmcmc.py:import shutil bilby/core/sampler/ptmcmc.py:import numpy as np bilby/core/sampler/ptmcmc.py:from .base_sampler import MCMCSampler, SamplerNotInstalledError bilby/core/sampler/ptmcmc.py:from ..utils import logger bilby/core/sampler/ptmcmc.py: use_ratio=False, plot=False, skip_import_verification=False, bilby/core/sampler/ptmcmc.py: skip_import_verification=skip_import_verification, bilby/core/sampler/ptmcmc.py: # PTMCMC is imported with Caps so need to overwrite the parent function bilby/core/sampler/ptmcmc.py: self.external_sampler = __import__(external_sampler_name) bilby/core/sampler/ptmcmc.py: def _import_external_sampler(): bilby/core/sampler/ptmcmc.py: from PTMCMCSampler import PTMCMCSampler bilby/core/sampler/ptmcmc.py: PTMCMCSampler = self._import_external_sampler() bilby/core/sampler/pymc3.py:from collections import OrderedDict bilby/core/sampler/pymc3.py:from distutils.version import StrictVersion bilby/core/sampler/pymc3.py:import numpy as np bilby/core/sampler/pymc3.py:from ..utils import derivatives, infer_args_from_method bilby/core/sampler/pymc3.py:from ..prior import DeltaFunction, Sine, Cosine, PowerLaw, MultivariateGaussian bilby/core/sampler/pymc3.py:from .base_sampler import MCMCSampler bilby/core/sampler/pymc3.py:from ..likelihood import GaussianLikelihood, PoissonLikelihood, ExponentialLikelihood, \ bilby/core/sampler/pymc3.py:from ...gw.likelihood import BasicGravitationalWaveTransient, GravitationalWaveTransient bilby/core/sampler/pymc3.py: skip_import_verification=False, **kwargs): bilby/core/sampler/pymc3.py: _, STEP_METHODS, _ = self._import_external_sampler() bilby/core/sampler/pymc3.py: skip_import_verification=skip_import_verification, **kwargs) bilby/core/sampler/pymc3.py: def _import_external_sampler(): bilby/core/sampler/pymc3.py: import pymc3 bilby/core/sampler/pymc3.py: from pymc3.sampling import STEP_METHODS bilby/core/sampler/pymc3.py: from pymc3.theanof import floatX bilby/core/sampler/pymc3.py: def _import_theano(): bilby/core/sampler/pymc3.py: import theano # noqa bilby/core/sampler/pymc3.py: import theano.tensor as tt bilby/core/sampler/pymc3.py: from theano.compile.ops import as_op # noqa bilby/core/sampler/pymc3.py: pymc3, STEP_METHODS, floatX = self._import_external_sampler() bilby/core/sampler/pymc3.py: theano, tt, as_op = self._import_theano() bilby/core/sampler/pymc3.py: pymc3, STEP_METHODS, floatX = self._import_external_sampler() bilby/core/sampler/pymc3.py: theano, tt, as_op = self._import_theano() bilby/core/sampler/pymc3.py: pymc3, STEP_METHODS, floatX = self._import_external_sampler() bilby/core/sampler/pymc3.py: theano, tt, as_op = self._import_theano() bilby/core/sampler/pymc3.py: pymc3, STEP_METHODS, floatX = self._import_external_sampler() bilby/core/sampler/pymc3.py: theano, tt, as_op = self._import_theano() bilby/core/sampler/pymc3.py: pymc3, STEP_METHODS, floatX = self._import_external_sampler() bilby/core/sampler/pymc3.py: pymc3, _, _ = self._import_external_sampler() bilby/core/sampler/pymc3.py: pymc3, STEP_METHODS, floatX = self._import_external_sampler() bilby/core/sampler/pymc3.py: pymc3, STEP_METHODS, floatX = self._import_external_sampler() bilby/core/sampler/pymc3.py: theano, tt, as_op = self._import_theano() bilby/core/sampler/pymultinest.py:import importlib bilby/core/sampler/pymultinest.py:import os bilby/core/sampler/pymultinest.py:import shutil bilby/core/sampler/pymultinest.py:import distutils.dir_util bilby/core/sampler/pymultinest.py:import signal bilby/core/sampler/pymultinest.py:import time bilby/core/sampler/pymultinest.py:import datetime bilby/core/sampler/pymultinest.py:import sys bilby/core/sampler/pymultinest.py:import numpy as np bilby/core/sampler/pymultinest.py:from ..utils import check_directory_exists_and_if_not_mkdir bilby/core/sampler/pymultinest.py:from ..utils import logger bilby/core/sampler/pymultinest.py:from .base_sampler import NestedSampler bilby/core/sampler/pymultinest.py: importance_nested_sampling: bool, (False) bilby/core/sampler/pymultinest.py: If true, use importance nested sampling bilby/core/sampler/pymultinest.py: importance_nested_sampling=False, bilby/core/sampler/pymultinest.py: skip_import_verification=False, bilby/core/sampler/pymultinest.py: skip_import_verification=skip_import_verification, bilby/core/sampler/pymultinest.py: import pymultinest bilby/core/sampler/pymultinest.py: pm_run = importlib.import_module("pymultinest.run") bilby/core/sampler/ultranest.py:import datetime bilby/core/sampler/ultranest.py:import distutils.dir_util bilby/core/sampler/ultranest.py:import inspect bilby/core/sampler/ultranest.py:import os bilby/core/sampler/ultranest.py:import shutil bilby/core/sampler/ultranest.py:import signal bilby/core/sampler/ultranest.py:import time bilby/core/sampler/ultranest.py:import numpy as np bilby/core/sampler/ultranest.py:from pandas import DataFrame bilby/core/sampler/ultranest.py:from ..utils import check_directory_exists_and_if_not_mkdir, logger bilby/core/sampler/ultranest.py:from .base_sampler import NestedSampler bilby/core/sampler/ultranest.py: skip_import_verification=False, bilby/core/sampler/ultranest.py: skip_import_verification=skip_import_verification, bilby/core/sampler/ultranest.py: import ultranest bilby/core/sampler/ultranest.py: import ultranest.stepsampler bilby/core/series.py:from . import utils bilby/core/utils.py:from distutils.spawn import find_executable bilby/core/utils.py:import logging bilby/core/utils.py:import os bilby/core/utils.py:import shutil bilby/core/utils.py:import sys bilby/core/utils.py:from math import fmod bilby/core/utils.py:import argparse bilby/core/utils.py:import inspect bilby/core/utils.py:import functools bilby/core/utils.py:import types bilby/core/utils.py:import subprocess bilby/core/utils.py:import multiprocessing bilby/core/utils.py:from importlib import import_module bilby/core/utils.py:import json bilby/core/utils.py:import warnings bilby/core/utils.py:import numpy as np bilby/core/utils.py:from scipy.interpolate import interp2d bilby/core/utils.py:from scipy.special import logsumexp bilby/core/utils.py:import pandas as pd bilby/core/utils.py:import matplotlib.pyplot as plt bilby/core/utils.py: in both functions and methods; this is important, since the first bilby/core/utils.py: available for any script which includes `import bilby`, but no help command bilby/core/utils.py: # Here we import bilby, which initialses and parses the default command-line args bilby/core/utils.py: >>> import bilby bilby/core/utils.py: # Next, we import argparse and define a new argparse object bilby/core/utils.py: >>> import argparse bilby/core/utils.py: from scipy.interpolate.dfitpack import bispeu bilby/core/utils.py: from .prior import MultivariateGaussianDist, Prior, PriorDict bilby/core/utils.py: from ..gw.prior import HealPixMapPriorDist bilby/core/utils.py: from astropy import cosmology as cosmo, units bilby/core/utils.py: logger.debug("Cannot import astropy, cannot write cosmological priors") bilby/core/utils.py: import gzip bilby/core/utils.py: cls = getattr(import_module(dct['__module__']), dct['__name__']) bilby/core/utils.py: cls = getattr(import_module(dct['__module__']), dct['__name__']) bilby/core/utils.py: return getattr(import_module(dct["__module__"]), dct["__name__"], default) bilby/core/utils.py: from astropy import cosmology as cosmo bilby/core/utils.py: logger.debug("Cannot import astropy, cosmological priors may not be " bilby/core/utils.py: from astropy import units bilby/core/utils.py: logger.debug("Cannot import astropy, cosmological priors may not be " bilby/core/utils.py: from matplotlib import rcParams bilby/core/utils.py: from matplotlib import rcParams bilby/core/utils.py: from .prior.dict import PriorDict bilby/core/utils.py: import h5py bilby/gw/__init__.py:from . import (conversion, cosmology, detector, eos, likelihood, prior, bilby/gw/__init__.py:from .waveform_generator import WaveformGenerator bilby/gw/__init__.py:from .likelihood import GravitationalWaveTransient bilby/gw/__init__.py:from .detector import calibration bilby/gw/conversion.py:import sys bilby/gw/conversion.py:import multiprocessing bilby/gw/conversion.py:from tqdm.auto import tqdm bilby/gw/conversion.py:import numpy as np bilby/gw/conversion.py:from pandas import DataFrame bilby/gw/conversion.py:from ..core.likelihood import MarginalizedLikelihoodReconstructionError bilby/gw/conversion.py:from ..core.utils import logger, solar_mass bilby/gw/conversion.py:from ..core.prior import DeltaFunction bilby/gw/conversion.py:from .utils import lalsim_SimInspiralTransformPrecessingNewInitialConditions bilby/gw/conversion.py:from .eos.eos import SpectralDecompositionEOS, EOSFamily, IntegrateTOV bilby/gw/conversion.py:from .cosmology import get_cosmology bilby/gw/conversion.py: from astropy import units bilby/gw/conversion.py: from astropy.cosmology import z_at_value bilby/gw/cosmology.py:from ..core.utils import logger bilby/gw/cosmology.py: from astropy import cosmology as cosmo bilby/gw/detector/__init__.py:from ..conversion import convert_to_lal_binary_black_hole_parameters bilby/gw/detector/__init__.py:from .calibration import * bilby/gw/detector/__init__.py:from .interferometer import * bilby/gw/detector/__init__.py:from .networks import * bilby/gw/detector/__init__.py:from .psd import * bilby/gw/detector/__init__.py:from .strain_data import * bilby/gw/detector/__init__.py: import lal bilby/gw/detector/__init__.py: import lalsimulation as lalsim bilby/gw/detector/calibration.py:import numpy as np bilby/gw/detector/calibration.py:from scipy.interpolate import interp1d bilby/gw/detector/geometry.py:import numpy as np bilby/gw/detector/geometry.py:from .. import utils as gwutils bilby/gw/detector/interferometer.py:import os bilby/gw/detector/interferometer.py:import sys bilby/gw/detector/interferometer.py:import numpy as np bilby/gw/detector/interferometer.py:from matplotlib import pyplot as plt bilby/gw/detector/interferometer.py:from ...core import utils bilby/gw/detector/interferometer.py:from ...core.utils import docstring, logger bilby/gw/detector/interferometer.py:from .. import utils as gwutils bilby/gw/detector/interferometer.py:from ..utils import PropertyAccessor bilby/gw/detector/interferometer.py:from .calibration import Recalibrate bilby/gw/detector/interferometer.py:from .geometry import InterferometerGeometry bilby/gw/detector/interferometer.py:from .strain_data import InterferometerStrainData bilby/gw/detector/interferometer.py: import gwpy bilby/gw/detector/interferometer.py: import gwpy.signal bilby/gw/detector/interferometer.py: import deepdish bilby/gw/detector/interferometer.py: import deepdish bilby/gw/detector/interferometer.py: import dill bilby/gw/detector/interferometer.py: import dill bilby/gw/detector/networks.py:import os bilby/gw/detector/networks.py:import sys bilby/gw/detector/networks.py:import warnings bilby/gw/detector/networks.py:import numpy as np bilby/gw/detector/networks.py:import math bilby/gw/detector/networks.py:from ...core import utils bilby/gw/detector/networks.py:from ...core.utils import logger bilby/gw/detector/networks.py:from .. import utils as gwutils bilby/gw/detector/networks.py:from .interferometer import Interferometer bilby/gw/detector/networks.py:from .psd import PowerSpectralDensity bilby/gw/detector/networks.py:from .strain_data import InterferometerStrainData bilby/gw/detector/networks.py: import deepdish bilby/gw/detector/networks.py: import deepdish bilby/gw/detector/networks.py: import dill bilby/gw/detector/networks.py: import dill bilby/gw/detector/psd.py:import os bilby/gw/detector/psd.py:import numpy as np bilby/gw/detector/psd.py:from scipy.interpolate import interp1d bilby/gw/detector/psd.py:from ...core import utils bilby/gw/detector/psd.py:from ...core.utils import logger bilby/gw/detector/psd.py:from .strain_data import InterferometerStrainData bilby/gw/detector/psd.py: self.__import_amplitude_spectral_density() bilby/gw/detector/psd.py: self.__import_power_spectral_density() bilby/gw/detector/psd.py: def __import_amplitude_spectral_density(self): bilby/gw/detector/psd.py: def __import_power_spectral_density(self): bilby/gw/detector/strain_data.py:import numpy as np bilby/gw/detector/strain_data.py:from scipy.signal.windows import tukey bilby/gw/detector/strain_data.py:from ...core import utils bilby/gw/detector/strain_data.py:from ...core.series import CoupledTimeAndFrequencySeries bilby/gw/detector/strain_data.py:from ...core.utils import logger bilby/gw/detector/strain_data.py:from .. import utils as gwutils bilby/gw/detector/strain_data.py:from ..utils import PropertyAccessor bilby/gw/detector/strain_data.py: import gwpy bilby/gw/detector/strain_data.py: import gwpy.signal bilby/gw/detector/strain_data.py: import lal bilby/gw/detector/strain_data.py: import pycbc bilby/gw/detector/strain_data.py: import pycbc bilby/gw/eos/__init__.py:from .tov_solver import IntegrateTOV bilby/gw/eos/__init__.py:from .eos import (SpectralDecompositionEOS, bilby/gw/eos/eos.py:import os bilby/gw/eos/eos.py:import numpy as np bilby/gw/eos/eos.py:import matplotlib.pyplot as plt bilby/gw/eos/eos.py:from scipy.integrate import cumtrapz, quad bilby/gw/eos/eos.py:from scipy.interpolate import interp1d, CubicSpline bilby/gw/eos/eos.py:from scipy.optimize import minimize_scalar bilby/gw/eos/eos.py:from .tov_solver import IntegrateTOV bilby/gw/eos/eos.py:from ...core import utils bilby/gw/eos/tov_solver.py:import numpy as np bilby/gw/eos/tov_solver.py:from scipy.integrate import solve_ivp bilby/gw/likelihood.py:import gc bilby/gw/likelihood.py:import os bilby/gw/likelihood.py:import json bilby/gw/likelihood.py:import copy bilby/gw/likelihood.py:import numpy as np bilby/gw/likelihood.py:import scipy.integrate as integrate bilby/gw/likelihood.py:from scipy.interpolate import interp1d bilby/gw/likelihood.py: from scipy.special import logsumexp bilby/gw/likelihood.py: from scipy.misc import logsumexp bilby/gw/likelihood.py:from scipy.special import i0e bilby/gw/likelihood.py:from ..core.likelihood import Likelihood bilby/gw/likelihood.py:from ..core.utils import BilbyJsonEncoder, decode_bilby_json bilby/gw/likelihood.py:from ..core.utils import ( bilby/gw/likelihood.py:from ..core.prior import Interped, Prior, Uniform bilby/gw/likelihood.py:from .detector import InterferometerList, get_empty_interferometer bilby/gw/likelihood.py:from .prior import BBHPriorDict, CBCPriorDict, Cosmological bilby/gw/likelihood.py:from .source import lal_binary_black_hole bilby/gw/likelihood.py:from .utils import ( bilby/gw/likelihood.py:from .waveform_generator import WaveformGenerator bilby/gw/likelihood.py:from collections import namedtuple bilby/gw/likelihood.py: from lal import git_version, __version__ bilby/gw/likelihood.py: from lalsimulation import git_version, __version__ bilby/gw/prior.py:import os bilby/gw/prior.py:import copy bilby/gw/prior.py:import numpy as np bilby/gw/prior.py:from scipy.interpolate import InterpolatedUnivariateSpline, interp1d bilby/gw/prior.py:from scipy.integrate import cumtrapz bilby/gw/prior.py:from scipy.special import hyp2f1 bilby/gw/prior.py:from scipy.stats import norm bilby/gw/prior.py:from ..core.prior import (PriorDict, Uniform, Prior, DeltaFunction, Gaussian, bilby/gw/prior.py:from ..core.utils import infer_args_from_method, logger bilby/gw/prior.py:from .conversion import ( bilby/gw/prior.py:from .cosmology import get_cosmology bilby/gw/prior.py: from astropy import cosmology as cosmo, units bilby/gw/prior.py: self.hp = self._check_imports() bilby/gw/prior.py: def _check_imports(): bilby/gw/prior.py: import healpy bilby/gw/result.py:import json bilby/gw/result.py:import pickle bilby/gw/result.py:import os bilby/gw/result.py:import matplotlib.pyplot as plt bilby/gw/result.py:from matplotlib import rcParams bilby/gw/result.py:import numpy as np bilby/gw/result.py:from ..core.result import Result as CoreResult bilby/gw/result.py:from ..core.utils import ( bilby/gw/result.py:from .utils import plot_spline_pos, spline_angle_xform, asd_from_freq_series bilby/gw/result.py:from .detector import get_empty_interferometer, Interferometer bilby/gw/result.py: import plotly.graph_objects as go bilby/gw/result.py: from plotly.offline import plot bilby/gw/result.py: from plotly.subplots import make_subplots bilby/gw/result.py: "HTML plotting requested, but plotly cannot be imported, " bilby/gw/result.py: from astropy.time import Time bilby/gw/result.py: from ligo.skymap import io, version, plot, postprocess, bayestar, kde bilby/gw/result.py: import healpy as hp bilby/gw/sampler/__init__.py:from . import proposal bilby/gw/sampler/proposal.py:import random bilby/gw/sampler/proposal.py:import numpy as np bilby/gw/sampler/proposal.py:from ...core.sampler.proposal import JumpProposal bilby/gw/source.py:import numpy as np bilby/gw/source.py:from ..core import utils bilby/gw/source.py:from ..core.utils import logger bilby/gw/source.py:from .conversion import bilby_to_lalsimulation_spins bilby/gw/source.py:from .utils import (lalsim_GetApproximantFromString, bilby/gw/source.py: import lal bilby/gw/source.py: import lalsimulation as lalsim bilby/gw/utils.py:import os bilby/gw/utils.py:import json bilby/gw/utils.py:from math import fmod bilby/gw/utils.py:import numpy as np bilby/gw/utils.py:from scipy.interpolate import interp1d bilby/gw/utils.py:import matplotlib.pyplot as plt bilby/gw/utils.py:from ..core.utils import (ra_dec_to_theta_phi, bilby/gw/utils.py: from gwpy.timeseries import TimeSeries bilby/gw/utils.py: import lal bilby/gw/utils.py: import lalsimulation as lalsim bilby/gw/utils.py: from ligo.gracedb.rest import GraceDb bilby/gw/waveform_generator.py:import numpy as np bilby/gw/waveform_generator.py:from ..core import utils bilby/gw/waveform_generator.py:from ..core.series import CoupledTimeAndFrequencySeries bilby/gw/waveform_generator.py:from .utils import PropertyAccessor bilby/gw/waveform_generator.py:from .conversion import convert_to_lal_binary_black_hole_parameters bilby/hyper/__init__.py:from . import likelihood, model bilby/hyper/likelihood.py:import logging bilby/hyper/likelihood.py:import numpy as np bilby/hyper/likelihood.py:from ..core.likelihood import Likelihood bilby/hyper/likelihood.py:from .model import Model bilby/hyper/likelihood.py:from ..core.prior import PriorDict bilby/hyper/model.py:from ..core.utils import infer_args_from_function_except_n_args ```