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

Function test_weighted_operations_3D

xarray/tests/test_weighted.py:600–620  ·  view source on GitHub ↗
(dim, add_nans, skipna)

Source from the content-addressed store, hash-verified

598@pytest.mark.parametrize("skipna", (None, True, False))
599@pytest.mark.filterwarnings("ignore:invalid value encountered in sqrt")
600def test_weighted_operations_3D(dim, add_nans, skipna):
601 dims = ("a", "b", "c")
602 coords = dict(a=[0, 1, 2, 3], b=[0, 1, 2, 3], c=[0, 1, 2, 3])
603
604 weights = DataArray(np.random.randn(4, 4, 4), dims=dims, coords=coords)
605
606 data_values = np.random.randn(4, 4, 4)
607
608 # add approximately 25 % NaNs (https://stackoverflow.com/a/32182680/3010700)
609 if add_nans:
610 c = int(data_values.size * 0.25)
611 data_values.ravel()[np.random.choice(data_values.size, c, replace=False)] = (
612 np.nan
613 )
614
615 data = DataArray(data_values, dims=dims, coords=coords)
616
617 check_weighted_operations(data, weights, dim, skipna)
618
619 ds = data.to_dataset(name="data")
620 check_weighted_operations(ds, weights, dim, skipna)
621
622
623@pytest.mark.parametrize("dim", ("a", "b", "c", ("a", "b"), ("a", "b", "c"), None))

Callers

nothing calls this directly

Calls 3

to_datasetMethod · 0.95
DataArrayClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…