Skip to content

Commit

Permalink
Update src/rulesets/Base/indexing.jl
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
devmotion and github-actions[bot] authored Feb 8, 2024
1 parent 348fb86 commit 9ce63a5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/rulesets/Base/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ This returns roughly `dx = zero(x)`, except that this is guaranteed to be mutabl
and its element type is wide enough to allow `setindex!(dx, dy, inds...)`, which is exactly what
`∇getindex` does next.
"""
_setindex_zero(x::AbstractArray{<:Number}, dy, inds::Integer...) = fill!(similar(x, typeof(dy)), false)
_setindex_zero(x::AbstractArray{<:Number}, dy, inds...) = fill!(similar(x, eltype(dy)), false)
_setindex_zero(x::AbstractArray{<:Number}, dy, inds::Integer...) =
fill!(similar(x, typeof(dy)), false)
function _setindex_zero(x::AbstractArray{<:Number}, dy, inds...)
return fill!(similar(x, eltype(dy)), false)
end
function _setindex_zero(x::AbstractArray, dy, inds::Integer...)
# This allows for types which don't define zero (like Vector) and types whose zero special (like Tangent),
# but always makes an abstract type. TODO: make it infer concrete type for e.g. vectors of SVectors
Expand Down

0 comments on commit 9ce63a5

Please sign in to comment.