Skip to content

Commit b624ce0

Browse files
committed
COMPAT: 32-bit compat fixes mainly in testing
closes #13566
1 parent 2655dae commit b624ce0

13 files changed

+104
-82
lines changed

pandas/core/internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3085,7 +3085,7 @@ def reduction(self, f, axis=0, consolidate=True, transposed=False,
30853085
# compute the orderings of our original data
30863086
if len(self.blocks) > 1:
30873087

3088-
indexer = np.empty(len(self.axes[0]), dtype='int64')
3088+
indexer = np.empty(len(self.axes[0]), dtype=np.intp)
30893089
i = 0
30903090
for b in self.blocks:
30913091
for j in b.mgr_locs:

pandas/tests/indexes/test_datetimelike.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,9 @@ def test_get_loc(self):
534534
# time indexing
535535
idx = pd.date_range('2000-01-01', periods=24, freq='H')
536536
tm.assert_numpy_array_equal(idx.get_loc(time(12)),
537-
np.array([12], dtype=np.int64))
537+
np.array([12]), check_dtype=False)
538538
tm.assert_numpy_array_equal(idx.get_loc(time(12, 30)),
539-
np.array([], dtype=np.int64))
539+
np.array([]), check_dtype=False)
540540
with tm.assertRaises(NotImplementedError):
541541
idx.get_loc(time(12, 30), method='pad')
542542

@@ -587,7 +587,8 @@ def test_time_loc(self): # GH8667
587587
ts = pd.Series(np.random.randn(n), index=idx)
588588
i = np.arange(start, n, step)
589589

590-
tm.assert_numpy_array_equal(ts.index.get_loc(key), i)
590+
tm.assert_numpy_array_equal(ts.index.get_loc(key), i,
591+
check_dtype=False)
591592
tm.assert_series_equal(ts[key], ts.iloc[i])
592593

593594
left, right = ts.copy(), ts.copy()

pandas/tests/indexes/test_multi.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1750,12 +1750,12 @@ def test_reindex_level(self):
17501750
exp_index2 = self.index.join(idx, level='second', how='left')
17511751

17521752
self.assertTrue(target.equals(exp_index))
1753-
exp_indexer = np.array([0, 2, 4], dtype=np.int64)
1754-
tm.assert_numpy_array_equal(indexer, exp_indexer)
1753+
exp_indexer = np.array([0, 2, 4])
1754+
tm.assert_numpy_array_equal(indexer, exp_indexer, check_dtype=False)
17551755

17561756
self.assertTrue(target2.equals(exp_index2))
1757-
exp_indexer2 = np.array([0, -1, 0, -1, 0, -1], dtype=np.int64)
1758-
tm.assert_numpy_array_equal(indexer2, exp_indexer2)
1757+
exp_indexer2 = np.array([0, -1, 0, -1, 0, -1])
1758+
tm.assert_numpy_array_equal(indexer2, exp_indexer2, check_dtype=False)
17591759

17601760
assertRaisesRegexp(TypeError, "Fill method not supported",
17611761
self.index.reindex, self.index, method='pad',

pandas/tests/series/test_analytics.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def test_kurt(self):
262262
self.assertTrue((df.kurt() == 0).all())
263263

264264
def test_argsort(self):
265-
self._check_accum_op('argsort')
265+
self._check_accum_op('argsort', check_dtype=False)
266266
argsorted = self.ts.argsort()
267267
self.assertTrue(issubclass(argsorted.dtype.type, np.integer))
268268

@@ -289,8 +289,10 @@ def test_argsort_stable(self):
289289
mexpected = np.argsort(s.values, kind='mergesort')
290290
qexpected = np.argsort(s.values, kind='quicksort')
291291

292-
self.assert_series_equal(mindexer, Series(mexpected))
293-
self.assert_series_equal(qindexer, Series(qexpected))
292+
self.assert_series_equal(mindexer, Series(mexpected),
293+
check_dtype=False)
294+
self.assert_series_equal(qindexer, Series(qexpected),
295+
check_dtype=False)
294296
self.assertFalse(np.array_equal(qindexer, mindexer))
295297

296298
def test_cumsum(self):
@@ -487,10 +489,11 @@ def testit():
487489
except ImportError:
488490
pass
489491

490-
def _check_accum_op(self, name):
492+
def _check_accum_op(self, name, check_dtype=True):
491493
func = getattr(np, name)
492494
self.assert_numpy_array_equal(func(self.ts).values,
493-
func(np.array(self.ts)))
495+
func(np.array(self.ts)),
496+
check_dtype=check_dtype)
494497

495498
# with missing values
496499
ts = self.ts.copy()
@@ -499,7 +502,8 @@ def _check_accum_op(self, name):
499502
result = func(ts)[1::2]
500503
expected = func(np.array(ts.valid()))
501504

502-
self.assert_numpy_array_equal(result.values, expected)
505+
self.assert_numpy_array_equal(result.values, expected,
506+
check_dtype=False)
503507

504508
def test_compress(self):
505509
cond = [True, False, True, False, False]
@@ -1360,13 +1364,13 @@ def test_searchsorted_numeric_dtypes_scalar(self):
13601364
self.assertEqual(r, e)
13611365

13621366
r = s.searchsorted([30])
1363-
e = np.array([2], dtype=np.int64)
1367+
e = np.array([2], dtype=np.intp)
13641368
tm.assert_numpy_array_equal(r, e)
13651369

13661370
def test_searchsorted_numeric_dtypes_vector(self):
13671371
s = Series([1, 2, 90, 1000, 3e9])
13681372
r = s.searchsorted([91, 2e6])
1369-
e = np.array([3, 4], dtype=np.int64)
1373+
e = np.array([3, 4], dtype=np.intp)
13701374
tm.assert_numpy_array_equal(r, e)
13711375

13721376
def test_search_sorted_datetime64_scalar(self):
@@ -1380,14 +1384,14 @@ def test_search_sorted_datetime64_list(self):
13801384
s = Series(pd.date_range('20120101', periods=10, freq='2D'))
13811385
v = [pd.Timestamp('20120102'), pd.Timestamp('20120104')]
13821386
r = s.searchsorted(v)
1383-
e = np.array([1, 2], dtype=np.int64)
1387+
e = np.array([1, 2], dtype=np.intp)
13841388
tm.assert_numpy_array_equal(r, e)
13851389

13861390
def test_searchsorted_sorter(self):
13871391
# GH8490
13881392
s = Series([3, 1, 2])
13891393
r = s.searchsorted([0, 3], sorter=np.argsort(s))
1390-
e = np.array([0, 2], dtype=np.int64)
1394+
e = np.array([0, 2], dtype=np.intp)
13911395
tm.assert_numpy_array_equal(r, e)
13921396

13931397
def test_is_unique(self):

pandas/tests/test_algos.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,14 @@ def test_unique_label_indices():
702702
left = unique_label_indices(a)
703703
right = np.unique(a, return_index=True)[1]
704704

705-
tm.assert_numpy_array_equal(left, right)
705+
tm.assert_numpy_array_equal(left, right,
706+
check_dtype=False)
706707

707708
a[np.random.choice(len(a), 10)] = -1
708709
left = unique_label_indices(a)
709710
right = np.unique(a, return_index=True)[1][1:]
710-
tm.assert_numpy_array_equal(left, right)
711+
tm.assert_numpy_array_equal(left, right,
712+
check_dtype=False)
711713

712714

713715
def test_rank():

pandas/tests/test_categorical.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,20 @@ def f():
515515
def test_argsort(self):
516516
c = Categorical([5, 3, 1, 4, 2], ordered=True)
517517

518-
expected = np.array([2, 4, 1, 3, 0], dtype=np.int64)
519-
tm.assert_numpy_array_equal(c.argsort(ascending=True), expected)
518+
expected = np.array([2, 4, 1, 3, 0])
519+
tm.assert_numpy_array_equal(c.argsort(ascending=True), expected,
520+
check_dtype=False)
520521

521522
expected = expected[::-1]
522-
tm.assert_numpy_array_equal(c.argsort(ascending=False), expected)
523+
tm.assert_numpy_array_equal(c.argsort(ascending=False), expected,
524+
check_dtype=False)
523525

524526
def test_numpy_argsort(self):
525527
c = Categorical([5, 3, 1, 4, 2], ordered=True)
526528

527-
expected = np.array([2, 4, 1, 3, 0], dtype=np.int64)
528-
tm.assert_numpy_array_equal(np.argsort(c), expected)
529+
expected = np.array([2, 4, 1, 3, 0])
530+
tm.assert_numpy_array_equal(np.argsort(c), expected,
531+
check_dtype=False)
529532

530533
msg = "the 'kind' parameter is not supported"
531534
tm.assertRaisesRegexp(ValueError, msg, np.argsort,
@@ -1505,7 +1508,7 @@ def test_searchsorted(self):
15051508
# Single item array
15061509
res = c1.searchsorted(['bread'])
15071510
chk = s1.searchsorted(['bread'])
1508-
exp = np.array([1], dtype=np.int64)
1511+
exp = np.array([1], dtype=np.intp)
15091512
self.assert_numpy_array_equal(res, exp)
15101513
self.assert_numpy_array_equal(res, chk)
15111514

@@ -1514,21 +1517,21 @@ def test_searchsorted(self):
15141517
# np.array.searchsorted()
15151518
res = c1.searchsorted('bread')
15161519
chk = s1.searchsorted('bread')
1517-
exp = np.array([1], dtype=np.int64)
1520+
exp = np.array([1], dtype=np.intp)
15181521
self.assert_numpy_array_equal(res, exp)
15191522
self.assert_numpy_array_equal(res, chk)
15201523

15211524
# Searching for a value that is not present in the Categorical
15221525
res = c1.searchsorted(['bread', 'eggs'])
15231526
chk = s1.searchsorted(['bread', 'eggs'])
1524-
exp = np.array([1, 4], dtype=np.int64)
1527+
exp = np.array([1, 4], dtype=np.intp)
15251528
self.assert_numpy_array_equal(res, exp)
15261529
self.assert_numpy_array_equal(res, chk)
15271530

15281531
# Searching for a value that is not present, to the right
15291532
res = c1.searchsorted(['bread', 'eggs'], side='right')
15301533
chk = s1.searchsorted(['bread', 'eggs'], side='right')
1531-
exp = np.array([3, 4], dtype=np.int64) # eggs before milk
1534+
exp = np.array([3, 4], dtype=np.intp) # eggs before milk
15321535
self.assert_numpy_array_equal(res, exp)
15331536
self.assert_numpy_array_equal(res, chk)
15341537

@@ -1538,7 +1541,7 @@ def test_searchsorted(self):
15381541
chk = s2.searchsorted(['bread', 'eggs'], side='right',
15391542
sorter=[0, 1, 2, 3, 5, 4])
15401543
# eggs after donuts, after switching milk and donuts
1541-
exp = np.array([3, 5], dtype=np.int64)
1544+
exp = np.array([3, 5], dtype=np.intp)
15421545
self.assert_numpy_array_equal(res, exp)
15431546
self.assert_numpy_array_equal(res, chk)
15441547

pandas/tests/test_groupby.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -5934,49 +5934,49 @@ def test_nargsort(self):
59345934
result = _nargsort(items, kind='mergesort', ascending=True,
59355935
na_position='last')
59365936
exp = list(range(5, 105)) + list(range(5)) + list(range(105, 110))
5937-
tm.assert_numpy_array_equal(result, np.array(exp, dtype=np.int64))
5937+
tm.assert_numpy_array_equal(result, np.array(exp), check_dtype=False)
59385938

59395939
# mergesort, ascending=True, na_position='first'
59405940
result = _nargsort(items, kind='mergesort', ascending=True,
59415941
na_position='first')
59425942
exp = list(range(5)) + list(range(105, 110)) + list(range(5, 105))
5943-
tm.assert_numpy_array_equal(result, np.array(exp, dtype=np.int64))
5943+
tm.assert_numpy_array_equal(result, np.array(exp), check_dtype=False)
59445944

59455945
# mergesort, ascending=False, na_position='last'
59465946
result = _nargsort(items, kind='mergesort', ascending=False,
59475947
na_position='last')
59485948
exp = list(range(104, 4, -1)) + list(range(5)) + list(range(105, 110))
5949-
tm.assert_numpy_array_equal(result, np.array(exp, dtype=np.int64))
5949+
tm.assert_numpy_array_equal(result, np.array(exp), check_dtype=False)
59505950

59515951
# mergesort, ascending=False, na_position='first'
59525952
result = _nargsort(items, kind='mergesort', ascending=False,
59535953
na_position='first')
59545954
exp = list(range(5)) + list(range(105, 110)) + list(range(104, 4, -1))
5955-
tm.assert_numpy_array_equal(result, np.array(exp, dtype=np.int64))
5955+
tm.assert_numpy_array_equal(result, np.array(exp), check_dtype=False)
59565956

59575957
# mergesort, ascending=True, na_position='last'
59585958
result = _nargsort(items2, kind='mergesort', ascending=True,
59595959
na_position='last')
59605960
exp = list(range(5, 105)) + list(range(5)) + list(range(105, 110))
5961-
tm.assert_numpy_array_equal(result, np.array(exp, dtype=np.int64))
5961+
tm.assert_numpy_array_equal(result, np.array(exp), check_dtype=False)
59625962

59635963
# mergesort, ascending=True, na_position='first'
59645964
result = _nargsort(items2, kind='mergesort', ascending=True,
59655965
na_position='first')
59665966
exp = list(range(5)) + list(range(105, 110)) + list(range(5, 105))
5967-
tm.assert_numpy_array_equal(result, np.array(exp, dtype=np.int64))
5967+
tm.assert_numpy_array_equal(result, np.array(exp), check_dtype=False)
59685968

59695969
# mergesort, ascending=False, na_position='last'
59705970
result = _nargsort(items2, kind='mergesort', ascending=False,
59715971
na_position='last')
59725972
exp = list(range(104, 4, -1)) + list(range(5)) + list(range(105, 110))
5973-
tm.assert_numpy_array_equal(result, np.array(exp, dtype=np.int64))
5973+
tm.assert_numpy_array_equal(result, np.array(exp), check_dtype=False)
59745974

59755975
# mergesort, ascending=False, na_position='first'
59765976
result = _nargsort(items2, kind='mergesort', ascending=False,
59775977
na_position='first')
59785978
exp = list(range(5)) + list(range(105, 110)) + list(range(104, 4, -1))
5979-
tm.assert_numpy_array_equal(result, np.array(exp, dtype=np.int64))
5979+
tm.assert_numpy_array_equal(result, np.array(exp), check_dtype=False)
59805980

59815981
def test_datetime_count(self):
59825982
df = DataFrame({'a': [1, 2, 3] * 2,

pandas/tools/merge.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ def _merger(x, y):
436436
# if we DO have duplicates, then
437437
# we cannot guarantee order
438438

439-
sorter = np.concatenate([groupby.indices[g] for g, _ in groupby])
439+
sorter = com._ensure_platform_int(
440+
np.concatenate([groupby.indices[g] for g, _ in groupby]))
440441
if len(result) != len(sorter):
441442
if check_duplicates:
442443
raise AssertionError("invalid reverse grouping")

pandas/tools/tests/test_merge.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def test_cython_left_outer_join(self):
9191
exp_rs = exp_rs.take(exp_ri)
9292
exp_rs[exp_ri == -1] = -1
9393

94-
self.assert_numpy_array_equal(ls, exp_ls)
95-
self.assert_numpy_array_equal(rs, exp_rs)
94+
self.assert_numpy_array_equal(ls, exp_ls, check_dtype=False)
95+
self.assert_numpy_array_equal(rs, exp_rs, check_dtype=False)
9696

9797
def test_cython_right_outer_join(self):
9898
left = a_([0, 1, 2, 1, 2, 0, 0, 1, 2, 3, 3], dtype=np.int64)
@@ -117,8 +117,8 @@ def test_cython_right_outer_join(self):
117117
exp_rs = exp_rs.take(exp_ri)
118118
exp_rs[exp_ri == -1] = -1
119119

120-
self.assert_numpy_array_equal(ls, exp_ls)
121-
self.assert_numpy_array_equal(rs, exp_rs)
120+
self.assert_numpy_array_equal(ls, exp_ls, check_dtype=False)
121+
self.assert_numpy_array_equal(rs, exp_rs, check_dtype=False)
122122

123123
def test_cython_inner_join(self):
124124
left = a_([0, 1, 2, 1, 2, 0, 0, 1, 2, 3, 3], dtype=np.int64)
@@ -141,8 +141,8 @@ def test_cython_inner_join(self):
141141
exp_rs = exp_rs.take(exp_ri)
142142
exp_rs[exp_ri == -1] = -1
143143

144-
self.assert_numpy_array_equal(ls, exp_ls)
145-
self.assert_numpy_array_equal(rs, exp_rs)
144+
self.assert_numpy_array_equal(ls, exp_ls, check_dtype=False)
145+
self.assert_numpy_array_equal(rs, exp_rs, check_dtype=False)
146146

147147
def test_left_outer_join(self):
148148
joined_key2 = merge(self.df, self.df2, on='key2')

pandas/tools/tests/test_tile.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ class TestCut(tm.TestCase):
1919
def test_simple(self):
2020
data = np.ones(5)
2121
result = cut(data, 4, labels=False)
22-
desired = np.array([1, 1, 1, 1, 1], dtype=np.int64)
23-
tm.assert_numpy_array_equal(result, desired)
22+
desired = np.array([1, 1, 1, 1, 1])
23+
tm.assert_numpy_array_equal(result, desired,
24+
check_dtype=False)
2425

2526
def test_bins(self):
2627
data = np.array([.2, 1.4, 2.5, 6.2, 9.7, 2.1])

0 commit comments

Comments
 (0)