Skip to content

Commit bb15dee

Browse files
committed
add an internal 'istable' method
1 parent 47ea1c1 commit bb15dee

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/data_utils.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ 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+
istable(::Mode, ::Val{:other}) = false
152+
153+
istable(::Mode, ::Val{:table}) = true
154+
142155
# ------------------------------------------------------------------------
143156
# decoder
144157

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)