-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
opencog::attentionbank(AtomSpace* asp) method in AttentionBank has the following check to compare if two AtomSpaces are equal:
This can fail if one AtomSpace is deleted and immediately after that the second one is created.
because the the new AtomSpace can be created with the same memory address as the previous one.
I encountered it in the Python test that can or can't fail depending with each address the new AtomSpace is created:
(note that the opencog/opencog#3549 pull request is required to run the test)
import unittest
from unittest import TestCase
from opencog.type_constructors import *
from opencog.utilities import initialize_opencog, finalize_opencog
from opencog.bank import AttentionBank, af_bindlink
class AttentionBankTest(TestCase):
def setUp(self):
self.atomspace = AtomSpace()
initialize_opencog(self.atomspace)
def tearDown(self):
finalize_opencog()
del self.atomspace
def test_get_handles_by_av_different_as1(self):
attention_bank = AttentionBank(self.atomspace)
node1 = ConceptNode("node1")
attention_bank.set_sti(node1, 2.0)
atoms = attention_bank.get_atoms_by_av(1.0, 4.0)
self.assertEqual(1, len(atoms))
def test_get_handles_by_av_different_as2(self):
attention_bank = AttentionBank(self.atomspace)
node2 = ConceptNode("node2")
attention_bank.set_sti(node2, 2.0)
atoms = attention_bank.get_atoms_by_av(1.0, 4.0)
self.assertEqual(1, len(atoms))
if __name__ == '__main__':
unittest.main()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels