From 2b592c0ef37a315721c6b09e516e9e0a3a4ecb0e Mon Sep 17 00:00:00 2001 From: Matt Fishman Date: Tue, 2 Apr 2024 20:00:14 -0400 Subject: [PATCH] Remove most exports (#152) --- Project.toml | 2 +- README.md | 28 ++--- examples/Project.toml | 2 + examples/boundary.jl | 3 +- .../contraction_sequence.jl | 2 +- examples/dynamics/2d_ising_imag_tebd.jl | 11 +- examples/dynamics/Project.toml | 6 + examples/examples.jl | 7 +- examples/mincut.jl | 24 +++- examples/mps.jl | 11 +- examples/treetensornetworks/Project.toml | 5 + examples/treetensornetworks/comb_tree.jl | 2 +- examples/treetensornetworks/ttn_type.jl | 13 +- src/exports.jl | 119 +----------------- src/mincut.jl | 7 +- test/runtests.jl | 10 +- test/test_abstractgraph.jl | 3 + test/test_additensornetworks.jl | 21 ++-- test/test_apply.jl | 30 +++-- test/test_belief_propagation.jl | 42 ++++--- test/test_binary_tree_partition.jl | 29 +++-- test/test_contract_deltas.jl | 18 ++- test/test_contraction_sequence.jl | 93 +++++++------- test/test_contraction_sequence_to_graph.jl | 15 ++- test/test_examples/test_examples.jl | 20 +-- test/test_forms.jl | 32 +++-- test/test_gauging.jl | 26 ++-- test/test_indsnetwork.jl | 16 ++- test/test_itensornetwork.jl | 58 +++++++-- test/test_sitetype.jl | 15 ++- test/test_tebd.jl | 12 +- test/test_tno.jl | 26 ++-- test/test_treetensornetworks/Project.toml | 4 + test/test_treetensornetworks/test_expect.jl | 12 +- test/test_treetensornetworks/test_position.jl | 10 +- .../test_solvers/Project.toml | 2 + .../test_solvers/test_contract.jl | 32 +++-- .../test_solvers/test_dmrg.jl | 37 ++++-- .../test_solvers/test_dmrg_x.jl | 29 +++-- .../test_solvers/test_linsolve.jl | 12 +- test/test_ttno.jl | 13 +- test/test_ttns.jl | 14 ++- 42 files changed, 502 insertions(+), 371 deletions(-) create mode 100644 examples/dynamics/Project.toml create mode 100644 examples/treetensornetworks/Project.toml create mode 100644 test/test_treetensornetworks/Project.toml diff --git a/Project.toml b/Project.toml index c43dc9b5..9306ec49 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ITensorNetworks" uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7" authors = ["Matthew Fishman and contributors"] -version = "0.4.1" +version = "0.5" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" diff --git a/README.md b/README.md index fe3fd65c..caf9d964 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ and 3 edge(s): 3 => 4 with vertex data: -4-element Dictionaries.Dictionary{Int64, Any} +4-element Dictionary{Int64, Any} 1 │ ((dim=2|id=739|"1,2"),) 2 │ ((dim=2|id=739|"1,2"), (dim=2|id=920|"2,3")) 3 │ ((dim=2|id=920|"2,3"), (dim=2|id=761|"3,4")) @@ -104,7 +104,7 @@ and 4 edge(s): (1, 2) => (2, 2) with vertex data: -4-element Dictionaries.Dictionary{Tuple{Int64, Int64}, Any} +4-element Dictionary{Tuple{Int64, Int64}, Any} (1, 1) │ ((dim=2|id=712|"1×1,2×1"), (dim=2|id=598|"1×1,1×2")) (2, 1) │ ((dim=2|id=712|"1×1,2×1"), (dim=2|id=457|"2×1,2×2")) (1, 2) │ ((dim=2|id=598|"1×1,1×2"), (dim=2|id=683|"1×2,2×2")) @@ -134,7 +134,7 @@ and 1 edge(s): (1, 1) => (1, 2) with vertex data: -2-element Dictionaries.Dictionary{Tuple{Int64, Int64}, Any} +2-element Dictionary{Tuple{Int64, Int64}, Any} (1, 1) │ ((dim=2|id=712|"1×1,2×1"), (dim=2|id=598|"1×1,1×2")) (1, 2) │ ((dim=2|id=598|"1×1,1×2"), (dim=2|id=683|"1×2,2×2")) @@ -148,7 +148,7 @@ and 1 edge(s): (2, 1) => (2, 2) with vertex data: -2-element Dictionaries.Dictionary{Tuple{Int64, Int64}, Any} +2-element Dictionary{Tuple{Int64, Int64}, Any} (2, 1) │ ((dim=2|id=712|"1×1,2×1"), (dim=2|id=457|"2×1,2×2")) (2, 2) │ ((dim=2|id=457|"2×1,2×2"), (dim=2|id=683|"1×2,2×2")) ``` @@ -164,7 +164,7 @@ julia> using ITensorNetworks: ⊗, contract, contraction_sequence julia> using ITensorUnicodePlots: @visualize julia> s = siteinds("S=1/2", named_grid(3)) -ITensorNetworks.IndsNetwork{Int64, ITensors.Index} with 3 vertices: +IndsNetwork{Int64, Index} with 3 vertices: 3-element Vector{Int64}: 1 2 @@ -175,13 +175,13 @@ and 2 edge(s): 2 => 3 with vertex data: -3-element Dictionaries.Dictionary{Int64, Vector{ITensors.Index}} - 1 │ ITensors.Index[(dim=2|id=830|"S=1/2,Site,n=1")] - 2 │ ITensors.Index[(dim=2|id=369|"S=1/2,Site,n=2")] - 3 │ ITensors.Index[(dim=2|id=558|"S=1/2,Site,n=3")] +3-element Dictionary{Int64, Vector{Index}} + 1 │ Index[(dim=2|id=830|"S=1/2,Site,n=1")] + 2 │ Index[(dim=2|id=369|"S=1/2,Site,n=2")] + 3 │ Index[(dim=2|id=558|"S=1/2,Site,n=3")] and edge data: -0-element Dictionaries.Dictionary{NamedGraphs.NamedEdge{Int64}, Vector{ITensors.Index}} +0-element Dictionary{NamedEdge{Int64}, Vector{Index}} julia> tn1 = ITensorNetwork(s; link_space=2) ITensorNetwork{Int64} with 3 vertices: @@ -195,7 +195,7 @@ and 2 edge(s): 2 => 3 with vertex data: -3-element Dictionaries.Dictionary{Int64, Any} +3-element Dictionary{Int64, Any} 1 │ ((dim=2|id=830|"S=1/2,Site,n=1"), (dim=2|id=186|"1,2")) 2 │ ((dim=2|id=369|"S=1/2,Site,n=2"), (dim=2|id=186|"1,2"), (dim=2|id=430|"2,3… 3 │ ((dim=2|id=558|"S=1/2,Site,n=3"), (dim=2|id=430|"2,3")) @@ -212,7 +212,7 @@ and 2 edge(s): 2 => 3 with vertex data: -3-element Dictionaries.Dictionary{Int64, Any} +3-element Dictionary{Int64, Any} 1 │ ((dim=2|id=830|"S=1/2,Site,n=1"), (dim=2|id=994|"1,2")) 2 │ ((dim=2|id=369|"S=1/2,Site,n=2"), (dim=2|id=994|"1,2"), (dim=2|id=978|"2,3… 3 │ ((dim=2|id=558|"S=1/2,Site,n=3"), (dim=2|id=978|"2,3")) @@ -293,8 +293,8 @@ julia> @visualize Z; julia> contraction_sequence(Z) 2-element Vector{Vector}: - NamedGraphs.Key{Tuple{Int64, Int64}}[Key((1, 1)), Key((1, 2))] - Any[Key((2, 1)), Any[Key((2, 2)), NamedGraphs.Key{Tuple{Int64, Int64}}[Key((3, 1)), Key((3, 2))]]] + Key{Tuple{Int64, Int64}}[Key((1, 1)), Key((1, 2))] + Any[Key((2, 1)), Any[Key((2, 2)), Key{Tuple{Int64, Int64}}[Key((3, 1)), Key((3, 2))]]] julia> Z̃ = contract(Z, (1, 1) => (2, 1)); diff --git a/examples/Project.toml b/examples/Project.toml index a0736efc..71c0245f 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -1,4 +1,6 @@ [deps] +AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" +DataGraphs = "b5a273c3-7e6c-41f6-98bd-8d7f1525a36a" Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7" ITensorUnicodePlots = "73163f41-4a9e-479f-8353-73bf94dbd758" diff --git a/examples/boundary.jl b/examples/boundary.jl index 7c43712a..f97c15b8 100644 --- a/examples/boundary.jl +++ b/examples/boundary.jl @@ -1,6 +1,7 @@ +using Graphs: vertices using NamedGraphs using ITensors -using ITensorNetworks +using ITensorNetworks: ITensorNetwork using ITensorUnicodePlots using Metis diff --git a/examples/contraction_sequence/contraction_sequence.jl b/examples/contraction_sequence/contraction_sequence.jl index 34eb097d..7f737df0 100644 --- a/examples/contraction_sequence/contraction_sequence.jl +++ b/examples/contraction_sequence/contraction_sequence.jl @@ -1,6 +1,6 @@ using NamedGraphs using ITensors -using ITensorNetworks +using ITensorNetworks: randomITensorNetwork using Random Random.seed!(1234) diff --git a/examples/dynamics/2d_ising_imag_tebd.jl b/examples/dynamics/2d_ising_imag_tebd.jl index fe917523..f228a553 100644 --- a/examples/dynamics/2d_ising_imag_tebd.jl +++ b/examples/dynamics/2d_ising_imag_tebd.jl @@ -1,8 +1,11 @@ -using ITensors -using ITensorNetworks +using Graphs: vertices +using ITensors: ITensors, inner +using ITensors.ITensorMPS: MPO, MPS +using ITensorNetworks: cartesian_to_linear, dmrg, expect, group_terms, ising, siteinds, tebd using ITensorUnicodePlots -using UnicodePlots -using Random +using NamedGraphs: named_grid, rename_vertices +using UnicodePlots: heatmap +using Random: Random Random.seed!(1234) diff --git a/examples/dynamics/Project.toml b/examples/dynamics/Project.toml new file mode 100644 index 00000000..75f5e78a --- /dev/null +++ b/examples/dynamics/Project.toml @@ -0,0 +1,6 @@ +[deps] +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" +ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7" +ITensorUnicodePlots = "73163f41-4a9e-479f-8353-73bf94dbd758" +NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19" +UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" diff --git a/examples/examples.jl b/examples/examples.jl index fdf5b757..f6836a9b 100644 --- a/examples/examples.jl +++ b/examples/examples.jl @@ -1,7 +1,6 @@ -using ITensors -using ITensorNetworks -using ITensorUnicodePlots -using NamedGraphs +using ITensorNetworks: IndsNetwork, itensors +using ITensorUnicodePlots: @visualize +using NamedGraphs: named_grid χ, d = 5, 2 system_dims = (4, 4) diff --git a/examples/mincut.jl b/examples/mincut.jl index 298157cc..4fc40534 100644 --- a/examples/mincut.jl +++ b/examples/mincut.jl @@ -1,7 +1,23 @@ -using NamedGraphs -using ITensors -using ITensorNetworks -using ITensorUnicodePlots +using Graphs: + adjacency_matrix, + bfs_tree, + center, + diameter, + eccentricity, + neighborhood_dists, + nv, + periphery, + radius +using NamedGraphs: + dijkstra_mst, + dijkstra_parents, + dijkstra_tree, + mincut_partitions, + named_grid, + symrcm_permute +using ITensors: dag +using ITensorNetworks: ITensorNetwork, ⊗, flatten_networks, siteinds +using ITensorUnicodePlots: @visualize g = named_grid(5) s = siteinds("S=1/2", g) diff --git a/examples/mps.jl b/examples/mps.jl index 8f3804f9..f8a0a323 100644 --- a/examples/mps.jl +++ b/examples/mps.jl @@ -1,9 +1,10 @@ -using AbstractTrees -using ITensors -using ITensorNetworks +using AbstractTrees: print_tree +using DataGraphs: edge_data, vertex_data +using ITensors: contract, dag, sim +using ITensorNetworks: IndsNetwork, ITensorNetwork, contraction_sequence, siteinds using ITensorUnicodePlots -using Random -using NamedGraphs +using Random: Random, randn! +using NamedGraphs: named_path_graph, subgraph Random.seed!(1234) diff --git a/examples/treetensornetworks/Project.toml b/examples/treetensornetworks/Project.toml new file mode 100644 index 00000000..7cd92cce --- /dev/null +++ b/examples/treetensornetworks/Project.toml @@ -0,0 +1,5 @@ +[deps] +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" +ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7" +ITensorUnicodePlots = "73163f41-4a9e-479f-8353-73bf94dbd758" +NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19" diff --git a/examples/treetensornetworks/comb_tree.jl b/examples/treetensornetworks/comb_tree.jl index 85d628e6..dbb0651f 100644 --- a/examples/treetensornetworks/comb_tree.jl +++ b/examples/treetensornetworks/comb_tree.jl @@ -1,6 +1,6 @@ using NamedGraphs using ITensors -using ITensorNetworks +using ITensorNetworks: TTN using ITensorUnicodePlots g = named_comb_tree((5, 2)) diff --git a/examples/treetensornetworks/ttn_type.jl b/examples/treetensornetworks/ttn_type.jl index 2c05313b..4c23536b 100644 --- a/examples/treetensornetworks/ttn_type.jl +++ b/examples/treetensornetworks/ttn_type.jl @@ -1,8 +1,11 @@ -using AbstractTrees -using NamedGraphs -using ITensors -using ITensorNetworks -using ITensorUnicodePlots +using Graphs: dst, edgetype, neighbors, src, vertices +using NamedGraphs: incident_edges, is_leaf, leaf_vertices, named_binary_tree +using ITensors: contract, dag, prime +using ITensorNetworks: + TTN, ⊗, contraction_sequence, inner, norm_sqr_network, orthogonalize, siteinds +using ITensorUnicodePlots: @visualize +using LinearAlgebra: norm, qr, svd +using Random: randn! g = named_binary_tree(3) s = siteinds("S=1/2", g) diff --git a/src/exports.jl b/src/exports.jl index 1471287b..ca9d4d77 100644 --- a/src/exports.jl +++ b/src/exports.jl @@ -1,118 +1 @@ -# Graphs -export grid, - dst, - edges, - src, - neighbors, - inneighbors, - induced_subgraph, - mincut, - ne, - nv, - outneighbors, - has_edge, - has_vertex, - bfs_tree, - dfs_tree, - edgetype, - is_directed, - is_tree, - rem_vertex!, - vertices, - post_order_dfs_vertices, - edge_path, - vertex_path - -# NamedGraphs -export Key, - named_binary_tree, - named_grid, - parent_vertex, - child_vertices, - post_order_dfs_edges, - leaf_vertices, - is_leaf, - incident_edges, # TODO: Remove this export. - comb_tree, - named_comb_tree, - subgraph, - mincut_partitions - -# DataGraphs -export DataGraph, vertex_data, edge_data, underlying_graph - -# ITensorNetworks: indsnetwork.jl -export IndsNetwork, union_all_inds - -# ITensorNetworks: itensornetwork.jl -export AbstractITensorNetwork, - ITensorNetwork, - ⊗, - itensors, - reverse_bfs_edges, - data_graph, - default_bp_cache, - flatten_networks, - inner_network, - norm_network, - factorize!, - norm_sqr_network, - linkinds_combiners, - combine_linkinds, - externalinds, - internalinds, - subgraphs, - reverse_bfs_edges, - randomITensorNetwork, - random_mps, - # treetensornetwork - default_root_vertex, - mpo, - mps, - ortho_center, - set_ortho_center, - BilinearFormNetwork, - QuadraticFormNetwork, - TreeTensorNetwork, - TTN, - random_ttn, - ProjTTN, - ProjTTNSum, - ProjOuterProdTTN, - set_nsite, - position, - # contraction_sequences.jl - contraction_sequence, - # utils.jl - cartesian_to_linear, - # namedgraphs.jl - rename_vertices, - # models.jl - heisenberg, - ising, - # opsum.jl - group_terms, - # tebd.jl - tebd, - # treetensornetwork/opsum_to_ttn.jl - mpo, - # treetensornetwork/solvers.jl - TimeDependentSum, - dmrg_x, - tdvp, - to_vec - -# ITensorNetworks: mincut.jl -export path_graph_structure, binary_tree_structure - -# ITensorNetworks: approx_itensornetwork.jl -export approx_itensornetwork - -# ITensorNetworks: partition.jl -export partition, partition_vertices, subgraphs, subgraph_vertices - -# ITensorNetworks: utility.jl -export relabel_sites - -# KrylovKit -export eigsolve, linsolve +export ITensorNetwork diff --git a/src/mincut.jl b/src/mincut.jl index 9ca7c834..fdb9d290 100644 --- a/src/mincut.jl +++ b/src/mincut.jl @@ -1,9 +1,8 @@ -using Graphs: weights -using Graphs: dijkstra_shortest_paths -using NamedGraphs: NamedDiGraph -using GraphsFlows: GraphsFlows using AbstractTrees: Leaves, PostOrderDFS using Combinatorics: powerset +using Graphs: dijkstra_shortest_paths, weights +using GraphsFlows: GraphsFlows +using NamedGraphs: NamedDiGraph # a large number to prevent this edge being a cut MAX_WEIGHT = 1e32 diff --git a/test/runtests.jl b/test/runtests.jl index f02b8f2b..6d854718 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,7 @@ -using Test -using Glob -using ITensorNetworks +@eval module $(gensym()) +using Test: @test, @testset +using Glob: Glob +using ITensorNetworks: ITensorNetworks # https://discourse.julialang.org/t/rdir-search-recursive-for-files-with-a-given-name-pattern/75605/12 @testset "ITensorNetworks.jl, test directory $root" for (root, dirs, files) in walkdir( @@ -12,5 +13,4 @@ using ITensorNetworks @time include(joinpath(root, test_file)) end end - -nothing +end diff --git a/test/test_abstractgraph.jl b/test/test_abstractgraph.jl index 9aa2bb50..d44ee85c 100644 --- a/test/test_abstractgraph.jl +++ b/test/test_abstractgraph.jl @@ -1,5 +1,7 @@ +@eval module $(gensym()) using NamedGraphs: add_edge!, add_vertex!, NamedDiGraph using ITensorNetworks: _root, _is_rooted, _is_rooted_directed_binary_tree +using Test: @test, @testset @testset "test rooted directed graphs" begin g = NamedDiGraph([1, 2, 3]) @@ -13,3 +15,4 @@ using ITensorNetworks: _root, _is_rooted, _is_rooted_directed_binary_tree add_edge!(g, 1, 4) @test !_is_rooted_directed_binary_tree(g) end +end diff --git a/test/test_additensornetworks.jl b/test/test_additensornetworks.jl index 2f6c4246..c0c21d3f 100644 --- a/test/test_additensornetworks.jl +++ b/test/test_additensornetworks.jl @@ -1,16 +1,10 @@ -using ITensorNetworks -using ITensorNetworks: inner_network -using Test -using Compat -using ITensors -using Metis -using NamedGraphs -using NamedGraphs: hexagonal_lattice_graph, rem_edge! -using Random -using LinearAlgebra -using SplitApplyCombine - -using Random +@eval module $(gensym()) +using Graphs: rem_edge!, vertices +using NamedGraphs: NamedEdge, hexagonal_lattice_graph, named_grid +using ITensorNetworks: ITensorNetwork, inner_network, randomITensorNetwork, siteinds +using ITensors: ITensors, apply, op +using Random: Random +using Test: @test, @testset @testset "add_itensornetworks" begin Random.seed!(5623) @@ -75,3 +69,4 @@ using Random @test expec_method1 ≈ expec_method2 end +end diff --git a/test/test_apply.jl b/test/test_apply.jl index f32d8853..f129d6d2 100644 --- a/test/test_apply.jl +++ b/test/test_apply.jl @@ -1,19 +1,22 @@ -using ITensorNetworks +@eval module $(gensym()) +using Compat: Compat +using Graphs: vertices using ITensorNetworks: - environment, - update, + BeliefPropagationCache, + ITensorNetwork, + VidalITensorNetwork, + apply, contract_inner, + environment, norm_network, - BeliefPropagationCache, - VidalITensorNetwork -using Test -using Compat -using ITensors -using Metis -using NamedGraphs -using Random -using LinearAlgebra -using SplitApplyCombine + randomITensorNetwork, + siteinds, + update +using ITensors: ITensors +using NamedGraphs: PartitionVertex, named_grid +using Random: Random +using SplitApplyCombine: group +using Test: @test, @testset @testset "apply" begin Random.seed!(5623) @@ -79,3 +82,4 @@ using SplitApplyCombine @test isapprox(real(fSBP * conj(fSBP)), real(fVidal * conj(fVidal)); atol=1e-3) end end +end diff --git a/test/test_belief_propagation.jl b/test/test_belief_propagation.jl index 4cbb9a7a..2ba83ce1 100644 --- a/test/test_belief_propagation.jl +++ b/test/test_belief_propagation.jl @@ -1,23 +1,34 @@ -using ITensorNetworks +@eval module $(gensym()) +using Compat: Compat +using Graphs: vertices using ITensorNetworks: - ising_network, - split_index, + ITensorNetworks, + BeliefPropagationCache, + IndsNetwork, + ⊗, + apply, + combine_linkinds, + contract, contract_inner, contract_boundary_mps, - BeliefPropagationCache, + contraction_sequence, + environment, + flatten_networks, + ising_network, + linkinds_combiners, + randomITensorNetwork, + siteinds, + split_index, tensornetwork, update, - update_factor, - environment, - contract -using Test -using Compat -using ITensors -using LinearAlgebra -using NamedGraphs -using SplitApplyCombine -using Random -using Metis + update_factor +using ITensors: ITensors, ITensor, combiner, dag, inds, op, prime, randomITensor +using ITensors.NDTensors: array +using LinearAlgebra: eigvals, tr +using NamedGraphs: NamedEdge, PartitionVertex, named_comb_tree, named_grid +using Random: Random +using SplitApplyCombine: group +using Test: @test, @testset ITensors.disable_warn_order() @@ -158,3 +169,4 @@ ITensors.disable_warn_order() @test abs.((numerator / denominator) - exact_sz) <= 1e-5 end +end diff --git a/test/test_binary_tree_partition.jl b/test/test_binary_tree_partition.jl index 4fe55250..745072b8 100644 --- a/test/test_binary_tree_partition.jl +++ b/test/test_binary_tree_partition.jl @@ -1,17 +1,25 @@ -using ITensors, OMEinsumContractionOrders -using Graphs, NamedGraphs -using ITensorNetworks -using ITensors: contract +@eval module $(gensym()) +using DataGraphs: DataGraph, underlying_graph, vertex_data +using Graphs: add_vertex!, vertices +using ITensors: Index, ITensor, contract, noncommoninds, randomITensor +using ITensors.ITensorMPS: MPS using ITensorNetworks: - _root, + _DensityMartrixAlgGraph, + _contract_deltas_ignore_leaf_partitions, + _is_rooted_directed_binary_tree, _mps_partition_inds_order, _mincut_partitions, - _is_rooted_directed_binary_tree, - _contract_deltas_ignore_leaf_partitions, + _partition, _rem_vertex!, - _DensityMartrixAlgGraph, - _partition -using Test + _root, + IndsNetwork, + ITensorNetwork, + binary_tree_structure, + path_graph_structure, + randomITensorNetwork +using NamedGraphs: NamedEdge, named_grid, post_order_dfs_vertices +using OMEinsumContractionOrders: OMEinsumContractionOrders +using Test: @test, @testset @testset "test mincut functions on top of MPS" begin i = Index(2, "i") @@ -140,3 +148,4 @@ end # Check that a specific density matrix info has been cached @test haskey(alg_graph.caches.es_to_pdm, Set([NamedEdge(nothing, path[3])])) end +end diff --git a/test/test_contract_deltas.jl b/test/test_contract_deltas.jl index 151aa6c3..36eddfe0 100644 --- a/test/test_contract_deltas.jl +++ b/test/test_contract_deltas.jl @@ -1,6 +1,19 @@ -using ITensors +@eval module $(gensym()) +using Graphs: dfs_tree, nv, vertices +using ITensors: Index, ITensor, delta, noncommoninds, randomITensor using ITensorNetworks: - _contract_deltas, _contract_deltas_ignore_leaf_partitions, _noncommoninds, _root + _contract_deltas, + _contract_deltas_ignore_leaf_partitions, + _noncommoninds, + _partition, + _root, + binary_tree_structure, + IndsNetwork, + ITensorNetwork, + path_graph_structure, + randomITensorNetwork +using NamedGraphs: leaf_vertices, named_grid +using Test: @test, @testset @testset "test _contract_deltas with no deltas" begin i = Index(2, "i") @@ -44,3 +57,4 @@ end @test nvs == 9 end end +end diff --git a/test/test_contraction_sequence.jl b/test/test_contraction_sequence.jl index 5470dabe..26ff3e79 100644 --- a/test/test_contraction_sequence.jl +++ b/test/test_contraction_sequence.jl @@ -1,50 +1,57 @@ -using ITensors -using ITensorNetworks -using OMEinsumContractionOrders -using Random -using Test +@eval module $(gensym()) using EinExprs: Exhaustive, Greedy, HyPar +using ITensorNetworks: + contraction_sequence, norm_sqr_network, randomITensorNetwork, siteinds +using ITensors: ITensors, contract +using NamedGraphs: named_grid +using OMEinsumContractionOrders: OMEinsumContractionOrders +using Random: Random +using Test: @test, @testset Random.seed!(1234) - -ITensors.disable_warn_order() - @testset "contraction_sequence" begin - dims = (2, 3) - g = named_grid(dims) - s = siteinds("S=1/2", g) - χ = 10 - ψ = randomITensorNetwork(s; link_space=χ) - tn = norm_sqr_network(ψ) - seq_optimal = contraction_sequence(tn; alg="optimal") - res_optimal = contract(tn; sequence=seq_optimal)[] - seq_greedy = contraction_sequence(tn; alg="greedy") - res_greedy = contract(tn; sequence=seq_greedy)[] - seq_tree_sa = contraction_sequence(tn; alg="tree_sa") - res_tree_sa = contract(tn; sequence=seq_tree_sa)[] - seq_sa_bipartite = contraction_sequence(tn; alg="sa_bipartite") - res_sa_bipartite = contract(tn; sequence=seq_sa_bipartite)[] - seq_einexprs_exhaustive = contraction_sequence(tn; alg="einexpr", optimizer=Exhaustive()) - res_einexprs_exhaustive = contract(tn; sequence=seq_einexprs_exhaustive)[] - seq_einexprs_greedy = contraction_sequence(tn; alg="einexpr", optimizer=Greedy()) - res_einexprs_greedy = contract(tn; sequence=seq_einexprs_exhaustive)[] - @test res_greedy ≈ res_optimal - @test res_tree_sa ≈ res_optimal - @test res_sa_bipartite ≈ res_optimal - @test res_einexprs_exhaustive ≈ res_optimal - @test res_einexprs_greedy ≈ res_optimal + ITensors.@disable_warn_order begin + dims = (2, 3) + g = named_grid(dims) + s = siteinds("S=1/2", g) + χ = 10 + ψ = randomITensorNetwork(s; link_space=χ) + tn = norm_sqr_network(ψ) + seq_optimal = contraction_sequence(tn; alg="optimal") + res_optimal = contract(tn; sequence=seq_optimal)[] + seq_greedy = contraction_sequence(tn; alg="greedy") + res_greedy = contract(tn; sequence=seq_greedy)[] + seq_tree_sa = contraction_sequence(tn; alg="tree_sa") + res_tree_sa = contract(tn; sequence=seq_tree_sa)[] + seq_sa_bipartite = contraction_sequence(tn; alg="sa_bipartite") + res_sa_bipartite = contract(tn; sequence=seq_sa_bipartite)[] + seq_einexprs_exhaustive = contraction_sequence( + tn; alg="einexpr", optimizer=Exhaustive() + ) + res_einexprs_exhaustive = contract(tn; sequence=seq_einexprs_exhaustive)[] + seq_einexprs_greedy = contraction_sequence(tn; alg="einexpr", optimizer=Greedy()) + res_einexprs_greedy = contract(tn; sequence=seq_einexprs_exhaustive)[] + @test res_greedy ≈ res_optimal + @test res_tree_sa ≈ res_optimal + @test res_sa_bipartite ≈ res_optimal + @test res_einexprs_exhaustive ≈ res_optimal + @test res_einexprs_greedy ≈ res_optimal - if !Sys.iswindows() - # KaHyPar doesn't work on Windows - # https://github.com/kahypar/KaHyPar.jl/issues/9 - using Pkg - Pkg.add("KaHyPar") - using KaHyPar - seq_kahypar_bipartite = contraction_sequence(tn; alg="kahypar_bipartite", sc_target=200) - res_kahypar_bipartite = contract(tn; sequence=seq_kahypar_bipartite)[] - @test res_optimal ≈ res_kahypar_bipartite - seq_einexprs_kahypar = contraction_sequence(tn; alg="einexpr", optimizer=HyPar()) - res_einexprs_kahypar = contract(tn; sequence=seq_einexprs_kahypar)[] - @test res_einexprs_kahypar ≈ res_optimal + if !Sys.iswindows() + # KaHyPar doesn't work on Windows + # https://github.com/kahypar/KaHyPar.jl/issues/9 + using Pkg + Pkg.add("KaHyPar") + using KaHyPar + seq_kahypar_bipartite = contraction_sequence( + tn; alg="kahypar_bipartite", sc_target=200 + ) + res_kahypar_bipartite = contract(tn; sequence=seq_kahypar_bipartite)[] + @test res_optimal ≈ res_kahypar_bipartite + seq_einexprs_kahypar = contraction_sequence(tn; alg="einexpr", optimizer=HyPar()) + res_einexprs_kahypar = contract(tn; sequence=seq_einexprs_kahypar)[] + @test res_einexprs_kahypar ≈ res_optimal + end end end +end diff --git a/test/test_contraction_sequence_to_graph.jl b/test/test_contraction_sequence_to_graph.jl index caee8993..2e21c2a4 100644 --- a/test/test_contraction_sequence_to_graph.jl +++ b/test/test_contraction_sequence_to_graph.jl @@ -1,15 +1,19 @@ -using ITensorNetworks +@eval module $(gensym()) +using Graphs: vertices using ITensorNetworks: + _root, + contraction_sequence, contraction_sequence_to_digraph, contraction_sequence_to_graph, internal_edges, contraction_tree_leaf_bipartition, distance_to_leaf, + flatten_networks, leaf_vertices, - _root -using Test -using ITensors -using NamedGraphs + randomITensorNetwork, + siteinds +using Test: @test, @testset +using NamedGraphs: is_leaf, leaf_vertices, named_grid @testset "contraction_sequence_to_graph" begin n = 3 @@ -48,3 +52,4 @@ using NamedGraphs end end end +end diff --git a/test/test_examples/test_examples.jl b/test/test_examples/test_examples.jl index b805db50..c6cfed71 100644 --- a/test/test_examples/test_examples.jl +++ b/test/test_examples/test_examples.jl @@ -1,6 +1,7 @@ -using ITensorNetworks -using Suppressor -using Test +@eval module $(gensym()) +using ITensorNetworks: ITensorNetworks +using Suppressor: @suppress +using Test: @testset @testset "Test examples" begin example_files = [ @@ -12,20 +13,21 @@ using Test "mps.jl", "peps.jl", "steiner_tree.jl", - joinpath("dynamics", "2d_ising_imag_tebd.jl"), - joinpath("treetensornetworks", "comb_tree.jl"), - joinpath("treetensornetworks", "spanning_tree.jl"), - joinpath("treetensornetworks", "ttn_basics.jl"), - joinpath("treetensornetworks", "ttn_type.jl"), + "dynamics/2d_ising_imag_tebd.jl", + "treetensornetworks/comb_tree.jl", + "treetensornetworks/spanning_tree.jl", + "treetensornetworks/ttn_basics.jl", + "treetensornetworks/ttn_type.jl", ] @testset "Test $example_file" for example_file in example_files @suppress include(joinpath(pkgdir(ITensorNetworks), "examples", example_file)) end if !Sys.iswindows() - example_files = [joinpath("contraction_sequence", "contraction_sequence.jl")] + example_files = ["contraction_sequence/contraction_sequence.jl"] @testset "Test $example_file (using KaHyPar, so no Windows support)" for example_file in example_files @suppress include(joinpath(pkgdir(ITensorNetworks), "examples", example_file)) end end end +end diff --git a/test/test_forms.jl b/test/test_forms.jl index 0bfa2d02..75dfd5e8 100644 --- a/test/test_forms.jl +++ b/test/test_forms.jl @@ -1,22 +1,29 @@ -using ITensors +@eval module $(gensym()) +using DataGraphs: underlying_graph using Graphs: nv using NamedGraphs -using ITensorNetworks using ITensorNetworks: - delta_network, - update, - tensornetwork, + BeliefPropagationCache, + BilinearFormNetwork, + QuadraticFormNetwork, + bra_network, bra_vertex, - ket_vertex, + delta_network, dual_index_map, - bra_network, + environment, + externalinds, ket_network, + ket_vertex, operator_network, - environment, - BeliefPropagationCache -using Test -using Random -using SplitApplyCombine + randomITensorNetwork, + siteinds, + tensornetwork, + union_all_inds, + update +using ITensors: contract, dag, inds, prime, randomITensor +using LinearAlgebra: norm +using Test: @test, @testset +using Random: Random @testset "FormNetworks" begin g = named_grid((1, 4)) @@ -66,3 +73,4 @@ using SplitApplyCombine ∂qf_∂v_bp /= norm(∂qf_∂v_bp) @test ∂qf_∂v_bp ≈ ∂qf_∂v end +end diff --git a/test/test_gauging.jl b/test/test_gauging.jl index f0a7d10b..ce7c8867 100644 --- a/test/test_gauging.jl +++ b/test/test_gauging.jl @@ -1,12 +1,21 @@ -using ITensors -using ITensorNetworks +@eval module $(gensym()) +using Compat: Compat using ITensorNetworks: - contract_inner, gauge_error, update, messages, BeliefPropagationCache, VidalITensorNetwork -using NamedGraphs -using Test -using Compat -using Random -using SplitApplyCombine + BeliefPropagationCache, + ITensorNetwork, + VidalITensorNetwork, + contract_inner, + gauge_error, + messages, + randomITensorNetwork, + siteinds, + update +using ITensors: diagITensor, inds +using ITensors.NDTensors: vector +using LinearAlgebra: diag +using NamedGraphs: named_grid +using Random: Random +using Test: @test, @testset @testset "gauging" begin n = 3 @@ -37,3 +46,4 @@ using SplitApplyCombine @test diagITensor(vector(diag(only(m_e))), inds(only(m_e))) ≈ only(m_e) atol = 1e-8 end end +end diff --git a/test/test_indsnetwork.jl b/test/test_indsnetwork.jl index 1a9bc27f..30662263 100644 --- a/test/test_indsnetwork.jl +++ b/test/test_indsnetwork.jl @@ -1,8 +1,13 @@ -using Dictionaries -using ITensors -using ITensorNetworks -using Random -using Test +@eval module $(gensym()) +using DataGraphs: edge_data, vertex_data +using Dictionaries: Dictionary +using Graphs: edges, ne, nv, vertices +using ITensorNetworks: IndsNetwork, union_all_inds +using ITensors: Index +using ITensors.NDTensors: dim +using NamedGraphs: named_comb_tree +using Random: Random +using Test: @test, @testset @testset "IndsNetwork constructors" begin Random.seed!(1234) @@ -164,3 +169,4 @@ end @test all(issetequal(is_m[v], union(is1[v], is2[v])) for v in vertices(c)) @test all(issetequal(is_m[e], union(is1[e], is2[e])) for e in edges(c)) end +end diff --git a/test/test_itensornetwork.jl b/test/test_itensornetwork.jl index 5f09ecd8..b4200e46 100644 --- a/test/test_itensornetwork.jl +++ b/test/test_itensornetwork.jl @@ -1,11 +1,52 @@ -using Dictionaries -using Distributions -using GraphsFlows -using ITensors -using ITensorNetworks -using NamedGraphs -using Random -using Test +@eval module $(gensym()) +using DataGraphs: vertex_data +using Dictionaries: Dictionary +using Distributions: Uniform +using Graphs: + dijkstra_shortest_paths, + edges, + grid, + has_vertex, + ne, + neighbors, + nv, + rem_vertex!, + vertices, + weights +using GraphsFlows: GraphsFlows +using ITensors: + ITensors, + Index, + ITensor, + commonind, + commoninds, + contract, + dag, + hascommoninds, + hasinds, + inds, + itensor, + order, + sim, + uniqueinds +using ITensors.NDTensors: dims +using ITensorNetworks: + ITensorNetworks, + ⊗, + IndsNetwork, + ITensorNetwork, + contraction_sequence, + externalinds, + inner_network, + internalinds, + linkinds, + orthogonalize, + randomITensorNetwork, + siteinds +using LinearAlgebra: factorize +using NamedGraphs: NamedEdge, incident_edges, named_comb_tree, named_grid +using Random: Random, randn! +using Test: @test, @test_broken, @testset @testset "ITensorNetwork tests" begin @testset "ITensorNetwork Basics" begin @@ -269,3 +310,4 @@ using Test @test_broken swapprime(tn, 0, 2) end end +end diff --git a/test/test_sitetype.jl b/test/test_sitetype.jl index a3515565..443298dd 100644 --- a/test/test_sitetype.jl +++ b/test/test_sitetype.jl @@ -1,8 +1,12 @@ -using Dictionaries -using ITensors -using ITensorNetworks -using Random -using Test +@eval module $(gensym()) +using DataGraphs: vertex_data +using Dictionaries: Dictionary +using Graphs: nv, vertices +using ITensorNetworks: IndsNetwork, siteinds +using ITensors: SiteType, hastags, space +using ITensors.NDTensors: dim +using NamedGraphs: named_grid +using Test: @test, @testset @testset "Site ind system" begin g = named_grid((2, 2)) @@ -47,3 +51,4 @@ using Test @test all(dim(only(s_fs[v])) == fdim(v) for v in vertices(g)) @test all(hastags.(vertex_data(s_fs), Ref("$testtag,Site"))) end +end diff --git a/test/test_tebd.jl b/test/test_tebd.jl index 3a9e0ecc..6894850b 100644 --- a/test/test_tebd.jl +++ b/test/test_tebd.jl @@ -1,6 +1,11 @@ -using ITensors -using ITensorNetworks -using Test +@eval module $(gensym()) +using Graphs: vertices +using ITensors: ITensors +using ITensors.ITensorMPS: MPO, MPS +using ITensorNetworks: + ITensorNetwork, cartesian_to_linear, dmrg, expect, group_terms, ising, siteinds, tebd +using NamedGraphs: named_grid, rename_vertices +using Test: @test, @testset ITensors.disable_warn_order() @@ -64,3 +69,4 @@ ITensors.disable_warn_order() @test (((abs((E2 - E1) / E2) < 1e-4) && (E1 < E0)) || (E2 < E1 < E0)) @test E2 ≈ E_dmrg rtol = 1e-4 end +end diff --git a/test/test_tno.jl b/test/test_tno.jl index 115bf377..a9868eae 100644 --- a/test/test_tno.jl +++ b/test/test_tno.jl @@ -1,9 +1,18 @@ -using Test -using ITensorNetworks -using ITensors -using Random - -using ITensorNetworks: gate_group_to_tno, get_tnos, group_commuting_itensors, contract_inner +@eval module $(gensym()) +using Graphs: vertices +using ITensorNetworks: + apply, + contract_inner, + flatten_networks, + group_commuting_itensors, + gate_group_to_tno, + get_tnos, + ising, + randomITensorNetwork, + siteinds +using ITensors: ITensor, noprime +using NamedGraphs: named_grid +using Test: @test, @testset @testset "TN operator Basics" begin L = 3 @@ -33,13 +42,13 @@ using ITensorNetworks: gate_group_to_tno, get_tnos, group_commuting_itensors, co for tno in tnos ψ_tnod = flatten_networks(ψ_tnod, tno) for v in vertices(ψ_tnod) - noprime!(ψ_tnod[v]) + ψ_tnod[v] = noprime(ψ_tnod[v]) end end ψ_tno = copy(ψ) ψ_tno = flatten_networks(ψ_tno, single_tno) for v in vertices(ψ_tno) - noprime!(ψ_tno[v]) + ψ_tno[v] = noprime(ψ_tno[v]) end z1 = contract_inner(ψ_gated, ψ_gated) @@ -52,3 +61,4 @@ using ITensorNetworks: gate_group_to_tno, get_tnos, group_commuting_itensors, co @test f13 * conj(f13) ≈ 1.0 @test f23 * conj(f23) ≈ 1.0 end +end diff --git a/test/test_treetensornetworks/Project.toml b/test/test_treetensornetworks/Project.toml new file mode 100644 index 00000000..bc880f8b --- /dev/null +++ b/test/test_treetensornetworks/Project.toml @@ -0,0 +1,4 @@ +[deps] +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" +ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7" +NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19" diff --git a/test/test_treetensornetworks/test_expect.jl b/test/test_treetensornetworks/test_expect.jl index 37dc9f7c..82db353a 100644 --- a/test/test_treetensornetworks/test_expect.jl +++ b/test/test_treetensornetworks/test_expect.jl @@ -1,6 +1,9 @@ -using ITensors -using ITensorNetworks -using Test +@eval module $(gensym()) +using Graphs: vertices +using ITensors.ITensorMPS: MPS +using ITensorNetworks: TTN, expect, random_mps, siteinds +using NamedGraphs: named_comb_tree +using Test: @test, @testset @testset "MPS expect comparison with ITensors" begin N = 25 @@ -28,5 +31,4 @@ end res = expect("Sz", state) @test all([isapprox(res[v], magnetization[v]; atol=1e-8) for v in vertices(s)]) end - -nothing +end diff --git a/test/test_treetensornetworks/test_position.jl b/test/test_treetensornetworks/test_position.jl index 9e8f96bb..f1c1e0a8 100644 --- a/test/test_treetensornetworks/test_position.jl +++ b/test/test_treetensornetworks/test_position.jl @@ -1,6 +1,8 @@ -using ITensors -using ITensorNetworks -using ITensorNetworks: position, environments +@eval module $(gensym()) +using Graphs: vertices +using ITensors: ITensors +using ITensorNetworks: ITensorNetworks, ProjTTN, TTN, environments, position, siteinds +using NamedGraphs: named_comb_tree using Test @testset "ProjTTN position" begin @@ -44,4 +46,4 @@ using Test ITensors.disable_auto_fermion() end end -nothing +end diff --git a/test/test_treetensornetworks/test_solvers/Project.toml b/test/test_treetensornetworks/test_solvers/Project.toml index 3b8c43c1..c377be4d 100644 --- a/test/test_treetensornetworks/test_solvers/Project.toml +++ b/test/test_treetensornetworks/test_solvers/Project.toml @@ -1,4 +1,6 @@ [deps] +DataGraphs = "b5a273c3-7e6c-41f6-98bd-8d7f1525a36a" +Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" diff --git a/test/test_treetensornetworks/test_solvers/test_contract.jl b/test/test_treetensornetworks/test_solvers/test_contract.jl index c7ea970e..c78b2c64 100644 --- a/test/test_treetensornetworks/test_solvers/test_contract.jl +++ b/test/test_treetensornetworks/test_solvers/test_contract.jl @@ -1,7 +1,26 @@ -using ITensors -using ITensorNetworks -using Random -using Test +@eval module $(gensym()) +using Graphs: vertices +using ITensorNetworks: + ITensorNetworks, + OpSum, + ProjOuterProdTTN, + ProjTTNSum, + TTN, + TreeTensorNetwork, + apply, + contract, + delta, + dmrg, + inner, + mpo, + random_mps, + random_ttn, + siteinds +using ITensors: prime, replaceinds, replaceprime +using ITensors.ITensorMPS: randomMPO +using LinearAlgebra: norm, normalize +using NamedGraphs: named_comb_tree +using Test: @test, @test_broken, @testset @testset "Contract MPO" begin N = 20 @@ -83,7 +102,7 @@ end c = named_comb_tree(tooth_lengths) s = siteinds("S=1/2", c) - psi = normalize!(random_ttn(s; link_space=8)) + psi = normalize(random_ttn(s; link_space=8)) os = ITensorNetworks.heisenberg(c; J1=1, J2=1) H = TTN(os, s) @@ -146,5 +165,4 @@ end # Test with good initial guess @test contract(t1, t2; alg="fit", init=t12_ref, nsweeps=1) ≈ t12_ref rtol = 1e-7 end - -nothing +end diff --git a/test/test_treetensornetworks/test_solvers/test_dmrg.jl b/test/test_treetensornetworks/test_solvers/test_dmrg.jl index 37ae80c0..00eb181b 100644 --- a/test/test_treetensornetworks/test_solvers/test_dmrg.jl +++ b/test/test_treetensornetworks/test_solvers/test_dmrg.jl @@ -1,9 +1,31 @@ -using ITensors -using ITensorNetworks -using Dictionaries -using Random -using Test -using Observers +@eval module $(gensym()) +using DataGraphs: edge_data, vertex_data +using Dictionaries: Dictionary +using Graphs: nv, vertices +using ITensors: ITensors +using ITensors.ITensorMPS: MPO, MPS, randomMPS +using ITensorNetworks: + ITensorNetworks, + OpSum, + TTN, + apply, + dmrg, + inner, + linkdims, + mpo, + random_mps, + random_ttn, + relabel_sites, + siteinds +using KrylovKit: eigsolve +using NamedGraphs: named_comb_tree +using Observers: observer +using Test: @test, @test_broken, @testset + +# This is needed since `eigen` is broken +# if there are no QNs and auto-fermion +# is enabled. +ITensors.disable_auto_fermion() @testset "MPS DMRG" for nsites in [1, 2] N = 10 @@ -261,5 +283,4 @@ end @test all(edge_data(linkdims(psi)) .<= maxdim) end - -nothing +end diff --git a/test/test_treetensornetworks/test_solvers/test_dmrg_x.jl b/test/test_treetensornetworks/test_solvers/test_dmrg_x.jl index 18c90539..505a4775 100644 --- a/test/test_treetensornetworks/test_solvers/test_dmrg_x.jl +++ b/test/test_treetensornetworks/test_solvers/test_dmrg_x.jl @@ -1,7 +1,23 @@ -using ITensors -using ITensorNetworks -using Random -using Test +@eval module $(gensym()) +using Graphs: nv +using ITensorNetworks: + ITensorNetworks, + OpSum, + TTN, + apply, + contract, + dmrg_x, + inner, + linkdims, + mpo, + mps, + random_mps, + siteinds +using ITensors: @disable_warn_order, array, dag, onehot, uniqueind +using LinearAlgebra: eigen, normalize +using NamedGraphs: named_comb_tree +using Random: Random +using Test: @test, @testset @testset "MPS DMRG-X" for conserve_qns in (false, true) n = 10 @@ -48,7 +64,7 @@ end # TODO: Use `TTN(s; states=v -> rand(["↑", "↓"]))` or # `ttns(s; states=v -> rand(["↑", "↓"]))` - ψ = normalize!(TTN(s, v -> rand(["↑", "↓"]))) + ψ = normalize(TTN(s, v -> rand(["↑", "↓"]))) dmrg_x_kwargs = (nsweeps=20, normalize=true, maxdim=20, cutoff=1e-10, outputlevel=0) @@ -76,5 +92,4 @@ end @test inner(ϕ', H, ϕ) ≈ (dag(U_exact') * T * U_exact)[] atol = 1e-6 @test abs(inner(U_dmrgx, U_exact)) ≈ 1 atol = 1e-6 end - -nothing +end diff --git a/test/test_treetensornetworks/test_solvers/test_linsolve.jl b/test/test_treetensornetworks/test_solvers/test_linsolve.jl index 168471bb..cb2af561 100644 --- a/test/test_treetensornetworks/test_solvers/test_linsolve.jl +++ b/test/test_treetensornetworks/test_solvers/test_linsolve.jl @@ -1,7 +1,8 @@ -using ITensors -using ITensorNetworks -using Test -using Random +@eval module $(gensym()) +using ITensorNetworks: ITensorNetworks, OpSum, apply, dmrg, inner, mpo, random_mps, siteinds +using KrylovKit: linsolve +using Random: Random +using Test: @test, @test_broken, @testset @testset "Linsolve" begin @testset "Linsolve Basics" begin @@ -51,5 +52,4 @@ using Random # @test norm(x - x_c) < 1E-3 end end - -nothing +end diff --git a/test/test_ttno.jl b/test/test_ttno.jl index 213d16ac..f134cf20 100644 --- a/test/test_ttno.jl +++ b/test/test_ttno.jl @@ -1,7 +1,11 @@ -using Test -using ITensorNetworks -using ITensors -using Random +@eval module $(gensym()) +using Graphs: vertices +using ITensorNetworks: TTN, contract, ortho_center, siteinds, union_all_inds +using ITensors: @disable_warn_order, prime, randomITensor +using LinearAlgebra: norm +using NamedGraphs: named_comb_tree +using Random: shuffle +using Test: @test, @testset @testset "TTN operator Basics" begin @@ -49,3 +53,4 @@ using Random # TODO end end +end diff --git a/test/test_ttns.jl b/test/test_ttns.jl index b3a9fb76..81bc9760 100644 --- a/test/test_ttns.jl +++ b/test/test_ttns.jl @@ -1,7 +1,12 @@ -using Test -using ITensorNetworks -using ITensors -using Random +@eval module $(gensym()) +using DataGraphs: vertex_data +using Graphs: vertices +using ITensorNetworks: TTN, contract, ortho_center, siteinds +using ITensors: @disable_warn_order, randomITensor +using LinearAlgebra: norm +using NamedGraphs: named_comb_tree +using Random: shuffle +using Test: @test, @testset @testset "TTN Basics" begin @@ -47,3 +52,4 @@ using Random # TODO end end +end