Skip to content

Commit

Permalink
formatter...
Browse files Browse the repository at this point in the history
  • Loading branch information
pogudingleb committed Jan 8, 2024
1 parent 9d6a27a commit 8c30f65
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
21 changes: 17 additions & 4 deletions src/RationalFunctionFields/RationalFunctionField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,30 @@ function field_contains(
return field_contains(field, fractions_to_dennums(ratfuncs), prob_threshold)
end

function field_contains(field::RationalFunctionField{T}, polys::Vector{T}, prob_threshold) where {T}
function field_contains(
field::RationalFunctionField{T},
polys::Vector{T},
prob_threshold,
) where {T}
id = one(parent(first(polys)))
return field_contains(field, [[id, p] for p in polys], prob_threshold)
end

# ------------------------------------------------------------------------------

function issubfield(F::RationalFunctionField{T}, E::RationalFunctionField{T}, prob_threshold) where {T}
function issubfield(
F::RationalFunctionField{T},
E::RationalFunctionField{T},
prob_threshold,
) where {T}
return all(field_contains(E, F.dennums, prob_threshold))
end

function fields_equal(F::RationalFunctionField{T}, E::RationalFunctionField{T}, prob_threshold) where {T}
function fields_equal(
F::RationalFunctionField{T},
E::RationalFunctionField{T},
prob_threshold,
) where {T}
new_p = 1 - (1 - prob_threshold) / 2
return issubfield(F, E, new_p) && issubfield(E, F, new_p)
end
Expand Down Expand Up @@ -558,7 +570,8 @@ Out of $(length(new_fracs)) fractions $(length(new_fracs_unique)) are syntactica
runtime =
@elapsed new_fracs = beautifuly_generators(RationalFunctionField(new_fracs_unique))
@debug "Checking inclusion with probability $prob_threshold"
runtime = @elapsed result = issubfield(rff, RationalFunctionField(new_fracs), prob_threshold)
runtime =
@elapsed result = issubfield(rff, RationalFunctionField(new_fracs), prob_threshold)
_runtime_logger[:id_inclusion_check] = runtime
if !result
@warn "Field membership check failed. Error will follow."
Expand Down
12 changes: 10 additions & 2 deletions src/StructuralIdentifiability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ function assess_identifiability(
restart_logging(loglevel = loglevel)
reset_timings()
with_logger(_si_logger[]) do
return _assess_identifiability(ode, funcs_to_check = funcs_to_check, prob_threshold = prob_threshold)
return _assess_identifiability(
ode,
funcs_to_check = funcs_to_check,
prob_threshold = prob_threshold,
)
end
end

Expand Down Expand Up @@ -214,7 +218,11 @@ function _assess_identifiability(
end
funcs_to_check_ = [eval_at_nemo(each, conversion) for each in funcs_to_check]

result = _assess_identifiability(ode, funcs_to_check = funcs_to_check_, prob_threshold = prob_threshold)
result = _assess_identifiability(
ode,
funcs_to_check = funcs_to_check_,
prob_threshold = prob_threshold,
)
nemo2mtk = Dict(funcs_to_check_ .=> funcs_to_check)
out_dict = OrderedDict(nemo2mtk[param] => result[param] for param in funcs_to_check_)
return out_dict
Expand Down
8 changes: 6 additions & 2 deletions src/discrete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,12 @@ function _assess_local_identifiability(
funcs_to_check_ = [eval_at_nemo(x, conversion) for x in funcs_to_check]
known_ic_ = [eval_at_nemo(x, conversion) for x in known_ic]

result =
_assess_local_identifiability_discrete_aux(dds_aux, funcs_to_check_, known_ic_, prob_threshold)
result = _assess_local_identifiability_discrete_aux(
dds_aux,
funcs_to_check_,
known_ic_,
prob_threshold,
)
nemo2mtk = Dict(funcs_to_check_ .=> funcs_to_check)
out_dict = OrderedDict(nemo2mtk[param] => result[param] for param in funcs_to_check_)
if length(known_ic) > 0
Expand Down
8 changes: 6 additions & 2 deletions src/parametrizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,12 @@ end

function _reparametrize_global(ode::ODE{P}; prob_threshold = 0.99, seed = 42) where {P}
Random.seed!(seed)
id_funcs =
find_identifiable_functions(ode, with_states = true, simplify = :strong, prob_threshold = prob_threshold)
id_funcs = find_identifiable_functions(
ode,
with_states = true,
simplify = :strong,
prob_threshold = prob_threshold,
)
ode_ring = parent(ode)
@assert base_ring(parent(first(id_funcs))) == ode_ring
@info "Constructing a new parametrization"
Expand Down

0 comments on commit 8c30f65

Please sign in to comment.