5.12. ArrayLike¶
- class ArrayLike¶
ArrayLike is a pseudo type. It is used to generalize all constant types.
More detailed, an ArrayLike may refer to:
A Constant object.
A numpy.ndarray dense array.
A scipy.sparse.spmatrix sparse matrix.
A numeric value (except complex), or
Any acceptable input argument for numpy.array() .
For example:
listobj = [[0, 1], [2, 3]] tupleobj = tuple(listobj) constant = Constant(listobj) numeric = 1 nparrobj = numpy.array(listobj) spmatobj = scipy.sparse.coo_matrix(nparrobj) # list print(huber(listobj)) # tuple print(huber(tupleobj)) # Constant print(huber(constant)) # numeric value print(huber(numeric)) # numpy.ndarray print(huber(nparrobj)) # scipy.sparse.spmatrix print(huber(spmatobj))