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

Function create_nan_array

xarray/tests/test_units.py:33–42  ·  view source on GitHub ↗

Create array with NaN values, handling cast warnings for int dtypes.

(values, dtype)

Source from the content-addressed store, hash-verified

31
32
33def create_nan_array(values, dtype):
34 """Create array with NaN values, handling cast warnings for int dtypes."""
35 import warnings
36
37 # When casting float arrays with NaN to integer, NumPy raises a warning
38 # This is expected behavior when dtype is int
39 with warnings.catch_warnings():
40 if np.issubdtype(dtype, np.integer):
41 warnings.filterwarnings("ignore", "invalid value encountered in cast")
42 return np.array(values).astype(dtype)
43
44
45# make sure scalars are converted to 0d arrays so quantities can

Callers 10

test_fillnaMethod · 0.85
test_dropnaMethod · 0.85
test_isinMethod · 0.85
test_fillnaMethod · 0.85
test_dropnaMethod · 0.85
test_isinMethod · 0.85
test_interpolate_naMethod · 0.85
test_combine_firstMethod · 0.85

Calls 1

astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…