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

Method choice

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

Source from the content-addressed store, hash-verified

124
125 @derived_from(np.random.Generator, skipblocks=1)
126 def choice(
127 self,
128 a,
129 size=None,
130 replace=True,
131 p=None,
132 axis=0,
133 shuffle=True,
134 chunks="auto",
135 ):
136 (
137 a,
138 size,
139 replace,
140 p,
141 axis,
142 chunks,
143 meta,
144 dependencies,
145 ) = _choice_validate_params(self, a, size, replace, p, axis, chunks)
146
147 sizes = list(product(*chunks))
148 bitgens = _spawn_bitgens(self._bit_generator, len(sizes))
149
150 name = f"da.random.choice-{tokenize(bitgens, size, chunks, a, replace, p, axis, shuffle)}"
151 keys = product([name], *(range(len(bd)) for bd in chunks))
152 dsk = {
153 k: Task(k, _choice_rng, bitgen, a, size, replace, p, axis, shuffle)
154 for k, bitgen, size in zip(keys, bitgens, sizes)
155 }
156
157 graph = HighLevelGraph.from_collections(name, dsk, dependencies=dependencies)
158 return Array(graph, name, chunks, meta=meta)
159
160 @derived_from(np.random.Generator, skipblocks=1)
161 def exponential(self, scale=1.0, size=None, chunks="auto", **kwargs):

Callers 15

object_sizeFunction · 0.45
test_parquetFunction · 0.45
test_parquet_appendFunction · 0.45
test_avro.pyFile · 0.45
make_stringFunction · 0.45
test_combineFunction · 0.45
make_random_stringFunction · 0.45
make_stringFunction · 0.45
test_localFunction · 0.45
test_appendFunction · 0.45
test_append_createFunction · 0.45
test_partition_on_catsFunction · 0.45

Calls 6

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

Tested by 15

test_parquetFunction · 0.36
test_parquet_appendFunction · 0.36
test_combineFunction · 0.36
test_localFunction · 0.36
test_appendFunction · 0.36
test_append_createFunction · 0.36
test_partition_on_catsFunction · 0.36
test_partition_on_cats_2Function · 0.36
test_append_wo_indexFunction · 0.36