pynetdesign.modelling.utils.contains_only_numeric#
- pynetdesign.modelling.utils.contains_only_numeric(seq)[source]#
Check if a sequence (tuple, list, or numpy array) contains only numeric values.
- Parameters:
- seq
tuple,list, ornumpy.ndarray The sequence to be checked.
- seq
- Returns:
- bool
True if all elements in the sequence are numeric (int, float, or complex), False otherwise.
Examples
>>> t1 = (1, 2.5, 3+4j) >>> contains_only_numeric(t1) True
>>> l1 = [1, 2.5, 3] >>> contains_only_numeric(l1) True
>>> a1 = np.array([1, 2.5, 3+4j]) >>> contains_only_numeric(a1) True
>>> t2 = (1, 'a', 2.5) >>> contains_only_numeric(t2) False