8000 np.repeat not accepting np.uint for repeats · Issue #15965 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
np.repeat not accepting np.uint for repeats #15965
Open
@jeras

Description

@jeras

Repeat only accepts int or int array for repeats, np.uint is not accepted. But the function still checks if repeats are negative. I am working with nonegative values this becomes an unnecessary conversion step.

Reproducing code example:

import numpy as np
x = np.array([1,2,3,4])
r = np.array([1,0,0,2], dtype=np.uint)
x.repeat(r)

Error message:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-9ac14301bd8a> in <module>
      2 x = np.array([1,2,3,4])
      3 r = np.array([1,0,0,2], dtype=np.uint)
----> 4 x.repeat(r)

TypeError: Cannot cast array data from dtype('uint64') to dtype('int64') according to the rule 'safe'

Numpy/Python version information:

1.17.4 3.8.2 (default, Mar 13 2020, 10:14:16) 
[GCC 9.3.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0