57
57
58
58
from numpy .testing import assert_almost_equal , assert_array_equal , assert_allclose
59
59
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
61
61
62
62
from ..tmpdirs import InTemporaryDirectory
63
63
@@ -139,6 +139,12 @@ def validate_array_interface_with_dtype(self, pmaker, params):
139
139
assert_array_equal (orig , params ['arr_out' ])
140
140
assert_dt_equal (orig .dtype , params ['dtype_out' ])
141
141
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
+
142
148
for dtype in np .sctypes ['float' ] + np .sctypes ['int' ] + np .sctypes ['uint' ]:
143
149
# Directly coerce with a dtype
144
150
direct = dtype (prox )
@@ -156,6 +162,9 @@ def validate_array_interface_with_dtype(self, pmaker, params):
156
162
# Shape matches expected shape
157
163
assert_equal (out .shape , params ['shape' ])
158
164
165
+ if context is not None :
166
+ context .__exit__ ()
167
+
159
168
def validate_header_isolated (self , pmaker , params ):
160
169
# Confirm altering input header has no effect
161
170
# Depends on header providing 'get_data_dtype', 'set_data_dtype',
0 commit comments