test_matrix¶
wield.control.algorithms.statespace.dense.test.test_matrix
This is a pytest module needing documentation
Functions
|
This is a pytest needing documentation |
This is a pytest needing documentation |
Details
- test_QRH()[source][github]¶
This is a pytest needing documentation
code
1def test_QRH(): 2 3 N = 10 4 M = np.random.rand(N, N) 5 M = np.array( 6 [ 7 [1, 0, 0], 8 [1, 1, 0], 9 [0, 0, 0], 10 ], 11 float, 12 ) 13 14 eye = np.eye(M.shape[0], M.shape[1]) 15 16 R, [Q], [QT] = matrix_algorithms.QR( 17 mat=M, 18 mshadow=None, 19 qmul=[eye], 20 qAmul=[eye], 21 pivoting=False, 22 # method = 'Householder', 23 method="Givens", 24 Rexact=False, 25 ) 26 R2, [Q], [QT] = matrix_algorithms.QR( 27 mat=M, 28 mshadow=None, 29 qmul=[eye], 30 qAmul=[eye], 31 pivoting=False, 32 # method = 'Householder', 33 method="Givens", 34 Rexact=True, 35 ) 36 37 import tabulate 38 39 print("near", tabulate.tabulate(R)) 40 print("exact", tabulate.tabulate(R2)) 41 print(tabulate.tabulate(Q)) 42 print(tabulate.tabulate(QT)) 43 44 numpy.testing.assert_almost_equal(Q @ Q.T, eye) 45 numpy.testing.assert_almost_equal(Q @ QT, eye) 46 numpy.testing.assert_almost_equal(Q @ R2, M)
pytest information
This code is wrapped in a pytest function using conventions detailed in Pytest Conventions. The full name of this test, as known by the documentation, is:
wield.control.algorithms.statespace.dense.test.test_matrix.test_QRHThe full name is useful when building documentation, to link a reference to this page using
:func:`name`, or directly include it with an autofunction directive. The collapse nodes below show every instance of the test run. There may only be one, but if the test was run multiple times through pytest parametrizations, the list can be longer.test_QRH
output
status: skipped duration: 0.000s captured errors: def test_QRH(): N = 10 M = np.random.rand(N, N) M = np.array( [ [1, 0, 0], [1, 1, 0], [0, 0, 0], ], float, ) eye = np.eye(M.shape[0], M.shape[1]) > R, [Q], [QT] = matrix_algorithms.QR( mat=M, mshadow=None, qmul=[eye], qAmul=[eye], pivoting=False, # method = 'Householder', method="Givens", Rexact=False, ) E TypeError: QR() got an unexpected keyword argument 'qmul' ../../src/wield/control/algorithms/statespace/dense/test/test_matrix.py:44: TypeError
- test_QRHpivot()[source][github]¶
This is a pytest needing documentation
code
1def test_QRHpivot(): 2 3 N = 10 4 M = np.random.rand(N, N) 5 M = np.array( 6 [ 7 [1, 0, 0], 8 [0, 1, 0], 9 [0, 1, 0], 10 ], 11 float, 12 ) 13 14 eye = np.eye(M.shape[0], M.shape[1]) 15 16 R, [Q], [QT], P = matrix_algorithms.QR( 17 mat=M, 18 mshadow=None, 19 qmul=[eye], 20 qAmul=[eye], 21 pivoting=True, 22 # method = 'Householder', 23 method="Givens", 24 Rexact=True, 25 ) 26 27 import tabulate 28 29 print(P) 30 print(tabulate.tabulate(R)) 31 # print(tabulate.tabulate(Q)) 32 # print(tabulate.tabulate(QT)) 33 34 numpy.testing.assert_almost_equal(Q @ Q.T, eye) 35 numpy.testing.assert_almost_equal(Q @ QT, eye) 36 numpy.testing.assert_almost_equal((Q @ R)[:, P], M)
pytest information
This code is wrapped in a pytest function using conventions detailed in Pytest Conventions. The full name of this test, as known by the documentation, is:
wield.control.algorithms.statespace.dense.test.test_matrix.test_QRHpivotThe full name is useful when building documentation, to link a reference to this page using
:func:`name`, or directly include it with an autofunction directive. The collapse nodes below show every instance of the test run. There may only be one, but if the test was run multiple times through pytest parametrizations, the list can be longer.test_QRHpivot
output
status: skipped duration: 0.000s captured errors: def test_QRHpivot(): N = 10 M = np.random.rand(N, N) M = np.array( [ [1, 0, 0], [0, 1, 0], [0, 1, 0], ], float, ) eye = np.eye(M.shape[0], M.shape[1]) > R, [Q], [QT], P = matrix_algorithms.QR( mat=M, mshadow=None, qmul=[eye], qAmul=[eye], pivoting=True, # method = 'Householder', method="Givens", Rexact=True, ) E TypeError: QR() got an unexpected keyword argument 'qmul' ../../src/wield/control/algorithms/statespace/dense/test/test_matrix.py:92: TypeError