From 4bb09ba9f96c261a633a4ac2b4f7529dbcf549b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Jun 2024 01:57:35 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks --- hierarc/LensPosterior/base_config.py | 10 +- hierarc/LensPosterior/kin_constraints.py | 8 +- .../kin_constraints_composite.py | 13 +-- hierarc/LensPosterior/kin_scaling_config.py | 13 ++- hierarc/Likelihood/cosmo_likelihood.py | 6 +- hierarc/Likelihood/hierarchy_likelihood.py | 84 +++++++++------ hierarc/Likelihood/kin_scaling.py | 37 +++++-- hierarc/Likelihood/lens_sample_likelihood.py | 38 +++---- .../Distributions/anisotropy_distributions.py | 23 ++-- .../Distributions/lens_distribution.py | 84 ++++++++------- .../test_kin_constraints_composite.py | 28 +++-- test/test_Likelihood/test_cosmo_likelihood.py | 24 +++-- .../test_hierarchy_likelihood.py | 29 ++--- test/test_Likelihood/test_kin_scaling.py | 101 ++++++++++-------- .../test_anisotropy_distribution.py | 47 +++++--- .../test_lens_distribution.py | 62 ++++++----- test/test_Sampling/test_mcmc_sampling.py | 14 +-- 17 files changed, 365 insertions(+), 256 deletions(-) diff --git a/hierarc/LensPosterior/base_config.py b/hierarc/LensPosterior/base_config.py index 258c12f..ee39e43 100644 --- a/hierarc/LensPosterior/base_config.py +++ b/hierarc/LensPosterior/base_config.py @@ -109,6 +109,10 @@ def __init__( ImageModelPosterior.__init__( self, theta_E, theta_E_error, gamma, gamma_error, r_eff, r_eff_error ) - KinScalingConfig.__init__(self, anisotropy_model, r_eff, - gamma_in_scaling=gamma_in_scaling, - log_m2l_scaling=log_m2l_scaling) + KinScalingConfig.__init__( + self, + anisotropy_model, + r_eff, + gamma_in_scaling=gamma_in_scaling, + log_m2l_scaling=log_m2l_scaling, + ) diff --git a/hierarc/LensPosterior/kin_constraints.py b/hierarc/LensPosterior/kin_constraints.py index 7bae1ea..15cf2a9 100644 --- a/hierarc/LensPosterior/kin_constraints.py +++ b/hierarc/LensPosterior/kin_constraints.py @@ -180,7 +180,6 @@ def hierarchy_configuration(self, num_sample_model=20): "kin_scaling_param_list": self.param_name_list, "j_kin_scaling_param_axes": self.kin_scaling_param_array, "j_kin_scaling_grid_list": ani_scaling_array_list, - } return kwargs_likelihood @@ -253,7 +252,12 @@ def _anisotropy_scaling_relative(self, j_ani_0): if self._anisotropy_model == "GOM": ani_scaling_array_list = [ - np.zeros((len(self.kin_scaling_param_array[0]), len(self.kin_scaling_param_array[1]))) + np.zeros( + ( + len(self.kin_scaling_param_array[0]), + len(self.kin_scaling_param_array[1]), + ) + ) for _ in range(num_data) ] for i, a_ani in enumerate(self.kin_scaling_param_array[0]): diff --git a/hierarc/LensPosterior/kin_constraints_composite.py b/hierarc/LensPosterior/kin_constraints_composite.py index 99e8711..60bcc14 100644 --- a/hierarc/LensPosterior/kin_constraints_composite.py +++ b/hierarc/LensPosterior/kin_constraints_composite.py @@ -400,21 +400,18 @@ def hierarchy_configuration(self, num_sample_model=20): "j_model": j_model_list, "error_cov_measurement": error_cov_measurement, "error_cov_j_sqrt": error_cov_j_sqrt, - - #"ani_param_array": self.kin_scaling_param_array, - #"gamma_in_array": self.gamma_in_array, - #"log_m2l_array": self.log_m2l_array, - #"param_scaling_grid_list": ani_scaling_grid_list, - + # "ani_param_array": self.kin_scaling_param_array, + # "gamma_in_array": self.gamma_in_array, + # "log_m2l_array": self.log_m2l_array, + # "param_scaling_grid_list": ani_scaling_grid_list, "gamma_in_prior_mean": self._gamma_in_prior_mean, "gamma_in_prior_std": self._gamma_in_prior_std, - "kin_scaling_param_list": self.param_name_list, "j_kin_scaling_param_axes": self.kin_scaling_param_array, "j_kin_scaling_grid_list": ani_scaling_grid_list, } - #if not self._is_m2l_population_level: + # if not self._is_m2l_population_level: # kwargs_likelihood["log_m2l_array"] = None return kwargs_likelihood diff --git a/hierarc/LensPosterior/kin_scaling_config.py b/hierarc/LensPosterior/kin_scaling_config.py index 8a51b2a..d6979f3 100644 --- a/hierarc/LensPosterior/kin_scaling_config.py +++ b/hierarc/LensPosterior/kin_scaling_config.py @@ -5,7 +5,9 @@ class KinScalingConfig(object): """Class to manage the anisotropy model and parameters for the Posterior processing.""" - def __init__(self, anisotropy_model, r_eff, gamma_in_scaling=None, log_m2l_scaling=None): + def __init__( + self, anisotropy_model, r_eff, gamma_in_scaling=None, log_m2l_scaling=None + ): """ :param anisotropy_model: type of stellar anisotropy model. Supported are 'OM' and 'GOM' or 'const', see details in lenstronomy.Galkin module @@ -28,10 +30,12 @@ def __init__(self, anisotropy_model, r_eff, gamma_in_scaling=None, log_m2l_scali ] self._param_name_list = ["a_ani", "beta_inf"] elif self._anisotropy_model == "const": - self._ani_param_array = [np.linspace(-0.49, 1, 7)] # used for constant anisotropy description + self._ani_param_array = [ + np.linspace(-0.49, 1, 7) + ] # used for constant anisotropy description self._param_name_list = ["a_ani"] elif self._anisotropy_model == "NONE": - self._param_name_list =[] + self._param_name_list = [] else: raise ValueError( "anisotropy model %s not supported." % self._anisotropy_model @@ -77,8 +81,7 @@ def kin_scaling_param_array(self): @property def param_name_list(self): - """ - list of parameters in same order as interpolated + """List of parameters in same order as interpolated. :return: """ diff --git a/hierarc/Likelihood/cosmo_likelihood.py b/hierarc/Likelihood/cosmo_likelihood.py index f900cbf..8ad2a06 100644 --- a/hierarc/Likelihood/cosmo_likelihood.py +++ b/hierarc/Likelihood/cosmo_likelihood.py @@ -60,11 +60,7 @@ def __init__( normalized=normalized, kwargs_global_model=kwargs_model, ) - self.param = ParamManager( - cosmology, - **kwargs_model, - **kwargs_bounds - ) + self.param = ParamManager(cosmology, **kwargs_model, **kwargs_bounds) self._lower_limit, self._upper_limit = self.param.param_bounds self._prior_add = False if custom_prior is not None: diff --git a/hierarc/Likelihood/hierarchy_likelihood.py b/hierarc/Likelihood/hierarchy_likelihood.py index 2b5aaf7..16ba54f 100644 --- a/hierarc/Likelihood/hierarchy_likelihood.py +++ b/hierarc/Likelihood/hierarchy_likelihood.py @@ -2,7 +2,9 @@ from hierarc.Likelihood.LensLikelihood.base_lens_likelihood import LensLikelihoodBase from hierarc.Likelihood.kin_scaling import KinScaling from hierarc.Sampling.Distributions.los_distributions import LOSDistribution -from hierarc.Sampling.Distributions.anisotropy_distributions import AnisotropyDistribution +from hierarc.Sampling.Distributions.anisotropy_distributions import ( + AnisotropyDistribution, +) from hierarc.Sampling.Distributions.lens_distribution import LensDistribution import numpy as np import copy @@ -94,11 +96,12 @@ def __init__( """ TransformedCosmography.__init__(self, z_lens=z_lens, z_source=z_source) - KinScaling.__init__(self, - j_kin_scaling_param_axes=j_kin_scaling_param_axes, - j_kin_scaling_grid_list=j_kin_scaling_grid_list, - j_kin_scaling_param_name_list=kin_scaling_param_list - ) + KinScaling.__init__( + self, + j_kin_scaling_param_axes=j_kin_scaling_param_axes, + j_kin_scaling_grid_list=j_kin_scaling_grid_list, + j_kin_scaling_param_name_list=kin_scaling_param_list, + ) LensLikelihoodBase.__init__( self, @@ -119,28 +122,32 @@ def __init__( los_distributions=los_distributions, ) kwargs_min, kwargs_max = self.param_bounds_interpol() - self._lens_distribution = LensDistribution(lambda_mst_sampling=False, - lambda_mst_distribution=lambda_mst_distribution, - gamma_in_sampling=gamma_in_sampling, - gamma_in_distribution=gamma_in_distribution, - log_m2l_sampling=log_m2l_sampling, - log_m2l_distribution=log_m2l_distribution, - alpha_lambda_sampling=alpha_lambda_sampling, - beta_lambda_sampling=beta_lambda_sampling, - alpha_gamma_in_sampling=alpha_gamma_in_sampling, - alpha_log_m2l_sampling=alpha_log_m2l_sampling, - log_scatter=log_scatter, - mst_ifu=mst_ifu, - lambda_scaling_property=lambda_scaling_property, - lambda_scaling_property_beta=lambda_scaling_property_beta, - kwargs_min=kwargs_min, - kwargs_max=kwargs_max,) - - self._aniso_distribution = AnisotropyDistribution(anisotropy_model=anisotropy_model, - anisotropy_sampling=anisotropy_sampling, - distribution_function=anisotroy_distribution_function, - kwargs_anisotropy_min=kwargs_min, - kwargs_anisotropy_max=kwargs_max) + self._lens_distribution = LensDistribution( + lambda_mst_sampling=False, + lambda_mst_distribution=lambda_mst_distribution, + gamma_in_sampling=gamma_in_sampling, + gamma_in_distribution=gamma_in_distribution, + log_m2l_sampling=log_m2l_sampling, + log_m2l_distribution=log_m2l_distribution, + alpha_lambda_sampling=alpha_lambda_sampling, + beta_lambda_sampling=beta_lambda_sampling, + alpha_gamma_in_sampling=alpha_gamma_in_sampling, + alpha_log_m2l_sampling=alpha_log_m2l_sampling, + log_scatter=log_scatter, + mst_ifu=mst_ifu, + lambda_scaling_property=lambda_scaling_property, + lambda_scaling_property_beta=lambda_scaling_property_beta, + kwargs_min=kwargs_min, + kwargs_max=kwargs_max, + ) + + self._aniso_distribution = AnisotropyDistribution( + anisotropy_model=anisotropy_model, + anisotropy_sampling=anisotropy_sampling, + distribution_function=anisotroy_distribution_function, + kwargs_anisotropy_min=kwargs_min, + kwargs_anisotropy_max=kwargs_max, + ) self._gamma_in_prior_mean = gamma_in_prior_mean self._gamma_in_prior_std = gamma_in_prior_std @@ -278,7 +285,10 @@ def log_likelihood_single( realization of the hyperparameter distribution """ kwargs_lens_draw = self._lens_distribution.draw_lens(**kwargs_lens) - lambda_mst, gamma_ppn = kwargs_lens_draw["lambda_mst"], kwargs_lens_draw["gamma_ppn"] + lambda_mst, gamma_ppn = ( + kwargs_lens_draw["lambda_mst"], + kwargs_lens_draw["gamma_ppn"], + ) kappa_ext = self._los.draw_los(kwargs_los) # draw intrinsic source magnitude @@ -309,9 +319,9 @@ def log_likelihood_single( and "gamma_in" in kwargs_lens_draw ): gamma_in = kwargs_lens_draw["gamma_in"] - lnlikelihood -= ( - self._gamma_in_prior_mean - gamma_in - ) ** 2 / (2 * self._gamma_in_prior_std**2) + lnlikelihood -= (self._gamma_in_prior_mean - gamma_in) ** 2 / ( + 2 * self._gamma_in_prior_std**2 + ) return np.nan_to_num(lnlikelihood) @@ -433,7 +443,10 @@ def sigma_v_measured_vs_predict( cov_error_predict = np.zeros_like(cov_error_measurement) for i in range(self._num_distribution_draws): kwargs_lens_draw = self._lens_distribution.draw_lens(**kwargs_lens) - lambda_mst, gamma_ppn = kwargs_lens_draw["lambda_mst"], kwargs_lens_draw["gamma_ppn"] + lambda_mst, gamma_ppn = ( + kwargs_lens_draw["lambda_mst"], + kwargs_lens_draw["gamma_ppn"], + ) kappa_ext = self._los.draw_los(kwargs_los) ddt_, dd_, _ = self.displace_prediction( ddt, dd, gamma_ppn=gamma_ppn, lambda_mst=lambda_mst, kappa_ext=kappa_ext @@ -478,7 +491,10 @@ def ddt_dd_model_prediction(self, cosmo, kwargs_lens=None, kwargs_los=None): dd_draws = [] for i in range(self._num_distribution_draws): kwargs_lens_draw = self._lens_distribution.draw_lens(**kwargs_lens) - lambda_mst, gamma_ppn = kwargs_lens_draw["lambda_mst"], kwargs_lens_draw["gamma_ppn"] + lambda_mst, gamma_ppn = ( + kwargs_lens_draw["lambda_mst"], + kwargs_lens_draw["gamma_ppn"], + ) kappa_ext = self._los.draw_los(kwargs_los) ddt_, dd_, _ = self.displace_prediction( ddt, dd, gamma_ppn=gamma_ppn, lambda_mst=lambda_mst, kappa_ext=kappa_ext diff --git a/hierarc/Likelihood/kin_scaling.py b/hierarc/Likelihood/kin_scaling.py index f016adf..40e75f5 100644 --- a/hierarc/Likelihood/kin_scaling.py +++ b/hierarc/Likelihood/kin_scaling.py @@ -26,9 +26,13 @@ def __init__(self, param_grid_axes, j_kin_scaling_grid): param_grid_axes = [param_grid_axes] if self._dim_scaling == 1: - self._f_ani = interp1d(param_grid_axes[0], j_kin_scaling_grid, kind="linear") + self._f_ani = interp1d( + param_grid_axes[0], j_kin_scaling_grid, kind="linear" + ) elif self._dim_scaling == 2: - self._f_ani = interp2d(param_grid_axes[0], param_grid_axes[1], j_kin_scaling_grid.T) + self._f_ani = interp2d( + param_grid_axes[0], param_grid_axes[1], j_kin_scaling_grid.T + ) else: self._f_ani = RegularGridInterpolator( tuple(param_grid_axes), @@ -57,7 +61,10 @@ class KinScaling(object): """Class to manage model parameter and anisotropy scalings for IFU data.""" def __init__( - self, j_kin_scaling_param_axes=None, j_kin_scaling_grid_list=None, j_kin_scaling_param_name_list=None + self, + j_kin_scaling_param_axes=None, + j_kin_scaling_grid_list=None, + j_kin_scaling_param_name_list=None, ): """ @@ -71,7 +78,10 @@ def __init__( else: self._param_list = j_kin_scaling_param_name_list self._param_arrays = j_kin_scaling_param_axes - if not isinstance(j_kin_scaling_param_axes, list) and j_kin_scaling_param_name_list is not None: + if ( + not isinstance(j_kin_scaling_param_axes, list) + and j_kin_scaling_param_name_list is not None + ): self._param_arrays = [j_kin_scaling_param_axes] self._evaluate_scaling = False self._is_log_m2l_population_level = False @@ -85,7 +95,9 @@ def __init__( self._f_ani_list = [] for scaling_grid in j_kin_scaling_grid_list: self._j_scaling_ifu.append( - ParameterScalingSingleMeasurement(j_kin_scaling_param_axes, scaling_grid) + ParameterScalingSingleMeasurement( + j_kin_scaling_param_axes, scaling_grid + ) ) if isinstance(j_kin_scaling_param_axes, list): @@ -94,22 +106,25 @@ def __init__( self._dim_scaling = 1 def _kwargs2param_array(self, kwargs): - """ - converts dictionary to sorted array in same order as interpolation grid + """Converts dictionary to sorted array in same order as interpolation grid. - :param kwargs: dictionary of all model components, must include the one that are interpolated + :param kwargs: dictionary of all model components, must include the one that are + interpolated :return: sorted list of parameters to interpolate """ param_array = [] for param in self._param_list: if param not in kwargs: - raise ValueError("key %s not in parameters and hence kinematic scaling not possible" % param) + raise ValueError( + "key %s not in parameters and hence kinematic scaling not possible" + % param + ) param_array.append(kwargs.get(param)) return param_array def param_bounds_interpol(self): - """ - minimum and maximum bounds of parameters that are being used to call interpolation function + """Minimum and maximum bounds of parameters that are being used to call + interpolation function. :return: dictionaries of minimum and maximum bounds """ diff --git a/hierarc/Likelihood/lens_sample_likelihood.py b/hierarc/Likelihood/lens_sample_likelihood.py index d168b09..a8e1431 100644 --- a/hierarc/Likelihood/lens_sample_likelihood.py +++ b/hierarc/Likelihood/lens_sample_likelihood.py @@ -29,11 +29,10 @@ def __init__(self, kwargs_lens_list, normalized=False, kwargs_global_model=None) DSPLikelihood(normalized=normalized, **_kwargs_lens) ) else: - kwargs_lens_ = self._merge_global2local_settings(kwargs_global_model=kwargs_global_model, - kwargs_lens=kwargs_lens) - self._lens_list.append( - LensLikelihood(**kwargs_lens_) + kwargs_lens_ = self._merge_global2local_settings( + kwargs_global_model=kwargs_global_model, kwargs_lens=kwargs_lens ) + self._lens_list.append(LensLikelihood(**kwargs_lens_)) def log_likelihood( self, @@ -91,18 +90,19 @@ def _merge_global2local_settings(kwargs_global_model, kwargs_lens): return {**kwargs_global_model_subset, **kwargs_lens} -_input_param_list = ["anisotropy_model", - "anisotropy_sampling", - "anisotroy_distribution_function", - "los_distributions", - "lambda_mst_distribution", - "gamma_in_sampling", - "gamma_in_distribution", - "log_m2l_sampling", - "log_m2l_distribution", - "alpha_lambda_sampling", - "beta_lambda_sampling", - "alpha_gamma_in_sampling", - "alpha_log_m2l_sampling", - "log_scatter" - ] +_input_param_list = [ + "anisotropy_model", + "anisotropy_sampling", + "anisotroy_distribution_function", + "los_distributions", + "lambda_mst_distribution", + "gamma_in_sampling", + "gamma_in_distribution", + "log_m2l_sampling", + "log_m2l_distribution", + "alpha_lambda_sampling", + "beta_lambda_sampling", + "alpha_gamma_in_sampling", + "alpha_log_m2l_sampling", + "log_scatter", +] diff --git a/hierarc/Sampling/Distributions/anisotropy_distributions.py b/hierarc/Sampling/Distributions/anisotropy_distributions.py index c5f92a0..1050a1f 100644 --- a/hierarc/Sampling/Distributions/anisotropy_distributions.py +++ b/hierarc/Sampling/Distributions/anisotropy_distributions.py @@ -2,11 +2,16 @@ class AnisotropyDistribution(object): - """ - class to draw anisotropy parameters from hyperparameter distributions - """ - def __init__(self, anisotropy_model, anisotropy_sampling, - distribution_function, kwargs_anisotropy_min, kwargs_anisotropy_max): + """Class to draw anisotropy parameters from hyperparameter distributions.""" + + def __init__( + self, + anisotropy_model, + anisotropy_sampling, + distribution_function, + kwargs_anisotropy_min, + kwargs_anisotropy_max, + ): """ :param anisotropy_model: string, name of anisotropy model to consider @@ -25,11 +30,15 @@ def __init__(self, anisotropy_model, anisotropy_sampling, kwargs_anisotropy_max = {} self._kwargs_min = kwargs_anisotropy_min self._kwargs_max = kwargs_anisotropy_max - self._a_ani_min, self._a_ani_max = self._kwargs_min.get("a_ani", -np.inf), self._kwargs_max.get("a_ani", np.inf) + self._a_ani_min, self._a_ani_max = self._kwargs_min.get( + "a_ani", -np.inf + ), self._kwargs_max.get("a_ani", np.inf) self._beta_inf_min = self._kwargs_min.get("beta_inf", -np.inf) self._beta_inf_max = self._kwargs_max.get("beta_inf", np.inf) - def draw_anisotropy(self, a_ani=None, a_ani_sigma=0, beta_inf=None, beta_inf_sigma=0): + def draw_anisotropy( + self, a_ani=None, a_ani_sigma=0, beta_inf=None, beta_inf_sigma=0 + ): """Draw Gaussian distribution and re-sample if outside bounds. :param a_ani: mean of the distribution diff --git a/hierarc/Sampling/Distributions/lens_distribution.py b/hierarc/Sampling/Distributions/lens_distribution.py index dd1c273..0c98b16 100644 --- a/hierarc/Sampling/Distributions/lens_distribution.py +++ b/hierarc/Sampling/Distributions/lens_distribution.py @@ -2,9 +2,7 @@ class LensDistribution(object): - """ - class to draw lens parameters of individual lens from distributions - """ + """Class to draw lens parameters of individual lens from distributions.""" def __init__( self, @@ -74,8 +72,12 @@ def __init__( kwargs_max = {} if kwargs_min is None: kwargs_min = {} - self._gamma_in_min, self._gamma_in_max = kwargs_min.get("gamma_in", -np.inf), kwargs_max.get("gamma_in", np.inf) - self._log_m2l_min, self._log_m2l_max = kwargs_min.get("log_m2l", -np.inf), kwargs_max.get("log_m2l", np.inf) + self._gamma_in_min, self._gamma_in_max = kwargs_min.get( + "gamma_in", -np.inf + ), kwargs_max.get("gamma_in", np.inf) + self._log_m2l_min, self._log_m2l_max = kwargs_min.get( + "log_m2l", -np.inf + ), kwargs_max.get("log_m2l", np.inf) def draw_lens( self, @@ -93,8 +95,7 @@ def draw_lens( log_m2l_sigma=0, alpha_log_m2l=0, ): - """Draws a realization of a specific model from the hyperparameter - distribution. + """Draws a realization of a specific model from the hyperparameter distribution. :param lambda_mst: MST transform :param lambda_mst_sigma: spread in the distribution @@ -124,10 +125,11 @@ def draw_lens( else: lambda_mst_mean_lens = lambda_mst - lambda_lens = (lambda_mst_mean_lens - + alpha_lambda * self._lambda_scaling_property - + beta_lambda * self._lambda_scaling_property_beta - ) + lambda_lens = ( + lambda_mst_mean_lens + + alpha_lambda * self._lambda_scaling_property + + beta_lambda * self._lambda_scaling_property_beta + ) lambda_mst_draw = lambda_lens if self._lambda_mst_sampling: if self._lambda_mst_distribution in ["GAUSSIAN"]: @@ -142,24 +144,28 @@ def draw_lens( "gamma_in parameter is out of bounds of the interpolated range!" ) if self._gamma_in_distribution in ["GAUSSIAN"]: - gamma_in_lens = gamma_in + alpha_gamma_in * self._lambda_scaling_property + gamma_in_lens = ( + gamma_in + alpha_gamma_in * self._lambda_scaling_property + ) else: gamma_in_lens = gamma_in gamma_in_draw = np.random.normal(gamma_in_lens, gamma_in_sigma) if gamma_in_draw < self._gamma_in_min or gamma_in_draw > self._gamma_in_max: - return self.draw_lens(lambda_mst=lambda_mst, - lambda_mst_sigma=lambda_mst_sigma, - gamma_ppn=gamma_ppn, - lambda_ifu=lambda_ifu, - lambda_ifu_sigma=lambda_ifu_sigma, - alpha_lambda=alpha_lambda, - beta_lambda=beta_lambda, - gamma_in=gamma_in, - gamma_in_sigma=gamma_in_sigma, - alpha_gamma_in=alpha_gamma_in, - log_m2l=log_m2l, - log_m2l_sigma=log_m2l_sigma, - alpha_log_m2l=alpha_log_m2l) + return self.draw_lens( + lambda_mst=lambda_mst, + lambda_mst_sigma=lambda_mst_sigma, + gamma_ppn=gamma_ppn, + lambda_ifu=lambda_ifu, + lambda_ifu_sigma=lambda_ifu_sigma, + alpha_lambda=alpha_lambda, + beta_lambda=beta_lambda, + gamma_in=gamma_in, + gamma_in_sigma=gamma_in_sigma, + alpha_gamma_in=alpha_gamma_in, + log_m2l=log_m2l, + log_m2l_sigma=log_m2l_sigma, + alpha_log_m2l=alpha_log_m2l, + ) kwargs_return["gamma_in"] = gamma_in_draw if self._log_m2l_sampling: @@ -172,18 +178,20 @@ def draw_lens( log_m2l_draw = np.random.normal(log_m2l_lens, log_m2l_sigma) if log_m2l_draw < self._log_m2l_min or log_m2l_draw > self._log_m2l_max: - return self.draw_lens(lambda_mst=lambda_mst, - lambda_mst_sigma=lambda_mst_sigma, - gamma_ppn=gamma_ppn, - lambda_ifu=lambda_ifu, - lambda_ifu_sigma=lambda_ifu_sigma, - alpha_lambda=alpha_lambda, - beta_lambda=beta_lambda, - gamma_in=gamma_in, - gamma_in_sigma=gamma_in_sigma, - alpha_gamma_in=alpha_gamma_in, - log_m2l=log_m2l, - log_m2l_sigma=log_m2l_sigma, - alpha_log_m2l=alpha_log_m2l) + return self.draw_lens( + lambda_mst=lambda_mst, + lambda_mst_sigma=lambda_mst_sigma, + gamma_ppn=gamma_ppn, + lambda_ifu=lambda_ifu, + lambda_ifu_sigma=lambda_ifu_sigma, + alpha_lambda=alpha_lambda, + beta_lambda=beta_lambda, + gamma_in=gamma_in, + gamma_in_sigma=gamma_in_sigma, + alpha_gamma_in=alpha_gamma_in, + log_m2l=log_m2l, + log_m2l_sigma=log_m2l_sigma, + alpha_log_m2l=alpha_log_m2l, + ) kwargs_return["log_m2l"] = log_m2l_draw return kwargs_return diff --git a/test/test_LensPosterior/test_kin_constraints_composite.py b/test/test_LensPosterior/test_kin_constraints_composite.py index f99c616..5b7b779 100644 --- a/test/test_LensPosterior/test_kin_constraints_composite.py +++ b/test/test_LensPosterior/test_kin_constraints_composite.py @@ -104,9 +104,13 @@ def test_likelihoodconfiguration_om(self): kwargs_likelihood = kin_constraints.hierarchy_configuration(num_sample_model=5) kwargs_likelihood["normalized"] = False - ln_class = LensLikelihood(gamma_in_sampling=True, log_m2l_sampling=True, **kwargs_likelihood) + ln_class = LensLikelihood( + gamma_in_sampling=True, log_m2l_sampling=True, **kwargs_likelihood + ) kwargs_kin = {"a_ani": 1} - ln_class.lens_log_likelihood(cosmo, kwargs_lens={"gamma_in": 2, "log_m2l": 1}, kwargs_kin=kwargs_kin) + ln_class.lens_log_likelihood( + cosmo, kwargs_lens={"gamma_in": 2, "log_m2l": 1}, kwargs_kin=kwargs_kin + ) kwargs_lens_light_test = [{"amp": [1, 1], "sigma": [1, 2]}] lens_light_model_list_test = ["MULTI_GAUSSIAN"] @@ -256,9 +260,13 @@ def test_likelihoodconfiguration_gom(self): kwargs_likelihood = kin_constraints.hierarchy_configuration(num_sample_model=5) kwargs_likelihood["normalized"] = False - ln_class = LensLikelihood(gamma_in_sampling=True, log_m2l_sampling=True, **kwargs_likelihood) + ln_class = LensLikelihood( + gamma_in_sampling=True, log_m2l_sampling=True, **kwargs_likelihood + ) kwargs_kin = {"a_ani": 1, "beta_inf": 0.5} - ln_class.lens_log_likelihood(cosmo, kwargs_lens={"gamma_in": 2, "log_m2l": 1}, kwargs_kin=kwargs_kin) + ln_class.lens_log_likelihood( + cosmo, kwargs_lens={"gamma_in": 2, "log_m2l": 1}, kwargs_kin=kwargs_kin + ) class TestKinConstraintsCompositeM2l(object): @@ -360,9 +368,13 @@ def test_likelihoodconfiguration_om(self): kwargs_likelihood = kin_constraints.hierarchy_configuration(num_sample_model=5) kwargs_likelihood["normalized"] = False - ln_class = LensLikelihood(gamma_in_sampling=True, log_m2l_sampling=False, **kwargs_likelihood) + ln_class = LensLikelihood( + gamma_in_sampling=True, log_m2l_sampling=False, **kwargs_likelihood + ) kwargs_kin = {"a_ani": 1} - ln_class.lens_log_likelihood(cosmo, kwargs_lens={"gamma_in": 2, "log_m2l": 0}, kwargs_kin=kwargs_kin) + ln_class.lens_log_likelihood( + cosmo, kwargs_lens={"gamma_in": 2, "log_m2l": 0}, kwargs_kin=kwargs_kin + ) def test_likelihoodconfiguration_gom(self): anisotropy_model = "GOM" @@ -457,7 +469,9 @@ def test_likelihoodconfiguration_gom(self): kwargs_likelihood["normalized"] = False ln_class = LensLikelihood(gamma_in_sampling=True, **kwargs_likelihood) kwargs_kin = {"a_ani": 1, "beta_inf": 0.5} - ln_class.lens_log_likelihood(cosmo, kwargs_lens={"gamma_in": 2}, kwargs_kin=kwargs_kin) + ln_class.lens_log_likelihood( + cosmo, kwargs_lens={"gamma_in": 2}, kwargs_kin=kwargs_kin + ) class TestRaise(unittest.TestCase): diff --git a/test/test_Likelihood/test_cosmo_likelihood.py b/test/test_Likelihood/test_cosmo_likelihood.py index aa86363..fcbd2fc 100644 --- a/test/test_Likelihood/test_cosmo_likelihood.py +++ b/test/test_Likelihood/test_cosmo_likelihood.py @@ -57,11 +57,13 @@ def setup_method(self): "kwargs_lower_cosmo": kwargs_lower_cosmo, "kwargs_upper_cosmo": kwargs_upper_cosmo, } - self.kwargs_model = {"ppn_sampling": False, - "lambda_mst_sampling": False, - "lambda_mst_distribution": "delta", - "anisotropy_sampling": False, - "anisotropy_model": "OM",} + self.kwargs_model = { + "ppn_sampling": False, + "lambda_mst_sampling": False, + "lambda_mst_distribution": "delta", + "anisotropy_sampling": False, + "anisotropy_model": "OM", + } # self.kwargs_likelihood_list = [{'z_lens': self.z_L, 'z_source': self.z_S, 'likelihood_type': 'TDKinKDE', # 'dd_sample': self.dd_samples, 'ddt_sample': self.ddt_samples, @@ -79,7 +81,9 @@ def test_log_likelihood(self): cosmo_fixed=None, ) - def custom_prior(kwargs_cosmo, kwargs_lens, kwargs_kin, kwargs_source, kwargs_los): + def custom_prior( + kwargs_cosmo, kwargs_lens, kwargs_kin, kwargs_source, kwargs_los + ): return -1 cosmoL_prior = CosmoLikelihood( @@ -241,8 +245,12 @@ def test_kde_likelihood_integration(self): self.cosmology, rescale=True, ) - cosmoL = CosmoLikelihood([], "FLCDM", self.kwargs_model, - self.kwargs_bounds, KDE_likelihood_chain=chain + cosmoL = CosmoLikelihood( + [], + "FLCDM", + self.kwargs_model, + self.kwargs_bounds, + KDE_likelihood_chain=chain, ) kwargs_cosmo = {"h0": self.H0_true, "om": self.omega_m_true, "ok": 0} args = cosmoL.param.kwargs2args(kwargs_cosmo=kwargs_cosmo) diff --git a/test/test_Likelihood/test_hierarchy_likelihood.py b/test/test_Likelihood/test_hierarchy_likelihood.py index f17c828..f89e8a2 100644 --- a/test/test_Likelihood/test_hierarchy_likelihood.py +++ b/test/test_Likelihood/test_hierarchy_likelihood.py @@ -24,16 +24,16 @@ def setup_method(self): "dd_mean": dd, "dd_sigma": dd / 10, } - kwargs_model = {"anisotropy_model": "OM", - "anisotropy_sampling": True, - "anisotroy_distribution_function": "GAUSSIAN", - "lambda_mst_distribution": "GAUSSIAN", - } + kwargs_model = { + "anisotropy_model": "OM", + "anisotropy_sampling": True, + "anisotroy_distribution_function": "GAUSSIAN", + "lambda_mst_distribution": "GAUSSIAN", + } # "gamma_in_sampling" = False, - gamma_in_distribution = "NONE", - log_m2l_sampling = False, - log_m2l_distribution = "NONE", - + gamma_in_distribution = ("NONE",) + log_m2l_sampling = (False,) + log_m2l_distribution = ("NONE",) self.likelihood = LensLikelihood( z_lens, @@ -134,7 +134,9 @@ def setup_method(self): **kwargs_model ) - param_scaling_array = np.outer(np.ones_like(gamma_in_array), np.ones_like(log_m2l_array)) + param_scaling_array = np.outer( + np.ones_like(gamma_in_array), np.ones_like(log_m2l_array) + ) j_kin_scaling_param_axes = [gamma_in_array, log_m2l_array] @@ -239,7 +241,6 @@ def test_lens_log_likelihood(self): kwargs_test = self.likelihood._kwargs_init(kwargs=None) assert type(kwargs_test) is dict - kwargs_lens = { "gamma_in": 1, "gamma_in_sigma": 0, @@ -276,11 +277,11 @@ def test_lens_log_likelihood(self): dds = self.cosmo.angular_diameter_distance_z1z2(z1=z_lens, z2=z_source).value ddt = (1.0 + z_lens) * dd * ds / dds - #ln_likelihood = self.likelihood_gamma_in_fail_case.log_likelihood_single( + # ln_likelihood = self.likelihood_gamma_in_fail_case.log_likelihood_single( # ddt, dd, delta_lum_dist, kwargs_lens, kwargs_kin, kwargs_source, kwargs_los - #) + # ) - #assert ln_likelihood < -10000000 + # assert ln_likelihood < -10000000 if __name__ == "__main__": diff --git a/test/test_Likelihood/test_kin_scaling.py b/test/test_Likelihood/test_kin_scaling.py index f66aa32..f120166 100644 --- a/test/test_Likelihood/test_kin_scaling.py +++ b/test/test_Likelihood/test_kin_scaling.py @@ -11,9 +11,11 @@ def test_single_param(self): param_arrays = np.linspace(0, 1, 11) scaling_grid_list = [param_arrays**2] param_list = ["a"] - kin_scaling = KinScaling(j_kin_scaling_param_axes=param_arrays, - j_kin_scaling_grid_list=scaling_grid_list, - j_kin_scaling_param_name_list=param_list) + kin_scaling = KinScaling( + j_kin_scaling_param_axes=param_arrays, + j_kin_scaling_grid_list=scaling_grid_list, + j_kin_scaling_param_name_list=param_list, + ) kwargs_param = {"a": 0.5} j_scaling = kin_scaling.kin_scaling(kwargs_param=kwargs_param) npt.assert_almost_equal(j_scaling, 0.5**2, decimal=2) @@ -21,14 +23,16 @@ def test_single_param(self): assert kwargs_min["a"] == 0 param_arrays = np.linspace(0, 1, 11) - scaling_grid_list = [param_arrays ** 2] + scaling_grid_list = [param_arrays**2] param_list = ["a"] - kin_scaling = KinScaling(j_kin_scaling_param_axes=[param_arrays], - j_kin_scaling_grid_list=scaling_grid_list, - j_kin_scaling_param_name_list=param_list) + kin_scaling = KinScaling( + j_kin_scaling_param_axes=[param_arrays], + j_kin_scaling_grid_list=scaling_grid_list, + j_kin_scaling_param_name_list=param_list, + ) kwargs_param = {"a": 0.5} j_scaling = kin_scaling.kin_scaling(kwargs_param=kwargs_param) - npt.assert_almost_equal(j_scaling, 0.5 ** 2, decimal=2) + npt.assert_almost_equal(j_scaling, 0.5**2, decimal=2) kwargs_min, kwargs_max = kin_scaling.param_bounds_interpol() assert kwargs_min["a"] == 0 @@ -41,9 +45,11 @@ def test_two_parameters(self): assert shape_scaling[1] == 21 # assert 1 == 0 param_list = ["a", "b"] - kin_scaling = KinScaling(j_kin_scaling_param_axes=param_arrays, - j_kin_scaling_grid_list=scaling_grid_list, - j_kin_scaling_param_name_list=param_list) + kin_scaling = KinScaling( + j_kin_scaling_param_axes=param_arrays, + j_kin_scaling_grid_list=scaling_grid_list, + j_kin_scaling_param_name_list=param_list, + ) kwargs_param = {"a": 0.5, "b": 0.3} j_scaling = kin_scaling.kin_scaling(kwargs_param=kwargs_param) print(j_scaling) @@ -59,9 +65,11 @@ def test__kwargs2param_array(self): scaling_grid_list = [xy * uv, xy, uv] param_list = ["a", "b"] - kin_scaling = KinScaling(j_kin_scaling_param_axes=param_arrays, - j_kin_scaling_grid_list=scaling_grid_list, - j_kin_scaling_param_name_list=param_list) + kin_scaling = KinScaling( + j_kin_scaling_param_axes=param_arrays, + j_kin_scaling_grid_list=scaling_grid_list, + j_kin_scaling_param_name_list=param_list, + ) kwargs_param = {"a": 0.5, "b": 0.3} param_array = kin_scaling._kwargs2param_array(kwargs_param) assert param_array[0] == kwargs_param["a"] @@ -73,11 +81,16 @@ def test__kwargs2param_array(self): assert kwargs_max["a"] == 1 def test_empty(self): - kin_scaling = KinScaling(j_kin_scaling_param_axes=None, j_kin_scaling_grid_list=None, j_kin_scaling_param_name_list=None) + kin_scaling = KinScaling( + j_kin_scaling_param_axes=None, + j_kin_scaling_grid_list=None, + j_kin_scaling_param_name_list=None, + ) output = kin_scaling.kin_scaling(kwargs_param=None) assert output == 1 kwargs_min, kwargs_max = kin_scaling.param_bounds_interpol() + class TestParameterScalingSingleAperture(object): def setup_method(self): ani_param_array = np.linspace(start=0, stop=1, num=10) @@ -91,7 +104,7 @@ def setup_method(self): np.linspace(start=1, stop=2, num=5), ] param_scaling_array = np.outer(ani_param_array[0], ani_param_array[1]) - print(np.shape(param_scaling_array), 'test shape') + print(np.shape(param_scaling_array), "test shape") self.scaling_2d = ParameterScalingSingleMeasurement( ani_param_array, param_scaling_array ) @@ -153,8 +166,9 @@ def setup_method(self): ani_param_array = np.linspace(start=0, stop=1, num=10) param_scaling_array = ani_param_array * 2 self.scaling = KinScaling( - j_kin_scaling_param_axes=ani_param_array, j_kin_scaling_grid_list=[param_scaling_array], - j_kin_scaling_param_name_list=["a"] + j_kin_scaling_param_axes=ani_param_array, + j_kin_scaling_grid_list=[param_scaling_array], + j_kin_scaling_param_name_list=["a"], ) ani_param_array = [ @@ -162,10 +176,11 @@ def setup_method(self): np.linspace(start=1, stop=2, num=5), ] param_scaling_array = np.outer(ani_param_array[0], ani_param_array[1]) - self.scaling_2d = KinScaling(j_kin_scaling_param_axes=ani_param_array, - j_kin_scaling_grid_list=[param_scaling_array], - j_kin_scaling_param_name_list=["a", "b"] - ) + self.scaling_2d = KinScaling( + j_kin_scaling_param_axes=ani_param_array, + j_kin_scaling_grid_list=[param_scaling_array], + j_kin_scaling_param_name_list=["a", "b"], + ) ani_param_array = np.linspace(start=0, stop=1, num=10) gamma_in_array = np.linspace(start=0.1, stop=2.9, num=5) @@ -176,11 +191,11 @@ def setup_method(self): ani_param_array, np.outer(gamma_in_array, log_m2l_array), ) - self.scaling_nfw = KinScaling(j_kin_scaling_param_axes=param_arrays, - j_kin_scaling_grid_list=[param_scaling_array], - j_kin_scaling_param_name_list=["a", "b", "c"] - ) - + self.scaling_nfw = KinScaling( + j_kin_scaling_param_axes=param_arrays, + j_kin_scaling_grid_list=[param_scaling_array], + j_kin_scaling_param_name_list=["a", "b", "c"], + ) gom_param_array = [ np.linspace(start=0, stop=1, num=10), @@ -199,21 +214,22 @@ def setup_method(self): np.outer(gamma_in_array, log_m2l_array), ), ) - self.scaling_nfw_2d = KinScaling(j_kin_scaling_param_axes=param_arrays, - j_kin_scaling_grid_list=[param_scaling_array], - j_kin_scaling_param_name_list=["a", "b", "c", "d"] - ) - + self.scaling_nfw_2d = KinScaling( + j_kin_scaling_param_axes=param_arrays, + j_kin_scaling_grid_list=[param_scaling_array], + j_kin_scaling_param_name_list=["a", "b", "c", "d"], + ) param_arrays = [ani_param_array, gamma_in_array] param_scaling_array = np.multiply.outer( ani_param_array, gamma_in_array, ) - self.scaling_nfw_no_m2l = KinScaling(j_kin_scaling_param_axes=param_arrays, - j_kin_scaling_grid_list=[param_scaling_array], - j_kin_scaling_param_name_list=["a", "b"] - ) + self.scaling_nfw_no_m2l = KinScaling( + j_kin_scaling_param_axes=param_arrays, + j_kin_scaling_grid_list=[param_scaling_array], + j_kin_scaling_param_name_list=["a", "b"], + ) gom_param_array = [ np.linspace(start=0, stop=1, num=10), @@ -231,17 +247,18 @@ def setup_method(self): gamma_in_array, ), ) - self.scaling_nfw_2d_no_m2l = KinScaling(j_kin_scaling_param_axes=param_arrays, - j_kin_scaling_grid_list=[param_scaling_array], - j_kin_scaling_param_name_list=["a", "b", "c"] - ) + self.scaling_nfw_2d_no_m2l = KinScaling( + j_kin_scaling_param_axes=param_arrays, + j_kin_scaling_grid_list=[param_scaling_array], + j_kin_scaling_param_name_list=["a", "b", "c"], + ) def test_kin_scaling(self): scaling = self.scaling.kin_scaling(kwargs_param=None) assert scaling[0] == 1 - scaling = self.scaling.kin_scaling(kwargs_param={"a":1}) + scaling = self.scaling.kin_scaling(kwargs_param={"a": 1}) assert scaling[0] == 2 kwargs_param = {"a": 1, "b": 2} @@ -252,7 +269,7 @@ def test_kin_scaling(self): scaling = self.scaling_nfw.kin_scaling(kwargs_param=kwargs_param) assert scaling[0] == 1 * 2.9 * 0.5 - kwargs_param = {"a": 1, "b": 2., "c": 2.9, "d": 0.5} + kwargs_param = {"a": 1, "b": 2.0, "c": 2.9, "d": 0.5} scaling = self.scaling_nfw_2d.kin_scaling(kwargs_param=kwargs_param) assert scaling[0] == 1 * 2 * 2.9 * 0.5 diff --git a/test/test_Sampling/test_Distributions/test_anisotropy_distribution.py b/test/test_Sampling/test_Distributions/test_anisotropy_distribution.py index 6dd65ce..55b954f 100644 --- a/test/test_Sampling/test_Distributions/test_anisotropy_distribution.py +++ b/test/test_Sampling/test_Distributions/test_anisotropy_distribution.py @@ -1,4 +1,6 @@ -from hierarc.Sampling.Distributions.anisotropy_distributions import AnisotropyDistribution +from hierarc.Sampling.Distributions.anisotropy_distributions import ( + AnisotropyDistribution, +) class TestAnisotropyDistribution(object): @@ -9,28 +11,39 @@ def setup_method(self): kwargs_anisotropy_min = {"a_ani": 0, "beta_inf": 0.1} kwargs_anisotropy_max = {"a_ani": 5, "beta_inf": 1} - self._ani_dist = AnisotropyDistribution(anisotropy_model=anisotropy_model, - anisotropy_sampling=True, - distribution_function=distribution_function, - kwargs_anisotropy_min=kwargs_anisotropy_min, - kwargs_anisotropy_max=kwargs_anisotropy_max) + self._ani_dist = AnisotropyDistribution( + anisotropy_model=anisotropy_model, + anisotropy_sampling=True, + distribution_function=distribution_function, + kwargs_anisotropy_min=kwargs_anisotropy_min, + kwargs_anisotropy_max=kwargs_anisotropy_max, + ) - ani_dist = AnisotropyDistribution(anisotropy_model=anisotropy_model, - anisotropy_sampling=False, - distribution_function=distribution_function, - kwargs_anisotropy_min=kwargs_anisotropy_min, - kwargs_anisotropy_max=kwargs_anisotropy_max) + ani_dist = AnisotropyDistribution( + anisotropy_model=anisotropy_model, + anisotropy_sampling=False, + distribution_function=distribution_function, + kwargs_anisotropy_min=kwargs_anisotropy_min, + kwargs_anisotropy_max=kwargs_anisotropy_max, + ) def test_draw_anisotropy(self): - kwargs_anisotropy = {"a_ani": 1, "beta_inf": 0.8, "a_ani_sigma": 0.1, "beta_inf_sigma": 0.2} + kwargs_anisotropy = { + "a_ani": 1, + "beta_inf": 0.8, + "a_ani_sigma": 0.1, + "beta_inf_sigma": 0.2, + } kwargs_drawn = self._ani_dist.draw_anisotropy(**kwargs_anisotropy) assert "a_ani" in kwargs_drawn assert "beta_inf" in kwargs_drawn - ani_dist = AnisotropyDistribution(anisotropy_model="NONE", - anisotropy_sampling=False, - distribution_function="NONE", - kwargs_anisotropy_min=None, - kwargs_anisotropy_max=None) + ani_dist = AnisotropyDistribution( + anisotropy_model="NONE", + anisotropy_sampling=False, + distribution_function="NONE", + kwargs_anisotropy_min=None, + kwargs_anisotropy_max=None, + ) kwargs_drawn = ani_dist.draw_anisotropy() assert "a_ani" not in kwargs_drawn diff --git a/test/test_Sampling/test_Distributions/test_lens_distribution.py b/test/test_Sampling/test_Distributions/test_lens_distribution.py index 6f71712..f5a30a2 100644 --- a/test/test_Sampling/test_Distributions/test_lens_distribution.py +++ b/test/test_Sampling/test_Distributions/test_lens_distribution.py @@ -6,35 +6,39 @@ class TestLensDistribution(object): def setup_method(self): - self.kwargs_sampling = {"lambda_mst_distribution": "GAUSSIAN", - "gamma_in_sampling": True, - "gamma_in_distribution": "GAUSSIAN", - "log_m2l_sampling": True, - "log_m2l_distribution" : "GAUSSIAN", - "alpha_lambda_sampling": True, - "beta_lambda_sampling": True, - "alpha_gamma_in_sampling": True, - "alpha_log_m2l_sampling": True, - "log_scatter": False, # change for different tests - "mst_ifu": False, # change for different tests - "lambda_scaling_property": 0.1, - "lambda_scaling_property_beta": 0.2, - "kwargs_min": {"gamma_in": 0, "log_m2l": -3}, - "kwargs_max": {"gamma_in": 3, "log_m2l": 3}} - - self.kwargs_lens = {"lambda_mst": 1.1, - "lambda_mst_sigma": 0.1, - "gamma_ppn": 0.9, - "lambda_ifu": 0.5, - "lambda_ifu_sigma": 0.2, - "alpha_lambda": -0.2, - "beta_lambda": 0.3, - "gamma_in": 1.5, - "gamma_in_sigma": 0.2, - "alpha_gamma_in": 0.2, - "log_m2l": 0.6, - "log_m2l_sigma": 0.2, - "alpha_log_m2l": -0.1} + self.kwargs_sampling = { + "lambda_mst_distribution": "GAUSSIAN", + "gamma_in_sampling": True, + "gamma_in_distribution": "GAUSSIAN", + "log_m2l_sampling": True, + "log_m2l_distribution": "GAUSSIAN", + "alpha_lambda_sampling": True, + "beta_lambda_sampling": True, + "alpha_gamma_in_sampling": True, + "alpha_log_m2l_sampling": True, + "log_scatter": False, # change for different tests + "mst_ifu": False, # change for different tests + "lambda_scaling_property": 0.1, + "lambda_scaling_property_beta": 0.2, + "kwargs_min": {"gamma_in": 0, "log_m2l": -3}, + "kwargs_max": {"gamma_in": 3, "log_m2l": 3}, + } + + self.kwargs_lens = { + "lambda_mst": 1.1, + "lambda_mst_sigma": 0.1, + "gamma_ppn": 0.9, + "lambda_ifu": 0.5, + "lambda_ifu_sigma": 0.2, + "alpha_lambda": -0.2, + "beta_lambda": 0.3, + "gamma_in": 1.5, + "gamma_in_sigma": 0.2, + "alpha_gamma_in": 0.2, + "log_m2l": 0.6, + "log_m2l_sigma": 0.2, + "alpha_log_m2l": -0.1, + } def test_draw_lens(self): lens_dist = LensDistribution(**self.kwargs_sampling) diff --git a/test/test_Sampling/test_mcmc_sampling.py b/test/test_Sampling/test_mcmc_sampling.py index e27550e..2228700 100644 --- a/test/test_Sampling/test_mcmc_sampling.py +++ b/test/test_Sampling/test_mcmc_sampling.py @@ -67,13 +67,13 @@ def test_mcmc_emcee(self): backend = emcee.backends.HDFBackend(backup_filename) kwargs_emcee = {"backend": backend} - kwargs_model = {"ppn_sampling": False, - "lambda_mst_sampling": False, - "lambda_mst_distribution": "delta", - "anisotropy_sampling": False, - "anisotropy_model": "OM", - - } + kwargs_model = { + "ppn_sampling": False, + "lambda_mst_sampling": False, + "lambda_mst_distribution": "delta", + "anisotropy_sampling": False, + "anisotropy_model": "OM", + } mcmc_sampler = MCMCSampler( kwargs_likelihood_list=kwargs_likelihood_list,