opendp.domains module#
The domains
module provides functions for creating and using domains.
For more context, see domains in the User Guide.
For convenience, all the functions of this module are also available from opendp.prelude
.
We suggest importing under the conventional name dp
:
>>> import opendp.prelude as dp
- opendp.domains.atom_domain(bounds=None, nullable=False, T=None)[source]#
Construct an instance of
AtomDomain
.atom_domain in Rust documentation.
- Parameters:
bounds –
nullable (bool) –
T (Type Argument) – The type of the atom.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- Example:
>>> dp.atom_domain(T=float) AtomDomain(T=f64)
- opendp.domains.domain_carrier_type(this)[source]#
Get the carrier type of a
domain
.- Parameters:
this (Domain) – The domain to retrieve the carrier type from.
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.domain_debug(this)[source]#
Debug a
domain
.- Parameters:
this (Domain) – The domain to debug (stringify).
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.domain_type(this)[source]#
Get the type of a
domain
.- Parameters:
this (Domain) – The domain to retrieve the type from.
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.expr_domain(lazyframe_domain, grouping_columns=None)[source]#
Construct an ExprDomain from a LazyFrameDomain.
Must pass either
context
orgrouping_columns
.- Parameters:
lazyframe_domain (Domain) – the domain of the LazyFrame to be constructed
grouping_columns (list[str]) – set when creating an expression that aggregates
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.lazyframe_domain(series_domains)[source]#
Construct an instance of
LazyFrameDomain
.- Parameters:
series_domains – Domain of each series in the lazyframe.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.map_domain(key_domain, value_domain)[source]#
Construct an instance of
MapDomain
.- Parameters:
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.member(this, val)[source]#
Check membership in a
domain
.- Parameters:
this (Domain) – The domain to check membership in.
val – A potential element of the domain.
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.option_domain(element_domain, D=None)[source]#
Construct an instance of
OptionDomain
.option_domain in Rust documentation.
- Parameters:
element_domain (Domain) –
D (Type Argument) – The type of the inner domain.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.series_domain(name, element_domain)[source]#
Construct an instance of
SeriesDomain
.series_domain in Rust documentation.
- Parameters:
name (str) – The name of the series.
element_domain (Domain) – The domain of elements in the series.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.user_domain(identifier, member, descriptor=None)[source]#
Construct a new UserDomain. Any two instances of an UserDomain are equal if their string descriptors are equal. Contains a function used to check if any value is a member of the domain.
- Parameters:
identifier (str) – A string description of the data domain.
member – A function used to test if a value is a member of the data domain.
descriptor – Additional constraints on the domain.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.vector_domain(atom_domain, size=None)[source]#
Construct an instance of
VectorDomain
.- Parameters:
atom_domain (Domain) – The inner domain.
size –
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.domains.with_margin(frame_domain, by, max_partition_length=None, max_num_partitions=None, max_partition_contributions=None, max_influenced_partitions=None, public_info=None)[source]#
- Parameters:
frame_domain (Domain) –
by –
max_partition_length –
max_num_partitions –
max_partition_contributions –
max_influenced_partitions –
public_info (str) –
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library