Skip to content

Commit 2ad12d1

Browse files
committed
remove type piracy
1 parent b97d552 commit 2ad12d1

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/FillArrays.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ for (Typ, funcs, func) in ((:Zeros, :zeros, :zero), (:Ones, :ones, :one))
461461
end
462462

463463
# temporary patch. should be a PR(#48895) to LinearAlgebra
464-
Diagonal{T}(A::AbstractMatrix) where T = Diagonal{T}(diag(A))
465-
function convert(::Type{T}, A::AbstractMatrix) where T<:Diagonal
464+
Diagonal{T}(A::AbstractFillMatrix) where T = Diagonal{T}(diag(A))
465+
function convert(::Type{T}, A::AbstractFillMatrix) where T<:Diagonal
466466
checksquare(A)
467467
isdiag(A) ? T(A) : throw(InexactError(:convert, T, A))
468468
end

src/fillalgebra.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,12 @@ end
253253
function +(a::ZerosVector{T}, b::AbstractRange) where {T}
254254
size(a) size(b) && throw(DimensionMismatch("dimensions must match."))
255255
Tout = promote_type(T, eltype(b))
256-
return AbstractRange{Tout}(b)
256+
return T(first(b)):T(step(b)):T(last(b))
257257
end
258-
function +(a::ZerosVector{T}, b::UnitRange) where {T}
258+
function +(a::ZerosVector{T}, b::UnitRange) where {T<:Integer}
259259
size(a) size(b) && throw(DimensionMismatch("dimensions must match."))
260260
Tout = promote_type(T, eltype(b))
261-
return AbstractRange{Tout}(b)
261+
return AbstractUnitRange{T}(b)
262262
end
263263

264264
function -(a::ZerosVector, b::AbstractRange)
@@ -267,10 +267,6 @@ function -(a::ZerosVector, b::AbstractRange)
267267
end
268268
-(a::AbstractRange, b::ZerosVector) = a + b
269269

270-
# temporary patch. should be a PR(#48894) to julia base.
271-
AbstractRange{T}(r::AbstractUnitRange) where {T<:Integer} = AbstractUnitRange{T}(r)
272-
AbstractRange{T}(r::AbstractRange) where T = T(first(r)):T(step(r)):T(last(r))
273-
274270
####
275271
# norm
276272
####

0 commit comments

Comments
 (0)