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:

  1. A Constant object.

  2. A numpy.ndarray dense array.

  3. A scipy.sparse.spmatrix sparse matrix.

  4. A numeric value (except complex), or

  5. 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))