Repository navigation
fix: preserve integer indices in empty SparseEmbedding.from_dict results - #762
RAMZI0TO99 wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Empty sparse embeddings now keep integer indices, so they can index NumPy arrays and concatenate without promoting indices to float. The change is small and well covered by the added tests, so merge risk is minimal. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
SparseEmbedding.from_dict({}) currently returns float64 indices, despite the
class declaring integer indices. Using the empty embedding to index a NumPy
array raises IndexError. Concatenating it with nonempty integer indices also
promotes the combined indices to float64.
Specify dtype=np.int64 in the empty-input branch. Add regression tests for
empty indexing, nonempty pairing and dictionary roundtrips, concatenation in
both orders, and real BM25 document embedding after all tokens are filtered.
Reproduction:
Before: float64 indices, followed by
IndexError: arrays used as indices must be of integer (or boolean) type.After: int64 indices and
Result: [0. 0. 0. 0. 0.].Environment: Windows 11 build 10.0.26200, Python 3.13.5, NumPy 2.3.5,
FastEmbed 0.8.1 installed from upstream commit
7d36728.
Validation:
BM25 argument-validation tests on Python 3.10.11 / NumPy 2.2.6.
NumPy 2.3.5. A local sandbox temporary-directory restriction prevented the
three BM25 cases from running in that environment; all three pass on 3.10.
The BM25 tests use local temporary paths and inline stopwords and require no
downloads. Related historical PR #285 added the empty-input branch but did
not preserve its index dtype: #285
All Submissions
found in ten all-state GitHub searches and the newest ten open PR diffs;
API rate limits prevented inspecting the remaining 21 open PR diffs.