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')
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.')
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)))
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')
def test_with_alpha(self): GQ = qm.GaussLaguerre() a = GQ.integrate(f=self.fsp) self.assertTrue(isinstance(a, float), msg='Expect float return')
def test_no_f(self): GQ = qm.GaussLaguerre() with self.assertRaises(SystemExit): GQ.integrate()
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')
def test_no_f(self): GQ = qm.GaussLaguerre(extend_precision=False) with self.assertRaises(SystemExit): GQ.integrate()
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')