From 175e431eadaae9e439b5a8e020afce06dc6cf4f4 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 21 Oct 2023 10:38:36 +0200 Subject: [PATCH] fix error (#350) --- src/dicts.jl | 4 ++-- test/runtests.jl | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dicts.jl b/src/dicts.jl index addc2fd..e390d20 100644 --- a/src/dicts.jl +++ b/src/dicts.jl @@ -126,14 +126,14 @@ end function subset(x::DictRowTable, inds; viewhint::Union{Bool,Nothing}=nothing, view::Union{Bool,Nothing}=nothing) if view !== nothing - @warn "`view` keyword argument is deprecated for `Tables.subset`, use `viewhint` instead" + @warn "`view` keyword argument is deprecated for `Tables.subset`, use `viewhint` instead" maxlog=10 viewhint = view end values = viewhint === true ? Base.view(getfield(x, :values), inds) : getfield(x, :values)[inds] if inds isa Integer return DictRow(getfield(x, :names), values) else - values isa AbstractVector || throw(ArgumentError("`Tables.subset`: invalid `inds` argument, expected `RowTable` output, got $(typeof(ret))")) + values isa AbstractVector || throw(ArgumentError("`Tables.subset`: invalid `inds` argument, expected `RowTable` output, got $(typeof(values))")) return DictRowTable(getfield(x, :names), getfield(x, :types), values) end end diff --git a/test/runtests.jl b/test/runtests.jl index 2e2aab8..832dc80 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -153,6 +153,7 @@ end @test Tables.subset(nt, 1:2, viewhint=false) == (a=[1,2], b=[4.0, 5.0], c=["7","8"]) @test Tables.subset(nt, 1:2, viewhint=nothing) == (a=[1,2], b=[4.0, 5.0], c=["7","8"]) @test_throws ArgumentError Tables.subset(nt, [1:2 1:2]) + @test_throws ArgumentError Tables.subset(Tables.dictrowtable(nt), [1:2 1:2]) @test Tables.subset(nt, 1, viewhint=true) == (a=1, b=4.0, c="7") rs = Tables.subset(nt, 1:2, viewhint=true) @@ -1038,4 +1039,4 @@ end @test DataAPI.ncol(Tables.dictrowtable(NamedTuple[])) == 0 @test DataAPI.nrow(Tables.dictrowtable([(a=1, b=2), (a=3, b=4), (a=5, b=6)])) == 3 @test DataAPI.ncol(Tables.dictrowtable([(a=1, b=2), (a=3, b=4), (a=5, b=6)])) == 2 -end \ No newline at end of file +end