(self, index)
| 125 | return self.expr.__len__() |
| 126 | |
| 127 | def __getitem__(self, index): |
| 128 | # Field access, e.g. x['a'] or x[['a', 'b']] |
| 129 | if isinstance(index, str) or ( |
| 130 | isinstance(index, list) and index and all(isinstance(i, str) for i in index) |
| 131 | ): |
| 132 | # TODO(expr-soon): needs map_blocks that we don't support yet, |
| 133 | # but implementation is trivial after we have that |
| 134 | raise NotImplementedError() |
| 135 | |
| 136 | if not isinstance(index, tuple): |
| 137 | index = (index,) |
| 138 | |
| 139 | from dask.array._array_expr._slicing import ( |
| 140 | slice_array, |
| 141 | slice_with_int_dask_array, |
| 142 | ) |
| 143 | from dask.array.slicing import normalize_index |
| 144 | |
| 145 | index2 = normalize_index(index, self.shape) |
| 146 | dependencies = {self.name} |
| 147 | for i in index2: |
| 148 | if isinstance(i, Array): |
| 149 | dependencies.add(i.name) |
| 150 | |
| 151 | if any(isinstance(i, Array) and i.dtype.kind in "iu" for i in index2): |
| 152 | self, index2 = slice_with_int_dask_array(self, index2) |
| 153 | if any(isinstance(i, Array) and i.dtype == bool for i in index2): |
| 154 | # TODO(expr-soon): This is simple but needs ravel which needs reshape, |
| 155 | # which is not simple. Trivial to add after we have reshape |
| 156 | raise NotImplementedError |
| 157 | |
| 158 | if all(isinstance(i, slice) and i == slice(None) for i in index2): |
| 159 | return self |
| 160 | |
| 161 | result = slice_array(self.expr, index2) |
| 162 | return new_collection(result) |
| 163 | |
| 164 | def __add__(self, other): |
| 165 | return elemwise(operator.add, self, other) |
nothing calls this directly
no test coverage detected