mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-16 23:11:27 +00:00
24 lines
605 B
Python
24 lines
605 B
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import unittest
|
|
|
|
import numpy as np
|
|
|
|
from scene_search.meili import Meili
|
|
|
|
|
|
class MeiliVectorSerializationTests(unittest.TestCase):
|
|
def test_numpy_float32_vector_is_json_serializable(self) -> None:
|
|
vector = np.asarray([0.125, -0.25, 0.5], dtype=np.float32)
|
|
|
|
converted = Meili._json_vector(vector)
|
|
|
|
self.assertEqual(converted, [0.125, -0.25, 0.5])
|
|
self.assertTrue(all(type(value) is float for value in converted))
|
|
json.dumps({"vector": converted}, allow_nan=False)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|