示例#1
0
 def test_init(self):
     GQ = qm.GaussLaguerre(deg=10, lower=1.0, upper=12.0)
     self.assertTrue(hasattr(GQ, 'f'), msg='Expect attribute f to exist')
     self.assertEqual(GQ.f, None, msg='Expect value of None')
     self.assertEqual(len(GQ.points), 10, msg='Expect 10 nodes')
     self.assertEqual(len(GQ.weights), 10, msg='Expect 10 weights')
     self.assertEqual(GQ.alpha, 0, msg='Expect alpha eq 0')
示例#2
0
 def test_update_weights(self):
     Q = qm.GaussLaguerre(deg=10, lower=1.0, upper=12.0,
                          extend_precision=False)
     Q.weights = []
     Q.update_weights(alpha=0.0)
     self.assertTrue(isinstance(Q.weights, np.ndarray),
                     msg='Weights should be updated.')
示例#3
0
 def test_init(self):
     Q = qm.GaussLaguerre(deg=10, lower=1.0, upper=12.0)
     attributes = ['points', 'weights', 'f', 'alpha',
                   'initial_weights', 'description', 'singularity']
     for att in attributes:
         self.assertTrue(hasattr(Q, att),
                         msg=str('Missing {} attribute'.format(att)))
示例#4
0
 def test_init_with_f(self):
     GQ = qm.GaussLaguerre(deg=10, lower=1.0, upper=12.0,
                           alpha=0.5, f=self.fsp)
     self.assertTrue(hasattr(GQ, 'f'), msg='Expect attribute f to exist')
     self.assertEqual(GQ.f, self.fsp, msg='Expect function fsp')
     self.assertEqual(len(GQ.points), 10, msg='Expect 10 nodes')
     self.assertEqual(len(GQ.weights), 10, msg='Expect 10 weights')
     self.assertEqual(GQ.alpha, 0.5, msg='Expect alpha eq 0.5')
示例#5
0
 def test_with_alpha(self):
     GQ = qm.GaussLaguerre()
     a = GQ.integrate(f=self.fsp)
     self.assertTrue(isinstance(a, float), msg='Expect float return')
示例#6
0
 def test_no_f(self):
     GQ = qm.GaussLaguerre()
     with self.assertRaises(SystemExit):
         GQ.integrate()
示例#7
0
 def test_with_alpha(self):
     GQ = qm.GaussLaguerre(extend_precision=False)
     a = GQ.integrate(f=self.f)
     self.assertEqual(a.size, 1, msg='Expect float return')
示例#8
0
 def test_no_f(self):
     GQ = qm.GaussLaguerre(extend_precision=False)
     with self.assertRaises(SystemExit):
         GQ.integrate()
示例#9
0
 def test_integrate(self):
     Q = qm.GaussLaguerre(deg=10, lower=0.0, upper=1.0,
                          extend_precision=False)
     a = Q.integrate(f=self.f)
     self.assertTrue(isinstance(a, float), msg='Expect float')