Source code for opendp.core

# Auto-generated. Do not edit.
from opendp._convert import *
from opendp._lib import *
from opendp.mod import *
from opendp.typing import *

__all__ = [
    "_error_free",
    "_measurement_free",
    "_transformation_free",
    "measurement_check",
    "measurement_input_carrier_type",
    "measurement_input_distance_type",
    "measurement_invoke",
    "measurement_map",
    "measurement_output_distance_type",
    "transformation_check",
    "transformation_input_carrier_type",
    "transformation_input_distance_type",
    "transformation_invoke",
    "transformation_map",
    "transformation_output_distance_type"
]


def _error_free(
    this: FfiError
) -> bool:
    """Internal function. Free the memory associated with `error`.
    
    [_error_free in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn._error_free.html)
    
    :param this: 
    :type this: FfiError
    :return: A boolean, where true indicates successful free
    :rtype: bool
    :raises TypeError: if an argument's type differs from the expected type
    :raises UnknownTypeError: if a type argument fails to parse
    """
    # No type arguments to standardize.
    # No arguments to convert to c types.
    # Call library function.
    function = lib.opendp_core___error_free
    function.argtypes = [ctypes.POINTER(FfiError)]
    function.restype = ctypes.c_bool
    
    return c_to_py(function(this))


def _measurement_free(
    this: Measurement
):
    """Internal function. Free the memory associated with `this`.
    
    [_measurement_free in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn._measurement_free.html)
    
    :param this: 
    :type this: Measurement
    :raises TypeError: if an argument's type differs from the expected type
    :raises UnknownTypeError: if a type argument fails to parse
    :raises OpenDPException: packaged error from the core OpenDP library
    """
    # No type arguments to standardize.
    # No arguments to convert to c types.
    # Call library function.
    function = lib.opendp_core___measurement_free
    function.argtypes = [Measurement]
    function.restype = FfiResult
    
    return c_to_py(unwrap(function(this), ctypes.c_void_p))


def _transformation_free(
    this: Transformation
):
    """Internal function. Free the memory associated with `this`.
    
    [_transformation_free in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn._transformation_free.html)
    
    :param this: 
    :type this: Transformation
    :raises TypeError: if an argument's type differs from the expected type
    :raises UnknownTypeError: if a type argument fails to parse
    :raises OpenDPException: packaged error from the core OpenDP library
    """
    # No type arguments to standardize.
    # No arguments to convert to c types.
    # Call library function.
    function = lib.opendp_core___transformation_free
    function.argtypes = [Transformation]
    function.restype = FfiResult
    
    return c_to_py(unwrap(function(this), ctypes.c_void_p))


[docs]def measurement_check( measurement: Measurement, distance_in: Any, distance_out: Any ): """Check the privacy relation of the `measurement` at the given `d_in`, `d_out` [measurement_check in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.measurement_check.html) :param measurement: Measurement to check the privacy relation of. :type measurement: Measurement :param distance_in: :type distance_in: Any :param distance_out: :type distance_out: Any :return: True indicates that the relation passed at the given distance. :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. measurement = py_to_c(measurement, c_type=Measurement, type_name=None) distance_in = py_to_c(distance_in, c_type=AnyObjectPtr, type_name=measurement_input_distance_type(measurement)) distance_out = py_to_c(distance_out, c_type=AnyObjectPtr, type_name=measurement_output_distance_type(measurement)) # Call library function. function = lib.opendp_core__measurement_check function.argtypes = [Measurement, AnyObjectPtr, AnyObjectPtr] function.restype = FfiResult return c_to_py(unwrap(function(measurement, distance_in, distance_out), BoolPtr))
[docs]def measurement_input_carrier_type( this: Measurement ) -> str: """Get the input (carrier) data type of `this`. [measurement_input_carrier_type in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.measurement_input_carrier_type.html) :param this: The measurement to retrieve the type from. :type this: Measurement :rtype: str :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. this = py_to_c(this, c_type=Measurement, type_name=None) # Call library function. function = lib.opendp_core__measurement_input_carrier_type function.argtypes = [Measurement] function.restype = FfiResult return c_to_py(unwrap(function(this), ctypes.c_char_p))
[docs]def measurement_input_distance_type( this: Measurement ) -> str: """Get the input distance type of `measurement`. [measurement_input_distance_type in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.measurement_input_distance_type.html) :param this: The measurement to retrieve the type from. :type this: Measurement :rtype: str :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. this = py_to_c(this, c_type=Measurement, type_name=None) # Call library function. function = lib.opendp_core__measurement_input_distance_type function.argtypes = [Measurement] function.restype = FfiResult return c_to_py(unwrap(function(this), ctypes.c_char_p))
[docs]def measurement_invoke( this: Measurement, arg: Any ) -> Any: """Invoke the `measurement` with `arg`. Returns a differentially private release. [measurement_invoke in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.measurement_invoke.html) :param this: Measurement to invoke. :type this: Measurement :param arg: Input data to supply to the measurement. A member of the measurement's input domain. :type arg: Any :rtype: Any :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. this = py_to_c(this, c_type=Measurement, type_name=None) arg = py_to_c(arg, c_type=AnyObjectPtr, type_name=measurement_input_carrier_type(this)) # Call library function. function = lib.opendp_core__measurement_invoke function.argtypes = [Measurement, AnyObjectPtr] function.restype = FfiResult return c_to_py(unwrap(function(this, arg), AnyObjectPtr))
[docs]def measurement_map( measurement: Measurement, distance_in: Any ) -> Any: """Use the `measurement` to map a given `d_in` to `d_out`. [measurement_map in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.measurement_map.html) :param measurement: Measurement to check the map distances with. :type measurement: Measurement :param distance_in: Distance in terms of the input metric. :type distance_in: Any :rtype: Any :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. measurement = py_to_c(measurement, c_type=Measurement, type_name=None) distance_in = py_to_c(distance_in, c_type=AnyObjectPtr, type_name=measurement_input_distance_type(measurement)) # Call library function. function = lib.opendp_core__measurement_map function.argtypes = [Measurement, AnyObjectPtr] function.restype = FfiResult return c_to_py(unwrap(function(measurement, distance_in), AnyObjectPtr))
[docs]def measurement_output_distance_type( this: Measurement ) -> str: """Get the output distance type of `measurement`. [measurement_output_distance_type in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.measurement_output_distance_type.html) :param this: The measurement to retrieve the type from. :type this: Measurement :rtype: str :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. this = py_to_c(this, c_type=Measurement, type_name=None) # Call library function. function = lib.opendp_core__measurement_output_distance_type function.argtypes = [Measurement] function.restype = FfiResult return c_to_py(unwrap(function(this), ctypes.c_char_p))
[docs]def transformation_check( transformation: Transformation, distance_in: Any, distance_out: Any ): """Check the privacy relation of the `measurement` at the given `d_in`, `d_out` [transformation_check in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.transformation_check.html) :param transformation: :type transformation: Transformation :param distance_in: :type distance_in: Any :param distance_out: :type distance_out: Any :return: True indicates that the relation passed at the given distance. :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. transformation = py_to_c(transformation, c_type=Transformation, type_name=None) distance_in = py_to_c(distance_in, c_type=AnyObjectPtr, type_name=transformation_input_distance_type(transformation)) distance_out = py_to_c(distance_out, c_type=AnyObjectPtr, type_name=transformation_output_distance_type(transformation)) # Call library function. function = lib.opendp_core__transformation_check function.argtypes = [Transformation, AnyObjectPtr, AnyObjectPtr] function.restype = FfiResult return c_to_py(unwrap(function(transformation, distance_in, distance_out), BoolPtr))
[docs]def transformation_input_carrier_type( this: Transformation ) -> str: """Get the input (carrier) data type of `this`. [transformation_input_carrier_type in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.transformation_input_carrier_type.html) :param this: The transformation to retrieve the type from. :type this: Transformation :rtype: str :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. this = py_to_c(this, c_type=Transformation, type_name=None) # Call library function. function = lib.opendp_core__transformation_input_carrier_type function.argtypes = [Transformation] function.restype = FfiResult return c_to_py(unwrap(function(this), ctypes.c_char_p))
[docs]def transformation_input_distance_type( this: Transformation ) -> str: """Get the input distance type of `transformation`. [transformation_input_distance_type in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.transformation_input_distance_type.html) :param this: The transformation to retrieve the type from. :type this: Transformation :rtype: str :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. this = py_to_c(this, c_type=Transformation, type_name=None) # Call library function. function = lib.opendp_core__transformation_input_distance_type function.argtypes = [Transformation] function.restype = FfiResult return c_to_py(unwrap(function(this), ctypes.c_char_p))
[docs]def transformation_invoke( this: Transformation, arg: Any ) -> Any: """Invoke the `transformation` with `arg`. Returns a differentially private release. [transformation_invoke in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.transformation_invoke.html) :param this: Transformation to invoke. :type this: Transformation :param arg: Input data to supply to the transformation. A member of the transformation's input domain. :type arg: Any :rtype: Any :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. this = py_to_c(this, c_type=Transformation, type_name=None) arg = py_to_c(arg, c_type=AnyObjectPtr, type_name=transformation_input_carrier_type(this)) # Call library function. function = lib.opendp_core__transformation_invoke function.argtypes = [Transformation, AnyObjectPtr] function.restype = FfiResult return c_to_py(unwrap(function(this, arg), AnyObjectPtr))
[docs]def transformation_map( transformation: Transformation, distance_in: Any ) -> Any: """Use the `transformation` to map a given `d_in` to `d_out`. [transformation_map in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.transformation_map.html) :param transformation: Transformation to check the map distances with. :type transformation: Transformation :param distance_in: Distance in terms of the input metric. :type distance_in: Any :rtype: Any :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. transformation = py_to_c(transformation, c_type=Transformation, type_name=None) distance_in = py_to_c(distance_in, c_type=AnyObjectPtr, type_name=transformation_input_distance_type(transformation)) # Call library function. function = lib.opendp_core__transformation_map function.argtypes = [Transformation, AnyObjectPtr] function.restype = FfiResult return c_to_py(unwrap(function(transformation, distance_in), AnyObjectPtr))
[docs]def transformation_output_distance_type( this: Transformation ) -> str: """Get the output distance type of `transformation`. [transformation_output_distance_type in Rust documentation.](https://docs.rs/opendp/latest/opendp/core/fn.transformation_output_distance_type.html) :param this: The transformation to retrieve the type from. :type this: Transformation :rtype: str :raises TypeError: if an argument's type differs from the expected type :raises UnknownTypeError: if a type argument fails to parse :raises OpenDPException: packaged error from the core OpenDP library """ # No type arguments to standardize. # Convert arguments to c types. this = py_to_c(this, c_type=Transformation, type_name=None) # Call library function. function = lib.opendp_core__transformation_output_distance_type function.argtypes = [Transformation] function.restype = FfiResult return c_to_py(unwrap(function(this), ctypes.c_char_p))