Skip to content

Support array objects as the repeats argument to cupy.repeat #3849

@beckernick

Description

@beckernick

For consistency with NumPy, it would be nice to allow passing a CuPy array (or perhaps an ndarray-like object) as the repeats= argument to cupy.repeat.

I can do the following with NumPy:

import numpy as np
np.repeat(a=np.arange(3), repeats=np.array([2,2,2]))
array([0, 0, 1, 1, 2, 2])

But the analogous action is not implemented for CuPy:

if isinstance(repeats, ndarray):
raise ValueError(
'cupy.ndaray cannot be specified as `repeats` argument.')

It's required to be an integer, list, or tuple.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions