diff options
-rw-r--r-- | numpy/random/_generator.pyx | 7 | ||||
-rw-r--r-- | numpy/random/mtrand.pyx | 7 |
2 files changed, 4 insertions, 10 deletions
diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index 297642940..1c4689a70 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -2,7 +2,7 @@ #cython: wraparound=False, nonecheck=False, boundscheck=False, cdivision=True, language_level=3 import operator import warnings -from collections.abc import MutableSequence +from collections.abc import Sequence from cpython.pycapsule cimport PyCapsule_IsValid, PyCapsule_GetPointer from cpython cimport (Py_INCREF, PyFloat_AsDouble) @@ -4398,9 +4398,6 @@ cdef class Generator: char* x_ptr char* buf_ptr - if isinstance(x, memoryview): - x = np.asarray(x) - axis = normalize_axis_index(axis, np.ndim(x)) if type(x) is np.ndarray and x.ndim == 1 and x.size: @@ -4443,7 +4440,7 @@ cdef class Generator: x[i] = buf else: # Untyped path. - if not isinstance(x, MutableSequence): + if not isinstance(x, Sequence): # See gh-18206. We may decide to deprecate here in the future. warnings.warn( "`x` isn't a recognized object; `shuffle` is not guaranteed " diff --git a/numpy/random/mtrand.pyx b/numpy/random/mtrand.pyx index daab2c6f1..df8d7e380 100644 --- a/numpy/random/mtrand.pyx +++ b/numpy/random/mtrand.pyx @@ -2,7 +2,7 @@ #cython: wraparound=False, nonecheck=False, boundscheck=False, cdivision=True, language_level=3 import operator import warnings -from collections.abc import MutableSequence +from collections.abc import Sequence import numpy as np @@ -4436,9 +4436,6 @@ cdef class RandomState: char* x_ptr char* buf_ptr - if isinstance(x, memoryview): - x = np.asarray(x) - if type(x) is np.ndarray and x.ndim == 1 and x.size: # Fast, statically typed path: shuffle the underlying buffer. # Only for non-empty, 1d objects of class ndarray (subclasses such @@ -4476,7 +4473,7 @@ cdef class RandomState: x[i] = buf else: # Untyped path. - if not isinstance(x, MutableSequence): + if not isinstance(x, Sequence): # See gh-18206. We may decide to deprecate here in the future. warnings.warn( "`x` isn't a recognized object; `shuffle` is not guaranteed " |