Module arg_check
[hide private]
[frames] | no frames]

Module arg_check

source code

Argument checking functions for the relax user functions.

Functions [hide private]
bool
check_float(num)
Check if the given number is a Python or numpy float.
source code
bool
is_bool(arg, name=None, raise_error=True)
Test if the argument is a Boolean.
source code
bool
is_float(arg, name=None, can_be_none=False, raise_error=True)
Test if the argument is a float.
source code
bool
is_float_array(arg, name=None, size=None, can_be_none=False, raise_error=True)
Test if the argument is an array of floats.
source code
bool
is_float_matrix(arg, name=None, dim=(3, 3), can_be_none=False, raise_error=True)
Test if the argument is a matrix of floats.
source code
bool
is_func(arg, name=None, can_be_none=False, raise_error=True)
Test if the argument is a function.
source code
bool
is_int(arg, name=None, can_be_none=False, raise_error=True)
Test if the argument is an integer.
source code
bool
is_int_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, none_elements=False, raise_error=True)
Test if the argument is a list of integers.
source code
bool
is_int_or_int_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, none_elements=False, raise_error=True)
Test if the argument is an integer or a list of integers.
source code
bool
is_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, list_of_lists=False, raise_error=True)
Test if the argument is a list.
source code
bool
is_none(arg, name, raise_error=True)
Test if the argument is None.
source code
bool
is_num(arg, name=None, can_be_none=False, raise_error=True)
Test if the argument is a number.
source code
bool
is_num_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)
Test if the argument is a list of numbers.
source code
bool
is_num_or_num_tuple(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)
Test if the argument is a tuple of numbers.
source code
bool
is_num_tuple(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)
Test if the argument is a tuple of numbers.
source code
bool
is_str(arg, name=None, can_be_none=False, raise_error=True)
Test if the argument is a string.
source code
bool
is_str_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, list_of_lists=False, raise_error=True)
Test if the argument is a list of strings.
source code
bool
is_str_or_inst(arg, name=None, can_be_none=False, raise_error=True)
Test if the argument is a string.
source code
bool
is_str_or_num_or_str_num_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)
Test if the argument is a number, a string, a list of numbers, or a list of strings.
source code
bool
is_str_or_num_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)
Test if the argument is a string or a list of numbers.
source code
bool
is_str_or_str_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)
Test if the argument is a string or a list of strings.
source code
bool
is_tuple(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)
Test if the argument is a tuple.
source code
Variables [hide private]
  __package__ = None
hash(x)

Imports: float32, float64, ndarray, float16, float128, RelaxBoolError, RelaxFloatError, RelaxFunctionError, RelaxIntError, RelaxIntListIntError, RelaxListFloatError, RelaxListIntError, RelaxMatrixFloatError, RelaxNoneFloatError, RelaxNoneFunctionError, RelaxListNumError, RelaxListStrError, RelaxNoneError, RelaxNoneIntError, RelaxNoneIntListIntError, RelaxNoneListFloatError, RelaxNoneListIntError, RelaxNoneMatrixFloatError, RelaxNoneListNumError, RelaxNoneListStrError, RelaxNoneNumError, RelaxNoneNumStrListNumStrError, RelaxNoneNumTupleNumError, RelaxNoneStrError, RelaxNoneStrFileError, RelaxNoneStrListNumError, RelaxNoneStrListStrError, RelaxNumError, RelaxNumStrListNumStrError, RelaxNumTupleNumError, RelaxStrError, RelaxStrFileError, RelaxStrListNumError, RelaxStrListStrError, RelaxTupleError, RelaxTupleNumError, DummyFileObject, FunctionType, MethodType


Function Details [hide private]

check_float(num)

source code 

Check if the given number is a Python or numpy float.

Parameters:
  • num (anything.) - The number to check.
Returns: bool
True if the number is a float, False otherwise.

is_bool(arg, name=None, raise_error=True)

source code 

Test if the argument is a Boolean.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:
  • RelaxBoolError - If not a Boolean (and the raise_error flag is set).

is_float(arg, name=None, can_be_none=False, raise_error=True)

source code 

Test if the argument is a float.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_float_array(arg, name=None, size=None, can_be_none=False, raise_error=True)

source code 

Test if the argument is an array of floats.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The dimension of the array.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_float_matrix(arg, name=None, dim=(3, 3), can_be_none=False, raise_error=True)

source code 

Test if the argument is a matrix of floats.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • dim (tuple of int) - The m,n dimensions of the matrix.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_func(arg, name=None, can_be_none=False, raise_error=True)

source code 

Test if the argument is a function.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_int(arg, name=None, can_be_none=False, raise_error=True)

source code 

Test if the argument is an integer.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:
  • RelaxIntError - If not an integer (and the raise_error flag is set).
  • RelaxNoneIntError - If not an integer or not None (and the raise_error flag is set).

is_int_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, none_elements=False, raise_error=True)

source code 

Test if the argument is a list of integers.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • none_elements (bool) - A flag which if True allows the list to contain None.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_int_or_int_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, none_elements=False, raise_error=True)

source code 

Test if the argument is an integer or a list of integers.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • none_elements (bool) - A flag which if True allows the list to contain None.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, list_of_lists=False, raise_error=True)

source code 

Test if the argument is a list.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • list_of_lists (bool) - A flag which if True allows the argument to be a list of lists of strings.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_none(arg, name, raise_error=True)

source code 

Test if the argument is None.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_num(arg, name=None, can_be_none=False, raise_error=True)

source code 

Test if the argument is a number.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:
  • RelaxNumError - If not a number (and the raise_error flag is set).
  • RelaxNoneNumError - If not a number or not None (and the raise_error flag is set).

is_num_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)

source code 

Test if the argument is a list of numbers.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_num_or_num_tuple(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)

source code 

Test if the argument is a tuple of numbers.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_num_tuple(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)

source code 

Test if the argument is a tuple of numbers.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_str(arg, name=None, can_be_none=False, raise_error=True)

source code 

Test if the argument is a string.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:
  • RelaxStrError - If not an integer (and the raise_error flag is set).
  • RelaxNoneStrError - If not an integer or not None (and the raise_error flag is set).

is_str_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, list_of_lists=False, raise_error=True)

source code 

Test if the argument is a list of strings.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • list_of_lists (bool) - A flag which if True allows the argument to be a list of lists of strings.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_str_or_inst(arg, name=None, can_be_none=False, raise_error=True)

source code 

Test if the argument is a string.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:
  • RelaxStrError - If not an integer (and the raise_error flag is set).
  • RelaxNoneStrError - If not an integer or not None (and the raise_error flag is set).

is_str_or_num_or_str_num_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)

source code 

Test if the argument is a number, a string, a list of numbers, or a list of strings.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_str_or_num_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)

source code 

Test if the argument is a string or a list of numbers.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_str_or_str_list(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)

source code 

Test if the argument is a string or a list of strings.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises:

is_tuple(arg, name=None, size=None, can_be_none=False, can_be_empty=False, raise_error=True)

source code 

Test if the argument is a tuple.

Parameters:
  • arg (anything) - The argument.
  • name (str) - The plain English name of the argument.
  • size (None or int) - The number of elements required.
  • can_be_none (bool) - A flag specifying if the argument can be none.
  • can_be_empty (bool) - A flag which if True allows the list to be empty.
  • raise_error (bool) - A flag which if True will cause RelaxErrors to be raised.
Returns: bool
The answer to the question (if raise_error is not set).
Raises: