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

How is 0.0:0.0:∞ handled? #117

Open
putianyi889 opened this issue Mar 15, 2023 · 3 comments
Open

How is 0.0:0.0:∞ handled? #117

putianyi889 opened this issue Mar 15, 2023 · 3 comments

Comments

@putianyi889
Copy link
Contributor

putianyi889 commented Mar 15, 2023

Currently this cannot be constructed with colons.

julia> 0.0:0.0:∞
ERROR: ArgumentError: InfStepRange must have infinite length
Stacktrace:
 [1] (::Colon)(start::Float64, step::Float64, stop::Infinities.Infinity)
   @ InfiniteArrays C:\Users\pty\.julia\dev\InfiniteArrays\src\infrange.jl:19
 [2] top-level scope
   @ REPL[40]:1

It can be generated using the type constructor or manipulating ranges.

julia> (1.0:∞)-(1.0:∞)
0.0:0.0:+∞

julia> InfStepRange(0.0,0.0)
0.0:0.0:+∞

julia> InfStepRange(0,0)
0:0:+

This is the same strategy that Julia Base uses. StepRangeLen is well defined for this purpose, while InfStepRange is ambiguous on what the stop should be.

julia> (1.0:5.0)-(1.0:5.0)
StepRangeLen(0.0, 0.0, 5)

julia> (1:5)-(1:5)
StepRangeLen(0, 0, 5)

InfUnitRange has a different pipeline.

julia> (1:∞)-(1:∞)
ℵ₀-element Fill{Int64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}} with indices OneToInf(), with entries equal to 0
@putianyi889
Copy link
Contributor Author

There is a case where 0.0:0.0:∞ has a problem, although it doesn't have much to do with the type definitions.

julia> r = InfiniteArrays.InfStepRange(0.0,0.0)
0.0:0.0:+∞

julia> s=-r
-0.0:-0.0:-∞

julia> last(s),last(r)
(-∞, +∞)

julia> s[end],r[end]
(ℵ₀, ℵ₀)

julia> s==r
false

@putianyi889
Copy link
Contributor Author

iszero(0.0:0.0:+∞) currently falls into infinite loop.

@dlfivefifty
Copy link
Member

This change is related: #122

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