Skip to content

Commit

Permalink
Merge ade0393 into ff938e2
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman authored Mar 31, 2024
2 parents ff938e2 + ade0393 commit f3c75a3
Show file tree
Hide file tree
Showing 9 changed files with 486 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ITensors"
uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5"
authors = ["Matthew Fishman <mfishman@flatironinstitute.org>", "Miles Stoudenmire <mstoudenmire@flatironinstitute.org>"]
version = "0.3.59"
version = "0.3.60"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
21 changes: 1 addition & 20 deletions src/ITensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,7 @@ module ITensors
#####################################
# External packages
#
using Adapt
using BitIntegers
using ChainRulesCore
using Compat
using DocStringExtensions
using Functors
using HDF5
using IsApprox
using LinearAlgebra
using NDTensors
using PackageCompiler
using Pkg
using Printf
using Random
using Reexport
using SerializedElementArrays
using StaticArrays
using TimerOutputs
using TupleTools
using Zeros
include("usings.jl")

#####################################
# General utility functions
Expand Down
2 changes: 0 additions & 2 deletions src/exports.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using NDTensors.RankFactorization: Spectrum, eigs, entropy, truncerror

export
# From external modules
# LinearAlgebra
Expand Down
32 changes: 32 additions & 0 deletions src/usings.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# TODO: Delete these and move them to the tops of files where
# they are be used, and change to explicit usings, i.e.
# `using NDTensors: tensor`.
# Try using `ExplicitImports.jl`:
# https://github.com/ericphanson/ExplicitImports.jl
# to automate the process.
using Adapt
using BitIntegers
using ChainRulesCore
using Compat
using DocStringExtensions
using Functors
using HDF5
using IsApprox
using LinearAlgebra
using NDTensors
using NDTensors.RankFactorization: Spectrum, eigs, entropy, truncerror
using PackageCompiler
using Pkg
using Printf
using Random
using Reexport
using SerializedElementArrays
using StaticArrays
using TimerOutputs
using TupleTools
using Zeros

# This makes `scalartype` available externally as
# `ITensors.scalartype`, this isn't be used within
# the `ITensors` module right now.
using NDTensors: scalartype
7 changes: 7 additions & 0 deletions test/base/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
8 changes: 4 additions & 4 deletions test/base/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using ITensors
using Test

@eval module $(gensym())
using ITensors: ITensors
using Test: @testset
ITensors.Strided.disable_threads()
ITensors.BLAS.set_num_threads(1)
ITensors.disable_threaded_blocksparse()

@testset "$(@__DIR__)" begin
filenames = filter(readdir(@__DIR__)) do f
startswith("test_")(f) && endswith(".jl")(f)
Expand All @@ -14,3 +13,4 @@ ITensors.disable_threaded_blocksparse()
@time include(filename)
end
end
end
9 changes: 9 additions & 0 deletions test/base/test_exports.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@eval module $(gensym())
using ITensors: ITensors
using Test: @test, @testset
include("utils/TestITensorsExportedNames/TestITensorsExportedNames.jl")
using .TestITensorsExportedNames: ITENSORS_EXPORTED_NAMES
@testset "Test $name is exported" for name in ITENSORS_EXPORTED_NAMES
@test Base.isexported(ITensors, name)
end
end
93 changes: 85 additions & 8 deletions test/base/test_itensor.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,83 @@
using ITensors
using LinearAlgebra
using Test

@eval module $(gensym())
using Combinatorics: permutations

import Random: seed!
import ITensors.NDTensors: DenseTensor
using ITensors:
ITensors,
Index,
IndexSet,
ITensor,
Order,
QN,
,
δ,
addtags,
allhastags,
anyhastags,
commonind,
convert_eltype,
convert_leaf_eltype,
dag,
directsum,
eachindval,
eachval,
filterinds,
firstind,
hascommoninds,
hasind,
hasinds,
hassameinds,
hastags,
inner,
itensor,
mapprime,
noprime,
onehot,
order,
permute,
prime,
product,
randomITensor,
removetags,
replaceind,
replaceind!,
replaceinds,
replaceinds!,
replacetags,
scalar,
setelt,
setprime,
settags,
sim,
swapinds,
swapinds!,
swapprime,
uniqueind,
uniqueindex,
val
using ITensors.NDTensors:
NDTensors,
DenseTensor,
array,
dim,
dims,
eigen,
factorize,
ind,
inds,
matrix,
maxdim,
mindim,
polar,
storage,
vector
using LinearAlgebra:
LinearAlgebra, axpy!, diag, dot, ishermitian, mul!, norm, nullspace, qr, rmul!, svd, tr
using Random: Random
using Test: @test, @test_throws, @testset

# Enable debug checking for these tests
ITensors.enable_debug_checks()

seed!(12345)
Random.seed!(12345)

function invdigits(::Type{T}, x...) where {T}
return T(sum([x[length(x) - k + 1] * 10^(k - 1) for k in 1:length(x)]))
Expand Down Expand Up @@ -72,6 +139,15 @@ end
@test iszero(ITensor(i, j))
end

elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
@testset "ITensors.scalartype (eltype=$elt)" for elt in elts
i, j = Index.((2, 2))
a = ITensor(elt, i, j)
@test ITensors.scalartype(a) === elt
a = randomITensor(elt, i, j)
@test ITensors.scalartype(a) === elt
end

@testset "map" begin
A = randomITensor(Index(2))
@test eltype(A) == Float64
Expand Down Expand Up @@ -1847,3 +1923,4 @@ end # End Dense ITensor basic functionality

# Disable debug checking once tests are completed
ITensors.disable_debug_checks()
end
Loading

0 comments on commit f3c75a3

Please sign in to comment.