fudge.core.math.test package

Submodules

fudge.core.math.test.testFudgeMath module

test fudge/core/math cmattoon, 3/24/2011

class fudge.core.math.test.testFudgeMath.testLegendre(methodName='runTest')[source]

Bases: unittest.case.TestCase

test0()[source]

Simple test, just check a couple of values for n = 0,1,2

test1()[source]

Check that all odd order polynomials evaluate to zero at the origin

test2()[source]

Check that all odd order polynomials are in fact odd and even ones are in fact even

test3()[source]

Check some more values, these are taken from Abramowitz and Stegun, 8.15 Example 1

test4()[source]

Check range testing of parameters

test5()[source]

Check recursion relation

fudge.core.math.test.testXYs module

fudge.core.math.test.test_linearAlgebra module

class fudge.core.math.test.test_linearAlgebra.AllCorrelatedCovarianceTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests

Pathological, all correlated, legal, but NOT INVERTIBLE

setUpMtx()[source]
test_construct_matrixinverse_from_eigendecomposition(*args, **kwargs)[source]
test_eigenvector_orthogonality(*args, **kwargs)[source]
test_eigenvector_orthonormality(*args, **kwargs)[source]
class fudge.core.math.test.test_linearAlgebra.AlmostAllCorrelatedCovarianceTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests

Pathological, all correlated, legal, but NOT INVERTIBLE

setUpMtx()[source]
test_construct_matrixinverse_from_eigendecomposition(*args, **kwargs)[source]
class fudge.core.math.test.test_linearAlgebra.BasicLinearAlgebraTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.MatrixTests

Very basic matrix tests

test_inner_products()[source]

Inner product test

test_matrix_addition()[source]

Addition test

test_outer_product()[source]

Outer product test

test_transpose()[source]

Transpose

class fudge.core.math.test.test_linearAlgebra.BoringCovarianceTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests

Boring, a diagonal matrix

setUpMtx()[source]
class fudge.core.math.test.test_linearAlgebra.CGLSQRTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.MatrixTests

setUp()[source]
test_data_constraint()[source]
test_data_constraint_prior()[source]
test_data_only()[source]
test_data_prior()[source]
class fudge.core.math.test.test_linearAlgebra.EigendecompositionTests[source]

Define some tests that should be run for DERIVED classes only. This doesn’t inherit from unittest.TestCase since the tests aren’t meant to be run inside this class.

Derived classes need to inherit from both this and from Eigendecomposition_base

test_construct_matrix_by_pruning()[source]

Try to reconstruct the matix using the PRUNED eigenvalue decomposition

test_construct_matrixinverse_by_pruning(*args, **kwargs)[source]

Try to construct the matrix inverse using the PRUNED eigenvalue decomposition

test_construct_matrixinverse_from_eigendecomposition()[source]

Try to construct the matrix inverse using the eigenvalue decomposition

test_eigenmodes_are_really_eigenmodes()[source]

Check that A * v[i] = e[i] * v[i]

test_eigenvector_normalization()[source]

Eigenvector normalization test:

test_eigenvector_orthogonality()[source]

Eigenvector orthogonality test

test_eigenvector_orthonormality()[source]

Check that eigenvectors are orthonormal, better get back identity matrix here

test_reconstruct_matrix_from_eigendecomposition()[source]

Try to reconstruct the matrix using the eigenvalue decomposition

class fudge.core.math.test.test_linearAlgebra.EigendecompositionTests_allShouldFail[source]

Bases: fudge.core.math.test.test_linearAlgebra.EigendecompositionTests

For some input matrices, all tests are expected to fail. They should inherit from this class instead of EigendecompositionTests

test_construct_matrix_by_pruning(*args, **kwargs)[source]
test_construct_matrixinverse_by_pruning(*args, **kwargs)[source]
test_construct_matrixinverse_from_eigendecomposition(*args, **kwargs)[source]
test_eigenmodes_are_really_eigenmodes(*args, **kwargs)[source]
test_eigenvector_normalization(*args, **kwargs)[source]
test_eigenvector_orthogonality(*args, **kwargs)[source]
test_eigenvector_orthonormality(*args, **kwargs)[source]
test_reconstruct_matrix_from_eigendecomposition(*args, **kwargs)[source]
class fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.MatrixTests

setUp()[source]
setUpMtx()[source]
class fudge.core.math.test.test_linearAlgebra.IllegalCovarianceTest(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests_allShouldFail

A bad matrix for testing:

Eigensystem for A. It is OK using numpy.linalg.eig, but not (apparently) with numpy.linalg.eigh, I checked against mathematica: >>> m = {{1., 2., 3.}, {1., 2., 1.}, {3., 2., 1.}} >>> {e, v} = Eigensystem[ m ] >>> {{5.23607, -2., 0.763932}, {{-0.647936, -0.400447, -0.647936}, {-0.707107, 1.08315*10^-16, 0.707107}, {0.465341, -0.752938, 0.465341}}}

numpy.linalg.eig gives: >>> evals: >>> [-2.14644241 0.78156156 5.36488085] >>> evecs: >>> [[-0.64135318 0.52747554 -0.55716753] >>> [-0.20230251 -0.81675359 -0.54035845] >>> [ 0.74009445 0.23384422 -0.63053714]]

However, note that this A is not a valid covariance as the off-diagonal elements are bigger than the on-diagonal ones.

setUpMtx()[source]
test_construct_matrix_by_pruning(*args, **kwargs)[source]
test_construct_matrixinverse_from_eigendecomposition(*args, **kwargs)[source]
class fudge.core.math.test.test_linearAlgebra.LotsOffDiagonalCovarianceTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests

Lots of off-diagonal

setUpMtx()[source]
class fudge.core.math.test.test_linearAlgebra.MatrixCompositionTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.MatrixTests

Very basic matrix tests

setUp()[source]
test_stackD()[source]

Testing diagonal stacking

test_stackH()[source]

Testing horizontal stacking

test_stackV()[source]

Testing vertical stacking

class fudge.core.math.test.test_linearAlgebra.MatrixTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

assertMatrixAlmostEqual(a, b, rtol=1e-05, atol=1e-08)[source]
assertMatrixEqual(a, b)[source]

The numpy “==” operator is a universal function, so it operates on each element in the matrices. The result is another matrix whose elements are all a[i,j] == b[i,j]. You need to call the .all() function to check that all elements evaluated to “True” Or, could just use array_equal()…

assertMatrixTrue(a)[source]

You need to call the .all() function to check that all elements evaluated to “True”

class fudge.core.math.test.test_linearAlgebra.OffDiagonalBarelyPathologicalCovarianceTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests_allShouldFail

Pathological, all correlated, barely illegal and very much not invertible, and slightly off-diagonal

setUpMtx()[source]
class fudge.core.math.test.test_linearAlgebra.OnDiagonalBarelyPathologicalCovarianceTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests_allShouldFail

Pathological, all correlated, barely illegal and very much not invertible

setUpMtx()[source]
class fudge.core.math.test.test_linearAlgebra.RealCovarianceTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests

Real covariance for testing, H(n,tot) cs cov.

setUpMtx()[source]
class fudge.core.math.test.test_linearAlgebra.SomeOffDiagonalCovarianceTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests

Some off-diagonal-ness

setUpMtx()[source]
class fudge.core.math.test.test_linearAlgebra.ZeroSubspaceCovarianceTests(methodName='runTest')[source]

Bases: fudge.core.math.test.test_linearAlgebra.Eigendecomposition_base, fudge.core.math.test.test_linearAlgebra.EigendecompositionTests_allShouldFail

Zeros? it still works!, but has negative eigenvalues

setUpMtx()[source]

Module contents