def test_indexed_matrix_6(): indices = [2, 3, 5, 7] matrix = IndexedMatrix(indices=indices) matrix.add_indices([6, 10]) # One of the indices does not exist, so this raises an Exception. matrix.remove_indices([5, 6, 9])
def test_indexed_matrix_3(): indices = [2, 3, 5, 7] matrix = IndexedMatrix(indices=indices) matrix.add_indices(4) assert matrix.shape == (5, 5) assert np.array_equal(matrix.indices, [2, 3, 4, 5, 7])
def test_indexed_matrix_5(): indices = [2, 3, 5, 7] matrix = IndexedMatrix(indices=indices) matrix.add_indices([6, 10]) assert matrix.shape == (6, 6) assert np.array_equal(matrix.indices, [2, 3, 5, 6, 7, 10]) matrix.remove_indices(7) assert matrix.shape == (5, 5) assert np.array_equal(matrix.indices, [2, 3, 5, 6, 10])
def test_indexed_matrix_9(): matrix = IndexedMatrix() indices = [10, 20] matrix.add_indices(10) assert np.array_equal(matrix.not_in_indices(indices), [20]) matrix[10, 10] = 1 assert np.array_equal(matrix.not_in_indices(indices), [20]) matrix.add_indices(20) assert np.array_equal(matrix.not_in_indices(indices), []) matrix[20, :] = 0 matrix[:, 20] = 0 assert np.array_equal(matrix.not_in_indices(indices), [])
def test_indexed_matrix_4(): indices = [2, 3, 5, 7] matrix = IndexedMatrix(indices=indices) matrix.add_indices(7) assert np.array_equal(matrix.indices, indices)