def _checkNumerical(inputvalue, minvalue=None, maxvalue=None, description='inputvalue'):
    """Check that the given numerical value is valid.

    Args:
        * inputvalue (numerical): The value to be checked.
        * minvalue (numerical): Minimum value  Use None to skip this part of the test.
        * maxvalue (numerical): Maximum value. Use None to skip this part of the test.
        * description (string): Used in error messages for the checked inputvalue

    Raises:
        TypeError, ValueError

    Note: Can not use the function :func:`_checkString`, as it uses this function internally.

    """
    # Type checking
    if not isinstance(description, str):
        raise TypeError('The description should be a string. Given: {0!r}'.format(description))

    if not isinstance(inputvalue, (int, long, float)):
        raise TypeError('The {0} must be numerical. Given: {1!r}'.format(description, inputvalue))

    if not isinstance(minvalue, (int, float, long, type(None))):
        raise TypeError('The minvalue must be numeric or None. Given: {0!r}'.format(minvalue))

    if not isinstance(maxvalue, (int, float, long, type(None))):
        raise TypeError('The maxvalue must be numeric or None. Given: {0!r}'.format(maxvalue))

    # Consistency checking
    if (not minvalue is None) and (not maxvalue is None):
        if maxvalue < minvalue:
            raise ValueError('The maxvalue must not be smaller than minvalue. Given: {0} and {1}, respectively.'.format( \
                maxvalue, minvalue))

    # Value checking
    if not minvalue is None:
        if inputvalue < minvalue:
            raise ValueError('The {0} is too small: {1}, but minimum value is {2}.'.format( \
                description, inputvalue, minvalue))

    if not maxvalue is None:
        if inputvalue > maxvalue:
            raise ValueError('The {0} is too large: {1}, but maximum value is {2}.'.format( \
                description, inputvalue, maxvalue))
def _checkNumerical ( inputvalue , minvalue = None , maxvalue = None , description = 'inputvalue' ) : if not isinstance ( description , str ) : raise TypeError ( 'The description should be a string. Given: {0!r}' . format ( description ) ) if not isinstance ( inputvalue , ( int , long , float ) ) : raise TypeError ( 'The {0} must be numerical. Given: {1!r}' . format ( description , inputvalue ) ) if not isinstance ( minvalue , ( int , float , long , type ( None ) ) ) : raise TypeError ( 'The minvalue must be numeric or None. Given: {0!r}' . format ( minvalue ) ) if not isinstance ( maxvalue , ( int , float , long , type ( None ) ) ) : raise TypeError ( 'The maxvalue must be numeric or None. Given: {0!r}' . format ( maxvalue ) ) if ( not minvalue is None ) and ( not maxvalue is None ) : if maxvalue < minvalue : raise ValueError ( 'The maxvalue must not be smaller than minvalue. Given: {0} and {1}, respectively.' . format ( maxvalue , minvalue ) ) if not minvalue is None : if inputvalue < minvalue : raise ValueError ( 'The {0} is too small: {1}, but minimum value is {2}.' . format ( description , inputvalue , minvalue ) ) if not maxvalue is None : if inputvalue > maxvalue : raise ValueError ( 'The {0} is too large: {1}, but maximum value is {2}.' . format ( description , inputvalue , maxvalue ) )
Check that the given numerical value is valid.

    Args:
        * inputvalue (numerical): The value to be checked.
        * minvalue (numerical): Minimum value  Use None to skip this part of the test.
        * maxvalue (numerical): Maximum value. Use None to skip this part of the test.
        * description (string): Used in error messages for the checked inputvalue

    Raises:
        TypeError, ValueError

    Note: Can not use the function :func:`_checkString`, as it uses this function internally.