chore: import upstream snapshot with attribution
build / build (macos-latest) (push) Has been cancelled
build / build (ubuntu-latest) (push) Has been cancelled
build / build (windows-latest) (push) Has been cancelled
minimal / deploy (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:38:00 +08:00
commit 3a7c47b2a6
623 changed files with 133790 additions and 0 deletions
@@ -0,0 +1,48 @@
"""
Sparse Vectors module tests
"""
import unittest
from txtai.vectors import SparseVectors, SparseVectorsFactory
class TestSparseVectors(unittest.TestCase):
"""
Sparse Vectors tests.
"""
def testCustom(self):
"""
Test custom sparse vectors instance
"""
self.assertIsNotNone(
SparseVectorsFactory.create({"method": "txtai.vectors.SparseSTVectors", "path": "sparse-encoder-testing/splade-bert-tiny-nq"})
)
def testDefaultNormalize(self):
"""
Test defaultnormalize method
"""
vectors = SparseVectors(None, None, None)
self.assertFalse(vectors.defaultnormalize())
def testNotSupported(self):
"""
Test exceptions for unsupported methods
"""
vectors = SparseVectors(None, None, None)
self.assertRaises(ValueError, vectors.truncate, None)
self.assertRaises(ValueError, vectors.quantize, None)
def testNotFound(self):
"""
Test unresolvable vector backend
"""
with self.assertRaises(ImportError):
SparseVectorsFactory.create({"method": "notfound.vectors"})