def test_covmodel_spline_prior(use_spline, prior_spline_monotonicity, prior_spline_convexity, prior_spline_num_constraint_points, prior_spline_maxder_gaussian, prior_spline_maxder_uniform, mrdata): covmodel = CovModel( 'cov1', use_spline=use_spline, prior_spline_monotonicity=prior_spline_monotonicity, prior_spline_convexity=prior_spline_convexity, prior_spline_num_constraint_points=prior_spline_num_constraint_points, prior_spline_maxder_gaussian=prior_spline_maxder_gaussian, prior_spline_maxder_uniform=prior_spline_maxder_uniform) covmodel.attach_data(mrdata) num_constraints = ((prior_spline_monotonicity is not None) + (prior_spline_convexity is not None)) * prior_spline_num_constraint_points num_constraints += (prior_spline_maxder_uniform is not None) * covmodel.spline.num_intervals num_regularizers = (prior_spline_maxder_gaussian is not None) * covmodel.spline.num_intervals assert covmodel.num_constraints == num_constraints assert covmodel.num_regularizations == num_regularizers
def test_covmodel_spline(spline_knots, spline_degree, spline_l_linear, spline_r_linear, use_re, use_re_mid_point, mrdata): covmodel = CovModel('cov1', use_re=use_re, use_re_mid_point=use_re_mid_point, use_spline=True, spline_knots=spline_knots, spline_degree=spline_degree, spline_l_linear=spline_l_linear, spline_r_linear=spline_r_linear) assert all( covmodel.spline_knots_template == np.array([0.0, 0.25, 0.75, 1.0])) assert covmodel.spline_degree == spline_degree assert covmodel.spline_l_linear == spline_l_linear assert covmodel.spline_r_linear == spline_r_linear covmodel.attach_data(mrdata) assert covmodel.num_x_vars == covmodel.spline.num_spline_bases - 1 if use_re and use_re_mid_point: assert covmodel.num_z_vars == 1 elif use_re and not use_re_mid_point: assert covmodel.num_z_vars == covmodel.num_x_vars elif not use_re: assert covmodel.num_z_vars == 0
def test_covmodel_beta_uprior(prior_beta_uniform, use_spline, mrdata): covmodel = CovModel('cov1', use_spline=use_spline, prior_beta_uniform=prior_beta_uniform) covmodel.attach_data(mrdata) assert covmodel.prior_beta_uniform.ndim == 2 assert np.all(covmodel.prior_beta_uniform[0] == 0.0) assert np.all(covmodel.prior_beta_uniform[1] == 1.0)
def test_covmodel_beta_lprior(prior_beta_laplace, use_spline, mrdata): covmodel = CovModel('cov1', use_spline=use_spline, prior_beta_laplace=prior_beta_laplace) covmodel.attach_data(mrdata) assert covmodel.prior_beta_laplace.ndim == 2 assert np.all(covmodel.prior_beta_laplace[0] == 0.0) assert np.all(covmodel.prior_beta_laplace[1] == 1.0)
def test_covmodel_beta_gprior(prior_beta_gaussian, use_spline, mrdata): covmodel = CovModel('cov1', use_spline=use_spline, prior_beta_gaussian=prior_beta_gaussian) covmodel.attach_data(mrdata) assert covmodel.prior_beta_gaussian.ndim == 2 assert np.all(covmodel.prior_beta_gaussian[0] == 0.0) assert np.all(covmodel.prior_beta_gaussian[1] == 1.0)
def test_covmodel_gamma_uprior(prior_gamma_uniform, use_spline, use_re, use_re_mid_point, mrdata): covmodel = CovModel('cov1', use_spline=use_spline, prior_gamma_uniform=prior_gamma_uniform, use_re=use_re, use_re_mid_point=use_re_mid_point) covmodel.attach_data(mrdata) assert covmodel.prior_gamma_uniform.ndim == 2 assert np.all(covmodel.prior_gamma_uniform[0] == 0.0) assert np.all(covmodel.prior_gamma_uniform[1] == 1.0)
def test_covmodel_gamma_gprior(prior_gamma_gaussian, use_spline, use_re, use_re_mid_point, mrdata): covmodel = CovModel('cov1', use_spline=True, prior_gamma_gaussian=prior_gamma_gaussian, use_re=use_re, use_re_mid_point=use_re_mid_point) covmodel.attach_data(mrdata) assert covmodel.prior_gamma_gaussian.ndim == 2 assert np.all(covmodel.prior_gamma_gaussian[0] == 0.0) assert np.all(covmodel.prior_gamma_gaussian[1] == 1.0)