JuliaArrays / JuliaArrays/ArrayInterface.jl

ismutable wrong for FillArrays

Open
#77 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
140
Forks
44
Avg merge
4d 14h
Merged PRs (30d)
5

Description

FillArrays are not mutable.

julia> ArrayInterface.ismutable(typeof(Fill(4, (2,2))))
true

I think that
https://github.com/SciML/ArrayInterface.jl/blob/730592e19c5e3effb086a5cc0b61ecc1a1936a76/src/ArrayInterface.jl#L75-L81

Should be

 function ismutable(::Type{T}) where {T<:AbstractArray} 
     if parent_type(T) <: T 
         return false  # no parent, and have not hit a type we know about 
     else 
         return ismutable(parent_type(T)) 
     end 
 end

ismutable{::Type{<:Array}} = true
ismutable{::Type{<:SparseVector}} = true
ismutable{::Type{<:SparseMatrixCSC}} = true
ismutable{::Type{<:BitArray}} = true

Alternatively
the fallback case could be: return T.mutable rather than false.
On the assumption that if you are a mutable struct that has subtypes AbstractArray you probably have defined setindex

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read src/ArrayInterface.jl lines 75-81 and reproduce the FillArrays example showing ArrayInterface.ismutable(typeof(Fill(4, (2,2)))) returning true. Compare the proposed parent-type recursion and T.mutable fallback, then verify that FillArrays are classified as immutable while the listed mutable array types remain true.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.