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

Method test_fillna

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

Source from the content-addressed store, hash-verified

2811 ),
2812 )
2813 def test_fillna(self, fill_value, unit, error, dtype):
2814 original_unit = unit_registry.m
2815 array = (
2816 create_nan_array([1.4, np.nan, 2.3, np.nan, np.nan, 9.1], dtype)
2817 * original_unit
2818 )
2819 data_array = xr.DataArray(data=array)
2820
2821 func = method("fillna")
2822
2823 value = fill_value * unit
2824 if error is not None:
2825 with pytest.raises(error):
2826 func(data_array, value=value)
2827
2828 return
2829
2830 units = extract_units(data_array)
2831 expected = attach_units(
2832 func(
2833 strip_units(data_array), value=strip_units(convert_units(value, units))
2834 ),
2835 units,
2836 )
2837 actual = func(data_array, value=value)
2838
2839 assert_units_equal(expected, actual)
2840 assert_identical(expected, actual)
2841
2842 def test_dropna(self, dtype):
2843 array = (

Callers

nothing calls this directly

Calls 9

assert_identicalFunction · 0.90
create_nan_arrayFunction · 0.85
methodClass · 0.85
extract_unitsFunction · 0.85
attach_unitsFunction · 0.85
strip_unitsFunction · 0.85
convert_unitsFunction · 0.85
assert_units_equalFunction · 0.85
funcFunction · 0.70

Tested by

no test coverage detected