MCPcopy
hub / github.com/dask/dask / getter

Function getter

dask/array/core.py:121–144  ·  view source on GitHub ↗
(a, b, asarray=True, lock=None)

Source from the content-addressed store, hash-verified

119
120
121def getter(a, b, asarray=True, lock=None):
122 if isinstance(b, tuple) and any(x is None for x in b):
123 b2 = tuple(x for x in b if x is not None)
124 b3 = tuple(
125 None if x is None else slice(None, None)
126 for x in b
127 if not isinstance(x, Integral)
128 )
129 return getter(a, b2, asarray=asarray, lock=lock)[b3]
130
131 if lock:
132 lock.acquire()
133 try:
134 c = a[b]
135 # Below we special-case `np.matrix` to force a conversion to
136 # `np.ndarray` and preserve original Dask behavior for `getter`,
137 # as for all purposes `np.matrix` is array-like and thus
138 # `is_arraylike` evaluates to `True` in that case.
139 if asarray and (not is_arraylike(c) or isinstance(c, np.matrix)):
140 c = np.asarray(c)
141 finally:
142 if lock:
143 lock.release()
144 return c
145
146
147def getter_nofancy(a, b, asarray=True, lock=None):

Callers 5

test_getterFunction · 0.90
partial_reduceFunction · 0.85
getter_nofancyFunction · 0.85
getter_inlineFunction · 0.85
chunksMethod · 0.85

Calls 4

anyFunction · 0.90
is_arraylikeFunction · 0.90
acquireMethod · 0.45
releaseMethod · 0.45

Tested by 1

test_getterFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…