mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
Remove hamming option from string distance tests (#9882)
Description: We should not test Hamming string distance for strings that are not equal length, since this is not defined. Removing hamming distance tests for unequal string distances.
This commit is contained in:
parent
e6b7d9f65b
commit
2bd9f5da7f
@ -56,8 +56,13 @@ async def test_zero_distance_pairwise_async(distance: StringDistance) -> None:
|
|||||||
assert result["score"] == 0
|
assert result["score"] == 0
|
||||||
|
|
||||||
|
|
||||||
|
valid_distances = [
|
||||||
|
distance for distance in StringDistance if distance != StringDistance.HAMMING
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.requires("rapidfuzz")
|
@pytest.mark.requires("rapidfuzz")
|
||||||
@pytest.mark.parametrize("distance", list(StringDistance))
|
@pytest.mark.parametrize("distance", valid_distances)
|
||||||
@pytest.mark.parametrize("normalize_score", [True, False])
|
@pytest.mark.parametrize("normalize_score", [True, False])
|
||||||
def test_non_zero_distance(distance: StringDistance, normalize_score: bool) -> None:
|
def test_non_zero_distance(distance: StringDistance, normalize_score: bool) -> None:
|
||||||
eval_chain = StringDistanceEvalChain(
|
eval_chain = StringDistanceEvalChain(
|
||||||
@ -74,7 +79,7 @@ def test_non_zero_distance(distance: StringDistance, normalize_score: bool) -> N
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.requires("rapidfuzz")
|
@pytest.mark.requires("rapidfuzz")
|
||||||
@pytest.mark.parametrize("distance", list(StringDistance))
|
@pytest.mark.parametrize("distance", valid_distances)
|
||||||
async def test_non_zero_distance_async(distance: StringDistance) -> None:
|
async def test_non_zero_distance_async(distance: StringDistance) -> None:
|
||||||
eval_chain = StringDistanceEvalChain(distance=distance)
|
eval_chain = StringDistanceEvalChain(distance=distance)
|
||||||
prediction = "I like to eat apples."
|
prediction = "I like to eat apples."
|
||||||
@ -87,7 +92,7 @@ async def test_non_zero_distance_async(distance: StringDistance) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.requires("rapidfuzz")
|
@pytest.mark.requires("rapidfuzz")
|
||||||
@pytest.mark.parametrize("distance", list(StringDistance))
|
@pytest.mark.parametrize("distance", valid_distances)
|
||||||
def test_non_zero_distance_pairwise(distance: StringDistance) -> None:
|
def test_non_zero_distance_pairwise(distance: StringDistance) -> None:
|
||||||
eval_chain = PairwiseStringDistanceEvalChain(distance=distance)
|
eval_chain = PairwiseStringDistanceEvalChain(distance=distance)
|
||||||
prediction = "I like to eat apples."
|
prediction = "I like to eat apples."
|
||||||
@ -101,7 +106,7 @@ def test_non_zero_distance_pairwise(distance: StringDistance) -> None:
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.requires("rapidfuzz")
|
@pytest.mark.requires("rapidfuzz")
|
||||||
@pytest.mark.parametrize("distance", list(StringDistance))
|
@pytest.mark.parametrize("distance", valid_distances)
|
||||||
async def test_non_zero_distance_pairwise_async(distance: StringDistance) -> None:
|
async def test_non_zero_distance_pairwise_async(distance: StringDistance) -> None:
|
||||||
eval_chain = PairwiseStringDistanceEvalChain(distance=distance)
|
eval_chain = PairwiseStringDistanceEvalChain(distance=distance)
|
||||||
prediction = "I like to eat apples."
|
prediction = "I like to eat apples."
|
||||||
|
Loading…
Reference in New Issue
Block a user