DiffPriv.mech.utils

Arbitrary utils placeholder

View Source
"""Arbitrary utils placeholder"""

# Base error classes
class DomainError(Exception):
    """Raised when domain is not valid"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Domain Error] {message}')
        else:
            super().__init__('[Domain Error] Differential privacy parameter '
                             'domain is invalid.')


# Derived error classes
class NotNatural(DomainError):
    """Raised when a value is not a natural number"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Not Natural] {message}')
        else:
            super().__init__('[Not Natural] Differential privacy parameter '
                             'must be a natural number (i.e. ∈ ℕ).')

class Negative(DomainError):
    """Raised when a value is not a nonnegative number"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Negative] {message}')
        else:
            super().__init__('[Negative] Differential privacy parameter '
                             'must be a nonnegative number (i.e. ≥ 0).')

class NotInteger(DomainError):
    """Raised when a value is not an integer"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Not Integer] {message}')
        else:
            super().__init__('[Not Integer] Differential privacy parameter '
                             'must be an integer (i.e. ∈ ℤ).')

class Complex(DomainError):
    """Raised when a value is not a real number"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Complex] {message}')
        else:
            super().__init__('[Complex] Differential privacy parameter '
                             'must be a real number (i.e. ∈ ℝ).')

class NotScalar(DomainError):
    """Raised when a value is not a scalar"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Not Scalar] {message}')
        else:
            super().__init__('[Not Scalar] Differential privacy parameter '
                             'must be a scalar and real (i.e. ∈ ℝ).')
#   class DomainError(builtins.Exception):
View Source
class DomainError(Exception):
    """Raised when domain is not valid"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Domain Error] {message}')
        else:
            super().__init__('[Domain Error] Differential privacy parameter '
                             'domain is invalid.')

Raised when domain is not valid

#   DomainError(message=None)
View Source
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Domain Error] {message}')
        else:
            super().__init__('[Domain Error] Differential privacy parameter '
                             'domain is invalid.')
Inherited Members
builtins.BaseException
with_traceback
args
#   class NotNatural(DomainError):
View Source
class NotNatural(DomainError):
    """Raised when a value is not a natural number"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Not Natural] {message}')
        else:
            super().__init__('[Not Natural] Differential privacy parameter '
                             'must be a natural number (i.e. ∈ ℕ).')

Raised when a value is not a natural number

#   NotNatural(message=None)
View Source
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Not Natural] {message}')
        else:
            super().__init__('[Not Natural] Differential privacy parameter '
                             'must be a natural number (i.e. ∈ ℕ).')
Inherited Members
builtins.BaseException
with_traceback
args
#   class Negative(DomainError):
View Source
class Negative(DomainError):
    """Raised when a value is not a nonnegative number"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Negative] {message}')
        else:
            super().__init__('[Negative] Differential privacy parameter '
                             'must be a nonnegative number (i.e. ≥ 0).')

Raised when a value is not a nonnegative number

#   Negative(message=None)
View Source
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Negative] {message}')
        else:
            super().__init__('[Negative] Differential privacy parameter '
                             'must be a nonnegative number (i.e. ≥ 0).')
Inherited Members
builtins.BaseException
with_traceback
args
#   class NotInteger(DomainError):
View Source
class NotInteger(DomainError):
    """Raised when a value is not an integer"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Not Integer] {message}')
        else:
            super().__init__('[Not Integer] Differential privacy parameter '
                             'must be an integer (i.e. ∈ ℤ).')

Raised when a value is not an integer

#   NotInteger(message=None)
View Source
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Not Integer] {message}')
        else:
            super().__init__('[Not Integer] Differential privacy parameter '
                             'must be an integer (i.e. ∈ ℤ).')
Inherited Members
builtins.BaseException
with_traceback
args
#   class Complex(DomainError):
View Source
class Complex(DomainError):
    """Raised when a value is not a real number"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Complex] {message}')
        else:
            super().__init__('[Complex] Differential privacy parameter '
                             'must be a real number (i.e. ∈ ℝ).')

Raised when a value is not a real number

#   Complex(message=None)
View Source
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Complex] {message}')
        else:
            super().__init__('[Complex] Differential privacy parameter '
                             'must be a real number (i.e. ∈ ℝ).')
Inherited Members
builtins.BaseException
with_traceback
args
#   class NotScalar(DomainError):
View Source
class NotScalar(DomainError):
    """Raised when a value is not a scalar"""
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Not Scalar] {message}')
        else:
            super().__init__('[Not Scalar] Differential privacy parameter '
                             'must be a scalar and real (i.e. ∈ ℝ).')

Raised when a value is not a scalar

#   NotScalar(message=None)
View Source
    def __init__(self, message=None):
        if message:
            super().__init__(f'[Not Scalar] {message}')
        else:
            super().__init__('[Not Scalar] Differential privacy parameter '
                             'must be a scalar and real (i.e. ∈ ℝ).')
Inherited Members
builtins.BaseException
with_traceback
args