Skip to content

Commit 730592e

Browse files
Merge pull request #76 from mkg33/master
Documentation changes
2 parents 858fcef + 6563ebf commit 730592e

File tree

5 files changed

+87
-89
lines changed

5 files changed

+87
-89
lines changed

README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
Julia has only recently reached v1.0 and the AbstractArray interface is still
77
quite new. The purpose of this library is to solidify extensions to the current
8-
AbstractArray interface which are put to use in package ecosystems like
8+
AbstractArray interface, which are put to use in package ecosystems like
99
DifferentialEquations.jl. Since these libraries are live, this package will
10-
serve as a staging ground for ideas before they merged into Base Julia. For this
11-
reason, no functionality is exported so that way if such functions are added
12-
and exported in a future Base Julia there will be no issues with the upgrade.
10+
serve as a staging ground for ideas before they are merged into Base Julia. For this
11+
reason, no functionality is exported so that if such functions are added
12+
and exported in a future Base Julia, there will be no issues with the upgrade.
1313

1414
## parent_type(x)
1515

@@ -23,14 +23,14 @@ such as `pop!` and `popfirst!` are available for collections of type `T`.
2323
## indices(x[, d])
2424

2525
Given an array `x`, this returns the indices along dimension `d`. If `x` is a tuple
26-
of arrays then the indices corresponding to dimension `d` of all arrays in `x` are
27-
returned. If any indices are not equal along dimension `d` an error is thrown. A
26+
of arrays, then the indices corresponding to dimension `d` of all arrays in `x` are
27+
returned. If any indices are not equal along dimension `d`, an error is thrown. A
2828
tuple may be used to specify a different dimension for each array. If `d` is not
29-
specified then indices for visiting each index of `x` is returned.
29+
specified, then indices for visiting each index of `x` are returned.
3030

3131
## ismutable(x)
3232

33-
A trait function for whether `x` is a mutable or immutable array. Used for
33+
A trait function for whether `x` is a mutable or an immutable array. Used for
3434
dispatching to in-place and out-of-place versions of functions.
3535

3636
## aos_to_soa(x)
@@ -43,16 +43,16 @@ A trait function for whether a matrix `x` is a sparse structured matrix.
4343

4444
## can_setindex(x)
4545

46-
A trait function for whether an array `x` can use `setindex!`
46+
A trait function for whether an array `x` can use `setindex!`.
4747

4848
## has_sparsestruct(x)
4949

50-
Determine whether `findstructralnz` accepts the parameter `x`
50+
Determine whether `findstructralnz` accepts the parameter `x`.
5151

5252
## findstructralnz(x)
5353

5454
Returns iterators `(I,J)` of the non-zeros in the structure of the matrix `x`.
55-
The same as the to first two elements of `findnz(::SparseMatrixCSC)`
55+
The same as the first two elements of `findnz(::SparseMatrixCSC)`.
5656

5757
## fast_matrix_colors(A)
5858

@@ -61,7 +61,7 @@ A trait function for whether `matrix_colors(A)` is a fast algorithm or a slow
6161

6262
## matrix_colors(A)
6363

64-
Returns an array of for the sparsity colors of a matrix type `A`. Also includes
64+
Returns an array for the sparsity colors of a matrix type `A`. Also includes
6565
an abstract type `ColoringAlgorithm` for `matrix_colors(A,alg::ColoringAlgorithm)`
6666
of non-structured matrices.
6767

@@ -79,16 +79,16 @@ A `setindex!` which is always allowed.
7979

8080
## lu_instance(A)
8181

82-
Return an instance of the LU factorization object with the correct type
82+
Returns an instance of the LU factorization object with the correct type
8383
cheaply.
8484

8585
## issingular(A)
8686

87-
Return an instance of the LU factorization object with the correct type cheaply.
87+
Returns an instance of the LU factorization object with the correct type cheaply.
8888

8989
## safevec(v)
9090

91-
Is a form of `vec` which is safe for all values in vector spaces, i.e. if
91+
Is a form of `vec` which is safe for all values in vector spaces, i.e., if it
9292
is already a vector, like an AbstractVector or Number, it will return said
9393
AbstractVector or Number.
9494

@@ -97,18 +97,18 @@ AbstractVector or Number.
9797
Creates the zero'd matrix version of `u`. Note that this is unique because
9898
`similar(u,length(u),length(u))` returns a mutable type, so is not type-matching,
9999
while `fill(zero(eltype(u)),length(u),length(u))` doesn't match the array type,
100-
i.e. you'll get a CPU array from a GPU array. The generic fallback is
101-
`u .* u' .* false` which works on a surprising number of types, but can be broken
102-
with weird (recursive) broadcast overloads. For higher order tensors, this
103-
returns the matrix linear operator type which acts on the `vec` of the array.
100+
i.e., you'll get a CPU array from a GPU array. The generic fallback is
101+
`u .* u' .* false`, which works on a surprising number of types, but can be broken
102+
with weird (recursive) broadcast overloads. For higher-order tensors, this
103+
returns the matrix linear operator type, which acts on the `vec` of the array.
104104

105105
## restructure(x,y)
106106

107107
Restructures the object `y` into a shape of `x`, keeping its values intact. For
108-
simple objects like an `Array`, this simply amounts to a reshape. However, for
108+
simple objects, like an `Array`, this simply amounts to a reshape. However, for
109109
more complex objects such as an `ArrayPartition`, not all of the structural
110110
information is adequately contained in the type for standard tools to work. In
111-
these cases, `restructure` gives a way to convert for example an `Array` into
111+
these cases, `restructure` gives a way to convert, for example, an `Array` into
112112
a matching `ArrayPartition`.
113113

114114
## known_first(::Type{T})
@@ -136,8 +136,8 @@ Otherwise, return `nothing`.
136136

137137
## device(::Type{T})
138138

139-
Indicates the most efficient way to access elements from the collection in low level code.
140-
For `GPUArrays`, will return `ArrayInterface.GPU()`.
139+
Indicates the most efficient way to access elements from the collection in low-level code.
140+
For `GPUArrays`, returns `ArrayInterface.GPU()`.
141141
For `AbstractArray` supporting a `pointer` method, returns `ArrayInterface.CPUPointer()`.
142142
For other `AbstractArray`s and `Tuple`s, returns `ArrayInterface.CPUIndex()`.
143143
Otherwise, returns `nothing`.
@@ -155,21 +155,21 @@ Returns a tuple of boolean `Val`s indicating whether that axis is contiguous.
155155
## contiguous_batch_size(::Type{T})
156156

157157
Returns the size of contiguous batches if `!isone(stride_rank(T, contiguous_axis(T)))`.
158-
If `isone(stride_rank(T, contiguous_axis(T)))`, then it will return `ContiguousBatch{0}()`.
159-
If `contiguous_axis(T) == -1`, it will return `ContiguousBatch{-1}()`.
160-
If unknown, it will return `nothing`.
158+
If `isone(stride_rank(T, contiguous_axis(T)))`, then returns `ContiguousBatch{0}()`.
159+
If `contiguous_axis(T) == -1`, returns `ContiguousBatch{-1}()`.
160+
If unknown, returns `nothing`.
161161

162162
## stride_rank(::Type{T})
163163

164164
Returns the rank of each stride.
165165

166166
## dense_dims(::Type{T})
167167
Returns a tuple of indicators for whether each axis is dense.
168-
An axis `i` of array `A` is dense if `stride(A, i) * size(A, i) == stride(A, j)` where `j` is the axis (if it exists) such that `stride_rank(A)[i] + 1 == stride_rank(A)[j]`.
168+
An axis `i` of array `A` is dense if `stride(A, i) * size(A, i) == stride(A, j)`, where `j` is the axis (if it exists) such that `stride_rank(A)[i] + 1 == stride_rank(A)[j]`.
169169

170170
## ArrayInterface.size(A)
171171

172-
Returns the size of `A`. If the size of any axes are known at compile time,
172+
Returns the size of `A`. If the sizes of any axes are known at compile time,
173173
these should be returned as `StaticInt`s. For example:
174174
```julia
175175
julia> using StaticArrays, ArrayInterface
@@ -207,7 +207,7 @@ Is the function `f` whitelisted for `LoopVectorization.@avx`?
207207
Creates a static integer with value known at compile time. It is a number,
208208
supporting basic arithmetic. Many operations with two `StaticInt` integers
209209
will produce another `StaticInt` integer. If one of the arguments to a
210-
function call isn't static (e.g., `StaticInt(4) + 3`) then the `StaticInt`
210+
function call isn't static (e.g., `StaticInt(4) + 3`), then the `StaticInt`
211211
number will promote to a dynamic value.
212212

213213
# List of things to add
@@ -242,5 +242,5 @@ development.
242242
`Base.@pure ismutable(array::AbstractArray) = typeof(array).mutable`, but there are a lot of cases
243243
where this tends to not work out in a way one would expect. For example, if you put a normal array
244244
into an immutable struct that adds more information to it, this is considered immutable, even if
245-
all of the `setindex!` methods work (by forwarding to the mutable array). Thus it seems safer to just
245+
all of the `setindex!` methods work (by forwarding to the mutable array). Thus, it seems safer to just
246246
always assume mutability is standard for an array, and allow arrays to opt-out.

src/ArrayInterface.jl

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ end
110110
"""
111111
can_setindex(x::DataType)
112112
113-
Query whether a type can use `setindex!`
113+
Query whether a type can use `setindex!`.
114114
"""
115115
can_setindex(x) = true
116116
can_setindex(x::AbstractArray) = can_setindex(typeof(x))
@@ -119,14 +119,14 @@ can_setindex(::Type{<:AbstractRange}) = false
119119
"""
120120
aos_to_soa(x)
121121
122-
Converts an array of structs formulation to a struct of array
122+
Converts an array of structs formulation to a struct of array.
123123
"""
124124
aos_to_soa(x) = x
125125

126126
"""
127127
fast_scalar_indexing(x)
128128
129-
Query whether an array type has fast scalar indexing
129+
Query whether an array type has fast scalar indexing.
130130
"""
131131
fast_scalar_indexing(x) = true
132132
fast_scalar_indexing(x::AbstractArray) = fast_scalar_indexing(typeof(x))
@@ -136,21 +136,21 @@ fast_scalar_indexing(::Type{<:LinearAlgebra.LQPackedQ}) = false
136136
"""
137137
allowed_getindex(x,i...)
138138
139-
A scalar getindex which is always allowed
139+
A scalar `getindex` which is always allowed.
140140
"""
141141
allowed_getindex(x,i...) = x[i...]
142142

143143
"""
144144
allowed_setindex!(x,v,i...)
145145
146-
A scalar setindex! which is always allowed
146+
A scalar `setindex!` which is always allowed.
147147
"""
148148
allowed_setindex!(x,v,i...) = Base.setindex!(x,v,i...)
149149

150150
"""
151151
isstructured(x::DataType)
152152
153-
Query whether a type is a representation of a structured matrix
153+
Query whether a type is a representation of a structured matrix.
154154
"""
155155
isstructured(x) = false
156156
isstructured(x::AbstractArray) = isstructured(typeof(x))
@@ -166,7 +166,7 @@ isstructured(::Diagonal) = true
166166
"""
167167
has_sparsestruct(x::AbstractArray)
168168
169-
Determine whether `findstructralnz` accepts the parameter `x`
169+
Determine whether `findstructralnz` accepts the parameter `x`.
170170
"""
171171
has_sparsestruct(x) = false
172172
has_sparsestruct(x::AbstractArray) = has_sparsestruct(typeof(x))
@@ -200,7 +200,7 @@ diaganyzero(A) = any(iszero, view(A, diagind(A)))
200200
findstructralnz(x::AbstractArray)
201201
202202
Return: (I,J) #indexable objects
203-
Find sparsity pattern of special matrices, the same as the first two elements of findnz(::SparseMatrixCSC)
203+
Find sparsity pattern of special matrices, the same as the first two elements of findnz(::SparseMatrixCSC).
204204
"""
205205
function findstructralnz(x::Diagonal)
206206
n = Base.size(x,1)
@@ -448,7 +448,7 @@ fast_matrix_colors(A::Type{<:Union{Diagonal,Bidiagonal,Tridiagonal,SymTridiagona
448448
matrix_colors(A::Union{Array,UpperTriangular,LowerTriangular})
449449
450450
The color vector for dense matrix and triangular matrix is simply
451-
`[1,2,3,..., Base.size(A,2)]`
451+
`[1,2,3,..., Base.size(A,2)]`.
452452
"""
453453
function matrix_colors(A::Union{Array,UpperTriangular,LowerTriangular})
454454
eachindex(1:Base.size(A,2)) # Vector Base.size matches number of rows
@@ -473,7 +473,7 @@ end
473473
"""
474474
lu_instance(A) -> lu_factorization_instance
475475
476-
Return an instance of the LU factorization object with the correct type
476+
Returns an instance of the LU factorization object with the correct type
477477
cheaply.
478478
"""
479479
function lu_instance(A::Matrix{T}) where T
@@ -487,21 +487,21 @@ end
487487
"""
488488
lu_instance(a::Number) -> a
489489
490-
Return the number.
490+
Returns the number.
491491
"""
492492
lu_instance(a::Number) = a
493493

494494
"""
495495
lu_instance(a::Any) -> lu(a, check=false)
496496
497-
Return the number.
497+
Returns the number.
498498
"""
499499
lu_instance(a::Any) = lu(a, check=false)
500500

501501
"""
502502
safevec(v)
503503
504-
Is a form of `vec` which is safe for all values in vector spaces, i.e. if
504+
It is a form of `vec` which is safe for all values in vector spaces, i.e., if it
505505
is already a vector, like an AbstractVector or Number, it will return said
506506
AbstractVector or Number.
507507
"""
@@ -513,11 +513,11 @@ safevec(v::AbstractVector) = v
513513
zeromatrix(u::AbstractVector)
514514
515515
Creates the zero'd matrix version of `u`. Note that this is unique because
516-
`similar(u,length(u),length(u))` returns a mutable type, so is not type-matching,
516+
`similar(u,length(u),length(u))` returns a mutable type, so it is not type-matching,
517517
while `fill(zero(eltype(u)),length(u),length(u))` doesn't match the array type,
518-
i.e. you'll get a CPU array from a GPU array. The generic fallback is
519-
`u .* u' .* false` which works on a surprising number of types, but can be broken
520-
with weird (recursive) broadcast overloads. For higher order tensors, this
518+
i.e., you'll get a CPU array from a GPU array. The generic fallback is
519+
`u .* u' .* false`, which works on a surprising number of types, but can be broken
520+
with weird (recursive) broadcast overloads. For higher-order tensors, this
521521
returns the matrix linear operator type which acts on the `vec` of the array.
522522
"""
523523
function zeromatrix(u)
@@ -553,7 +553,7 @@ struct GPU <: AbstractDevice end
553553
"""
554554
device(::Type{T})
555555
556-
Indicates the most efficient way to access elements from the collection in low level code.
556+
Indicates the most efficient way to access elements from the collection in low-level code.
557557
For `GPUArrays`, will return `ArrayInterface.GPU()`.
558558
For `AbstractArray` supporting a `pointer` method, returns `ArrayInterface.CPUPointer()`.
559559
For other `AbstractArray`s and `Tuple`s, returns `ArrayInterface.CPUIndex()`.
@@ -583,9 +583,10 @@ defines_strides(::Type{A}) where {A <: Union{<:Transpose,<:Adjoint,<:SubArray,<:
583583
"""
584584
can_avx(f)
585585
586-
Returns `true` if the function `f` is guaranteed to be compatible with `LoopVectorization.@avx` for supported element and array types.
587-
While a return value of `false` does not indicate the function isn't supported, this allows a library to conservatively apply `@avx`
588-
only when it is known to be safe to do so.
586+
Returns `true` if the function `f` is guaranteed to be compatible with
587+
`LoopVectorization.@avx` for supported element and array types. While a return
588+
value of `false` does not indicate the function isn't supported, this allows a
589+
library to conservatively apply `@avx` only when it is known to be safe to do so.
589590
590591
```julia
591592
function mymap!(f, y, args...)
@@ -602,7 +603,7 @@ can_avx(::Any) = false
602603
"""
603604
insert(collection, index, item)
604605
605-
Return a new instance of `collection` with `item` inserted into at the given `index`.
606+
Returns a new instance of `collection` with `item` inserted into at the given `index`.
606607
"""
607608
Base.@propagate_inbounds function insert(collection, index, item)
608609
@boundscheck checkbounds(collection, index)
@@ -635,7 +636,7 @@ end
635636
"""
636637
deleteat(collection, index)
637638
638-
Return a new instance of `collection` with the item at the given `index` removed.
639+
Returns a new instance of `collection` with the item at the given `index` removed.
639640
"""
640641
@propagate_inbounds function deleteat(collection::AbstractVector, index)
641642
@boundscheck if !checkindex(Bool, eachindex(collection), index)

0 commit comments

Comments
 (0)