Skip to content

Commit 2655cd5

Browse files
committed
Move NDTensorsMappedArraysExt test to ITensors testsuite
1 parent c22256c commit 2655cd5

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
1010
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
1111
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
1212
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
13+
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
1314
NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
1415
OptimKit = "77e91f04-9b3b-57a6-a776-40b61faaebe0"
1516
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[deps]
2+
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
3+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
4+
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
5+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@eval module $(gensym())
2+
using ITensors: Index, itensor
3+
using LinearAlgebra: qr, svd
4+
using MappedArrays: mappedarray
5+
using Test: @test, @testset
6+
f(i::Int...) = float(sum(iⱼ -> iⱼ^2, i))
7+
f(i::CartesianIndex) = f(Tuple(i)...)
8+
@testset "NDTensorsMappedArraysExt" begin
9+
a = mappedarray(f, CartesianIndices((2, 2)))
10+
b = copy(a)
11+
i, j = Index.((2, 2))
12+
ta = itensor(a, i, j)
13+
tb = itensor(b, i, j)
14+
@test ta tb
15+
@test ta[i => 1, j => 2] tb[i => 1, j => 2]
16+
@test 2 * ta 2 * tb
17+
@test ta + ta tb + tb
18+
@test ta * ta tb * tb
19+
ua, sa, va = svd(ta, i)
20+
@test ua * sa * va ta
21+
qa, ra = qr(ta, i)
22+
@test qa * ra ta
23+
end
24+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ITensors.disable_threaded_blocksparse()
2222
"ext/ITensorsChainRulesCoreExt",
2323
"ext/ITensorsPackageCompilerExt",
2424
"ext/ITensorsVectorInterfaceExt",
25+
"ext/NDTensorsMappedArraysExt",
2526
]
2627
@time for dir in dirs
2728
println("\nTest $(@__DIR__)/$(dir)")

0 commit comments

Comments
 (0)