Ejemplo n.º 1
0
 def test_init_abscissa_float(self):
     """brightness.Distribution.__init__: Python, float abscissa"""
     d1 = brightness.Distribution(self.masses, 5000, engine=self.engine)
     d2 = brightness.Distribution(self.masses,
                                  np.arange(100, 5001),
                                  engine=self.engine)
     np.testing.assert_allclose(d1.graph[:, 100:], d2.graph)
Ejemplo n.º 2
0
 def test_init_df(self):
     """brightness.Distribution.__init__: Python, DataFrame"""
     # This assumes that the numba array version works
     absc = 5000
     bd1 = brightness.Distribution(self.peak_data, absc, engine=self.engine)
     bd2 = brightness.Distribution(self.masses, absc, engine=self.engine)
     np.testing.assert_allclose(bd1.graph, bd2.graph)
Ejemplo n.º 3
0
 def test_init_list(self):
     """brightness.Distribution.__init__: Python, list of DataFrames"""
     # This assumes that the array version works
     l = [self.peak_data.loc[[0, 1]], self.peak_data.loc[[2]]]
     absc = 5000
     np.testing.assert_allclose(
         brightness.Distribution(l, absc, engine=self.engine).graph,
         brightness.Distribution(self.masses, absc,
                                 engine=self.engine).graph)
Ejemplo n.º 4
0
 def test_init_cam_eff(self):
     """brightness.Distribution.__init__: Python, cam_eff"""
     eff = 20
     absc = 5000
     d1 = brightness.Distribution(self.masses,
                                  absc,
                                  cam_eff=eff,
                                  engine=self.engine)
     d2 = brightness.Distribution(self.masses / eff,
                                  absc,
                                  cam_eff=1,
                                  engine=self.engine)
     np.testing.assert_allclose(d1.graph, d2.graph)
Ejemplo n.º 5
0
 def test_init_abscissa_none(self):
     """brightness.Distribution.__init__: Python, `None` abscissa"""
     smth = 1
     d1 = brightness.Distribution(self.masses,
                                  None,
                                  bw=smth,
                                  engine=self.engine)
     a = np.max(self.masses) + 2 * smth * np.sqrt(np.max(self.masses)) - 1
     d2 = brightness.Distribution(self.masses,
                                  a,
                                  bw=smth,
                                  engine=self.engine)
     np.testing.assert_allclose(d1.graph, d2.graph)
Ejemplo n.º 6
0
 def test_init_kern_width(self):
     """brightness.Distribution.__init__: Python, truncated kernel"""
     smth = 1
     x, y = self._calc_graph(smth)
     d = brightness.Distribution(self.masses,
                                 x,
                                 bw=smth,
                                 cam_eff=1,
                                 kern_width=5,
                                 engine=self.engine)
     np.testing.assert_allclose([x, y], d.graph, atol=1e-6)
Ejemplo n.º 7
0
 def test_init_array(self):
     """brightness.Distribution.__init__: Python, full kernel, ndarray"""
     smth = 1
     x, y = self._calc_graph(smth)
     d = brightness.Distribution(self.masses,
                                 x,
                                 bw=smth,
                                 cam_eff=1,
                                 kern_width=np.inf,
                                 engine=self.engine)
     np.testing.assert_allclose([x, y], d.graph)
Ejemplo n.º 8
0
 def test_most_probable(self):
     """brightness.Distribution.most_probable: Python"""
     absc = 5000
     d = brightness.Distribution(self.masses, absc, engine=self.engine)
     np.testing.assert_allclose(d.most_probable(), self.most_probable)
Ejemplo n.º 9
0
 def test_std(self):
     """brightness.Distribution.std: Python"""
     absc = 5000
     d = brightness.Distribution(self.masses, absc, engine=self.engine)
     var = np.sum((d.graph[0] - d.mean())**2 * d.graph[1])
     np.testing.assert_allclose(d.std(), np.sqrt(var))
Ejemplo n.º 10
0
 def test_mean(self):
     """brightness.Distribution.mean: Python"""
     absc = 5000
     d = brightness.Distribution(self.masses, absc, engine=self.engine)
     mean = np.sum(d.graph[0] * d.graph[1])
     np.testing.assert_allclose(d.mean(), mean)