Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed May 21, 2024
1 parent 0123b7b commit ef0a794
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/abstractitensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ is_getindex_expr(x) = false
is_assignment_expr(expr::Expr) = (expr.head === :(=))
is_assignment_expr(expr) = false

# TODO: Define this in terms of a function mapping
# preserve_graph_function(::typeof(setindex!)) = setindex!_preserve_graph
# preserve_graph_function(::typeof(map_vertex_data)) = map_vertex_data_preserve_graph
# Also allow annotating codeblocks like `@views`.
macro preserve_graph(expr)
if !is_setindex!_expr(expr)
error(
Expand Down Expand Up @@ -390,6 +394,7 @@ function map_vertex_data(f, tn::AbstractITensorNetwork)
return tn
end

# TODO: Define `@preserve_graph map_vertex_data(f, tn)`
function map_vertex_data_preserve_graph(f, tn::AbstractITensorNetwork)
tn = copy(tn)
for v in vertices(tn)
Expand All @@ -399,10 +404,12 @@ function map_vertex_data_preserve_graph(f, tn::AbstractITensorNetwork)
end

function Base.conj(tn::AbstractITensorNetwork)
# TODO: Use `@preserve_graph map_vertex_data(f, tn)`
return map_vertex_data_preserve_graph(conj, tn)
end

function ITensors.dag(tn::AbstractITensorNetwork)
# TODO: Use `@preserve_graph map_vertex_data(f, tn)`
return map_vertex_data_preserve_graph(dag, tn)
end

Expand Down

0 comments on commit ef0a794

Please sign in to comment.