| 459 | |
| 460 | |
| 461 | def full(shape, fill_value, *args, **kwargs): |
| 462 | # np.isscalar has somewhat strange behavior: |
| 463 | # https://docs.scipy.org/doc/numpy/reference/generated/numpy.isscalar.html |
| 464 | if np.ndim(fill_value) != 0: |
| 465 | raise ValueError( |
| 466 | f"fill_value must be scalar. Received {type(fill_value).__name__} instead." |
| 467 | ) |
| 468 | if kwargs.get("dtype") is None: |
| 469 | if hasattr(fill_value, "dtype"): |
| 470 | kwargs["dtype"] = fill_value.dtype |
| 471 | else: |
| 472 | kwargs["dtype"] = type(fill_value) |
| 473 | return _full(*args, shape=shape, fill_value=fill_value, **kwargs) |
| 474 | |
| 475 | |
| 476 | def full_like(a, fill_value, order="C", dtype=None, chunks=None, name=None, shape=None): |