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 empty unstack on empty data frame #2842

Merged
merged 4 commits into from
Aug 24, 2021
Merged

Fix empty unstack on empty data frame #2842

merged 4 commits into from
Aug 24, 2021

Conversation

bkamins
Copy link
Member

@bkamins bkamins commented Aug 23, 2021

Fixes #2841

@bkamins bkamins added the bug label Aug 23, 2021
@bkamins bkamins added this to the patch milestone Aug 23, 2021
@bkamins bkamins requested a review from nalimilan August 23, 2021 04:53
@bkamins
Copy link
Member Author

bkamins commented Aug 23, 2021

@nalimilan - here only coverage fails (and it is false positive)

dfu = unstack(df, :b, :c)
@test isempty(dfu)
@test names(dfu) == ["a"]
@test dfu.a isa Vector{Any}
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason to check this type?

Copy link
Member Author

Choose a reason for hiding this comment

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

For current and future safety I guess. I was surprised that:

julia> Symbol.(Any[])
Any[]

because I knew that:

julia> map(Symbol, Any[])
Symbol[]

so I thought it does not hurt to be extra careful with empty collections and add a test.

Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
@bkamins bkamins merged commit b85e26c into main Aug 24, 2021
@bkamins bkamins deleted the bkamins-patch-1 branch August 24, 2021 15:58
@bkamins
Copy link
Member Author

bkamins commented Aug 24, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error for unstacking an empty dataframe
2 participants