Skip to content

test: add unit tests for local sparse-vector helpers#1256

Open
eeshsaxena wants to merge 1 commit into
qdrant:masterfrom
eeshsaxena:test/sparse-utils
Open

test: add unit tests for local sparse-vector helpers#1256
eeshsaxena wants to merge 1 commit into
qdrant:masterfrom
eeshsaxena:test/sparse-utils

Conversation

@eeshsaxena

Copy link
Copy Markdown

Description

qdrant_client/local/sparse.py holds the client-side sparse-vector
helpers but had no dedicated test module (only incidental use in fixtures).
This adds tests/test_sparse.py covering:

  • empty_sparse_vector() producing empty indices/values
  • validate_sparse_vector() accepting a well-formed vector and raising
    AssertionError on length mismatch, NaN values, and duplicate indices
  • is_sorted() on empty/single-element and sorted vs. unsorted inputs
  • sort_sparse_vector() ordering indices while carrying values along, and
    returning the input unchanged when it is already sorted

No source changes.

Verification

pytest tests/test_sparse.py - 9 passed. ruff check / ruff format --check clean.

@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit ee5bdcb
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/6a4e7820afe64600074d8eea
😎 Deploy Preview https://deploy-preview-1256--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

This PR adds a new test file, tests/test_sparse.py, containing pytest-based tests for Qdrant's local sparse-vector utility functions. The tests cover empty_sparse_vector creation, validate_sparse_vector acceptance and rejection scenarios (length mismatch, NaN values, duplicate indices), is_sorted behavior on empty, single-element, sorted, and unsorted vectors, and sort_sparse_vector correctness including an identity short-circuit case for already-sorted input.

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant