Skip to content

Drop support for versions of Julia lower than v1.6 #985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: 1.4
version: 1.6
- name: Install dependencies
run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI@0.1"'
- name: Run benchmarks
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ jobs:
strategy:
matrix:
version:
- '1.6'
- '1'
- '1.0'
- '1.1'
- '1.2'
- '1.3'
- '1.4'
- 'nightly'
os:
- ubuntu-latest
Expand All @@ -32,13 +28,6 @@ jobs:
# See https://github.com/marketplace/actions/setup-julia-environment
# MacOS not available on x86
- {os: 'macOS-latest', arch: 'x86'}
# Don't test on all versions
- {os: 'macOS-latest', version: '1.1'}
- {os: 'macOS-latest', version: '1.2'}
- {os: 'macOS-latest', version: '1.3'}
- {os: 'windows-latest', version: '1.1'}
- {os: 'windows-latest', version: '1.2'}
- {os: 'windows-latest', version: '1.3'}
steps:
- uses: actions/checkout@v1
- uses: julia-actions/setup-julia@latest
Expand All @@ -57,7 +46,7 @@ jobs:
- uses: actions/checkout@v1
- uses: julia-actions/setup-julia@latest
with:
version: '1.4'
version: '1.6'
- run: julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(; path=pwd()));
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name = "StaticArrays"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.3.6"
version = "1.4.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
julia = "1"
julia = "1.6"

[extras]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Expand Down
4 changes: 2 additions & 2 deletions benchmark/bench_matrix_ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ using StaticArrays

const suite = BenchmarkGroup()
const matrix_sizes = if haskey(ENV, "GITHUB_EVENT_PATH")
(1, 2, 3, 4, 10, 20)
(1, 2, 3, 4, 10)
else
1:20
1:10
end

# Use same arrays across processes (at least with the same Julia version):
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*Statically sized arrays for Julia*

**StaticArrays** provides a framework for implementing statically sized arrays
in Julia (≥ 0.5), using the abstract type `StaticArray{Size,T,N} <: AbstractArray{T,N}`.
in Julia, using the abstract type `StaticArray{Size,T,N} <: AbstractArray{T,N}`.
Subtypes of [`StaticArray`](@ref) will provide fast implementations of common array and
linear algebra operations. Note that here "statically sized" means that the
size can be determined from the *type*, and "static" does **not** necessarily
Expand Down
9 changes: 2 additions & 7 deletions src/SizedArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ struct SizedArray{S<:Tuple,T,N,M,TData<:AbstractArray{T,M}} <: StaticArray{S,T,N
end

# Julia v1.0 has some weird bug that prevents this from working
@static if VERSION >= v"1.1"
@inline SizedArray(a::StaticArray{S,T,N}) where {S<:Tuple,T,N} = SizedArray{S,T,N}(a)
end
@inline SizedArray(a::StaticArray{S,T,N}) where {S<:Tuple,T,N} = SizedArray{S,T,N}(a)
@inline function SizedArray{S,T,N}(
a::TData,
) where {S,T,N,M,TData<:AbstractArray{T,M}}
Expand Down Expand Up @@ -151,10 +149,7 @@ end

const SizedMatrix{S1,S2,T} = SizedArray{Tuple{S1,S2},T,2}

# Julia v1.0 has some weird bug that prevents this from working
@static if VERSION >= v"1.1"
SizedMatrix(a::StaticMatrix{N,M,T}) where {N,M,T} = SizedMatrix{N,M,T}(a)
end
SizedMatrix(a::StaticMatrix{N,M,T}) where {N,M,T} = SizedMatrix{N,M,T}(a)
@inline function SizedMatrix{S1,S2}(
a::TData,
) where {S1,S2,T,M,TData<:AbstractArray{T,M}}
Expand Down
6 changes: 2 additions & 4 deletions src/StaticArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ include("deque.jl")
include("flatten.jl")
include("io.jl")

if Base.VERSION >= v"1.4.2"
include("precompile.jl")
_precompile_()
end
include("precompile.jl")
_precompile_()

end # module
12 changes: 5 additions & 7 deletions src/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,11 @@ end
end
end

if VERSION >= v"1.6.0-DEV.1334"
# FIXME: This always assumes one-based linear indexing and that subtypes of StaticArray
# don't overload iterate
@inline function Base.rest(a::StaticArray{S}, (_, i) = (nothing, 0)) where {S}
newlen = tuple_prod(S) - i
return similar_type(typeof(a), Size(newlen))(Base.rest(Tuple(a), i + 1))
end
# FIXME: This always assumes one-based linear indexing and that subtypes of StaticArray
# don't overload iterate
@inline function Base.rest(a::StaticArray{S}, (_, i) = (nothing, 0)) where {S}
newlen = tuple_prod(S) - i
return similar_type(typeof(a), Size(newlen))(Base.rest(Tuple(a), i + 1))
end

# SArrays may avoid the SubArray wrapper and consequently an additional level of indirection
Expand Down
14 changes: 0 additions & 14 deletions test/SHermitianCompact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ end

fill3(x) = fill(3, x)

# @allocated behaves differently on 1.4, but the differences appear spurious in
# practice. See
# https://github.com/JuliaArrays/StaticArrays.jl/issues/710
allocated_workaround = VERSION >= v"1.4-DEV"

@testset "SHermitianCompact" begin
@testset "Inner Constructor" begin
for (N, L) in ((3, 6), (4, 10), (6, 21))
Expand Down Expand Up @@ -164,9 +159,6 @@ allocated_workaround = VERSION >= v"1.4-DEV"
let a = a
@test -a == -SMatrix(a)
@test -a isa SHermitianCompact{3, Int, 6}
if !allocated_workaround
@test_noalloc -a
end
end
for (x, y) in ((a, b), (a, c), (c, a))
@eval begin
Expand Down Expand Up @@ -210,15 +202,9 @@ allocated_workaround = VERSION >= v"1.4-DEV"
let a = SHermitianCompact(SVector{21, Int}(1 : 21))
@test a + 3I == SMatrix(a) + 3I
@test a + 3I isa typeof(a)
if !allocated_workaround
@test_noalloc a + 3I
end

@test a - 4I == SMatrix(a) - 4I
@test a - 4I isa typeof(a)
if !allocated_workaround
@test_noalloc a - 4I
end

@test a * 3I === a * 3
@test 3I * a === 3 * a
Expand Down
25 changes: 10 additions & 15 deletions test/SizedArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
@test size(SizedArray{Tuple{4,5},Int}(undef).data) == (4, 5)

# 0-element constructor
if VERSION >= v"1.1"
@test (@inferred SizedArray(MMatrix{0,0,Float64}()))::SizedMatrix{0,0,Float64} == SizedMatrix{0,0,Float64}()
end
@test (@inferred SizedArray(MMatrix{0,0,Float64}()))::SizedMatrix{0,0,Float64} == SizedMatrix{0,0,Float64}()

# From Tuple
@test @inferred(SizedArray{Tuple{2},Float64,1,1}((1,2)))::SizedArray{Tuple{2},Float64,1,1,Vector{Float64}} == [1.0, 2.0]
Expand Down Expand Up @@ -82,9 +80,7 @@
@test convert(Matrix, SizedMatrix{2,2}([1 2;3 4])) == [1 2; 3 4]

# 0-element constructor
if VERSION >= v"1.1"
@test (@inferred SizedMatrix(MMatrix{0,0,Float64}()))::SizedMatrix{0,0,Float64} == SizedMatrix{0,0,Float64}()
end
@test (@inferred SizedMatrix(MMatrix{0,0,Float64}()))::SizedMatrix{0,0,Float64} == SizedMatrix{0,0,Float64}()
end

# setindex
Expand All @@ -98,15 +94,14 @@
# pointer
@testset "pointer" begin
@test pointer(sa) === pointer(sa.data)
if VERSION ≥ v"1.5"
A = MMatrix{32,3,Float64}(undef);
av1 = view(A, 1, :);
av2 = view(A, :, 1);
@test pointer(A) == pointer(av1) == pointer(av2)
@test pointer(A, LinearIndices(A)[1,2]) == pointer(av1, 2)
@test pointer(A, LinearIndices(A)[2,1]) == pointer(av2, 2)
@test pointer(A, LinearIndices(A)[4,3]) == pointer(view(A, :, 3), 4) == pointer(view(A, 4, :), 3)
end

A = MMatrix{32,3,Float64}(undef);
av1 = view(A, 1, :);
av2 = view(A, :, 1);
@test pointer(A) == pointer(av1) == pointer(av2)
@test pointer(A, LinearIndices(A)[1,2]) == pointer(av1, 2)
@test pointer(A, LinearIndices(A)[2,1]) == pointer(av2, 2)
@test pointer(A, LinearIndices(A)[4,3]) == pointer(view(A, :, 3), 4) == pointer(view(A, 4, :), 3)
end

@testset "vec" begin
Expand Down
50 changes: 24 additions & 26 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,38 +327,36 @@ end
@test @inferred(hcat(SA[1 2 3])) === SA[1 2 3]
end

@static if VERSION >= v"1.6.0-DEV.1334"
@testset "Base.rest" begin
x = SA[1, 2, 3]
@testset "Base.rest" begin
x = SA[1, 2, 3]
@test Base.rest(x) == x
a, b... = x
@test b == SA[2, 3]

x = SA[1 2; 3 4]
@test Base.rest(x) == vec(x)
a, b... = x
@test b == SA[3, 2, 4]

a, b... = SA[1]
@test b == []
@test b isa SVector{0}

for (Vec, Mat) in [(MVector, MMatrix), (SizedVector, SizedMatrix)]
x = Vec(1, 2, 3)
@test Base.rest(x) == x
@test pointer(Base.rest(x)) != pointer(x)
a, b... = x
@test b == SA[2, 3]
@test b == Vec(2, 3)

x = SA[1 2; 3 4]
x = Mat{2,2}(1, 2, 3, 4)
@test Base.rest(x) == vec(x)
@test pointer(Base.rest(x)) != pointer(x)
a, b... = x
@test b == SA[3, 2, 4]
@test b == Vec(2, 3, 4)

a, b... = SA[1]
a, b... = Vec(1)
@test b == []
@test b isa SVector{0}

for (Vec, Mat) in [(MVector, MMatrix), (SizedVector, SizedMatrix)]
x = Vec(1, 2, 3)
@test Base.rest(x) == x
@test pointer(Base.rest(x)) != pointer(x)
a, b... = x
@test b == Vec(2, 3)

x = Mat{2,2}(1, 2, 3, 4)
@test Base.rest(x) == vec(x)
@test pointer(Base.rest(x)) != pointer(x)
a, b... = x
@test b == Vec(2, 3, 4)

a, b... = Vec(1)
@test b == []
@test b isa Vec{0}
end
@test b isa Vec{0}
end
end
2 changes: 0 additions & 2 deletions test/accumulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ using StaticArrays, Test
]
@test cumsum(a; dims = 2) == cumsum(collect(a); dims = 2)
@test cumsum(a; dims = 2) isa similar_type(a)
v"1.1" <= VERSION < v"1.2" && continue
@inferred cumsum(a; dims = Val(2))
end
end
Expand All @@ -43,7 +42,6 @@ using StaticArrays, Test
a = similar_type(SArray, Int, Size(shape))(1:prod(shape))
@test cumsum(a; dims = i) == cumsum(collect(a); dims = i)
@test cumsum(a; dims = i) isa SArray
v"1.1" <= VERSION < v"1.2" && continue
@inferred cumsum(a; dims = Val(i))
end

Expand Down
25 changes: 8 additions & 17 deletions test/ambiguities.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@

# Allow no new ambiguities (see #18), unless you fix some old ones first!

const allowable_ambiguities =
if VERSION < v"1.1"
3
elseif VERSION < v"1.2"
1
else
0
end
const allowable_ambiguities = VERSION ≥ v"1.7" ? 60 :
VERSION ≥ v"1.6" ? 61 : error("version must be ≥1.6")

if VERSION ≥ v"1.6.0"
# TODO: Revisit and fix. See
# https://github.com/JuliaLang/julia/pull/36962
# https://github.com/JuliaLang/julia/issues/36951
@test_broken length(detect_ambiguities(#=LinearAlgebra, =#StaticArrays)) <= allowable_ambiguities
else
@test length(detect_ambiguities(Base, LinearAlgebra, StaticArrays)) <= allowable_ambiguities
end
# TODO: Revisit and fix. See
# https://github.com/JuliaLang/julia/pull/36962
# https://github.com/JuliaLang/julia/issues/36951
# Let's not allow new ambiguities. If any change makes the ambiguity count decrease, the
# change should decrement `allowable_ambiguities` accordingly
@test length(detect_ambiguities(#=LinearAlgebra, =#StaticArrays)) == allowable_ambiguities
11 changes: 4 additions & 7 deletions test/chol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,10 @@ using LinearAlgebra: PosDefException
@test (@inferred c \ Symmetric(d)) isa SMatrix{3,3,elty}
@test c \ Symmetric(d) ≈ c_a \ Symmetric(d_a)

if VERSION >= v"1.3"
# on earlier versions of Julia d_a / c_a fails
@test (@inferred d / c) isa SMatrix{3,3,elty}
@test d / c ≈ d_a / c_a
@test (@inferred Symmetric(d) / c) isa SMatrix{3,3,elty}
@test Symmetric(d) / c ≈ Symmetric(d_a) / c_a
end
@test (@inferred d / c) isa SMatrix{3,3,elty}
@test d / c ≈ d_a / c_a
@test (@inferred Symmetric(d) / c) isa SMatrix{3,3,elty}
@test Symmetric(d) / c ≈ Symmetric(d_a) / c_a

v_a = randn(elty, 3)
v = SVector{3}(v_a)
Expand Down
6 changes: 1 addition & 5 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
@testset "Type parameter errors" begin
# (not sure what type of exception these should be?)
@test_throws Exception SVector{1.0,Int}((1,))
@static if VERSION < v"1.6-"
@test_throws DimensionMismatch("No precise constructor for SArray{Tuple{2},$Int,1,2} found. Length of input was 1.") SVector{2,Int}((1,))
else
@test_throws DimensionMismatch("No precise constructor for SVector{2, $Int} found. Length of input was 1.") SVector{2,Int}((1,))
end
@test_throws DimensionMismatch("No precise constructor for SVector{2, $Int} found. Length of input was 1.") SVector{2,Int}((1,))
@test_throws Exception SVector{1,3}((1,))

@test_throws Exception SMatrix{1.0,1,Int,1}((1,))
Expand Down
8 changes: 4 additions & 4 deletions test/eigen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ using StaticArrays, Test, LinearAlgebra
m2_a = randn(2,2)
m2_a = m2_a*m2_a'
m2 = SMatrix{2,2}(m2_a)
@test (@inferred_maybe_allow SVector{2,ComplexF64} eigvals(m1, m2)) ≈ eigvals(m1_a, m2_a)
@test (@inferred_maybe_allow SVector{2,ComplexF64} eigvals(Symmetric(m1), Symmetric(m2))) ≈ eigvals(Symmetric(m1_a), Symmetric(m2_a))
@test (@inferred SVector{2,ComplexF64} eigvals(m1, m2)) ≈ eigvals(m1_a, m2_a)
@test (@inferred SVector{2,ComplexF64} eigvals(Symmetric(m1), Symmetric(m2))) ≈ eigvals(Symmetric(m1_a), Symmetric(m2_a))
end

@test_throws DimensionMismatch eigvals(SA[1 2 3; 4 5 6], SA[1 2 3; 4 5 5])
Expand Down Expand Up @@ -131,7 +131,7 @@ using StaticArrays, Test, LinearAlgebra
m2_a = randn(3,3)
m2_a = m2_a*m2_a'
m2 = SMatrix{3,3}(m2_a)
@test (@inferred_maybe_allow SVector{3,ComplexF64} eigvals(m1, m2)) ≈ eigvals(m1_a, m2_a)
@test (@inferred SVector{3,ComplexF64} eigvals(m1, m2)) ≈ eigvals(m1_a, m2_a)
end

@testset "3×3 complex" begin
Expand Down Expand Up @@ -265,7 +265,7 @@ using StaticArrays, Test, LinearAlgebra

# Test that general eigen() gives a small union of concrete types
SEigen{T} = Eigen{T, T, SArray{Tuple{n,n},T,2,n*n}, SArray{Tuple{n},T,1,n}}
@inferred_maybe_allow Union{SEigen{ComplexF64},SEigen{Float64}} eigen(m)
@inferred Union{SEigen{ComplexF64},SEigen{Float64}} eigen(m)

mc = @SMatrix randn(ComplexF64, n, n)
@inferred eigen(Hermitian(mc + mc'))
Expand Down
Loading