Questions or feedback?

opendp.extras.numpy package#

Submodules#

Module contents#

This module requires extra installs: pip install 'opendp[numpy]'

For convenience, all the members of this module are also available from opendp.prelude. We suggest importing under the conventional name dp:

>>> import opendp.prelude as dp

The members of this module will then be accessible at dp.numpy.

class opendp.extras.numpy.NPArray2Domain(origin, norm, p, size, num_columns, nan, cardinalities, T)[source]#

Bases: NamedTuple

Parameters:
  • origin (numpy.ndarray | None) –

  • norm (float | None) –

  • p (Literal[1, 2, None]) –

  • size (int | None) –

  • num_columns (int | None) –

  • nan (bool) –

  • cardinalities (numpy.ndarray | None) –

  • T (str | RuntimeType) –

T: str | RuntimeType#

atom type

cardinalities: numpy.ndarray | None#

cardinalities of the categorical columns

nan: bool#

whether NaN values are allowed

norm: float | None#

each row in x is bounded by the norm

num_columns: int | None#

number of columns in the data

origin: numpy.ndarray | None#

center of the norm region

p: Literal[1, 2, None]#

designates L`p` norm

size: int | None#

number of rows in data

class opendp.extras.numpy.NPArrayDDomain(shape, T)[source]#

Bases: NamedTuple

Parameters:
  • shape (tuple[int, ...]) –

  • T (str | RuntimeType) –

T: str | RuntimeType#

atom type

shape: tuple[int, ...]#

shape of the array

opendp.extras.numpy.array2_domain(*, norm=None, p=None, origin=None, size=None, num_columns=None, nan=None, cardinalities=None, T=None)[source]#

Construct a Domain representing 2-dimensional numpy arrays.

Parameters:
  • norm (float | None) – each row in x is bounded by the norm

  • p (Literal[1, 2, None]) – designates L`p` norm

  • origin – center of the norm region. Assumed to be at zero

  • size (int | None) – number of rows in data

  • num_columns (int | None) – number of columns in the data

  • nan (Optional[bool]) – whether NaN values are allowed

  • cardinalities (list[int] | numpy.ndarray | None) – cardinalities of the categorical columns

  • T (RuntimeTypeDescriptor | None) – atom type

Return type:

Domain

opendp.extras.numpy.arrayd_domain(*, shape, T)[source]#

Construct a Domain representing d-dimensional numpy arrays.

Parameters:
  • shape (tuple[int, ...]) – shape of the array

  • T (RuntimeType | str | Type[Sequence[Any] | tuple[Any, Any] | float | str | bool] | tuple[RuntimeTypeDescriptor, ...] | _GenericAlias | GenericAlias) – atom type

Return type:

Domain