Skip to content

Commit e6ea846

Browse files
authored
Hotfixes for WeightedParticles (#64)
* pass frozen when condense * bug fix: cannot access private _hist of other
1 parent 757e51a commit e6ea846

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pomdp_py/representations/distribution/particles.pyx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ cdef class WeightedParticles(GenerativeDistribution):
5353
def frozen(self):
5454
return self._frozen
5555

56+
@property
57+
def hist(self):
58+
return self._hist
59+
60+
@property
61+
def hist_valid(self):
62+
return self._hist_valid
63+
5664
def add(self, particle):
5765
"""add(self, particle)
5866
particle: (value, weight) tuple"""
@@ -77,7 +85,7 @@ cdef class WeightedParticles(GenerativeDistribution):
7785

7886
def __eq__(self, other):
7987
if isinstance(other, WeightedParticles):
80-
return self._hist == other._hist
88+
return self._hist == other.hist
8189
return False
8290

8391
def __getitem__(self, value):
@@ -161,7 +169,7 @@ cdef class WeightedParticles(GenerativeDistribution):
161169
Returns a new set of weighted particles with unique values
162170
and weights aggregated (taken average).
163171
"""
164-
return WeightedParticles.from_histogram(self.get_histogram())
172+
return WeightedParticles.from_histogram(self.get_histogram(), frozen=self._frozen)
165173

166174

167175
cdef class Particles(WeightedParticles):

0 commit comments

Comments
 (0)