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

Print intervals as 3..4? #319

Closed
dpsanders opened this issue Aug 13, 2019 · 10 comments · Fixed by #567
Closed

Print intervals as 3..4? #319

dpsanders opened this issue Aug 13, 2019 · 10 comments · Fixed by #567

Comments

@dpsanders
Copy link
Member

Maybe it would be less confusing to print out intervals as 3..4 instead of [3, 4]?

@dpsanders
Copy link
Member Author

Or using brackets with 2 vertical bars?

cc @yurivish

@lbenet
Copy link
Member

lbenet commented Aug 13, 2019

Why not having both options, so the user can decide? We already have @format :midpoint...

@Kolaru
Copy link
Collaborator

Kolaru commented Aug 13, 2019

The .. format may be kind of confusing with decimal numbers: -3.21..5.67 (dots everywhere!).

@dpsanders
Copy link
Member Author

Yes I agree that we should have both options available.

I actually find -3.21..5.67 quite readable myself. Or add a space:

julia> -3.21 .. 5.67
[-3.21001, 5.67001]

@lbenet
Copy link
Member

lbenet commented Aug 13, 2019

Yes, add spaces!

@perrutquist
Copy link

The repr function falls back to show, and repr(x) is often Julia code that creates x, so it would seem logical to print out either 3 .. 4 or 3.5 ± 0.5. (Especially since [3, 4] creates a vector.)

I'd personally find it really useful if I could copy-paste from the output and get a new interval with a guarantee to contain the original interval (even if it does not recreate it exactly).

Whether or not to add spaces could be determined by get(io, :compact, true). That's how it's done for complex numbers.

@dpsanders
Copy link
Member Author

Note that you can already have the midpoint-radius version:

julia> @format midpoint
Display parameters:
- format: midpoint
- decorations: false
- significant figures: 6

julia> 3..4
3.5 ± 0.5

@Kolaru
Copy link
Collaborator

Kolaru commented Oct 25, 2022

For the default it is not a clear cut.

However as opposed to what the Julia doc recommends, we don't have a show method (e.g. repr) that can be copy pasted to reconstruct the printed object.

The IEEE standard already may mention something about it.

@dpsanders
Copy link
Member Author

That is implemented in @format full, but agreed that repr should probably return that.

@Kolaru
Copy link
Collaborator

Kolaru commented Jul 24, 2023

Fixed in #555

@Kolaru Kolaru closed this as completed Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants