def testBladeInitColumnVector(): # testing column vector c = np.array([[2], [0], [0]]) B = Blade(c) print 's: ', B.s print 'blade: ', B.blade assert np.allclose(np.dot(B.blade.T, B.blade), np.eye(1)) assert np.allclose(B.s, 2.0) assert B.k == 1 B = Blade(c, s=2.0) print 's: ', B.s print 'blade: ', B.blade assert np.allclose(np.dot(B.blade.T, B.blade), np.eye(1)) assert np.allclose(B.s, 4.0) assert B.k == 1
def testBladeInitOneIndexVector(): # testing one-index (row-ish) vector c = np.array([2, 0, 0]) B = Blade(c) assert np.allclose(np.dot(B.blade.T, B.blade), np.eye(1)) assert np.allclose(B.s, 2.0) assert B.k == 1
def testBladeInitRankDeficient(): # testing rank deficient A = np.array([[1, 0], [1, 0], [0, 0]]) B = Blade(A) print B.blade.shape assert B.blade.shape == (1, 0) assert np.allclose(B.s, 0) assert B.k == 0 B = Blade(A, s=2.0) assert B.blade.shape == (1, 0) assert np.allclose(B.s, 0) assert B.k == 0 # too many columns C = np.array([[1, 0, 1], [0, 1, 0]]) B2 = Blade(C) assert B2.blade.shape == (1, 0) assert np.allclose(B2.s, 0) assert B2.k == 0