@@ -168,13 +168,25 @@ def test_data(random_inputs: np.ndarray[Any, Any]) -> None:
168168
169169
170170def test_real_and_imag () -> None :
171- named_array : NamedArray [Any , Any ]
172- named_array = NamedArray (["x" ], np .arange (3 ) - 1j * np .arange (3 ))
173- expected_real = np .arange (3 )
174- assert np .array_equal (named_array .real .data , expected_real )
171+ expected_real : np .ndarray [Any , np .dtype [np .float64 ]]
172+ expected_real = np .arange (3 , dtype = np .float64 )
173+
174+ expected_imag : np .ndarray [Any , np .dtype [np .float64 ]]
175+ expected_imag = - np .arange (3 , dtype = np .float64 )
176+
177+ arr : np .ndarray [Any , np .dtype [np .complex128 ]]
178+ arr = expected_real + 1j * expected_imag
179+
180+ named_array : NamedArray [Any , np .dtype [np .complex128 ]]
181+ named_array = NamedArray (["x" ], arr )
182+
183+ actual_real : duckarray [Any , np .dtype [np .float64 ]] = named_array .real .data
184+ assert np .array_equal (actual_real , expected_real )
185+ assert actual_real .dtype == expected_real .dtype
175186
176- expected_imag = - np .arange (3 )
177- assert np .array_equal (named_array .imag .data , expected_imag )
187+ actual_imag : duckarray [Any , np .dtype [np .float64 ]] = named_array .imag .data
188+ assert np .array_equal (actual_imag , expected_imag )
189+ assert actual_imag .dtype == expected_imag .dtype
178190
179191
180192# Additional tests as per your original class-based code
@@ -347,7 +359,9 @@ def _new(
347359
348360def test_replace_namedarray () -> None :
349361 dtype_float = np .dtype (np .float32 )
362+ np_val : np .ndarray [Any , np .dtype [np .float32 ]]
350363 np_val = np .array ([1.5 , 3.2 ], dtype = dtype_float )
364+ np_val2 : np .ndarray [Any , np .dtype [np .float32 ]]
351365 np_val2 = 2 * np_val
352366
353367 narr_float : NamedArray [Any , np .dtype [np .float32 ]]
0 commit comments