Skip to content

Commit a084325

Browse files
authored
Merge pull request #236 from jbms/fix-issue-231
Clarify fill value representation, change nan representation
2 parents 8787965 + 5930dcb commit a084325

File tree

1 file changed

+56
-23
lines changed

1 file changed

+56
-23
lines changed

docs/v3/core/v3.0.rst

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -597,30 +597,63 @@ mandatory names:
597597
Provides an element value to use for uninitialised portions of the
598598
Zarr array.
599599

600-
If the data type of the Zarr array is Boolean then the value must
601-
be the literal ``false`` or ``true``. If the data type is one of
602-
the integer data types defined in this specification, then the
603-
value must be a number with no fraction or exponent part and must
604-
be within the range of the data type.
605-
606-
For any data type, the ``fill_value`` is required. The literal
607-
``null`` is not permitted. The fill value needs to be defined
608-
so that the data is independent of implementation details. Internally
609-
implementations may provide a default ``fill_value``, but that must
610-
be converted to a fixed value in the stored metadata.
611-
612-
If the ``data_type`` of an array is defined in a ``data_type`` extension,
613-
then said extension is responsible for interpreting the value of
614-
``fill_value`` and returning a suitable type that can be used.
615-
616-
For core data types for which fill values are not permitted in JSON or
617-
for which decimal representation could be lossy, a string representing of
618-
the binary (starting with ``0b``) or hexadecimal value (starting with
619-
``0x``) is accepted. This string must include all leading or trailing
620-
zeroes necessary to match the given type size. The string values ``"NaN"``,
621-
``"+Infinity"`` and ``"-Infinity"`` are also understood for floating point
622-
data types.
600+
The permitted values depend on the data type:
623601

602+
``bool``
603+
The value must be a JSON boolean (``false`` or ``true``).
604+
605+
Integers (``{uint,int}{8,16,32,64}``)
606+
The value must be a JSON number with no fraction or exponent part that is
607+
within the representable range of the data type.
608+
609+
IEEE 754 floating point numbers (``float{16,32,64}``)
610+
The value may be either:
611+
612+
- A JSON number, that will be rounded to the nearest representable value.
613+
614+
- A JSON string of the form:
615+
616+
- ``"Infinity"``, denoting positive infinity;
617+
- ``"-Infinity"``, denoting negative infinity;
618+
- ``"NaN"``, denoting thenot-a-number (NaN) value where the sign bit is
619+
0 (positive), the most significant bit (MSB) of the mantissa is 1, and
620+
all other bits of the mantissa are zero;
621+
- ``"0xYYYYYYYY"``, specifying the byte representation of the floating
622+
point number as an unsigned integer. For example, for ``float32``,
623+
``"NaN"`` is equivalent to ``"0x7fc00000"``. This representation is
624+
the only way to specify a NaN value other than the specific NaN value
625+
denoted by ``"NaN"``.
626+
627+
.. warning::
628+
629+
While this NaN syntax is consistent with the syntax accepted by the
630+
C99 ``strtod`` function, C99 leaves the meaning of the NaN payload
631+
string implementation defined, which may not match the Zarr
632+
definition.
633+
634+
Complex numbers (``complex{64,128}``)
635+
The value must be a two-element array, specifying the real and imaginary
636+
components respectively, where each component is specified as defined
637+
above for floating point number.
638+
639+
For example, ``[1, 2]`` indicates ``1 + 2i`` and ``["-Infinity", "NaN"]``
640+
indicates a complex number with real component of -inf and imaginary
641+
component of NaN.
642+
643+
Raw data types (``r<N>``)
644+
An array of integers, with length equal to ``<N>``, where each integer is
645+
in the range ``[0, 255]``.
646+
647+
Extensions to the spec that define new data types must also define the JSON
648+
fill value representation.
649+
650+
.. note::
651+
652+
The ``fill_value`` metadata field is required, but Zarr implementations
653+
may provide an interface for creating a new array with which users can
654+
leave the fill value unspecified, in which case a default fill value for
655+
the data type will be chosen. However, the default fill value that is
656+
chosen MUST be recorded in the metadata.
624657

625658
The following members are optional:
626659

0 commit comments

Comments
 (0)