Skip to content

Commit ce24a51

Browse files
authoredJan 15, 2018
Merge pull request #34 from fredrikekre/fe/type-constructor
deprecate constructors with type as first argument
2 parents e0ec9ed + c80b595 commit ce24a51

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed
 

‎README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ like Fortran.
88
```julia
99
julia> using OffsetArrays
1010

11-
julia> y = OffsetArray(Float64, -1:1, -7:7, -128:512, -5:5, -1:1, -3:3, -2:2, -1:1);
11+
julia> y = OffsetArray{Float64}(-1:1, -7:7, -128:512, -5:5, -1:1, -3:3, -2:2, -1:1);
1212

1313
julia> summary(y)
1414
"OffsetArrays.OffsetArray{Float64,8,Array{Float64,8}} with indices -1:1×-7:7×-128:512×-5:5×-1:1×-3:3×-2:2×-1:1"
@@ -117,11 +117,11 @@ Only the 2nd timing after warming up is given.
117117
Added
118118
+ examples/scalar_law/PROGRAM1/...
119119
```sh
120-
[~/w/m/O/e/s/PROGRAM1] $ julia linaddmain.jl --cells=10000 --runs=3 ms master|✚ 1…
120+
[~/w/m/O/e/s/PROGRAM1] $ julia linaddmain.jl --cells=10000 --runs=3 ms master|✚ 1…
121121
0.672295 seconds (42.90 k allocations: 1.990 MB)
122122
0.509693 seconds (18 allocations: 313.281 KB)
123123
0.512243 seconds (18 allocations: 313.281 KB)
124-
[~/w/m/O/e/s/PROGRAM1] $ julia linaddmain.jl --cells=100000 --runs=3 6134ms master|✚ 1…
124+
[~/w/m/O/e/s/PROGRAM1] $ julia linaddmain.jl --cells=100000 --runs=3 6134ms master|✚ 1…
125125
7.270463 seconds (42.90 k allocations: 4.736 MB)
126126
7.177485 seconds (18 allocations: 3.053 MB)
127127
7.248687 seconds (18 allocations: 3.053 MB)

‎src/OffsetArrays.jl

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ OffsetArray{T}(inds::Indices{N}) where {T,N} = OffsetArray{T,N}(inds)
3333
OffsetArray{T,N}(inds::Vararg{AbstractUnitRange,N}) where {T,N} = OffsetArray{T,N}(inds)
3434
OffsetArray{T}(inds::Vararg{AbstractUnitRange,N}) where {T,N} = OffsetArray{T,N}(inds)
3535
OffsetArray(A::AbstractArray{T,0}) where {T} = OffsetArray{T,0,typeof(A)}(A, ())
36-
OffsetArray(::Type{T}, inds::Vararg{UnitRange{Int},N}) where {T,N} = OffsetArray{T,N}(inds)
3736

3837
# OffsetVector constructors
3938
OffsetVector(A::AbstractVector, offset) = OffsetArray(A, offset)
40-
OffsetVector(::Type{T}, inds::AbstractUnitRange) where {T} = OffsetArray{T,1}(inds)
4139
OffsetVector{T}(inds::AbstractUnitRange) where {T} = OffsetArray{T}(inds)
4240

41+
# https://github.com/JuliaLang/julia/pull/19989
42+
Base.@deprecate OffsetArray(::Type{T}, inds::Vararg{UnitRange{Int},N}) where {T,N} OffsetArray{T}(inds)
43+
Base.@deprecate OffsetVector(::Type{T}, inds::AbstractUnitRange) where {T} OffsetVector{T}(inds)
44+
4345
# The next two are necessary for ambiguity resolution. Really, the
4446
# second method should not be necessary.
4547
OffsetArray(A::AbstractArray{T,0}, inds::Tuple{}) where {T} = OffsetArray{T,0,typeof(A)}(A, ())

‎test/runtests.jl

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ using Compat.DelimitedFiles
88
# Basics
99
for n = 0:5
1010
for a in (OffsetArray(ones(Int,ntuple(d->1,n)), ntuple(x->x-1,n)),
11-
fill!(OffsetArray(Float64, ntuple(x->x:x, n)...), 1),
1211
fill!(OffsetArray{Float64}(ntuple(x->x:x, n)), 1),
1312
fill!(OffsetArray{Float64}(ntuple(x->x:x, n)...), 1),
1413
fill!(OffsetArray{Float64,n}(ntuple(x->x:x, n)), 1),
@@ -24,7 +23,7 @@ a = OffsetArray(a0)
2423
@test ndims(a) == 0
2524
@test a[] == 3
2625

27-
y = OffsetArray(Float64, -1:1, -7:7, -128:512, -5:5, -1:1, -3:3, -2:2, -1:1)
26+
y = OffsetArray{Float64}(-1:1, -7:7, -128:512, -5:5, -1:1, -3:3, -2:2, -1:1)
2827
@test axes(y) == (-1:1, -7:7, -128:512, -5:5, -1:1, -3:3, -2:2, -1:1)
2928
y[-1,-7,-128,-5,-1,-3,-2,-1] = 14
3029
y[-1,-7,-128,-5,-1,-3,-2,-1] += 5
@@ -368,6 +367,5 @@ end
368367
local v = rand(5)
369368
@test OffsetVector(v, -2) == OffsetArray(v, -2)
370369
@test OffsetVector(v, -2:2) == OffsetArray(v, -2:2)
371-
@test typeof(OffsetVector(Float64, -2:2)) == typeof(OffsetArray(Float64, -2:2))
372370
@test typeof(OffsetVector{Float64}(-2:2)) == typeof(OffsetArray{Float64}(-2:2))
373371
end

0 commit comments

Comments
 (0)
Please sign in to comment.