diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml deleted file mode 100644 index 3494a9f..0000000 --- a/.JuliaFormatter.toml +++ /dev/null @@ -1,3 +0,0 @@ -style = "sciml" -format_markdown = true -format_docstrings = true diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml new file mode 100644 index 0000000..6762c6f --- /dev/null +++ b/.github/workflows/FormatCheck.yml @@ -0,0 +1,19 @@ +name: format-check + +on: + push: + branches: + - 'master' + - 'main' + - 'release-' + tags: '*' + pull_request: + +jobs: + runic: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: fredrikekre/runic-action@v1 + with: + version: '1' diff --git a/src/MATLABDiffEq.jl b/src/MATLABDiffEq.jl index 05d29b4..a70a724 100644 --- a/src/MATLABDiffEq.jl +++ b/src/MATLABDiffEq.jl @@ -14,26 +14,30 @@ _is_matlab_compatible_eltype(::Type) = false function _check_matlab_compatible(u0, tspan) T = eltype(u0) if !_is_matlab_compatible_eltype(T) - throw(ArgumentError( - "MATLABDiffEq.jl requires Float64-compatible element types. " * - "Got eltype(u0) = $T. MATLAB does not support arbitrary precision " * - "(BigFloat) or GPU arrays (JLArrays, CuArrays). Please convert your " * - "initial conditions to Float64: u0 = Float64.(u0)" - )) + throw( + ArgumentError( + "MATLABDiffEq.jl requires Float64-compatible element types. " * + "Got eltype(u0) = $T. MATLAB does not support arbitrary precision " * + "(BigFloat) or GPU arrays (JLArrays, CuArrays). Please convert your " * + "initial conditions to Float64: u0 = Float64.(u0)" + ) + ) end tT = eltype(tspan) if !_is_matlab_compatible_eltype(tT) - throw(ArgumentError( - "MATLABDiffEq.jl requires Float64-compatible time span types. " * - "Got eltype(tspan) = $tT. MATLAB does not support arbitrary precision " * - "(BigFloat). Please use Float64 for tspan: tspan = Float64.(tspan)" - )) + throw( + ArgumentError( + "MATLABDiffEq.jl requires Float64-compatible time span types. " * + "Got eltype(tspan) = $tT. MATLAB does not support arbitrary precision " * + "(BigFloat). Please use Float64 for tspan: tspan = Float64.(tspan)" + ) + ) end # Check that the array type itself is a standard Julia array if !(u0 isa Array || u0 isa Number) @warn "MATLABDiffEq.jl works best with standard Julia Arrays. " * - "Got $(typeof(u0)). The array will be converted to a standard Array " * - "before being sent to MATLAB." + "Got $(typeof(u0)). The array will be converted to a standard Array " * + "before being sent to MATLAB." end return nothing end @@ -63,11 +67,11 @@ function DiffEqBase.__solve( ks = []; saveat = eltype(tupType)[], timeseries_errors = true, - reltol = 1e-3, - abstol = 1e-6, + reltol = 1.0e-3, + abstol = 1.0e-6, callback = nothing, kwargs... -) where {uType, tupType, isinplace, AlgType <: MATLABAlgorithm} + ) where {uType, tupType, isinplace, AlgType <: MATLABAlgorithm} # Validate that input types are MATLAB-compatible _check_matlab_compatible(prob.u0, prob.tspan) @@ -144,7 +148,7 @@ function DiffEqBase.__solve( stats = buildDEStats(solstats) - DiffEqBase.build_solution( + return DiffEqBase.build_solution( prob, alg, ts, @@ -170,7 +174,7 @@ function buildDEStats(solverstats::Dict{String, <:Any})::DiffEqBase.Stats destats.nsolve = Int(get(solverstats, "nsolves", 0)) destats.njacs = Int(get(solverstats, "npds", 0)) destats.nw = Int(get(solverstats, "ndecomps", 0)) - destats + return destats end @setup_workload begin diff --git a/test/runtests.jl b/test/runtests.jl index 4fc4d84..51c0a3b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -19,20 +19,22 @@ sol = solve(prob, MATLABDiffEq.ode45()) function lorenz(du, u, p, t) du[1] = 10.0(u[2] - u[1]) du[2] = u[1] * (28.0 - u[3]) - u[2] - du[3] = u[1] * u[2] - (8 / 3) * u[3] + return du[3] = u[1] * u[2] - (8 / 3) * u[3] end u0 = [1.0; 0.0; 0.0] tspan = (0.0, 100.0) prob = ODEProblem(lorenz, u0, tspan) sol = solve(prob, MATLABDiffEq.ode45()) -algs = [MATLABDiffEq.ode23 - MATLABDiffEq.ode45 - MATLABDiffEq.ode113 - MATLABDiffEq.ode23s - MATLABDiffEq.ode23t - MATLABDiffEq.ode23tb - MATLABDiffEq.ode15s] +algs = [ + MATLABDiffEq.ode23 + MATLABDiffEq.ode45 + MATLABDiffEq.ode113 + MATLABDiffEq.ode23s + MATLABDiffEq.ode23t + MATLABDiffEq.ode23tb + MATLABDiffEq.ode15s +] for alg in algs sol = solve(prob, alg())