Skip to content

docs: add Bit reference section for pgvector.Bit - #159

Open
HUIIIM wants to merge 1 commit into
pgvector:masterfrom
HUIIIM:docs/bit-reference
Open

HUIIIM wants to merge 1 commit into
pgvector:masterfrom
HUIIIM:docs/bit-reference

Conversation

@HUIIIM

@HUIIIM HUIIIM commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

— vertciti AI team (assisting Jiahui Miao)

Summary

The README's Reference section documents Vector, HalfVector, and
SparseVector, but has no entry for Bit — even though Bit is a public
class exported from pgvector (pgvector/__init__.py lists it in __all__)
[实证], and the README's own SQLAlchemy ("Binary Quantization"), Django
(BitField), and Peewee (FixedBitField) sections all rely on the BIT type
[实证]. This PR adds the missing "Bit Vectors" reference subsection, following
the exact pattern of the existing subsections.

Labels: [实证] = verified from the pgvector 0.5.0 package source and the
README at 60739df.

Testing

Docs-only change. Constructor and round-trip behavior were verified by
executing against the released 0.5.0 package [实证]:
Bit([True, False, True]) -> to_list() == [True, False, True];
Bit("101") -> to_text() == "101"; .to_numpy() returns a bool ndarray.
[未确认: not exercised against a live database in this pass.]

@chrikrah chrikrah 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.

All four snippets under ### Bit Vectors run at 2cad55b and print what the headings promise, so I would merge this.

$ python -c "
from pgvector import Bit
bit = Bit([True, False, True]); print(repr(bit))
bit = Bit('101');              print(repr(bit))
print(bit.to_list())
print(bit.to_numpy())
"
Bit(101)
Bit(101)
[True, False, True]
[ True False  True]
$ python -m pytest tests/test_bit.py -q
17 passed, 2 warnings in 0.04s
# python 3.12.3, numpy 2.5.3, pgvector imported from the PR tree
# not run: the suites that need a live Postgres

non-blocking: a bool NumPy array works too, Bit(np.array([True, False, True])), at pgvector/bit.py:39-52 and tested at tests/test_bit.py:39. An int array raises expected elements to be boolean, so the snippet is not the one ### Vectors uses.

non-blocking: two blank lines sit before ## History, where the rest of the file uses one.

@HUIIIM, was the NumPy constructor left out on purpose?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants