def test_read_hierarchical_transformed(self): inner_map = [transformed_prior, [np.sqrt, ['_parameter_0']]] parameter_map = [transformed_prior, [np.maximum, ['_parameter_1', inner_map]]] priors = [prior.Uniform(0, 1), prior.Uniform(1, 2)] expected_base = [prior.Uniform(1, 2), prior.TransformedPrior(np.sqrt, prior.Uniform(0, 1))] expected_full = prior.TransformedPrior(np.maximum, expected_base) self.assertEqual(read_map(parameter_map, priors), expected_full) values = [25, 7] self.assertEqual(read_map(inner_map, values), 5) self.assertEqual(read_map(parameter_map, values), 7)
def test_read_composite_map(self): n_map = [dict, [[['red', [[transformed_prior, [complex, [1.5, "_parameter_2"]]], [transformed_prior, [complex, [1.6, "_parameter_3"]]]]], ['green', [[transformed_prior, [complex, [1.7, "_parameter_4"]]], [transformed_prior, [complex, [1.8, "_parameter_5"]]]]]]]] parameter_map = [dict, [[['r', ["_parameter_0", "_parameter_1"]], ['n', n_map], ['center', [10, 20, "_parameter_6"]]]]] placeholders = [0.5, 0.7, 0.01, 0.02, 0.03, 0.04, 30] n_expected = {'red': [complex(1.5, 0.01), complex(1.6, 0.02)], 'green': [complex(1.7, 0.03), complex(1.8, 0.04)]} expected = {'r': [0.5, 0.7], 'n': n_expected, 'center': [10, 20, 30]} self.assertEqual(read_map(parameter_map, placeholders), expected)
def test_read_transformed_prior_map_priors(self): parameter_map = [transformed_prior, [np.sqrt, ['_parameter_0']]] priors = [prior.Uniform(0, 1)] expected = prior.TransformedPrior(np.sqrt, priors) self.assertEqual(read_map(parameter_map, priors), expected)
def test_read_transformed_prior_map_values(self): parameter_map = [transformed_prior, [np.sqrt, ['_parameter_0']]] values = [4] self.assertEqual(read_map(parameter_map, values), 2)
def test_read_complex_map_priors(self): parameter_map = [transformed_prior, [complex, ['_parameter_0', '_parameter_1']]] priors = [prior.Uniform(0, 1), prior.Uniform(1, 2)] expected = prior.TransformedPrior(complex, [priors[0], priors[1]]) self.assertEqual(read_map(parameter_map, priors), expected)
def test_read_complex_map_values(self): parameter_map = [transformed_prior, [complex, ['_parameter_0', '_parameter_1']]] values = [0, 1] self.assertEqual(read_map(parameter_map, values), complex(0, 1))
def test_read_placeholder_map(self): parameter_map = [0, 1, "_parameter_2"] placeholders = [3, 4, 5] expected = [0, 1, 5] self.assertEqual(read_map(parameter_map, placeholders), expected)
def test_read_func_map(self): parameter_map = [dict, [[['a', 0], ['b', 1], ['c', 2]]]] expected = {'a': 0, 'b': 1, 'c': 2} self.assertEqual(read_map(parameter_map, []), expected)