| 45 | return len(self._idx.shape) |
| 46 | |
| 47 | def __handle_binary__(self, func, other): |
| 48 | if is_py_value(other): |
| 49 | return Arange.make(func(self._idx, other), self._dim_map, self._dim_order) |
| 50 | else: |
| 51 | assert isinstance(other, Arange) |
| 52 | left = self._idx |
| 53 | for i in range(other.dim): |
| 54 | left = np.expand_dims(left, axis=-1) |
| 55 | right = other._idx |
| 56 | for i in range(self.dim): |
| 57 | right = np.expand_dims(right, axis=0) |
| 58 | idx = func(left, right) |
| 59 | for k in self._dim_map.keys(): |
| 60 | assert k not in other._dim_map.keys(), "Unexpected dim name collision" |
| 61 | dim_map = {k: v for k, v in self._dim_map.items()} |
| 62 | dim_map.update(other._dim_map) |
| 63 | dim_order = self._dim_order + other._dim_order |
| 64 | return Arange.make(idx, dim_map, dim_order) |
| 65 | |
| 66 | def __handle_rbinary__(self, func, other): |
| 67 | if is_py_value(other): |