Skip to content

Commit

Permalink
move some attributes to properties
Browse files Browse the repository at this point in the history
  • Loading branch information
meandmytram committed Oct 26, 2023
1 parent d5027e4 commit 106ff48
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions mdopt/mps/explicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ def __init__(
self.tensors = tensors
self.num_sites = len(tensors)
self.num_bonds = self.num_sites - 1
self.bond_dimensions = [
self.tensors[i].shape[-1] for i in range(self.num_bonds)
]
self.phys_dimensions = [self.tensors[i].shape[1] for i in range(self.num_sites)]
self.singular_values = singular_values
self.num_singval_mat = len(singular_values)
self.dtype = tensors[0].dtype
Expand Down Expand Up @@ -105,6 +101,20 @@ def __init__(
f"instead the norm is {norm} at bond {i + 1}."
)

@property
def bond_dimensions(self) -> List[int]:
"""
Returns the list of all bond dimensions of the MPS.
"""
return [self.tensors[i].shape[-1] for i in range(self.num_bonds)]

@property
def phys_dimensions(self) -> List[int]:
"""
Returns the list of all physical dimensions of the MPS.
"""
return [self.tensors[i].shape[1] for i in range(self.num_sites)]

def __len__(self) -> int:
"""
Returns the number of sites in the MPS.
Expand All @@ -130,7 +140,7 @@ def copy(self) -> "ExplicitMPS":

def reverse(self) -> "ExplicitMPS":
"""
Returns a reversed version of a given MPS.
Returns a reversed version of the current MPS.
"""

reversed_tensors = list(np.transpose(t) for t in reversed(self.tensors))
Expand Down

0 comments on commit 106ff48

Please sign in to comment.