codekingpro/portable-devtools
114k
1import numpy as np
2from chromadb.api import ClientAPI
3
4
5def test_invalid_update(client: ClientAPI) -> None:
6 client.reset()
7
8 collection = client.create_collection("test")
9
10 # Update is invalid because ID does not exist
11 collection.update(ids=["foo"], embeddings=[[0.0, 0.0, 0.0]])
12
13 collection.add(ids=["foo"], embeddings=[[1.0, 1.0, 1.0]])
14 result = collection.get(ids=["foo"], include=["embeddings"])
15 # Embeddings should be the same as what was provided to .add()
16 assert result["embeddings"] is not None
17 assert np.allclose(result["embeddings"][0], np.array([1.0, 1.0, 1.0]))
18 