forked from zarr-developers/zarr-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_missing.py
More file actions
44 lines (31 loc) · 1.15 KB
/
test_missing.py
File metadata and controls
44 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import unittest
from zarr.creation import array
class TestArrayMissingKeys(unittest.TestCase):
def test_raises_on_missing_key_zd(self):
a = array(1, chunks=1)
# pop first chunk
a.chunk_store.pop("0")
# read from missing chunk and make sure fill-value is returned
assert a.fill_value == a[()]
# configure raise on missing chunk
a.set_options(fill_missing_chunk=False)
# reading missing chunk should raise
with self.assertRaises(KeyError):
a[()]
def test_raises_on_missing_key_1d(self):
a = array(range(4), chunks=2)
# pop first chunk
a.chunk_store.pop("0")
# read from missing chunk and make sure fill-value is returned
assert a.fill_value == a[0]
assert a.fill_value == a[1]
# read from avaible chunk w/o error
assert 2 == a[2]
assert 3 == a[3]
# configure raise on missing chunk
a.set_options(fill_missing_chunk=False)
# reading missing chunk should raise
with self.assertRaises(KeyError):
a[0]
with self.assertRaises(KeyError):
a[:2]