diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml index 9c79359..959ad88 100644 --- a/.JuliaFormatter.toml +++ b/.JuliaFormatter.toml @@ -1,2 +1,3 @@ style = "sciml" -format_markdown = true \ No newline at end of file +format_markdown = true +format_docstrings = true \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 700707c..af89ce9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,3 +5,6 @@ updates: directory: "/" # Location of package manifests schedule: interval: "weekly" + ignore: + - dependency-name: "crate-ci/typos" + update-types: ["version-update:semver-patch", "version-update:semver-minor"] \ No newline at end of file diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml new file mode 100644 index 0000000..599253c --- /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 0000000..79b68a4 --- /dev/null +++ b/.typos.toml @@ -0,0 +1 @@ +[default.extend-words] \ No newline at end of file diff --git a/src/dense.jl b/src/dense.jl index 374316b..ed3aea7 100644 --- a/src/dense.jl +++ b/src/dense.jl @@ -11,7 +11,7 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). # Fields -- `ruleconfig::RC`: a [`ChainRulesCore.RuleConfig`](https://juliadiff.org/ChainRulesCore.jl/stable/rule_author/superpowers/ruleconfig.html) object. + - `ruleconfig::RC`: a [`ChainRulesCore.RuleConfig`](https://juliadiff.org/ChainRulesCore.jl/stable/rule_author/superpowers/ruleconfig.html) object. """ Base.@kwdef struct AutoChainRules{RC} <: AbstractADType ruleconfig::RC @@ -38,18 +38,19 @@ mode(::AutoDiffractor) = ForwardOrReverseMode() AutoEnzyme{M} Struct used to select the [Enzyme.jl](https://github.com/EnzymeAD/Enzyme.jl) backend for automatic differentiation. - + Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). - + # Constructors AutoEnzyme(; mode=nothing) # Fields -- `mode::M`: can be either - - an object subtyping `EnzymeCore.Mode` (like `EnzymeCore.Forward` or `EnzymeCore.Reverse`) if a specific mode is required - - `nothing` to choose the best mode automatically + - `mode::M`: can be either + + + an object subtyping `EnzymeCore.Mode` (like `EnzymeCore.Forward` or `EnzymeCore.Reverse`) if a specific mode is required + + `nothing` to choose the best mode automatically """ Base.@kwdef struct AutoEnzyme{M} <: AbstractADType mode::M = nothing @@ -85,9 +86,9 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). # Fields -- `fdtype::T1`: finite difference type -- `fdjtype::T2`: finite difference type for the Jacobian -- `fdhtype::T3`: finite difference type for the Hessian + - `fdtype::T1`: finite difference type + - `fdjtype::T2`: finite difference type for the Jacobian + - `fdhtype::T3`: finite difference type for the Hessian """ Base.@kwdef struct AutoFiniteDiff{T1, T2, T3} <: AbstractADType fdtype::T1 = Val(:forward) @@ -110,7 +111,7 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). # Fields -- `fdm::T`: a [`FiniteDifferenceMethod`](https://juliadiff.org/FiniteDifferences.jl/stable/pages/api/#FiniteDifferences.FiniteDifferenceMethod) + - `fdm::T`: a [`FiniteDifferenceMethod`](https://juliadiff.org/FiniteDifferences.jl/stable/pages/api/#FiniteDifferences.FiniteDifferenceMethod) """ Base.@kwdef struct AutoFiniteDifferences{T} <: AbstractADType fdm::T @@ -131,11 +132,11 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). # Type parameters -- `chunksize`: the preferred [chunk size](https://juliadiff.org/ForwardDiff.jl/stable/user/advanced/#Configuring-Chunk-Size) to evaluate several derivatives at once + - `chunksize`: the preferred [chunk size](https://juliadiff.org/ForwardDiff.jl/stable/user/advanced/#Configuring-Chunk-Size) to evaluate several derivatives at once # Fields -- `tag::T`: a [custom tag](https://juliadiff.org/ForwardDiff.jl/release-0.10/user/advanced.html#Custom-tags-and-tag-checking-1) to handle nested differentiation calls (usually not necessary) + - `tag::T`: a [custom tag](https://juliadiff.org/ForwardDiff.jl/release-0.10/user/advanced.html#Custom-tags-and-tag-checking-1) to handle nested differentiation calls (usually not necessary) """ struct AutoForwardDiff{chunksize, T} <: AbstractADType tag::T @@ -149,22 +150,22 @@ mode(::AutoForwardDiff) = ForwardMode() """ AutoPolyesterForwardDiff{chunksize,T} - + Struct used to select the [PolyesterForwardDiff.jl](https://github.com/JuliaDiff/PolyesterForwardDiff.jl) backend for automatic differentiation. - + Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). - + # Constructors - + AutoPolyesterForwardDiff(; chunksize=nothing, tag=nothing) # Type parameters -- `chunksize`: the preferred [chunk size](https://juliadiff.org/ForwardDiff.jl/stable/user/advanced/#Configuring-Chunk-Size) to evaluate several derivatives at once + - `chunksize`: the preferred [chunk size](https://juliadiff.org/ForwardDiff.jl/stable/user/advanced/#Configuring-Chunk-Size) to evaluate several derivatives at once # Fields -- `tag::T`: a [custom tag](https://juliadiff.org/ForwardDiff.jl/release-0.10/user/advanced.html#Custom-tags-and-tag-checking-1) to handle nested differentiation calls (usually not necessary) + - `tag::T`: a [custom tag](https://juliadiff.org/ForwardDiff.jl/release-0.10/user/advanced.html#Custom-tags-and-tag-checking-1) to handle nested differentiation calls (usually not necessary) """ struct AutoPolyesterForwardDiff{chunksize, T} <: AbstractADType tag::T @@ -189,7 +190,7 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). # Fields -- `compile::Bool`: whether to [compile the tape](https://juliadiff.org/ReverseDiff.jl/api/#ReverseDiff.compile) prior to differentiation + - `compile::Bool`: whether to [compile the tape](https://juliadiff.org/ReverseDiff.jl/api/#ReverseDiff.compile) prior to differentiation """ Base.@kwdef struct AutoReverseDiff <: AbstractADType compile::Bool = false @@ -225,7 +226,7 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). # Fields -- `safe_mode::Bool`: whether to run additional checks to catch errors early. On by default. Turn off to maximise performance if your code runs correctly. + - `safe_mode::Bool`: whether to run additional checks to catch errors early. On by default. Turn off to maximise performance if your code runs correctly. """ Base.@kwdef struct AutoTapir <: AbstractADType safe_mode::Bool = true diff --git a/src/mode.jl b/src/mode.jl index a3dea59..79a8f6a 100644 --- a/src/mode.jl +++ b/src/mode.jl @@ -5,10 +5,10 @@ Abstract supertype for the traits identifying differentiation modes. # Subtypes -- [`ForwardMode`](@ref) -- [`ReverseMode`](@ref) -- [`ForwardOrReverseMode`](@ref) -- [`SymbolicMode`](@ref) + - [`ForwardMode`](@ref) + - [`ReverseMode`](@ref) + - [`ForwardOrReverseMode`](@ref) + - [`SymbolicMode`](@ref) """ abstract type AbstractMode end @@ -41,7 +41,8 @@ struct ReverseMode <: AbstractMode end Trait for AD choices that can work either in [`ForwardMode`](@ref) or [`ReverseMode`](@ref), depending on their configuration. !!! warning - This trait should rarely be used, because more precise dispatches to [`ForwardMode`](@ref) or [`ReverseMode`](@ref) should be defined. + + This trait should rarely be used, because more precise dispatches to [`ForwardMode`](@ref) or [`ReverseMode`](@ref) should be defined. """ struct ForwardOrReverseMode <: AbstractMode end diff --git a/src/sparse.jl b/src/sparse.jl index c561c4b..70bf692 100644 --- a/src/sparse.jl +++ b/src/sparse.jl @@ -7,8 +7,8 @@ Abstract supertype for sparsity pattern detectors. # Required methods -- [`jacobian_sparsity`](@ref) -- [`hessian_sparsity`](@ref) + - [`jacobian_sparsity`](@ref) + - [`hessian_sparsity`](@ref) """ abstract type AbstractSparsityDetector end @@ -34,7 +34,7 @@ Trivial sparsity detector, which always returns a full sparsity pattern (only on # See also -- [`AbstractSparsityDetector`](@ref) + - [`AbstractSparsityDetector`](@ref) """ struct NoSparsityDetector <: AbstractSparsityDetector end @@ -51,18 +51,18 @@ Abstract supertype for Jacobian/Hessian coloring algorithms, defined for example # Required methods -- [`column_coloring`](@ref) -- [`row_coloring`](@ref) -- [`symmetric_coloring`](@ref) + - [`column_coloring`](@ref) + - [`row_coloring`](@ref) + - [`symmetric_coloring`](@ref) # Note The terminology and definitions are taken from the following paper: > "What Color Is Your Jacobian? Graph Coloring for Computing Derivatives" -> +> > Assefaw Hadish Gebremedhin, Fredrik Manne, and Alex Pothen (2005) -> +> > https://epubs.siam.org/doi/10.1137/S0036144504444711 """ abstract type AbstractColoringAlgorithm end @@ -88,12 +88,12 @@ function row_coloring end """ symmetric_coloring(M::AbstractMatrix, ca::ColoringAlgorithm)::AbstractVector{<:Integer} -Use algorithm `ca` to construct a symetrically structurally orthogonal partition of the columns (or rows) of the symmetric matrix `M`. +Use algorithm `ca` to construct a symmetrically structurally orthogonal partition of the columns (or rows) of the symmetric matrix `M`. The result is a coloring vector `c` of length `size(M, 1) == size(M, 2)` such that for every non-zero coefficient `M[i, j]`, at least one of the following conditions holds: -- column `j` is the only column of its color `c[j]` with a non-zero coefficient in row `i`; -- column `i` is the only column of its color `c[i]` with a non-zero coefficient in row `j`. + - column `j` is the only column of its color `c[j]` with a non-zero coefficient in row `i`; + - column `i` is the only column of its color `c[i]` with a non-zero coefficient in row `j`. """ function symmetric_coloring end @@ -104,7 +104,7 @@ Trivial coloring algorithm, which always returns a different color for each matr # See also -- [`AbstractColoringAlgorithm`](@ref) + - [`AbstractColoringAlgorithm`](@ref) """ struct NoColoringAlgorithm <: AbstractColoringAlgorithm end @@ -121,9 +121,9 @@ Wraps an ADTypes.jl object to deal with sparse Jacobians and Hessians. # Fields -- `dense_ad::D`: the underlying AD package, subtyping [`AbstractADType`](@ref) -- `sparsity_detector::S`: the sparsity pattern detector, subtyping [`AbstractSparsityDetector`](@ref) -- `coloring_algorithm::C`: the coloring algorithm, subtyping [`AbstractColoringAlgorithm`](@ref) + - `dense_ad::D`: the underlying AD package, subtyping [`AbstractADType`](@ref) + - `sparsity_detector::S`: the sparsity pattern detector, subtyping [`AbstractSparsityDetector`](@ref) + - `coloring_algorithm::C`: the coloring algorithm, subtyping [`AbstractColoringAlgorithm`](@ref) # Constructors @@ -158,10 +158,10 @@ end dense_ad(ad::AutoSparse)::AbstractADType Return the underlying AD package for a sparse AD choice. - + # See also -- [`AutoSparse`](@ref) + - [`AutoSparse`](@ref) """ dense_ad(ad::AutoSparse) = ad.dense_ad @@ -174,8 +174,8 @@ Return the sparsity pattern detector for a sparse AD choice. # See also -- [`AutoSparse`](@ref) -- [`AbstractSparsityDetector`](@ref) + - [`AutoSparse`](@ref) + - [`AbstractSparsityDetector`](@ref) """ sparsity_detector(ad::AutoSparse) = ad.sparsity_detector @@ -186,7 +186,7 @@ Return the coloring algorithm for a sparse AD choice. # See also -- [`AutoSparse`](@ref) -- [`AbstractColoringAlgorithm`](@ref) + - [`AutoSparse`](@ref) + - [`AbstractColoringAlgorithm`](@ref) """ coloring_algorithm(ad::AutoSparse) = ad.coloring_algorithm diff --git a/test/dense.jl b/test/dense.jl index 7753779..abe3f9b 100644 --- a/test/dense.jl +++ b/test/dense.jl @@ -139,8 +139,8 @@ end @test ad isa AutoTapir @test mode(ad) isa ReverseMode @test ad.safe_mode - - ad = AutoTapir(; safe_mode=false) + + ad = AutoTapir(; safe_mode = false) @test !ad.safe_mode end