Skip to content

Commit 0660226

Browse files
remove back compats
1 parent 78f4ca1 commit 0660226

File tree

2 files changed

+56
-157
lines changed

2 files changed

+56
-157
lines changed

.github/workflows/Downstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
julia-version: [1,1.6]
17+
julia-version: [1]
1818
os: [ubuntu-latest]
1919
package:
2020
- {user: JuliaDiff, repo: SparseDiffTools.jl, group: Core}

src/ArrayInterface.jl

Lines changed: 55 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,8 @@ julia> ArrayInterface.map_tuple_type(sqrt, Tuple{1,4,16})
4040
```
4141
"""
4242
function map_tuple_type end
43-
if VERSION >= v"1.8"
44-
@inline function map_tuple_type(f, @nospecialize(T::Type))
45-
ntuple(i -> f(fieldtype(T, i)), Val{fieldcount(T)}())
46-
end
47-
else
48-
function map_tuple_type(f::F, ::Type{T}) where {F, T <: Tuple}
49-
if @generated
50-
t = Expr(:tuple)
51-
for i in 1:fieldcount(T)
52-
push!(t.args, :(f($(fieldtype(T, i)))))
53-
end
54-
Expr(:block, Expr(:meta, :inline), t)
55-
else
56-
Tuple(f(fieldtype(T, i)) for i in 1:fieldcount(T))
57-
end
58-
end
43+
@inline function map_tuple_type(f, @nospecialize(T::Type))
44+
ntuple(i -> f(fieldtype(T, i)), Val{fieldcount(T)}())
5945
end
6046

6147
"""
@@ -78,50 +64,22 @@ julia> ArrayInterface.flatten_tuples((1, (2, (3,))))
7864
```
7965
"""
8066
function flatten_tuples end
81-
if VERSION >= v"1.8"
82-
function flatten_tuples(t::Tuple)
83-
fields = _new_field_positions(t)
84-
ntuple(Val{nfields(fields)}()) do k
85-
i, j = getfield(fields, k)
86-
i = length(t) - i
87-
@inbounds j === 0 ? getfield(t, i) : getfield(getfield(t, i), j)
88-
end
89-
end
90-
_new_field_positions(::Tuple{}) = ()
91-
@nospecialize
92-
function _new_field_positions(x::Tuple)
93-
(_fl1(x, x[1])..., _new_field_positions(Base.tail(x))...)
94-
end
95-
_fl1(x::Tuple, x1::Tuple) = ntuple(Base.Fix1(tuple, length(x) - 1), Val(length(x1)))
96-
_fl1(x::Tuple, x1) = ((length(x) - 1, 0),)
97-
@specialize
98-
else
99-
@inline function flatten_tuples(t::Tuple)
100-
if @generated
101-
texpr = Expr(:tuple)
102-
for i in 1:fieldcount(t)
103-
p = fieldtype(t, i)
104-
if p <: Tuple
105-
for j in 1:fieldcount(p)
106-
push!(texpr.args, :(@inbounds(getfield(getfield(t, $i), $j))))
107-
end
108-
else
109-
push!(texpr.args, :(@inbounds(getfield(t, $i))))
110-
end
111-
end
112-
Expr(:block, Expr(:meta, :inline), texpr)
113-
else
114-
_flatten(t)
115-
end
116-
end
117-
_flatten(::Tuple{}) = ()
118-
@inline function _flatten(t::Tuple{Any, Vararg{Any}})
119-
(getfield(t, 1), _flatten(Base.tail(t))...)
120-
end
121-
@inline function _flatten(t::Tuple{Tuple, Vararg{Any}})
122-
(getfield(t, 1)..., _flatten(Base.tail(t))...)
67+
function flatten_tuples(t::Tuple)
68+
fields = _new_field_positions(t)
69+
ntuple(Val{nfields(fields)}()) do k
70+
i, j = getfield(fields, k)
71+
i = length(t) - i
72+
@inbounds j === 0 ? getfield(t, i) : getfield(getfield(t, i), j)
12373
end
12474
end
75+
_new_field_positions(::Tuple{}) = ()
76+
@nospecialize
77+
function _new_field_positions(x::Tuple)
78+
(_fl1(x, x[1])..., _new_field_positions(Base.tail(x))...)
79+
end
80+
_fl1(x::Tuple, x1::Tuple) = ntuple(Base.Fix1(tuple, length(x) - 1), Val(length(x1)))
81+
_fl1(x::Tuple, x1) = ((length(x) - 1, 0),)
82+
@specialize
12583

12684
"""
12785
parent_type(::Type{T}) -> Type
@@ -299,11 +257,7 @@ ismutable(::Type{BigFloat}) = false
299257
ismutable(::Type{BigInt}) = false
300258
function ismutable(::Type{T}) where {T}
301259
if parent_type(T) <: T
302-
@static if VERSION v"1.7.0-DEV.1208"
303-
return Base.ismutabletype(T)
304-
else
305-
return T.mutable
306-
end
260+
return Base.ismutabletype(T)
307261
else
308262
return ismutable(parent_type(T))
309263
end
@@ -440,32 +394,17 @@ matrix_colors(A::Bidiagonal) = _cycle(1:2, Base.size(A, 2))
440394
matrix_colors(A::Union{Tridiagonal, SymTridiagonal}) = _cycle(1:3, Base.size(A, 2))
441395
_cycle(repetend, len) = repeat(repetend, div(len, length(repetend)) + 1)[1:len]
442396

443-
@static if VERSION > v"1.9-"
444-
"""
445-
bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
397+
"""
398+
bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
446399
447-
Returns an instance of the Bunch-Kaufman factorization object with the correct type
448-
cheaply.
449-
"""
450-
function bunchkaufman_instance(A::Matrix{T}) where T
451-
return bunchkaufman(similar(A, 0, 0), check = false)
452-
end
453-
function bunchkaufman_instance(A::SparseMatrixCSC)
454-
bunchkaufman(sparse(similar(A, 1, 1)), check = false)
455-
end
456-
else
457-
"""
458-
bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
459-
460-
Returns an instance of the Bunch-Kaufman factorization object with the correct type
461-
cheaply.
462-
"""
463-
function bunchkaufman_instance(A::Matrix{T}) where T
464-
return bunchkaufman(similar(A, 0, 0))
465-
end
466-
function bunchkaufman_instance(A::SparseMatrixCSC)
467-
bunchkaufman(sparse(similar(A, 1, 1)))
468-
end
400+
Returns an instance of the Bunch-Kaufman factorization object with the correct type
401+
cheaply.
402+
"""
403+
function bunchkaufman_instance(A::Matrix{T}) where T
404+
return bunchkaufman(similar(A, 0, 0), check = false)
405+
end
406+
function bunchkaufman_instance(A::SparseMatrixCSC)
407+
bunchkaufman(sparse(similar(A, 1, 1)), check = false)
469408
end
470409

471410
"""
@@ -482,32 +421,16 @@ Returns the number.
482421
"""
483422
bunchkaufman_instance(a::Any) = bunchkaufman(a, check = false)
484423

485-
@static if VERSION < v"1.8beta"
486-
const DEFAULT_CHOLESKY_PIVOT = Val(false)
487-
else
488-
const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra.NoPivot()
489-
end
424+
const DEFAULT_CHOLESKY_PIVOT = Val(false)
490425

491-
@static if VERSION > v"1.9-"
492-
"""
493-
cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
426+
"""
427+
cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
494428
495-
Returns an instance of the Cholesky factorization object with the correct type
496-
cheaply.
497-
"""
498-
function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
499-
return cholesky(similar(A, 0, 0), pivot, check = false)
500-
end
501-
else
502-
"""
503-
cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
504-
505-
Returns an instance of the Cholesky factorization object with the correct type
506-
cheaply.
507-
"""
508-
function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
509-
return cholesky(similar(A, 0, 0), pivot)
510-
end
429+
Returns an instance of the Cholesky factorization object with the correct type
430+
cheaply.
431+
"""
432+
function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
433+
return cholesky(similar(A, 0, 0), pivot, check = false)
511434
end
512435

513436
function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT)
@@ -521,23 +444,13 @@ Returns the number.
521444
"""
522445
cholesky_instance(a::Number, pivot = DEFAULT_CHOLESKY_PIVOT) = a
523446

524-
@static if VERSION > v"1.9-"
525-
"""
526-
cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
527-
528-
Slow fallback which gets the instance via factorization. Should get
529-
specialized for new matrix types.
530-
"""
531-
cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot, check = false)
532-
else
533-
"""
534-
cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
535-
536-
Slow fallback which gets the instance via factorization. Should get
537-
specialized for new matrix types.
538-
"""
539-
cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot)
540-
end
447+
"""
448+
cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
449+
450+
Slow fallback which gets the instance via factorization. Should get
451+
specialized for new matrix types.
452+
"""
453+
cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot, check = false)
541454

542455
"""
543456
ldlt_instance(A) -> ldlt_factorization_instance
@@ -586,18 +499,14 @@ function lu_instance(A::Matrix{T}) where {T}
586499
return LU{luT}(similar(A, 0, 0), ipiv, info)
587500
end
588501
function lu_instance(jac_prototype::SparseMatrixCSC)
589-
@static if VERSION < v"1.9.0-DEV.1622"
590-
SuiteSparse.UMFPACK.UmfpackLU(Ptr{Cvoid}(),
591-
Ptr{Cvoid}(),
592-
1,
593-
1,
594-
jac_prototype.colptr[1:1],
595-
jac_prototype.rowval[1:1],
596-
jac_prototype.nzval[1:1],
597-
0)
598-
else
599-
SuiteSparse.UMFPACK.UmfpackLU(similar(jac_prototype, 1, 1))
600-
end
502+
SuiteSparse.UMFPACK.UmfpackLU(Ptr{Cvoid}(),
503+
Ptr{Cvoid}(),
504+
1,
505+
1,
506+
jac_prototype.colptr[1:1],
507+
jac_prototype.rowval[1:1],
508+
jac_prototype.nzval[1:1],
509+
0)
601510
end
602511

603512
function lu_instance(A::Symmetric{T}) where {T}
@@ -629,23 +538,13 @@ Returns the number.
629538
"""
630539
lu_instance(a::Number) = a
631540

632-
@static if VERSION > v"1.9-"
633-
"""
634-
lu_instance(a::Any) -> lu(a, check=false)
635-
636-
Slow fallback which gets the instance via factorization. Should get
637-
specialized for new matrix types.
638-
"""
639-
lu_instance(a::Any) = lu(a, check = false)
640-
else
641-
"""
541+
"""
642542
lu_instance(a::Any) -> lu(a, check=false)
643543
644-
Slow fallback which gets the instance via factorization. Should get
645-
specialized for new matrix types.
646-
"""
647-
lu_instance(a::Any) = lu(a)
648-
end
544+
Slow fallback which gets the instance via factorization. Should get
545+
specialized for new matrix types.
546+
"""
547+
lu_instance(a::Any) = lu(a, check = false)
649548

650549
"""
651550
qr_instance(A, pivot = NoPivot()) -> qr_factorization_instance

0 commit comments

Comments
 (0)