@@ -40,7 +40,7 @@ Metadata
40
40
41
41
Each array requires essential configuration metadata to be stored, enabling
42
42
correct interpretation of the stored data. This metadata is encoded using JSON
43
- and stored as the value of the ' .zarray' key within an array store.
43
+ and stored as the value of the " .zarray" key within an array store.
44
44
45
45
The metadata resource is a JSON object. The following keys MUST be present
46
46
within the object:
@@ -66,9 +66,9 @@ fill_value
66
66
A scalar value providing the default value to use for uninitialized
67
67
portions of the array.
68
68
order
69
- Either 'C' or 'F' , defining the layout of bytes within each chunk of the
70
- array. 'C' means row-major order, i.e., the last dimension varies fastest;
71
- 'F' means column-major order, i.e., the first dimension varies fastest.
69
+ Either "C" or "F" , defining the layout of bytes within each chunk of the
70
+ array. "C" means row-major order, i.e., the last dimension varies fastest;
71
+ "F" means column-major order, i.e., the first dimension varies fastest.
72
72
73
73
Other keys MUST NOT be present within the metadata object.
74
74
@@ -116,8 +116,17 @@ Structured data types (i.e., with multiple named fields) are encoded as a list
116
116
of two-element lists, following `NumPy array protocol type descriptions (descr)
117
117
<http://docs.scipy.org/doc/numpy/reference/arrays.interface.html#> `_. For
118
118
example, the JSON list ``[["r", "|u1"], ["g", "|u1"], ["b", "|u1"]] `` defines a
119
- data type composed of three single-byte unsigned integers labelled 'r', 'g' and
120
- 'b'.
119
+ data type composed of three single-byte unsigned integers labelled "r", "g" and
120
+ "b".
121
+
122
+ Fill value encoding
123
+ ~~~~~~~~~~~~~~~~~~~
124
+
125
+ Not a Number (NaN) must be encoded as the JSON string "NaN" if used as the
126
+ value of the "fill_value" field.
127
+
128
+ When decoding the "fill_value" field, the JSON string "NaN" should be decoded
129
+ as Not a Number (NaN) if the dtype basic type is floating point ("f").
121
130
122
131
Chunks
123
132
~~~~~~
@@ -134,17 +143,17 @@ compressed data.
134
143
The compressed sequence of bytes for each chunk is stored under a key formed
135
144
from the index of the chunk within the grid of chunks representing the array.
136
145
To form a string key for a chunk, the indices are converted to strings and
137
- concatenated with the period character ('.' ) separating each index. For
146
+ concatenated with the period character ("." ) separating each index. For
138
147
example, given an array with shape (10000, 10000) and chunk shape (1000, 1000)
139
148
there will be 100 chunks laid out in a 10 by 10 grid. The chunk with indices
140
149
(0, 0) provides data for rows 0-1000 and columns 0-1000 and is stored under the
141
- key ' 0.0' ; the chunk with indices (2, 4) provides data for rows 2000-3000 and
142
- columns 4000-5000 and is stored under the key ' 2.4' ; etc.
150
+ key " 0.0" ; the chunk with indices (2, 4) provides data for rows 2000-3000 and
151
+ columns 4000-5000 and is stored under the key " 2.4" ; etc.
143
152
144
153
There is no need for all chunks to be present within an array store. If a chunk
145
154
is not present then it is considered to be in an uninitialized state. An
146
155
unitialized chunk MUST be treated as if it was uniformly filled with the value
147
- of the ' fill_value' field in the array metadata. If the ' fill_value' field is
156
+ of the " fill_value" field in the array metadata. If the " fill_value" field is
148
157
``null `` then the contents of the chunk are undefined.
149
158
150
159
Note that all chunks in an array have the same shape. If the length of any
@@ -161,30 +170,30 @@ Logical storage paths
161
170
Multiple arrays can be stored in the same array store by associating each array
162
171
with a different logical path. A logical path is simply an ASCII string. The
163
172
logical path is used to form a prefix for keys used by the array. For example,
164
- if an array is stored at logical path ' foo/bar' then the array metadata will be
165
- stored under the key ' foo/bar/.zarray' , the user-defined attributes will be
166
- stored under the key ' foo/bar/.zattrs' , and the chunks will be stored under
167
- keys like ' foo/bar/0.0', ' foo/bar/0.1' , etc.
173
+ if an array is stored at logical path " foo/bar" then the array metadata will be
174
+ stored under the key " foo/bar/.zarray" , the user-defined attributes will be
175
+ stored under the key " foo/bar/.zattrs" , and the chunks will be stored under
176
+ keys like " foo/bar/0.0", " foo/bar/0.1" , etc.
168
177
169
178
To ensure consistent behaviour across different storage systems, logical paths
170
179
MUST be normalized as follows:
171
180
172
- * Replace all backward slash characters (' \\ ' ) with forward slash characters
173
- ('/')
174
- * Strip any leading '/' characters
175
- * Strip any trailing '/' characters
176
- * Collapse any sequence of more than one '/' character into a single '/'
181
+ * Replace all backward slash characters (" \\ " ) with forward slash characters
182
+ ("/")
183
+ * Strip any leading "/" characters
184
+ * Strip any trailing "/" characters
185
+ * Collapse any sequence of more than one "/" character into a single "/"
177
186
character
178
187
179
- The key prefix is then obtained by appending a single '/' character to the
188
+ The key prefix is then obtained by appending a single "/" character to the
180
189
normalized logical path.
181
190
182
- After normalization, if splitting a logical path by the '/' character results
183
- in any path segment equal to the string '.' or the string '..' then an error
191
+ After normalization, if splitting a logical path by the "/" character results
192
+ in any path segment equal to the string "." or the string ".." then an error
184
193
MUST be raised.
185
194
186
195
N.B., how the underlying array store processes requests to store values under
187
- keys containing the '/' character is entirely up to the store implementation
196
+ keys containing the "/" character is entirely up to the store implementation
188
197
and is not constrained by this specification. E.g., an array store could simply
189
198
treat all keys as opaque ASCII strings; equally, an array store could map
190
199
logical paths onto some kind of hierarchical storage (e.g., directories on a
@@ -194,20 +203,20 @@ Groups
194
203
~~~~~~
195
204
196
205
Arrays can be organized into groups which can also contain other groups. A
197
- group is created by storing group metadata under the ' .zgroup' key under some
206
+ group is created by storing group metadata under the " .zgroup" key under some
198
207
logical path. E.g., a group exists at the root of an array store if the
199
- ' .zgroup' key exists in the store, and a group exists at logical path ' foo/bar'
200
- if the ' foo/bar/.zgroup' key exists in the store.
208
+ " .zgroup" key exists in the store, and a group exists at logical path " foo/bar"
209
+ if the " foo/bar/.zgroup" key exists in the store.
201
210
202
211
If the user requests a group to be created under some logical path, then groups
203
212
MUST also be created at all ancestor paths. E.g., if the user requests group
204
- creation at path ' foo/bar' then groups MUST be created at path ' foo' and the
213
+ creation at path " foo/bar" then groups MUST be created at path " foo" and the
205
214
root of the store, if they don't already exist.
206
215
207
216
If the user requests an array to be created under some logical path, then
208
217
groups MUST also be created at all ancestor paths. E.g., if the user requests
209
- array creation at path ' foo/bar/baz' then groups must be created at path
210
- ' foo/bar' , path ' foo' , and the root of the store, if they don't already exist.
218
+ array creation at path " foo/bar/baz" then groups must be created at path
219
+ " foo/bar" , path " foo" , and the root of the store, if they don't already exist.
211
220
212
221
The group metadata resource is a JSON object. The following keys MUST be present
213
222
within the object:
@@ -220,20 +229,20 @@ Other keys MUST NOT be present within the metadata object.
220
229
221
230
The members of a group are arrays and groups stored under logical paths that
222
231
are direct children of the parent group's logical path. E.g., if a groups exist
223
- under the logical paths ' foo' and ' foo/bar' and an array exists at logical path
224
- ' foo/baz' then the members of the group at path ' foo' are the group at path
225
- ' foo/bar' and the array at path ' foo/baz' .
232
+ under the logical paths " foo" and " foo/bar" and an array exists at logical path
233
+ " foo/baz" then the members of the group at path " foo" are the group at path
234
+ " foo/bar" and the array at path " foo/baz" .
226
235
227
236
Attributes
228
237
----------
229
238
230
239
An array or group can be associated with custom attributes, which are simple
231
240
key/value items with application-specific meaning. Custom attributes are
232
- encoded as a JSON object and stored under the ' .zattrs' key within an array
241
+ encoded as a JSON object and stored under the " .zattrs" key within an array
233
242
store.
234
243
235
244
For example, the JSON object below encodes three attributes named
236
- ' foo', ' bar' and ' baz' ::
245
+ " foo", " bar" and " baz" ::
237
246
238
247
{
239
248
"foo": 42,
@@ -258,7 +267,7 @@ Create an array::
258
267
... fill_value=42, compression='zlib', compression_opts=1,
259
268
... store=store, overwrite=True)
260
269
261
- No chunks are initialized yet, so only the ' .zarray' and ' .zattrs' keys
270
+ No chunks are initialized yet, so only the " .zarray" and " .zattrs" keys
262
271
have been set in the store::
263
272
264
273
>>> import os
@@ -427,7 +436,7 @@ Changes in version 2
427
436
428
437
* Added support for storing multiple arrays in the same store and organising
429
438
arrays into hierarchies using groups.
430
- * Array metadata is now stored under the ' .zarray' key instead of the ' meta'
439
+ * Array metadata is now stored under the " .zarray" key instead of the " meta"
431
440
key
432
- * Custom attributes are now stored under the ' .zattrs' key instead of the
433
- ' attrs' key
441
+ * Custom attributes are now stored under the " .zattrs" key instead of the
442
+ " attrs" key
0 commit comments