Skip to content

COMPAT: 32-bit compat fixes mainly in testing #13584

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,7 @@ def reduction(self, f, axis=0, consolidate=True, transposed=False,
# compute the orderings of our original data
if len(self.blocks) > 1:

indexer = np.empty(len(self.axes[0]), dtype='int64')
indexer = np.empty(len(self.axes[0]), dtype=np.intp)
i = 0
for b in self.blocks:
for j in b.mgr_locs:
Expand Down
7 changes: 4 additions & 3 deletions pandas/tests/indexes/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ def test_get_loc(self):
# time indexing
idx = pd.date_range('2000-01-01', periods=24, freq='H')
tm.assert_numpy_array_equal(idx.get_loc(time(12)),
np.array([12], dtype=np.int64))
np.array([12]), check_dtype=False)
tm.assert_numpy_array_equal(idx.get_loc(time(12, 30)),
np.array([], dtype=np.int64))
np.array([]), check_dtype=False)
with tm.assertRaises(NotImplementedError):
idx.get_loc(time(12, 30), method='pad')

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

tm.assert_numpy_array_equal(ts.index.get_loc(key), i)
tm.assert_numpy_array_equal(ts.index.get_loc(key), i,
check_dtype=False)
tm.assert_series_equal(ts[key], ts.iloc[i])

left, right = ts.copy(), ts.copy()
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/indexes/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1750,12 +1750,12 @@ def test_reindex_level(self):
exp_index2 = self.index.join(idx, level='second', how='left')

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

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

assertRaisesRegexp(TypeError, "Fill method not supported",
self.index.reindex, self.index, method='pad',
Expand Down
24 changes: 14 additions & 10 deletions pandas/tests/series/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def test_kurt(self):
self.assertTrue((df.kurt() == 0).all())

def test_argsort(self):
self._check_accum_op('argsort')
self._check_accum_op('argsort', check_dtype=False)
argsorted = self.ts.argsort()
self.assertTrue(issubclass(argsorted.dtype.type, np.integer))

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

self.assert_series_equal(mindexer, Series(mexpected))
self.assert_series_equal(qindexer, Series(qexpected))
self.assert_series_equal(mindexer, Series(mexpected),
check_dtype=False)
self.assert_series_equal(qindexer, Series(qexpected),
check_dtype=False)
self.assertFalse(np.array_equal(qindexer, mindexer))

def test_cumsum(self):
Expand Down Expand Up @@ -487,10 +489,11 @@ def testit():
except ImportError:
pass

def _check_accum_op(self, name):
def _check_accum_op(self, name, check_dtype=True):
func = getattr(np, name)
self.assert_numpy_array_equal(func(self.ts).values,
func(np.array(self.ts)))
func(np.array(self.ts)),
check_dtype=check_dtype)

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

self.assert_numpy_array_equal(result.values, expected)
self.assert_numpy_array_equal(result.values, expected,
check_dtype=False)

def test_compress(self):
cond = [True, False, True, False, False]
Expand Down Expand Up @@ -1360,13 +1364,13 @@ def test_searchsorted_numeric_dtypes_scalar(self):
self.assertEqual(r, e)

r = s.searchsorted([30])
e = np.array([2], dtype=np.int64)
e = np.array([2], dtype=np.intp)
tm.assert_numpy_array_equal(r, e)

def test_searchsorted_numeric_dtypes_vector(self):
s = Series([1, 2, 90, 1000, 3e9])
r = s.searchsorted([91, 2e6])
e = np.array([3, 4], dtype=np.int64)
e = np.array([3, 4], dtype=np.intp)
tm.assert_numpy_array_equal(r, e)

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

def test_searchsorted_sorter(self):
# GH8490
s = Series([3, 1, 2])
r = s.searchsorted([0, 3], sorter=np.argsort(s))
e = np.array([0, 2], dtype=np.int64)
e = np.array([0, 2], dtype=np.intp)
tm.assert_numpy_array_equal(r, e)

def test_is_unique(self):
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,12 +702,14 @@ def test_unique_label_indices():
left = unique_label_indices(a)
right = np.unique(a, return_index=True)[1]

tm.assert_numpy_array_equal(left, right)
tm.assert_numpy_array_equal(left, right,
check_dtype=False)

a[np.random.choice(len(a), 10)] = -1
left = unique_label_indices(a)
right = np.unique(a, return_index=True)[1][1:]
tm.assert_numpy_array_equal(left, right)
tm.assert_numpy_array_equal(left, right,
check_dtype=False)


def test_rank():
Expand Down
23 changes: 13 additions & 10 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,17 +515,20 @@ def f():
def test_argsort(self):
c = Categorical([5, 3, 1, 4, 2], ordered=True)

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

expected = expected[::-1]
tm.assert_numpy_array_equal(c.argsort(ascending=False), expected)
tm.assert_numpy_array_equal(c.argsort(ascending=False), expected,
check_dtype=False)

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

expected = np.array([2, 4, 1, 3, 0], dtype=np.int64)
tm.assert_numpy_array_equal(np.argsort(c), expected)
expected = np.array([2, 4, 1, 3, 0])
tm.assert_numpy_array_equal(np.argsort(c), expected,
check_dtype=False)

msg = "the 'kind' parameter is not supported"
tm.assertRaisesRegexp(ValueError, msg, np.argsort,
Expand Down Expand Up @@ -1505,7 +1508,7 @@ def test_searchsorted(self):
# Single item array
res = c1.searchsorted(['bread'])
chk = s1.searchsorted(['bread'])
exp = np.array([1], dtype=np.int64)
exp = np.array([1], dtype=np.intp)
self.assert_numpy_array_equal(res, exp)
self.assert_numpy_array_equal(res, chk)

Expand All @@ -1514,21 +1517,21 @@ def test_searchsorted(self):
# np.array.searchsorted()
res = c1.searchsorted('bread')
chk = s1.searchsorted('bread')
exp = np.array([1], dtype=np.int64)
exp = np.array([1], dtype=np.intp)
self.assert_numpy_array_equal(res, exp)
self.assert_numpy_array_equal(res, chk)

# Searching for a value that is not present in the Categorical
res = c1.searchsorted(['bread', 'eggs'])
chk = s1.searchsorted(['bread', 'eggs'])
exp = np.array([1, 4], dtype=np.int64)
exp = np.array([1, 4], dtype=np.intp)
self.assert_numpy_array_equal(res, exp)
self.assert_numpy_array_equal(res, chk)

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

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

Expand Down
16 changes: 8 additions & 8 deletions pandas/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -5934,49 +5934,49 @@ def test_nargsort(self):
result = _nargsort(items, kind='mergesort', ascending=True,
na_position='last')
exp = list(range(5, 105)) + list(range(5)) + list(range(105, 110))
tm.assert_numpy_array_equal(result, np.array(exp, dtype=np.int64))
tm.assert_numpy_array_equal(result, np.array(exp), check_dtype=False)

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

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

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

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

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

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

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

def test_datetime_count(self):
df = DataFrame({'a': [1, 2, 3] * 2,
Expand Down
3 changes: 2 additions & 1 deletion pandas/tools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ def _merger(x, y):
# if we DO have duplicates, then
# we cannot guarantee order

sorter = np.concatenate([groupby.indices[g] for g, _ in groupby])
sorter = com._ensure_platform_int(
np.concatenate([groupby.indices[g] for g, _ in groupby]))
if len(result) != len(sorter):
if check_duplicates:
raise AssertionError("invalid reverse grouping")
Expand Down
12 changes: 6 additions & 6 deletions pandas/tools/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def test_cython_left_outer_join(self):
exp_rs = exp_rs.take(exp_ri)
exp_rs[exp_ri == -1] = -1

self.assert_numpy_array_equal(ls, exp_ls)
self.assert_numpy_array_equal(rs, exp_rs)
self.assert_numpy_array_equal(ls, exp_ls, check_dtype=False)
self.assert_numpy_array_equal(rs, exp_rs, check_dtype=False)

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

self.assert_numpy_array_equal(ls, exp_ls)
self.assert_numpy_array_equal(rs, exp_rs)
self.assert_numpy_array_equal(ls, exp_ls, check_dtype=False)
self.assert_numpy_array_equal(rs, exp_rs, check_dtype=False)

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

self.assert_numpy_array_equal(ls, exp_ls)
self.assert_numpy_array_equal(rs, exp_rs)
self.assert_numpy_array_equal(ls, exp_ls, check_dtype=False)
self.assert_numpy_array_equal(rs, exp_rs, check_dtype=False)

def test_left_outer_join(self):
joined_key2 = merge(self.df, self.df2, on='key2')
Expand Down
5 changes: 3 additions & 2 deletions pandas/tools/tests/test_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class TestCut(tm.TestCase):
def test_simple(self):
data = np.ones(5)
result = cut(data, 4, labels=False)
desired = np.array([1, 1, 1, 1, 1], dtype=np.int64)
tm.assert_numpy_array_equal(result, desired)
desired = np.array([1, 1, 1, 1, 1])
tm.assert_numpy_array_equal(result, desired,
check_dtype=False)

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