sidpy.base.num_utils.contains_integers

sidpy.base.num_utils.contains_integers(iter_int, min_val=None)[source]

Checks if the provided object is iterable (list, tuple etc.) and contains integers optionally greater than equal to the provided min_val

Parameters:
  • iter_int (collections.Iterable) – Iterable (e.g. list, tuple, etc.) of integers

  • min_val (int, optional, default = None) – The value above which each element of iterable must possess. By default, this is ignored.

Returns:

Whether or not the provided object is an iterable of integers

Return type:

bool

Examples

>>> item = [1, 2, -3, 4]
>>> print('{} : contains integers? : {}'.format(item, sidpy.base.num_utils.contains_integers(item)))
[1, 2, -3, 4] : contains integers? : True
>>> item = [1, 4.5, 2.2, -1]
>>> print('{} : contains integers? : {}'.format(item, sidpy.base.num_utils.contains_integers(item)))
[1, 4.5, 2.2, -1] : contains integers? : False
>>> item = [1, 5, 8, 3]
>>> min_val = 2
>>> print('{} : contains integers >= {} ? : {}'.format(item, min_val, sidpy.base.num_utils.contains_integers(item, min_val=min_val)))
[1, 5, 8, 3] : contains integers >= 2 ? : False