Commit aabc44d
committed
Fix: treat NumPy uint8 vectors as u8, not bit-packed binary
A NumPy uint8 buffer is ambiguous: the same bytes back both bit-packed
binary vectors (b1x8) and unsigned byte vectors (u8). numpy_string_to_kind
maps uint8 to b1x8 for backwards compatibility, so when no explicit dtype
was passed to add/search, a u8 index reinterpreted its data as packed bits
and the vectors silently collapsed to (near-)zero. int8 worked because it
maps to i8 unambiguously.
Disambiguate against the index's own scalar kind: when the caller gave no
dtype and the buffer resolves to b1x8 but the index is u8, use u8. Binary
indexes are unaffected, so bit-packed uint8 vectors keep working. Applied
at the add, search, and cluster dispatch sites through a shared helper, and
added a scalar_kind() accessor to the multi-shard wrapper so it compiles for
both index types.
Adds a regression test that stores sparse uint8 counts, checks the round
trip and search ranking, and confirms the binary path is untouched. The
test fails on the current code (vector stored as all zeros) and passes with
the fix.
Closes #5951 parent cc23bba commit aabc44d
2 files changed
Lines changed: 65 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
| |||
180 | 183 | | |
181 | 184 | | |
182 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
183 | 204 | | |
184 | 205 | | |
185 | 206 | | |
| |||
286 | 307 | | |
287 | 308 | | |
288 | 309 | | |
289 | | - | |
290 | | - | |
291 | | - | |
| 310 | + | |
292 | 311 | | |
293 | 312 | | |
294 | 313 | | |
| |||
501 | 520 | | |
502 | 521 | | |
503 | 522 | | |
504 | | - | |
505 | | - | |
506 | | - | |
| 523 | + | |
507 | 524 | | |
508 | 525 | | |
509 | 526 | | |
| |||
780 | 797 | | |
781 | 798 | | |
782 | 799 | | |
783 | | - | |
784 | | - | |
785 | | - | |
| 800 | + | |
786 | 801 | | |
787 | 802 | | |
788 | 803 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
168 | 209 | | |
169 | 210 | | |
170 | 211 | | |
| |||
0 commit comments