Skip to content

Conversation

@simone-silvestri
Copy link

This PR is trying to solve #370. This is just an initial proposal, but I guess there is a lot of work to do still.
I have noticed that

julia> BigInt(1) !== BigInt(1)
true

so I had to manually change some tests when the offsets are BigInts

Any suggestion or comment is more than welcome as I am not very sure about downstream implications of this PR

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.58%. Comparing base (f9fd311) to head (ed6b86f).

Files with missing lines Patch % Lines
src/OffsetArrays.jl 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #371      +/-   ##
==========================================
- Coverage   96.57%   95.58%   -0.99%     
==========================================
  Files           6        6              
  Lines         467      476       +9     
==========================================
+ Hits          451      455       +4     
- Misses         16       21       +5     

☔ 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.

Copy link

@giordano giordano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer the decision about adding a new type parameter to the maintainers of the package

@static if isdefined(Adapt, :parent_type)
# To support Adapt 3.0 which doesn't have parent_type defined
Adapt.parent_type(::Type{OffsetArray{T,N,AA,I}}) where {T,N,AA,I} = AA
Adapt.parent_type(::Type{OffsetArray{T,N,AA}}) where {T,N,AA} = AA

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is probably redundant at this point

Suggested change
Adapt.parent_type(::Type{OffsetArray{T,N,AA}}) where {T,N,AA} = AA


Base.IndexStyle(::Type{OA}) where {OA<:OffsetArray} = IndexStyle(parenttype(OA))
parenttype(::Type{OffsetArray{T,N,AA,I}}) where {T,N,AA,I} = AA
parenttype(::Type{OffsetArray{T,N,AA}}) where {T,N,AA} = AA

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this method is redundant

Suggested change
parenttype(::Type{OffsetArray{T,N,AA}}) where {T,N,AA} = AA


Base.strides(A::OffsetArray) = strides(parent(A))
Base.elsize(::Type{OffsetArray{T,N,A,I}}) where {T,N,A,I} = Base.elsize(A)
Base.elsize(::Type{OffsetArray{T,N,A}}) where {T,N,A} = Base.elsize(A)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other redundant method

Suggested change
Base.elsize(::Type{OffsetArray{T,N,A}}) where {T,N,A} = Base.elsize(A)

# something similar also holds for OffsetUnitRange{BigInt}
# We may replace the former with the latter in an indexing operation to obtain a performance boost
@inline function Base.to_index(r::OffsetUnitRange{<:Union{Int,BigInt}})
@inline function Base.to_index(r::OffsetUnitRange{<:Union{Integer,BigInt}})
Copy link

@giordano giordano Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BigInt <: Integer

Suggested change
@inline function Base.to_index(r::OffsetUnitRange{<:Union{Integer,BigInt}})
@inline function Base.to_index(r::OffsetUnitRange{<:Integer})

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