Skip to content

utils

Utility functions for the drone models.

to_xp(*args, xp, device)

Convert all arrays in the argument list to the given xp framework and device.

Source code in drone_models/utils/__init__.py
def to_xp(*args: Any, xp: ModuleType, device: Any) -> tuple[Array, ...] | Array:
    """Convert all arrays in the argument list to the given xp framework and device."""
    result = tuple(xp.asarray(x, device=device) for x in args)
    if len(result) == 1:
        return result[0]
    return result