sgpykit.util.checks

Functions

contains_same_elements(obj1, obj2)

Check if two objects contain the same elements.

is_array_like(obj)

Check if an object is array-like.

is_list_math_equal(list1, list2[, tol])

Recursively compares two nested lists or arrays to check if they are equal.

is_nparray_of_numbers(obj)

Check if an object is a NumPy array of numbers.

is_number_or_list_of_numbers_nonnegative(obj)

Check if an object is a non-negative number or a list of non-negative numbers.

is_number_or_nparray_of_numbers(obj)

Check if an object is a number or a NumPy array of numbers.

is_number_or_nparray_of_numbers_nonnegative(obj)

Check if an object is a non-negative number or a NumPy array of non-negative numbers.

is_numeric_scalar(item)

Check if an item is a numeric scalar.

sgpykit.util.checks.contains_same_elements(obj1, obj2)[source]

Check if two objects contain the same elements.

Parameters:
obj1array_like

First object to compare.

obj2array_like

Second object to compare.

Returns:
bool

True if both objects contain the same elements, False otherwise.

sgpykit.util.checks.is_array_like(obj)[source]

Check if an object is array-like.

Parameters:
objobject

Object to check.

Returns:
bool

True if the object is array-like, False otherwise.

sgpykit.util.checks.is_list_math_equal(list1, list2, tol=1e-10)[source]

Recursively compares two nested lists or arrays to check if they are equal.

Parameters:
list1array_like

First list or array to compare.

list2array_like

Second list or array to compare.

tolfloat, optional

Tolerance for floating-point comparison. Default is 1e-10.

Returns:
bool

True if the lists or arrays are equal within the specified tolerance, False otherwise.

Raises:
AssertionError

If the lists or arrays are not equal.

sgpykit.util.checks.is_nparray_of_numbers(obj)[source]

Check if an object is a NumPy array of numbers.

Parameters:
objobject

Object to check.

Returns:
bool

True if the object is a NumPy array of numbers, False otherwise.

sgpykit.util.checks.is_number_or_list_of_numbers_nonnegative(obj)[source]

Check if an object is a non-negative number or a list of non-negative numbers.

Parameters:
objobject

Object to check.

Returns:
bool

True if the object is a non-negative number or a list of non-negative numbers, False otherwise.

sgpykit.util.checks.is_number_or_nparray_of_numbers(obj)[source]

Check if an object is a number or a NumPy array of numbers.

Parameters:
objobject

Object to check.

Returns:
bool

True if the object is a number or a NumPy array of numbers, False otherwise.

sgpykit.util.checks.is_number_or_nparray_of_numbers_nonnegative(obj)[source]

Check if an object is a non-negative number or a NumPy array of non-negative numbers.

Parameters:
objobject

Object to check.

Returns:
bool

True if the object is a non-negative number or a NumPy array of non-negative numbers, False otherwise.

sgpykit.util.checks.is_numeric_scalar(item)[source]

Check if an item is a numeric scalar.

Parameters:
itemobject

Item to check.

Returns:
bool

True if the item is a numeric scalar, False otherwise.