Skip to content

Commit aac8671

Browse files
committed
fix schemaless tables, allow matrices
1 parent 0554e4b commit aac8671

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/TableView.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ struct IteratorAndFirst{F, T}
2828
first = iterate(x)
2929
return new{typeof(first), typeof(x)}(first, x, len)
3030
end
31+
function IteratorAndFirst(first, x)
32+
len = Base.haslength(x) ? length(x) + 1 : 1
33+
return new{typeof(first), typeof(x)}(first, x, len)
34+
end
3135
end
3236
Base.IteratorSize(::Type{IteratorAndFirst{F, T}}) where {F, T} = Base.IteratorSize(T)
3337
Base.length(x::IteratorAndFirst) = x.len
@@ -39,6 +43,8 @@ function Base.iterate(x::IteratorAndFirst, st)
3943
return iterate(x.source, st)
4044
end
4145

46+
showtable(table::AbstractMatrix; kwargs...) = showtable(Tables.table(table); kwargs...)
47+
4248
function showtable(table; dark = false, height = :auto, width = "100%")
4349
rows = Tables.rows(table)
4450
tablelength = Base.IteratorSize(rows) == Base.HasLength() ? length(rows) : nothing

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ end
1919
]
2020
@test showtable(nttable) isa WebIO.Scope
2121
end
22+
@testset "normal array" begin
23+
array = rand(10, 10)
24+
@test showtable(array) isa WebIO.Scope
25+
end

0 commit comments

Comments
 (0)