Skip to content

Commit b2f0b81

Browse files
committed
allow array element to be none
1 parent 175b50b commit b2f0b81

File tree

4 files changed

+883
-693
lines changed

4 files changed

+883
-693
lines changed

numcodecs/tests/test_vlen_array.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
from numcodecs.vlen import VLenArray
1212
except ImportError: # pragma: no cover
1313
raise nose.SkipTest("vlen-array not available")
14-
from numcodecs.tests.common import (check_config, check_repr, check_encode_decode_array,
15-
check_backwards_compatibility)
14+
from numcodecs.tests.common import (check_config, check_repr,
15+
check_encode_decode_array,
16+
check_backwards_compatibility,
17+
assert_array_items_equal)
1618

1719

1820
arrays = [
@@ -88,3 +90,14 @@ def test_decode_errors():
8890
codec.decode(enc, out=123)
8991
with assert_raises(ValueError):
9092
codec.decode(enc, out=np.zeros(10, dtype='i4'))
93+
94+
95+
def test_encode_none():
96+
a = np.array([[1, 3], None, [4, 7]], dtype=object)
97+
codec = VLenArray(int)
98+
enc = codec.encode(a)
99+
dec = codec.decode(enc)
100+
expect = np.array([np.array([1, 3]),
101+
np.array([]),
102+
np.array([4, 7])], dtype=object)
103+
assert_array_items_equal(expect, dec)

0 commit comments

Comments
 (0)