Skip to content

Preserve blocking of indices when slicing a unit range with a blocked unit range #465

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mtfishman
Copy link
Collaborator

Fixes #367.

Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.69%. Comparing base (4059149) to head (1f5d851).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #465      +/-   ##
==========================================
+ Coverage   93.64%   93.69%   +0.04%     
==========================================
  Files          19       19              
  Lines        1667     1680      +13     
==========================================
+ Hits         1561     1574      +13     
  Misses        106      106              

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

function getindex(r::Base.OneTo{T}, s::BlockedOneTo) where T
@inline
@boundscheck checkbounds(r, s)
return BlockedOneTo(T.(blocklasts(s)))
Copy link
Member

Choose a reason for hiding this comment

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

To avoid allocations should this be:

Suggested change
return BlockedOneTo(T.(blocklasts(s)))
return BlockedOneTo(convert(AbstractVector{T}, blocklasts(s)))

return BlockedOneTo(T.(blocklasts(s)))
end
function getindex(r::BlockedOneTo{T}, s::BlockedOneTo) where T
return Base.OneTo(r)[s]
Copy link
Member

Choose a reason for hiding this comment

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

To potentially support ∞-arrays I would do:

Suggested change
return Base.OneTo(r)[s]
return Base.oneto(r)[s]

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.

getindex(::UnitRange, ::BlockedUnitRange) isn't blocked
2 participants