Repository navigation
fix: preserve integer indices in empty SparseEmbedding.from_dict results - #768
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 The empty sparse-embedding indexing fix is ready to merge after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 creates float64 indices, so even assigning empty values withdense[embedding.indices] = embedding.valuesraises NumPy's integer-index error. This sets the empty indices to int64, preserving valid NumPy indexing and integer concatenation.The nonempty conversion and values array are unchanged. Regression tests cover empty arrays/indexing, pairing and dictionary round trips, concatenation, and empty BM25 document embeddings.
Validation on Windows 11, Python 3.13.5, NumPy 2.3.5, FastEmbed 0.8.1:
python -m pytest -q tests/test_sparse_embedding_base.py tests/test_common.py.The full model/OS/Python CI matrix was not run locally.
Split from #766 following the maintainer's request for one PR per problem. This branch is based directly on current main and contains only this problem's production change and regression module.