22
22
class State :
23
23
"""Base class for all states."""
24
24
25
- def __init__ (self , name : str , initial_value : Any ):
25
+ def __init__ (self , initial_value : Any ):
26
26
"""Create a new state."""
27
- self .name = name
28
27
self ._value = initial_value
29
28
self ._last_update_time = 0
30
29
self .model = None # Set when state is added to agent
@@ -61,12 +60,11 @@ class ContinuousState(State):
61
60
62
61
def __init__ (
63
62
self ,
64
- name : str ,
65
63
initial_value : float ,
66
64
rate_function : Callable [[float , float ], float ],
67
65
):
68
66
"""Create a new continuous state."""
69
- super ().__init__ (name , initial_value )
67
+ super ().__init__ (initial_value )
70
68
self .rate_function = rate_function
71
69
72
70
@property
@@ -89,14 +87,13 @@ class CompositeState(State):
89
87
90
88
def __init__ (
91
89
self ,
92
- name : str ,
93
90
dependent_states : list [State ],
94
91
computation_function : Callable [..., Any ],
95
92
):
96
93
"""Create a new composite state."""
97
94
self .dependent_states = dependent_states
98
95
self .computation_function = computation_function
99
- super ().__init__ (name , None ) # Value computed on first access
96
+ super ().__init__ (None ) # Value computed on first access
100
97
101
98
@property
102
99
def value (self ) -> Any :
@@ -144,11 +141,6 @@ def __setattr__(self, name: str, value: Any) -> None:
144
141
states = object .__getattribute__ (self , "states" )
145
142
# If setting a State object, add or update the states dictionary
146
143
if isinstance (value , State ):
147
- # The state's name should match the attribute name
148
- if value .name != name :
149
- raise ValueError (
150
- f"State name '{ value .name } ' does not match attribute name '{ name } '"
151
- )
152
144
states [name ] = value
153
145
value .model = self .model
154
146
else :
0 commit comments