-
Notifications
You must be signed in to change notification settings - Fork 428
Improve diskann-disk test coverage #1193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
02c3fb6
94cfbf4
6d26e5a
86e0fc8
ad17a52
31bb404
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,4 +128,30 @@ mod tests { | |
| assert_eq!(pq_scratch.query_scratch[i], query[i]); | ||
| }); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_pq_scratch_set_rejects_short_query() { | ||
| let dim = 16; | ||
| let mut pq_scratch = PQScratch::new(64, dim, 4, 256).unwrap(); | ||
|
|
||
| // Query shorter than dim should fail | ||
| let short_query: Vec<f32> = (1..dim).map(|i| i as f32).collect(); // dim-1 elements | ||
| let err = pq_scratch.set(&short_query).unwrap_err(); | ||
| assert_eq!(err.kind(), diskann::ANNErrorKind::DimensionMismatchError); | ||
| assert!(err.to_string().contains("expected query of length")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_pq_scratch_set_accepts_oversized_query() { | ||
| let dim = 8; | ||
| let mut pq_scratch = PQScratch::new(64, dim, 4, 256).unwrap(); | ||
|
|
||
| // Query longer than dim should succeed (only first `dim` elements used) | ||
| let long_query: Vec<f32> = (1..=dim + 10).map(|i| i as f32).collect(); | ||
| pq_scratch.set(&long_query).unwrap(); | ||
|
|
||
| for (i, &val) in long_query.iter().enumerate().take(dim) { | ||
| assert_eq!(pq_scratch.query_scratch[i], val); | ||
| } | ||
| } | ||
|
Comment on lines
+144
to
+156
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this expected behavior? Shouldn't the scratch fail for an incorrectly sized query?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is the expected behavior, according to the documentation of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed the chain of calls to Can we fix this since we've found it? The reason I'm asking is cause this is actually incorrect behavior; I'm not actually sure how this ended up getting supported (It's probably my fault!). The f32 dimension is not larger than the dimension of minmax vectors, it's actually smaller :) |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.