Skip to content

Preserve block information in more slicing operations #459

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 5 commits into
base: master
Choose a base branch
from

Conversation

mtfishman
Copy link
Collaborator

@mtfishman mtfishman commented Apr 26, 2025

This introduces a generalization of BlockSlice for views involving vectors of Block and BlockIndexRange, building off of #445.

I call it BlockedSlice but I'm open to suggestions. At first I tried to just generalize BlockSlice to be an AbstractVector subtype but some operations depend on it being an AbstractUnitRange so I think it makes sense to have both.

The motivation is that in https://github.com/ITensor/BlockSparseArrays.jl it would be helpful to preserve information about the original blocks being sliced when taking views involving vectors of Block and BlockIndexRange. #445 drops the blocks input in the slice operation, so it is hard to tell if a certain slice operation was really originally blockwise.

@dlfivefifty curious to hear your thoughts on this since you wrote #445.

Copy link

codecov bot commented Apr 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #459      +/-   ##
==========================================
+ Coverage   93.64%   93.66%   +0.02%     
==========================================
  Files          19       19              
  Lines        1667     1673       +6     
==========================================
+ Hits         1561     1567       +6     
  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.

@mtfishman
Copy link
Collaborator Author

I assume I'll have to add more methods for BlockInds, but I wanted to see what were the minimal functions needed to get tests passing and also get feedback on the design.

@mtfishman mtfishman requested a review from dlfivefifty April 28, 2025 13:54
@@ -288,6 +288,16 @@ _indices(B) = B

Block(bs::BlockSlice{<:BlockIndexRange}) = Block(bs.block)

struct BlockInds{BB,T<:Integer,INDS<:AbstractVector{T}} <: AbstractVector{T}
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a docstring so I know what this is meant to do?

Copy link
Collaborator Author

@mtfishman mtfishman Apr 28, 2025

Choose a reason for hiding this comment

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

Can do. I was holding off doing "final touches" like that to get your reaction if this is something you want in the first place (and get feedback on the name).

Copy link
Member

Choose a reason for hiding this comment

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

I can't react to something I don't understand 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Gotcha, I thought I described it in the first comment of the PR but I can add a docstring as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added a docstring along with some tests, let me know if that helps to clarify the purpose of this object. I changed the name to BlockedSlice but I'm not so happy with that and again I'm open to suggestions.

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