diff --git a/hyperon_das_atomdb/adapters/ram_only.py b/hyperon_das_atomdb/adapters/ram_only.py index 67047ee1..b325246b 100644 --- a/hyperon_das_atomdb/adapters/ram_only.py +++ b/hyperon_das_atomdb/adapters/ram_only.py @@ -40,7 +40,7 @@ class Database: atom_type: dict[str, Any] = dc_field(default_factory=dict) node: dict[str, AtomT] = dc_field(default_factory=dict) link: dict[str, AtomT] = dc_field(default_factory=dict) - outgoing_set: dict[str, set[str]] = dc_field(default_factory=dict) + outgoing_set: dict[str, list[str]] = dc_field(default_factory=dict) incoming_set: dict[str, set[str]] = dc_field(default_factory=dict) patterns: dict[str, set[str]] = dc_field(default_factory=dict) templates: dict[str, set[str]] = dc_field(default_factory=dict) @@ -180,7 +180,7 @@ def _add_outgoing_set(self, key: str, targets_hash: list[str]) -> None: key (str): The key for the outgoing set. targets_hash (list[str]): A list of target hashes to be added to the outgoing set. """ - self.db.outgoing_set[key] = set(targets_hash) + self.db.outgoing_set[key] = targets_hash def _get_and_delete_outgoing_set(self, handle: str) -> list[str] | None: """ @@ -192,7 +192,7 @@ def _get_and_delete_outgoing_set(self, handle: str) -> list[str] | None: Returns: list[str] | None: The outgoing set if found and deleted, otherwise None. """ - return list(self.db.outgoing_set.pop(handle)) if handle in self.db.outgoing_set else None + return self.db.outgoing_set.pop(handle, None) def _add_incoming_set(self, key: str, targets_hash: list[str]) -> None: """ diff --git a/tests/unit/adapters/test_ram_only.py b/tests/unit/adapters/test_ram_only.py index b4df70d1..3a8f7592 100644 --- a/tests/unit/adapters/test_ram_only.py +++ b/tests/unit/adapters/test_ram_only.py @@ -760,8 +760,8 @@ def test_delete_atom(self): }, } assert db.db.outgoing_set == { - inheritance_dog_mammal_handle: {dog_handle, mammal_handle}, - inheritance_cat_mammal_handle: {cat_handle, mammal_handle}, + inheritance_dog_mammal_handle: [dog_handle, mammal_handle], + inheritance_cat_mammal_handle: [cat_handle, mammal_handle], } assert db.db.templates == { "41c082428b28d7e9ea96160f7fd614ad": { @@ -904,7 +904,7 @@ def test_delete_atom(self): dog_handle: {inheritance_dog_mammal_handle}, mammal_handle: {inheritance_dog_mammal_handle}, } - assert db.db.outgoing_set == {inheritance_dog_mammal_handle: {dog_handle, mammal_handle}} + assert db.db.outgoing_set == {inheritance_dog_mammal_handle: [dog_handle, mammal_handle]} assert db.db.templates == { "41c082428b28d7e9ea96160f7fd614ad": { inheritance_dog_mammal_handle, @@ -956,7 +956,7 @@ def test_delete_atom(self): cat_handle: {inheritance_cat_mammal_handle}, mammal_handle: {inheritance_cat_mammal_handle}, } - assert db.db.outgoing_set == {inheritance_cat_mammal_handle: {cat_handle, mammal_handle}} + assert db.db.outgoing_set == {inheritance_cat_mammal_handle: [cat_handle, mammal_handle]} assert db.db.templates == { "41c082428b28d7e9ea96160f7fd614ad": { inheritance_cat_mammal_handle,