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

Redesign around IdOffsetRange #90

Merged
merged 5 commits into from
Jan 18, 2020
Merged

Redesign around IdOffsetRange #90

merged 5 commits into from
Jan 18, 2020

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.

2 participants