This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 1640af4 fix: tdigest quantile edge case (#63)
1640af4 is described below
commit 1640af48016eea0d5f8fb242236dd71442f22f4d
Author: tison <[email protected]>
AuthorDate: Thu Jan 8 21:10:38 2026 +0800
fix: tdigest quantile edge case (#63)
Signed-off-by: tison <[email protected]>
---
datasketches/src/tdigest/sketch.rs | 2 +-
datasketches/tests/tdigest_test.rs | 9 +++++++++
licenserc.toml | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/datasketches/src/tdigest/sketch.rs
b/datasketches/src/tdigest/sketch.rs
index 037953d..91c90c7 100644
--- a/datasketches/src/tdigest/sketch.rs
+++ b/datasketches/src/tdigest/sketch.rs
@@ -1175,7 +1175,7 @@ impl TDigestView<'_> {
}
let mut right_weight = 0.;
if self.centroids[i + 1].weight.get() == 1 {
- if weight_so_far + dw - weight < 0.5 {
+ if weight_so_far + dw - weight <= 0.5 {
return Some(self.centroids[i + 1].mean);
}
right_weight = 0.5;
diff --git a/datasketches/tests/tdigest_test.rs
b/datasketches/tests/tdigest_test.rs
index 870f3de..b61d779 100644
--- a/datasketches/tests/tdigest_test.rs
+++ b/datasketches/tests/tdigest_test.rs
@@ -228,3 +228,12 @@ fn test_invalid_inputs() {
}
assert!(td.is_empty());
}
+
+#[test]
+fn test_estimate_repeat_values() {
+ let mut tdigest = TDigestMut::default();
+ for _ in 0..20 {
+ tdigest.update(1.0);
+ }
+ assert_eq!(tdigest.quantile(0.9), Some(1.0));
+}
diff --git a/licenserc.toml b/licenserc.toml
index 1937a22..82c6c6b 100644
--- a/licenserc.toml
+++ b/licenserc.toml
@@ -17,4 +17,4 @@
headerPath = "Apache-2.0-ASF.txt"
-includes = ['**/*.rs', '**/*.yml', '**/*.yaml', '**/*.toml']
+includes = ['**/*.py', '**/*.rs', '**/*.yml', '**/*.yaml', '**/*.toml']
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]