Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v14 - Ready] Fix deprecated method usage and unnecessary prints while tests run #928

Merged
merged 6 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
Graphviz_jll = "3c863552-8265-54e4-a6dc-903eb78fde85"
HomotopyContinuation = "f213a82b-91d6-5c5d-acf7-10f1c761b327"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
isaacsas marked this conversation as resolved.
Show resolved Hide resolved
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand All @@ -83,4 +84,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["BifurcationKit", "DiffEqCallbacks", "DomainSets", "Graphviz_jll", "HomotopyContinuation", "NonlinearSolve", "OrdinaryDiffEq", "Plots", "Random", "SafeTestsets", "SciMLBase", "SciMLNLSolve", "StableRNGs", "Statistics", "SteadyStateDiffEq", "StochasticDiffEq", "StructuralIdentifiability", "Test", "Unitful"]
test = ["BifurcationKit", "DiffEqCallbacks", "DomainSets", "Graphviz_jll", "HomotopyContinuation", "Logging", "NonlinearSolve", "OrdinaryDiffEq", "Plots", "Random", "SafeTestsets", "SciMLBase", "SciMLNLSolve", "StableRNGs", "Statistics", "SteadyStateDiffEq", "StochasticDiffEq", "StructuralIdentifiability", "Test", "Unitful"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
function BK.BifurcationProblem(rs::ReactionSystem, u0_bif, ps, bif_par, args...;
plot_var = nothing, record_from_solution = BK.record_sol_default, jac = true, u0 = [], kwargs...)
if !isautonomous(rs)
error("Attempting to create a `BifurcationProblem` for a non-autonomous system (e.g. where some rate depend on $(rs.iv)). This is not possible.")
error("Attempting to create a `BifurcationProblem` for a non-autonomous system (e.g. where some rate depend on $(get_iv(rs))). This is not possible.")
end

# Converts symbols to symbolics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Notes:
function Catalyst.hc_steady_states(rs::ReactionSystem, ps; filter_negative = true,
neg_thres = -1e-20, u0 = [], kwargs...)
if !isautonomous(rs)
error("Attempting to compute steady state for a non-autonomous system (e.g. where some rate depend on $(rs.iv)). This is not possible.")
error("Attempting to compute steady state for a non-autonomous system (e.g. where some rate depend on $(get_iv(rs))). This is not possible.")
end
ss_poly = steady_state_polynomial(rs, ps, u0)
sols = HC.real_solutions(HC.solve(ss_poly; kwargs...))
Expand Down Expand Up @@ -67,7 +67,7 @@ function make_int_exps(expr)
wrap(Rewriters.Postwalk(Rewriters.PassThrough(___make_int_exps))(unwrap(expr))).val
end
function ___make_int_exps(expr)
!istree(expr) && return expr
!iscall(expr) && return expr
if (operation(expr) == ^)
if isinteger(arguments(expr)[2])
return arguments(expr)[1]^Int64(arguments(expr)[2])
Expand Down
2 changes: 1 addition & 1 deletion src/reactionsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1479,4 +1479,4 @@
end

# Checks if a unit consist of exponents with base 1 (and is this unitless).
unitless_exp(u) = istree(u) && (operation(u) == ^) && (arguments(u)[1] == 1)
unitless_exp(u) = iscall(u) && (operation(u) == ^) && (arguments(u)[1] == 1)

Check warning on line 1482 in src/reactionsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/reactionsystem.jl#L1482

Added line #L1482 was not covered by tests
isaacsas marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion src/reactionsystem_conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@
iscomplete(rs) || error(COMPLETENESS_ERROR)
spatial_convert_err(rs::ReactionSystem, NonlinearSystem)
if !isautonomous(rs)
error("Attempting to convert a non-autonomous `ReactionSystem` (e.g. where some rate depend on $(rs.iv)) to a `NonlinearSystem`. This is not possible. if you are intending to compute system steady states, consider creating and solving a `SteadyStateProblem.")
error("Attempting to convert a non-autonomous `ReactionSystem` (e.g. where some rate depend on $(get_iv(rs))) to a `NonlinearSystem`. This is not possible. if you are intending to compute system steady states, consider creating and solving a `SteadyStateProblem.")

Check warning on line 523 in src/reactionsystem_conversions.jl

View check run for this annotation

Codecov / codecov/patch

src/reactionsystem_conversions.jl#L523

Added line #L523 was not covered by tests
end

# Generates system equations.
Expand Down
2 changes: 1 addition & 1 deletion src/reactionsystem_serialisation/serialisation_support.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ const SKIPPED_METADATA = [ModelingToolkit.MTKVariableTypeCtx, Symbolics.Variable
# Potentially strips the call for a symbolics. E.g. X(t) becomes X (but p remains p). This is used
# when variables are written to files, as in code they are used without the call part.
function strip_call(sym)
return istree(sym) ? Sym{Real}(Symbolics.getname(sym)) : sym
return iscall(sym) ? Sym{Real}(Symbolics.getname(sym)) : sym
end

# For an vector of symbolics, creates a dictionary taking each symbolics to each call-stripped form.
Expand Down
6 changes: 3 additions & 3 deletions src/reactionsystem_serialisation/serialise_reactionsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ function make_reaction_system_call(
has_connection_type && (@string_append! reaction_system_string ", connection_type")

# Potentially appends a combinatoric_ratelaws statement.
if !Symbolics.unwrap(rs.combinatoric_ratelaws)
if !Symbolics.unwrap(combinatoric_ratelaws(rs))
@string_append! reaction_system_string ", combinatoric_ratelaws = false"
end

# Potentially appends `ReactionSystem` metadata value(s). Weird composite types are not supported.
if !isnothing(rs.metadata)
@string_append! reaction_system_string ", metadata = $(x_2_string(rs.metadata))"
if !isnothing(MT.get_metadata(rs))
@string_append! reaction_system_string ", metadata = $(x_2_string(MT.get_metadata(rs)))"
end

# Finalises the call. Appends potential annotation. If the system is complete, add a call for this.
Expand Down
2 changes: 1 addition & 1 deletion src/steady_state_stability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
tol = 10 * sqrt(eps(ss_val_type(u))), ss_jac = steady_state_jac(rs; u0 = u))
# Warning checks.
if !isautonomous(rs)
error("Attempting to compute stability for a non-autonomous system (e.g. where some rate depend on $(rs.iv)). This is not possible.")
error("Attempting to compute stability for a non-autonomous system (e.g. where some rate depend on $(get_iv(rs))). This is not possible.")

Check warning on line 51 in src/steady_state_stability.jl

View check run for this annotation

Codecov / codecov/patch

src/steady_state_stability.jl#L51

Added line #L51 was not covered by tests
end

# If `u` is a vector of values, we convert it to a map. Also, if there are conservation laws,
Expand Down
4 changes: 2 additions & 2 deletions test/dsl/dsl_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,8 @@ let
end
end
V,W = getfield.(observed(rn), :lhs)
@test isequal(arguments(ModelingToolkit.unwrap(V)), Any[rn.iv, rn.sivs[1], rn.sivs[2]])
@test isequal(arguments(ModelingToolkit.unwrap(W)), Any[rn.iv, rn.sivs[2]])
@test isequal(arguments(ModelingToolkit.unwrap(V)), Any[Catalyst.get_iv(rn), Catalyst.get_sivs(rn)[1], Catalyst.get_sivs(rn)[2]])
@test isequal(arguments(ModelingToolkit.unwrap(W)), Any[Catalyst.get_iv(rn), Catalyst.get_sivs(rn)[2]])
end

# Checks that metadata is written properly.
Expand Down
Loading
Loading