Skip to content

Commit

Permalink
format(".") with blue style from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
st-- committed Oct 7, 2021
1 parent 2232432 commit 8b54ef6
Show file tree
Hide file tree
Showing 24 changed files with 567 additions and 483 deletions.
29 changes: 13 additions & 16 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ DocMeta.setdocmeta!(
@scalar_rule(sin(x), cos(x)) # frule and rrule doctest
@scalar_rule(sincos(x), @setup((sinx, cosx) = Ω), cosx, -sinx) # frule doctest
@scalar_rule(hypot(x::Real, y::Real), (x / Ω, y / Ω)) # rrule doctest
end
end,
)

indigo = DocThemeIndigo.install(ChainRulesCore)

makedocs(
modules=[ChainRulesCore],
format=Documenter.HTML(
prettyurls=false,
assets=[indigo],
mathengine=MathJax3(
modules = [ChainRulesCore],
format = Documenter.HTML(
prettyurls = false,
assets = [indigo],
mathengine = MathJax3(
Dict(
:tex => Dict(
"inlineMath" => [["\$","\$"], ["\\(","\\)"]],
"inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
"tags" => "ams",
# TODO: remove when using physics package
"macros" => Dict(
Expand All @@ -42,9 +42,9 @@ makedocs(
),
),
),
sitename="ChainRules",
authors="Jarrett Revels and other contributors",
pages=[
sitename = "ChainRules",
authors = "Jarrett Revels and other contributors",
pages = [
"Introduction" => "index.md",
"FAQ" => "FAQ.md",
"Rule configurations and calling back into AD" => "config.md",
Expand All @@ -63,11 +63,8 @@ makedocs(
],
"API" => "api.md",
],
strict=true,
checkdocs=:exports,
strict = true,
checkdocs = :exports,
)

deploydocs(
repo = "github.com/JuliaDiff/ChainRulesCore.jl.git",
push_preview=true,
)
deploydocs(repo = "github.com/JuliaDiff/ChainRulesCore.jl.git", push_preview = true)
48 changes: 24 additions & 24 deletions docs/src/assets/make_logo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ using Random

const bridge_len = 50

function chain(jiggle=0)
shaky_rotate(θ) = rotate+ jiggle*(rand()-0.5))
function chain(jiggle = 0)
shaky_rotate(θ) = rotate+ jiggle * (rand() - 0.5))

### 1
shaky_rotate(0)
sethue(Luxor.julia_red)
link()
m1 = getmatrix()


### 2
sethue(Luxor.julia_green)
translate(-50, 130);
shaky_rotate/3);
translate(-50, 130)
shaky_rotate / 3)
link()
m2 = getmatrix()

setmatrix(m1)
sethue(Luxor.julia_red)
overlap(-1.3π)
setmatrix(m2)

### 3
shaky_rotate(-π/3);
translate(-120,80);
shaky_rotate(-π / 3)
translate(-120, 80)
sethue(Luxor.julia_purple)
link()

setmatrix(m2)
setcolor(Luxor.julia_green)
overlap(-1.5π)
Expand All @@ -45,24 +45,24 @@ end
function link()
sector(50, 90, π, 0, :fill)
sector(Point(0, bridge_len), 50, 90, 0, -π, :fill)
rect(50,-3,40, bridge_len+6, :fill)
rect(-50-40,-3,40, bridge_len+6, :fill)


rect(50, -3, 40, bridge_len + 6, :fill)
rect(-50 - 40, -3, 40, bridge_len + 6, :fill)

sethue("black")
move(Point(-50, bridge_len))
arc(Point(0,0), 50, π, 0, :stoke)
arc(Point(0, 0), 50, π, 0, :stoke)
arc(Point(0, bridge_len), 50, 0, -π, :stroke)

move(Point(-90, bridge_len))
arc(Point(0,0), 90, π, 0, :stoke)
arc(Point(0, 0), 90, π, 0, :stoke)
arc(Point(0, bridge_len), 90, 0, -π, :stroke)
strokepath()
end

function overlap(ang_end)
sector(Point(0, bridge_len), 50, 90, -0., ang_end, :fill)
sector(Point(0, bridge_len), 50, 90, -0.0, ang_end, :fill)
sethue("black")
arc(Point(0, bridge_len), 50, 0, ang_end, :stoke)
move(Point(90, bridge_len))
Expand All @@ -75,13 +75,13 @@ end

function save_logo(filename)
Random.seed!(16)
Drawing(450,450, filename)
Drawing(450, 450, filename)
origin()
translate(50, -130);
translate(50, -130)
chain(0.5)
finish()
preview()
end

save_logo("logo.svg")
save_logo("logo.png")
save_logo("logo.png")
8 changes: 4 additions & 4 deletions src/accumulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end

add!!(x::AbstractArray, y::Thunk) = add!!(x, unthunk(y))

function add!!(x::AbstractArray{<:Any, N}, y::AbstractArray{<:Any, N}) where N
function add!!(x::AbstractArray{<:Any,N}, y::AbstractArray{<:Any,N}) where {N}
return if is_inplaceable_destination(x)
x .+= y
else
Expand Down Expand Up @@ -75,8 +75,8 @@ end

struct BadInplaceException <: Exception
ithunk::InplaceableThunk
accumuland
returned_value
accumuland::Any
returned_value::Any
end

function Base.showerror(io::IO, err::BadInplaceException)
Expand All @@ -88,7 +88,7 @@ function Base.showerror(io::IO, err::BadInplaceException)
if err.accumuland == err.returned_value
println(
io,
"Which in this case happenned to be equal. But they are not the same object."
"Which in this case happenned to be equal. But they are not the same object.",
)
end
end
4 changes: 2 additions & 2 deletions src/compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ end
if VERSION < v"1.1"
# Note: these are actually *better* than the ones in julia 1.1, 1.2, 1.3,and 1.4
# See: https://github.com/JuliaLang/julia/issues/34292
function fieldtypes(::Type{T}) where T
function fieldtypes(::Type{T}) where {T}
if @generated
ntuple(i -> fieldtype(T, i), fieldcount(T))
else
ntuple(i -> fieldtype(T, i), fieldcount(T))
end
end

function fieldnames(::Type{T}) where T
function fieldnames(::Type{T}) where {T}
if @generated
ntuple(i -> fieldname(T, i), fieldcount(T))
else
Expand Down
1 change: 1 addition & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

8 changes: 5 additions & 3 deletions src/ignore_derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ ignore_derivatives(x) = x
Tells the AD system to ignore the expression. Equivalent to `ignore_derivatives() do (...) end`.
"""
macro ignore_derivatives(ex)
return :(ChainRulesCore.ignore_derivatives() do
$(esc(ex))
end)
return :(
ChainRulesCore.ignore_derivatives() do
$(esc(ex))
end
)
end
Loading

0 comments on commit 8b54ef6

Please sign in to comment.