| 287 | |
| 288 | @derived_from(np.random.Generator, skipblocks=1) |
| 289 | def permutation(self, x): |
| 290 | from dask.array.slicing import shuffle_slice |
| 291 | |
| 292 | if self._backend_name == "cupy": |
| 293 | raise NotImplementedError( |
| 294 | "`Generator.permutation` not supported for cupy-backed " |
| 295 | "Generator objects. Use the 'numpy' array backend to " |
| 296 | "call `dask.array.random.default_rng`, or pass in " |
| 297 | " `numpy.random.PCG64()`." |
| 298 | ) |
| 299 | |
| 300 | if isinstance(x, numbers.Number): |
| 301 | x = arange(x, chunks="auto") |
| 302 | |
| 303 | index = self._backend.arange(len(x)) |
| 304 | _shuffle(self._bit_generator, index) |
| 305 | return shuffle_slice(x, index) |
| 306 | |
| 307 | @derived_from(np.random.Generator, skipblocks=1) |
| 308 | def poisson(self, lam=1.0, size=None, chunks="auto", **kwargs): |