Skip to content

COMPAT: remove deprecated optinos from printing in test suite (GH6984) #6986

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 1 commit into from
Apr 27, 2014
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
4 changes: 3 additions & 1 deletion doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ Deprecations
will not be supported in a future release (:issue:`6645`)

- Indexers will warn ``FutureWarning`` when used with a scalar indexer and
a non-floating point Index (:issue:`4892`)
a non-floating point Index (:issue:`4892`, :issue:`6960`)

- Numpy 1.9 compat w.r.t. deprecation warnings (:issue:`6960`)

- :meth:`Panel.shift` now has a function signature that matches :meth:`DataFrame.shift`.
The old positional argument ``lags`` has been changed to a keyword argument
Expand Down
26 changes: 17 additions & 9 deletions doc/source/v0.14.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ Deprecations
will not be supported in a future release (:issue:`6645`)

- Indexers will warn ``FutureWarning`` when used with a scalar indexer and
a non-floating point Index (:issue:`4892`)
a non-floating point Index (:issue:`4892`, :issue:`6960`)

.. code-block:: python

Expand All @@ -401,17 +401,25 @@ Deprecations
pandas/core/index.py:469: FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point
Out[1]: 1

In [5]: Series(1,np.arange(5)).iloc[3.0]
In [2]: Series(1,np.arange(5)).iloc[3.0]
pandas/core/index.py:469: FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point
Out[5]: 1
Out[2]: 1

# these are Float64Indexes, so integer or floating point is acceptable
In [3]: Series(1,np.arange(5.))[3]
Out[3]: 1
In [3]: Series(1,np.arange(5)).iloc[3.0:4]
pandas/core/index.py:527: FutureWarning: slice indexers when using iloc should be integers and not floating point
Out[3]:
3 1
dtype: int64

In [4]: Series(1,np.arange(5.))[3.0]
# these are Float64Indexes, so integer or floating point is acceptable
In [4]: Series(1,np.arange(5.))[3]
Out[4]: 1

In [5]: Series(1,np.arange(5.))[3.0]
Out[6]: 1

- Numpy 1.9 compat w.r.t. deprecation warnings (:issue:`6960`)

- :meth:`Panel.shift` now has a function signature that matches :meth:`DataFrame.shift`.
The old positional argument ``lags`` has been changed to a keyword argument
``periods`` with a default value of 1. A ``FutureWarning`` is raised if the
Expand Down Expand Up @@ -484,13 +492,13 @@ Enhancements
- Added ``how`` option to rolling-moment functions to dictate how to handle resampling; :func:``rolling_max`` defaults to max,
:func:``rolling_min`` defaults to min, and all others default to mean (:issue:`6297`)
- ``CustomBuisnessMonthBegin`` and ``CustomBusinessMonthEnd`` are now available (:issue:`6866`)
- :meth:`Series.quantile` and :meth:`DataFrame.quantile` now accept an array of
- :meth:`Series.quantile` and :meth:`DataFrame.quantile` now accept an array of
quantiles.
- ``pivot_table`` can now accept ``Grouper`` by ``index`` and ``columns`` keywords (:issue:`6913`)

.. ipython:: python

import datetime
import datetime
df = DataFrame({
'Branch' : 'A A A A A B'.split(),
'Buyer': 'Carl Mark Carl Carl Joe Joe'.split(),
Expand Down
7 changes: 4 additions & 3 deletions pandas/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _describe_option(pat='', _print_desc=True):
return s


def _reset_option(pat):
def _reset_option(pat, silent=False):

keys = _select_options(pat)

Expand All @@ -154,7 +154,7 @@ def _reset_option(pat):
'value')

for k in keys:
_set_option(k, _registered_options[k].defval)
_set_option(k, _registered_options[k].defval, silent=silent)


def get_default_val(pat):
Expand Down Expand Up @@ -361,7 +361,7 @@ def __enter__(self):
def __exit__(self, *args):
if self.undo:
for pat, val in self.undo:
_set_option(pat, val)
_set_option(pat, val, silent=True)


def register_option(key, defval, doc='', validator=None, cb=None):
Expand Down Expand Up @@ -567,6 +567,7 @@ def _warn_if_deprecated(key):
d = _get_deprecated_option(key)
if d:
if d.msg:
print(d.msg)
warnings.warn(d.msg, DeprecationWarning)
else:
msg = "'%s' is deprecated" % key
Expand Down
19 changes: 9 additions & 10 deletions pandas/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ def test_eng_float_formatter(self):

fmt.set_eng_float_format(accuracy=0)
repr(self.frame)

fmt.reset_option('^display.')
self.reset_display_options()

def test_repr_tuples(self):
buf = StringIO()
Expand Down Expand Up @@ -1034,7 +1033,7 @@ def test_to_string_no_index(self):
assert(df_s == expected)

def test_to_string_float_formatting(self):
fmt.reset_option('^display.')
self.reset_display_options()
fmt.set_option('display.precision', 6, 'display.column_space',
12, 'display.notebook_repr_html', False)

Expand Down Expand Up @@ -1065,7 +1064,7 @@ def test_to_string_float_formatting(self):
'1 0.253')
assert(df_s == expected)

fmt.reset_option('^display.')
self.reset_display_options()
self.assertEqual(get_option("display.precision"), 7)

df = DataFrame({'x': [1e9, 0.2512]})
Expand Down Expand Up @@ -1157,7 +1156,7 @@ def test_to_string_index_formatter(self):
self.assertEqual(rs, xp)

def test_to_string_left_justify_cols(self):
fmt.reset_option('^display.')
self.reset_display_options()
df = DataFrame({'x': [3234, 0.253]})
df_s = df.to_string(justify='left')
expected = (' x \n'
Expand All @@ -1166,7 +1165,7 @@ def test_to_string_left_justify_cols(self):
assert(df_s == expected)

def test_to_string_format_na(self):
fmt.reset_option('^display.')
self.reset_display_options()
df = DataFrame({'A': [np.nan, -1, -2.1234, 3, 4],
'B': [np.nan, 'foo', 'foooo', 'fooooo', 'bar']})
result = df.to_string()
Expand Down Expand Up @@ -1434,14 +1433,14 @@ def test_repr_html(self):
fmt.set_option('display.notebook_repr_html', False)
self.frame._repr_html_()

fmt.reset_option('^display.')
self.reset_display_options()

df = DataFrame([[1, 2], [3, 4]])
self.assertTrue('2 rows' in df._repr_html_())
fmt.set_option('display.show_dimensions', False)
self.assertFalse('2 rows' in df._repr_html_())

fmt.reset_option('^display.')
self.reset_display_options()

def test_repr_html_wide(self):
row = lambda l, k: [tm.rands(k) for _ in range(l)]
Expand Down Expand Up @@ -1580,7 +1579,7 @@ def get_ipython():
repstr = self.frame._repr_html_()
self.assertIn('class', repstr) # info fallback

fmt.reset_option('^display.')
self.reset_display_options()

def test_to_html_with_classes(self):
df = pandas.DataFrame()
Expand Down Expand Up @@ -2092,7 +2091,7 @@ def test_eng_float_formatter(self):
'3 1E+06')
self.assertEqual(result, expected)

fmt.reset_option('^display.')
self.reset_display_options()

def compare(self, formatter, input, output):
formatted_input = formatter(input)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4355,7 +4355,7 @@ def test_repr_dimensions(self):
fmt.set_option('display.show_dimensions', False)
self.assertFalse("2 rows x 2 columns" in repr(df))

fmt.reset_option('^display\.')
self.reset_display_options()

@slow
def test_repr_big(self):
Expand Down Expand Up @@ -4391,7 +4391,7 @@ def test_repr_unsortable(self):
fmt.set_option('display.max_rows', 1000, 'display.max_columns', 1000)
repr(self.frame)

fmt.reset_option('^display\.')
self.reset_display_options()

warnings.filters = warn_filters

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@ def test_format_sparse_config(self):
result = self.index.format()
self.assertEqual(result[1], 'foo two')

pd.reset_option("^display\.")
self.reset_display_options()

warnings.filters = warn_filters

Expand Down
4 changes: 4 additions & 0 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def setUpClass(cls):
def tearDownClass(cls):
pass

def reset_display_options(self):
# reset the display options
pd.reset_option('^display.',silent=True)

def assert_numpy_array_equal(self, np_array, assert_equal):
if np.array_equal(np_array, assert_equal):
return
Expand Down