Registry / data / ddsketch

ddsketch

JSON →
library3.0.1pypypi✓ verified 26d ago

DDSketch is a Python library for distributed quantile sketches, an algorithm for estimating quantiles with guaranteed relative accuracy. It allows for merging sketches from different sources while maintaining accuracy. The current version is 3.0.1. Releases are made as needed for bug fixes, Python version compatibility, or feature enhancements.

pip install ddsketch
INSTALL
IMPORT
SIG · DDSKETCH
D
ddsketch
datapythonv3.0.1
Install
1.9s avg
Import
22ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.022s · 19.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.9s · import 0.021s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DDSketch
from ddsketch import DDSketch
from ddsketch.ddsketch import DDSketch
The DDSketch class was moved to the top-level package namespace in v2.0.0 for easier access.

This example demonstrates initializing a DDSketch, adding data points, retrieving quantiles, and merging with another sketch.

from ddsketch import DDSketch # Initialize a DDSketch with a desired relative accuracy s = DDSketch(relative_accuracy=0.01) # 1% relative accuracy # Add data points s.add(1.0) s.add(2.0) s.add(3.0) s.add(10.0, count=5) # Add 10.0 five times # Get quantiles print(f"Value at 0.5 quantile: {s.get_value_at_quantile(0.5)}") print(f"Value at 0.9 quantile: {s.get_value_at_quantile(0.9)}") # Get min/max values print(f"Min value: {s.min_value}") print(f"Max value: {s.max_value}") # Merge another sketch s2 = DDSketch(relative_accuracy=0.01) s2.add(20.0) s.merge(s2) print(f"Value at 0.95 quantile after merge: {s.get_value_at_quantile(0.95)}")
Debug
Known issues
breakingPython 2.x and Python 3.6 support has been dropped. The library now requires Python >= 3.7.
fix
Upgrade your Python environment to 3.7 or newer. If you need older Python support, use `ddsketch<3.0.0`.
affects: >=3.0.0
breakingThe `numpy` dependency was removed. If your project explicitly relied on `ddsketch` pulling in `numpy`, you will need to add it as a direct dependency to your project.
fix
No action needed for `ddsketch` functionality, but if you require `numpy`, add `pip install numpy` to your project's dependencies.
affects: >=2.0.0
breakingMany `DDSketch` attributes such as `mapping`, `store`, `negative_store`, `zero_count`, `relative_accuracy`, `min`, and `max` were removed from direct access.
fix
Access these attributes via new properties or methods (e.g., `s.min_value`, `s.max_value`) or use the newly exposed top-level `stores` and `mappings` for custom implementations. Review the v2.0.0 release notes for specific attribute replacements.
affects: >=2.0.0
deprecatedProtobuf serialization is now an optional dependency. If you use `DDSketch.to_proto()` or `DDSketch.from_proto()`, you must install the `serialization` extra.
fix
Install with `pip install ddsketch[serialization]` to ensure Protobuf functionality is available.
affects: >=3.0.0
gotchaThe import path for `DDSketch` changed from `ddsketch.ddsketch.DDSketch` to `ddsketch.DDSketch` to simplify top-level access.
fix
Update import statements from `from ddsketch.ddsketch import DDSketch` to `from ddsketch import DDSketch`.
affects: >=2.0.0
breakingThe `DDSketch.add()` method no longer accepts a `count` keyword argument. Instead, it accepts `value` and an optional `weight`.
fix
Remove the `count` keyword argument when calling `DDSketch.add()`. If you need to add a value multiple times, call `add()` repeatedly or use the `weight` parameter if adding a value with a specific weight.
affects: >=3.0.0
breakingThe `add()` method signature changed; it no longer accepts a `count` keyword argument. To add a value multiple times, call `add()` in a loop.
fix
Replace calls like `s.add(value, count=N)` with a loop, e.g., `for _ in range(N): s.add(value)`.
affects: >=2.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'ddsketch'
The `ddsketch` library is not installed in the current Python environment, or there's a typo in the import statement.
fix
Ensure the library is installed using pip: `pip install ddsketch`. If it's installed, double-check the import statement for typos, it should be `from ddsketch import DDSketch`.
AttributeError: module 'ddsketch' has no attribute 'DDSketch'
The `DDSketch` class is not directly available under the `ddsketch` module or there's a case sensitivity issue or a typo in the class name.
fix
The correct way to import the main class is `from ddsketch import DDSketch`. Ensure the capitalization and class name are exact as `DDSketch`.
TypeError: DDSketch() takes no arguments
The `DDSketch` constructor was called with arguments, but the default constructor for `ddsketch.DDSketch` (as of version 3.0.1) expects no arguments for basic instantiation, or the arguments provided are incorrect.
fix
Instantiate the DDSketch without arguments: `sketch = DDSketch()`. If you intend to set configuration like `relative_accuracy`, use the appropriate constructor or setter methods if they exist, or refer to the documentation for advanced constructors like `DDSketch(relative_accuracy=0.01)` if available in a specific version or subclass.
Upgrade
Version history
3.0.1latest on PyPI · released Apr 1, 2024
Audit
Dependencies
protobufoptionalRequired for serializing/deserializing DDSketch objects to/from Protocol Buffers. This is an optional dependency.
Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources
ddsketch — pip install ddsketch · libregistry