MCPcopy
hub / github.com/pydata/xarray / np_cov_ind

Function np_cov_ind

xarray/tests/test_computation.py:1616–1630  ·  view source on GitHub ↗
(ts1, ts2, a, x)

Source from the content-addressed store, hash-verified

1614 if dim is not None:
1615
1616 def np_cov_ind(ts1, ts2, a, x):
1617 # Ensure the ts are aligned and missing values ignored
1618 ts1, ts2 = broadcast(ts1, ts2)
1619 valid_values = ts1.notnull() & ts2.notnull()
1620
1621 # While dropping isn't ideal here, numpy will return nan
1622 # if any segment contains a NaN.
1623 ts1 = ts1.where(valid_values)
1624 ts2 = ts2.where(valid_values)
1625
1626 return np.ma.cov(
1627 np.ma.masked_invalid(ts1.sel(a=a, x=x).data.flatten()),
1628 np.ma.masked_invalid(ts2.sel(a=a, x=x).data.flatten()),
1629 ddof=ddof,
1630 )[0, 1]
1631
1632 expected = np.zeros((3, 4))
1633 for a in [0, 1, 2]:

Callers 1

test_covFunction · 0.85

Calls 5

broadcastFunction · 0.90
covMethod · 0.80
notnullMethod · 0.45
whereMethod · 0.45
selMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…