Skip to content

Commit f867f50

Browse files
N5N3vtjnash
andcommitted
Code clean and make test work.
Co-Authored-By: Jameson Nash <vtjnash+github@gmail.com>
1 parent 2d386ec commit f867f50

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

base/abstractarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ If multiple arguments are passed, equivalent to `has_offset_axes(A) | has_offset
104104
"""
105105
has_offset_axes(A) = _any_tuple(x->Int(first(x))::Int != 1, false, axes(A)...)
106106
has_offset_axes(A::AbstractVector) = Int(firstindex(A))::Int != 1 # improve performance of a common case (ranges)
107-
#Use `_any_tuple` to avoid unneed invoke.
108-
#TODO: call `any` directly once our compiler is ready.
107+
# Use `_any_tuple` to avoid unneeded invoke.
108+
# note: this could call `any` directly if the compiler can infer it
109109
has_offset_axes(As...) = _any_tuple(has_offset_axes, false, As...)
110110
has_offset_axes(::Colon) = false
111111

test/abstractarray.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,12 +1572,12 @@ end
15721572
end
15731573

15741574
module IRUtils
1575-
include(normpath(@__DIR__, "./compiler/irutils.jl"))
1575+
include("compiler/irutils.jl")
15761576
end
15771577

15781578
@testset "strides for ReshapedArray" begin
15791579
# Type-based contiguous Check
1580-
a = vec(reinterpret(reshape,Int16,reshape(view(reinterpret(Int32,randn(10)),2:11),5,:)))
1580+
a = vec(reinterpret(reshape, Int16, reshape(view(reinterpret(Int32, randn(10)), 2:11), 5, :)))
15811581
f(a) = only(strides(a));
15821582
@test IRUtils.fully_eliminated(f, Base.typesof(a)) && f(a) == 1
15831583
# General contiguous check
@@ -1624,14 +1624,14 @@ end
16241624
tb = reinterpret(Float64, view(a, 1:2:10))
16251625
tc = reinterpret(Float64, reshape(view(a, 1:3:10), 2, 2, 1))
16261626
# Issue #44040
1627-
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc))
1628-
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(tc,tc))
1629-
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc,tb))
1627+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta, tc))
1628+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(tc, tc))
1629+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta, tc, tb))
16301630
# Ranges && CartesianIndices
1631-
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(1:10,Base.OneTo(10),1.0:2.0,LinRange(1.0,2.0,2),1:2:10,CartesianIndices((1:2:10,1:2:10))))
1631+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(1:10, Base.OneTo(10), 1.0:2.0, LinRange(1.0, 2.0, 2), 1:2:10, CartesianIndices((1:2:10, 1:2:10))))
16321632
# Remind us to call `any` in `Base.has_offset_axes` once our compiler is ready.
1633-
@inline _has_offset_axes(A) = @inline any(x->Int(first(x))::Int != 1, axes(A))
1633+
@inline _has_offset_axes(A) = @inline any(x -> Int(first(x))::Int != 1, axes(A))
16341634
@inline _has_offset_axes(As...) = @inline any(_has_offset_axes, As)
1635-
a, b = zeros(2,2,2), zeros(2,2)
1636-
@test_broken IRUtils.fully_eliminated(_has_offset_axes, Base.typesof(a,a,b,b))
1635+
a, b = zeros(2, 2, 2), zeros(2, 2)
1636+
@test_broken IRUtils.fully_eliminated(_has_offset_axes, Base.typesof(a, a, b, b))
16371637
end

test/ranges.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,9 +2032,11 @@ end
20322032
end
20332033

20342034
@testset "length(StepRange()) type stability" begin
2035-
typeof(length(StepRange(1,Int128(1),1))) == typeof(length(StepRange(1,Int128(1),0))) #bigints
2036-
typeof(length(StepRange(Int8(1),Int128(1),Int8(1)))) == typeof(length(StepRange(Int8(1),Int128(1),Int8(0)))) #smallints
2037-
typeof(checked_length(StepRange(1,Int128(1),1))) == typeof(checked_length(StepRange(1,Int128(1),0)))
2035+
for SR in (StepRange{Int,Int128}, StepRange{Int8,Int128})
2036+
r1, r2 = SR(1, 1, 1), SR(1, 1, 0)
2037+
@test typeof(length(r1)) == typeof(checked_length(r1)) ==
2038+
typeof(length(r2)) == typeof(checked_length(r2))
2039+
end
20382040
end
20392041

20402042
@testset "LinRange eltype for element types that wrap integers" begin
@@ -2351,10 +2353,8 @@ end
23512353

23522354
@testset "firstindex(::StepRange{T,T})" begin
23532355
test_firstindex(x) = firstindex(x) === first(Base.axes1(x))
2354-
for T1 in (Int8,Int16,Int32,Int64,Int128), T2 in (Int8,Int16,Int32,Int64,Int128)
2355-
for T in (T1, unsigned(T1)), S in (T2, unsigned(T2))
2356-
@test test_firstindex(StepRange{T,S}(1,1,1))
2357-
@test test_firstindex(StepRange{T,S}(1,1,0))
2358-
end
2356+
for T in Base.BitInteger_types, S in Base.BitInteger_types
2357+
@test test_firstindex(StepRange{T,S}(1, 1, 1))
2358+
@test test_firstindex(StepRange{T,S}(1, 1, 0))
23592359
end
23602360
end

0 commit comments

Comments
 (0)