Skip to content

Commit 78c9b35

Browse files
committed
Import group for methods managing immutables
1 parent 8a95783 commit 78c9b35

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

ArrayInterfaceCore/src/ArrayInterfaceCore.jl

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -162,30 +162,6 @@ Converts an array of structs formulation to a struct of array.
162162
"""
163163
aos_to_soa(x) = x
164164

165-
"""
166-
fast_scalar_indexing(::Type{T}) -> Bool
167-
168-
Query whether an array type has fast scalar indexing.
169-
"""
170-
fast_scalar_indexing(x) = fast_scalar_indexing(typeof(x))
171-
fast_scalar_indexing(::Type) = true
172-
fast_scalar_indexing(::Type{<:LinearAlgebra.AbstractQ}) = false
173-
fast_scalar_indexing(::Type{<:LinearAlgebra.LQPackedQ}) = false
174-
175-
"""
176-
allowed_getindex(x,i...)
177-
178-
A scalar `getindex` which is always allowed.
179-
"""
180-
allowed_getindex(x, i...) = x[i...]
181-
182-
"""
183-
allowed_setindex!(x,v,i...)
184-
185-
A scalar `setindex!` which is always allowed.
186-
"""
187-
allowed_setindex!(x, v, i...) = Base.setindex!(x, v, i...)
188-
189165
"""
190166
isstructured(::Type{T}) -> Bool
191167

ArrayInterfaceCore/src/indexing.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
11

2+
"""
3+
fast_scalar_indexing(::Type{T}) -> Bool
4+
5+
Query whether an array type has fast scalar indexing.
6+
"""
7+
fast_scalar_indexing(x) = fast_scalar_indexing(typeof(x))
8+
fast_scalar_indexing(::Type) = true
9+
fast_scalar_indexing(::Type{<:LinearAlgebra.AbstractQ}) = false
10+
fast_scalar_indexing(::Type{<:LinearAlgebra.LQPackedQ}) = false
11+
12+
"""
13+
allowed_getindex(x,i...)
14+
15+
A scalar `getindex` which is always allowed.
16+
"""
17+
allowed_getindex(x, i...) = x[i...]
18+
19+
"""
20+
allowed_setindex!(x,v,i...)
21+
22+
A scalar `setindex!` which is always allowed.
23+
"""
24+
allowed_setindex!(x, v, i...) = Base.setindex!(x, v, i...)
25+
26+
227
@inline function _to_cartesian(a, i::CanonicalInt)
328
@inbounds(CartesianIndices(ntuple(dim -> indices(a, dim), Val(ndims(a))))[i])
429
end

src/ArrayInterface.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module ArrayInterface
22

33
using ArrayInterfaceCore
4-
import ArrayInterfaceCore: allowed_getindex, allowed_setindex!, aos_to_soa, buffer, can_change_size, can_setindex,
5-
deleteat, fast_matrix_colors, fast_scalar_indexing, findstructralnz, has_parent,
6-
has_sparsestruct, is_column_major, issingular, is_splat_index, is_lazy_conjugate, insert,
7-
isstructured, matrix_colors, ismutable, restructure, lu_instance, parent_type, safevec,
8-
unsafe_reconstruct, zeromatrix
4+
import ArrayInterfaceCore: allowed_getindex, allowed_setindex!, aos_to_soa, buffer,
5+
has_parent, parent_type, fast_matrix_colors, findstructralnz, has_sparsestruct,
6+
issingular, is_lazy_conjugate, isstructured, matrix_colors, restructure, lu_instance,
7+
safevec, unsafe_reconstruct, zeromatrix
98

109
# ArrayIndex subtypes and methods
1110
import ArrayInterfaceCore: ArrayIndex, MatrixIndex, VectorIndex, BidiagonalIndex, TridiagonalIndex, StrideIndex
@@ -17,14 +16,18 @@ import ArrayInterfaceCore: OptionallyStaticStepRange, OptionallyStaticUnitRange,
1716
# dimension methods
1817
import ArrayInterfaceCore: dimnames, known_dimnames, has_dimnames, from_parent_dims, to_dims, to_parent_dims
1918
# indexing methods
20-
import ArrayInterfaceCore: to_axes, to_axis, to_indices, to_index, getindex, setindex!, ndims_index
19+
import ArrayInterfaceCore: to_axes, to_axis, to_indices, to_index, getindex, setindex!,
20+
ndims_index, is_splat_index, fast_scalar_indexing
2121
# stride layout methods
2222
import ArrayInterfaceCore: strides, stride_rank, contiguous_axis_indicator, contiguous_batch_size,
23-
known_strides, known_offsets,offsets, offset1, known_offset1, contiguous_axis, dense_dims, defines_strides
23+
known_strides, known_offsets,offsets, offset1, known_offset1, contiguous_axis, dense_dims,
24+
defines_strides, is_column_major
2425
# axes types and methods
2526
import ArrayInterfaceCore: axes, axes_types, lazy_axes, LazyAxis
2627
# static sizing
2728
import ArrayInterfaceCore: size, known_size, known_length, static_length
29+
# managing immutables
30+
import ArrayInterfaceCore: ismutable, can_change_size, can_setindex, deleteat, insert
2831

2932
using LinearAlgebra
3033
using Requires

0 commit comments

Comments
 (0)