Skip to content

Commit 1aa6cd4

Browse files
committed
Merge pull request #11391 from jreback/slow
TST: make a couple of tests slow / remove some warnings
2 parents 84e2f31 + 0634ddf commit 1aa6cd4

File tree

17 files changed

+123
-101
lines changed

17 files changed

+123
-101
lines changed

ci/requirements-2.7_SLOW.pip

Whitespace-only changes.

pandas/io/ga.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
3. Goto APIs and register for OAuth2.0 for installed applications
55
4. Download JSON secret file and move into same directory as this file
66
"""
7-
8-
# GH11038
9-
import warnings
10-
warnings.warn("The pandas.io.ga module is deprecated and will be "
11-
"removed in a future version.",
12-
FutureWarning, stacklevel=2)
13-
147
from datetime import datetime
158
import re
169
from pandas import compat
@@ -27,6 +20,12 @@
2720
from oauth2client.client import AccessTokenRefreshError
2821
from pandas.compat import zip, u
2922

23+
# GH11038
24+
import warnings
25+
warnings.warn("The pandas.io.ga module is deprecated and will be "
26+
"removed in a future version.",
27+
FutureWarning, stacklevel=2)
28+
3029
TYPE_MAP = {u('INTEGER'): int, u('FLOAT'): float, u('TIME'): int}
3130

3231
NO_CALLBACK = auth.OOB_CALLBACK_URN

pandas/io/tests/test_data.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
import numpy as np
1010
import pandas as pd
1111
from pandas import DataFrame, Timestamp
12-
from pandas.io import data as web
13-
from pandas.io.data import DataReader, SymbolWarning, RemoteDataError, _yahoo_codes
1412
from pandas.util.testing import (assert_series_equal, assert_produces_warning,
1513
network, assert_frame_equal)
1614
import pandas.util.testing as tm
1715

16+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
17+
from pandas.io import data as web
18+
19+
from pandas.io.data import DataReader, SymbolWarning, RemoteDataError, _yahoo_codes
20+
1821
if compat.PY3:
1922
from urllib.error import HTTPError
2023
else:
@@ -293,6 +296,7 @@ def test_get_date_ret_index(self):
293296

294297

295298
class TestYahooOptions(tm.TestCase):
299+
296300
@classmethod
297301
def setUpClass(cls):
298302
super(TestYahooOptions, cls).setUpClass()

pandas/io/tests/test_excel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
from distutils.version import LooseVersion
88

9+
import warnings
910
import operator
1011
import functools
1112
import nose
@@ -1829,7 +1830,6 @@ def test_column_format(self):
18291830
# Applicable to xlsxwriter only.
18301831
_skip_if_no_xlsxwriter()
18311832

1832-
import warnings
18331833
with warnings.catch_warnings():
18341834
# Ignore the openpyxl lxml warning.
18351835
warnings.simplefilter("ignore")

pandas/io/tests/test_ga.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
from datetime import datetime
33

4+
import warnings
45
import nose
56
import pandas as pd
67
from pandas import compat
@@ -13,7 +14,12 @@
1314

1415
try:
1516
import httplib2
16-
import pandas.io.ga as ga
17+
import apiclient
18+
19+
# deprecated
20+
with warnings.catch_warnings(record=True):
21+
import pandas.io.ga as ga
22+
1723
from pandas.io.ga import GAnalytics, read_ga
1824
from pandas.io.auth import AuthenticationConfigError, reset_default_token_store
1925
from pandas.io import auth

pandas/io/tests/test_packers.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -461,20 +461,21 @@ def test_sparse_frame(self):
461461

462462
def test_sparse_panel(self):
463463

464-
items = ['x', 'y', 'z']
465-
p = Panel(dict((i, tm.makeDataFrame().ix[:2, :2]) for i in items))
466-
sp = p.to_sparse()
464+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
465+
items = ['x', 'y', 'z']
466+
p = Panel(dict((i, tm.makeDataFrame().ix[:2, :2]) for i in items))
467+
sp = p.to_sparse()
467468

468-
self._check_roundtrip(sp, tm.assert_panel_equal,
469-
check_panel_type=True)
469+
self._check_roundtrip(sp, tm.assert_panel_equal,
470+
check_panel_type=True)
470471

471-
sp2 = p.to_sparse(kind='integer')
472-
self._check_roundtrip(sp2, tm.assert_panel_equal,
473-
check_panel_type=True)
472+
sp2 = p.to_sparse(kind='integer')
473+
self._check_roundtrip(sp2, tm.assert_panel_equal,
474+
check_panel_type=True)
474475

475-
sp3 = p.to_sparse(fill_value=0)
476-
self._check_roundtrip(sp3, tm.assert_panel_equal,
477-
check_panel_type=True)
476+
sp3 = p.to_sparse(fill_value=0)
477+
self._check_roundtrip(sp3, tm.assert_panel_equal,
478+
check_panel_type=True)
478479

479480

480481
class TestCompression(TestPackers):

pandas/io/tests/test_wb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
from pandas.util.testing import network
66
from pandas.util.testing import assert_frame_equal
77
from numpy.testing.decorators import slow
8-
from pandas.io.wb import search, download, get_countries
98
import pandas.util.testing as tm
109

10+
# deprecated
11+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
12+
from pandas.io.wb import search, download, get_countries
1113

1214
class TestWB(tm.TestCase):
1315

pandas/rpy/tests/test_common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import numpy as np
77
import unittest
88
import nose
9+
import warnings
910
import pandas.util.testing as tm
1011

1112
try:

pandas/sparse/array.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,15 @@ def __getitem__(self, key):
283283
if com.is_integer(key):
284284
return self._get_val_at(key)
285285
else:
286-
data_slice = self.values[key]
286+
if isinstance(key, SparseArray):
287+
key = np.asarray(key)
288+
if hasattr(key,'__len__') and len(self) != len(key):
289+
indices = self.sp_index
290+
if hasattr(indices,'to_int_index'):
291+
indices = indices.to_int_index()
292+
data_slice = self.values.take(indices.indices)[key]
293+
else:
294+
data_slice = self.values[key]
287295
return self._constructor(data_slice)
288296

289297
def __getslice__(self, i, j):
@@ -513,7 +521,12 @@ def make_sparse(arr, kind='block', fill_value=nan):
513521
else:
514522
mask = arr != fill_value
515523

516-
indices = np.arange(length, dtype=np.int32)[mask]
524+
length = len(arr)
525+
if length != mask.size:
526+
# the arr is a SparseArray
527+
indices = mask.sp_index.indices
528+
else:
529+
indices = np.arange(length, dtype=np.int32)[mask]
517530

518531
if kind == 'block':
519532
locs, lens = splib.get_blocks(indices)

pandas/stats/tests/test_moments.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ class TestMoments(Base):
4343

4444
def setUp(self):
4545
self._create_data()
46-
warnings.simplefilter("ignore", category=FutureWarning)
47-
48-
def tearDown(self):
49-
warnings.simplefilter("default", category=FutureWarning)
5046

5147
def test_centered_axis_validation(self):
5248
# ok
@@ -890,7 +886,6 @@ def _create_data(self):
890886

891887
def setUp(self):
892888
self._create_data()
893-
warnings.simplefilter("ignore", category=FutureWarning)
894889

895890
def _test_moments_consistency(self,
896891
min_periods,
@@ -1516,9 +1511,6 @@ def test_rolling_functions_window_non_shrinkage(self):
15161511

15171512
functions = [lambda x: mom.rolling_cov(x, x, pairwise=True, window=10, min_periods=5),
15181513
lambda x: mom.rolling_corr(x, x, pairwise=True, window=10, min_periods=5),
1519-
# rolling_corr_pairwise is depracated, so the following line should be deleted
1520-
# when rolling_corr_pairwise is removed.
1521-
lambda x: mom.rolling_corr_pairwise(x, x, window=10, min_periods=5),
15221514
]
15231515
for f in functions:
15241516
df_result_panel = f(df)
@@ -1585,9 +1577,6 @@ def test_moment_functions_zero_length(self):
15851577
lambda x: mom.expanding_corr(x, x, pairwise=True, min_periods=5),
15861578
lambda x: mom.rolling_cov(x, x, pairwise=True, window=10, min_periods=5),
15871579
lambda x: mom.rolling_corr(x, x, pairwise=True, window=10, min_periods=5),
1588-
# rolling_corr_pairwise is depracated, so the following line should be deleted
1589-
# when rolling_corr_pairwise is removed.
1590-
lambda x: mom.rolling_corr_pairwise(x, x, window=10, min_periods=5),
15911580
]
15921581
for f in functions:
15931582
df1_result_panel = f(df1)

0 commit comments

Comments
 (0)