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

Function np_corr

xarray/tests/test_computation.py:1691–1702  ·  view source on GitHub ↗
(ts1, ts2)

Source from the content-addressed store, hash-verified

1689 else:
1690
1691 def np_corr(ts1, ts2):
1692 # Ensure the ts are aligned and missing values ignored
1693 ts1, ts2 = broadcast(ts1, ts2)
1694 valid_values = ts1.notnull() & ts2.notnull()
1695
1696 ts1 = ts1.where(valid_values)
1697 ts2 = ts2.where(valid_values)
1698
1699 return np.ma.corrcoef(
1700 np.ma.masked_invalid(ts1.data.flatten()),
1701 np.ma.masked_invalid(ts2.data.flatten()),
1702 )[0, 1]
1703
1704 expected = np_corr(da_a, da_b)
1705 actual = xr.corr(da_a, da_b, dim)

Callers 1

test_corrFunction · 0.85

Calls 3

broadcastFunction · 0.90
notnullMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…