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

Method test_pad_linear_ramp

xarray/tests/test_dataarray.py:4730–4748  ·  view source on GitHub ↗
(self, end_values)

Source from the content-addressed store, hash-verified

4728 "end_values", (None, 3, (3, 5), {"dim_0": (2, 1), "dim_2": (4, 2)})
4729 )
4730 def test_pad_linear_ramp(self, end_values) -> None:
4731 ar = DataArray(np.arange(3 * 4 * 5).reshape(3, 4, 5))
4732 actual = ar.pad(
4733 dim_0=(1, 3), dim_2=(2, 2), mode="linear_ramp", end_values=end_values
4734 )
4735 if end_values is None:
4736 end_values = 0
4737 elif isinstance(end_values, dict):
4738 end_values = (end_values["dim_0"], (4, 4), end_values["dim_2"])
4739 expected = DataArray(
4740 np.pad(
4741 np.arange(3 * 4 * 5).reshape(3, 4, 5),
4742 pad_width=((1, 3), (0, 0), (2, 2)),
4743 mode="linear_ramp",
4744 end_values=end_values,
4745 )
4746 )
4747 assert actual.shape == (7, 4, 9)
4748 assert_identical(actual, expected)
4749
4750 @pytest.mark.parametrize("mode", ("reflect", "symmetric"))
4751 @pytest.mark.parametrize("reflect_type", (None, "even", "odd"))

Callers

nothing calls this directly

Calls 5

padMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90
arangeMethod · 0.80
padMethod · 0.45

Tested by

no test coverage detected