From 933d46d8c239b630205a13481e4bbff047398b11 Mon Sep 17 00:00:00 2001 From: Anton Troynikov Date: Tue, 7 Nov 2023 18:18:47 -0800 Subject: [PATCH] [ENH] Fix random seed in multimodal EF test (#1353) ## Description of changes Because the multimodal embedding function test generates random images and documents, it's possible for it to randomly get into a degenerate state with respect to the index. To avoid this, we fix the seed. ## Test plan This is the test. - [x] Tests pass locally with `pytest` for python, `yarn test` for js ## Documentation Changes None --- chromadb/test/ef/test_multimodal_ef.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chromadb/test/ef/test_multimodal_ef.py b/chromadb/test/ef/test_multimodal_ef.py index 52213c77a4c..82f66fea33e 100644 --- a/chromadb/test/ef/test_multimodal_ef.py +++ b/chromadb/test/ef/test_multimodal_ef.py @@ -55,6 +55,10 @@ def test_multimodal( n_examples: int = 10, n_query_results: int = 3, ) -> None: + # Fix numpy's random seed for reproducibility + random_state = np.random.get_state() + np.random.seed(0) + image_ids = [str(i) for i in range(n_examples)] images = [random_image() for _ in range(n_examples)] image_embeddings = default_ef(images) @@ -131,6 +135,7 @@ def test_multimodal( ) assert query_result["ids"][0] == nearest_document_neighbor_ids + np.random.set_state(random_state) @pytest.mark.xfail