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

Method test_fillna

xarray/tests/test_units.py:4311–4339  ·  view source on GitHub ↗
(self, fill_value, unit, error, dtype)

Source from the content-addressed store, hash-verified

4309 ),
4310 )
4311 def test_fillna(self, fill_value, unit, error, dtype):
4312 array1 = (
4313 create_nan_array([1.4, np.nan, 2.3, np.nan, np.nan, 9.1], dtype)
4314 * unit_registry.m
4315 )
4316 array2 = (
4317 create_nan_array([4.3, 9.8, 7.5, np.nan, 8.2, np.nan], dtype)
4318 * unit_registry.m
4319 )
4320 ds = xr.Dataset({"a": ("x", array1), "b": ("x", array2)})
4321 value = fill_value * unit
4322 units = extract_units(ds)
4323
4324 if error is not None:
4325 with pytest.raises(error):
4326 ds.fillna(value=value)
4327
4328 return
4329
4330 actual = ds.fillna(value=value)
4331 expected = attach_units(
4332 strip_units(ds).fillna(
4333 value=strip_units(convert_units(value, {None: unit_registry.m}))
4334 ),
4335 units,
4336 )
4337
4338 assert_units_equal(expected, actual)
4339 assert_equal(expected, actual)
4340
4341 def test_dropna(self, dtype):
4342 array1 = (

Callers

nothing calls this directly

Calls 8

fillnaMethod · 0.95
assert_equalFunction · 0.90
create_nan_arrayFunction · 0.85
extract_unitsFunction · 0.85
attach_unitsFunction · 0.85
strip_unitsFunction · 0.85
convert_unitsFunction · 0.85
assert_units_equalFunction · 0.85

Tested by

no test coverage detected