Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GraphDynamicalSystems"
uuid = "13529e2e-ed53-56b1-bd6f-420b01fca819"
authors = ["Reuben Gardos Reid <[email protected]>"]
version = "0.0.4"
version = "0.0.5"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
16 changes: 8 additions & 8 deletions src/qualitative_networks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const base_qn_grammar = @csgrammar begin
Val = Val - Val
Val = Val / Val
Val = Val * Val
Val = Min(Val, Val)
Val = Max(Val, Val)
Val = Ceil(Val)
Val = Floor(Val)
Val = min(Val, Val)
Val = max(Val, Val)
Val = ceil(Val)
Val = floor(Val)
end

const default_qn_constants = [0, 1, 2]
Expand Down Expand Up @@ -404,10 +404,10 @@ function interpret(e::Union{Expr,Symbol,Int}, qn::QN)
:($v1 - $v2) => interpret(v1, qn) - interpret(v2, qn)
:($v1 / $v2) => interpret(v1, qn) / interpret(v2, qn)
:($v1 * $v2) => interpret(v1, qn) * interpret(v2, qn)
:(Min($v1, $v2)) => min(interpret(v1, qn), interpret(v2, qn))
:(Max($v1, $v2)) => max(interpret(v1, qn), interpret(v2, qn))
:(Ceil($v)) => ceil(interpret(v, qn))
:(Floor($v)) => floor(interpret(v, qn))
:(min($v1, $v2)) => min(interpret(v1, qn), interpret(v2, qn))
:(max($v1, $v2)) => max(interpret(v1, qn), interpret(v2, qn))
:(ceil($v)) => ceil(interpret(v, qn))
:(floor($v)) => floor(interpret(v, qn))
_ => error("Unhandled Expr in `interpret`: $e")
end
end
Expand Down
12 changes: 7 additions & 5 deletions test/qn_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ end
set_state!(qn, :B, 2)
@test interpret(:(A / B), qn) == 0.5
@test interpret(:(A / 2), qn) == 0.5
@test interpret(:(Min(A, B)), qn) == 1
@test interpret(:(Max(A, B)), qn) == 2
@test interpret(:(Ceil(A / B)), qn) == 1
@test interpret(:(Floor(A / B)), qn) == 0
@test interpret(:(min(A, B)), qn) == 1
@test interpret(:(max(A, B)), qn) == 2
@test interpret(:(ceil(A / B)), qn) == 1
@test interpret(:(floor(A / B)), qn) == 0
@test_throws r"Unhandled" interpret(:(nonexistent_function(A)), qn)
end

Expand Down Expand Up @@ -142,14 +142,16 @@ end
@test_throws r"no activators or inhibitors" default_target_function(0, 4)
end

@testitem "Load from BMA" begin
@testitem "Load from BMA" setup = [RandomSetup] begin
using JSON
using DynamicalSystemsBase: step!
bma_models_path = joinpath(@__DIR__, "resources", "bma_models")
good_models = joinpath(bma_models_path, "well_formed_examples")

for model_path in readdir(good_models; join = true)
qn = QN(model_path)
@test qn isa GraphDynamicalSystem
step!(create_qn_system(qn), 100)
end

bad_models = joinpath(bma_models_path, "error_examples")
Expand Down
Loading