Skip to content

Commit ec5e745

Browse files
authored
Merge pull request #48 from alan-turing-institute/tl-istable
Add internal `istable` method
2 parents 47ea1c1 + 190003b commit ec5e745

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/data_utils.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,20 @@ schema(::LightInterface, ::Val{:other}, X; kw...) = errlight("schema")
139139

140140
schema(::LightInterface, ::Val{:table}, X; kw...) = errlight("schema")
141141

142+
# ------------------------------------------------------------------------
143+
# istable
144+
145+
"""
146+
istable(X)
147+
148+
Return true if `X` is tabular.
149+
"""
150+
istable(X) = istable(get_interface_mode(), vtrait(X))
151+
152+
istable(::Mode, ::Val{:other}) = false
153+
154+
istable(::Mode, ::Val{:table}) = true
155+
142156
# ------------------------------------------------------------------------
143157
# decoder
144158

test/data_utils.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ end
8080
@test sch.scitypes[2] <: Multiclass
8181
end
8282
# ------------------------------------------------------------------------
83+
@testset "istable" begin
84+
setlight()
85+
X = rand(5)
86+
@test !M.istable(X)
87+
X = randn(5,5)
88+
@test !M.istable(X)
89+
X = DataFrame(A=rand(10))
90+
@test M.istable(X)
91+
end
92+
# ------------------------------------------------------------------------
8393
@testset "decoder-light" begin
8494
setlight()
8595
x = 5

0 commit comments

Comments
 (0)