pyvista_validation.check.check_iterable

Contents

pyvista_validation.check.check_iterable#

pyvista_validation.check.check_iterable(obj, *, name='Object')#

Check if an object is an instance of Iterable.

Parameters:
objIterable

Iterable object to check.

namestr, default: “Object”

Variable name to use in the error messages if any are raised.

Returns:
Iterable

The input, unchanged. Type checkers see it as an iterable.

Raises:
TypeError

If input is not an instance of Iterable.

Examples

Check if an object is iterable.

>>> import numpy as np
>>> from pyvista_validation import check_iterable
>>> check_iterable([1, 2, 3])
[1, 2, 3]
>>> check_iterable(np.array((4, 5, 6)))
array([4, 5, 6])