Skip to main content
Glama
testvectors.py1.17 kB
""" 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"})

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/neuml/txtai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server