tree_structured.base

Base Class for checking data type.

Module Contents

Classes

Base

Validate basic types of the variables and their expected values.

class tree_structured.base.Base

Validate basic types of the variables and their expected values.

static is_bool(num: Any) bool

Return whether num is bool.

Parameters:

num (Any) – Input value to be validated as bool.

Returns:

True if num is boolean {0,1}.

Return type:

bool

static is_integer(num: Any) bool

Return whether the num is integer.

Parameters:

num (Any) – Input value to be validated as int.

Returns:

True if num is integer and False if num is not an integer.

Return type:

bool

static is_float(num: Any) bool

Return whether the num is float.

Parameters:

num (Any) – Input value to be validated as float.

Returns:

True if num is float and False if num is not float.

Return type:

bool

static are_list_elements_integer(array: list | numpy.typing.NDArray) bool

Return whether all elements of an array are integer.

Parameters:

array ({array-like}) –

Returns:

True if all elements of array are integer and False if this condition is not fulfilled.

Return type:

bool

static are_integer_elements_greater_than_zero(array: list[int] | numpy.typing.NDArray[numpy.int_]) bool

Return whether all elements of array are greater than zero.

Parameters:

array (list or ndarray of int) – Input list to be validated if all its elements are greater than zero.

Returns:

True if all elements of array are greater than zero and False if this condition is not fulfilled.

Return type:

bool

static is_array_like(x: Any) bool

Return whether x is in format of an array.

Parameters:

x (Any) – Input value to be validated as an array.

Returns:

True if x in like an array and False if it is not.

Return type:

bool

static is_array_binary(array: list | numpy.typing.NDArray) bool

Return whether all the elements of array are boolean.

Parameters:

array (list or ndarray) – Input array to be validated if all its elements are binary.

Returns:

True if all array elements are boolean.

Return type:

bool

static is_percentage(percent: Any) tuple[bool, float]

Return Whether percent is a number in range 0 to 100.

Parameters:

percent ({float, int}) –

Returns:

  • status (bool) – True if percent is a valid input.

  • percent (float) – Validated percent in float type.