forked from inaos/iron-array-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext_bug.py
More file actions
54 lines (46 loc) · 1.55 KB
/
Copy pathcontext_bug.py
File metadata and controls
54 lines (46 loc) · 1.55 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
45
46
47
48
49
50
51
52
53
54
import iarray as ia
shape = ()
chunkshape = ()
blockshape = ()
try:
storage = ia.Storage(chunkshape, blockshape)
dtshape = ia.DTShape(shape)
with ia.config(dtshape=dtshape, storage=storage) as cfg:
storage2 = cfg.storage
if chunkshape is not None:
assert storage2.chunkshape == chunkshape
assert storage2.blockshape == blockshape
else:
# automatic partitioning
assert storage2.chunkshape <= shape
assert storage2.blockshape <= storage2.chunkshape
except ValueError:
# chunkshape cannot be set when a plainbuffer is used
assert shape == ()
# One can pass storage parameters straight to config() dataclass too
try:
dtshape = ia.DTShape(shape)
with ia.config(
dtshape=dtshape,
chunkshape=chunkshape,
blockshape=blockshape,
enforce_frame=True,
) as cfg:
storage2 = cfg.storage
if chunkshape is not None:
assert storage2.chunkshape == chunkshape
assert storage2.blockshape == blockshape
else:
# automatic partitioning
assert storage2.chunkshape <= shape
assert storage2.blockshape <= storage2.chunkshape
assert storage2.enforce_frame == True
except ValueError:
# chunkshape cannot be set when a plainbuffer is used
assert shape == ()
def test_nested_contexts():
# Set the default to enable compression
ia.set_config(clevel=5)
a = ia.ones(ia.DTShape((100, 100)))
ia.set_config(clevel=5)
a = ia.ones(ia.DTShape((100, 100)))