(
self,
deep: bool = True,
data: T_DuckArray | np.typing.ArrayLike | None = None,
memo: dict[int, Any] | None = None,
)
| 940 | return self._replace(encoding={}) |
| 941 | |
| 942 | def _copy( |
| 943 | self, |
| 944 | deep: bool = True, |
| 945 | data: T_DuckArray | np.typing.ArrayLike | None = None, |
| 946 | memo: dict[int, Any] | None = None, |
| 947 | ) -> Self: |
| 948 | if data is None: |
| 949 | data_old = self._data |
| 950 | |
| 951 | if not isinstance(data_old, indexing.MemoryCachedArray): |
| 952 | ndata = data_old |
| 953 | else: |
| 954 | # don't share caching between copies |
| 955 | # TODO: MemoryCachedArray doesn't match the array api: |
| 956 | ndata = indexing.MemoryCachedArray(data_old.array) # type: ignore[assignment] |
| 957 | |
| 958 | if deep: |
| 959 | ndata = copy.deepcopy(ndata, memo) |
| 960 | |
| 961 | else: |
| 962 | ndata = as_compatible_data(data) |
| 963 | if self.shape != ndata.shape: |
| 964 | raise ValueError( |
| 965 | f"Data shape {ndata.shape} must match shape of object {self.shape}" |
| 966 | ) |
| 967 | |
| 968 | attrs = copy.deepcopy(self._attrs, memo) if deep else copy.copy(self._attrs) |
| 969 | encoding = ( |
| 970 | copy.deepcopy(self._encoding, memo) if deep else copy.copy(self._encoding) |
| 971 | ) |
| 972 | |
| 973 | # note: dims is already an immutable tuple |
| 974 | return self._replace(data=ndata, attrs=attrs, encoding=encoding) |
| 975 | |
| 976 | def _replace( |
| 977 | self, |
nothing calls this directly
no test coverage detected