Skip to content

Commit

Permalink
Merge pull request #361 from SciML/format
Browse files Browse the repository at this point in the history
setup SciML Style
  • Loading branch information
ChrisRackauckas authored Jun 23, 2022
2 parents e4a952f + 1dd55f2 commit f7d2447
Show file tree
Hide file tree
Showing 44 changed files with 2,815 additions and 2,712 deletions.
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style = "sciml"
42 changes: 42 additions & 0 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -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'
17 changes: 6 additions & 11 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ using Documenter, Surrogates

include("pages.jl")

makedocs(
sitename="Surrogates.jl",
format = Documenter.HTML(analytics = "UA-90474609-3",
assets = ["assets/favicon.ico"],
canonical="https://surrogates.sciml.ai/stable/"),
pages = pages
)
makedocs(sitename = "Surrogates.jl",
format = Documenter.HTML(analytics = "UA-90474609-3",
assets = ["assets/favicon.ico"],
canonical = "https://surrogates.sciml.ai/stable/"),
pages = pages)


deploydocs(
repo = "github.com/SciML/Surrogates.jl.git",
)
deploydocs(repo = "github.com/SciML/Surrogates.jl.git")
76 changes: 37 additions & 39 deletions docs/pages.jl
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
pages = [
"index.md"
"Tutorials" => [
"Basics" => "tutorials.md",
"Radials" => "radials.md",
"Kriging" => "kriging.md",
"Gaussian Process" =>"abstractgps.md",
"Lobachevsky" => "lobachevsky.md",
"Linear" => "LinearSurrogate.md",
"InverseDistance" => "InverseDistance.md",
"RandomForest" => "randomforest.md",
"SecondOrderPolynomial" => "secondorderpoly.md",
"NeuralSurrogate" => "neural.md",
"Wendland" => "wendland.md",
"Polynomial Chaos" => "polychaos.md",
"Variable Fidelity" => "variablefidelity.md",
"Gradient Enhanced Kriging" => "gek.md"
]
"User guide" => [
"Samples" => "samples.md",
"Surrogates" => "surrogate.md",
"Optimization" => "optimizations.md"
]
"Benchmarks" => [
"Sphere function" => "sphere_function.md",
"Lp norm" => "lp.md",
"Rosenbrock" => "rosenbrock.md",
"Tensor product" => "tensor_prod.md",
"Cantilever beam" => "cantilever.md",
"Water Flow function" => "water_flow.md",
"Welded beam function" => "welded_beam.md",
"Branin function" => "BraninFunction.md",
"Ackley function" => "ackley.md",
"Gramacy & Lee Function" => "gramacylee.md",
"Salustowicz Benchmark" => "Salustowicz.md",
"Multi objective optimization" => "multi_objective_opt.md"
]
"Contributing" => "contributing.md"
]
pages = ["index.md"
"Tutorials" => [
"Basics" => "tutorials.md",
"Radials" => "radials.md",
"Kriging" => "kriging.md",
"Gaussian Process" => "abstractgps.md",
"Lobachevsky" => "lobachevsky.md",
"Linear" => "LinearSurrogate.md",
"InverseDistance" => "InverseDistance.md",
"RandomForest" => "randomforest.md",
"SecondOrderPolynomial" => "secondorderpoly.md",
"NeuralSurrogate" => "neural.md",
"Wendland" => "wendland.md",
"Polynomial Chaos" => "polychaos.md",
"Variable Fidelity" => "variablefidelity.md",
"Gradient Enhanced Kriging" => "gek.md",
]
"User guide" => [
"Samples" => "samples.md",
"Surrogates" => "surrogate.md",
"Optimization" => "optimizations.md",
]
"Benchmarks" => [
"Sphere function" => "sphere_function.md",
"Lp norm" => "lp.md",
"Rosenbrock" => "rosenbrock.md",
"Tensor product" => "tensor_prod.md",
"Cantilever beam" => "cantilever.md",
"Water Flow function" => "water_flow.md",
"Welded beam function" => "welded_beam.md",
"Branin function" => "BraninFunction.md",
"Ackley function" => "ackley.md",
"Gramacy & Lee Function" => "gramacylee.md",
"Salustowicz Benchmark" => "Salustowicz.md",
"Multi objective optimization" => "multi_objective_opt.md",
]
"Contributing" => "contributing.md"]
10 changes: 5 additions & 5 deletions lib/SurrogatesAbstractGPs/src/SurrogatesAbstractGPs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ using AbstractGPs
mutable struct AbstractGPSurrogate{X, Y, GP, GP_P, S} <: AbstractSurrogate
x::X
y::Y
gp::GP
gp::GP
gp_posterior::GP_P
Σy::S
end
end

# constructor
function AbstractGPSurrogate(x, y; gp = GP(Matern52Kernel()), Σy = 0.1)
AbstractGPSurrogate(x, y, gp, posterior(gp(x, Σy),y), Σy)
end
AbstractGPSurrogate(x, y, gp, posterior(gp(x, Σy), y), Σy)
end

# predictor
function (g::AbstractGPSurrogate)(val)
Expand All @@ -34,7 +34,7 @@ function add_point!(g::AbstractGPSurrogate, new_x, new_y)
x_copy = copy(g.x)
push!(x_copy, new_x)
y_copy = copy(g.y)
push!(y_copy, new_y)
push!(y_copy, new_y)
updated_posterior = posterior(g.gp(x_copy, g.Σy), y_copy)
g.x, g.y, g.gp_posterior = x_copy, y_copy, updated_posterior
nothing
Expand Down
Loading

0 comments on commit f7d2447

Please sign in to comment.