(a, b, asarray=True, lock=None)
| 119 | |
| 120 | |
| 121 | def 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 | |
| 147 | def getter_nofancy(a, b, asarray=True, lock=None): |
searching dependent graphs…