(self)
| 253 | |
| 254 | @cached_property |
| 255 | def _info(self): |
| 256 | if self.operand("dtype") is not None: |
| 257 | need_enforce_dtype = True |
| 258 | dtype = self.operand("dtype") |
| 259 | else: |
| 260 | # We follow NumPy's rules for dtype promotion, which special cases |
| 261 | # scalars and 0d ndarrays (which it considers equivalent) by using |
| 262 | # their values to compute the result dtype: |
| 263 | # https://github.com/numpy/numpy/issues/6240 |
| 264 | # We don't inspect the values of 0d dask arrays, because these could |
| 265 | # hold potentially very expensive calculations. Instead, we treat |
| 266 | # them just like other arrays, and if necessary cast the result of op |
| 267 | # to match. |
| 268 | vals = [ |
| 269 | ( |
| 270 | np.empty((1,) * max(1, a.ndim), dtype=a.dtype) |
| 271 | if not is_scalar_for_elemwise(a) |
| 272 | else a |
| 273 | ) |
| 274 | for a in self.elemwise_args |
| 275 | ] |
| 276 | try: |
| 277 | dtype = apply_infer_dtype( |
| 278 | self.op, vals, {}, "elemwise", suggest_dtype=False |
| 279 | ) |
| 280 | except Exception: |
| 281 | raise NotImplementedError |
| 282 | need_enforce_dtype = any( |
| 283 | not is_scalar_for_elemwise(a) and a.ndim == 0 |
| 284 | for a in self.elemwise_args |
| 285 | ) |
| 286 | |
| 287 | blockwise_kwargs = {} |
| 288 | op = self.op |
| 289 | if self.where is not True: |
| 290 | blockwise_kwargs["elemwise_where_function"] = op |
| 291 | op = _elemwise_handle_where |
| 292 | |
| 293 | if need_enforce_dtype: |
| 294 | blockwise_kwargs.update( |
| 295 | { |
| 296 | "enforce_dtype": dtype, |
| 297 | "enforce_dtype_function": op, |
| 298 | } |
| 299 | ) |
| 300 | op = _enforce_dtype |
| 301 | |
| 302 | return op, dtype, blockwise_kwargs |
| 303 | |
| 304 | @property |
| 305 | def func(self): |
nothing calls this directly
no test coverage detected