-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add an abstract type signaling e.g. OffsetArray safe to use (also add badges to packages) #284
Comments
I'm unsure if I like this idea. For example, what should a |
😱 |
I'm not sure I understand the problem. For now I'm just trying to fix the immediate problem, not also fix for something not implemented yet. I see Diagonal(A::AbstractMatrix) and it can also take in AbstractVector when constructing. Either way, it seems could get you Diagonal{OffsetArray} when provided with OffsetArray (in theory, up to Base), and I don't see it contradicting my proposal.
so I think would just need the corresponding AbstractArbitraryAVector too? |
Two facts:
Outcome: The ecosystem not only blocks |
Right, most packages assume Changing them to use How many array wrappers are there? A tiny finite amount much smaller than the number of packages in total in the ecosystem. Wouldn't we just have to update them before blocking |
I think you misunderstand. To construct e.g. What you get out however can't be any abstract type. It will be either a (dense, usually) 1-based or 0-based (a wrapper for 1-based) type. I was thinking should I first meant to write above you get a dense array, then changed to "(dense, usually)", since I confirmed you can get sparse diagonal. |
struct Diagonal{...} <: AbstractArbitratyArray{...} otherwise For a multi-dimensional array, julia> using OffsetArrays
julia> xo = OffsetArray([1 2; 3 4], -1, -1)
2×2 OffsetArray(::Matrix{Int64}, 0:1, 0:1) with eltype Int64 with indices 0:1×0:1:
1 2
3 4
julia> for i in 1:length(xo)
@show xo[i]
end
xo[i] = 1
xo[i] = 3
xo[i] = 2
xo[i] = 4 |
Close this since it's not a doable approach. "This-package-supports-offset-arrays" badge also sounds unnecessary to me compared to |
@timholy, @jishnub plausibly you want a diagonal offset array, but you can't have an arbitrary-based diagonal I'm trying to think of all the potential issues, and while it's valuable to have Then there is no good solution available for Is it useful to think of such a strange edge case? I think so, since it's possible, I find it would be ugly to support @johnnychen94, Does it also inform the decision on this issue:
|
FWIW, the same discussion reraised in https://discourse.julialang.org/t/does-abstractarray-itself-need-to-support-indexing-beyond-1-based/83324 |
It seems to me my proposal for the new abstract type could work:
https://discourse.julialang.org/t/offsetarrays-inbounds-and-confusion/81295/10?u=palli
I think this new type might belong at JuliaLang, but I at least want to discuss it first. Maybe it could start in the package and me later migrated?
I do not propose, yet, making AbstractArray not work for this package. For now this would be opt-in and when enough packages have been changed to use the new abstract type we can cross that bridge.
If this works, then it should go into the "best practices" #281 proposal. Also the badges proposal (see link).
The text was updated successfully, but these errors were encountered: