-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scalar contract bug and other bug fixes and debugging tools (#547)
* Bump NDTensors to v0.1.21 and ITensors to v0.1.32. * Add regression test for scalar contract bug with mixed element types. * Add `@debug_check` macro, turn on and off with `enable_debug_checks()` and `disable_debug_checks()`. * Add `index_id_rng()`, an RNG specifically for generating Index IDs. * Add check for arrow directions in QN IndexSet contraction.
- Loading branch information
Showing
20 changed files
with
309 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
# XXX: rename use_debug_checks | ||
use_debug_checks() = false | ||
|
||
macro debug_check(ex) | ||
quote | ||
if use_debug_checks() | ||
$(esc(ex)) | ||
end | ||
end | ||
end | ||
|
||
function enable_debug_checks() | ||
if !getfield(@__MODULE__, :use_debug_checks)() | ||
Core.eval(@__MODULE__, :(use_debug_checks() = true)) | ||
end | ||
end | ||
|
||
function disable_debug_checks() | ||
if getfield(@__MODULE__, :use_debug_checks)() | ||
Core.eval(@__MODULE__, :(use_debug_checks() = false)) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ export | |
# Deprecated | ||
addblock!, | ||
|
||
# ITensors.jl | ||
index_id_rng, | ||
|
||
# argsdict/argsdict.jl | ||
argsdict, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using ITensors | ||
using Test | ||
|
||
@testset "Test debug checks on IndexSet construction" begin | ||
i = Index(2, "i") | ||
|
||
@test !ITensors.use_debug_checks() | ||
# Test that no error is thrown in constructor | ||
@test IndexSet(i, i) isa IndexSet{2} | ||
@test IndexSet(i, i') isa IndexSet{2} | ||
|
||
# Turn on debug checks | ||
ITensors.enable_debug_checks() | ||
@test ITensors.use_debug_checks() | ||
@test_throws ErrorException IndexSet(i, i) | ||
# Test that no error is thrown in constructor | ||
@test IndexSet(i, i') isa IndexSet{2} | ||
|
||
# Turn off debug checks | ||
ITensors.disable_debug_checks() | ||
@test !ITensors.use_debug_checks() | ||
# Test that no error is thrown in constructor | ||
@test IndexSet(i, i) isa IndexSet{2} | ||
@test IndexSet(i, i') isa IndexSet{2} | ||
end | ||
|
Oops, something went wrong.
68a55ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
68a55ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/26828
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: