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

Method test_full_like

xarray/tests/test_dataarray.py:4323–4345  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4321 array.other = 2
4322
4323 def test_full_like(self) -> None:
4324 # For more thorough tests, see test_variable.py
4325 da = DataArray(
4326 np.random.random(size=(2, 2)),
4327 dims=("x", "y"),
4328 attrs={"attr1": "value1"},
4329 coords={"x": [4, 3]},
4330 name="helloworld",
4331 )
4332
4333 actual = full_like(da, 2)
4334 expect = da.copy(deep=True)
4335 expect.values = np.array([[2.0, 2.0], [2.0, 2.0]])
4336 assert_identical(expect, actual)
4337
4338 # override dtype
4339 actual = full_like(da, fill_value=True, dtype=bool)
4340 expect.values = np.array([[True, True], [True, True]])
4341 assert expect.dtype == bool
4342 assert_identical(expect, actual)
4343
4344 with pytest.raises(ValueError, match="'dtype' cannot be dict-like"):
4345 full_like(da, fill_value=True, dtype={"x": bool})
4346
4347 def test_dot(self) -> None:
4348 x = np.linspace(-3, 3, 6)

Callers

nothing calls this directly

Calls 4

copyMethod · 0.95
DataArrayClass · 0.90
full_likeFunction · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected