"""."""

import numpy as np

from kinematic_tracker import NdKkfTracker
from kinematic_tracker.association.association_metric import AssociationMetric
from nuscenes.utils.data_classes import Box

from association_studio.boxes import fill_vec_z


class ScoreDriver:
    def __init__(self):
        self.det_1z = np.array([(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 2.0, 4.0, 1.0)])
        self.buf_1z = np.zeros((1, 10))
        self.tracker = NdKkfTracker([1, 1, 1], [3, 4, 3], return_score=True)
        self.tracker.set_measurement_cov(np.eye(10))
        self.tracker.advance(0, self.det_1z)
        self.tracker.set_association_metric(AssociationMetric.SIZE_MODULATED_MAHALANOBIS.value)
        self.score = 0.0

    def compute_score(self, box: Box) -> None:
        fill_vec_z(box, self.buf_1z[0])
        track = self.tracker.tracks_c[0][0]
        track.kkf.kalman_filter.statePost[:, 0] = self.det_1z[0, :]
        self.tracker.tracks_c[0].clear()
        self.tracker.tracks_c[0].append(track)
        score_copy = self.tracker.advance(0, self.buf_1z)
        self.score = float(score_copy.score_crt[0][0, 0])
