How to use the pydsdl.PrimitiveType.CastMode.TRUNCATED function in pydsdl

To help you get started, we’ve selected a few pydsdl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UAVCAN / pyuavcan / pyuavcan / dsdl / _compiler.py View on Github external
def _test_if_saturated(t: pydsdl.PrimitiveType) -> bool:
    if isinstance(t, pydsdl.PrimitiveType):
        return {
            pydsdl.PrimitiveType.CastMode.SATURATED: True,
            pydsdl.PrimitiveType.CastMode.TRUNCATED: False,
        }[t.cast_mode]
    else:  # pragma: no cover
        raise TypeError(f'Cast mode is not defined for {type(t).__name__}')