Skip to content

Commit 9f760e1

Browse files
committed
TST: split some sorting tests
1 parent e725882 commit 9f760e1

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

pandas/tests/test_sorting.py

+14-11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
class TestSorting(tm.TestCase):
2020

21+
@pytest.mark.slow
2122
def test_int64_overflow(self):
2223

2324
B = np.concatenate((np.arange(1000), np.arange(1000), np.arange(500)))
@@ -51,9 +52,11 @@ def test_int64_overflow(self):
5152
expected = df.groupby(tups).sum()['values']
5253

5354
for k, v in compat.iteritems(expected):
54-
self.assertEqual(left[k], right[k[::-1]])
55-
self.assertEqual(left[k], v)
56-
self.assertEqual(len(left), len(right))
55+
assert left[k] == right[k[::-1]]
56+
assert left[k] == v
57+
len(left) == len(right)
58+
59+
def test_int64_overflow_moar(self):
5760

5861
# GH9096
5962
values = range(55109)
@@ -62,7 +65,7 @@ def test_int64_overflow(self):
6265
'c': values,
6366
'd': values})
6467
grouped = data.groupby(['a', 'b', 'c', 'd'])
65-
self.assertEqual(len(grouped), len(values))
68+
assert len(grouped) == len(values)
6669

6770
arr = np.random.randint(-1 << 12, 1 << 12, (1 << 15, 5))
6871
i = np.random.choice(len(arr), len(arr) * 4)
@@ -76,15 +79,15 @@ def test_int64_overflow(self):
7679
gr = df.groupby(list('abcde'))
7780

7881
# verify this is testing what it is supposed to test!
79-
self.assertTrue(is_int64_overflow_possible(gr.grouper.shape))
82+
assert is_int64_overflow_possible(gr.grouper.shape)
8083

8184
# mannually compute groupings
8285
jim, joe = defaultdict(list), defaultdict(list)
8386
for key, a, b in zip(map(tuple, arr), df['jim'], df['joe']):
8487
jim[key].append(a)
8588
joe[key].append(b)
8689

87-
self.assertEqual(len(gr), len(jim))
90+
assert len(gr) == len(jim)
8891
mi = MultiIndex.from_tuples(jim.keys(), names=list('abcde'))
8992

9093
def aggr(func):
@@ -201,7 +204,7 @@ def test_int64_overflow_issues(self):
201204

202205
# it works!
203206
result = merge(df1, df2, how='outer')
204-
self.assertTrue(len(result) == 2000)
207+
assert len(result) == 2000
205208

206209
low, high, n = -1 << 10, 1 << 10, 1 << 20
207210
left = DataFrame(np.random.randint(low, high, (n, 7)),
@@ -216,11 +219,11 @@ def test_int64_overflow_issues(self):
216219
right['right'] *= -1
217220

218221
out = merge(left, right, how='outer')
219-
self.assertEqual(len(out), len(left))
222+
assert len(out) == len(left)
220223
assert_series_equal(out['left'], - out['right'], check_names=False)
221224
result = out.iloc[:, :-2].sum(axis=1)
222225
assert_series_equal(out['left'], result, check_names=False)
223-
self.assertTrue(result.name is None)
226+
assert result.name is None
224227

225228
out.sort_values(out.columns.tolist(), inplace=True)
226229
out.index = np.arange(len(out))
@@ -241,7 +244,7 @@ def test_int64_overflow_issues(self):
241244

242245
# confirm that this is checking what it is supposed to check
243246
shape = left.apply(Series.nunique).values
244-
self.assertTrue(is_int64_overflow_possible(shape))
247+
assert is_int64_overflow_possible(shape)
245248

246249
# add duplicates to left frame
247250
left = concat([left, left], ignore_index=True)
@@ -307,7 +310,7 @@ def verify_order(df):
307310
for how in 'left', 'right', 'outer', 'inner':
308311
mask = jmask[how]
309312
frame = align(out[mask].copy())
310-
self.assertTrue(mask.all() ^ mask.any() or how == 'outer')
313+
assert mask.all() ^ mask.any() or how == 'outer'
311314

312315
for sort in [False, True]:
313316
res = merge(left, right, how=how, sort=sort)

0 commit comments

Comments
 (0)