Skip to content

fix: preserve single-component vector conversion - #2229

Open
DiadkoShmek wants to merge 1 commit into
weaviate:mainfrom
DiadkoShmek:fix/single-component-vector
Open

DiadkoShmek wants to merge 1 commit into
weaviate:mainfrom
DiadkoShmek:fix/single-component-vector

Conversation

@DiadkoShmek

Copy link
Copy Markdown

Summary

Keep a single-component embedding as a list when get_vector() squeezes a supported array or tensor. np.array([0.5]) and pd.Series([0.5]) currently become the scalar 0.5, despite the helper's list-return contract. _Pack.single() then raises TypeError: object of type 'float' has no len(); the equivalent Python list works.

Wrap scalar conversion results in a list in both the direct squeeze().tolist() path and the numpy() fallback. Existing list results are retained, without flattening multi-vectors or changing request shape classification.

Validation

  • Added regression coverage with actual NumPy float32/float64, pandas, polars and list inputs, including byte-packing parity. A mock tensor exercises the NumPy fallback with one, multiple and zero elements.
  • On unchanged main (d1e185eaa5425cc0884c28689bbaa11d5eec7898), the vector test file reports 4 failed, 9 passed. With this change, vector, utility and byte-operations tests report 57 passed.
  • A separate offline replay constructs near-vector protobuf requests with the real client modules for server version 1.29.0. NumPy/pandas single-component inputs fail before and succeed after; list, two-component and multi-vector controls retain their bytes. No server or RPC was used.
  • Repository-pinned Ruff 0.14.7 checks/formatting, flake8 with development plugins, and git diff --check: passed on both changed files.

Real TensorFlow/PyTorch runtimes and server integration were not tested. The helper also normalizes a zero-dimensional array conversion to a list; zero-dimensional query input remains rejected by the existing shape classifier.

AI disclosure: Codex prepared and tested this change, with a separate AI review of the complete diff and focused cases. No personal human code review is claimed.

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@weaviate-git-bot

Copy link
Copy Markdown

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

@DiadkoShmek

Copy link
Copy Markdown
Author

I agree to the Weaviate Contributor License Agreement: https://weaviate.io/service/contributor-license-agreement

This branch has not been deployed

No deployments
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.

2 participants