Skip to content

Commit

Permalink
[ENH] Fix random seed in multimodal EF test (#1353)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
atroyn authored Nov 8, 2023
1 parent 161963d commit 933d46d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions chromadb/test/ef/test_multimodal_ef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 933d46d

Please sign in to comment.