From 7e21c6a31649b25a36fe142f7e5ef86692f723ad Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Thu, 6 Apr 2017 22:55:20 -0400 Subject: [PATCH] TST: suppress some warnings --- pandas/core/algorithms.py | 8 ++++++-- pandas/tests/test_errors.py | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 244f882f2c103..9b88ea23483bd 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -3,7 +3,7 @@ intended for public consumption """ from __future__ import division -from warnings import warn +from warnings import warn, catch_warnings import numpy as np from pandas import compat, _np_version_under1p8 @@ -110,7 +110,11 @@ def _ensure_data(values, dtype=None): values = _ensure_uint64(values) ndtype = dtype = 'uint64' elif is_complex_dtype(values) or is_complex_dtype(dtype): - values = _ensure_float64(values) + + # ignore the fact that we are casting to float + # which discards complex parts + with catch_warnings(record=True): + values = _ensure_float64(values) ndtype = dtype = 'float64' elif is_float_dtype(values) or is_float_dtype(dtype): values = _ensure_float64(values) diff --git a/pandas/tests/test_errors.py b/pandas/tests/test_errors.py index aabce7ecb7066..4a0850734e134 100644 --- a/pandas/tests/test_errors.py +++ b/pandas/tests/test_errors.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import pytest +from warnings import catch_warnings import pandas # noqa import pandas as pd @@ -44,7 +45,8 @@ def test_error_rename(): except CParserError: pass - try: - raise ParserError() - except pd.parser.CParserError: - pass + with catch_warnings(record=True): + try: + raise ParserError() + except pd.parser.CParserError: + pass