|
1 | 1 | using Combinatorics: Combinatorics |
2 | | -using ITensorBase: @names, AbstractITensor, ITensor, LittleSet, Name, NameMismatch, |
| 2 | +using ITensorBase: @names, AbstractITensor, ITensor, Name, NameMismatch, |
3 | 3 | NamedDimsCartesianIndex, NamedDimsCartesianIndices, aligndims, aligneddims, apply, |
4 | 4 | dename, denamed, denamedtype, dim, dimnames, dimnametype, dims, fusednames, inds, |
5 | 5 | isnamed, mapinds, name, named, nameddims, namedoneto, product, replacedimnames, |
|
37 | 37 | @test inds(na) == (i, j) |
38 | 38 | @test inds(na, 1) == i |
39 | 39 | @test inds(na, 2) == j |
40 | | - @test dimnames(na) == ("i", "j") |
| 40 | + @test dimnames(na) == ["i", "j"] |
41 | 41 | @test dimnames(na, 1) == "i" |
42 | 42 | @test dimnames(na, 2) == "j" |
43 | 43 | @test dim(na, "i") == 1 |
|
108 | 108 | j = namedoneto(4, "j") |
109 | 109 | for na′ in ( |
110 | 110 | similar(na, Float32, (j, i)), |
111 | | - similar(na, Float32, LittleSet((j, i))), |
112 | 111 | similar(a, Float32, (j, i)), |
113 | | - similar(a, Float32, LittleSet((j, i))), |
114 | 112 | ) |
115 | 113 | @test eltype(na′) ≡ Float32 |
116 | 114 | @test all(inds(na′) .== (j, i)) |
|
123 | 121 | j = namedoneto(4, "j") |
124 | 122 | for na′ in ( |
125 | 123 | similar(na, (j, i)), |
126 | | - similar(na, LittleSet((j, i))), |
127 | 124 | similar(a, (j, i)), |
128 | | - similar(a, LittleSet((j, i))), |
129 | 125 | ) |
130 | 126 | @test eltype(na′) ≡ eltype(na) |
131 | 127 | @test all(inds(na′) .== (j, i)) |
|
154 | 150 | a = randn(elt, 2) |
155 | 151 | na = a[i] |
156 | 152 | @test na isa ITensor{String} |
157 | | - @test dimnames(na) == ("i",) |
| 153 | + @test dimnames(na) == ["i"] |
158 | 154 | @test denamed(na) == a |
159 | 155 |
|
160 | 156 | # slicing |
|
416 | 412 | @test !iszero(na) |
417 | 413 | end |
418 | 414 | end |
419 | | - @testset "LittleSet" begin |
420 | | - # Broadcasting |
421 | | - s = LittleSet((1, 2)) |
422 | | - @test eltype(s) == Int |
423 | | - @test s .+ [3, 4] == [4, 6] |
424 | | - @test s .+ (3, 4) ≡ (4, 6) |
425 | | - |
426 | | - s = LittleSet(("a", "b", "c")) |
427 | | - @test all(s .== ("a", "b", "c")) |
428 | | - @test values(s) == ("a", "b", "c") |
429 | | - @test Tuple(s) == ("a", "b", "c") |
430 | | - @test s[1] == "a" |
431 | | - @test s[2] == "b" |
432 | | - @test s[3] == "c" |
433 | | - for s′ in ( |
434 | | - replace(x -> x == "b" ? "x" : x, s), |
435 | | - replace(s, "b" => "x"), |
436 | | - map(x -> x == "b" ? "x" : x, s), |
437 | | - ) |
438 | | - @test s′ isa LittleSet |
439 | | - @test Tuple(s′) == ("a", "x", "c") |
440 | | - @test s′[1] == "a" |
441 | | - @test s′[2] == "x" |
442 | | - @test s′[3] == "c" |
443 | | - end |
444 | | - |
445 | | - s = LittleSet((1, 2, 3)) |
446 | | - @test LittleSet(s).values isa Tuple |
447 | | - @test LittleSet(s) == s |
448 | | - sp = LittleSet{NTuple{3, Float64}}(s) |
449 | | - @test eltype(sp) === Float64 |
450 | | - @test values(sp) == (1.0, 2.0, 3.0) |
451 | | - end |
452 | 415 | @testset "show" begin |
453 | 416 | a = ITensor([1 2; 3 4], ("i", "j")) |
454 | 417 | @test sprint(show, "text/plain", a) == |
|
0 commit comments