Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix error in error #350

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dicts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@

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

Check warning on line 129 in src/dicts.jl

View check run for this annotation

Codecov / codecov/patch

src/dicts.jl#L129

Added line #L129 was not covered by tests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unrelated change but deprecation-style warnings should generally get a maxlog imo

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
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
end
Loading