Repository: google/TensorNetwork

Issue:
split_node_... routines crash during the second call 
The following code crashes
```python 
import tensornetwork as tn
import numpy as np
tn.set_default_backend('tensorflow')
node1=tn.Node(np.random.rand(10,2,10))
tn.split_node_full_svd(node1,[node1[0], node1[1]], [node1[2]])
tn.split_node_full_svd(node1,[node1[0], node1[1]], [node1[2]]) #this raises a ValueError
```
with 
`ValueError: Edge 'Dangling_0' did not contain node '__unnamed_node__' on axis 0. node1: '__unnamed_node__', axis1: 0, node2: 'None', axis2: None`

The same is true for `split_node_qr` and `split_node_rq`. `split_node` is working though. Seems like a bug.


Discussion:
This is expected behavior. The edges get reset on `node1` after the split call.
but why is it then crashing? The input to `split_node_full_svd` in the second line is just a regular `Node`, i.e. `node1` with three normal, dangling `Edge`s.
In any case, the behaviour is inconsistent since `split_node` works fine. I'll check what's going on.
Oh I see. Hm yeah that's strange. Let me look into it.
found it. I had forgotten to call `node.fresh_edges` at the end out the routines. I'll make a fix

Resolving patch:
diff --git a/tensornetwork/network_operations.py b/tensornetwork/network_operations.py
--- a/tensornetwork/network_operations.py
+++ b/tensornetwork/network_operations.py
@@ -98,10 +98,7 @@ def transpose(node: BaseNode,
     axis_names = node.axis_names
 
   new_node = Node(
-      node.tensor,
-      name=name,
-      axis_names=node.axis_names,
-      backend=node.backend)
+      node.tensor, name=name, axis_names=node.axis_names, backend=node.backend)
   return new_node.reorder_axes(perm)
 
 
@@ -289,10 +286,12 @@ def split_node(
   backend = node.backend
   node.reorder_edges(left_edges + right_edges)
 
-  u, s, vh, trun_vals = backend.svd_decomposition(node.tensor, len(left_edges),
-                                                  max_singular_values,
-                                                  max_truncation_err,
-                                                  relative=relative)
+  u, s, vh, trun_vals = backend.svd_decomposition(
+      node.tensor,
+      len(left_edges),
+      max_singular_values,
+      max_truncation_err,
+      relative=relative)
   sqrt_s = backend.sqrt(s)
   u_s = u * sqrt_s
   # We have to do this since we are doing element-wise multiplication against
@@ -389,6 +388,7 @@ def split_node_qr(
     right_node.add_edge(edge, i + 1)
     edge.update_axis(i + len(left_edges), node, i + 1, right_node)
   connect(left_node.edges[-1], right_node.edges[0], name=edge_name)
+  node.fresh_edges(node.axis_names)
   return left_node, right_node
 
 
@@ -463,6 +463,7 @@ def split_node_rq(
     right_node.add_edge(edge, i + 1)
     edge.update_axis(i + len(left_edges), node, i + 1, right_node)
   connect(left_node.edges[-1], right_node.edges[0], name=edge_name)
+  node.fresh_edges(node.axis_names)
   return left_node, right_node
 
 
@@ -566,10 +567,12 @@ def split_node_full_svd(
   backend = node.backend
 
   node.reorder_edges(left_edges + right_edges)
-  u, s, vh, trun_vals = backend.svd_decomposition(node.tensor, len(left_edges),
-                                                  max_singular_values,
-                                                  max_truncation_err,
-                                                  relative=relative)
+  u, s, vh, trun_vals = backend.svd_decomposition(
+      node.tensor,
+      len(left_edges),
+      max_singular_values,
+      max_truncation_err,
+      relative=relative)
   left_node = Node(
       u, name=left_name, axis_names=left_axis_names, backend=backend)
   singular_values_node = Node(
@@ -592,6 +595,7 @@ def split_node_full_svd(
       left_node.edges[-1], singular_values_node.edges[0], name=left_edge_name)
   connect(
       singular_values_node.edges[1], right_node.edges[0], name=right_edge_name)
+  node.fresh_edges(node.axis_names)
   return left_node, singular_values_node, right_node, trun_vals
 
 


Test patch: