Skip to content

Commit bc61ea4

Browse files
Merge pull request #25 from willow-ahrens/wma/types
Add a description of datatype values
2 parents e471cf0 + d166ca9 commit bc61ea4

1 file changed

Lines changed: 48 additions & 11 deletions

File tree

spec/latest/index.bs

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,58 @@ Data Types {#key_data_types}
229229

230230
The `data_types` key must be present and shall define the data types of all required
231231
arrays based on the [[#key_format]]. The data type declares the type of both the
232-
on-disk array as well as the in-memory array. When these are identical, a simple string
233-
defines the type. When the on-disk and in-memory types differ due to limitations in the
234-
storage container (ex. HDF5 lacks a BOOL type), the type is shown as "on_disk->in_memory".
235-
For the example of storing BOOL type as INT8, this would be "int8->bool" to indicate that
236-
after reading the values array into memory, it should be interpreted as boolean data.
232+
on-disk array as well as the in-memory array.
237233

238234
For a given [[#key_format]], all named binary arrays for that format shall have a
239235
corresponding name in `data_types`.
240236

237+
The following strings shall be used to describe data types:
238+
: "uint8"
239+
:: unsigned 8-bit integer
240+
: "uint16"
241+
:: unsigned 16-bit integer
242+
: "uint32"
243+
:: unsigned 32-bit integer
244+
: "uint64"
245+
:: unsigned 64-bit integer
246+
: "int8"
247+
:: signed 8-bit integer
248+
: "int16"
249+
:: signed 16-bit integer
250+
: "int32"
251+
:: signed 32-bit integer
252+
: "int64"
253+
:: signed 64-bit integer
254+
: "float32"
255+
:: IEEE binary32 floating point number
256+
: "float64"
257+
:: IEEE binary64 floating point number
258+
: "bint8"
259+
:: An unsigned 8-bit integer, to be reinterpreted as a Boolean number, however
260+
that is represented in the host language. The value 0 shall map to false and the
261+
value 1 shall map to true. When parsing, implementations may choose to interpret
262+
values other than 0 or 1 as true, or throw an error.
263+
264+
## Value Modifiers ## {#value_modifiers}
265+
266+
When the value array is meant to be reinterpreted before reading, a special bracket syntax is
267+
provided to indicate modifications to the underlying value array.
268+
269+
### Sparse Array with Complex Values ### {#complex_arrays}
270+
271+
When a value array is composed of alternating real and imaginary components of
272+
complex numbers, the type is written as `complex[<type>]`. For example, a value
273+
array of complex `float64` would have a datatype of `complex[float64]` The real
274+
component of the `i`th element in the modified array shall be stored at position
275+
`2i` in the original array, and the imaginary component of the `i`th element in
276+
the modified array shall be at position `2i + 1` in the underlying array.
277+
241278
### Sparse Array with All Values the Same ### {#iso_arrays}
242279

243-
When all values of a sparse array are the same identical value, a special syntax is
244-
provided to compress the value array to a single value rather than duplicating the same
245-
number unnecessarily. The format of the array is written as `iso[<format>]` to indicate
246-
that the array will store only a single element which is common to all stored indices.
280+
When all values of a sparse array are the same identical value, the type is
281+
written as `iso[<type>]`. This indicates that the array will store only a single
282+
element which is common to all stored indices. All elements in the modified
283+
array shall be stored at position 0 of the underlying array.
247284

248285
<div class=example>
249286

@@ -306,12 +343,12 @@ Example of a CSR Matrix whose values are all 7.
306343

307344
```json
308345
{
309-
"format": "iso[CSR]",
346+
"format": "CSR",
310347
"shape": [5, 5],
311348
"data_types": {
312349
"pointers_0": "uint64",
313350
"indices_1": "uint64",
314-
"values": "int8"
351+
"values": "iso[int8]"
315352
}
316353
}
317354
```

0 commit comments

Comments
 (0)