def _to_ndarray(self, a):
        """Casts Python lists and tuples to a numpy array or raises an AssertionError."""

        if isinstance(a, (list, tuple)):
            a = numpy.array(a)

        if not is_ndarray(a):
            raise TypeError("Expected an ndarray but got object of type '{}' instead".format(type(a)))

        return a
Casts Python lists and tuples to a numpy array or raises an AssertionError.