Skip to content

Commit

Permalink
Support Tables.jl and TypedTables.jl (#29)
Browse files Browse the repository at this point in the history
* start on Tables support

* Make it Tables-friendly

* Require Julia 1.6
  • Loading branch information
cscherrer authored Jun 16, 2022
1 parent ee5fb39 commit c9d9a54
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Sobol = "ed01d8cd-4d21-5b2a-85b4-cc3bdc58bad4"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"

[compat]
ArraysOfArrays = "0.5"
Expand All @@ -23,6 +25,8 @@ NestedTuples = "0.3"
StatsBase = "0.33"
StatsFuns = "1"
StructArrays = "0.5, 0.6"
Tables = "1"
TypedTables = "1"
julia = "1.6"

[extras]
Expand Down
3 changes: 3 additions & 0 deletions src/TupleVectors.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module TupleVectors

import Tables
import TypedTables

include("tuplevector.jl")
include("summarize.jl")
include("chainvec.jl")
Expand Down
12 changes: 12 additions & 0 deletions src/tuplevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,15 @@ end
function Base.resize!(tv::TupleVector, n::Int)
rmap(x -> resize!(x, n), unwrap(tv))
end

TypedTables.columnnames(::TupleVector{NamedTuple{N,T}}) where {N,T} = N

Tables.istable(::Type{<:TupleVector}) = true
Tables.rowaccess(::Type{<:TupleVector}) = true
Tables.columnaccess(::Type{<:TupleVector}) = true

Tables.schema(tv::TupleVector{NamedTuple{N,T}}) where {N,T} = Tables.Schema(N,T)

Tables.columns(tv::TupleVector) = unwrap(tv)

Tables.rows(tv::TupleVector) = tv

2 comments on commit c9d9a54

@cscherrer
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/62469

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" c9d9a548978d3c002addf8c351ea53830e979a24
git push origin v0.2.0

Please sign in to comment.