Skip to content

Commit

Permalink
Move NDTensorsMappedArraysExt test to ITensors testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Oct 24, 2024
1 parent c22256c commit 2655cd5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
OptimKit = "77e91f04-9b3b-57a6-a776-40b61faaebe0"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Expand Down
5 changes: 5 additions & 0 deletions test/ext/NDTensorsMappedArraysExt/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
24 changes: 24 additions & 0 deletions test/ext/NDTensorsMappedArraysExt/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@eval module $(gensym())
using ITensors: Index, itensor
using LinearAlgebra: qr, svd
using MappedArrays: mappedarray
using Test: @test, @testset
f(i::Int...) = float(sum(iⱼ -> iⱼ^2, i))
f(i::CartesianIndex) = f(Tuple(i)...)
@testset "NDTensorsMappedArraysExt" begin
a = mappedarray(f, CartesianIndices((2, 2)))
b = copy(a)
i, j = Index.((2, 2))
ta = itensor(a, i, j)
tb = itensor(b, i, j)
@test ta tb
@test ta[i => 1, j => 2] tb[i => 1, j => 2]
@test 2 * ta 2 * tb
@test ta + ta tb + tb
@test ta * ta tb * tb
ua, sa, va = svd(ta, i)
@test ua * sa * va ta
qa, ra = qr(ta, i)
@test qa * ra ta
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ITensors.disable_threaded_blocksparse()
"ext/ITensorsChainRulesCoreExt",
"ext/ITensorsPackageCompilerExt",
"ext/ITensorsVectorInterfaceExt",
"ext/NDTensorsMappedArraysExt",
]
@time for dir in dirs
println("\nTest $(@__DIR__)/$(dir)")
Expand Down

0 comments on commit 2655cd5

Please sign in to comment.