Skip to content

Commit 67b0bb0

Browse files
committed
soften error to warning, keep API compatibility
1 parent 2bf2cdc commit 67b0bb0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

zarr/storage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ def _init_array_metadata(store, shape, chunks=None, dtype=None, compressor='defa
343343
# deal with object encoding
344344
if dtype == object:
345345
if object_codec is None:
346-
raise ValueError('an object_codec is required for object arrays')
346+
warnings.warn('missing object_codec for object array; this will raise a '
347+
'ValueError in version 3.0', FutureWarning)
347348
else:
348349
filters_config.insert(0, object_codec.get_config())
349350
elif object_codec is not None:

zarr/tests/test_core.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shutil
77
import pickle
88
import os
9+
import warnings
910

1011

1112
import numpy as np
@@ -26,6 +27,12 @@
2627
Categorize, JSON)
2728

2829

30+
# needed for PY2/PY3 consistent behaviour
31+
if PY2: # pragma: py3 no cover
32+
warnings.resetwarnings()
33+
warnings.simplefilter('always')
34+
35+
2936
# noinspection PyMethodMayBeStatic
3037
class TestArray(unittest.TestCase):
3138

@@ -869,7 +876,7 @@ def test_dtypes(self):
869876
def test_object_arrays(self):
870877

871878
# an object_codec is required for object arrays
872-
with assert_raises(ValueError):
879+
with pytest.warns(FutureWarning):
873880
self.create_array(shape=10, chunks=3, dtype=object)
874881

875882
# create an object array using msgpack

0 commit comments

Comments
 (0)