Skip to content

Conversation

@jdavyy
Copy link

@jdavyy jdavyy commented Dec 6, 2025

Description of changes

This PR clarifies the Vector type alias in base_types.py to explicitly represent a 1D float32 NumPy array.

  • Improvements
    • Replaces NDArray[Union[np.int32, np.float32]] with NDArray[np.float32]
    • Removes ambiguity around vector dimensionality and dtype
    • Aligns the type alias with the expected embedding format used throughout the project

Fixes #5879

Test plan

This change does not affect runtime behavior. It only updates type hints.

  • mypy runs locally without errors in base_types.py
  • Full test suite not required for typing-only change, but CI will validate compatibility

Migration plan

No migration required. This is a non-breaking clarification to type hints only.

Observability plan

No observability changes required. This update does not alter runtime code paths.

Documentation Changes

No user-facing documentation changes required. This update improves type clarity internally without affecting public APIs.

@github-actions
Copy link

github-actions bot commented Dec 6, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@propel-code-bot
Copy link
Contributor

Narrowed Vector type alias to float32 arrays

The PR updates the Vector type alias in chromadb/base_types.py, restricting it from NDArray[Union[np.int32, np.float32]] to NDArray[np.float32]. This aims to clarify that vectors are expected to use float32 embeddings without altering runtime behavior.

Key Changes

• Updated Vector alias in chromadb/base_types.py to NDArray[np.float32] to reflect float32 embedding usage.

Affected Areas

chromadb/base_types.py typing definitions

This summary was automatically generated by @propel-code-bot

UpdateMetadata = Mapping[str, Union[int, float, str, bool, SparseVector, None]]
PyVector = Union[Sequence[float], Sequence[int]]
Vector = NDArray[Union[np.int32, np.float32]] # TODO: Specify that the vector is 1D
Vector = NDArray[np.float32] #Clarified to represent a 1D float32 vector
Copy link
Contributor

Choose a reason for hiding this comment

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

Advisory

[Style] Good clarification. To make the comment more durable and descriptive of the code itself (rather than the change), consider rephrasing it to explain what the type represents. Also, PEP 8 suggests a space after the # for inline comments.

Context for Agents
Good clarification. To make the comment more durable and descriptive of the code itself (rather than the change), consider rephrasing it to explain what the type represents. Also, PEP 8 suggests a space after the `#` for inline comments.

File: chromadb/base_types.py
Line: 122

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.

Clarify Vector type alias to specify 1D NDArray in base_types.py

1 participant