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

Method test_real_and_imag

xarray/tests/test_namedarray.py:269–288  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

267 assert isinstance(output2.data, CustomArrayIndexable)
268
269 def test_real_and_imag(self) -> None:
270 expected_real: np.ndarray[Any, np.dtype[np.float64]]
271 expected_real = np.arange(3, dtype=np.float64)
272
273 expected_imag: np.ndarray[Any, np.dtype[np.float64]]
274 expected_imag = -np.arange(3, dtype=np.float64)
275
276 arr: np.ndarray[Any, np.dtype[np.complex128]]
277 arr = expected_real + 1j * expected_imag
278
279 named_array: NamedArray[Any, np.dtype[np.complex128]]
280 named_array = NamedArray(["x"], arr)
281
282 actual_real: duckarray[Any, np.dtype[np.float64]] = named_array.real.data
283 assert np.array_equal(np.asarray(actual_real), expected_real)
284 assert actual_real.dtype == expected_real.dtype
285
286 actual_imag: duckarray[Any, np.dtype[np.float64]] = named_array.imag.data
287 assert np.array_equal(np.asarray(actual_imag), expected_imag)
288 assert actual_imag.dtype == expected_imag.dtype
289
290 # Additional tests as per your original class-based code
291 @pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

NamedArrayClass · 0.90
arangeMethod · 0.80

Tested by

no test coverage detected