def test_kmr_matrix(): """Test with KMR matrices""" print(__name__ + '.' + test_kmr_matrix.__name__) matrices = Matrices() for matrix_dict in matrices.kmr_matrix_dicts: x = gth_solve(matrix_dict['A']) yield StationaryDistSumOne(), x yield StationaryDistNonnegative(), x yield StationaryDistLeftEigenVec(), matrix_dict['A'], x
def test_stoch_matrix(): """Test with stochastic matrices""" print(__name__ + '.' + test_stoch_matrix.__name__) matrices = Matrices() for matrix_dict in matrices.stoch_matrix_dicts: x = gth_solve(matrix_dict['A']) yield StationaryDistSumOne(), x yield StationaryDistNonnegative(), x yield StationaryDistEqualToKnown(), matrix_dict['stationary_dist'], x
def test_matrices_with_C_F_orders(): """ Test matrices with C- and F-contiguous orders See the issue and fix on Numba: github.com/numba/numba/issues/1103 github.com/numba/numba/issues/1104 Fix in gth_solve(A): added `order='C'` when `A1` copies the input `A` """ P_C = np.array([[0.5, 0.5], [0, 1]], order='C') P_F = np.array([[0.5, 0.5], [0, 1]], order='F') stationary_dist = [0., 1.] computed_C_and_F = gth_solve(np.array([[1]])) assert_array_equal(computed_C_and_F, [1]) computed_C = gth_solve(P_C) computed_F = gth_solve(P_F) assert_array_equal(computed_C, stationary_dist) assert_array_equal(computed_F, stationary_dist)
def test_gen_matrix_1(): """Test with generator matrices""" matrices = Matrices() for matrix_dict in matrices.gen_matrix_dicts: x = gth_solve(matrix_dict['A']) StationaryDistEqualToKnown()(matrix_dict['stationary_dist'], x)
def test_gen_matrix(test_class): """Test with generator matrices""" matrices = Matrices() for matrix_dict in matrices.gen_matrix_dicts: x = gth_solve(matrix_dict['A']) test_class()(x)
def test_kmr_matrix_1(): """Test with KMR matrices""" matrices = Matrices() for matrix_dict in matrices.kmr_matrix_dicts: x = gth_solve(matrix_dict['A']) StationaryDistLeftEigenVec()(matrix_dict['A'], x)
def test_kmr_matrix(test_class): """Test with KMR matrices""" matrices = Matrices() for matrix_dict in matrices.kmr_matrix_dicts: x = gth_solve(matrix_dict['A']) test_class()(x)
def test_stoch_matrix_1(): """Test with stochastic matrices""" matrices = Matrices() for matrix_dict in matrices.stoch_matrix_dicts: x = gth_solve(matrix_dict['A']) StationaryDistEqualToKnown()(matrix_dict['stationary_dist'], x)
def test_stoch_matrix(test_class): """Test with stochastic matrices""" matrices = Matrices() for matrix_dict in matrices.stoch_matrix_dicts: x = gth_solve(matrix_dict['A']) test_class()(x)
def test_raises_value_error_non_square(): """Test with non square input""" gth_solve(np.array([[0.4, 0.6]]))
def test_raises_value_error_non_2dim(): """Test with non 2dim input""" gth_solve(np.array([0.4, 0.6]))