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

Fix nested broadcast of AbstractBlockTuple #14

Merged
merged 4 commits into from
Jan 14, 2025

Conversation

ogauthe
Copy link
Contributor

@ogauthe ogauthe commented Jan 14, 2025

This PR allows for nested broadcast on a BlockedTuple (e.g blocklengths.(dual.(axes))).

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 28.57143% with 5 lines in your changes missing coverage. Please review.

Project coverage is 91.18%. Comparing base (b876749) to head (92edeaa).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/blockedtuple.jl 28.57% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #14      +/-   ##
==========================================
- Coverage   92.54%   91.18%   -1.37%     
==========================================
  Files          16       16              
  Lines         322      329       +7     
==========================================
+ Hits          298      300       +2     
- Misses         24       29       +5     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@mtfishman
Copy link
Member

Looks like there is a missing getindex overload in Julia 1.10.

Interestingly, Tuple broadcasting works without having ndims(::Tuple) defined. If this is the easiest route to getting it working, I'm ok with defining ndims for now, though we should treat it as an "internal" definition only used by broadcasting.

@ogauthe
Copy link
Contributor Author

ogauthe commented Jan 14, 2025

I am puzzled by the test failure on Julia 1.10. As for ndims, I followed the compiler advice, it is not clear to me why it is needed. I am not planning to define it for the object itself.

@mtfishman
Copy link
Member

I am puzzled by the test failure on Julia 1.10. As for ndims, I followed the compiler advice, it is not clear to me why it is needed. I am not planning to define it for the object itself.

I think what's happening is that in Julia 1.10 broadcasting made use of indexing with CartesianIndex. For AbstractArray subtypes, CartesianIndex indexing gets forwarded to indexing with integers, but that isn't the case right now for AbstractBlockTuple. You could try defining:

Base.getindex(bt::AbstractBlockTuple, i::CartesinaIndex{1}) = bt[Tuple(i)...]

and see if that fixes things.

@mtfishman mtfishman changed the title allow nested broadcast Fix nested broadcast of AbstractBlockTuple Jan 14, 2025
@mtfishman mtfishman merged commit 5323bc4 into ITensor:main Jan 14, 2025
9 of 11 checks passed
@ogauthe ogauthe deleted the nested_broadcast branch January 14, 2025 22:41
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