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