Skip to content

Commit 5a265c6

Browse files
committed
Correct default fill_value for creation.create
1 parent a81de6b commit 5a265c6

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

zarr/creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def create(shape, chunks=True, dtype=None, compressor='default',
19-
fill_value=0, order='C', store=None, synchronizer=None,
19+
fill_value=None, order='C', store=None, synchronizer=None,
2020
overwrite=False, path=None, chunk_store=None, filters=None,
2121
cache_metadata=True, cache_attrs=True, read_only=False,
2222
object_codec=None, dimension_separator=None,

zarr/tests/test_core.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from pkg_resources import parse_version
1919

2020
from zarr.core import Array
21+
from zarr.creation import create
2122
from zarr.meta import json_loads
2223
from zarr.n5 import N5Store, N5FSStore, n5_keywords
2324
from zarr.storage import (
@@ -1249,6 +1250,14 @@ def test_object_arrays_vlen_bytes(self):
12491250
assert_array_equal(data, z[:])
12501251
z.store.close()
12511252

1253+
# Zero-length bytes
1254+
z = create(shape=(1,), dtype=bytes)
1255+
assert z.dtype == object
1256+
assert isinstance(z.filters[0], VLenBytes)
1257+
z[0] = b''
1258+
assert z[0] == b''
1259+
z.store.close()
1260+
12521261
z = self.create_array(shape=data.shape, dtype=object, object_codec=Pickle())
12531262
z[:] = data
12541263
assert_array_equal(data, z[:])

zarr/tests/test_creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def test_create():
433433
assert (100,) == z.chunks # auto-chunks
434434
assert np.dtype(None) == z.dtype
435435
assert 'blosc' == z.compressor.codec_id
436-
assert 0 == z.fill_value
436+
assert None == z.fill_value
437437

438438
# all specified
439439
z = create(100, chunks=10, dtype='i4', compressor=Zlib(1),

zarr/tests/test_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2207,7 +2207,7 @@ def test_read_write(self):
22072207

22082208

22092209
def test_fill_value_change():
2210-
a = zarr.create((10, 10), dtype=int)
2210+
a = zarr.create((10, 10), dtype=int, fill_value=0)
22112211

22122212
assert a[0, 0] == 0
22132213

0 commit comments

Comments
 (0)