Skip to content

Commit 7a024c8

Browse files
author
Pietro Vertechi
committed
test adapt
1 parent 78275ce commit 7a024c8

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ Tables = "0.2"
1414
julia = "1"
1515

1616
[extras]
17+
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
1718
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
1819
PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
1920
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2021
WeakRefStrings = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
2122

2223
[targets]
23-
test = ["Test", "OffsetArrays", "PooledArrays", "WeakRefStrings"]
24+
test = ["Test", "GPUArrays", "OffsetArrays", "PooledArrays", "WeakRefStrings"]

src/compatibility.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GPU storage
22
import Adapt
3-
Adapt.adapt_storage(to, s::StructArray) = replace_storage(x->Adapt.adapt(to, x), s)
3+
Adapt.adapt_structure(to, s::StructArray) = replace_storage(x->Adapt.adapt(to, x), s)
44

55
# Table interface
66
import Tables

test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ using StructArrays: staticschema, iscompatible, _promote_typejoin, append!!
33
using OffsetArrays: OffsetArray
44
import Tables, PooledArrays, WeakRefStrings
55
using DataAPI: refarray, refvalue
6+
using Adapt: adapt
7+
import GPUArrays
68
using Test
79

810
@testset "index" begin
@@ -693,3 +695,13 @@ end
693695
@test vcat(dest, StructVector(makeitr())) == append!!(copy(dest), makeitr())
694696
end
695697
end
698+
699+
@testset "adapt" begin
700+
s = StructArray(a = 1:10, b = StructArray(c = 1:10, d = 1:10))
701+
t = adapt(Array, s)
702+
@test propertynames(t) == (:a, :b)
703+
@test s == t
704+
@test t.a isa Array
705+
@test t.b.c isa Array
706+
@test t.b.d isa Array
707+
end

0 commit comments

Comments
 (0)