File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,6 @@ cdef class ObjectState(State):
74
74
""" __setitem__(self, attr, value)
75
75
Sets the attribute `attr` to the given value."""
76
76
self .attributes[attr] = value
77
- self ._hashcache = - 1
78
77
79
78
def __len__ (self ):
80
79
return len (self .attributes)
@@ -109,10 +108,10 @@ cdef class OOState(State):
109
108
110
109
@property
111
110
def situation (self ):
112
- """ situation(self )
111
+ """ situation(selppf )
113
112
This is a `frozenset` which can be used to identify
114
113
the situation of this state since it supports hashing."""
115
- return self ._situation
114
+ return frozenset ( self .object_states.items())
116
115
117
116
def __str__ (self ):
118
117
return ' %s ::[%s ]' % (str (self .__class__.__name__ ),
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ def test_hashing_pickling():
21
21
objstate3 = objstate1 .copy ()
22
22
assert hash (objstate3 ) == hash (objstate1 )
23
23
objstate3 ["color" ] = "green"
24
- assert hash (objstate3 ) != hash (objstate1 )
24
+ # hashcode should be kept constant after the object's creation
25
+ assert hash (objstate3 ) == hash (objstate1 )
25
26
assert objstate3 != objstate1
26
27
27
28
oos1 = pomdp_py .OOState ({1 :objstate1 , 2 :objstate2 })
You can’t perform that action at this time.
0 commit comments