Skip to content

Commit

Permalink
Hotfixes for WeightedParticles (#64)
Browse files Browse the repository at this point in the history
* pass frozen when condense

* bug fix: cannot access private _hist of other
  • Loading branch information
kaiyu-zheng authored Mar 29, 2024
1 parent 757e51a commit e6ea846
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pomdp_py/representations/distribution/particles.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ cdef class WeightedParticles(GenerativeDistribution):
def frozen(self):
return self._frozen

@property
def hist(self):
return self._hist

@property
def hist_valid(self):
return self._hist_valid

def add(self, particle):
"""add(self, particle)
particle: (value, weight) tuple"""
Expand All @@ -77,7 +85,7 @@ cdef class WeightedParticles(GenerativeDistribution):

def __eq__(self, other):
if isinstance(other, WeightedParticles):
return self._hist == other._hist
return self._hist == other.hist
return False

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


cdef class Particles(WeightedParticles):
Expand Down

0 comments on commit e6ea846

Please sign in to comment.