Skip to content

Commit 5e7838c

Browse files
committed
test: more dtype tests
1 parent e9a7967 commit 5e7838c

36 files changed

Lines changed: 316 additions & 0 deletions

packages/zarr-metadata/tests/v3/data_type/bool/__init__.py

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"true": true,
3+
"false": false
4+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Validate bool fill-value fixtures."""
2+
3+
from __future__ import annotations
4+
5+
import json
6+
from pathlib import Path
7+
8+
import pytest
9+
from pydantic import TypeAdapter
10+
11+
from zarr_metadata.v3.data_type.bool import BoolFillValue
12+
13+
FILL_VALUES: dict[str, object] = json.loads(
14+
(Path(__file__).parent / "fill_values.json").read_text()
15+
)
16+
17+
18+
@pytest.mark.parametrize("case", FILL_VALUES.values(), ids=list(FILL_VALUES))
19+
def test_fill_value(case: object) -> None:
20+
TypeAdapter(BoolFillValue).validate_python(case)

packages/zarr-metadata/tests/v3/data_type/complex128/__init__.py

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"numeric": [1.5, 2.5],
3+
"zero": [0.0, 0.0],
4+
"with_sentinel_components": ["-Infinity", "NaN"],
5+
"mixed_numeric_and_sentinel": [1.0, "Infinity"],
6+
"with_hex_components": ["0x7ff8000000000000", "0x0000000000000000"]
7+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Validate complex128 fill-value fixtures.
2+
3+
A v3 complex fill_value is a two-element JSON array `[real, imag]` where
4+
each component is shaped per the corresponding float's fill value: a
5+
number, one of the named sentinels (`"NaN"`, `"Infinity"`,
6+
`"-Infinity"`), or a hex string of the underlying float's bits.
7+
"""
8+
9+
from __future__ import annotations
10+
11+
import json
12+
from pathlib import Path
13+
14+
import pytest
15+
from pydantic import TypeAdapter
16+
17+
from zarr_metadata.v3.data_type.complex128 import Complex128FillValue
18+
19+
FILL_VALUES: dict[str, object] = json.loads(
20+
(Path(__file__).parent / "fill_values.json").read_text()
21+
)
22+
23+
24+
@pytest.mark.parametrize("case", FILL_VALUES.values(), ids=list(FILL_VALUES))
25+
def test_fill_value(case: object) -> None:
26+
TypeAdapter(Complex128FillValue).validate_python(case)

packages/zarr-metadata/tests/v3/data_type/complex64/__init__.py

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"numeric": [1.5, 2.5],
3+
"zero": [0.0, 0.0],
4+
"with_sentinel_components": ["-Infinity", "NaN"],
5+
"mixed_numeric_and_sentinel": [1.0, "Infinity"],
6+
"with_hex_components": ["0x7fc00000", "0x00000000"]
7+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Validate complex64 fill-value fixtures.
2+
3+
A v3 complex fill_value is a two-element JSON array `[real, imag]` where
4+
each component is shaped per the corresponding float's fill value: a
5+
number, one of the named sentinels (`"NaN"`, `"Infinity"`,
6+
`"-Infinity"`), or a hex string of the underlying float's bits.
7+
"""
8+
9+
from __future__ import annotations
10+
11+
import json
12+
from pathlib import Path
13+
14+
import pytest
15+
from pydantic import TypeAdapter
16+
17+
from zarr_metadata.v3.data_type.complex64 import Complex64FillValue
18+
19+
FILL_VALUES: dict[str, object] = json.loads(
20+
(Path(__file__).parent / "fill_values.json").read_text()
21+
)
22+
23+
24+
@pytest.mark.parametrize("case", FILL_VALUES.values(), ids=list(FILL_VALUES))
25+
def test_fill_value(case: object) -> None:
26+
TypeAdapter(Complex64FillValue).validate_python(case)

packages/zarr-metadata/tests/v3/data_type/int16/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)