Skip to content

Commit 20cf988

Browse files
committed
Add tests
1 parent d1ab4a9 commit 20cf988

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

test/base/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
[deps]
22
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
33
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
4+
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
45
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
56
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
7+
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
68
NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
79
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
810
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"

test/base/test_diagitensor.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ using Test
106106
end
107107
end
108108

109+
@testset "diag_itensor constructor from Range" begin
110+
t = diag_itensor(1:d, i, j)
111+
@test ITensors.data(t) == 1:d
112+
@test ITensors.data(t) isa Vector{Float64}
113+
114+
t = diag_itensor(Int, 1:d, i, j)
115+
@test ITensors.data(t) 1:d
116+
end
117+
109118
@testset "reductions (sum, prod)" for elt in (
110119
Float32, Float64, Complex{Float32}, Complex{Float64},
111120
)

test/base/test_itensor.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,21 @@ end
995995
@test storage(T) isa NDTensors.Dense{Float64}
996996
end
997997

998+
@testset "Construct from Range" begin
999+
# https://github.com/ITensor/ITensors.jl/issues/1691
1000+
1001+
# Automatic conversion to float.
1002+
i, j = Index.((2, 2))
1003+
t = ITensor(1:4, (i, j))
1004+
@test ITensors.data(t) == 1:4
1005+
@test ITensors.data(t) isa Vector{Float64}
1006+
1007+
# Preserve integer element type.
1008+
i, j = Index.((2, 2))
1009+
t = ITensor(Int, 1:4, (i, j))
1010+
@test ITensors.data(t) 1:4
1011+
end
1012+
9981013
@testset "ITensor Array constructor view behavior" begin
9991014
d = 2
10001015
i = Index(d)

0 commit comments

Comments
 (0)