-
Notifications
You must be signed in to change notification settings - Fork 21
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 2d heisenberg example and add error for bad unit cell inputs #88
Conversation
I'm unable to replicate the errors from the CI at the moment (on 1.10.4), all tests pass locally for me |
It looks like it may be specific to Julia 1.11, it was just released and the CI started testing against that automatically. |
Here is a minimal code that reproduces the test failure in Julia 1.11: using ITensors: ITensor, Index
i = Index(2)
a = reshape([ITensor(), ITensor(i)], 1, 2)
b = reshape([ITensor(2.0), ITensor(2.0, i)], 2, 1)
a * b which leads to an error: ERROR: StackOverflowError:
Stacktrace:
[1] promote_result(::Type, ::Type, ::Type{NDTensors.EmptyNumber}, ::Type{Bool})
@ Base ./promotion.jl:338
[2] promote_type
@ ./promotion.jl:318 [inlined]--- the above 2 lines are repeated 79982 more times --- so it is related to performing matrix multiplication of matrices of ITensors where some of the ITensors are not initialized. |
It looks like there were a few missing using NDTensors: EmptyNumber
Base.promote_rule(::Type{T}, ::Type{EmptyNumber}) where {T<:Number} = T
Base.promote_rule(::Type{Bool}, ::Type{EmptyNumber}) = Bool seems to fix the issue. I'll make a PR to |
Here are more minimal examples that error with stack overflows without those new definitions: promote_type(Bool, EmptyNumber)
promote_type(EmptyNumber, Bool) |
Thanks @mtfishman ! I can check things in InfiniteMPS once that's sorted (there looks like some deprecated |
ITensor/ITensors.jl#1541 is now merged, that should fix the test failures in Julia 1.11. |
Looks good, thanks Ryan! I'll merge once tests pass. |
As reported in https://itensor.discourse.group/t/vumps-example-2d-heisenberg-model-interaction-term/2052?u=ryanlevy
The 2D heisenberg example misses some operators, which is fixed in this version. I've also included a warning to help users catch this in the future, happy to take suggestions on alternative "fixes"