From efaff1243a2401eb9e2eace14db318a597258a1f Mon Sep 17 00:00:00 2001 From: Orjan Ameye Date: Sat, 26 Oct 2024 11:15:21 +0200 Subject: [PATCH 1/5] test: enable JET --- test/runtests.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index e4883fae..1081be93 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,10 +5,10 @@ using Random const SEED = 0xd8e5d8df Random.seed!(SEED) -# @testset "Code linting" begin -# using JET -# JET.test_package(HarmonicBalance; target_defined_modules=true) -# end +@testset "Code linting" begin + using JET + JET.test_package(HarmonicBalance; target_defined_modules=true) +end @testset "Code quality" begin using ExplicitImports, Aqua From 8e2455f546f546ab04086de63d4696fb25c16e12 Mon Sep 17 00:00:00 2001 From: Orjan Ameye Date: Sat, 26 Oct 2024 18:08:55 +0200 Subject: [PATCH 2/5] fix `HarmonicBalance.simplify` and `HarmonicBalance.expand` JET error --- src/HarmonicEquation.jl | 2 +- src/HarmonicVariable.jl | 2 +- src/KrylovBogoliubov/KrylovEquation.jl | 2 +- src/LinearResponse/Lorentzian_spectrum.jl | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/HarmonicEquation.jl b/src/HarmonicEquation.jl index d5846309..69c9556b 100644 --- a/src/HarmonicEquation.jl +++ b/src/HarmonicEquation.jl @@ -167,7 +167,7 @@ end "Simplify the equations in HarmonicEquation." function simplify!(eom::HarmonicEquation) - return eom.equations = [simplify(eq) for eq in eom.equations] + return eom.equations = [Symbolics.simplify(eq) for eq in eom.equations] end """ diff --git a/src/HarmonicVariable.jl b/src/HarmonicVariable.jl index 7a1702c5..17d28c04 100644 --- a/src/HarmonicVariable.jl +++ b/src/HarmonicVariable.jl @@ -25,7 +25,7 @@ end # when HV is used for substitute, substitute its symbol function ExprUtils.substitute_all(eq::Union{Num,Equation}, rules::Dict{HarmonicVariable}) - return substitute(eq, Dict(zip(getfield.(keys(rules), :symbol), values(rules)))) + return Symbolics.substitute(eq, Dict(zip(getfield.(keys(rules), :symbol), values(rules)))) end function ExprUtils.substitute_all(var::HarmonicVariable, rules) diff --git a/src/KrylovBogoliubov/KrylovEquation.jl b/src/KrylovBogoliubov/KrylovEquation.jl index 439b9231..eb308be0 100644 --- a/src/KrylovBogoliubov/KrylovEquation.jl +++ b/src/KrylovBogoliubov/KrylovEquation.jl @@ -116,7 +116,7 @@ function van_der_Pol(eom::DifferentialEquation, t::Num) D = Differential(t) nvar_t = diff2term(D(unwrap(nvar))) vdP_rules = Dict(D(hvar_u.symbol) => 0, D(hvar_v.symbol) => 0) - rules[nvar_t] = substitute(expand_derivatives(D(rule)), vdP_rules) + rules[nvar_t] = Symbolics.substitute(expand_derivatives(D(rule)), vdP_rules) uv_idx += 1 push!(vars, hvar_u, hvar_v) diff --git a/src/LinearResponse/Lorentzian_spectrum.jl b/src/LinearResponse/Lorentzian_spectrum.jl index d83e7ee1..44c1ebce 100644 --- a/src/LinearResponse/Lorentzian_spectrum.jl +++ b/src/LinearResponse/Lorentzian_spectrum.jl @@ -90,7 +90,8 @@ function JacobianSpectrum(res::Result; index::Int, branch::Int, force=false) for pair in _get_uv_pairs(hvars) u, v = hvars[pair] eigvec_2d = eigvec[pair] # fetch the relevant part of the Jacobian eigenvector - ωnum = real(unwrap(substitute(u.ω, solution_dict))) # the harmonic (numerical now) associated to this harmonic variable + ωnum = real(unwrap(Symbolics.substitute(u.ω, solution_dict))) + # ^ the harmonic (numerical now) associated to this harmonic variable # eigvec_2d is associated to a natural variable -> this variable gets Lorentzian peaks peaks = norm(eigvec_2d) * _pair_to_peaks(λ, eigvec_2d; ω=ωnum) From c568e424663f77dda5112dc9e8bae063f14890d5 Mon Sep 17 00:00:00 2001 From: Orjan Ameye Date: Sat, 26 Oct 2024 18:14:11 +0200 Subject: [PATCH 3/5] format --- src/HarmonicVariable.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/HarmonicVariable.jl b/src/HarmonicVariable.jl index 17d28c04..149c8c8e 100644 --- a/src/HarmonicVariable.jl +++ b/src/HarmonicVariable.jl @@ -25,7 +25,9 @@ end # when HV is used for substitute, substitute its symbol function ExprUtils.substitute_all(eq::Union{Num,Equation}, rules::Dict{HarmonicVariable}) - return Symbolics.substitute(eq, Dict(zip(getfield.(keys(rules), :symbol), values(rules)))) + return Symbolics.substitute( + eq, Dict(zip(getfield.(keys(rules), :symbol), values(rules))) + ) end function ExprUtils.substitute_all(var::HarmonicVariable, rules) From 3f2a91c84a5bc1bc25b6139df0912ecdeebfc2a1 Mon Sep 17 00:00:00 2001 From: Orjan Ameye Date: Sat, 26 Oct 2024 18:15:31 +0200 Subject: [PATCH 4/5] fix `HarmonicBalance.LinearResponse` has unused explicit imports for: substitute --- src/LinearResponse/LinearResponse.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LinearResponse/LinearResponse.jl b/src/LinearResponse/LinearResponse.jl index 23fb42be..01ec7816 100644 --- a/src/LinearResponse/LinearResponse.jl +++ b/src/LinearResponse/LinearResponse.jl @@ -8,7 +8,7 @@ using Plots: heatmap, theme_palette, scatter, RGB, cgrad using Latexify: Latexify, latexify, @L_str using Latexify.LaTeXStrings: LaTeXStrings -using Symbolics: Num, Equation, substitute, unwrap +using Symbolics: Num, Equation, unwrap using LinearAlgebra: norm, eigvals, eigen, eigvecs using OrderedCollections: OrderedDict From b126b94e394479e2ed1f996d716d1e4de230337e Mon Sep 17 00:00:00 2001 From: Orjan Ameye Date: Sat, 26 Oct 2024 18:31:34 +0200 Subject: [PATCH 5/5] explicit imports Symbolics in LinearResponse.jl --- src/LinearResponse/LinearResponse.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LinearResponse/LinearResponse.jl b/src/LinearResponse/LinearResponse.jl index 01ec7816..c3390fbe 100644 --- a/src/LinearResponse/LinearResponse.jl +++ b/src/LinearResponse/LinearResponse.jl @@ -8,7 +8,7 @@ using Plots: heatmap, theme_palette, scatter, RGB, cgrad using Latexify: Latexify, latexify, @L_str using Latexify.LaTeXStrings: LaTeXStrings -using Symbolics: Num, Equation, unwrap +using Symbolics: Symbolics, Num, Equation, unwrap using LinearAlgebra: norm, eigvals, eigen, eigvecs using OrderedCollections: OrderedDict