Skip to content

Commit 8c8f4f3

Browse files
committed
- deprecation fixes for julia master
- add new broadcast interface
1 parent 78f1b6f commit 8c8f4f3

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

REQUIRE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
julia 0.6
2-
Compat 0.32
2+
Compat 0.39

src/OffsetArrays.jl

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ OffsetArray(A::AbstractArray{T,N}, offsets::Vararg{Int,N}) where {T,N} =
2727
OffsetArray(A, offsets)
2828

2929
OffsetArray{T,N}(inds::Indices{N}) where {T,N} =
30-
OffsetArray{T,N,Array{T,N}}(Array{T,N}(map(length, inds)), map(indexoffset, inds))
30+
OffsetArray{T,N,Array{T,N}}(Array{T,N}(uninitialized, map(length, inds)), map(indexoffset, inds))
3131
OffsetArray{T}(inds::Indices{N}) where {T,N} = OffsetArray{T,N}(inds)
3232
OffsetArray{T,N}(inds::Vararg{AbstractUnitRange,N}) where {T,N} = OffsetArray{T,N}(inds)
3333
OffsetArray{T}(inds::Vararg{AbstractUnitRange,N}) where {T,N} = OffsetArray{T,N}(inds)
@@ -84,8 +84,14 @@ function Base.similar(A::AbstractArray, ::Type{T}, inds::Tuple{UnitRange,Vararg{
8484
OffsetArray(B, map(indexoffset, inds))
8585
end
8686

87-
Base.similar(f::Union{Function,Type}, shape::Tuple{UnitRange,Vararg{UnitRange}}) =
87+
Base.similar(f::Function, shape::Tuple{UnitRange,Vararg{UnitRange}}) =
8888
OffsetArray(f(map(length, shape)), map(indexoffset, shape))
89+
Base.similar(::Type{T}, shape::Tuple{UnitRange,Vararg{UnitRange}}) where {T<:OffsetArray} =
90+
OffsetArray(T(map(length, shape)), map(indexoffset, shape))
91+
Base.similar(::Type{T}, shape::Tuple{UnitRange,Vararg{UnitRange}}) where {T<:Array} =
92+
OffsetArray(T(uninitialized, map(length, shape)), map(indexoffset, shape))
93+
Base.similar(::Type{T}, shape::Tuple{UnitRange,Vararg{UnitRange}}) where {T<:BitArray} =
94+
OffsetArray(T(uninitialized, map(length, shape)), map(indexoffset, shape))
8995

9096
Base.reshape(A::AbstractArray, inds::Tuple{UnitRange,Vararg{UnitRange}}) =
9197
OffsetArray(reshape(A, map(length, inds)), map(indexoffset, inds))

test/runtests.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Base.Test
1+
using Compat.Test
22
using OffsetArrays
33

44
@test isempty(detect_ambiguities(OffsetArrays, Base, Core))
@@ -144,7 +144,7 @@ v = OffsetArray(rand(3), (-2,))
144144
@test sprint(show, v) == sprint(show, parent(v))
145145
io = IOBuffer()
146146
function cmp_showf(printfunc, io, A)
147-
ioc = IOContext(io, limit=true, compact=true)
147+
ioc = IOContext(io, :limit=>true, :compact=>true)
148148
printfunc(ioc, A)
149149
str1 = String(take!(io))
150150
printfunc(ioc, parent(A))

0 commit comments

Comments
 (0)