Skip to content

Commit c0558ec

Browse files
authored
Sort for RangeCumsum of OneToInf (#167)
* Sort for RangeCumsum of OneToInf * Use cumsum instead of Rangecumsum in test
1 parent a9cca92 commit c0558ec

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "InfiniteArrays"
22
uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
3-
version = "0.13.6"
3+
version = "0.13.7"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/infrange.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ function union(r1::RangeCumsum{T1, OneToInf{T1}}, r2::RangeCumsum{T2, OneToInf{T
524524
T = promote_type(T1, T2)
525525
RangeCumsum(OneToInf{T}())
526526
end
527+
Base.issorted(r::RangeCumsum{<:Any,<:OneToInf}) = true
528+
Base.sort(r::RangeCumsum{<:Any,<:OneToInf}) = r
529+
Base.sort!(r::RangeCumsum{<:Any,<:OneToInf}) = r
527530

528531
# vcat
529532

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ end
220220
@test sort(2:2:∞) sort!(2:2:∞) 2:2:
221221
@test_throws ArgumentError sort(2:-2:-∞)
222222
@test_throws ArgumentError sort!(2:-2:-∞)
223+
224+
@testset "RangeCumsum" begin
225+
r = InfiniteArrays.OneToInf()
226+
rs = cumsum(r)
227+
@test sort(rs) === sort!(rs) === rs
228+
@test @inferred((rs -> Val(issorted(rs)))(rs)) isa Val{true}
229+
end
223230
end
224231
@testset "in" begin
225232
@test 0 in UInt(0):100:

0 commit comments

Comments
 (0)