Skip to content

Commit 471067e

Browse files
committed
moved __len__ method from array to potential, following moving size() method
1 parent 84b6d62 commit 471067e

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

brml/array.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import copy
22
import numpy as np
3-
from brml.utilities import isvector
43
from brml.potential import Potential
54

65

@@ -16,15 +15,6 @@ def __init__(self, variables=np.array([]), table=np.array([])):
1615
# Instantiate Potential class.
1716
super().__init__(variables, table)
1817

19-
def __len__(self):
20-
"""
21-
Overwrites the behavior of the __len__ call (for instance len(Array).
22-
When calling len(Array) it is equivalent to just call Array.size()
23-
:return: Number of states in the Array's table
24-
:rtype: numpy.array
25-
"""
26-
return self.size()
27-
2818
def to_logarray(self):
2919
"""
3020
This function converts Array to a LogArray. At the moment the LogArray

brml/potential.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ def __repr__(self) -> str:
5353
self.variables, self.table)
5454
return s
5555

56+
def __len__(self):
57+
"""
58+
Overwrites the behavior of the __len__ call (for instance len(Array).
59+
When calling len(Array) it is equivalent to just call Array.size()
60+
:return: Number of states in the Array's table
61+
:rtype: numpy.array
62+
"""
63+
return self.size()
64+
5665
@staticmethod
5766
def _check_variables(variables):
5867
"""

0 commit comments

Comments
 (0)