Skip to content

Commit

Permalink
removes vector comparison in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-cechmanek committed Dec 19, 2024
1 parent 0e8faab commit 0ea192b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
1 change: 1 addition & 0 deletions redisvl/utils/vectorize/text/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(
If not provided, will use environment variables.
dtype (str): the default datatype to use when embedding text as byte arrays.
Used when setting `as_buffer=True` in calls to embed() and embed_many().
Defaults to 'float32'.
Raises:
ValueError: If credentials are not provided in config or environment.
Expand Down
16 changes: 2 additions & 14 deletions tests/integration/test_vectorizers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import os

import numpy as np
import pytest

from redisvl.redis.utils import buffer_to_array
from redisvl.utils.vectorize import (
AzureOpenAITextVectorizer,
BedrockTextVectorizer,
Expand Down Expand Up @@ -256,7 +254,6 @@ def bad_return_type(text: str) -> str:
def test_dtypes(vector_class, skip_vectorizer):
if skip_vectorizer:
pytest.skip("Skipping vectorizer instantiation...")
words = "test sentence"

# test dtype defaults to float32
if issubclass(vector_class, CustomTextVectorizer):
Expand All @@ -269,16 +266,6 @@ def test_dtypes(vector_class, skip_vectorizer):
vectorizer = vector_class()
assert vectorizer.dtype == "float32"

# test that the dtype can be overwriten in the method calls
raw = vectorizer.embed(words, as_buffer=False, input_type="search_query")
embedding = vectorizer.embed(
words, as_buffer=True, dtype="bfloat16", input_type="search_query"
)
assert np.allclose(buffer_to_array(embedding, dtype="bfloat16"), raw, atol=1e-03)

# test that over writing in method calls does not change initialized dtype
assert vectorizer.dtype == "float32"

# test initializing dtype in constructor
for dtype in ["float16", "float32", "float64", "bfloat16"]:
if issubclass(vector_class, CustomTextVectorizer):
Expand All @@ -287,7 +274,8 @@ def test_dtypes(vector_class, skip_vectorizer):
vectorizer = vector_class(
model=os.getenv(
"AZURE_OPENAI_DEPLOYMENT_NAME", "text-embedding-ada-002"
)
),
dtype=dtype,
)
else:
vectorizer = vector_class(dtype=dtype)
Expand Down

0 comments on commit 0ea192b

Please sign in to comment.