MCPcopy
hub / github.com/dask/dask / select

Function select

dask/array/routines.py:2280–2310  ·  view source on GitHub ↗
(condlist, choicelist, default=0)

Source from the content-addressed store, hash-verified

2278
2279@derived_from(np)
2280def select(condlist, choicelist, default=0):
2281 # Making the same checks that np.select
2282 # Check the size of condlist and choicelist are the same, or abort.
2283 if len(condlist) != len(choicelist):
2284 raise ValueError("list of cases must be same length as list of conditions")
2285
2286 if len(condlist) == 0:
2287 raise ValueError("select with an empty condition list is not possible")
2288
2289 choicelist = [asarray(choice) for choice in choicelist]
2290
2291 try:
2292 intermediate_dtype = result_type(*choicelist)
2293 except TypeError as e:
2294 msg = "Choicelist elements do not have a common dtype."
2295 raise TypeError(msg) from e
2296
2297 blockwise_shape = tuple(range(choicelist[0].ndim))
2298
2299 condargs = [arg for elem in condlist for arg in (elem, blockwise_shape)]
2300 choiceargs = [arg for elem in choicelist for arg in (elem, blockwise_shape)]
2301
2302 return blockwise(
2303 _select,
2304 blockwise_shape,
2305 *condargs,
2306 *choiceargs,
2307 dtype=intermediate_dtype,
2308 name="select",
2309 default=default,
2310 )
2311
2312
2313def _partition(total: int, divisor: int) -> tuple[tuple[int, ...], tuple[int, ...]]:

Callers

nothing calls this directly

Calls 3

asarrayFunction · 0.90
result_typeFunction · 0.85
blockwiseFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…