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

Function test_weighted_operations_different_shapes

xarray/tests/test_weighted.py:704–725  ·  view source on GitHub ↗
(
    shape_data, shape_weights, add_nans, skipna
)

Source from the content-addressed store, hash-verified

702@pytest.mark.parametrize("skipna", (None, True, False))
703@pytest.mark.filterwarnings("ignore:invalid value encountered in sqrt")
704def test_weighted_operations_different_shapes(
705 shape_data, shape_weights, add_nans, skipna
706):
707 weights = DataArray(np.random.randn(*shape_weights))
708
709 data_values = np.random.randn(*shape_data)
710
711 # add approximately 25 % NaNs
712 if add_nans:
713 c = int(data_values.size * 0.25)
714 data_values.ravel()[np.random.choice(data_values.size, c, replace=False)] = (
715 np.nan
716 )
717
718 data = DataArray(data_values)
719
720 check_weighted_operations(data, weights, "dim_0", skipna)
721 check_weighted_operations(data, weights, None, skipna)
722
723 ds = data.to_dataset(name="data")
724 check_weighted_operations(ds, weights, "dim_0", skipna)
725 check_weighted_operations(ds, weights, None, skipna)
726
727
728@pytest.mark.parametrize(

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…