MCPcopy Create free account
hub / github.com/danijar/dreamerv3 / SampleTreeNode

Class SampleTreeNode

embodied/core/selectors.py:309–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307
308
309class SampleTreeNode:
310
311 __slots__ = ('parent', 'children', 'uprob')
312
313 def __init__(self, parent=None):
314 self.parent = parent
315 self.children = []
316 self.uprob = 0
317
318 def __repr__(self):
319 return (
320 f'SampleTreeNode(uprob={self.uprob}, '
321 f'children={[x.uprob for x in self.children]})'
322 )
323
324 def __len__(self):
325 return len(self.children)
326
327 def __bool__(self):
328 return True
329
330 def append(self, child):
331 if child.parent:
332 child.parent.remove(child)
333 child.parent = self
334 self.children.append(child)
335 self.recompute()
336
337 def remove(self, child):
338 child.parent = None
339 self.children.remove(child)
340 self.recompute()
341
342 def recompute(self):
343 self.uprob = sum(x.uprob for x in self.children)
344 self.parent and self.parent.recompute()
345
346
347class SampleTreeEntry:

Callers 2

__init__Method · 0.85
insertMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected