Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ITensorNetworksNext"
uuid = "302f2e75-49f0-4526-aef7-d8ba550cb06c"
version = "0.3.8"
version = "0.3.9"
authors = ["ITensor developers <support@itensor.org> and contributors"]

[workspace]
Expand Down
9 changes: 5 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ITensorNetworksNext: ITensorNetworksNext
using Documenter: Documenter, DocMeta, deploydocs, makedocs
using ITensorNetworksNext: ITensorNetworksNext

DocMeta.setdocmeta!(
ITensorNetworksNext, :DocTestSetup, :(using ITensorNetworksNext); recursive = true
Expand All @@ -14,11 +14,12 @@ makedocs(;
format = Documenter.HTML(;
canonical = "https://itensor.github.io/ITensorNetworksNext.jl",
edit_link = "main",
assets = ["assets/favicon.ico", "assets/extras.css"],
assets = ["assets/favicon.ico", "assets/extras.css"]
),
pages = ["Home" => "index.md", "Reference" => "reference.md"],
pages = ["Home" => "index.md", "Reference" => "reference.md"]
)

deploydocs(;
repo = "github.com/ITensor/ITensorNetworksNext.jl", devbranch = "main", push_preview = true
repo = "github.com/ITensor/ITensorNetworksNext.jl", devbranch = "main",
push_preview = true
)
4 changes: 2 additions & 2 deletions docs/make_index.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Literate: Literate
using ITensorNetworksNext: ITensorNetworksNext
using Literate: Literate

function ccq_logo(content)
include_ccq_logo = """
Expand All @@ -17,5 +17,5 @@ Literate.markdown(
joinpath(pkgdir(ITensorNetworksNext), "docs", "src");
flavor = Literate.DocumenterFlavor(),
name = "index",
postprocess = ccq_logo,
postprocess = ccq_logo
)
4 changes: 2 additions & 2 deletions docs/make_readme.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Literate: Literate
using ITensorNetworksNext: ITensorNetworksNext
using Literate: Literate

function ccq_logo(content)
include_ccq_logo = """
Expand All @@ -17,5 +17,5 @@ Literate.markdown(
joinpath(pkgdir(ITensorNetworksNext));
flavor = Literate.CommonMarkFlavor(),
name = "README",
postprocess = ccq_logo,
postprocess = ccq_logo
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module ITensorNetworksNextTensorOperationsExt

using BackendSelection: @Algorithm_str, Algorithm
using ITensorNetworksNext.LazyNamedDimsArrays: LazyNamedDimsArrays, ismul, symnameddims,
substitute
using ITensorNetworksNext.LazyNamedDimsArrays.TermInterface: arguments
using ITensorNetworksNext.LazyNamedDimsArrays:
LazyNamedDimsArrays, ismul, substitute, symnameddims
using NamedDimsArrays: inds
using TensorOperations: TensorOperations, optimaltree

Expand Down
25 changes: 12 additions & 13 deletions src/AlgorithmsInterfaceExtensions/AlgorithmsInterfaceExtensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module AlgorithmsInterfaceExtensions

import AlgorithmsInterface as AI

#========================== Patches for AlgorithmsInterface.jl ============================#
# ========================== Patches for AlgorithmsInterface.jl ============================

abstract type Problem <: AI.Problem end
abstract type Algorithm <: AI.Algorithm end
Expand Down Expand Up @@ -30,7 +30,7 @@ function AI.initialize_state(
return DefaultState(; stopping_criterion_state, kwargs...)
end

#============================ DefaultState ================================================#
# ============================ DefaultState ================================================

@kwdef mutable struct DefaultState{
Iterate, StoppingCriterionState <: AI.StoppingCriterionState,
Expand All @@ -40,14 +40,13 @@ end
stopping_criterion_state::StoppingCriterionState
end

#============================ increment! ==================================================#
# ============================ increment! ==================================================

# Custom version of `increment!` that also takes the problem and algorithm as arguments.
function AI.increment!(problem::Problem, algorithm::Algorithm, state::State)
return AI.increment!(state)
end

#============================ solve! ======================================================#
# ============================ solve! ======================================================

# Custom version of `solve!` that allows specifying the logger and also overloads
# `increment!` on the problem and algorithm.
Expand All @@ -58,13 +57,13 @@ default_logging_context_prefix(x) = Symbol(basetypenameof(x), :_)
function default_logging_context_prefix(problem::Problem, algorithm::Algorithm)
return Symbol(
default_logging_context_prefix(problem),
default_logging_context_prefix(algorithm),
default_logging_context_prefix(algorithm)
)
end
function AI.solve!(
problem::Problem, algorithm::Algorithm, state::State;
logging_context_prefix = default_logging_context_prefix(problem, algorithm),
kwargs...,
kwargs...
)
logger = AI.algorithm_logger()

Expand Down Expand Up @@ -97,13 +96,13 @@ end
function AI.solve(
problem::Problem, algorithm::Algorithm;
logging_context_prefix = default_logging_context_prefix(problem, algorithm),
kwargs...,
kwargs...
)
state = AI.initialize_state(problem, algorithm; kwargs...)
return AI.solve!(problem, algorithm, state; logging_context_prefix, kwargs...)
end

#============================ AlgorithmIterator ===========================================#
# ============================ AlgorithmIterator ===========================================

abstract type AlgorithmIterator end

Expand Down Expand Up @@ -138,7 +137,7 @@ struct DefaultAlgorithmIterator{Problem, Algorithm, State} <: AlgorithmIterator
state::State
end

#============================ with_algorithmlogger ========================================#
# ============================ with_algorithmlogger ========================================

# Allow passing functions, not just CallbackActions.
@inline function with_algorithmlogger(f, args::Pair{Symbol, AI.LoggingAction}...)
Expand All @@ -148,7 +147,7 @@ end
return AI.with_algorithmlogger(f, (first.(args) .=> AI.CallbackAction.(last.(args)))...)
end

#============================ NestedAlgorithm =============================================#
# ============================ NestedAlgorithm =============================================

abstract type NestedAlgorithm <: Algorithm end

Expand Down Expand Up @@ -211,7 +210,7 @@ function DefaultNestedAlgorithm(f::Function, nalgorithms::Int; kwargs...)
return DefaultNestedAlgorithm(; algorithms = f.(1:nalgorithms), kwargs...)
end

#============================ FlattenedAlgorithm ==========================================#
# ============================ FlattenedAlgorithm ==========================================

# Flatten a nested algorithm.
abstract type FlattenedAlgorithm <: Algorithm end
Expand Down Expand Up @@ -283,7 +282,7 @@ end
stopping_criterion_state::StoppingCriterionState
end

#============================ NonIterativeAlgorithm =======================================#
# ============================ NonIterativeAlgorithm =======================================

# Algorithm that only performs a single step.
abstract type NonIterativeAlgorithm <: Algorithm end
Expand Down
8 changes: 6 additions & 2 deletions src/LazyNamedDimsArrays/symbolicarray.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# TODO: Allow dynamic/unknown number of dimensions by supporting vector axes.
struct SymbolicArray{T, N, Name, Axes <: NTuple{N, AbstractUnitRange{<:Integer}}} <: AbstractArray{T, N}
struct SymbolicArray{T, N, Name, Axes <: NTuple{N, AbstractUnitRange{<:Integer}}} <:
AbstractArray{T, N}
name::Name
axes::Axes
function SymbolicArray{T}(name, ax::Tuple{Vararg{AbstractUnitRange{<:Integer}}}) where {T}
function SymbolicArray{T}(
name,
ax::Tuple{Vararg{AbstractUnitRange{<:Integer}}}
) where {T}
N = length(ax)
return new{T, N, typeof(name), typeof(ax)}(name, ax)
end
Expand Down
2 changes: 1 addition & 1 deletion src/TensorNetworkGenerators/delta_network.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ..ITensorNetworksNext: TensorNetwork
using DiagonalArrays: δ
using Graphs: AbstractGraph
using ..ITensorNetworksNext: TensorNetwork
using NamedGraphs.GraphsExtensions: incident_edges

"""
Expand Down
2 changes: 1 addition & 1 deletion src/TensorNetworkGenerators/ising_network.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ..ITensorNetworksNext: @preserve_graph
using DiagonalArrays: DiagonalArray
using Graphs: degree, dst, edges, src
using ..ITensorNetworksNext: @preserve_graph
using LinearAlgebra: Diagonal, eigen
using NamedDimsArrays: apply, denamed, name, operator, randname
using NamedGraphs.GraphsExtensions: vertextype
Expand Down
12 changes: 6 additions & 6 deletions src/abstracttensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ using BackendSelection: @Algorithm_str, Algorithm
using DataGraphs: DataGraphs, AbstractDataGraph, edge_data, underlying_graph,
underlying_graph_type, vertex_data
using Dictionaries: Dictionary
using Graphs: Graphs, AbstractEdge, AbstractGraph, Graph, add_edge!, add_vertex!,
bfs_tree, center, dst, edges, edgetype, ne, neighbors, nv, rem_edge!, src, vertices
using Graphs: Graphs, AbstractEdge, AbstractGraph, Graph, add_edge!, add_vertex!, bfs_tree,
center, dst, edges, edgetype, ne, neighbors, nv, rem_edge!, src, vertices
using LinearAlgebra: LinearAlgebra, factorize
using MacroTools: @capture
using NamedDimsArrays: dimnames, inds
using NamedGraphs.GraphsExtensions:
directed_graph, incident_edges, rem_edges!, rename_vertices, vertextype, ⊔
using NamedGraphs: NamedGraphs, NamedGraph, not_implemented, steiner_tree
using NamedGraphs.GraphsExtensions: ⊔, directed_graph, incident_edges, rem_edges!,
rename_vertices, vertextype
using SplitApplyCombine: flatten

abstract type AbstractTensorNetwork{V, VD} <: AbstractDataGraph{V, VD, Nothing} end
Expand Down Expand Up @@ -144,7 +144,7 @@ is_assignment_expr(expr) = false
macro preserve_graph(expr)
if !is_setindex!_expr(expr)
error(
"preserve_graph must be used with setindex! syntax (as @preserve_graph a[i,j,...] = value)",
"preserve_graph must be used with setindex! syntax (as @preserve_graph a[i,j,...] = value)"
)
end
@capture(expr, array_[indices__] = value_)
Expand Down Expand Up @@ -234,7 +234,7 @@ using NamedGraphs.OrdinalIndexing: OrdinalSuffixedInteger
function Base.setindex!(
tn::AbstractTensorNetwork,
value,
edge::Pair{<:OrdinalSuffixedInteger, <:OrdinalSuffixedInteger},
edge::Pair{<:OrdinalSuffixedInteger, <:OrdinalSuffixedInteger}
)
return error("No edge data.")
end
Expand Down
4 changes: 2 additions & 2 deletions src/contract_network.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using BackendSelection: @Algorithm_str, Algorithm
using Base.Broadcast: materialize
using ITensorNetworksNext.LazyNamedDimsArrays: Mul, lazy, optimize_evaluation_order,
substitute, symnameddims
using ITensorNetworksNext.LazyNamedDimsArrays:
Mul, lazy, optimize_evaluation_order, substitute, symnameddims

# This is related to `MatrixAlgebraKit.select_algorithm`.
# TODO: Define this in BackendSelection.jl.
Expand Down
2 changes: 1 addition & 1 deletion src/sweeping/eigenproblem.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AlgorithmsInterface as AI
import .AlgorithmsInterfaceExtensions as AIE
import AlgorithmsInterface as AI

function dmrg(operator, algorithm, state)
problem = EigenProblem(operator)
Expand Down
2 changes: 1 addition & 1 deletion src/tensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ using DataGraphs: DataGraphs, AbstractDataGraph, DataGraph
using Dictionaries: AbstractDictionary, Indices, dictionary
using Graphs: AbstractSimpleGraph
using NamedDimsArrays: AbstractNamedDimsArray, dimnames
using NamedGraphs: NamedGraphs, NamedEdge, NamedGraph, vertextype
using NamedGraphs.GraphsExtensions: add_edges!, arrange_edge, arranged_edges, vertextype
using NamedGraphs: NamedGraphs, NamedEdge, NamedGraph, vertextype

function _TensorNetwork end

Expand Down
15 changes: 10 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ const GROUP = uppercase(
get(ENV, "GROUP", "ALL")
else
only(match(pat, ARGS[arg_id]).captures)
end,
end
)

"match files of the form `test_*.jl`, but exclude `*setup*.jl`"
"""
match files of the form `test_*.jl`, but exclude `*setup*.jl`
"""
function istestfile(fn)
return endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
return endswith(fn, ".jl") && startswith(basename(fn), "test_") &&
!contains(fn, "setup")
end
"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
"""
match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`
"""
function isexamplefile(fn)
return endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
end
Expand Down Expand Up @@ -57,7 +62,7 @@ end
:macrocall,
GlobalRef(Suppressor, Symbol("@suppress")),
LineNumberNode(@__LINE__, @__FILE__),
:(include($filename)),
:(include($filename))
)
)
end
Expand Down
14 changes: 7 additions & 7 deletions test/test_algorithmsinterfaceextensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ end
# Test with CallbackAction (wrapped functions)
state = AIE.with_algorithmlogger(
:TestProblem_TestAlgorithm_PreStep => callback1,
:TestProblem_TestAlgorithm_PostStep => callback2,
:TestProblem_TestAlgorithm_PostStep => callback2
) do
return AI.solve(problem, algorithm; iterate = [0.0])
end
Expand Down Expand Up @@ -227,7 +227,7 @@ end
)
state = AIE.DefaultState(;
iterate = [0.0],
stopping_criterion_state = stopping_criterion_state,
stopping_criterion_state = stopping_criterion_state
)

# Test progression through iterations
Expand All @@ -253,7 +253,7 @@ end
state = AIE.DefaultState(;
iterate = [5.0, 10.0],
iteration = 1,
stopping_criterion_state,
stopping_criterion_state
)

subproblem, subalgorithm, substate = AIE.get_subproblem(problem, nested_alg, state)
Expand All @@ -264,7 +264,7 @@ end
# Test set_substate!
new_substate = AIE.DefaultState(;
iterate = [100.0, 200.0],
substate.stopping_criterion_state,
substate.stopping_criterion_state
)
AIE.set_substate!(problem, nested_alg, state, new_substate)
@test state.iterate ≈ [100.0, 200.0]
Expand Down Expand Up @@ -321,7 +321,7 @@ end

flattened_alg = AIE.DefaultFlattenedAlgorithm(;
algorithms = nested_algs,
stopping_criterion = AI.StopAfterIteration(4),
stopping_criterion = AI.StopAfterIteration(4)
)

problem = TestProblem([1.0])
Expand All @@ -330,7 +330,7 @@ end
)
state = AIE.DefaultFlattenedAlgorithmState(;
iterate = [0.0],
stopping_criterion_state = stopping_criterion_state,
stopping_criterion_state = stopping_criterion_state
)

# Test initial state
Expand Down Expand Up @@ -388,7 +388,7 @@ end
# Using the helper function
flattened_alg = AIE.flattened_algorithm(2) do i
AIE.nested_algorithm(1) do j
TestAlgorithmStep(; stopping_criterion = AI.StopAfterIteration(2))
return TestAlgorithmStep(; stopping_criterion = AI.StopAfterIteration(2))
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_aqua.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ITensorNetworksNext: ITensorNetworksNext
using Aqua: Aqua
using ITensorNetworksNext: ITensorNetworksNext
using Test: @testset

@testset "Code quality (Aqua.jl)" begin
Expand Down
2 changes: 1 addition & 1 deletion test/test_basics.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Dictionaries: Indices
using Graphs: dst, edges, has_edge, ne, nv, src, vertices
using ITensorNetworksNext: TensorNetwork, linkinds, siteinds
using ITensorBase: Index
using ITensorNetworksNext: TensorNetwork, linkinds, siteinds
using NamedDimsArrays: dimnames
using NamedGraphs.GraphsExtensions: arranged_edges, incident_edges
using NamedGraphs.NamedGraphGenerators: named_grid
Expand Down
4 changes: 2 additions & 2 deletions test/test_contract_network.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Graphs: edges
using ITensorBase: Index
using ITensorNetworksNext: TensorNetwork, contract_network, linkinds, siteinds
using NamedGraphs.GraphsExtensions: arranged_edges, incident_edges
using NamedGraphs.NamedGraphGenerators: named_grid
using ITensorBase: Index
using ITensorNetworksNext: TensorNetwork, linkinds, siteinds, contract_network
using TensorOperations: TensorOperations
using Test: @test, @testset

Expand Down
Loading
Loading