2121import h5py
2222
2323#pylint: disable=useless-import-alias
24- import tensornetwork .config as config
2524from tensornetwork import ops
2625from tensornetwork .backends import backend_factory
2726from tensornetwork .backends .base_backend import BaseBackend
27+ from tensornetwork .backend_contextmanager import get_default_backend
2828
2929string_type = h5py .special_dtype (vlen = str )
3030Tensor = Any
@@ -525,8 +525,8 @@ def __init__(self,
525525 """Create a node.
526526
527527 Args:
528- tensor: The concrete that is represented by this node, or a `BaseNode`
529- object. If a tensor is passed, it can be
528+ tensor: The concrete that is represented by this node, or a `BaseNode`
529+ object. If a tensor is passed, it can be
530530 be either a numpy array or the tensor-type of the used backend.
531531 If a `BaseNode` is passed, the passed node has to have the same \
532532 backend as given by `backend`.
@@ -543,7 +543,7 @@ def __init__(self,
543543 backend = tensor .backend
544544 tensor = tensor .tensor
545545 if not backend :
546- backend = config . default_backend
546+ backend = get_default_backend ()
547547 if isinstance (backend , BaseBackend ):
548548 backend_obj = backend
549549 else :
@@ -633,13 +633,13 @@ def __init__(self,
633633 backend: An optional backend for the node. If `None`, a default
634634 backend is used
635635 dtype: The dtype used to initialize a numpy-copy node.
636- Note that this dtype has to be a numpy dtype, and it has to be
636+ Note that this dtype has to be a numpy dtype, and it has to be
637637 compatible with the dtype of the backend, e.g. for a tensorflow
638638 backend with a tf.Dtype=tf.floa32, `dtype` has to be `np.float32`.
639639 """
640640
641641 if not backend :
642- backend = config . default_backend
642+ backend = get_default_backend ()
643643 backend_obj = backend_factory .get_backend (backend )
644644
645645 self .rank = rank
@@ -1092,14 +1092,14 @@ def disconnect(self,
10921092 edge2_name : Optional [Text ] = None ) -> Tuple ["Edge" , "Edge" ]:
10931093 """
10941094 Break an existing non-dangling edge.
1095- This updates both Edge.node1 and Edge.node2 by removing the
1095+ This updates both Edge.node1 and Edge.node2 by removing the
10961096 connecting edge from `Edge.node1.edges` and `Edge.node2.edges`
10971097 and adding new dangling edges instead
10981098 Args:
10991099 edge1_name: A name for the new dangling edge at `self.node1`
11001100 edge2_name: A name for the new dangling edge at `self.node2`
11011101 Returns:
1102- (new_edge1, new_edge2): The new `Edge` objects of
1102+ (new_edge1, new_edge2): The new `Edge` objects of
11031103 `self.node1` and `self.node2`
11041104 """
11051105 if self .is_dangling ():
@@ -1155,7 +1155,7 @@ def get_parallel_edges(edge: Edge) -> Set[Edge]:
11551155 edge: The given edge.
11561156
11571157 Returns:
1158- A `set` of all of the edges parallel to the given edge
1158+ A `set` of all of the edges parallel to the given edge
11591159 (including the given edge).
11601160 """
11611161 return get_shared_edges (edge .node1 , edge .node2 )
@@ -1389,8 +1389,8 @@ def split_edge(edge: Edge,
13891389 shape : Tuple [int , ...],
13901390 new_edge_names : Optional [List [Text ]] = None ) -> List [Edge ]:
13911391 """Split an `Edge` into multiple edges according to `shape`. Reshapes
1392- the underlying tensors connected to the edge accordingly.
1393-
1392+ the underlying tensors connected to the edge accordingly.
1393+
13941394 This method acts as the inverse operation of flattening edges and
13951395 distinguishes between the following edge cases when adding new edges:
13961396 1) standard edge connecting two different nodes: reshape node dimensions
@@ -1772,7 +1772,7 @@ def disconnect(edge,
17721772 edge2_name : Optional [Text ] = None ) -> Tuple [Edge , Edge ]:
17731773 """
17741774 Break an existing non-dangling edge.
1775- This updates both Edge.node1 and Edge.node2 by removing the
1775+ This updates both Edge.node1 and Edge.node2 by removing the
17761776 connecting edge from `Edge.node1.edges` and `Edge.node2.edges`
17771777 and adding new dangling edges instead
17781778 """
@@ -1894,9 +1894,9 @@ def outer_product_final_nodes(nodes: Iterable[BaseNode],
18941894 edge_order : List [Edge ]) -> BaseNode :
18951895 """Get the outer product of `nodes`
18961896
1897- For example, if there are 3 nodes remaining in `nodes` with
1897+ For example, if there are 3 nodes remaining in `nodes` with
18981898 shapes :math:`(2, 3)`, :math:`(4, 5, 6)`, and :math:`(7)`
1899- respectively, the newly returned node will have shape
1899+ respectively, the newly returned node will have shape
19001900 :math:`(2, 3, 4, 5, 6, 7)`.
19011901
19021902 Args:
0 commit comments