Package solvcon :: Package tests :: Module test_numpy
[hide private]
[frames] | no frames]

Source Code for Module solvcon.tests.test_numpy

 1  # -*- coding: UTF-8 -*- 
 2   
 3  from unittest import TestCase 
 4   
5 -class TestNumpy(TestCase):
6 - def test_dot(self):
7 from numpy import array, dot 8 A = array([[1,2],[3,4]], dtype='int32') 9 B = array([[5,6],[7,8]], dtype='int32') 10 R = array([[19,22],[43,50]], dtype='int32') 11 for val in (dot(A,B)-R).flat: 12 self.assertEqual(val, 0) 13 u = array([1,1], dtype='int32') 14 Ru = array([3,7], dtype='int32') 15 for val in (dot(A,u)-Ru).flat: 16 self.assertEqual(val, 0)
17
18 - def test_eig(self):
19 from numpy import array, dot 20 from numpy.linalg import eig, inv 21 A = array([[1,2],[3,4]], dtype='int32') 22 vals, mat = eig(A) 23 lbd = dot(dot(inv(mat), A), mat) 24 for i in range(2): 25 self.assertAlmostEqual(vals[i], lbd[i,i], places=14)
26