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

Printing of zero-step StepRangeLen does not preserve types #56822

Open
mcabbott opened this issue Dec 14, 2024 · 0 comments
Open

Printing of zero-step StepRangeLen does not preserve types #56822

mcabbott opened this issue Dec 14, 2024 · 0 comments
Labels
display and printing Aesthetics and correctness of printed representations of objects. ranges Everything AbstractRange

Comments

@mcabbott
Copy link
Contributor

Here show doesn't print something which matches the original:

julia> x = -1 .+ 0 * range(1,100f0,5)
StepRangeLen(-1.0f0, 0.0f0, 5)

julia> y = StepRangeLen(-1.0f0, 0.0f0, 5)  # copying what's printed
StepRangeLen(-1.0f0, 0.0f0, 5)

julia> x === y  # not ideal!
false

julia> x === StepRangeLen{Float32}(-1.0, 0.0, 5)  # this would be better
true

julia> x === range(-1.0f0, -1.0f0, 5)  # also OK?
true

Float64:

x64 = -1 .+ 0 * range(1,100,5)
y64 = y = StepRangeLen(-1.0, 0.0, 5)  # copying what's printed
x64 === y64  # false
x64 === range(-1.0, -1.0, 5)  # true

I'm not certain that printing range cannot go wrong.

Originally marked "ugly temporary printing, to avoid 0:0:0".

@mcabbott mcabbott added display and printing Aesthetics and correctness of printed representations of objects. ranges Everything AbstractRange labels Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects. ranges Everything AbstractRange
Projects
None yet
Development

No branches or pull requests

1 participant