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

Compact printing in cut #381

Open
bkamins opened this issue Feb 25, 2022 · 1 comment
Open

Compact printing in cut #381

bkamins opened this issue Feb 25, 2022 · 1 comment

Comments

@bkamins
Copy link
Member

bkamins commented Feb 25, 2022

Currently we have:

julia> cut(1:10, 3)
10-element CategoricalArray{String,1,UInt32}:
 "Q1: [1.0, 4.0)"
 "Q1: [1.0, 4.0)"
 "Q1: [1.0, 4.0)"
 "Q2: [4.0, 6.999999999999999)"
 "Q2: [4.0, 6.999999999999999)"
 "Q2: [4.0, 6.999999999999999)"
 "Q3: [6.999999999999999, 10.0]"
 "Q3: [6.999999999999999, 10.0]"
 "Q3: [6.999999999999999, 10.0]"
 "Q3: [6.999999999999999, 10.0]"

which is not nice. It would be better to use compact printing.

Though we should make sure to correctly do this case:

julia> cut(1:10^-12:1+10^-11, 3)
11-element CategoricalArray{String,1,UInt32}:
 "Q1: [1.0, 1.0000000000033333)"
 "Q1: [1.0, 1.0000000000033333)"
 "Q1: [1.0, 1.0000000000033333)"
 "Q1: [1.0, 1.0000000000033333)"
 "Q2: [1.0000000000033333, 1.0000000000066667)"
 "Q2: [1.0000000000033333, 1.0000000000066667)"
 "Q2: [1.0000000000033333, 1.0000000000066667)"
 "Q3: [1.0000000000066667, 1.00000000001]"
 "Q3: [1.0000000000066667, 1.00000000001]"
 "Q3: [1.0000000000066667, 1.00000000001]"
 "Q3: [1.0000000000066667, 1.00000000001]"
@andreasnoack
Copy link
Member

I just hit a similar case hwere the many digits made plotting labels look ugly. What about supporting rounding in the cut(array, ngroups) method instead of just changing the printing? I guess it might be confusing if the string here don't reflect the actual cuts.

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

No branches or pull requests

2 participants