Skip to content
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

Compatibility with OffsetArrays #178

Open
rs1909 opened this issue Nov 23, 2022 · 2 comments
Open

Compatibility with OffsetArrays #178

rs1909 opened this issue Nov 23, 2022 · 2 comments

Comments

@rs1909
Copy link

rs1909 commented Nov 23, 2022

I can put OffsetArrays into a ComponentArray, but the offsets are not preserved:

using ComponentArrays, OffsetArrays
B = OffsetArray(randn(6,6), 0:5, 0:5)
C = OffsetArray(randn(6,6), 0:5, 0:5)
V = ComponentArray(b=B, c=C)

B[0,0] # works
V.b[0,0] # ERROR: BoundsError:
@jonniedie
Copy link
Owner

Unfortunately this one is kinda on OffsetArrays for not returning an OffsetArray when indexing.

julia> oa = OffsetArray([1, 2, 3, 4], -1)
4-element OffsetArray(::Vector{Int64}, 0:3) with eltype Int64 with indices 0:3:
 1
 2
 3
 4

julia> b = oa[0:2]
3-element Vector{Int64}:
 1
 2
 3

julia> b[0]
ERROR: BoundsError: attempt to access 3-element Vector{Int64} at index [0]
Stacktrace:
 [1] getindex(A::Vector{Int64}, i1::Int64)
   @ Base ./array.jl:924
 [2] top-level scope
   @ REPL[15]:1

There's nothing we could really do other than make OffsetArrays a dependency and maintain methods specifically for it.

@CarloLucibello
Copy link

CarloLucibello commented Apr 2, 2023

An OffsetArrays extension would be nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants