MCPcopy Index your code
hub / github.com/dask/dask / choice

Method choice

dask/array/random.py:550–577  ·  view source on GitHub ↗
(self, a, size=None, replace=True, p=None, chunks="auto")

Source from the content-addressed store, hash-verified

548
549 @derived_from(np.random.RandomState, skipblocks=1)
550 def choice(self, a, size=None, replace=True, p=None, chunks="auto"):
551 (
552 a,
553 size,
554 replace,
555 p,
556 axis, # np.random.RandomState.choice does not use axis
557 chunks,
558 meta,
559 dependencies,
560 ) = _choice_validate_params(self, a, size, replace, p, 0, chunks)
561
562 sizes = list(product(*chunks))
563 state_data = random_state_data(len(sizes), self._numpy_state)
564
565 name = (
566 f"da.random.choice-{tokenize(state_data, size, chunks, a, replace, p)}"
567 )
568 keys = product([name], *(range(len(bd)) for bd in chunks))
569 dsk = {
570 k: Task(k, _choice_rs, state, a, size, replace, p)
571 for k, state, size in zip(keys, state_data, sizes)
572 }
573
574 graph = HighLevelGraph.from_collections(
575 name, dsk, dependencies=dependencies
576 )
577 return Array(graph, name, chunks, meta=meta)
578
579 @derived_from(np.random.RandomState, skipblocks=1)
580 def exponential(self, scale=1.0, size=None, chunks="auto", **kwargs):

Callers 1

_choice_rsFunction · 0.95

Calls 6

random_state_dataFunction · 0.90
TaskClass · 0.90
ArrayClass · 0.90
from_collectionsMethod · 0.80
_choice_validate_paramsFunction · 0.70
tokenizeFunction · 0.50

Tested by

no test coverage detected