Skip to content

Commit 607a927

Browse files
authored
Adjust code comments & types from #6638 (#6642)
1 parent ab5b162 commit 607a927

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

xarray/core/computation.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from .merge import merge_attrs, merge_coordinates_without_align
3131
from .options import OPTIONS, _get_keep_attrs
3232
from .pycompat import is_duck_dask_array
33+
from .types import T_DataArray
3334
from .utils import is_dict_like
3435
from .variable import Variable
3536

@@ -1371,7 +1372,9 @@ def corr(da_a, da_b, dim=None):
13711372
return _cov_corr(da_a, da_b, dim=dim, method="corr")
13721373

13731374

1374-
def _cov_corr(da_a, da_b, dim=None, ddof=0, method=None):
1375+
def _cov_corr(
1376+
da_a: T_DataArray, da_b: T_DataArray, dim=None, ddof=0, method=None
1377+
) -> T_DataArray:
13751378
"""
13761379
Internal method for xr.cov() and xr.corr() so only have to
13771380
sanitize the input arrays once and we don't repeat code.
@@ -1390,9 +1393,9 @@ def _cov_corr(da_a, da_b, dim=None, ddof=0, method=None):
13901393
demeaned_da_b = da_b - da_b.mean(dim=dim)
13911394

13921395
# 4. Compute covariance along the given dim
1393-
# N.B. `skipna=False` is required or there is a bug when computing
1394-
# auto-covariance. E.g. Try xr.cov(da,da) for
1395-
# da = xr.DataArray([[1, 2], [1, np.nan]], dims=["x", "time"])
1396+
#
1397+
# N.B. `skipna=True` is required or auto-covariance is computed incorrectly. E.g.
1398+
# Try xr.cov(da,da) for da = xr.DataArray([[1, 2], [1, np.nan]], dims=["x", "time"])
13961399
cov = (demeaned_da_a * demeaned_da_b).sum(dim=dim, skipna=True, min_count=1) / (
13971400
valid_count
13981401
)

xarray/core/dataarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,8 +3548,8 @@ def imag(self) -> DataArray:
35483548
return self._replace(self.variable.imag)
35493549

35503550
def dot(
3551-
self, other: DataArray, dims: Hashable | Sequence[Hashable] | None = None
3552-
) -> DataArray:
3551+
self, other: T_DataArray, dims: Hashable | Sequence[Hashable] | None = None
3552+
) -> T_DataArray:
35533553
"""Perform dot product of two DataArrays along their shared dims.
35543554
35553555
Equivalent to taking taking tensordot over all shared dims.

0 commit comments

Comments
 (0)