"""."""

import numpy as np
import pytest

from nuscenes.utils.data_classes import Box
from pyquaternion import Quaternion

from association_studio.boxes import fill_vec_z, from_vec_z


def test_from_vec_z() -> None:
    box = from_vec_z(np.linspace(1, 10, 10))
    assert isinstance(box, Box)
    assert box.center == pytest.approx(np.linspace(1, 3, 3))
    assert box.orientation.q == pytest.approx(np.linspace(4, 7, 4))
    assert box.wlh == pytest.approx(np.linspace(8, 10, 3))


def test_fill_vec_z() -> None:
    q = Quaternion([1.0, 0.1, 0.2, 0.5])
    box = Box([2.0, 3.0, 4.0], [2.0, 4.0, 6.0], q)
    buf_z = np.zeros(10)
    fill_vec_z(box, buf_z)
    assert buf_z == pytest.approx([2, 3, 4, 1.0, 0.1, 0.2, 0.5, 2.0, 4.0, 6.0])
