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

Provide formatter for labeling categories in cut function #202

Merged
merged 10 commits into from
Sep 20, 2019

Conversation

greimel
Copy link
Contributor

@greimel greimel commented Jul 31, 2019

This is something I find useful. One could even add the group index as an additional argument.

Is this something that is worth adding?

e.g.

using Random, CategoricalArrays
data = rand(100)
cut(data, 10, label_formatter = (from,to;extend=true) -> string("P",Int(round(100 * parse(Float64,from),digits=0)),"P",Int(round(100 * parse(Float64,to), digits=0))))
# 100-element CategoricalArray{String,1,UInt32}:
# "P51P57" 
# "P16P26" 
# ...

@nalimilan
Copy link
Member

Thanks, sounds useful. Though I'd just use the labels argument, as we can do something different when it's a function rather than an array of names.

src/extras.jl Outdated Show resolved Hide resolved
@nalimilan
Copy link
Member

Ah, and can you add a test?

@greimel
Copy link
Contributor Author

greimel commented Sep 15, 2019

updated and improved

EDIT: shall I rebase?

Copy link
Member

@nalimilan nalimilan left a comment

Choose a reason for hiding this comment

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

A few more comments.

src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
test/15_extras.jl Outdated Show resolved Hide resolved
Co-Authored-By: Milan Bouchet-Valat <nalimilan@club.fr>
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated

# Examples
```jldoctest
julia> using CategoricalArrays
Copy link
Member

Choose a reason for hiding this comment

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

Is this actually needed? There's probably a way to avoid it as it takes a lot of space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you please clarify what you mean by "this"

Copy link
Member

Choose a reason for hiding this comment

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

I mean this using line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks - I dropped it. Let's see what CI says

src/extras.jl Outdated Show resolved Hide resolved
test/15_extras.jl Outdated Show resolved Hide resolved
test/15_extras.jl Outdated Show resolved Hide resolved
Co-Authored-By: Milan Bouchet-Valat <nalimilan@club.fr>
test/15_extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated Show resolved Hide resolved
src/extras.jl Outdated

# Examples
```jldoctest
julia> using CategoricalArrays
Copy link
Member

Choose a reason for hiding this comment

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

I mean this using line.

src/extras.jl Outdated Show resolved Hide resolved
Co-Authored-By: Milan Bouchet-Valat <nalimilan@club.fr>
@nalimilan nalimilan merged commit 0ede6dc into JuliaData:master Sep 20, 2019
@nalimilan
Copy link
Member

Thanks!

@greimel greimel deleted the cut-format-labels branch September 20, 2019 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants