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

Method test_masked_array

xarray/tests/test_variable.py:2755–2780  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2753 assert np.asarray(input_array).dtype == actual.dtype
2754
2755 def test_masked_array(self):
2756 original: Any = np.ma.MaskedArray(np.arange(5))
2757 expected = np.arange(5)
2758 actual: Any = as_compatible_data(original)
2759 assert_array_equal(expected, actual)
2760 assert np.dtype(float) == actual.dtype
2761
2762 original1: Any = np.ma.MaskedArray(np.arange(5), mask=4 * [False] + [True])
2763 expected1: Any = np.arange(5.0)
2764 expected1[-1] = np.nan
2765 actual = as_compatible_data(original1)
2766 assert_array_equal(expected1, actual)
2767 assert np.dtype(float) == actual.dtype
2768
2769 original2: Any = np.ma.MaskedArray([1.0, 2.0], mask=[True, False])
2770 original2.flags.writeable = False
2771 expected2: Any = [np.nan, 2.0]
2772 actual = as_compatible_data(original2)
2773 assert_array_equal(expected2, actual)
2774 assert np.dtype(float) == actual.dtype
2775
2776 # GH2377
2777 actual_var: Any = Variable(dims=tuple(), data=np.ma.masked)
2778 expected_var = Variable(dims=tuple(), data=np.nan)
2779 assert_array_equal(expected_var, actual_var)
2780 assert actual_var.dtype == expected_var.dtype
2781
2782 def test_datetime(self):
2783 expected = np.datetime64("2000-01-01")

Callers

nothing calls this directly

Calls 4

as_compatible_dataFunction · 0.90
VariableClass · 0.90
arangeMethod · 0.80
dtypeMethod · 0.45

Tested by

no test coverage detected