Skip to content
Open
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
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name = "StructArrays"
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
version = "0.7.2"
version = "0.8.0"

[deps]
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
LightBoundsErrors = "e21c612c-4641-4669-b9c3-3f4360ced9da"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[weakdeps]
Expand All @@ -31,6 +32,7 @@ Documenter = "1"
GPUArraysCore = "0.2"
InfiniteArrays = "0.15"
JLArrays = "0.2"
LightBoundsErrors = "1"
LinearAlgebra = "1"
KernelAbstractions = "0.9"
OffsetArrays = "1"
Expand Down
2 changes: 2 additions & 0 deletions src/StructArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ include("lazy.jl")
include("constructionbase.jl")
include("tables.jl")

using LightBoundsErrors: checkbounds_lightboundserror

# Implement refarray and refvalue to deal with pooled arrays and weakrefstrings effectively
import DataAPI: refarray, refvalue
using DataAPI: defaultarray
Expand Down
4 changes: 4 additions & 0 deletions src/structarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ map(c -> c[I...], Tuple(cols))
"""
@inline @generated get_ith(cols::Tup, I...) = :(Base.Cartesian.@ntuple $(fieldcount(cols)) i -> @inbounds cols[i][I...])

function Base.checkbounds(x::StructArray, I...)
checkbounds_lightboundserror(x, I...)
end

Base.@propagate_inbounds Base.getindex(x::StructArray, I...) = _getindex(x, to_indices(x, I)...)

Base.@propagate_inbounds function _getindex(x::StructArray{T}, I::Vararg{Int}) where {T}
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using LinearAlgebra
using Test
using SparseArrays
using InfiniteArrays
using LightBoundsErrors: LightBoundsError

import Aqua
import KernelAbstractions as KA
Expand Down Expand Up @@ -43,7 +44,7 @@ Base.convert(::Type{Millimeters}, x::Meters) = Millimeters(x.x*1000)
t = StructArray((a = a, b = b))
@test (@inferred t[2,2]) == (a = 4, b = 7)
@test (@inferred t[2,1:2]) == StructArray((a = [3, 4], b = [6, 7]))
@test_throws BoundsError t[3,3]
@test_throws LightBoundsError t[3,3]
@test (@inferred view(t, 2, 1:2)) == StructArray((a = view(a, 2, 1:2), b = view(b, 2, 1:2)))
@test @inferred(parentindices(view(t, 2, 1:2))) == (2, 1:2)
@test_throws ArgumentError parentindices(StructArray((view([1, 2], [1]), view([1, 2], [2]))))
Expand Down
Loading