Skip to content

Commit

Permalink
remove version < 1.6 checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Mar 2, 2022
1 parent addc367 commit 2cd6f89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/projection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ end

# Triangular
for UL in (:UpperTriangular, :LowerTriangular, :UpperHessenberg)
VERSION < v"1.4" && UL == :UpperHessenberg && continue # not defined in 1.0
@eval begin
ProjectTo(x::$UL) = ProjectTo{$UL}(; data=ProjectTo(parent(x)))
(project::ProjectTo{$UL})(dx::AbstractArray) = $UL(project.data(dx))
Expand All @@ -499,10 +498,10 @@ end
# Subspaces which aren't subtypes, like Diagonal inside Symmetric above:
(project::ProjectTo{UpperTriangular})(dx::Diagonal) = project.data(dx)
(project::ProjectTo{LowerTriangular})(dx::Diagonal) = project.data(dx)
if VERSION >= v"1.4"
(project::ProjectTo{UpperHessenberg})(dx::Diagonal) = project.data(dx)
(project::ProjectTo{UpperHessenberg})(dx::UpperTriangular) = project.data(dx)
end

(project::ProjectTo{UpperHessenberg})(dx::Diagonal) = project.data(dx)
(project::ProjectTo{UpperHessenberg})(dx::UpperTriangular) = project.data(dx)

(project::ProjectTo{UnitUpperTriangular})(dx::Diagonal) = NoTangent()
(project::ProjectTo{UnitLowerTriangular})(dx::Diagonal) = NoTangent()

Expand Down
10 changes: 4 additions & 6 deletions test/projection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,9 @@ struct NoSuperType end
@test pupp(rand(ComplexF32, 3, 3, 1)) isa UpperTriangular{Float64}
@test ProjectTo(UpperTriangular(randn(3, 3) .> 0))(randn(3, 3)) == NoTangent()

if VERSION >= v"1.4" # not sure 1.4 exactly!
phess = ProjectTo(UpperHessenberg(rand(3, 3)))
@test phess(reshape(1:9,3,3)) == [1 4 7; 2 5 8; 0 6 9]
@test phess(reshape(1:9,3,3) .+ im) isa UpperHessenberg{Float64}
end
phess = ProjectTo(UpperHessenberg(rand(3, 3)))
@test phess(reshape(1:9,3,3)) == [1 4 7; 2 5 8; 0 6 9]
@test phess(reshape(1:9,3,3) .+ im) isa UpperHessenberg{Float64}

pdu = ProjectTo(UnitLowerTriangular(rand(3, 3)))
# NB, since the diagonal is constant 1, its gradient is zero:
Expand Down Expand Up @@ -494,7 +492,7 @@ struct NoSuperType end
@test eval(Meta.parse(str))(ones(1, 3)) isa Adjoint{Float64,Vector{Float64}}
end

VERSION > v"1.1" && @testset "allocation tests" begin
@testset "allocation tests" begin
# For sure these fail on Julia 1.0, not sure about 1.3 etc.
# We only really care about current stable anyway
# Each "@test 33 > ..." is zero on nightly, 32 on 1.5.
Expand Down

0 comments on commit 2cd6f89

Please sign in to comment.