Skip to content

Commit eca846a

Browse files
authored
Accept Int32 offsets for VectorOfArrays (#18)
1 parent 9e6a9d2 commit eca846a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/vector_of_arrays.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ VectorOfArrays{T,N}(A::AbstractVector{<:AbstractArray})
2626
2727
VectorOfArrays(
2828
data::AbstractVector,
29-
elem_ptr::AbstractVector{Int},
29+
elem_ptr::AbstractVector{<:Integer},
3030
kernel_size::AbstractVector{<:Dims}
3131
checks::Function = ArraysOfArrays.full_consistency_checks
3232
)
@@ -44,7 +44,7 @@ and `ArraysOfArrays.no_consistency_checks`.
4444
struct VectorOfArrays{
4545
T, N, M,
4646
VT<:AbstractVector{T},
47-
VI<:AbstractVector{Int},
47+
VI<:AbstractVector{<:Integer},
4848
VD<:AbstractVector{Dims{M}}
4949
} <: AbstractVector{Array{T,N}}
5050
data::VT
@@ -73,7 +73,7 @@ struct VectorOfArrays{
7373
) where {
7474
T, M,
7575
VT<:AbstractVector{T},
76-
VI<:AbstractVector{Int},
76+
VI<:AbstractVector{<:Integer},
7777
VD<:AbstractVector{Dims{M}}
7878
}
7979
N = length((ntuple(_ -> 0, Val{M}())..., 0))
@@ -429,7 +429,7 @@ VectorOfVectors(A::AbstractVector{<:AbstractVector})
429429
VectorOfVectors{T}(A::AbstractVector{<:AbstractVector}) where {T}
430430
431431
VectorOfVectors(
432-
data::AbstractVector, elem_ptr::AbstractVector{Int},
432+
data::AbstractVector, elem_ptr::AbstractVector{<:Integer},
433433
checks::Function = full_consistency_checks
434434
)
435435
@@ -439,7 +439,7 @@ See also [VectorOfArrays](@ref).
439439
const VectorOfVectors{
440440
T,
441441
VT<:AbstractVector{T},
442-
VI<:AbstractVector{Int},
442+
VI<:AbstractVector{<:Integer},
443443
VD<:AbstractVector{Dims{0}}
444444
} = VectorOfArrays{T,1,0,VT,VI,VD}
445445

@@ -452,9 +452,9 @@ VectorOfVectors(A::AbstractVector{<:AbstractVector}) = VectorOfArrays(A)
452452

453453
VectorOfVectors(
454454
data::AbstractVector,
455-
elem_ptr::AbstractVector{Int},
455+
elem_ptr::AbstractVector{I},
456456
checks::Function = full_consistency_checks
457-
) = VectorOfArrays(
457+
) where I <: Integer= VectorOfArrays(
458458
data,
459459
elem_ptr,
460460
similar(elem_ptr, Dims{0}, size(elem_ptr, 1) - 1),

test/vector_of_arrays.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,14 @@ using ArraysOfArrays: full_consistency_checks, append_elemptr!, element_ptr
301301
A = [1, 1, 2, 3, 3, 2, 2, 2]
302302
A_grouped_ref = [[1, 1], [2], [3, 3], [2, 2, 2]]
303303
elem_ptr = consgrouped_ptrs(A)
304+
elem_ptr32 = Int32.(consgrouped_ptrs(A))
304305
@test first.(@inferred(VectorOfVectors(A, elem_ptr))) == [1, 2, 3, 2]
306+
@test first.(@inferred(VectorOfVectors(A, elem_ptr32))) == [1, 2, 3, 2]
305307

306308
B = [1, 2, 3, 4, 5, 6, 7, 8]
307309
B_grouped_ref = [[1, 2], [3], [4, 5], [6, 7, 8]]
308310
@test @inferred(VectorOfVectors(B, elem_ptr)) == B_grouped_ref
311+
@test @inferred(VectorOfVectors(B, elem_ptr32)) == B_grouped_ref
309312

310313
C = [1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8]
311314
C_grouped_ref = [[1.1, 2.2], [3.3], [4.4, 5.5], [6.6, 7.7, 8.8]]

0 commit comments

Comments
 (0)