Skip to content

COMPAT: clean up warnings #19003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ environment:
# See: http://stackoverflow.com/a/13751649/163740
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\run_with_env.cmd"
clone_folder: C:\projects\pandas
PANDAS_TESTING_MODE: "deprecate"

matrix:

Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ Other API Changes
- :func:`wide_to_long` previously kept numeric-like suffixes as ``object`` dtype. Now they are cast to numeric if possible (:issue:`17627`)
- In :func:`read_excel`, the ``comment`` argument is now exposed as a named parameter (:issue:`18735`)
- Rearranged the order of keyword arguments in :func:`read_excel()` to align with :func:`read_csv()` (:issue:`16672`)
- The options ``html.border`` and ``mode.use_inf_as_null`` were deprecated in prior versions, these will now show ``FutureWarning`` rather than a ``DeprecationWarning`` (:issue:`19003`)

.. _whatsnew_0230.deprecations:

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def _warn_if_deprecated(key):
if d:
if d.msg:
print(d.msg)
warnings.warn(d.msg, DeprecationWarning)
warnings.warn(d.msg, FutureWarning)
else:
msg = "'{key}' is deprecated".format(key=key)
if d.removal_ver:
Expand All @@ -624,7 +624,7 @@ def _warn_if_deprecated(key):
else:
msg += ', please refrain from using it.'

warnings.warn(msg, DeprecationWarning)
warnings.warn(msg, FutureWarning)
return True
return False

Expand Down
4 changes: 4 additions & 0 deletions pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ def array_equivalent(left, right, strict_nan=False):

# NaNs can occur in float and complex arrays.
if is_float_dtype(left) or is_complex_dtype(left):

# empty
if not (np.prod(left.shape) and np.prod(right.shape)):
return True
return ((left == right) | (isna(left) & isna(right))).all()

# numpy will will not allow this type of datetimelike vs integer comparison
Expand Down
12 changes: 6 additions & 6 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ def test_constructor_error_msgs(self):

# wrong size axis labels
with tm.assert_raises_regex(ValueError, "Shape of passed values "
"is \(3, 2\), indices "
"imply \(3, 1\)"):
r"is \(3, 2\), indices "
r"imply \(3, 1\)"):
DataFrame(np.random.rand(2, 3), columns=['A', 'B', 'C'], index=[1])

with tm.assert_raises_regex(ValueError, "Shape of passed values "
"is \(3, 2\), indices "
"imply \(2, 2\)"):
r"is \(3, 2\), indices "
r"imply \(2, 2\)"):
DataFrame(np.random.rand(2, 3), columns=['A', 'B'], index=[1, 2])

with tm.assert_raises_regex(ValueError, "If using all scalar "
Expand Down Expand Up @@ -1220,12 +1220,12 @@ def test_constructor_from_items(self):
def test_constructor_from_items_scalars(self):
# GH 17312
with tm.assert_raises_regex(ValueError,
'The value in each \(key, value\) '
r'The value in each \(key, value\) '
'pair must be an array, Series, or dict'):
DataFrame.from_items([('A', 1), ('B', 4)])

with tm.assert_raises_regex(ValueError,
'The value in each \(key, value\) '
r'The value in each \(key, value\) '
'pair must be an array, Series, or dict'):
DataFrame.from_items([('A', 1), ('B', 2)], columns=['col1'],
orient='index')
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_query_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,6 @@ def test_invalid_type_for_operator_raises(self, parser, engine):
ops = '+', '-', '*', '/'
for op in ops:
with tm.assert_raises_regex(TypeError,
"unsupported operand type\(s\) "
r"unsupported operand type\(s\) "
"for .+: '.+' and '.+'"):
df.eval('a {0} b'.format(op), engine=engine, parser=parser)
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_nth.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_nth(self):
df = DataFrame([[1, np.nan], [1, 4], [5, 6]], columns=['A', 'B'])
g = df.groupby('A')
# PR 17493, related to issue 11038
# test Series.nth with True for dropna produces DeprecationWarning
# test Series.nth with True for dropna produces FutureWarning
with assert_produces_warning(FutureWarning):
result = g.B.nth(0, dropna=True)
expected = g.B.first()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_transform_casting(self):
9 B-053 b76cd912ff "2014-10-08 19:17:48"
10 B-065 b76cd912ff "2014-10-08 19:21:38"
"""
df = pd.read_csv(StringIO(data), sep='\s+',
df = pd.read_csv(StringIO(data), sep=r'\s+',
index_col=[0], parse_dates=['DATETIME'])

result = df.groupby('ID3')['DATETIME'].transform(lambda x: x.diff())
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_date_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def test_daterange_bug_456(self):
assert isinstance(result, DatetimeIndex)

def test_error_with_zero_monthends(self):
msg = 'Offset <0 \* MonthEnds> did not increment date'
msg = r'Offset <0 \* MonthEnds> did not increment date'
with tm.assert_raises_regex(ValueError, msg):
date_range('1/1/2000', '1/1/2001', freq=MonthEnd(0))

Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/indexes/datetimes/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def test_dataframe(self, cache):
'day': [4, 5]})

msg = ("cannot assemble the datetimes: time data .+ does not "
"match format '%Y%m%d' \(match\)")
r"match format '%Y%m%d' \(match\)")
with tm.assert_raises_regex(ValueError, msg):
to_datetime(df2, cache=cache)
result = to_datetime(df2, errors='coerce', cache=cache)
Expand All @@ -719,15 +719,15 @@ def test_dataframe(self, cache):

# extra columns
msg = ("extra keys have been passed to the datetime assemblage: "
"\[foo\]")
r"\[foo\]")
with tm.assert_raises_regex(ValueError, msg):
df2 = df.copy()
df2['foo'] = 1
to_datetime(df2, cache=cache)

# not enough
msg = ('to assemble mappings requires at least that \[year, month, '
'day\] be specified: \[.+\] is missing')
msg = (r'to assemble mappings requires at least that \[year, month, '
r'day\] be specified: \[.+\] is missing')
for c in [['year'],
['year', 'month'],
['year', 'month', 'second'],
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/interval/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_constructors_empty(self, data, closed):
def test_constructors_errors(self):

# scalar
msg = ('IntervalIndex\(...\) must be called with a collection of '
msg = (r'IntervalIndex\(...\) must be called with a collection of '
'some kind, 5 was passed')
with tm.assert_raises_regex(TypeError, msg):
IntervalIndex(5)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/test_multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def test_getitem_partial_int(self):
# missing item:
with tm.assert_raises_regex(KeyError, '1'):
df[1]
with tm.assert_raises_regex(KeyError, "'\[1\] not in index'"):
with tm.assert_raises_regex(KeyError, r"'\[1\] not in index'"):
df[[1]]

def test_loc_multiindex_indexer_none(self):
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/io/formats/test_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,8 +1411,9 @@ def test_to_html_border_zero(self):
result = df.to_html(border=0)
assert 'border="0"' in result

@tm.capture_stdout
def test_display_option_warning(self):
with tm.assert_produces_warning(DeprecationWarning,
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
pd.options.html.border

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/formats/test_to_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,11 @@ def test_to_latex_longtable(self, frame):

df = DataFrame({'a': [1, 2]})
with1column_result = df.to_latex(index=False, longtable=True)
assert "\multicolumn{1}" in with1column_result
assert r"\multicolumn{1}" in with1column_result

df = DataFrame({'a': [1, 2], 'b': [3, 4], 'c': [5, 6]})
with3columns_result = df.to_latex(index=False, longtable=True)
assert "\multicolumn{3}" in with3columns_result
assert r"\multicolumn{3}" in with3columns_result

def test_to_latex_escape_special_chars(self):
special_characters = ['&', '%', '$', '#', '_', '{', '}', '~', '^',
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import numpy as np
import pandas as pd
from pandas.compat import PY3, is_platform_windows
from pandas.compat import PY3, is_platform_windows, is_platform_mac
from pandas.io.parquet import (to_parquet, read_parquet, get_engine,
PyArrowImpl, FastParquetImpl)
from pandas.util import testing as tm
Expand Down Expand Up @@ -174,8 +174,8 @@ def test_options_get_engine(fp, pa):
assert isinstance(get_engine('fastparquet'), FastParquetImpl)


@pytest.mark.xfail(is_platform_windows(),
reason="reading pa metadata failing on Windows")
@pytest.mark.xfail(is_platform_windows() or is_platform_mac(),
reason="reading pa metadata failing on Windows/mac")
def test_cross_engine_pa_fp(df_cross_compat, pa, fp):
# cross-compat with differing reading/writing engines

Expand Down
1 change: 1 addition & 0 deletions pandas/tests/plotting/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def test_parallel_coordinates(self):
def test_parallel_coordinates_with_sorted_labels(self):
""" For #15908 """
from pandas.plotting import parallel_coordinates

df = DataFrame({"feat": [i for i in range(30)],
"class": [2 for _ in range(10)] +
[3 for _ in range(10)] +
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/reshape/merge/test_merge_asof.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ def test_on_float_by_int(self):

def test_merge_datatype_error(self):
""" Tests merge datatype mismatch error """
msg = 'merge keys \[0\] object and int64, must be the same type'
msg = r'merge keys \[0\] object and int64, must be the same type'

left = pd.DataFrame({'left_val': [1, 5, 10],
'a': ['a', 'b', 'c']})
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/reshape/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ def test_concatlike_same_dtypes(self):
tm.assert_series_equal(res, exp, check_index_type=True)

# cannot append non-index
msg = ('cannot concatenate object of type \"(.+?)\";'
msg = (r'cannot concatenate object of type \"(.+?)\";'
' only pd.Series, pd.DataFrame, and pd.Panel'
' \(deprecated\) objs are valid')
r' \(deprecated\) objs are valid')
with tm.assert_raises_regex(TypeError, msg):
pd.Series(vals1).append(vals2)

Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/scalar/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_math_add(self, interval):
actual += 1
assert expected == actual

msg = "unsupported operand type\(s\) for \+"
msg = r"unsupported operand type\(s\) for \+"
with tm.assert_raises_regex(TypeError, msg):
interval + Interval(1, 2)

Expand All @@ -138,7 +138,7 @@ def test_math_sub(self, interval):
actual -= 1
assert expected == actual

msg = "unsupported operand type\(s\) for -"
msg = r"unsupported operand type\(s\) for -"
with tm.assert_raises_regex(TypeError, msg):
interval - Interval(1, 2)

Expand All @@ -158,11 +158,11 @@ def test_math_mult(self, interval):
actual *= 2
assert expected == actual

msg = "unsupported operand type\(s\) for \*"
msg = r"unsupported operand type\(s\) for \*"
with tm.assert_raises_regex(TypeError, msg):
interval * Interval(1, 2)

msg = "can\'t multiply sequence by non-int"
msg = r"can\'t multiply sequence by non-int"
with tm.assert_raises_regex(TypeError, msg):
interval * 'foo'

Expand All @@ -175,7 +175,7 @@ def test_math_div(self, interval):
actual /= 2.0
assert expected == actual

msg = "unsupported operand type\(s\) for /"
msg = r"unsupported operand type\(s\) for /"
with tm.assert_raises_regex(TypeError, msg):
interval / Interval(1, 2)

Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/series/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,9 @@ def test_isna_for_inf(self):
def test_isnull_for_inf_deprecated(self):
# gh-17115
s = Series(['a', np.inf, np.nan, 1.0])
with tm.assert_produces_warning(DeprecationWarning,
check_stacklevel=False):
pd.set_option('mode.use_inf_as_null', True)
with pd.option_context('mode.use_inf_as_null', True):
r = s.isna()
dr = s.dropna()
pd.reset_option('mode.use_inf_as_null')

e = Series([False, True, True, False])
de = Series(['a', 1.0], index=[0, 3])
Expand Down
Loading