From ae04fe79c5285fa40c51cb4aa95f6257b5326206 Mon Sep 17 00:00:00 2001 From: Arno Strouwen Date: Sat, 2 Dec 2023 19:14:20 +0100 Subject: [PATCH 1/2] typos CI --- .github/workflows/SpellCheck.yml | 13 +++++++++++++ .typos.toml | 1 + docs/src/libs/datadrivendmd/example_02.jl | 2 +- docs/src/libs/datadrivendmd/example_04.jl | 2 +- lib/DataDrivenDMD/src/type.jl | 2 +- lib/DataDrivenLux/src/algorithms/rewards.jl | 2 +- lib/DataDrivenLux/src/caches/candidate.jl | 4 ++-- lib/DataDrivenLux/src/solve.jl | 2 +- lib/DataDrivenLux/test/candidate.jl | 2 +- lib/DataDrivenSR/src/DataDrivenSR.jl | 6 +++--- lib/DataDrivenSparse/src/commonsolve.jl | 2 +- src/DataDrivenDiffEq.jl | 2 +- src/basis/build_function.jl | 4 ++-- src/basis/type.jl | 2 +- src/commonsolve.jl | 2 +- src/problem/type.jl | 6 +++--- src/utils/build_basis.jl | 4 ++-- src/utils/common_options.jl | 2 +- 18 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/SpellCheck.yml create mode 100644 .typos.toml diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml new file mode 100644 index 000000000..599253c8c --- /dev/null +++ b/.github/workflows/SpellCheck.yml @@ -0,0 +1,13 @@ +name: Spell Check + +on: [pull_request] + +jobs: + typos-check: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v3 + - name: Check spelling + uses: crate-ci/typos@v1.16.23 \ No newline at end of file diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 000000000..79b68a4c0 --- /dev/null +++ b/.typos.toml @@ -0,0 +1 @@ +[default.extend-words] \ No newline at end of file diff --git a/docs/src/libs/datadrivendmd/example_02.jl b/docs/src/libs/datadrivendmd/example_02.jl index 5a727814e..91750b818 100644 --- a/docs/src/libs/datadrivendmd/example_02.jl +++ b/docs/src/libs/datadrivendmd/example_02.jl @@ -20,7 +20,7 @@ sys = ODEProblem(f, u0, tspan) sol = solve(sys, Tsit5(), saveat = 0.05); # We could use the `DESolution` to define our problem, but here we want to use the data for didactic purposes. -# For a [`ContinuousDataDrivenProblem`](@ref DataDrivenProblem), we need either the state trajectory and the timepoints or the state trajectory and its derivate. +# For a [`ContinuousDataDrivenProblem`](@ref DataDrivenProblem), we need either the state trajectory and the timepoints or the state trajectory and its derivative. X = Array(sol) t = sol.t diff --git a/docs/src/libs/datadrivendmd/example_04.jl b/docs/src/libs/datadrivendmd/example_04.jl index 8add48ee2..df92851db 100644 --- a/docs/src/libs/datadrivendmd/example_04.jl +++ b/docs/src/libs/datadrivendmd/example_04.jl @@ -1,4 +1,4 @@ -# # [Nonlinear Time Continuous System](@id nonlinear_continuos) +# # [Nonlinear Time Continuous System](@id nonlinear_continuous) # # Similarly, we can use the [Extended Dynamic Mode Decomposition](https://link.springer.com/article/10.1007/s00332-015-9258-5) via a nonlinear [`Basis`](@ref) of observables. Here, we will look at a rather [famous example](https://arxiv.org/pdf/1510.03007.pdf) with a finite dimensional solution. diff --git a/lib/DataDrivenDMD/src/type.jl b/lib/DataDrivenDMD/src/type.jl index 5b651faf1..f0eb185c1 100644 --- a/lib/DataDrivenDMD/src/type.jl +++ b/lib/DataDrivenDMD/src/type.jl @@ -101,7 +101,7 @@ Return the approximation of the discrete Koopman operator stored in `k`. """ operator(k::Koopman{<:Any, <:Any, <:Any, true}) = __get_K(k) function operator(k::Koopman{<:Any, <:Any, <:Any, false}) - throw(AssertionError("Koopman is continouos.")) + throw(AssertionError("Koopman is continuous.")) end """_ diff --git a/lib/DataDrivenLux/src/algorithms/rewards.jl b/lib/DataDrivenLux/src/algorithms/rewards.jl index 055074815..04fb9ad31 100644 --- a/lib/DataDrivenLux/src/algorithms/rewards.jl +++ b/lib/DataDrivenLux/src/algorithms/rewards.jl @@ -19,7 +19,7 @@ end """ $(TYPEDEF) -Scales the losses in such a way that the minimum loss is the most influencial reward. +Scales the losses in such a way that the minimum loss is the most influential reward. """ struct AbsoluteReward{risk} <: AbstractRewardScale{risk} end diff --git a/lib/DataDrivenLux/src/caches/candidate.jl b/lib/DataDrivenLux/src/caches/candidate.jl index 7cdc1ec46..cc0b3d783 100644 --- a/lib/DataDrivenLux/src/caches/candidate.jl +++ b/lib/DataDrivenLux/src/caches/candidate.jl @@ -224,7 +224,7 @@ get_nodes(c::Candidate) = ChainRulesCore.@ignore_derivatives get_nodes(c.outgoin function convert_to_basis(candidate::Candidate, ps = candidate.ps, options = DataDrivenCommonOptions()) @unpack basis, model = candidate.model - @unpack eval_expresssion = options + @unpack eval_expression = options p_best = get_parameters(candidate) p_new = map(enumerate(ModelingToolkit.parameters(basis))) do (i, ps) @@ -243,5 +243,5 @@ function convert_to_basis(candidate::Candidate, ps = candidate.ps, controls = controls(basis), observed = observed(basis), implicits = implicit_variables(basis), name = gensym(:Basis), - eval_expression = eval_expresssion) + eval_expression = eval_expression) end diff --git a/lib/DataDrivenLux/src/solve.jl b/lib/DataDrivenLux/src/solve.jl index 5ba4ab596..84932eb79 100644 --- a/lib/DataDrivenLux/src/solve.jl +++ b/lib/DataDrivenLux/src/solve.jl @@ -15,7 +15,7 @@ function CommonSolve.solve!(prob::InternalDataDrivenProblem{A}) where { AbstractDAGSRAlgorithm } @unpack alg, basis, testdata, traindata, control_idx, options, problem, kwargs = prob - @unpack maxiters, progress, eval_expresssion, abstol = options + @unpack maxiters, progress, eval_expression, abstol = options cache = init_cache(alg, basis, problem) p = ProgressMeter.Progress(maxiters, dt = 0.1, enabled = progress) diff --git a/lib/DataDrivenLux/test/candidate.jl b/lib/DataDrivenLux/test/candidate.jl index a347bbbea..b1ead8994 100644 --- a/lib/DataDrivenLux/test/candidate.jl +++ b/lib/DataDrivenLux/test/candidate.jl @@ -30,7 +30,7 @@ using StableRNGs options = Optim.Options()) end -@testset "Candidate with parametes" begin +@testset "Candidate with parameters" begin fs = (exp,) arities = (1,) dag = LayeredDAG(1, 1, 1, arities, fs, skip = true) diff --git a/lib/DataDrivenSR/src/DataDrivenSR.jl b/lib/DataDrivenSR/src/DataDrivenSR.jl index 232bc830f..e78df4f75 100644 --- a/lib/DataDrivenSR/src/DataDrivenSR.jl +++ b/lib/DataDrivenSR/src/DataDrivenSR.jl @@ -131,7 +131,7 @@ end function convert_to_basis(paretofrontier, prob) @unpack alg, basis, problem, options = prob @unpack eq_options = alg - @unpack maxiters, eval_expresssion, generate_symbolic_parameters, digits, roundingmode = options + @unpack maxiters, eval_expression, generate_symbolic_parameters, digits, roundingmode = options eqs_ = map(paretofrontier) do dom node_to_symbolic(dom[end].tree, eq_options) @@ -175,7 +175,7 @@ function convert_to_basis(paretofrontier, prob) controls = controls(basis), observed = observed(basis), implicits = implicit_variables(basis), name = gensym(:Basis), - eval_expression = eval_expresssion) + eval_expression = eval_expression) end # apply the algorithm on each dataset @@ -207,7 +207,7 @@ function CommonSolve.solve!(ps::InternalDataDrivenProblem{EQSearch}) @unpack alg, basis, testdata, traindata, kwargs = ps @unpack weights, numprocs, procs, addprocs_function, parallelism, runtests, eq_options = alg @unpack traindata, testdata, basis, options = ps - @unpack maxiters, eval_expresssion, generate_symbolic_parameters, digits, roundingmode, selector = options + @unpack maxiters, eval_expression, generate_symbolic_parameters, digits, roundingmode, selector = options @unpack problem = ps results = map(traindata) do (X, Y) diff --git a/lib/DataDrivenSparse/src/commonsolve.jl b/lib/DataDrivenSparse/src/commonsolve.jl index e3cafce08..c38ca1636 100644 --- a/lib/DataDrivenSparse/src/commonsolve.jl +++ b/lib/DataDrivenSparse/src/commonsolve.jl @@ -69,7 +69,7 @@ function __sparse_regression(ps::InternalDataDrivenProblem{<:ImplicitOptimizer}, opt_iterations = [] foreach(enumerate(eachcol(candidate_matrix))) do (i, idx) - # We enforce that one of the implicit variables is necessary for sucess + # We enforce that one of the implicit variables is necessary for success coeff, thresholds, iters = alg(X[idx, :], Y, options = options, necessary_idx = implicit_idx[idx, i]) opt_coefficients[i:i, idx] .= coeff diff --git a/src/DataDrivenDiffEq.jl b/src/DataDrivenDiffEq.jl index 05704a283..3372f029e 100644 --- a/src/DataDrivenDiffEq.jl +++ b/src/DataDrivenDiffEq.jl @@ -44,7 +44,7 @@ using RecipesBase @enum DDProbType begin Direct = 1 # Direct problem without further information Discrete = 2 # Time discrete problem - Continuous = 3 # Time continous problem + Continuous = 3 # Time continuous problem end # We want to export the ReturnCodes diff --git a/src/basis/build_function.jl b/src/basis/build_function.jl index 7d780b668..881dad4e5 100644 --- a/src/basis/build_function.jl +++ b/src/basis/build_function.jl @@ -61,7 +61,7 @@ function (f::DataDrivenFunction{false, true})(u::AbstractVector, p::P, t::Number _apply_function(f, __EMPTY_VECTOR, u, p, t, c) end -# With implict, without controls +# With implicit, without controls function (f::DataDrivenFunction{true, false})(du::AbstractVector, u::AbstractVector, p::P, t::Number) where { P <: @@ -100,7 +100,7 @@ function (f::DataDrivenFunction{false, true})(res::AbstractVector, u::AbstractVe _apply_function!(f, res, __EMPTY_VECTOR, u, p, t, c) end -# With implict, without controls +# With implicit, without controls function (f::DataDrivenFunction{true, false})(res::AbstractVector, du::AbstractVector, u::AbstractVector, p::P, t::Number) where { diff --git a/src/basis/type.jl b/src/basis/type.jl index 3f6e4909f..edc122a2a 100644 --- a/src/basis/type.jl +++ b/src/basis/type.jl @@ -289,7 +289,7 @@ function (b::Basis{false, true})(u::AbstractVector, f(u, p, t, c) end -# With implict, without controls +# With implicit, without controls function (b::Basis{true, false})(du::AbstractVector, u::AbstractVector, p::P = parameters(b), t::Number = get_iv(b)) where { diff --git a/src/commonsolve.jl b/src/commonsolve.jl index c9c2069ac..2bf46c417 100644 --- a/src/commonsolve.jl +++ b/src/commonsolve.jl @@ -93,6 +93,6 @@ function CommonSolve.init(prob::AbstractDataDrivenProblem, basis::AbstractBasis, end function CommonSolve.solve!(::InternalDataDrivenProblem{ZeroDataDrivenAlgorithm}) - @warn "No sufficient algorithm choosen! Return ErrorDataDrivenResult!" + @warn "No sufficient algorithm chosen! Return ErrorDataDrivenResult!" return ErrorDataDrivenResult() end diff --git a/src/problem/type.jl b/src/problem/type.jl index 56e5eb5e6..cc33a9ac5 100644 --- a/src/problem/type.jl +++ b/src/problem/type.jl @@ -58,7 +58,7 @@ Three construction methods are available: + `DirectDataDrivenProblem` for direct mappings + `DiscreteDataDrivenProblem` for time discrete systems -+ `ContinousDataDrivenProblem` for systems continuous in time ++ `ContinuousDataDrivenProblem` for systems continuous in time where all are aliases for constructing a problem. @@ -123,7 +123,7 @@ function DataDrivenProblem(probType, X, t, DX, Y, U, p; name = gensym(:DDProblem if (isempty(DX) && !isempty(Y)) probType = DDProbType(1) # Direct problem elseif !isempty(DX) - probType = DDProbType(3) # Continouos + probType = DDProbType(3) # Continuous end end @@ -206,7 +206,7 @@ function DiscreteDataDrivenProblem(X::AbstractMatrix, t::AbstractVector, U::Func return DataDrivenProblem(X; t = t, U = U, probtype = DDProbType(2), kwargs...) end -## Continouos Constructors +## Continuous Constructors """ A time continuous `DataDrivenProblem` useable for problems of the form `f(x,p,t,u) ↦ dx/dt`. diff --git a/src/utils/build_basis.jl b/src/utils/build_basis.jl index 688cb57f8..78c99aa24 100644 --- a/src/utils/build_basis.jl +++ b/src/utils/build_basis.jl @@ -114,7 +114,7 @@ function _implicit_build_eqs(basis, eqs, p, prob) end function __construct_basis(X, b, prob, options) - @unpack eval_expresssion, generate_symbolic_parameters, digits, roundingmode = options + @unpack eval_expression, generate_symbolic_parameters, digits, roundingmode = options p = parameters(prob) @@ -162,7 +162,7 @@ function __construct_basis(X, b, prob, options) controls = controls(b), observed = observed(b), implicits = implicits, name = gensym(:Basis), - eval_expression = eval_expresssion) + eval_expression = eval_expression) end function unit_basis(prob::DataDrivenProblem) diff --git a/src/utils/common_options.jl b/src/utils/common_options.jl index 72b0d07da..7de8dfa9b 100644 --- a/src/utils/common_options.jl +++ b/src/utils/common_options.jl @@ -48,7 +48,7 @@ Denoising happens before normalization! """Enables the use of symbolic parameters for the result. If `false`, the numerical value is used.""" generate_symbolic_parameters::Bool = true """Evaluate the expression, see [`Symbolics.build_function`](https://symbolics.juliasymbolics.org/stable/manual/build_function/)""" - eval_expresssion::Bool = false + eval_expression::Bool = false """Additional kwargs""" kwargs::K = (;) end From bd8b06abc9c7e0d303496727e92af5ffcacec1e5 Mon Sep 17 00:00:00 2001 From: Arno Strouwen Date: Sat, 2 Dec 2023 19:15:24 +0100 Subject: [PATCH 2/2] Aqua CI --- Project.toml | 11 ++++++++--- docs/Project.toml | 2 ++ test/qa.jl | 11 +++++++++++ test/runtests.jl | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 test/qa.jl diff --git a/Project.toml b/Project.toml index b9232ad0b..416228092 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54" ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a" -ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" @@ -24,29 +23,35 @@ SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b" Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" [compat] +Aqua = "0.8" CommonSolve = "0.2" DataInterpolations = "4" DiffEqBase = "6" DocStringExtensions = "0.7, 0.8, 0.9" +LinearAlgebra = "1" MLUtils = "0.3, 0.4" ModelingToolkit = "7, 8" Parameters = "0.12" -ProgressMeter = "1.6" +Pkg = "1" QuadGK = "2.4" +Random = "1" RecipesBase = "1" Reexport = "1.0" Setfield = "1" +SafeTestsets = "0.1" Statistics = "1" StatsBase = "0.32.0, 0.33, 0.34" SymbolicUtils = "1" Symbolics = "5" +Test = "1" julia = "1.6" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test", "Random", "SafeTestsets", "Pkg"] +test = ["Aqua", "Test", "Random", "SafeTestsets", "Pkg"] diff --git a/docs/Project.toml b/docs/Project.toml index b7d3387f3..17c32f661 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -12,9 +12,11 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" [compat] DataDrivenDiffEq = "1" Documenter = "1" +LinearAlgebra = "1" Literate = "2.14" ModelingToolkit = "8" OrdinaryDiffEq = "6" Plots = "1" +Random = "1" StableRNGs = "1" StatsBase = "0.33, 0.34" diff --git a/test/qa.jl b/test/qa.jl new file mode 100644 index 000000000..a8a6bfe25 --- /dev/null +++ b/test/qa.jl @@ -0,0 +1,11 @@ +using DataDrivenDiffEq, Aqua +@testset "Aqua" begin + Aqua.find_persistent_tasks_deps(DataDrivenDiffEq) + Aqua.test_ambiguities(DataDrivenDiffEq, recursive = false, broken = true) + Aqua.test_deps_compat(DataDrivenDiffEq) + Aqua.test_piracies(DataDrivenDiffEq, broken = true) + Aqua.test_project_extras(DataDrivenDiffEq) + Aqua.test_stale_deps(DataDrivenDiffEq) + Aqua.test_unbound_args(DataDrivenDiffEq, broken = true) + Aqua.test_undefined_exports(DataDrivenDiffEq, broken = true) +end diff --git a/test/runtests.jl b/test/runtests.jl index 01cfd2804..ca793cbf6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -17,6 +17,7 @@ function activate_subpkg_env(subpkg) end @time begin if GROUP == "All" || GROUP == "Core" || GROUP == "Downstream" + @safetestset "Quality Assurance" begin include("qa.jl") end @safetestset "Basis" begin include("./basis/basis.jl") end @safetestset "Implicit Basis" begin include("./basis/implicit_basis.jl") end @safetestset "Basis generators" begin include("./basis/generators.jl") end