MCPcopy Create free account
hub / github.com/dask/dask / choice

Method choice

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

Source from the content-addressed store, hash-verified

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