fix: format test files with latest ruff version for CI compatibility
This commit is contained in:
@@ -71,9 +71,9 @@ def test_diskann_without_partition():
|
|||||||
|
|
||||||
for partition_file in partition_files:
|
for partition_file in partition_files:
|
||||||
file_path = index_dir / partition_file
|
file_path = index_dir / partition_file
|
||||||
assert (
|
assert not file_path.exists(), (
|
||||||
not file_path.exists()
|
f"Partition file {partition_file} should not exist in non-partition mode"
|
||||||
), f"Partition file {partition_file} should not exist in non-partition mode"
|
)
|
||||||
|
|
||||||
# Test search functionality
|
# Test search functionality
|
||||||
searcher = LeannSearcher(index_path)
|
searcher = LeannSearcher(index_path)
|
||||||
@@ -137,9 +137,9 @@ def test_diskann_with_partition():
|
|||||||
|
|
||||||
for large_file in large_files:
|
for large_file in large_files:
|
||||||
file_path = index_dir / large_file
|
file_path = index_dir / large_file
|
||||||
assert (
|
assert not file_path.exists(), (
|
||||||
not file_path.exists()
|
f"Large file {large_file} should have been deleted for storage saving"
|
||||||
), f"Large file {large_file} should have been deleted for storage saving"
|
)
|
||||||
|
|
||||||
# Verify required auxiliary files for partition mode exist
|
# Verify required auxiliary files for partition mode exist
|
||||||
required_files = [
|
required_files = [
|
||||||
@@ -149,9 +149,9 @@ def test_diskann_with_partition():
|
|||||||
|
|
||||||
for req_file in required_files:
|
for req_file in required_files:
|
||||||
file_path = index_dir / req_file
|
file_path = index_dir / req_file
|
||||||
assert (
|
assert file_path.exists(), (
|
||||||
file_path.exists()
|
f"Required auxiliary file {req_file} missing for partition mode"
|
||||||
), f"Required auxiliary file {req_file} missing for partition mode"
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
@@ -203,21 +203,21 @@ def test_diskann_partition_search_functionality():
|
|||||||
|
|
||||||
# Verify search results
|
# Verify search results
|
||||||
assert len(results) == top_k, f"Expected {top_k} results for query '{query}'"
|
assert len(results) == top_k, f"Expected {top_k} results for query '{query}'"
|
||||||
assert all(
|
assert all(result.score is not None for result in results), (
|
||||||
result.score is not None for result in results
|
"All results should have scores"
|
||||||
), "All results should have scores"
|
)
|
||||||
assert all(
|
assert all(result.score != float("-inf") for result in results), (
|
||||||
result.score != float("-inf") for result in results
|
"No result should have -inf score"
|
||||||
), "No result should have -inf score"
|
)
|
||||||
assert all(
|
assert all(result.text is not None for result in results), (
|
||||||
result.text is not None for result in results
|
"All results should have text"
|
||||||
), "All results should have text"
|
)
|
||||||
|
|
||||||
# Scores should be in descending order (higher similarity first)
|
# Scores should be in descending order (higher similarity first)
|
||||||
scores = [result.score for result in results]
|
scores = [result.score for result in results]
|
||||||
assert scores == sorted(
|
assert scores == sorted(scores, reverse=True), (
|
||||||
scores, reverse=True
|
"Results should be sorted by score descending"
|
||||||
), "Results should be sorted by score descending"
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
@@ -286,9 +286,9 @@ def test_diskann_medoid_and_norm_files():
|
|||||||
|
|
||||||
# Verify that scores are not -inf (which indicates norm file was loaded correctly)
|
# Verify that scores are not -inf (which indicates norm file was loaded correctly)
|
||||||
assert len(results) > 0
|
assert len(results) > 0
|
||||||
assert all(
|
assert all(result.score != float("-inf") for result in results), (
|
||||||
result.score != float("-inf") for result in results
|
"Scores should not be -inf when norm file is correct"
|
||||||
), "Scores should not be -inf when norm file is correct"
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ def test_readme_basic_example(backend_name):
|
|||||||
# Verify search results
|
# Verify search results
|
||||||
assert len(results) > 0
|
assert len(results) > 0
|
||||||
assert isinstance(results[0], SearchResult)
|
assert isinstance(results[0], SearchResult)
|
||||||
assert results[0].score != float(
|
assert results[0].score != float("-inf"), (
|
||||||
"-inf"
|
f"should return valid scores, got {results[0].score}"
|
||||||
), f"should return valid scores, got {results[0].score}"
|
)
|
||||||
# The second text about banana-crocodile should be more relevant
|
# The second text about banana-crocodile should be more relevant
|
||||||
assert "banana" in results[0].text or "crocodile" in results[0].text
|
assert "banana" in results[0].text or "crocodile" in results[0].text
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user