Skip to content

Commit f3176ee

Browse files
authored
add Primitive and ListOffsetArray adapts (#119)
1 parent 4159261 commit f3176ee

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
99
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
1010

1111
[weakdeps]
12+
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
1213
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
1314

1415
[extensions]
1516
AwkwardPythonCallExt = "PythonCall"
17+
AwkwardAdaptExt = "Adapt"
1618

1719
[compat]
20+
Adapt = "4.3.0"
1821
Conda = "1.10.0"
1922
JSON = "0.21.4"
2023
PythonCall = "0.9"

ext/AwkwardAdaptExt.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module AwkwardAdaptExt
2+
3+
import Adapt
4+
import AwkwardArray as ak
5+
6+
function Adapt.adapt_structure(to, x::ak.PrimitiveArray{I, T, B}) where {I, T, B}
7+
ak.PrimitiveArray(Adapt.adapt(to, x.data); x.parameters, behavior = B)
8+
end
9+
10+
function Adapt.adapt_structure(to, x::ak.ListOffsetArray{I, T, B}) where {I, T, B}
11+
new_offsets = Adapt.adapt(to, x.offsets)
12+
new_content = Adapt.adapt(to, x.content)
13+
ak.ListOffsetArray(new_offsets, new_content; x.parameters, behavior = B)
14+
end
15+
16+
end

0 commit comments

Comments
 (0)