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 5aef266  fix: comment and assertions inconsistency (#106)
5aef266 is described below

commit 5aef2669ce451bf0f0f508afadd39434200ec6e9
Author: Yichi Zhang <[email protected]>
AuthorDate: Thu Mar 5 21:34:11 2026 +0800

    fix: comment and assertions inconsistency (#106)
---
 datasketches/src/cpc/sketch.rs     |  4 ++--
 datasketches/src/cpc/union.rs      |  4 ++--
 datasketches/src/theta/bit_pack.rs | 14 ++++----------
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/datasketches/src/cpc/sketch.rs b/datasketches/src/cpc/sketch.rs
index d11d59b..534f0a0 100644
--- a/datasketches/src/cpc/sketch.rs
+++ b/datasketches/src/cpc/sketch.rs
@@ -97,7 +97,7 @@ impl CpcSketch {
     ///
     /// # Panics
     ///
-    /// Panics if `lg_k` is not in the range `[4, 16]`.
+    /// Panics if `lg_k` is not in the range `[4, 26]`.
     pub fn new(lg_k: u8) -> Self {
         Self::with_seed(lg_k, DEFAULT_UPDATE_SEED)
     }
@@ -106,7 +106,7 @@ impl CpcSketch {
     ///
     /// # Panics
     ///
-    /// Panics if `lg_k` is not in the range `[4, 16]`, or the computed seed 
hash is zero.
+    /// Panics if `lg_k` is not in the range `[4, 26]`, or the computed seed 
hash is zero.
     pub fn with_seed(lg_k: u8, seed: u64) -> Self {
         assert!(
             (MIN_LG_K..=MAX_LG_K).contains(&lg_k),
diff --git a/datasketches/src/cpc/union.rs b/datasketches/src/cpc/union.rs
index 4c68f5a..a983630 100644
--- a/datasketches/src/cpc/union.rs
+++ b/datasketches/src/cpc/union.rs
@@ -91,7 +91,7 @@ impl CpcUnion {
     ///
     /// # Panics
     ///
-    /// Panics if `lg_k` is not in the range `[4, 16]`.
+    /// Panics if `lg_k` is not in the range `[4, 26]`.
     pub fn new(lg_k: u8) -> Self {
         Self::with_seed(lg_k, DEFAULT_UPDATE_SEED)
     }
@@ -100,7 +100,7 @@ impl CpcUnion {
     ///
     /// # Panics
     ///
-    /// Panics if `lg_k` is not in the range `[4, 16]`.
+    /// Panics if `lg_k` is not in the range `[4, 26]`.
     pub fn with_seed(lg_k: u8, seed: u64) -> Self {
         // We begin with the accumulator holding an EMPTY_MERGED sketch object.
         let sketch = CpcSketch::with_seed(lg_k, seed);
diff --git a/datasketches/src/theta/bit_pack.rs 
b/datasketches/src/theta/bit_pack.rs
index 2a59351..013899b 100644
--- a/datasketches/src/theta/bit_pack.rs
+++ b/datasketches/src/theta/bit_pack.rs
@@ -4974,17 +4974,14 @@ fn unpack_bits_63(values: &mut [u64], bytes: &[u8]) {
 ///
 /// * Panics if `values.len()` is not equal to `BLOCK_WIDTH`.
 /// * Panics if `bits` is not in the range `1..=63`.
-/// * Panics if `bytes.len()` is less than `bits * BLOCK_WIDTH`.
+/// * Panics if `bytes.len()` is less than `bits`.
 pub(crate) fn pack_bits_block(values: &[u64], bytes: &mut [u8], bits: u8) {
     assert_eq!(values.len(), BLOCK_WIDTH, "values length must be 8");
     assert!(
         (1..=63).contains(&bits),
         "wrong number of bits in pack_bits_block8: {bits}"
     );
-    assert!(
-        bytes.len() < bits as usize * BLOCK_WIDTH,
-        "output buffer too small"
-    );
+    assert!(bytes.len() >= bits as usize, "output buffer too small");
 
     match bits {
         1 => pack_bits_1(values, bytes),
@@ -5060,17 +5057,14 @@ pub(crate) fn pack_bits_block(values: &[u64], bytes: 
&mut [u8], bits: u8) {
 ///
 /// * Panics if `values.len()` is not equal to `BLOCK_WIDTH`.
 /// * Panics if `bits` is not in the range `1..=63`.
-/// * Panics if `bytes.len()` is less than `bits * BLOCK_WIDTH`.
+/// * Panics if `bytes.len()` is less than `bits`.
 pub(crate) fn unpack_bits_block(values: &mut [u64], bytes: &[u8], bits: u8) {
     assert_eq!(values.len(), BLOCK_WIDTH, "values length must be 8");
     assert!(
         (1..=63).contains(&bits),
         "wrong number of bits in unpack_bits_block8: {bits}"
     );
-    assert!(
-        bytes.len() < bits as usize * BLOCK_WIDTH,
-        "input buffer too small"
-    );
+    assert!(bytes.len() >= bits as usize, "output buffer too small");
 
     match bits {
         1 => unpack_bits_1(values, bytes),


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to