-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename or outsource iswriteable
#99
Comments
The near-collision is unfortunate, we should at least re-name it. The goal was to do the dead-simple minimal thing, erring on the side of safety (i.e. not writing unelss quite sure), and revisit when someone had a compelling case to do otherwise. At least we depend on ChainRulesCore; I'm very reluctant to entangle this little package with the huge ArrayInterface. ChainRulesCore has more description of what its rules are, ArrayInterface doesn't try to explain: julia> using ChainRulesCore, ArrayInterface, StaticArrays, ReadOnlyArrays, FillArrays
## CRC
julia> ChainRulesCore.is_inplaceable_destination(transpose(1:3)) # ok!
false
julia> ChainRulesCore.is_inplaceable_destination(Diagonal([1,2,3])) # but you can only write some places, "an appropriate tangent"
true
julia> ChainRulesCore.is_inplaceable_destination(SA[1,2,3]) # ok
false
julia> ChainRulesCore.is_inplaceable_destination(ReadOnlyArray([1,2,3])) # fooled, fails the wrong way
true
## AI
julia> ArrayInterface.ismutable(ReadOnlyArray([1,2,3])) # likewise fooled
true
julia> ArrayInterface.ismutable(SA[1,2,3]) # isn't there literally a package registered to handle this?
true
julia> ArrayInterface.ismutable(Fill(1,2,3)) # issue 77 from 2020, still broken
true |
ArrayInterface's own dependencies were gutted recently, so one needs auxiliary packages like ArrayInterfaceStaticArrays for make In an ideal world, ArrayInterface would adopt a method more like |
Also note that julia> subtypes(DenseArray)
6-element Vector{Any}:
Array
Base.CodeUnits
Base.Experimental.Const
Random.UnsafeView
SharedArrays.SharedArray
SuiteSparse.CHOLMOD.Dense It's unlikely we'll see |
Sure, these internal types seem much more obscure though. I am surprised by this failure to the wrong side. Surely the question this function is useful for is "can be sure that writing won't give an error?", so it should return CRC at least documents that it's going to trust whatever |
I'd say that's what makes having an interface so important. ReadOnlyArrays is correct in defining parent, but the issue is that |
Yes. Ideally Base would have some such notion, clearly described, which everyone would extend. I am somewhat skeptical of ArrayInterface's claims to take up this role. In part because of the complete lack of documentation about what on earth it's actually supposed to return, which side does it fail towards, what's the intended use case -- here's all you get:
The link doesn't help much, and "mutable" of course already has a meaning:
Sadly ChainRulesCore is also not immune to bloat. |
I very much agree. My thought was that ArrayInterfaceCore still seems to be the most promising host package for mostly non-technical reasons (i.e. chance of adoption). |
I think I overheard somewhere that this one is supposed to be about whether scalar
It seems sad that indeed this thing appears to be spreading, as you say for non-technical reasons. ps. There was apparently a breaking release made over which way |
Through a typo, I found that Base exports
iswritable
(one char difference). Were we to outsource this, possible candidates includeChainRulesCore.is_inplaceable_destination
(used byadd!!
) andArrayInterfaceCore.ismutable
.The text was updated successfully, but these errors were encountered: