Skip to content

Commit 1c92e1f

Browse files
committed
get rid of VERSION checks
They are obsolete given the 1.10+ Julia compatibility.
1 parent 2204d5b commit 1c92e1f

File tree

4 files changed

+23
-62
lines changed

4 files changed

+23
-62
lines changed

src/collect.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ _append!!(dest::AbstractVector, itr, ::Base.SizeUnknown) =
160160
grow_to_structarray!(dest, itr)
161161

162162
# Optimized version when element collection is an `AbstractVector`
163-
# This only works for julia 1.3 or greater, which has `append!` for `AbstractVector`
164-
@static if VERSION v"1.3.0"
165-
function append!!(dest::V, v::AbstractVector{T}) where {V<:AbstractVector, T}
166-
new = iscompatible(T, V) ? dest : widen_from_type(dest, length(dest) + 1, T)
167-
return append!(new, v)
168-
end
163+
function append!!(dest::V, v::AbstractVector{T}) where {V<:AbstractVector, T}
164+
new = iscompatible(T, V) ? dest : widen_from_type(dest, length(dest) + 1, T)
165+
return append!(new, v)
169166
end

src/structarray.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,9 @@ function Base.deleteat!(s::StructVector{T}, idxs) where T
415415
return StructVector{T}(t)
416416
end
417417

418-
@static if VERSION >= v"1.7.0"
419-
function Base.keepat!(s::StructVector{T}, idxs) where T
420-
t = map(Base.Fix2(keepat!, idxs), components(s))
421-
return StructVector{T}(t)
422-
end
418+
function Base.keepat!(s::StructVector{T}, idxs) where T
419+
t = map(Base.Fix2(keepat!, idxs), components(s))
420+
return StructVector{T}(t)
423421
end
424422

425423
Base.copyto!(I::StructArray, J::StructArray) = (foreachfield(copyto!, I, J); I)

src/utils.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,7 @@ julia> s = StructArray(a=1:3, b = fill("string", 3));
143143
julia> s_pooled = StructArrays.replace_storage(s) do v
144144
isbitstype(eltype(v)) ? v : convert(PooledArray, v)
145145
end
146-
$(if VERSION < v"1.6-"
147-
"3-element StructArray(::UnitRange{Int64}, ::PooledArray{String,UInt32,1,Array{UInt32,1}}) with eltype $(NamedTuple{(:a, :b),Tuple{Int64,String}}):"
148-
else
149-
"3-element StructArray(::UnitRange{Int64}, ::PooledVector{String, UInt32, Vector{UInt32}}) with eltype $(NamedTuple{(:a, :b), Tuple{Int64, String}}):"
150-
end)
146+
3-element StructArray(::UnitRange{Int64}, ::PooledVector{String, UInt32, Vector{UInt32}}) with eltype $(NamedTuple{(:a, :b), Tuple{Int64, String}}):
151147
(a = 1, b = "string")
152148
(a = 2, b = "string")
153149
(a = 3, b = "string")

test/runtests.jl

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,8 @@ end
262262
@test d == c == StructArray(a=[1,10,2,3], b=[2,20,3,4], c=["a","A","b","c"])
263263
d = deleteat!(c, 2)
264264
@test d == c == StructArray(a=[1,2,3], b=[2,3,4], c=["a","b","c"])
265-
if Base.VERSION >= v"1.7.0"
266-
d = keepat!(c, 2)
267-
@test d == c == StructArray(a=[2], b=[3], c=["b"])
268-
end
265+
d = keepat!(c, 2)
266+
@test d == c == StructArray(a=[2], b=[3], c=["b"])
269267

270268
c = StructArray(a=[1], b=[2], c=["a"])
271269
d = [(a=10, b=20, c="A")]
@@ -302,10 +300,8 @@ end
302300
@test d == c == StructArray{C}(a=[1,10,2,3], b=[2,20,3,4], c=["a","A","b","c"])
303301
d = deleteat!(c, 2)
304302
@test d == c == StructArray{C}(a=[1,2,3], b=[2,3,4], c=["a","b","c"])
305-
if Base.VERSION >= v"1.7.0"
306-
d = keepat!(c, 2)
307-
@test d == c == StructArray{C}(a=[2], b=[3], c=["b"])
308-
end
303+
d = keepat!(c, 2)
304+
@test d == c == StructArray{C}(a=[2], b=[3], c=["b"])
309305

310306
c = StructArray{C}(a=[1], b=[2], c=["a"])
311307
d = [C(10, 20, "A")]
@@ -495,14 +491,12 @@ end
495491
end
496492

497493
@testset "constructor from slices" begin
498-
if VERSION >= v"1.1"
499-
X = [1.0 2.0; 3.0 4.0]
500-
@test StructArray{Complex{Float64}}(X; dims=1) == [Complex(1.0,3.0), Complex(2.0,4.0)]
501-
@test StructArray{Complex{Float64}}(X; dims=2) == [Complex(1.0,2.0), Complex(3.0,4.0)]
494+
X = [1.0 2.0; 3.0 4.0]
495+
@test StructArray{Complex{Float64}}(X; dims=1) == [Complex(1.0,3.0), Complex(2.0,4.0)]
496+
@test StructArray{Complex{Float64}}(X; dims=2) == [Complex(1.0,2.0), Complex(3.0,4.0)]
502497

503-
X = [1.0 2.0; 3.0 4.0; 5.0 6.0]
504-
@test StructArray{Tuple{Float64,Complex{Float64}}}(X; dims=1) == [(1.0,Complex(3.0,5.0)), (2.0, Complex(4.0,6.0))]
505-
end
498+
X = [1.0 2.0; 3.0 4.0; 5.0 6.0]
499+
@test StructArray{Tuple{Float64,Complex{Float64}}}(X; dims=1) == [(1.0,Complex(3.0,5.0)), (2.0, Complex(4.0,6.0))]
506500
end
507501

508502
struct A
@@ -1111,19 +1105,11 @@ end
11111105
io = IOBuffer()
11121106
Base.showarg(io, rows, true)
11131107
str = String(take!(io))
1114-
if VERSION < v"1.6-"
1115-
@test str == "LazyRows(::Array{Float64,2}, ::Array{Float64,2}) with eltype LazyRow{Complex{Float64}}"
1116-
else
1117-
@test str == "LazyRows(::Matrix{Float64}, ::Matrix{Float64}) with eltype LazyRow{ComplexF64}"
1118-
end
1108+
@test str == "LazyRows(::Matrix{Float64}, ::Matrix{Float64}) with eltype LazyRow{ComplexF64}"
11191109
io = IOBuffer()
11201110
Base.showarg(io, rows, false)
11211111
str = String(take!(io))
1122-
if VERSION < v"1.6-"
1123-
@test str == "LazyRows(::Array{Float64,2}, ::Array{Float64,2})"
1124-
else
1125-
@test str == "LazyRows(::Matrix{Float64}, ::Matrix{Float64})"
1126-
end
1112+
@test str == "LazyRows(::Matrix{Float64}, ::Matrix{Float64})"
11271113
s = StructArray((rand(10, 10), rand(10, 10)))
11281114
rows = LazyRows(s)
11291115
@test IndexStyle(rows) isa IndexLinear
@@ -1143,19 +1129,11 @@ end
11431129
io = IOBuffer()
11441130
Base.showarg(io, rows, true)
11451131
str = String(take!(io))
1146-
if VERSION < v"1.6-"
1147-
@test str == "LazyRows(::Array{Float64,2}, ::Array{Float64,2}) with eltype LazyRow{Tuple{Float64,Float64}}"
1148-
else
1149-
@test str == "LazyRows(::Matrix{Float64}, ::Matrix{Float64}) with eltype LazyRow{Tuple{Float64, Float64}}"
1150-
end
1132+
@test str == "LazyRows(::Matrix{Float64}, ::Matrix{Float64}) with eltype LazyRow{Tuple{Float64, Float64}}"
11511133
io = IOBuffer()
11521134
Base.showarg(io, rows, false)
11531135
str = String(take!(io))
1154-
if VERSION < v"1.6-"
1155-
@test str == "LazyRows(::Array{Float64,2}, ::Array{Float64,2})"
1156-
else
1157-
@test str == "LazyRows(::Matrix{Float64}, ::Matrix{Float64})"
1158-
end
1136+
@test str == "LazyRows(::Matrix{Float64}, ::Matrix{Float64})"
11591137
end
11601138

11611139
@testset "refarray" begin
@@ -1185,19 +1163,11 @@ end
11851163
io = IOBuffer()
11861164
Base.showarg(io, s, true)
11871165
str = String(take!(io))
1188-
if VERSION < v"1.6-"
1189-
@test str == "StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype Complex{Int64}"
1190-
else
1191-
@test str == "StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype Complex{Int64}"
1192-
end
1166+
@test str == "StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype Complex{Int64}"
11931167
io = IOBuffer()
11941168
Base.showarg(io, s, false)
11951169
str = String(take!(io))
1196-
if VERSION < v"1.6-"
1197-
@test str == "StructArray(::Array{Int64,1}, ::Array{Int64,1})"
1198-
else
1199-
@test str == "StructArray(::Vector{Int64}, ::Vector{Int64})"
1200-
end
1170+
@test str == "StructArray(::Vector{Int64}, ::Vector{Int64})"
12011171
end
12021172

12031173
@testset "append!!" begin
@@ -1474,7 +1444,7 @@ end
14741444
t = map(x -> (a=rand(["", 1, nothing]),), StructVector(a=1:10))::StructVector
14751445
@test eltype(t) <: NamedTuple{(:a,)}
14761446

1477-
t = VERSION >= v"1.7" ? @inferred(map(x -> (a=x.a, b=2), s)) : map(x -> (a=x.a, b=2), s)
1447+
t = @inferred map(x -> (a=x.a, b=2), s)
14781448
@test t isa StructArray
14791449
@test map(x -> (a=x.a, b=2), s) == [(a=1, b=2), (a=2, b=2), (a=3, b=2)]
14801450

0 commit comments

Comments
 (0)