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 Base.similar for physical and contractible network types #149

Merged
merged 3 commits into from
Mar 9, 2025

Conversation

leburgel
Copy link
Member

@leburgel leburgel commented Mar 7, 2025

The (untested) current implementations of Base.similar for our different network types was broken, leading to an UndefRefError in the checks on the virtual spaces in the inner constructor because all of the unitcell entries are undef. I patched it to really map similar over the unit cell entries, which I think is more in line with what we want here (e.g. to change the storage type of the entries in similar(::TensorMap, ...) style).

For context, I encountered this when calling similar on an InfinitePEPS, where I really expected the result to have the same virtual space structure. Alternatively, it's not clear that this is the proper way of implementing Base.similar and since this was never used or tested, I could also use Base.copy and just remove the broken Base.similar implementations.

Either way, I didn't want to leave in the broken implementations.

Copy link

codecov bot commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/operators/infinitepepo.jl 0.00% 6 Missing ⚠️
src/states/infinitepartitionfunction.jl 0.00% 6 Missing ⚠️
src/networks/infinitesquarenetwork.jl 0.00% 2 Missing ⚠️
src/states/infinitepeps.jl 0.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/networks/infinitesquarenetwork.jl 51.19% <0.00%> (ø)
src/states/infinitepeps.jl 74.19% <0.00%> (-0.81%) ⬇️
src/operators/infinitepepo.jl 23.07% <0.00%> (-1.35%) ⬇️
src/states/infinitepartitionfunction.jl 20.96% <0.00%> (-1.45%) ⬇️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pbrehmer
Copy link
Collaborator

pbrehmer commented Mar 7, 2025

Thanks for taking of this. IIRC, I ran into this a long while ago and even included a comment somewhere but that might have been removed. I agree with your way of implementing Base.similar and I do see that this would be useful in practice. I'd be fine with merging as is!

@lkdvos
Copy link
Member

lkdvos commented Mar 7, 2025

I guess this is a bit strange if you ever want to use it to change the spaces, so maybe we should just explicitly not allow this?
What I mean is only defining the single argument version and the two-argument version with a different scalar type

@leburgel leburgel requested a review from lkdvos March 7, 2025 15:46
@leburgel leburgel enabled auto-merge (squash) March 9, 2025 09:40
@leburgel leburgel merged commit c6cfcd1 into master Mar 9, 2025
32 of 33 checks passed
@leburgel leburgel deleted the lb/fix_similar branch March 9, 2025 10:20
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.

3 participants