Inner function of full_like, where other must be a variable
(
other: Variable,
fill_value: Any,
dtype: DTypeLike | None = None,
chunks: T_Chunks = None,
chunked_array_type: str | None = None,
from_array_kwargs: dict[str, Any] | None = None,
)
| 1741 | |
| 1742 | |
| 1743 | def _full_like_variable( |
| 1744 | other: Variable, |
| 1745 | fill_value: Any, |
| 1746 | dtype: DTypeLike | None = None, |
| 1747 | chunks: T_Chunks = None, |
| 1748 | chunked_array_type: str | None = None, |
| 1749 | from_array_kwargs: dict[str, Any] | None = None, |
| 1750 | ) -> Variable: |
| 1751 | """Inner function of full_like, where other must be a variable""" |
| 1752 | from xarray.core.variable import Variable |
| 1753 | |
| 1754 | if fill_value is dtypes.NA: |
| 1755 | fill_value = dtypes.get_fill_value(dtype if dtype is not None else other.dtype) |
| 1756 | |
| 1757 | if ( |
| 1758 | is_chunked_array(other.data) |
| 1759 | or chunked_array_type is not None |
| 1760 | or chunks is not None |
| 1761 | ): |
| 1762 | if chunked_array_type is None: |
| 1763 | chunkmanager = get_chunked_array_type(other.data) |
| 1764 | else: |
| 1765 | chunkmanager = guess_chunkmanager(chunked_array_type) |
| 1766 | |
| 1767 | if dtype is None: |
| 1768 | dtype = other.dtype |
| 1769 | |
| 1770 | if from_array_kwargs is None: |
| 1771 | from_array_kwargs = {} |
| 1772 | |
| 1773 | data = chunkmanager.array_api.full( |
| 1774 | other.shape, |
| 1775 | fill_value, |
| 1776 | dtype=dtype, |
| 1777 | chunks=chunks or other.data.chunks, |
| 1778 | **from_array_kwargs, |
| 1779 | ) |
| 1780 | else: |
| 1781 | data = duck_array_ops.full_like(other.data, fill_value, dtype=dtype) |
| 1782 | |
| 1783 | return Variable(dims=other.dims, data=data, attrs=other.attrs) |
| 1784 | |
| 1785 | |
| 1786 | @overload |
no test coverage detected
searching dependent graphs…