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

Method choice

dask/array/random.py:128–162  ·  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

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

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_series_map_metaFunction · 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