-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General bugfixes & enhancements. (#925)
* wrong Pk2D type should return TypeError * cosmetics * x_out in GNFW profile should trigger interp recomputation * enable flake for constants.py * comprehensive imports & specified __all__ for star-imports * E402 is all over CCL and we silence it every time; get rid of it * fixed typos * document x_out behavior * removed spurious import * remove huge mamba banner from installation output * temporary bugfix for rho0 in HMCalculator * enable func_from_name --> Func.from_name * implemented MassDef.from_name * HMCalculator from strings * removed anti-patterns * clear all temporary vars in Cosmology * combined type checking for * tests for all new features & few fixes * don't even store fastpt; reload time is negligible * more useful error when cosmicemu fails * improved coverage * Address Issue 805. * needs a copy of ccl_params stored in cosmo * removed repeated code * added new func to __all__ * forgot parens * flake * ImportError --> ModuleNotFoundError * make mass_def a required argument * make mass_def a required argument (tests) * reverted integ_interp in HaloProfileGNFW * make mass_def a required argument (more funcs) * bugfix in profiles.py * make sure changes don't break API * flake explicit exception * flake explicit exception * move rho_x calculation one indentation inward * remove checks for Gaussian and PowerLaw profiles Co-authored-by: David Alonso <dam.phys@gmail.com>
- Loading branch information
1 parent
77624d2
commit 96d7b11
Showing
30 changed files
with
503 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,178 @@ | ||
# flake8: noqa | ||
# flake8: noqa E402 | ||
from pkg_resources import get_distribution, DistributionNotFound | ||
try: | ||
__version__ = get_distribution(__name__).version | ||
except DistributionNotFound: | ||
# package is not installed | ||
pass | ||
del get_distribution, DistributionNotFound | ||
|
||
# Sets the environment variable for default config path if it does not | ||
# exist yet | ||
# Set the environment variable for default config path | ||
from os import environ, path | ||
if environ.get("CLASS_PARAM_DIR") is None: | ||
environ["CLASS_PARAM_DIR"] = path.dirname(path.abspath(__file__)) | ||
del environ, path | ||
|
||
# SWIG-generated | ||
from . import ccllib as lib | ||
from . import core, constants, background, power, halomodel, pk2d, tk3d, haloprofile, halos, massfunction, nl_pt | ||
|
||
# Errors | ||
from .errors import ( | ||
CCLError, | ||
CCLWarning, | ||
) | ||
|
||
# Core data structures | ||
from .core import Cosmology, CosmologyVanillaLCDM, CosmologyCalculator | ||
from .core import ( | ||
Cosmology, | ||
CosmologyVanillaLCDM, | ||
CosmologyCalculator, | ||
) | ||
|
||
# Background cosmology functions and growth functions | ||
from .background import growth_factor, growth_factor_unnorm, \ | ||
growth_rate, comoving_radial_distance, angular_diameter_distance, comoving_angular_distance, \ | ||
h_over_h0, luminosity_distance, distance_modulus, scale_factor_of_chi, \ | ||
omega_x, rho_x | ||
from .background import ( | ||
growth_factor, | ||
growth_factor_unnorm, | ||
growth_rate, | ||
comoving_radial_distance, | ||
angular_diameter_distance, | ||
comoving_angular_distance, | ||
luminosity_distance, | ||
distance_modulus, | ||
h_over_h0, | ||
scale_factor_of_chi, | ||
omega_x, | ||
rho_x, | ||
sigma_critical, | ||
) | ||
|
||
# Boltzmann solvers | ||
from .boltzmann import get_camb_pk_lin, get_isitgr_pk_lin, get_class_pk_lin | ||
from .boltzmann import ( | ||
get_camb_pk_lin, | ||
get_isitgr_pk_lin, | ||
get_class_pk_lin, | ||
) | ||
|
||
# Generalized power spectra | ||
from .pk2d import Pk2D, parse_pk2d | ||
from .pk2d import ( | ||
Pk2D, | ||
parse_pk2d, | ||
) | ||
|
||
# Generalized connected trispectra | ||
from .tk3d import Tk3D | ||
|
||
# Power spectrum calculations, sigma8 and kNL | ||
from .power import linear_power, nonlin_power, linear_matter_power, nonlin_matter_power, \ | ||
sigmaR, sigmaV, sigma8, sigmaM, kNL | ||
|
||
# BCM stuff | ||
from .bcm import bcm_model_fka, bcm_correct_pk2d | ||
|
||
# Old halo mass function | ||
from .massfunction import massfunc, halo_bias, massfunc_m2r | ||
|
||
# Cl's and tracers | ||
from .tracers import Tracer, NumberCountsTracer, WeakLensingTracer, CMBLensingTracer, \ | ||
tSZTracer, CIBTracer, ISWTracer, get_density_kernel, get_kappa_kernel, get_lensing_kernel | ||
from .power import ( | ||
linear_power, | ||
nonlin_power, | ||
linear_matter_power, | ||
nonlin_matter_power, | ||
sigmaR, | ||
sigmaV, | ||
sigma8, | ||
sigmaM, | ||
kNL, | ||
) | ||
|
||
# Baryons & Neutrinos | ||
from .bcm import ( | ||
bcm_model_fka, | ||
bcm_correct_pk2d, | ||
) | ||
|
||
from .neutrinos import ( | ||
Omeganuh2, | ||
nu_masses, | ||
) | ||
|
||
# Cells & Tracers | ||
from .cls import angular_cl | ||
from .covariances import angular_cl_cov_cNG, angular_cl_cov_SSC, sigma2_B_disc, sigma2_B_from_mask | ||
|
||
# Useful constants and unit conversions | ||
physical_constants = lib.cvar.constants | ||
|
||
from .tracers import ( | ||
Tracer, | ||
NumberCountsTracer, | ||
WeakLensingTracer, | ||
CMBLensingTracer, | ||
tSZTracer, | ||
CIBTracer, | ||
ISWTracer, | ||
get_density_kernel, | ||
get_kappa_kernel, | ||
get_lensing_kernel, | ||
) | ||
|
||
# Correlations & Covariances | ||
from .correlations import ( | ||
correlation, correlation_3d, correlation_multipole, correlation_3dRsd, | ||
correlation_3dRsd_avgmu, correlation_pi_sigma) | ||
|
||
# Properties of haloes | ||
from .halomodel import ( | ||
halomodel_matter_power, halo_concentration, | ||
onehalo_matter_power, twohalo_matter_power) | ||
|
||
# Halo density profiles | ||
from .haloprofile import nfw_profile_3d, einasto_profile_3d, hernquist_profile_3d, nfw_profile_2d | ||
|
||
# Specific to massive neutrinos | ||
from .neutrinos import Omeganuh2, nu_masses | ||
correlation, | ||
correlation_3d, | ||
correlation_multipole, | ||
correlation_3dRsd, | ||
correlation_3dRsd_avgmu, | ||
correlation_pi_sigma, | ||
) | ||
|
||
from .covariances import ( | ||
angular_cl_cov_cNG, | ||
angular_cl_cov_SSC, | ||
sigma2_B_disc, | ||
sigma2_B_from_mask, | ||
) | ||
|
||
# Parameters | ||
physical_constants = lib.cvar.constants | ||
|
||
# Expose function to toggle debug mode | ||
# Miscellaneous | ||
from .pyutils import debug_mode, resample_array | ||
|
||
from .errors import CCLError, CCLWarning | ||
# Deprecated & Renamed modules | ||
from .halomodel import ( | ||
halomodel_matter_power, | ||
halo_concentration, | ||
onehalo_matter_power, | ||
twohalo_matter_power, | ||
) | ||
|
||
from .massfunction import ( | ||
massfunc, | ||
halo_bias, | ||
massfunc_m2r, | ||
) | ||
|
||
from .haloprofile import ( | ||
nfw_profile_3d, | ||
einasto_profile_3d, | ||
hernquist_profile_3d, | ||
nfw_profile_2d, | ||
) | ||
|
||
|
||
__all__ = ( | ||
'lib', | ||
'physical_constants', | ||
'CCLError', 'CCLWarning', | ||
'Cosmology', 'CosmologyVanillaLCDM', 'CosmologyCalculator', | ||
'growth_factor', 'growth_factor_unnorm', 'growth_rate', | ||
'comoving_radial_distance', 'angular_diameter_distance', | ||
'comoving_angular_distance', 'luminosity_distance', 'distance_modulus', | ||
'h_over_h0', 'scale_factor_of_chi', 'omega_x', 'rho_x', 'sigma_critical', | ||
'get_camb_pk_lin', 'get_isitgr_pk_lin', 'get_class_pk_lin', | ||
'Pk2D', 'parse_pk2d', 'Tk3D', | ||
'linear_power', 'nonlin_power', | ||
'linear_matter_power', 'nonlin_matter_power', | ||
'sigmaR', 'sigmaV', 'sigma8', 'sigmaM', 'kNL', | ||
'bcm_model_fka', 'bcm_correct_pk2d', | ||
'Omeganuh2', 'nu_masses', | ||
'angular_cl', | ||
'Tracer', 'NumberCountsTracer', 'WeakLensingTracer', 'CMBLensingTracer', | ||
'tSZTracer', 'CIBTracer', 'ISWTracer', | ||
'get_density_kernel', 'get_kappa_kernel', 'get_lensing_kernel', | ||
'correlation', 'correlation_3d', 'correlation_multipole', | ||
'correlation_3dRsd', 'correlation_3dRsd_avgmu', 'correlation_pi_sigma', | ||
'angular_cl_cov_cNG', 'angular_cl_cov_SSC', | ||
'sigma2_B_disc', 'sigma2_B_from_mask', | ||
'debug_mode', 'resample_array', | ||
'halomodel_matter_power', 'halo_concentration', | ||
'onehalo_matter_power', 'twohalo_matter_power', | ||
'massfunc', 'halo_bias', 'massfunc_m2r', 'nfw_profile_3d', | ||
'einasto_profile_3d', 'hernquist_profile_3d', 'nfw_profile_2d', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
"""This file exposes constants present in CCL.""" | ||
# flake8: noqa | ||
from .ccllib import ( | ||
CCL_ERROR_CLASS, CCL_ERROR_INCONSISTENT, CCL_ERROR_INTEG, | ||
CCL_ERROR_LINSPACE, CCL_ERROR_MEMORY, CCL_ERROR_ROOT, CCL_ERROR_SPLINE, | ||
CCL_ERROR_SPLINE_EV, CCL_CORR_FFTLOG, CCL_CORR_BESSEL, CCL_CORR_LGNDRE, | ||
CCL_CORR_GG, CCL_CORR_GL, CCL_CORR_LP, CCL_CORR_LM) | ||
|
||
|
||
__all__ = ('CCL_ERROR_CLASS', 'CCL_ERROR_INCONSISTENT', 'CCL_ERROR_INTEG', | ||
'CCL_ERROR_LINSPACE', 'CCL_ERROR_MEMORY', 'CCL_ERROR_ROOT', | ||
'CCL_ERROR_SPLINE', 'CCL_ERROR_SPLINE_EV', 'CCL_CORR_FFTLOG', | ||
'CCL_CORR_BESSEL', 'CCL_CORR_LGNDRE', 'CCL_CORR_GG', 'CCL_CORR_GL', | ||
'CCL_CORR_LP', 'CCL_CORR_LM') |
Oops, something went wrong.