|
6 | 6 |
|
7 | 7 | import numpy as np |
8 | 8 | # create data |
9 | | -be_short_data = np.arange(100, dtype='>i2').reshape(10, 10) |
10 | | -le_short_data = np.arange(100, dtype='<i2').reshape(10, 10) |
11 | | -be_int_data = np.arange(100, dtype='>i4').reshape(10, 10) |
12 | | -le_int_data = np.arange(100, dtype='<i4').reshape(10, 10) |
| 9 | +be_short_data = np.arange(20, dtype='>i2').reshape(4,5) |
| 10 | +le_short_data = np.arange(20, dtype='<i2').reshape(4,5) |
| 11 | +be_int_data = np.arange(20, dtype='>i4').reshape(4,5) |
| 12 | +le_int_data = np.arange(20, dtype='<i4').reshape(4,5) |
13 | 13 |
|
14 | 14 |
|
15 | 15 | # In[ ]: |
16 | 16 |
|
17 | 17 |
|
18 | | -be_long_data = np.arange(100, dtype='>i8').reshape(10, 10) |
19 | | -le_long_data = np.arange(100, dtype='<i8').reshape(10, 10) |
| 18 | +be_long_data = np.arange(20, dtype='>i8').reshape(5,4) |
| 19 | +le_long_data = np.arange(20, dtype='<i8').reshape(5,4) |
20 | 20 |
|
21 | 21 |
|
22 | 22 | # In[ ]: |
23 | 23 |
|
24 | 24 |
|
25 | | -be_float_data = np.arange(200, dtype='>f4').reshape(20, 10) |
26 | | -le_float_data = np.arange(200, dtype='<f4').reshape(20, 10) |
| 25 | +be_float_data = np.arange(20, dtype='>f4').reshape(4,5) |
| 26 | +le_float_data = np.arange(20, dtype='<f4').reshape(4,5) |
27 | 27 |
|
28 | 28 |
|
29 | 29 | # In[ ]: |
30 | 30 |
|
31 | 31 |
|
32 | | -be_double_data = np.arange(100, dtype='>f8').reshape(10, 10) |
33 | | -le_double_data = np.arange(100, dtype='<f8').reshape(10, 10) |
| 32 | +be_double_data = np.arange(20, dtype='>f8').reshape(5,4) |
| 33 | +le_double_data = np.arange(20, dtype='<f8').reshape(5,4) |
34 | 34 |
|
35 | 35 |
|
36 | 36 | # In[ ]: |
37 | 37 |
|
38 | 38 |
|
39 | | -boolean_data = np.full((10, 4), [0, 1, 0, 1], dtype='|b1') |
| 39 | +boolean_data = np.full((4,5), [0, 1, 0, 1,0], dtype='|b1') |
40 | 40 |
|
41 | 41 |
|
42 | 42 | # In[ ]: |
43 | 43 |
|
44 | 44 |
|
45 | 45 | byte_data = be_int_data.tobytes() |
46 | | -bdata = np.frombuffer(byte_data, dtype='|i1').reshape(20, 20); |
| 46 | +bdata = np.frombuffer(byte_data, dtype='|i1').reshape(10,8); |
47 | 47 |
|
48 | 48 |
|
49 | 49 | # In[ ]: |
50 | 50 |
|
51 | 51 |
|
52 | | -charar = np.chararray((10, 12), itemsize=4) |
| 52 | +charar = np.chararray((10,12), itemsize=4) |
53 | 53 | charar[:] = 'abcd' |
54 | 54 |
|
55 | 55 |
|
|
65 | 65 |
|
66 | 66 | root_grp = zarr.group(store, overwrite=True) |
67 | 67 | # create a group for byte-order independent data types |
68 | | -unordered_group = root_grp.create_group('unordered_group') |
| 68 | +unordered_group = root_grp.create_group('unordered_group', overwrite=True) |
69 | 69 |
|
70 | 70 |
|
71 | 71 | # create a group for byte-ordered data types |
72 | | -byte_ordered_group = root_grp.create_group('byte_ordered_group') |
| 72 | +byte_ordered_group = root_grp.create_group('byte_ordered_group', overwrite=True) |
73 | 73 | # add groups for big and little endian |
74 | | -big_endian = byte_ordered_group.create_group('big_endian') |
75 | | -little_endian = byte_ordered_group.create_group('little_endian') |
| 74 | +big_endian = byte_ordered_group.create_group('big_endian', overwrite=True) |
| 75 | +little_endian = byte_ordered_group.create_group('little_endian', overwrite=True) |
76 | 76 |
|
77 | 77 | # create group for string types |
78 | | -string_group = root_grp.create_group('string_types') |
| 78 | +string_group = root_grp.create_group('string_types', overwrite=True) |
79 | 79 |
|
80 | 80 |
|
81 | 81 | # In[ ]: |
82 | 82 |
|
83 | 83 |
|
84 | 84 | # add data to unordered group |
85 | | -b = unordered_group.create_dataset('boolean_data', shape=(10, 4), chunks=(2, 2), dtype='|b1', overwrite=True) |
| 85 | +b = unordered_group.create_dataset('boolean_data', shape=(4,5), chunks=(2,5), dtype='|b1', overwrite=True, compressor=None) |
86 | 86 | b[:] = boolean_data |
87 | | -byte = unordered_group.create_dataset('byte_data', shape=(20, 20), chunks=(3, 3), dtype='|i1', overwrite=True) |
| 87 | +byte = unordered_group.create_dataset('byte_data', shape=(10,8), chunks=(5,4), dtype='|i1', overwrite=True, compressor=None) |
88 | 88 | byte[:] = bdata |
89 | | -ubyte = unordered_group.create_dataset('ubyte_data', shape=(20, 20), chunks=(4, 5), dtype='|u1', overwrite=True) |
| 89 | +ubyte = unordered_group.create_dataset('ubyte_data', shape=(10,8), chunks=(5,4), dtype='|u1', overwrite=True, compressor=None) |
90 | 90 | ubyte[:] = bdata |
91 | 91 |
|
92 | 92 |
|
93 | 93 | # In[ ]: |
94 | 94 |
|
95 | 95 |
|
96 | 96 | # add data to big endian group |
97 | | -shorts = big_endian.create_dataset('short_data', shape = (10, 10), chunks=(10, 5), dtype='>i2', overwrite=True) |
| 97 | +shorts = big_endian.create_dataset('short_data', shape=(4,5), chunks=(2,5), dtype='>i2', overwrite=True, compressor=None) |
98 | 98 | shorts[:] = be_short_data |
99 | | -ushorts = big_endian.create_dataset('ushort_data', shape = (10, 10), chunks=(10, 5), dtype='>u2', overwrite=True) |
| 99 | +ushorts = big_endian.create_dataset('ushort_data', shape=(4,5), chunks=(2,5), dtype='>u2', overwrite=True, compressor=None) |
100 | 100 | ushorts[:] = be_short_data |
101 | | -ints = big_endian.create_dataset('int_data', shape = (10, 10), chunks=(10, 5), dtype='>i4', overwrite=True) |
| 101 | +ints = big_endian.create_dataset('int_data', shape=(4,5), chunks=(2,5), dtype='>i4', overwrite=True, compressor=None) |
102 | 102 | ints[:] = be_int_data |
103 | | -uints = big_endian.create_dataset('uint_data', shape = (10, 10), chunks=(10, 5), dtype='>u4', overwrite=True) |
| 103 | +uints = big_endian.create_dataset('uint_data', shape=(4,5), chunks=(2,5), dtype='>u4', overwrite=True, compressor=None) |
104 | 104 | uints[:] = be_int_data |
105 | | -longs = big_endian.create_dataset('long_data', shape = (10, 10), chunks=(5, 10), dtype='>i8', overwrite=True) |
| 105 | +longs = big_endian.create_dataset('long_data', shape=(5,4), chunks=(5,2), dtype='>i8', overwrite=True, compressor=None) |
106 | 106 | longs[:] = be_long_data |
107 | | -ulongs = big_endian.create_dataset('ulong_data', shape = (10, 10), chunks=(5, 10), dtype='>u8', overwrite=True) |
| 107 | +ulongs = big_endian.create_dataset('ulong_data', shape=(5,4), chunks=(5,2), dtype='>u8', overwrite=True, compressor=None) |
108 | 108 | ulongs[:] = be_long_data |
109 | | -floats = big_endian.create_dataset('float_data', shape = (20, 10), chunks=(5, 5), dtype='>f4', overwrite=True) |
| 109 | +floats = big_endian.create_dataset('float_data', shape=(4,5), chunks=(2,5), dtype='>f4', overwrite=True, compressor=None) |
110 | 110 | floats[:] = be_float_data |
111 | | -doubles = big_endian.create_dataset('double_data', shape = (10, 10), chunks=(10, 10), dtype='>f8', overwrite=True) |
| 111 | +doubles = big_endian.create_dataset('double_data', shape=(5,4), chunks=(5,2), dtype='>f8', overwrite=True, compressor=None) |
112 | 112 | doubles[:] = be_double_data |
113 | 113 |
|
114 | 114 |
|
115 | 115 | # In[ ]: |
116 | 116 |
|
117 | 117 |
|
118 | 118 | # add data to little endian group |
119 | | -shorts = little_endian.create_dataset('short_data', shape = (10, 10), chunks=(10, 5), dtype='<i2', overwrite=True) |
| 119 | +shorts = little_endian.create_dataset('short_data', shape=(4,5), chunks=(2,5), dtype='<i2', overwrite=True, compressor=None) |
120 | 120 | shorts[:] = le_short_data |
121 | | -ushorts = little_endian.create_dataset('ushort_data', shape = (10, 10), chunks=(10, 5), dtype='<u2', overwrite=True) |
| 121 | +ushorts = little_endian.create_dataset('ushort_data', shape=(4,5), chunks=(2,5), dtype='<u2', overwrite=True, compressor=None) |
122 | 122 | ushorts[:] = le_short_data |
123 | | -ints = little_endian.create_dataset('int_data', shape = (10, 10), chunks=(10, 5), dtype='<i4', overwrite=True) |
| 123 | +ints = little_endian.create_dataset('int_data', shape=(4,5), chunks=(2,5), dtype='<i4', overwrite=True, compressor=None) |
124 | 124 | ints[:] = le_int_data |
125 | | -uints = little_endian.create_dataset('uint_data', shape = (10, 10), chunks=(10, 5), dtype='<u4', overwrite=True) |
| 125 | +uints = little_endian.create_dataset('uint_data', shape=(4,5), chunks=(2,5), dtype='<u4', overwrite=True, compressor=None) |
126 | 126 | uints[:] = le_int_data |
127 | | -longs = little_endian.create_dataset('long_data', shape = (10, 10), chunks=(5, 10), dtype='<i8', overwrite=True) |
| 127 | +longs = little_endian.create_dataset('long_data', shape=(5,4), chunks=(5,2), dtype='<i8', overwrite=True, compressor=None) |
128 | 128 | longs[:] = le_long_data |
129 | | -ulongs = little_endian.create_dataset('ulong_data', shape = (10, 10), chunks=(5, 10), dtype='<u8', overwrite=True) |
| 129 | +ulongs = little_endian.create_dataset('ulong_data', shape=(5,4), chunks=(5,2), dtype='<u8', overwrite=True, compressor=None) |
130 | 130 | ulongs[:] = le_long_data |
131 | | -floats = little_endian.create_dataset('float_data', shape = (20, 10), chunks=(5, 5), dtype='<f4', overwrite=True) |
| 131 | +floats = little_endian.create_dataset('float_data', shape=(4,5), chunks=(2,5), dtype='<f4', overwrite=True, compressor=None) |
132 | 132 | floats[:] = le_float_data |
133 | | -doubles = little_endian.create_dataset('double_data', shape = (10, 10), chunks=(10, 10), dtype='<f8', overwrite=True) |
| 133 | +doubles = little_endian.create_dataset('double_data', shape=(5,4), chunks=(5,2), dtype='<f8', overwrite=True, compressor=None) |
134 | 134 | doubles[:] = le_double_data |
135 | 135 |
|
136 | 136 |
|
137 | 137 | # In[ ]: |
138 | 138 |
|
139 | 139 |
|
140 | 140 | # add string data |
141 | | -chars = string_group.create_dataset('char_data', shape=(10,12), chunks=(2,4), dtype='S1', overwrite=True) |
| 141 | +chars = string_group.create_dataset('char_data', shape=(10,12), chunks=(5,3), dtype='S1', overwrite=True, compressor=None) |
142 | 142 | chars[:] = charar |
143 | | -strs = string_group.create_dataset('str_data', shape=(10,12), chunks=(2,2), dtype='S4', overwrite=True) |
| 143 | +strs = string_group.create_dataset('str_data', shape=(10,12), chunks=(5,6), dtype='S4', overwrite=True, compressor=None) |
144 | 144 | strs[:] = charar |
145 | | -unicode = string_group.create_dataset('unicode_data', shape=(10,12), chunks=(2,2), dtype='U4', overwrite=True) |
| 145 | +unicode = string_group.create_dataset('unicode_data', shape=(10,12), chunks=(5,6), dtype='U4', overwrite=True, compressor=None) |
146 | 146 | unicode[:] = charar |
147 | 147 |
|
0 commit comments