Skip to content
Closed
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
12 changes: 8 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[weakdeps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
FixedSizeArrays = "3821ddf9-e5b5-40d5-8e25-6813ab96b5e2"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

Expand All @@ -21,18 +22,20 @@ StructArraysGPUArraysCoreExt = ["GPUArraysCore", "KernelAbstractions"]
StructArraysLinearAlgebraExt = "LinearAlgebra"
StructArraysSparseArraysExt = "SparseArrays"
StructArraysStaticArraysExt = "StaticArrays"
StructArraysFixedSizeArraysExt = "FixedSizeArrays"

[compat]
Adapt = "4"
Aqua = "0.8"
ConstructionBase = "1"
DataAPI = "1"
Documenter = "1"
FixedSizeArrays = "1.2.0"
GPUArraysCore = "0.2"
InfiniteArrays = "0.15"
JLArrays = "0.2"
LinearAlgebra = "1"
KernelAbstractions = "0.9"
LinearAlgebra = "1"
OffsetArrays = "1"
PooledArrays = "1"
SparseArrays = "1"
Expand All @@ -47,11 +50,12 @@ julia = "1.10"
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FixedSizeArrays = "3821ddf9-e5b5-40d5-8e25-6813ab96b5e2"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
InfiniteArrays = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand All @@ -61,4 +65,4 @@ TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
WeakRefStrings = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"

[targets]
test = ["Adapt", "Aqua", "Documenter", "GPUArraysCore", "InfiniteArrays", "JLArrays", "LinearAlgebra", "KernelAbstractions", "OffsetArrays", "PooledArrays", "SparseArrays", "StaticArrays", "Test", "TypedTables", "WeakRefStrings"]
test = ["Adapt", "Aqua", "Documenter", "FixedSizeArrays", "GPUArraysCore", "InfiniteArrays", "JLArrays", "LinearAlgebra", "KernelAbstractions", "OffsetArrays", "PooledArrays", "SparseArrays", "StaticArrays", "Test", "TypedTables", "WeakRefStrings"]
28 changes: 28 additions & 0 deletions ext/StructArraysFixedSizeArraysExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module StructArraysFixedSizeArraysExt

using StructArrays
using FixedSizeArrays: FixedSizeArrayDefault

export fixed_size_array_backed_initializer

fixed_size_array_of(::Type{S}, d::NTuple{N, Any}) where {S, N} = similar(FixedSizeArrayDefault{S, N}, d)

const fixed_size_array_backed_initializer = StructArrays.StructArrayInitializer(StructArrays.alwaysfalse, fixed_size_array_of)

# Make `fixed_size_array_backed_initializer` available in `StructArrays` using this hack
# https://github.com/itsdfish/PackageExtensionsExample.jl/blob/41581ab0371cf512ace5dd063f7e7935effbb256/ext/DistributionsExt.jl#L28
function __init__()
Threads.@spawn begin
sleep(0.01)
Core.eval(
StructArrays,
quote
ext = Base.get_extension(StructArrays, :StructArraysFixedSizeArraysExt)
using .ext
VERSION >= v"1.11.0-DEV.469" && eval(Meta.parse("public fixed_size_array_backed_initializer"))
end
)
end
end

end
13 changes: 13 additions & 0 deletions 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 FixedSizeArrays

import Aqua
import KernelAbstractions as KA
Expand Down Expand Up @@ -1605,6 +1606,18 @@ end
end
end

@testset "FixedSizeArray" begin
itr = (ComplexF64(x, x) for x in 1:10)
a = collect_structarray(
itr;
initializer = StructArrays.fixed_size_array_backed_initializer,
)
@test a isa StructArray
@test a.re isa FixedSizeArray
b = collect_structarray(itr)
@test all(a .== b)
end

@testset "project quality" begin
Aqua.test_all(StructArrays)
end
Loading