Skip to content

Commit

Permalink
Fix deprecation warning when sorting data frame with no columns (#3190)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkamins authored Oct 4, 2022
1 parent 94ac6cc commit 7216ade
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/abstractdataframe/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ function ordering(df::AbstractDataFrame, cols::AbstractVector, lt::Function,
by::Function, rev::Bool, order::Ordering)

if length(cols) == 0
Base.depwarn("When empty column selector is passed ordering is done on all colums. " *
"This behavior is deprecated and will change in the future.", :ordering)
if ncol(df) > 0
Base.depwarn("When empty column selector is passed ordering is done on all colums. " *
"This behavior is deprecated and will change in the future.", :ordering)
end
return ordering(df, lt, by, rev, order)
end

Expand Down
4 changes: 2 additions & 2 deletions src/other/metadata.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Metadata API from DataAPI.jl

# private type that is passed as a default value in metadata and colmetadata
# do detect the fact that no default was passed
# private type that is passed as a default value in the metadata and colmetadata
# functions to detect the fact that no default was passed
struct MetadataMissingDefault end

# DataAPI.metadatasupport and DataAPI.colmetadatasupport are not exported
Expand Down
4 changes: 4 additions & 0 deletions test/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ using DataFrames, Random, Test, CategoricalArrays

d = DataFrame(dv1=dv1, dv2=dv2, dv3=dv3, cv1=cv1)

@test sort(DataFrame()) == DataFrame()
@test sort!(DataFrame()) == DataFrame()
@test isempty(sortperm(DataFrame()))
@test issorted(DataFrame())
@test sortperm(d) == sortperm(dv1)
@test sortperm(d[:, [:dv3, :dv1]]) == sortperm(dv3)
@test sort(d, :dv1)[!, :dv3] == sort(d, "dv1")[!, "dv3"] == sortperm(dv1)
Expand Down

2 comments on commit 7216ade

@bkamins
Copy link
Member Author

@bkamins bkamins commented on 7216ade Oct 4, 2022

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/69505

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.4.0 -m "<description of version>" 7216ade100da8b9dff44ad3294ad96810d11d8bc
git push origin v1.4.0

Please sign in to comment.