Skip to content
Closed
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
8 changes: 4 additions & 4 deletions zarr/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
from threading import Lock, RLock
import uuid

import numpy

from numcodecs.compat import ensure_bytes, ensure_contiguous_ndarray
from numcodecs.registry import codec_registry

Expand Down Expand Up @@ -740,8 +742,7 @@ def __init__(self, path):
def __getitem__(self, key):
filepath = os.path.join(self.path, key)
if os.path.isfile(filepath):
with open(filepath, 'rb') as f:
return f.read()
return numpy.fromfile(filepath, dtype='u1')
else:
raise KeyError(key)

Expand Down Expand Up @@ -773,8 +774,7 @@ def __setitem__(self, key, value):
temp_name = file_name + '.' + uuid.uuid4().hex + '.partial'
temp_path = os.path.join(dir_path, temp_name)
try:
with open(temp_path, mode='wb') as f:
f.write(value)
value.tofile(temp_path)

# move temporary file into place
replace(temp_path, file_path)
Expand Down