Skip to content

Commit 99e650a

Browse files
Sacha0fredrikekre
authored andcommitted
Replace OffsetArray(inds...) constructors and calls with OffsetArray(uninitialized, inds...). (#24783)
1 parent d4a0e27 commit 99e650a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

test/TestHelpers.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ OffsetVector{T,AA<:AbstractArray} = OffsetArray{T,1,AA}
129129
OffsetArray(A::AbstractArray{T,N}, offsets::NTuple{N,Int}) where {T,N} = OffsetArray{T,N,typeof(A)}(A, offsets)
130130
OffsetArray(A::AbstractArray{T,N}, offsets::Vararg{Int,N}) where {T,N} = OffsetArray(A, offsets)
131131

132-
OffsetArray{T,N}(inds::Indices{N}) where {T,N} = OffsetArray{T,N,Array{T,N}}(Array{T,N}(uninitialized, map(length, inds)), map(indsoffset, inds))
133-
OffsetArray{T}(inds::Indices{N}) where {T,N} = OffsetArray{T,N}(inds)
132+
OffsetArray{T,N}(::Uninitialized, inds::Indices{N}) where {T,N} =
133+
OffsetArray{T,N,Array{T,N}}(Array{T,N}(uninitialized, map(length, inds)), map(indsoffset, inds))
134+
OffsetArray{T}(::Uninitialized, inds::Indices{N}) where {T,N} =
135+
OffsetArray{T,N}(uninitialized, inds)
134136

135137
Base.IndexStyle(::Type{T}) where {T<:OffsetArray} = Base.IndexStyle(parenttype(T))
136138
parenttype(::Type{OffsetArray{T,N,AA}}) where {T,N,AA} = AA

test/offsetarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ v = view(A0, 1:1, i1)
230230
@test indices(v) === (Base.OneTo(1), -4:-3)
231231

232232
# copy! and fill!
233-
a = OffsetArray{Int}((-3:-1,))
233+
a = OffsetArray{Int}(uninitialized, (-3:-1,))
234234
fill!(a, -1)
235235
copy!(a, (1,2)) # non-array iterables
236236
@test a[-3] == 1
@@ -274,7 +274,7 @@ copy!(a, -3, b, 2)
274274
@test a[-3] == 2
275275
@test a[-2] == a[-1] == -1
276276
@test_throws BoundsError copy!(a, -3, b, 1, 4)
277-
am = OffsetArray{Int}((1:1, 7:9)) # for testing linear indexing
277+
am = OffsetArray{Int}(uninitialized, (1:1, 7:9)) # for testing linear indexing
278278
fill!(am, -1)
279279
copy!(am, b)
280280
@test am[1] == 1

0 commit comments

Comments
 (0)