5757
5858from numpy .testing import assert_almost_equal , assert_array_equal , assert_allclose
5959
60- from ..testing import data_path as DATA_PATH , assert_dt_equal
60+ from ..testing import data_path as DATA_PATH , assert_dt_equal , clear_and_catch_warnings
6161
6262from ..tmpdirs import InTemporaryDirectory
6363
@@ -139,6 +139,12 @@ def validate_array_interface_with_dtype(self, pmaker, params):
139139 assert_array_equal (orig , params ['arr_out' ])
140140 assert_dt_equal (orig .dtype , params ['dtype_out' ])
141141
142+ context = None
143+ if np .issubdtype (orig .dtype , np .complexfloating ):
144+ context = clear_and_catch_warnings ()
145+ context .__enter__ ()
146+ warnings .simplefilter ('ignore' , np .ComplexWarning )
147+
142148 for dtype in np .sctypes ['float' ] + np .sctypes ['int' ] + np .sctypes ['uint' ]:
143149 # Directly coerce with a dtype
144150 direct = dtype (prox )
@@ -156,6 +162,9 @@ def validate_array_interface_with_dtype(self, pmaker, params):
156162 # Shape matches expected shape
157163 assert_equal (out .shape , params ['shape' ])
158164
165+ if context is not None :
166+ context .__exit__ ()
167+
159168 def validate_header_isolated (self , pmaker , params ):
160169 # Confirm altering input header has no effect
161170 # Depends on header providing 'get_data_dtype', 'set_data_dtype',
0 commit comments