From ff48e5fba24689debc46c2def9ce7bea9ddf7938 Mon Sep 17 00:00:00 2001 From: Orjan Ameye Date: Sat, 26 Oct 2024 12:34:08 +0100 Subject: [PATCH] fix: fix krylov variable show method (#285) --- src/types.jl | 3 ++- test/krylov.jl | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/types.jl b/src/types.jl index f94477e6..ec2b7f11 100644 --- a/src/types.jl +++ b/src/types.jl @@ -164,7 +164,8 @@ end """Gives the full harmonic ansatz used to construct `eom`.""" function _show_ansatz(eom::HarmonicEquation) output = "" - for nat_var in get_variables(eom.natural_equation) + vars = unique(getfield.(eom.variables, :natural_variable)) + for nat_var in vars # the Hopf variable (limit cycle frequency) does not contribute a term harm_vars = filter( x -> isequal(nat_var, x.natural_variable) && x.type !== "Hopf", eom.variables diff --git a/test/krylov.jl b/test/krylov.jl index 406907c6..4f1cae94 100644 --- a/test/krylov.jl +++ b/test/krylov.jl @@ -19,6 +19,11 @@ add_harmonic!(diff_eom, x, ω) # x will rotate at ω harmonic_eq1 = get_krylov_equations(diff_eom; order=1) harmonic_eq2 = get_krylov_equations(diff_eom; order=2) +@testset "show method" begin + print_variable = HB._show_ansatz(harmonic_eq1) + @test !(occursin("xˍt(t)", print_variable)) +end + fixed = (ω0 => 1.0, γ => 0.005, α => 1.0, η => 0, F => 0.0, ψ => 0.0, θ => 0.0) varied = (ω => range(0.99, 1.01, 5), λ => range(1e-6, 0.05, 5))