ones_like#

rbc.stdlib.creation_functions.ones_like(a, dtype=None)#

Return an array of ones with the same shape and type as a given array.

Examples

>>> from rbc.stdlib import array_api
>>> @heavydb('int64[](int64[])')
... def ones_like(other):
...     return array_api.ones_like(other)
>>> ones_like([1, 2, 3]).execute()
array([1, 1, 1])
>>> @heavydb('float[](int64[])')
... def ones_like2(other):
...     return array_api.ones_like(other, 'float32')
>>> ones_like2([1, 2, 3]).execute()
array([1., 1., 1.], dtype=float32)

Array-API ‘ones_like’ doc