Skip to content

Conversation

@jishnub
Copy link
Member

@jishnub jishnub commented Dec 7, 2025

The goal of this PR is to split the core components (the OffsetArray and IdOffsetRange-related code) to their own package. The key differentiator would be that this package commits minimal type piracy. The only instance of type piracy would be to define functions like

similar(A::AbstractArray, ::Type{T}, shape::Tuple{Union{Integer, IdentityUnitRange{<:IdOffsetRange{T, I} where I<:AbstractUnitRange{T}}, Base.OneTo, IdOffsetRange{T, I} where I<:AbstractUnitRange{T}} where T<:Integer, Vararg{Union{Integer, IdentityUnitRange{<:IdOffsetRange{T, I} where I<:AbstractUnitRange{T}}, Base.OneTo, IdOffsetRange{T, I} where I<:AbstractUnitRange{T}} where T<:Integer}}) where T

While technically type piracy, a narrower method that accepts a Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}} exists in Base, so the only types that would dispatch to the new method added in this package are the ones that involve a IdOffsetRange. One key difference here is that we don't define these methods for generic IdentityUnitRanges anymore.

Importantly, no user-defined axis types would dispatch to this similar method. This makes it possible for packages to transitively depend on OffsetArraysCore without it impacting their code in any way. This would help with issues like #87 and #369.

Eventually, OffsetArrays may become a wrapper over OffsetArraysCore and carry out the major type piracies that improve the end-user experience but aren't necessary for package development.

Most of the code in this PR is copied over with minimal changes to get it working. The primary changes are to the similar and reshape methods to remove the piracy there.

@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.57%. Comparing base (bf83779) to head (f6b691d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #385   +/-   ##
=======================================
  Coverage   96.57%   96.57%           
=======================================
  Files           6        6           
  Lines         467      467           
=======================================
  Hits          451      451           
  Misses         16       16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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