Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#223] reverting erratic recent changes #225

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hyperon_das_atomdb/adapters/ram_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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:
"""
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/adapters/test_ram_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down