Skip to content

Conversation

@timholy
Copy link
Member

@timholy timholy commented Dec 15, 2019

This is breaking and might be a good excuse to go to 1.0. Fixes the observation in #65 (comment) even for other array types that offset their axes (see this test).

The motivation is discussed in more detail in https://discourse.julialang.org/t/why-is-there-a-performance-hit-on-broadcasting-with-offsetarrays/32194. There's something pretty satisfying, though, about offsetting the axes by a "lazy" mechanism

struct IdOffsetRange{T<:Integer,I<:AbstractUnitRange{T}} <: AbstractUnitRange{T}
parent::I
offset::T
end

@inline Base.first(r::IdOffsetRange) = first(r.parent) + r.offset
@inline Base.last(r::IdOffsetRange) = last(r.parent) + r.offset

because it makes it more possible to preserve any custom behavior of the parent array's axes.

CC @mbauman

@timholy
Copy link
Member Author

timholy commented Dec 15, 2019

Test failure on julia-1.0 might be due to the absence of JuliaLang/julia#28941? We could either add a bound on the Julia version or figure out a workaround.

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

Successfully merging this pull request may close these issues.

3 participants