-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2315b9
commit df9c88d
Showing
4 changed files
with
47 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from chromadb.api.types import validate_embeddings, Embeddings | ||
|
||
|
||
def test_embeddings_validation() -> None: | ||
invalid_embeddings = [[0, 0, True], [1.2, 2.24, 3.2]] | ||
|
||
with pytest.raises(ValueError) as e: | ||
validate_embeddings(invalid_embeddings) # type: ignore[arg-type] | ||
|
||
assert "Expected each value in the embedding to be a int or float" in str(e) | ||
|
||
invalid_embeddings = [[0, 0, "invalid"], [1.2, 2.24, 3.2]] | ||
|
||
with pytest.raises(ValueError) as e: | ||
validate_embeddings(invalid_embeddings) # type: ignore[arg-type] | ||
|
||
assert "Expected each value in the embedding to be a int or float" in str(e) | ||
|
||
with pytest.raises(ValueError) as e: | ||
validate_embeddings("invalid") # type: ignore[arg-type] | ||
|
||
assert "Expected embeddings to be a list, got str" in str(e) | ||
|
||
|
||
def test_0dim_embedding_validation() -> None: | ||
embds: Embeddings = [[]] | ||
with pytest.raises(ValueError) as e: | ||
validate_embeddings(embds) | ||
assert "Expected each embedding in the embeddings to be a non-empty list" in str(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters