OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-rocca commits / 439c9bb

Fix load_percepta_atomspace
439c9bb6ecdd2ffcfcadbd86b4a7ea6e9e27d7e3
by Nil Geisweiller <ngeiswei@gmail.com> · 2022-05-20T13:29:13.000Z

Changed files (1) +12 -5

rocca/agents/core.py +12 -5
……@@ -306,7 +306,7 @@ class OpencogAgent:
306306 ]
307307 return "\n".join(ss)
308308
309 def insert_to_percepta_record(self, timed_atom: Atom, i: int) -> None:
309 def insert_to_percepta_record(self, timed_atom: Atom, i: int = -1) -> None:
310310 """Insert a timestamped atom into self.percepta_record.
311311
312312 The percepta_record is a list of sets of timestamped percepta.
……@@ -314,8 +314,14 @@ class OpencogAgent:
314314 list is a set of percepta at the timestamp corresponding to
315315 its index.
316316
317 If it's index i is not provided (or is negative), then it is
318 extracted from the timestamp.
319
317320 """
318321
322 if i < 0:
323 i = to_int(get_time(timed_atom))
324
319325 while len(self.percepta_record) <= i:
320326 self.percepta_record.append(set())
321327 self.percepta_record[i].add(timed_atom)
……@@ -1680,12 +1686,13 @@ class OpencogAgent:
16801686
16811687 success = load_atomspace(self.percepta_atomspace, filepath, overwrite)
16821688 if success:
1683 pas_roots = atomspace_roots(self.percepta_atomspace)
16841689 if overwrite:
16851690 self.percepta_record.clear()
1686 print("TODO")
1687 # NEXT: take care of filling the percepta record
1688 # NEXT: update the cycle count as well
1691 pas_roots = atomspace_roots(self.percepta_atomspace)
1692 for mbr in pas_roots:
1693 self.insert_to_percepta_record(mbr.out[0])
1694 new_count = len(self.percepta_record)
1695 self.cycle_count = new_count - 1 if 0 < new_count else 0
16891696 return success
16901697
16911698 def save_cogscms_atomspace(self, filepath: str, overwrite: bool = True) -> bool: