opendp.extras.numpy package#

Module contents#

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

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

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

opendp.extras.numpy.array2_domain(*, norm=None, p=None, origin=None, size=None, num_columns=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

  • T (RuntimeTypeDescriptor | None) – atom type

Return type:

Domain

opendp.extras.numpy.make_np_clamp(input_domain, input_metric, norm, p, origin=None)[source]#

Construct a Transformation that clamps the norm of input data.

Parameters:
  • input_domain (Domain) – instance of array2_domain(…)

  • input_metric (Metric) – instance of symmetric_distance()

  • norm – clamp each row to this norm. Required if data is not already bounded

  • p – designates L`p` norm

  • origin – norm clamping is centered on this point. Defaults to zero

Return type:

Transformation