Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Add centermean validation test

morgan-codedee0416e87be1
diff --git a/test/python/testpipeline/testtrain/testtrainer.py b/test/python/testpipeline/testtrain/testtrainer.py
index b21c60d5..70f16ae9 100644
--- a/test/python/testpipeline/testtrain/testtrainer.py
+++ b/test/python/testpipeline/testtrain/testtrainer.py
@@ -349,6 +349,25 @@ class TestTrainer(unittest.TestCase):
create.assert_not_called()
+ def testLemurCenterMeanValidation(self):
+ """
+ Test LEMUR fit validates the centermean argument
+ """
+
+ random = np.random.default_rng(42)
+ documents = [random.normal(size=(5, 6)).astype(np.float32) for _ in range(8)]
+
+ tests = [
+ np.zeros((2, 6), dtype=np.float32),
+ np.zeros(4, dtype=np.float32),
+ np.full(6, np.nan, dtype=np.float32),
+ ]
+
+ for centermean in tests:
+ with self.subTest(shape=centermean.shape):
+ with self.assertRaisesRegex(ValueError, "centermean must be a finite one-dimensional array"):
+ LemurTrainer().fit(documents, epochs=0, centermean=centermean)
+
def testLemurRoundTrip(self):
"""
Test an ordinary LEMUR artifact save/load round-trip