Skip to content

Commit f919b9e

Browse files
sinhrksjreback
authored andcommitted
PEP8: test/indexes/base (#13771)
1 parent b60e42b commit f919b9e

File tree

1 file changed

+75
-56
lines changed

1 file changed

+75
-56
lines changed

pandas/tests/indexes/test_base.py

+75-56
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
from datetime import datetime, timedelta
44

5-
# TODO(wesm): fix long line flake8 issues
6-
# flake8: noqa
7-
85
import pandas.util.testing as tm
96
from pandas.indexes.api import Index, MultiIndex
107
from .common import Base
@@ -286,16 +283,19 @@ def test_constructor_dtypes(self):
286283

287284
for idx in [Index(np.array([True, False, True], dtype=bool)),
288285
Index([True, False, True]),
289-
Index(np.array([True, False, True], dtype=bool), dtype=bool),
286+
Index(np.array([True, False, True], dtype=bool),
287+
dtype=bool),
290288
Index([True, False, True], dtype=bool)]:
291289
self.assertIsInstance(idx, Index)
292290
self.assertEqual(idx.dtype, object)
293291

294292
for idx in [Index(np.array([1, 2, 3], dtype=int), dtype='category'),
295293
Index([1, 2, 3], dtype='category'),
296294
Index(np.array([np_datetime64_compat('2011-01-01'),
297-
np_datetime64_compat('2011-01-02')]), dtype='category'),
298-
Index([datetime(2011, 1, 1), datetime(2011, 1, 2)], dtype='category')]:
295+
np_datetime64_compat('2011-01-02')]),
296+
dtype='category'),
297+
Index([datetime(2011, 1, 1), datetime(2011, 1, 2)],
298+
dtype='category')]:
299299
self.assertIsInstance(idx, CategoricalIndex)
300300

301301
for idx in [Index(np.array([np_datetime64_compat('2011-01-01'),
@@ -304,7 +304,8 @@ def test_constructor_dtypes(self):
304304
self.assertIsInstance(idx, DatetimeIndex)
305305

306306
for idx in [Index(np.array([np_datetime64_compat('2011-01-01'),
307-
np_datetime64_compat('2011-01-02')]), dtype=object),
307+
np_datetime64_compat('2011-01-02')]),
308+
dtype=object),
308309
Index([datetime(2011, 1, 1),
309310
datetime(2011, 1, 2)], dtype=object)]:
310311
self.assertNotIsInstance(idx, DatetimeIndex)
@@ -483,10 +484,9 @@ def test_nanosecond_index_access(self):
483484
# self.assertEqual(first_value,
484485
# x['2013-01-01 00:00:00.000000050+0000'])
485486

486-
self.assertEqual(
487-
first_value,
488-
x[Timestamp(np_datetime64_compat('2013-01-01 00:00:00.000000050+0000',
489-
'ns'))])
487+
exp_ts = np_datetime64_compat('2013-01-01 00:00:00.000000050+0000',
488+
'ns')
489+
self.assertEqual(first_value, x[Timestamp(exp_ts)])
490490

491491
def test_comparators(self):
492492
index = self.dateIndex
@@ -1585,41 +1585,47 @@ def test_string_index_repr(self):
15851585
expected = u"""Index(['あ', 'いい', 'ううう'], dtype='object')"""
15861586
self.assertEqual(repr(idx), expected)
15871587
else:
1588-
expected = u"""\
1589-
Index([u'あ', u'いい', u'ううう'], dtype='object')"""
1588+
expected = u"""Index([u'あ', u'いい', u'ううう'], dtype='object')"""
15901589
self.assertEqual(coerce(idx), expected)
15911590

15921591
# multiple lines
15931592
idx = pd.Index([u'あ', u'いい', u'ううう'] * 10)
15941593
if PY3:
1595-
expected = u"""Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
1596-
'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
1597-
'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
1598-
dtype='object')"""
1599-
1594+
expected = (u"Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
1595+
u"'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',\n"
1596+
u" 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
1597+
u"'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',\n"
1598+
u" 'あ', 'いい', 'ううう', 'あ', 'いい', "
1599+
u"'ううう'],\n"
1600+
u" dtype='object')")
16001601
self.assertEqual(repr(idx), expected)
16011602
else:
1602-
expected = u"""Index([u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ',
1603-
u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい',
1604-
u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう'],
1605-
dtype='object')"""
1606-
1603+
expected = (u"Index([u'あ', u'いい', u'ううう', u'あ', u'いい', "
1604+
u"u'ううう', u'あ', u'いい', u'ううう', u'あ',\n"
1605+
u" u'いい', u'ううう', u'あ', u'いい', u'ううう', "
1606+
u"u'あ', u'いい', u'ううう', u'あ', u'いい',\n"
1607+
u" u'ううう', u'あ', u'いい', u'ううう', u'あ', "
1608+
u"u'いい', u'ううう', u'あ', u'いい', u'ううう'],\n"
1609+
u" dtype='object')")
16071610
self.assertEqual(coerce(idx), expected)
16081611

16091612
# truncated
16101613
idx = pd.Index([u'あ', u'いい', u'ううう'] * 100)
16111614
if PY3:
1612-
expected = u"""Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ',
1613-
...
1614-
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
1615-
dtype='object', length=300)"""
1616-
1615+
expected = (u"Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
1616+
u"'あ', 'いい', 'ううう', 'あ',\n"
1617+
u" ...\n"
1618+
u" 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', "
1619+
u"'ううう', 'あ', 'いい', 'ううう'],\n"
1620+
u" dtype='object', length=300)")
16171621
self.assertEqual(repr(idx), expected)
16181622
else:
1619-
expected = u"""Index([u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ',
1620-
...
1621-
u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう'],
1622-
dtype='object', length=300)"""
1623+
expected = (u"Index([u'あ', u'いい', u'ううう', u'あ', u'いい', "
1624+
u"u'ううう', u'あ', u'いい', u'ううう', u'あ',\n"
1625+
u" ...\n"
1626+
u" u'ううう', u'あ', u'いい', u'ううう', u'あ', "
1627+
u"u'いい', u'ううう', u'あ', u'いい', u'ううう'],\n"
1628+
u" dtype='object', length=300)")
16231629

16241630
self.assertEqual(coerce(idx), expected)
16251631

@@ -1629,49 +1635,62 @@ def test_string_index_repr(self):
16291635
# short
16301636
idx = pd.Index([u'あ', u'いい', u'ううう'])
16311637
if PY3:
1632-
expected = u"""Index(['あ', 'いい', 'ううう'], dtype='object')"""
1638+
expected = (u"Index(['あ', 'いい', 'ううう'], "
1639+
u"dtype='object')")
16331640
self.assertEqual(repr(idx), expected)
16341641
else:
1635-
expected = u"""Index([u'あ', u'いい', u'ううう'], dtype='object')"""
1642+
expected = (u"Index([u'あ', u'いい', u'ううう'], "
1643+
u"dtype='object')")
16361644
self.assertEqual(coerce(idx), expected)
16371645

16381646
# multiple lines
16391647
idx = pd.Index([u'あ', u'いい', u'ううう'] * 10)
16401648
if PY3:
1641-
expected = u"""Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
1642-
'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
1643-
'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
1644-
'あ', 'いい', 'ううう'],
1645-
dtype='object')"""
1649+
expected = (u"Index(['あ', 'いい', 'ううう', 'あ', 'いい', "
1650+
u"'ううう', 'あ', 'いい', 'ううう',\n"
1651+
u" 'あ', 'いい', 'ううう', 'あ', 'いい', "
1652+
u"'ううう', 'あ', 'いい', 'ううう',\n"
1653+
u" 'あ', 'いい', 'ううう', 'あ', 'いい', "
1654+
u"'ううう', 'あ', 'いい', 'ううう',\n"
1655+
u" 'あ', 'いい', 'ううう'],\n"
1656+
u" dtype='object')""")
16461657

16471658
self.assertEqual(repr(idx), expected)
16481659
else:
1649-
expected = u"""Index([u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい',
1650-
u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ',
1651-
u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい',
1652-
u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう'],
1653-
dtype='object')"""
1660+
expected = (u"Index([u'あ', u'いい', u'ううう', u'あ', u'いい', "
1661+
u"u'ううう', u'あ', u'いい',\n"
1662+
u" u'ううう', u'あ', u'いい', u'ううう', "
1663+
u"u'あ', u'いい', u'ううう', u'あ',\n"
1664+
u" u'いい', u'ううう', u'あ', u'いい', "
1665+
u"u'ううう', u'あ', u'いい',\n"
1666+
u" u'ううう', u'あ', u'いい', u'ううう', "
1667+
u"u'あ', u'いい', u'ううう'],\n"
1668+
u" dtype='object')")
16541669

16551670
self.assertEqual(coerce(idx), expected)
16561671

16571672
# truncated
16581673
idx = pd.Index([u'あ', u'いい', u'ううう'] * 100)
16591674
if PY3:
1660-
expected = u"""Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
1661-
'あ',
1662-
...
1663-
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
1664-
'ううう'],
1665-
dtype='object', length=300)"""
1675+
expected = (u"Index(['あ', 'いい', 'ううう', 'あ', 'いい', "
1676+
u"'ううう', 'あ', 'いい', 'ううう',\n"
1677+
u" 'あ',\n"
1678+
u" ...\n"
1679+
u" 'ううう', 'あ', 'いい', 'ううう', 'あ', "
1680+
u"'いい', 'ううう', 'あ', 'いい',\n"
1681+
u" 'ううう'],\n"
1682+
u" dtype='object', length=300)")
16661683

16671684
self.assertEqual(repr(idx), expected)
16681685
else:
1669-
expected = u"""Index([u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい',
1670-
u'ううう', u'あ',
1671-
...
1672-
u'ううう', u'あ', u'いい', u'ううう', u'あ', u'いい', u'ううう', u'あ',
1673-
u'いい', u'ううう'],
1674-
dtype='object', length=300)"""
1686+
expected = (u"Index([u'あ', u'いい', u'ううう', u'あ', u'いい', "
1687+
u"u'ううう', u'あ', u'いい',\n"
1688+
u" u'ううう', u'あ',\n"
1689+
u" ...\n"
1690+
u" u'ううう', u'あ', u'いい', u'ううう', "
1691+
u"u'あ', u'いい', u'ううう', u'あ',\n"
1692+
u" u'いい', u'ううう'],\n"
1693+
u" dtype='object', length=300)")
16751694

16761695
self.assertEqual(coerce(idx), expected)
16771696

0 commit comments

Comments
 (0)