Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsas committed Aug 31, 2021
1 parent 218bf11 commit f3f7eb8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/networkapi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function substoichmat(::Type{Matrix{Int}},rn::ReactionSystem; smap=speciesmap(rn
end
smat
end
function substoichmat(rn::ReactionSystem; sparse::Bool=false; smap=speciesmap(rn))
function substoichmat(rn::ReactionSystem; sparse::Bool=false, smap=speciesmap(rn))
sparse ? substoichmat(SparseMatrixCSC{Int,Int}, rn; smap=smap) : substoichmat(Matrix{Int}, rn; smap=smap)
end

Expand All @@ -179,7 +179,7 @@ coefficient of the ith product within the jth reaction.
Note:
- Set sparse=true for a sparse matrix representation
"""
function prodstoichmat(::Type{SparseMatrixCSC{Int}}, rn::ReactionSystem; smap=speciesmap(rn))
function prodstoichmat(::Type{SparseMatrixCSC{Int,Int}}, rn::ReactionSystem; smap=speciesmap(rn))
Is=Int[]; Js=Int[]; Vs=Int[];
for (k,rx) in enumerate(reactions(rn))
stoich = rx.prodstoich
Expand Down Expand Up @@ -360,7 +360,7 @@ function reactioncomplexes(::Type{Matrix{Int}},rn::ReactionSystem;
end
complexes,B
end
function reactioncomplexes(rn::ReactionSystem; sparse=false; smap=speciesmap(rn))
function reactioncomplexes(rn::ReactionSystem; sparse=false, smap=speciesmap(rn))
sparse ? reactioncomplexes(SparseMatrixCSC{Int,Int}, rn; smap=smap) : reactioncomplexes(Matrix{Int}, rn; smap=smap)
end

Expand Down
10 changes: 6 additions & 4 deletions test/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ rnmat = @reaction_network begin
β, 3I --> 2R + S
end α β

smat = [1 2 0;
0 3 0]
pmat = [0 2 0;
1 0 2]
smat = [1 0;
2 3;
0 0]
pmat = [0 1;
2 0;
0 2]
@test smat == substoichmat(rnmat) == Matrix(substoichmat(rnmat, sparse=true))
@test pmat == prodstoichmat(rnmat) == Matrix(prodstoichmat(rnmat, sparse=true))

Expand Down

0 comments on commit f3f7eb8

Please sign in to comment.