def test_sparse_matrix(self, model): sparse_types = ['dok', 'lil'] solution = model.optimize() for sparse_type in sparse_types: S = create_stoichiometric_array(model, array_type=sparse_type) mass_balance = S.dot(solution.fluxes) assert numpy.allclose(mass_balance, 0)
def test_dense_matrix(self, model): S = create_stoichiometric_array(model, array_type='dense', dtype=int) assert S.dtype == int assert numpy.allclose(S.max(), [59]) S = create_stoichiometric_array(model, array_type='data_frame', dtype=int) assert S.stoichiometry.dtype == int assert numpy.allclose(S.stoichiometry.max(), [59]) S = create_stoichiometric_array(model, array_type='dense', dtype=float) solution = model.optimize() mass_balance = S.dot(solution.fluxes) assert numpy.allclose(mass_balance, 0)
def test_dense_matrix(self, model): S = create_stoichiometric_matrix(model, array_type='dense', dtype=int) assert S.dtype == int assert numpy.allclose(S.max(), [59]) S_df = create_stoichiometric_matrix(model, array_type='DataFrame', dtype=int) assert S_df.values.dtype == int assert numpy.all(S_df.columns == [r.id for r in model.reactions]) assert numpy.all(S_df.index == [m.id for m in model.metabolites]) assert numpy.allclose(S_df.values, S) S = create_stoichiometric_matrix(model, array_type='dense', dtype=float) solution = model.optimize() mass_balance = S.dot(solution.fluxes) assert numpy.allclose(mass_balance, 0)