Skip to content

Commit

Permalink
make sure to use SciML Style
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Jun 23, 2022
1 parent dc9ed4e commit 5a3ff57
Show file tree
Hide file tree
Showing 13 changed files with 926 additions and 859 deletions.
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
@@ -0,0 +1 @@
style = "sciml"
42 changes: 42 additions & 0 deletions .github/workflows/FormatCheck.yml
@@ -0,0 +1,42 @@
name: format-check

on:
push:
branches:
- 'master'
- 'release-'
tags: '*'
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v1
- name: Install JuliaFormatter and format
# This will use the latest version by default but you can set the version like so:
#
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Format check
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'
24 changes: 10 additions & 14 deletions docs/make.jl
Expand Up @@ -2,18 +2,14 @@ using Documenter, Integrals

include("pages.jl")

makedocs(
sitename="Integrals.jl",
authors="Chris Rackauckas",
modules=[Integrals,Integrals.SciMLBase],
clean=true,doctest=false,
format = Documenter.HTML(analytics = "UA-90474609-3",
assets = ["assets/favicon.ico"],
canonical="https://integrals.sciml.ai/stable/"),
pages=pages
)
makedocs(sitename = "Integrals.jl",
authors = "Chris Rackauckas",
modules = [Integrals, Integrals.SciMLBase],
clean = true, doctest = false,
format = Documenter.HTML(analytics = "UA-90474609-3",
assets = ["assets/favicon.ico"],
canonical = "https://integrals.sciml.ai/stable/"),
pages = pages)

deploydocs(
repo = "github.com/SciML/Integrals.jl.git";
push_preview = true
)
deploydocs(repo = "github.com/SciML/Integrals.jl.git";
push_preview = true)
20 changes: 7 additions & 13 deletions docs/pages.jl
@@ -1,15 +1,9 @@
pages = [
"Home" => "index.md",
"Tutorials" => Any[
"tutorials/numerical_integrals.md",
"tutorials/differentiating_integrals.md"
],
"Basics" => Any[
"basics/IntegralProblem.md",
"basics/solve.md",
"basics/FAQ.md"
],
"Solvers" => Any[
"solvers/IntegralSolvers.md"
]
]
"Tutorials" => Any["tutorials/numerical_integrals.md",
"tutorials/differentiating_integrals.md"],
"Basics" => Any["basics/IntegralProblem.md",
"basics/solve.md",
"basics/FAQ.md"],
"Solvers" => Any["solvers/IntegralSolvers.md"],
]
54 changes: 30 additions & 24 deletions lib/IntegralsCuba/src/IntegralsCuba.jl
Expand Up @@ -9,11 +9,12 @@ struct CubaSUAVE <: AbstractCubaAlgorithm end
struct CubaDivonne <: AbstractCubaAlgorithm end
struct CubaCuhre <: AbstractCubaAlgorithm end

function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgorithm, sensealg,
lb, ub, p, args...;
reltol=1e-8, abstol=1e-8,
maxiters=alg isa CubaSUAVE ? 1000000 : typemax(Int),
kwargs...)
function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgorithm,
sensealg,
lb, ub, p, args...;
reltol = 1e-8, abstol = 1e-8,
maxiters = alg isa CubaSUAVE ? 1000000 : typemax(Int),
kwargs...)
prob = transformation_if_inf(prob) #intercept for infinite transformation
p = p
if lb isa Number && prob.batch == 0
Expand All @@ -36,7 +37,8 @@ function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgori
end
else
f = function (x, dx)
dx .= prob.f(scale_x!(_x, ub, lb, x), p) .* prod((y) -> y[1] - y[2], zip(ub, lb))
dx .= prob.f(scale_x!(_x, ub, lb, x), p) .*
prod((y) -> y[1] - y[2], zip(ub, lb))
end
end
else
Expand All @@ -50,11 +52,13 @@ function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgori
else
if prob.f([lb ub], p) isa Vector
f = function (x, dx)
dx .= prob.f(scale_x(ub, lb, x), p)' .* prod((y) -> y[1] - y[2], zip(ub, lb))
dx .= prob.f(scale_x(ub, lb, x), p)' .*
prod((y) -> y[1] - y[2], zip(ub, lb))
end
else
f = function (x, dx)
dx .= prob.f(scale_x(ub, lb, x), p) .* prod((y) -> y[1] - y[2], zip(ub, lb))
dx .= prob.f(scale_x(ub, lb, x), p) .*
prod((y) -> y[1] - y[2], zip(ub, lb))
end
end
end
Expand All @@ -67,11 +71,13 @@ function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgori
else
if prob.f([lb ub], p) isa Vector
f = function (x, dx)
dx .= prob.f(scale_x(ub, lb, x), p)' .* prod((y) -> y[1] - y[2], zip(ub, lb))
dx .= prob.f(scale_x(ub, lb, x), p)' .*
prod((y) -> y[1] - y[2], zip(ub, lb))
end
else
f = function (x, dx)
dx .= prob.f(scale_x(ub, lb, x), p) .* prod((y) -> y[1] - y[2], zip(ub, lb))
dx .= prob.f(scale_x(ub, lb, x), p) .*
prod((y) -> y[1] - y[2], zip(ub, lb))
end
end
end
Expand All @@ -83,21 +89,21 @@ function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgori
nvec = prob.batch == 0 ? 1 : prob.batch

if alg isa CubaVegas
out = Cuba.vegas(f, ndim, prob.nout; rtol=reltol,
atol=abstol, nvec=nvec,
maxevals=maxiters, kwargs...)
out = Cuba.vegas(f, ndim, prob.nout; rtol = reltol,
atol = abstol, nvec = nvec,
maxevals = maxiters, kwargs...)
elseif alg isa CubaSUAVE
out = Cuba.suave(f, ndim, prob.nout; rtol=reltol,
atol=abstol, nvec=nvec,
maxevals=maxiters, kwargs...)
out = Cuba.suave(f, ndim, prob.nout; rtol = reltol,
atol = abstol, nvec = nvec,
maxevals = maxiters, kwargs...)
elseif alg isa CubaDivonne
out = Cuba.divonne(f, ndim, prob.nout; rtol=reltol,
atol=abstol, nvec=nvec,
maxevals=maxiters, kwargs...)
out = Cuba.divonne(f, ndim, prob.nout; rtol = reltol,
atol = abstol, nvec = nvec,
maxevals = maxiters, kwargs...)
elseif alg isa CubaCuhre
out = Cuba.cuhre(f, ndim, prob.nout; rtol=reltol,
atol=abstol, nvec=nvec,
maxevals=maxiters, kwargs...)
out = Cuba.cuhre(f, ndim, prob.nout; rtol = reltol,
atol = abstol, nvec = nvec,
maxevals = maxiters, kwargs...)
end

if isinplace(prob) || prob.batch != 0
Expand All @@ -111,9 +117,9 @@ function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgori
end

SciMLBase.build_solution(prob, alg, val, out.error,
chi=out.probability, retcode=:Success)
chi = out.probability, retcode = :Success)
end

export CubaVegas, CubaSUAVE, CubaDivonne, CubaCuhre

end
end
1 change: 1 addition & 0 deletions lib/IntegralsCuba/test/runtests.jl
@@ -0,0 +1 @@

78 changes: 39 additions & 39 deletions lib/IntegralsCubature/src/IntegralsCubature.jl
Expand Up @@ -9,11 +9,11 @@ struct CubatureJLh <: AbstractCubatureJLAlgorithm end
struct CubatureJLp <: AbstractCubatureJLAlgorithm end

function Integrals.__solvebp_call(prob::IntegralProblem,
alg::AbstractCubatureJLAlgorithm,
sensealg, lb, ub, p, args...;
reltol=1e-8, abstol=1e-8,
maxiters=typemax(Int),
kwargs...)
alg::AbstractCubatureJLAlgorithm,
sensealg, lb, ub, p, args...;
reltol = 1e-8, abstol = 1e-8,
maxiters = typemax(Int),
kwargs...)
prob = transformation_if_inf(prob) #intercept for infinite transformation
nout = prob.nout
if nout == 1
Expand All @@ -27,23 +27,23 @@ function Integrals.__solvebp_call(prob::IntegralProblem,
if lb isa Number
if alg isa CubatureJLh
_val, err = Cubature.hquadrature(f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
else
_val, err = Cubature.pquadrature(f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
end
val = prob.f(lb, p) isa Number ? _val : [_val]
else
if alg isa CubatureJLh
_val, err = Cubature.hcubature(f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
else
_val, err = Cubature.pcubature(f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
end

if isinplace(prob) || !isa(prob.f(lb, p), Number)
Expand Down Expand Up @@ -75,22 +75,22 @@ function Integrals.__solvebp_call(prob::IntegralProblem,
if lb isa Number
if alg isa CubatureJLh
_val, err = Cubature.hquadrature_v(f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
else
_val, err = Cubature.pquadrature_v(f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
end
else
if alg isa CubatureJLh
_val, err = Cubature.hcubature_v(f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
else
_val, err = Cubature.pcubature_v(f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
end
end
val = _val isa Number ? [_val] : _val
Expand All @@ -105,22 +105,22 @@ function Integrals.__solvebp_call(prob::IntegralProblem,
if lb isa Number
if alg isa CubatureJLh
val, err = Cubature.hquadrature(nout, f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
else
val, err = Cubature.pquadrature(nout, f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
end
else
if alg isa CubatureJLh
val, err = Cubature.hcubature(nout, f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
else
val, err = Cubature.pcubature(nout, f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
end
end
else
Expand All @@ -137,29 +137,29 @@ function Integrals.__solvebp_call(prob::IntegralProblem,
if lb isa Number
if alg isa CubatureJLh
val, err = Cubature.hquadrature_v(nout, f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
else
val, err = Cubature.pquadrature_v(nout, f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
end
else
if alg isa CubatureJLh
val, err = Cubature.hcubature_v(nout, f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
else
val, err = Cubature.pcubature_v(nout, f, lb, ub;
reltol=reltol, abstol=abstol,
maxevals=maxiters)
reltol = reltol, abstol = abstol,
maxevals = maxiters)
end
end
end
end
SciMLBase.build_solution(prob, alg, val, err, retcode=:Success)
SciMLBase.build_solution(prob, alg, val, err, retcode = :Success)
end

export CubatureJLh, CubatureJLp

end
end
1 change: 1 addition & 0 deletions lib/IntegralsCubature/test/runtests.jl
@@ -0,0 +1 @@

0 comments on commit 5a3ff57

Please sign in to comment.