Skip to content

Commit 80bd6c9

Browse files
committed
#53 Rename class
1 parent 3dd34d8 commit 80bd6c9

File tree

2 files changed

+71
-86
lines changed

2 files changed

+71
-86
lines changed

src/spaces/state.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
"""
2+
Discretized state space
3+
"""
4+
5+
from typing import TypeVar, List, Any
6+
from src.exceptions.exceptions import Error
7+
8+
ActionStatus = TypeVar("ActionStatus")
9+
Env = TypeVar("Env")
10+
11+
12+
class StateIterator(object):
13+
"""
14+
StateIterator class. Helper class to iterate over the
15+
columns of a State object
16+
"""
17+
18+
def __init__(self, values: List):
19+
self.current_position = 0
20+
self.values = values
21+
22+
@property
23+
def at(self) -> Any:
24+
"""
25+
Returns the value of the iterator at the current position
26+
without incrementing the position of the iterator
27+
:return: Any
28+
"""
29+
return self.values[self.current_position]
30+
31+
@property
32+
def finished(self) -> bool:
33+
"""
34+
Returns true if the iterator is exhausted
35+
:return:
36+
"""
37+
return self.current_position >= len(self.values)
38+
39+
def __next__(self):
40+
41+
if self.current_position < len(self.values):
42+
result = self.values[self.current_position]
43+
self.current_position += 1
44+
return result
45+
46+
raise StopIteration
47+
48+
def __len__(self):
49+
"""
50+
Returns the total number of items in the iterator
51+
:return:
52+
"""
53+
return len(self.values)
54+
55+
56+
class State(object):
57+
"""
58+
Helper to represent a State
59+
"""
60+
def __init__(self):
61+
self.idx = -1
62+
self.total_distortion: float = 0.0
63+
self.column_names = []
64+
65+
def __contains__(self, item) -> bool:
66+
return item in self.column_names
67+
68+
def __iter__(self):
69+
return StateIterator(self.column_names)
70+
71+

src/spaces/state_space.py

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)