Exemple #1
0
 def test_update(self):
     sample_dict = dict(a=1, b=2)
     curr = Sample(sample_dict)
     prop = curr.copy()
     prop['a'] = 200
     self.assertEqual(prop['a'], 200)
     self.assertEqual(curr['a'], 1)
Exemple #2
0
 def create_random_sample(self):
     return Sample({
         "a": np.random.normal(0, 1),
         "b": np.random.normal(0, 1),
         LOGLKEY: np.random.normal(0, 1),
         LOGPKEY: -1
     })
Exemple #3
0
 def create_random_sample(self, ndim=2):
     p = {f"x{i}": np.random.normal(0, 1) for i in range(ndim)}
     p[LOGLKEY] = np.random.normal(0, 1)
     p[LOGPKEY] = -1
     p["fixedA"] = 1
     p["infinite_support"] = np.random.normal(0, 1)
     p["half_infinite_support"] = np.abs(np.random.normal(0, 1))
     return Sample(p)
Exemple #4
0
    def test_setitem(self):
        s = Sample(self.sample_dict)

        # Set existing parameter
        s['a'] = 100
        self.assertEqual(s['a'], 100)

        # Add parameter
        s['c'] = 100
        self.assertEqual(s['c'], 100)
Exemple #5
0
 def test_parameter_only_dict(self):
     s = Sample(self.sample_dict)
     self.assertEqual(s.parameter_only_dict, dict(a=1, b=2))
Exemple #6
0
 def test_list_access(self):
     s = Sample(self.sample_dict)
     slist = s.list
     self.assertEqual(slist, [self.sample_dict['a'], self.sample_dict['b']])
Exemple #7
0
 def test_dict_access(self):
     s = Sample(self.sample_dict)
     for key in s.keys:
         self.assertEqual(s[key], self.sample_dict[key])
Exemple #8
0
 def test_init(self):
     s = Sample(self.sample_dict)
     self.assertEqual(s.keys, list(self.sample_dict.keys()))
Exemple #9
0
 def create_random_sample(self, ndim=2):
     p = {f"x{i}": np.random.normal(0, 1) for i in range(ndim)}
     p[LOGLKEY] = np.random.normal(0, 1)
     p[LOGPKEY] = -1
     p["fixedA"] = 1
     return Sample(p)