(dim, add_nans, skipna)
| 598 | @pytest.mark.parametrize("skipna", (None, True, False)) |
| 599 | @pytest.mark.filterwarnings("ignore:invalid value encountered in sqrt") |
| 600 | def 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)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…