Skip to content

Commit dd46525

Browse files
authored
Update examples and signatures in docstrings (#506)
* Update examples and signatures in docstrings Indent method signatures for markdown; and change syntax highlighting tag from julia to julia-repl * Ignore docs/build/ from repository tracking
1 parent 14023f6 commit dd46525

2 files changed

Lines changed: 33 additions & 37 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
*.jl.*.cov
33
*.jl.mem
44
deps/deps.jl
5+
docs/build
56
Manifest.toml
67
*~

src/ArrayInterface.jl

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Returns tuple where each field corresponds to the field type of `T` modified by
1919
2020
# Examples
2121
22-
```julia
22+
```julia-repl
2323
julia> ArrayInterface.map_tuple_type(sqrt, Tuple{1,4,16})
2424
(1.0, 2.0, 4.0)
2525
@@ -37,7 +37,7 @@ Flattens any field of `t` that is a tuple. Only direct fields of `t` may be flat
3737
3838
# Examples
3939
40-
```julia
40+
```julia-repl
4141
julia> ArrayInterface.flatten_tuples((1, ()))
4242
(1,)
4343
@@ -138,15 +138,13 @@ See also [`SetIndex!`](@ref)
138138
139139
# Examples
140140
141-
```julia
141+
```julia-repl
142142
julia> ArrayInterface.GetIndex(1:10)(3)
143143
3
144144
145145
julia> ArrayInterface.GetIndex{false}(1:10)(11) # shouldn't be in-bounds
146146
11
147-
148147
```
149-
150148
"""
151149
struct GetIndex{CB, B} <: Function
152150
buffer::B
@@ -175,15 +173,13 @@ See also [`GetIndex`](@ref)
175173
176174
# Examples
177175
178-
```julia
179-
176+
```julia-repl
180177
julia> x = [1, 2, 3, 4];
181178
182179
julia> ArrayInterface.SetIndex!(x)(10, 2);
183180
184181
julia> x[2]
185182
10
186-
187183
```
188184
"""
189185
struct SetIndex!{CB, B} <: Function
@@ -224,7 +220,7 @@ function ismutable end
224220
ismutable(::Type{T}) -> Bool
225221
226222
Query whether instances of type `T` are mutable or not, see
227-
https://github.com/JuliaDiffEq/RecursiveArrayTools.jl/issues/19.
223+
<https://github.com/JuliaDiffEq/RecursiveArrayTools.jl/issues/19>.
228224
"""
229225
ismutable(x) = ismutable(typeof(x))
230226
function ismutable(::Type{T}) where {T <: AbstractArray}
@@ -319,7 +315,7 @@ diaganyzero(A) = any(iszero, view(A, diagind(A)))
319315
findstructralnz(x::AbstractArray)
320316
321317
Return: (I,J) #indexable objects
322-
Find sparsity pattern of special matrices, the same as the first two elements of findnz(::SparseMatrixCSC).
318+
Find sparsity pattern of special matrices, the same as the first two elements of `findnz(::SparseMatrixCSC)`.
323319
"""
324320
function findstructralnz(x::Diagonal)
325321
n = Base.size(x, 1)
@@ -416,7 +412,7 @@ matrix_colors(A::Union{Tridiagonal, SymTridiagonal}) = _cycle(1:3, Base.size(A,
416412
_cycle(repetend, len) = repeat(repetend, div(len, length(repetend)) + 1)[1:len]
417413

418414
"""
419-
bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
415+
bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
420416
421417
Returns an instance of the Bunch-Kaufman factorization object with the correct type
422418
cheaply.
@@ -426,14 +422,14 @@ function bunchkaufman_instance(A::Matrix{T}) where T
426422
end
427423

428424
"""
429-
bunchkaufman_instance(a::Number) -> a
425+
bunchkaufman_instance(a::Number) -> a
430426
431427
Returns the number.
432428
"""
433429
bunchkaufman_instance(a::Number) = a
434430

435431
"""
436-
bunchkaufman_instance(a::Any) -> cholesky(a, check=false)
432+
bunchkaufman_instance(a::Any) -> cholesky(a, check=false)
437433
438434
Returns the number.
439435
"""
@@ -442,7 +438,7 @@ bunchkaufman_instance(a::Any) = bunchkaufman(a, check = false)
442438
const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra.NoPivot()
443439

444440
"""
445-
cholesky_instance(A, pivot = LinearAlgebra.NoPivot()) -> cholesky_factorization_instance
441+
cholesky_instance(A, pivot = LinearAlgebra.NoPivot()) -> cholesky_factorization_instance
446442
447443
Returns an instance of the Cholesky factorization object with the correct type
448444
cheaply.
@@ -452,22 +448,22 @@ function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {
452448
end
453449

454450
"""
455-
cholesky_instance(a::Number, pivot = LinearAlgebra.NoPivot()) -> a
451+
cholesky_instance(a::Number, pivot = LinearAlgebra.NoPivot()) -> a
456452
457453
Returns the number.
458454
"""
459455
cholesky_instance(a::Number, pivot = DEFAULT_CHOLESKY_PIVOT) = a
460456

461457
"""
462-
cholesky_instance(a::Any, pivot = LinearAlgebra.NoPivot()) -> cholesky(a, check=false)
458+
cholesky_instance(a::Any, pivot = LinearAlgebra.NoPivot()) -> cholesky(a, check=false)
463459
464460
Slow fallback which gets the instance via factorization. Should get
465461
specialized for new matrix types.
466462
"""
467463
cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot, check = false)
468464

469465
"""
470-
ldlt_instance(A) -> ldlt_factorization_instance
466+
ldlt_instance(A) -> ldlt_factorization_instance
471467
472468
Returns an instance of the LDLT factorization object with the correct type
473469
cheaply.
@@ -481,22 +477,22 @@ function ldlt_instance(A::SymTridiagonal{T,V}) where {T,V}
481477
end
482478

483479
"""
484-
ldlt_instance(a::Number) -> a
480+
ldlt_instance(a::Number) -> a
485481
486482
Returns the number.
487483
"""
488484
ldlt_instance(a::Number) = a
489485

490486
"""
491-
ldlt_instance(a::Any) -> ldlt(a, check=false)
487+
ldlt_instance(a::Any) -> ldlt(a, check=false)
492488
493489
Slow fallback which gets the instance via factorization. Should get
494490
specialized for new matrix types.
495491
"""
496492
ldlt_instance(a::Any) = ldlt(a)
497493

498494
"""
499-
lu_instance(A) -> lu_factorization_instance
495+
lu_instance(A) -> lu_factorization_instance
500496
501497
Returns an instance of the LU factorization object with the correct type
502498
cheaply.
@@ -532,22 +528,22 @@ function lu_instance(A::Union{Tridiagonal{T},Diagonal{T},SymTridiagonal{T}}) whe
532528
end
533529

534530
"""
535-
lu_instance(a::Number) -> a
531+
lu_instance(a::Number) -> a
536532
537533
Returns the number.
538534
"""
539535
lu_instance(a::Number) = a
540536

541537
"""
542-
lu_instance(a::Any) -> lu(a, check=false)
538+
lu_instance(a::Any) -> lu(a, check = false)
543539
544540
Slow fallback which gets the instance via factorization. Should get
545541
specialized for new matrix types.
546542
"""
547543
lu_instance(a::Any) = lu(a, check = false)
548544

549545
"""
550-
qr_instance(A, pivot = NoPivot()) -> qr_factorization_instance
546+
qr_instance(A, pivot = NoPivot()) -> qr_factorization_instance
551547
552548
Returns an instance of the QR factorization object with the correct type
553549
cheaply.
@@ -565,7 +561,7 @@ function qr_instance(A::Matrix{BigFloat},pivot = DEFAULT_CHOLESKY_PIVOT)
565561
end
566562

567563
"""
568-
qr_instance(a::Number) -> a
564+
qr_instance(a::Number) -> a
569565
570566
Returns the number.
571567
"""
@@ -580,7 +576,7 @@ specialized for new matrix types.
580576
qr_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = qr(a)# check = false)
581577

582578
"""
583-
svd_instance(A) -> qr_factorization_instance
579+
svd_instance(A) -> qr_factorization_instance
584580
585581
Returns an instance of the SVD factorization object with the correct type
586582
cheaply.
@@ -590,7 +586,7 @@ function svd_instance(A::Matrix{T}) where {T}
590586
end
591587

592588
"""
593-
svd_instance(a::Number) -> a
589+
svd_instance(a::Number) -> a
594590
595591
Returns the number.
596592
"""
@@ -747,14 +743,14 @@ fast_scalar_indexing(::Type{<:LinearAlgebra.AbstractQ}) = false
747743
fast_scalar_indexing(::Type{<:LinearAlgebra.LQPackedQ}) = false
748744

749745
"""
750-
allowed_getindex(x,i...)
746+
allowed_getindex(x, i...)
751747
752748
A scalar `getindex` which is always allowed.
753749
"""
754750
allowed_getindex(x, i...) = x[i...]
755751

756752
"""
757-
allowed_setindex!(x,v,i...)
753+
allowed_setindex!(x, v, i...)
758754
759755
A scalar `setindex!` which is always allowed.
760756
"""
@@ -828,7 +824,7 @@ See also [`ndims_shape`](@ref)
828824
829825
# Examples
830826
831-
```julia
827+
```julia-repl
832828
julia> ArrayInterface.ndims_index(Int)
833829
1
834830
@@ -859,13 +855,13 @@ See also [`ndims_index`](@ref)
859855
860856
# Examples
861857
862-
```julia
858+
```julia-repl
863859
julia> ArrayInterface.ndims_shape([CartesianIndex(1, 1), CartesianIndex(1, 2)])
864860
1
865861
866862
julia> ndims(CartesianIndices((2,2))[[CartesianIndex(1, 1), CartesianIndex(1, 2)]])
867863
1
868-
864+
```
869865
"""
870866
ndims_shape(T::DataType) = ndims_index(T)
871867
ndims_shape(::Type{Colon}) = 1
@@ -876,7 +872,6 @@ ndims_shape(@nospecialize T::Type{<:AbstractArray}) = ndims(T)
876872
ndims_shape(x) = ndims_shape(typeof(x))
877873

878874

879-
880875
"""
881876
instances_do_not_alias(::Type{T}) -> Bool
882877
@@ -920,7 +915,7 @@ end
920915
"""
921916
defines_strides(::Type{T}) -> Bool
922917
923-
Is strides(::T) defined? It is assumed that types returning `true` also return a valid
918+
Is `strides(::T)` defined? It is assumed that types returning `true` also return a valid
924919
pointer on `pointer(::T)`.
925920
"""
926921
defines_strides(x) = defines_strides(typeof(x))
@@ -965,7 +960,7 @@ interface.
965960
966961
# Examples
967962
968-
```julia
963+
```julia-repl
969964
julia> ArrayInterface.ensures_all_unique(BitSet())
970965
true
971966
@@ -994,7 +989,7 @@ Returns `true` if all instances of `T` are sorted.
994989
995990
# Examples
996991
997-
```julia
992+
```julia-repl
998993
julia> ArrayInterface.ensures_sorted(BitSet())
999994
true
1000995
@@ -1019,8 +1014,8 @@ Note: This checks if a compatible `convert` methood exists between `T` and `args
10191014
10201015
# Examples:
10211016
1022-
```julia
1023-
julia> ca = ComponentVector((x = rand(3), y = rand(4),))
1017+
```julia-repl
1018+
julia> ca = ComponentVector((x = rand(3), y = rand(4)))
10241019
ComponentVector{Float64}(x = [0.6549137106381634, 0.37555505280294565, 0.8521039568665254], y = [0.40314196291239024, 0.35484725607638834, 0.6580528978034597, 0.10055508457632167])
10251020
10261021
julia> ArrayInterface.has_trivial_array_constructor(typeof(ca), ones(6))

0 commit comments

Comments
 (0)