Skip to content

Commit dde6f0b

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

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
@@ -106,8 +106,8 @@ See also [`require_one_based_indexing`](@ref).
106106
"""
107107
has_offset_axes(A) = _any_tuple(x->Int(first(x))::Int != 1, false, axes(A)...)
108108
has_offset_axes(A::AbstractVector) = Int(firstindex(A))::Int != 1 # improve performance of a common case (ranges)
109-
#Use `_any_tuple` to avoid unneed invoke.
110-
#TODO: call `any` directly once our compiler is ready.
109+
# Use `_any_tuple` to avoid unneeded invoke.
110+
# note: this could call `any` directly if the compiler can infer it
111111
has_offset_axes(As...) = _any_tuple(has_offset_axes, false, As...)
112112
has_offset_axes(::Colon) = false
113113

test/abstractarray.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ end
15841584
end
15851585

15861586
module IRUtils
1587-
include(normpath(@__DIR__, "./compiler/irutils.jl"))
1587+
include("compiler/irutils.jl")
15881588
end
15891589

15901590
@testset "strides for ReshapedArray" begin
@@ -1599,7 +1599,7 @@ end
15991599
return true
16001600
end
16011601
# Type-based contiguous Check
1602-
a = vec(reinterpret(reshape,Int16,reshape(view(reinterpret(Int32,randn(10)),2:11),5,:)))
1602+
a = vec(reinterpret(reshape, Int16, reshape(view(reinterpret(Int32, randn(10)), 2:11), 5, :)))
16031603
f(a) = only(strides(a));
16041604
@test IRUtils.fully_eliminated(f, Base.typesof(a)) && f(a) == 1
16051605
# General contiguous check
@@ -1674,14 +1674,14 @@ end
16741674
tb = reinterpret(Float64, view(a, 1:2:10))
16751675
tc = reinterpret(Float64, reshape(view(a, 1:3:10), 2, 2, 1))
16761676
# Issue #44040
1677-
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc))
1678-
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(tc,tc))
1679-
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc,tb))
1677+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta, tc))
1678+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(tc, tc))
1679+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta, tc, tb))
16801680
# Ranges && CartesianIndices
1681-
@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))))
1681+
@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))))
16821682
# Remind us to call `any` in `Base.has_offset_axes` once our compiler is ready.
1683-
@inline _has_offset_axes(A) = @inline any(x->Int(first(x))::Int != 1, axes(A))
1683+
@inline _has_offset_axes(A) = @inline any(x -> Int(first(x))::Int != 1, axes(A))
16841684
@inline _has_offset_axes(As...) = @inline any(_has_offset_axes, As)
1685-
a, b = zeros(2,2,2), zeros(2,2)
1686-
@test_broken IRUtils.fully_eliminated(_has_offset_axes, Base.typesof(a,a,b,b))
1685+
a, b = zeros(2, 2, 2), zeros(2, 2)
1686+
@test_broken IRUtils.fully_eliminated(_has_offset_axes, Base.typesof(a, a, b, b))
16871687
end

test/ranges.jl

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

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

20392041
@testset "LinRange eltype for element types that wrap integers" begin
@@ -2350,10 +2352,8 @@ end
23502352

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

0 commit comments

Comments
 (0)