Unverified Commit d4342185 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil 🚴
Browse files

clean up constants handling

parent 89354d95
......@@ -26,13 +26,6 @@ import SBML # conflict with Reaction struct name
include("banner.jl")
_print_banner()
# Constants
default_constants = (
FVA_TOL = 1e-6, # optimum bound
TEST_TOL = 1e-6, # default tolerance used for tests
TEST_RELAX_TOL = 0.5, # relaxed tolerance used for tests
)
# autoloading
const _inc(path...) = include(joinpath(path...))
const _inc_all(dir) = _inc.(joinpath.(dir, filter(fn -> endswith(fn, ".jl"), readdir(dir))))
......
......@@ -116,7 +116,7 @@ function _FVA_optimize_reaction(model, rid)
end
"""
fva(model::StandardModel, optimizer; optimum_bound=1.0-DEFAULT_FVA_TOL, modifications)
fva(model::StandardModel, optimizer; optimum_bound=1.0-_constants.tolerance, modifications)
Run flux variability analysis (FVA) on the `model` (of type `StandardModel`).
Optionally specifying problem modifications like in [`flux_balance_analysis`](@ref).
......@@ -141,7 +141,7 @@ fva_max, fva_min = fva(model, biomass, optimizer; solver_attributes=atts)
function flux_variability_analysis(
model::StandardModel,
optimizer;
optimum_bound = 1.0 - default_constants.FVA_TOL,
optimum_bound = 1.0 - _constants.tolerance,
modifications = [(model, opt_model) -> nothing],
)
# Run FBA
......
......@@ -65,7 +65,7 @@ end
@test isapprox(
sol["BIOMASS_Ecoli_core_w_GAM"],
1.0572509997013568,
atol = default_constants.TEST_TOL,
atol = TEST_TOLERANCE,
)
pfl = findfirst(model.reactions, "PFL")
......@@ -82,6 +82,6 @@ end
@test isapprox(
biomass_frac * sol_multi["BIOMASS_Ecoli_core_w_GAM"] + pfl_frac * sol_multi["PFL"],
31.999999998962604,
atol = default_constants.TEST_TOL,
atol = TEST_TOLERANCE,
)
end
......@@ -83,14 +83,6 @@ end
],
)
@test isapprox(
fva_max["EX_ac_e"]["EX_ac_e"],
8.518549434876208,
atol = default_constants.TEST_TOL,
)
@test isapprox(
fva_min["EX_ac_e"]["EX_ac_e"],
7.448388738973361,
atol = default_constants.TEST_TOL,
)
@test isapprox(fva_max["EX_ac_e"]["EX_ac_e"], 8.518549434876208, atol = TEST_TOLERANCE)
@test isapprox(fva_min["EX_ac_e"]["EX_ac_e"], 7.448388738973361, atol = TEST_TOLERANCE)
end
......@@ -31,6 +31,6 @@
qp_solver_attributes = change_solver_attribute("verbose", false),
)
@test isapprox(d["PGM"], -17.568590034769613, atol = default_constants.TEST_RELAX_TOL)
@test isapprox(v[8], -17.568590034769613, atol = default_constants.TEST_RELAX_TOL) # OSQP sucks
@test isapprox(d["PGM"], -17.568590034769613, atol = 0.5)
@test isapprox(v[8], -17.568590034769613, atol = 0.5)
end
......@@ -15,6 +15,10 @@ using Statistics
using JSON
using Measurements
# tolerance for comparing analysis results (should be a bit bigger than the
# error tolerance in computations)
TEST_TOLERANCE = 10 * COBREXA._constants.tolerance
function run_test_file(path...)
fn = joinpath(path...)
t = @elapsed include(fn)
......
......@@ -25,5 +25,5 @@
samples = hit_and_run(100_000, opt_model, keepevery = 10, samplesize = 5000)
@test isapprox(mean(samples[64, :]), 8.9, atol = default_constants.TEST_RELAX_TOL) # only tests if the sampler approximately converged
@test isapprox(mean(samples[64, :]), 8.9, atol = 0.1) # only tests if the sampler very approximately converged
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment