MCPcopy Index your code
hub / github.com/pydata/xarray / cov

Method cov

xarray/computation/rolling_exp.py:228–256  ·  view source on GitHub ↗

Exponentially weighted moving covariance. `keep_attrs` is always True for this method. Drop attrs separately to remove attrs. Examples -------- >>> da = xr.DataArray([1, 1, 2, 2, 2], dims="x") >>> da.rolling_exp(x=2, window_type="span").cov(da**2)

(self, other: T_DataWithCoords)

Source from the content-addressed store, hash-verified

226 ).transpose(*dim_order)
227
228 def cov(self, other: T_DataWithCoords) -> T_DataWithCoords:
229 """
230 Exponentially weighted moving covariance.
231
232 `keep_attrs` is always True for this method. Drop attrs separately to remove attrs.
233
234 Examples
235 --------
236 >>> da = xr.DataArray([1, 1, 2, 2, 2], dims="x")
237 >>> da.rolling_exp(x=2, window_type="span").cov(da**2)
238 <xarray.DataArray (x: 5)> Size: 40B
239 array([ nan, 0. , 1.38461538, 0.55384615, 0.19338843])
240 Dimensions without coordinates: x
241 """
242
243 dim_order = self.obj.dims
244 import numbagg
245
246 return apply_ufunc(
247 numbagg.move_exp_nancov,
248 self.obj,
249 other,
250 input_core_dims=[[self.dim], [self.dim]],
251 kwargs=self.kwargs,
252 output_core_dims=[[self.dim]],
253 keep_attrs=True,
254 on_missing_core_dim="copy",
255 dask="parallelized",
256 ).transpose(*dim_order)
257
258 def corr(self, other: T_DataWithCoords) -> T_DataWithCoords:
259 """

Callers 10

test_lazy_corrcovFunction · 0.80
np_cov_indFunction · 0.80
test_covFunction · 0.80
np_covFunction · 0.80
test_covcorr_consistencyFunction · 0.80
test_autocovFunction · 0.80
test_complex_covFunction · 0.80
test_bilinear_cov_corrFunction · 0.80
test_covMethod · 0.80

Calls 2

apply_ufuncFunction · 0.90
transposeMethod · 0.45

Tested by 10

test_lazy_corrcovFunction · 0.64
np_cov_indFunction · 0.64
test_covFunction · 0.64
np_covFunction · 0.64
test_covcorr_consistencyFunction · 0.64
test_autocovFunction · 0.64
test_complex_covFunction · 0.64
test_bilinear_cov_corrFunction · 0.64
test_covMethod · 0.64