Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting docstrings and typos #58

Merged
merged 2 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
style = "sciml"
format_markdown = true
format_markdown = true
format_docstrings = true
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
13 changes: 13 additions & 0 deletions .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[default.extend-words]
41 changes: 21 additions & 20 deletions src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions src/mode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
42 changes: 21 additions & 21 deletions src/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
4 changes: 2 additions & 2 deletions test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading