|
38 | 38 | normalize_storage_path, buffer_size,
|
39 | 39 | normalize_fill_value, nolock, normalize_dtype)
|
40 | 40 | from zarr.meta import encode_array_metadata, encode_group_metadata
|
41 |
| -from zarr.compat import PY2, binary_type, OrderedDict_move_to_end |
| 41 | +from zarr.compat import PY2, OrderedDict_move_to_end |
42 | 42 | from numcodecs.registry import codec_registry
|
| 43 | +from numcodecs.compat import ensure_bytes |
43 | 44 | from zarr.errors import (err_contains_group, err_contains_array, err_bad_compressor,
|
44 | 45 | err_fspath_exists_notdir, err_read_only, MetadataError)
|
45 | 46 |
|
@@ -444,23 +445,6 @@ def _init_group_metadata(store, overwrite=False, path=None, chunk_store=None):
|
444 | 445 | store[key] = encode_group_metadata(meta)
|
445 | 446 |
|
446 | 447 |
|
447 |
| -def ensure_bytes(s): |
448 |
| - if isinstance(s, binary_type): |
449 |
| - return s |
450 |
| - if isinstance(s, np.ndarray): |
451 |
| - if PY2: # pragma: py3 no cover |
452 |
| - # noinspection PyArgumentList |
453 |
| - return s.tostring(order='A') |
454 |
| - else: # pragma: py2 no cover |
455 |
| - # noinspection PyArgumentList |
456 |
| - return s.tobytes(order='A') |
457 |
| - if hasattr(s, 'tobytes'): |
458 |
| - return s.tobytes() |
459 |
| - if PY2 and hasattr(s, 'tostring'): # pragma: py3 no cover |
460 |
| - return s.tostring() |
461 |
| - return memoryview(s).tobytes() |
462 |
| - |
463 |
| - |
464 | 448 | def _dict_store_keys(d, prefix='', cls=dict):
|
465 | 449 | for k in d.keys():
|
466 | 450 | v = d[k]
|
|
0 commit comments