Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_attribution(self):
mapper = model_mapper.ModelMapper(MockConfig())
mapper.mock_class = MockClassMM
assert hasattr(mapper, "mock_class")
assert hasattr(mapper.mock_class, "one")
def test__order_maintained_with_prior_change(self, test_config):
mapper = model_mapper.ModelMapper(
test_config,
profile_1=geometry_profiles.EllipticalProfile, profile_2=geometry_profiles.GeometryProfile,
profile_3=geometry_profiles.EllipticalProfile)
unit_vector = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
before = mapper.physical_values_ordered_by_class(unit_vector)
mapper.profile_1.axis_ratio = model_mapper.UniformPrior(0, 2)
assert mapper.physical_values_ordered_by_class(unit_vector) == before
def make_mapper_with_one(test_config, width_config):
mapper = model_mapper.ModelMapper(width_config=width_config)
mapper.one = model_mapper.PriorModel(MockClassMM, config=test_config)
return mapper
def test_same_argument_name(self, test_config):
mapper = model_mapper.ModelMapper()
mapper.one = model_mapper.PriorModel(MockClassMM, test_config)
mapper.two = model_mapper.PriorModel(MockClassMM, test_config)
instance = mapper.instance_from_physical_vector([1, 2, 3, 4])
assert instance.one.one == 1
assert instance.one.two == 2
assert instance.two.one == 3
assert instance.two.two == 4
def test_config_prior_type(self):
collection = model_mapper.ModelMapper(MockConfig({"MockClassMM": {"one": ["g", 1., 2.]}}))
collection.mock_class = MockClassMM
assert isinstance(collection.mock_class.one, model_mapper.GaussianPrior)
assert collection.mock_class.one.mean == 1.
assert collection.mock_class.one.sigma == 2.
def test__2_classes__six_parameters(self, test_config, nlo_setup_path):
conf.instance.output_path = nlo_setup_path + '2_classes'
mapper = model_mapper.ModelMapper(config=test_config, class_1=MockClassNLOx4, class_2=MockClassNLOx6)
nlo = non_linear.NonLinearOptimizer(model_mapper=mapper)
assert nlo.variable.prior_count == 10
def test_replace_priors_with_gaussians_from_tuples(self, width_config):
mapper = model_mapper.ModelMapper(MockConfig(), width_config=width_config, mock_class=MockClassMM)
result = mapper.mapper_from_gaussian_tuples([(10, 3), (5, 3)])
assert isinstance(result.mock_class.one, model_mapper.GaussianPrior)
def test_value_vector_for_hypercube_vector(self):
collection = model_mapper.ModelMapper(MockConfig(), mock_class=MockClassMM)
collection.mock_class.two = model_mapper.UniformPrior(upper_limit=100.)
assert collection.physical_values_ordered_by_class([1., 0.5]) == [1., 50.]
def test_prior_creation(self, test_config, limit_config):
mm = model_mapper.ModelMapper(test_config, limit_config=limit_config)
mm.mock_class_gaussian = MockClassGaussian
prior_tuples = mm.prior_tuples_ordered_by_id
assert prior_tuples[0].prior.lower_limit == 0
assert prior_tuples[0].prior.upper_limit == 1
assert prior_tuples[1].prior.lower_limit == 0
assert prior_tuples[1].prior.upper_limit == 2
def test__most_likely__setup_model_instance__1_class_4_params(self, test_config, mn_summary_path):
conf.instance.output_path = mn_summary_path + '/1_class'
mapper = model_mapper.ModelMapper(config=test_config, mock_class=MockClassNLOx4)
mn = non_linear.MultiNest(model_mapper=mapper)
create_summary_4_parameters(path=mn.opt_path)
most_likely = mn.most_likely_instance_from_summary()
assert most_likely.mock_class.one == 9.0
assert most_likely.mock_class.two == -10.0
assert most_likely.mock_class.three == -11.0
assert most_likely.mock_class.four == 12.0