qdrant-client icon indicating copy to clipboard operation
qdrant-client copied to clipboard

Remove-np-ninf

Open icfly2 opened this issue 1 year ago • 2 comments

All Submissions:

  • [x] Contributions should target the dev branch. Did you create your branch from dev?
  • [x] Have you followed the guidelines in our Contributing document?
  • [x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. [x] Does your submission pass tests?
  2. [x] Have you installed pre-commit with pip3 install pre-commit and set up hooks with pre-commit install?

Changes to Core Features:

  • [x] Have you added an explanation of what your changes do and why you'd like us to include them?
  • [x] Have you written new tests for your core changes, as applicable?
  • [x] Have you successfully ran tests with your changes locally?

Numpy 2 dropped support for the np.INF and NINF and instead it recomends np.inf and - np.inf

WIP: I'm still looking for the contribution guide, inparticular the how to run the tests locally bit, as I'm not familiar with poetry. Tests pass in the runners but I'm pretty sure the current test suite doesn't cover the changed code.

icfly2 avatar Sep 19 '24 20:09 icfly2

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
Latest commit 66e9cbad27d168b3eeb95a935d1ed059601b4fbb
Latest deploy log https://app.netlify.com/sites/poetic-froyo-8baba7/deploys/66f30dcef9de1b00088f6ac5
Deploy Preview https://deploy-preview-782--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 site configuration.

netlify[bot] avatar Sep 19 '24 20:09 netlify[bot]

I can show that if you upgrade numpy to 2.x it fails the current test suite, but with the change, the client doesn't fail the tests. This requires the client without fastembed, as that is pinned to below 2 for numpy:


qdrant-client on  dev is 📦 v1.11.2 via 🐍 v3.10.13 
❯ poetry run pytest -x
============================== test session starts ==============================
platform linux -- Python 3.12.3, pytest-7.4.4, pluggy-1.5.0
rootdir: /home/rum/qdrant-client
configfile: pyproject.toml
plugins: asyncio-0.21.2, anyio-4.4.0, timeout-2.3.1
asyncio: mode=Mode.STRICT
collected 370 items                                                             

qdrant_client/hybrid/test_reranking.py .                                  [  0%]
qdrant_client/local/tests/test_datetimes.py ..................            [  5%]
qdrant_client/local/tests/test_distances.py .                             [  5%]
qdrant_client/local/tests/test_payload_filters.py ..                      [  5%]
qdrant_client/local/tests/test_payload_utils.py ...                       [  6%]
qdrant_client/local/tests/test_referenced_vectors.py .................... [ 12%]
..........                                                                [ 14%]
qdrant_client/local/tests/test_vectors.py .                               [ 15%]
tests/test_async_qdrant_client.py .....                                   [ 16%]
tests/test_fastembed.py .ssssss                                           [ 18%]
tests/test_in_memory.py .F

=================================== FAILURES ====================================
_______________ test_sparse_in_memory_key_filter_returns_results ________________

qdrant = <qdrant_client.qdrant_client.QdrantClient object at 0x7f58e905e8d0>

    def test_sparse_in_memory_key_filter_returns_results(qdrant: QdrantClient):
        qdrant.create_collection(
            collection_name="test_collection",
            vectors_config={},
            sparse_vectors_config={"text": models.SparseVectorParams()},
        )
    
        operation_info = qdrant.upsert(
            collection_name="test_collection",
            wait=True,
            points=[
                models.PointStruct(
                    id=1,
                    vector={
                        "text": models.SparseVector(
                            indices=[0, 1, 2, 3], values=[0.05, 0.61, 0.76, 0.74]
                        )
                    },
                    payload={"city": "Berlin"},
                ),
                models.PointStruct(
                    id=2,
                    vector={
                        "text": models.SparseVector(
                            indices=[0, 1, 2, 3], values=[0.19, 0.81, 0.75, 0.11]
                        )
                    },
                    payload={"city": ["Berlin", "London"]},
                ),
                models.PointStruct(
                    id=3,
                    vector={
                        "text": models.SparseVector(
                            indices=[0, 1, 2, 3], values=[0.36, 0.55, 0.47, 0.94]
                        )
                    },
                    payload={"city": ["Berlin", "Moscow"]},
                ),
                models.PointStruct(
                    id=4,
                    vector={
                        "text": models.SparseVector(
                            indices=[0, 1, 2, 3], values=[0.18, 0.01, 0.85, 0.80]
                        )
                    },
                    payload={"city": ["London", "Moscow"]},
                ),
            ],
        )
    
        assert operation_info.operation_id == 0
        assert operation_info.status == models.UpdateStatus.COMPLETED
    
>       search_result = qdrant.search(
            collection_name="test_collection",
            query_vector=models.NamedSparseVector(
                name="text",
                vector=models.SparseVector(indices=[0, 1, 2, 3], values=[0.2, 0.1, 0.9, 0.7]),
            ),
            query_filter=models.Filter(
                must=[models.FieldCondition(key="city", match=models.MatchValue(value="London"))]
            ),
            limit=3,
        )

tests/test_in_memory.py:110: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
qdrant_client/qdrant_client.py:387: in search
    return self._client.search(
qdrant_client/local/qdrant_local.py:204: in search
    return collection.search(
qdrant_client/local/local_collection.py:618: in search
    if sparse_scoring and score == np.NINF:

icfly2 avatar Sep 23 '24 13:09 icfly2

Thank you for addressing this

joein avatar Sep 24 '24 19:09 joein