Coverage for src/arraybridge/dtype_scaling.py: 90%
10 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 11:15 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 11:15 +0000
1"""Declaration-owned dtype scaling and compatibility projections."""
3from functools import partial
4from types import MappingProxyType
5from typing import Any
7from arraybridge.array_operations import _SCALING_RANGES as _SCALING_RANGES
8from arraybridge.types import MemoryType
11def _scale_generic(result: Any, target_dtype: Any, mem_type: MemoryType) -> Any:
12 """Scale through the operation leaf carried by ``mem_type``."""
14 return mem_type.scale_dtype(result, target_dtype)
17def _scale_pyclesperanto(result: Any, target_dtype: Any) -> Any:
18 """Compatibility adapter for the pyclesperanto scaling leaf."""
20 return MemoryType.PYCLESPERANTO.scale_dtype(result, target_dtype)
23SCALING_FUNCTIONS = MappingProxyType(
24 {memory_type.value: partial(_scale_generic, mem_type=memory_type) for memory_type in MemoryType}
25)