Registry / security / opendp

opendp

JSON →
library0.15.1pypypi✓ verified 83d ago

Python bindings for the OpenDP Library, a modular collection of tools for differential privacy. Current version 0.15.1, released approximately quarterly. Provides a high-level API for privacy-preserving data analysis.

pip install opendp
INSTALL
IMPORT
SIG · OPENDP
O
opendp
securitypythonv0.15.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Measurement
from opendp.typing import Measurement
from opendp import Measurement
Measurement is in opendp.typing
then_count
from opendp.transformations import then_count
from opendp import then_count
Transformations are in opendp.transformations
base_laplace
from opendp.measurements import base_laplace
from opendp import base_laplace
Measurements are in opendp.measurements

Simple differential privacy count query using OpenDP's compositor and transformation chain.

import opendp from opendp.transformations import make_split_dataframe, make_select_column, then_count, then_clamp, then_resize, then_variance, then_mean from opendp.measurements import then_laplace, then_gaussian from opendp.domains import vector_domain, atom_domain from opendp.metrics import symmetric_distance from opendp.typing import L2Sensitivity context = opendp.Context.compositor( data=... , # your data privacy_unit=opendp.parameters.unit('epsilon=1, delta=0.01') ) # Example: count with Laplace noise meas = (opendp.preprocessing.make_split_dataframe(",", ["A", "B"])) >> \ (opendp.transformations.make_select_column("A", TOA=str)) >> \ (then_count()) >> \ (then_laplace(scale=1.0)) released = meas(meas.arg) print(released)
Debug
Known issues
breakingBreaking change in 0.15: Many functions now require explicit typing and domain/metric arguments. Old patterns like `base_laplace()` without explicit `TO` or `L2Sensitivity` fail.
fix
Ensure every measurement/transformation includes explicit type parameters. E.g., `then_laplace(scale=1.0, TO=int)`.
affects: >=0.15
deprecated`make_count` and similar direct measurements are replaced by `then_count` and chaining operations.
fix
Use transformation chains ending with measurement, e.g., `then_count() >> then_laplace(scale=1.0)`.
affects: >=0.9
gotchaThe Context API is not yet stable and may change. Avoid relying on it for production code.
fix
Use the lower-level combinator API (e.g., `make_chain_mt`) for stability.
affects: <1.0
gotchaPrivacy parameters epsilon and delta must be passed as a single string, not separate arguments.
fix
Use `opendp.parameters.unit('epsilon=1, delta=0.01')`.
affects: >=0.12
Errors
Common errors & fixes
AttributeError: module 'opendp' has no attribute 'transformations'
Older import pattern; opendp submodules are not directly exposed.
fix
Use `from opendp.transformations import ...` instead of `opendp.transformations.make_count`.
TypeError: base_laplace() missing 1 required positional argument: 'scale'
Base measurements require scale as an argument; old code might have used default.
fix
Always provide scale: `base_laplace(scale=1.0)`.
NotImplementedError: This operation is not supported.
Using a transformation or measurement before preparing context or chaining correctly.
fix
Ensure the chain consists of transformations ending with a measurement; use `>>` operator.
ImportError: cannot import name 'make_count' from 'opendp.transformations'
`make_count` was removed or renamed to `then_count`.
fix
Use `from opendp.transformations import then_count`.
Upgrade
Version history
0.15.1latest on PyPI · released May 29, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
Resources
opendp — pip install opendp · libregistry