Skip to content

Commit c9d9a54

Browse files
authored
Support Tables.jl and TypedTables.jl (#29)
* start on Tables support * Make it Tables-friendly * Require Julia 1.6
1 parent ee5fb39 commit c9d9a54

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Sobol = "ed01d8cd-4d21-5b2a-85b4-cc3bdc58bad4"
1313
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1414
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
1515
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
16+
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
17+
TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
1618

1719
[compat]
1820
ArraysOfArrays = "0.5"
@@ -23,6 +25,8 @@ NestedTuples = "0.3"
2325
StatsBase = "0.33"
2426
StatsFuns = "1"
2527
StructArrays = "0.5, 0.6"
28+
Tables = "1"
29+
TypedTables = "1"
2630
julia = "1.6"
2731

2832
[extras]

src/TupleVectors.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module TupleVectors
22

3+
import Tables
4+
import TypedTables
5+
36
include("tuplevector.jl")
47
include("summarize.jl")
58
include("chainvec.jl")

src/tuplevector.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,15 @@ end
157157
function Base.resize!(tv::TupleVector, n::Int)
158158
rmap(x -> resize!(x, n), unwrap(tv))
159159
end
160+
161+
TypedTables.columnnames(::TupleVector{NamedTuple{N,T}}) where {N,T} = N
162+
163+
Tables.istable(::Type{<:TupleVector}) = true
164+
Tables.rowaccess(::Type{<:TupleVector}) = true
165+
Tables.columnaccess(::Type{<:TupleVector}) = true
166+
167+
Tables.schema(tv::TupleVector{NamedTuple{N,T}}) where {N,T} = Tables.Schema(N,T)
168+
169+
Tables.columns(tv::TupleVector) = unwrap(tv)
170+
171+
Tables.rows(tv::TupleVector) = tv

0 commit comments

Comments
 (0)