diff options
Diffstat (limited to 'numpy/random/_generator.pyx')
| -rw-r--r-- | numpy/random/_generator.pyx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index 1c4689a70..9673bc6f4 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -4398,7 +4398,9 @@ cdef class Generator: char* x_ptr char* buf_ptr - axis = normalize_axis_index(axis, np.ndim(x)) + if isinstance(x, np.ndarray): + # Only call ndim on ndarrays, see GH 18142 + axis = normalize_axis_index(axis, np.ndim(x)) if type(x) is np.ndarray and x.ndim == 1 and x.size: # Fast, statically typed path: shuffle the underlying buffer. |
