Skip to content
Snippets Groups Projects
Commit 6671b720 authored by Dennis Noll's avatar Dennis Noll
Browse files

[data] init DSSDisk

parent 75715a16
No related branches found
No related tags found
No related merge requests found
......@@ -232,3 +232,12 @@ class DSS(SKDict):
remove(path.join(dir, fn))
for key, value in self.items():
np.save(path.join(dir, "%s.npy" % sep.join(sorted(key))), value, **kwargs)
class DSSDisk(DSS):
def __setitem__(self, key, value):
if isinstance(value, np.ndarray) and not isinstance(value, np.memmap):
with tempfile.NamedTemporaryFile() as tmp_file:
np.save(tmp_file, value)
value = np.load(tmp_file.name, mmap_mode="r+")
return super().__setitem__(key, value)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment