File tree Expand file tree Collapse file tree 2 files changed +19
-20
lines changed Expand file tree Collapse file tree 2 files changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -34,26 +34,6 @@ class is not implemented.
34
34
# TODO: See if LogArray class is needed or this is enough.
35
35
return Array (variables = self .variables , table = np .log (self .table ))
36
36
37
- def size (self ):
38
- """
39
- Finds the number of states of the Array potential.
40
- At the moment this method calculates the number of states as follows:
41
- 1. Table 1D (vector) -> length of vector
42
- 2. Table 2D but one dimension has length 1 (e.g. (1, 2)) -> max
43
- of both dimensions (e.g. max(1, 2) = 2)
44
- 3. Table multidimensional but actually a vector - length vector
45
- 4. Table multidimensional -> return shape of table
46
- TODO: Consider moving this method to Potential superclass.
47
- TODO: Consider adding a __len__ method.
48
- Notice that it returns a numpy array even if table is a 1D vector.
49
- :return: Number of states in the table for each variable.
50
- :rtype: numpy.array
51
- """
52
- if isvector (self .table ):
53
- return np .array ([len (self .table )]).astype (np .int8 )
54
- else :
55
- return np .array (self .table .shape ).astype (np .int8 )
56
-
57
37
def sum (self , variables ):
58
38
"""
59
39
This method sums the probability table over provided variables. It is
Original file line number Diff line number Diff line change @@ -169,6 +169,25 @@ def set_table(self, table):
169
169
"""
170
170
self .table = self ._check_table (table )
171
171
172
+ def size (self ):
173
+ """
174
+ Finds the number of states of the Array potential.
175
+ At the moment this method calculates the number of states as follows:
176
+ 1. Table 1D (vector) -> length of vector
177
+ 2. Table 2D but one dimension has length 1 (e.g. (1, 2)) -> max
178
+ of both dimensions (e.g. max(1, 2) = 2)
179
+ 3. Table multidimensional but actually a vector - length vector
180
+ 4. Table multidimensional -> return shape of table
181
+ TODO: Consider adding a __len__ method.
182
+ Notice that it returns a numpy array even if table is a 1D vector.
183
+ :return: Number of states in the table for each variable.
184
+ :rtype: numpy.array
185
+ """
186
+ if isvector (self .table ):
187
+ return np .array ([len (self .table )]).astype (np .int8 )
188
+ else :
189
+ return np .array (self .table .shape ).astype (np .int8 )
190
+
172
191
173
192
if __name__ == "__main__" :
174
193
VARIABLES = 1
You can’t perform that action at this time.
0 commit comments