Skip to content

Commit 2f160f0

Browse files
authored
TST: suppress some warnings (#15932)
1 parent 0cfc08c commit 2f160f0

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

pandas/core/algorithms.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
intended for public consumption
44
"""
55
from __future__ import division
6-
from warnings import warn
6+
from warnings import warn, catch_warnings
77
import numpy as np
88

99
from pandas import compat, _np_version_under1p8
@@ -110,7 +110,11 @@ def _ensure_data(values, dtype=None):
110110
values = _ensure_uint64(values)
111111
ndtype = dtype = 'uint64'
112112
elif is_complex_dtype(values) or is_complex_dtype(dtype):
113-
values = _ensure_float64(values)
113+
114+
# ignore the fact that we are casting to float
115+
# which discards complex parts
116+
with catch_warnings(record=True):
117+
values = _ensure_float64(values)
114118
ndtype = dtype = 'float64'
115119
elif is_float_dtype(values) or is_float_dtype(dtype):
116120
values = _ensure_float64(values)

pandas/tests/test_errors.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
import pytest
4+
from warnings import catch_warnings
45
import pandas # noqa
56
import pandas as pd
67

@@ -44,7 +45,8 @@ def test_error_rename():
4445
except CParserError:
4546
pass
4647

47-
try:
48-
raise ParserError()
49-
except pd.parser.CParserError:
50-
pass
48+
with catch_warnings(record=True):
49+
try:
50+
raise ParserError()
51+
except pd.parser.CParserError:
52+
pass

0 commit comments

Comments
 (0)