Skip to content

liblaf.jarp.warp.types

Convenience accessors for Warp scalar, vector, and matrix dtypes.

Functions:

  • __getattr__

    Resolve dynamic shorthand names such as floating, vec3, or mat33.

  • matrix

    Build a Warp matrix dtype using the default floating scalar type.

  • vector

    Build a Warp vector dtype using the default floating scalar type.

Attributes:

floating module-attribute

floating: type

mat22 module-attribute

mat22: type

mat33 module-attribute

mat33: type

mat44 module-attribute

mat44: type

vec2 module-attribute

vec2: type

vec3 module-attribute

vec3: type

vec4 module-attribute

vec4: type

__getattr__

__getattr__(name: str) -> type

Resolve dynamic shorthand names such as floating, vec3, or mat33.

Source code in src/liblaf/jarp/warp/types.py
def __getattr__(name: str) -> type:
    """Resolve dynamic shorthand names such as `floating`, `vec3`, or `mat33`."""
    if name in {"float", "float_"}:
        warnings.warn(
            f"{__name__}.{name} is deprecated, use {__name__}.floating instead",
            DeprecationWarning,
            stacklevel=2,
        )
        return _floating()
    if name == "floating":
        return _floating()
    if (result := re.fullmatch(r"vec(?P<length>[1-9])", name)) is not None:
        length = int(result.group("length"))
        return wp.types.vector(length, _floating())
    if (result := re.fullmatch(r"mat(?P<rows>[1-9])(?P<cols>[1-9])", name)) is not None:
        rows = int(result.group("rows"))
        cols = int(result.group("cols"))
        return wp.types.matrix((rows, cols), _floating())
    msg: str = f"module '{__name__}' has no attribute '{name}'"
    raise AttributeError(msg, name=name, obj=sys.modules[__name__])

matrix

matrix(shape: tuple[int, int]) -> type

Build a Warp matrix dtype using the default floating scalar type.

Source code in src/liblaf/jarp/warp/types.py
def matrix(shape: tuple[int, int]) -> type:
    """Build a Warp matrix dtype using the default floating scalar type."""
    return wp.types.matrix(shape, _floating())

vector

vector(length: int) -> type

Build a Warp vector dtype using the default floating scalar type.

Source code in src/liblaf/jarp/warp/types.py
def vector(length: int) -> type:
    """Build a Warp vector dtype using the default floating scalar type."""
    return wp.types.vector(length, _floating())