Skip to content

Commit

Permalink
Add ability to remove keys from memory
Browse files Browse the repository at this point in the history
q- remove() takes a list of keys to delete from memory.
  • Loading branch information
Ezward committed May 26, 2024
1 parent 933b599 commit 410d2ba
Show file tree
Hide file tree
Showing 2 changed files with 266 additions and 66 deletions.
12 changes: 11 additions & 1 deletion donkeycar/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def __getitem__(self, key):
return self.d[key]

def update(self, new_d):
'''
update memory with values from a dictionary
'''
self.d.update(new_d)

def put(self, keys, inputs):
Expand All @@ -44,11 +47,18 @@ def put(self, keys, inputs):
else:
self.d[keys[0]] = inputs

self.d.update(dict)

def get(self, keys):
result = [self.d.get(k) for k in keys]
return result

def remove(self, keys):
'''
Remove all the keys in the given list
'''
for key in keys:
del self.d[key]

def keys(self):
return self.d.keys()
Expand Down
Loading

0 comments on commit 410d2ba

Please sign in to comment.