Skip to content

BUG: various 32bit compat issues #15766

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 3 commits 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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ Bug Fixes
- Bug in ``pd.qcut()`` with a single quantile and an array with identical values (:issue:`15431`)
- Compat with SciPy 0.19.0 for testing on ``.interpolate()`` (:issue:`15662`)

- Compat for 32-bit platforms for ``.qcut/cut``; bins will now be ``in64`` dtype (:issue:`14866`)

- Bug in the display of ``.info()`` where a qualifier (+) would always be displayed with a ``MultiIndex`` that contains only non-strings (:issue:`15245`)
- Bug in ``.replace()`` may result in incorrect dtypes. (:issue:`12747`, :issue:`15765`)
Expand Down
44 changes: 28 additions & 16 deletions pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,33 +169,45 @@ def isin(comps, values):
raise TypeError("only list-like objects are allowed to be passed"
" to isin(), you passed a "
"[{0}]".format(type(comps).__name__))
comps = np.asarray(comps)
if not is_list_like(values):
raise TypeError("only list-like objects are allowed to be passed"
" to isin(), you passed a "
"[{0}]".format(type(values).__name__))
if not isinstance(values, np.ndarray):
values = list(values)

from pandas import DatetimeIndex, PeriodIndex

if not isinstance(values, (ABCIndex, ABCSeries, np.ndarray)):
values = np.array(list(values), dtype='object')

if needs_i8_conversion(comps):
if is_period_dtype(values):
comps = PeriodIndex(comps)
values = PeriodIndex(values)
else:
comps = DatetimeIndex(comps)
values = DatetimeIndex(values)

values = values.asi8
comps = comps.asi8
elif is_bool_dtype(comps):

try:
comps = np.asarray(comps).view('uint8')
values = np.asarray(values).view('uint8')
except TypeError:
# object array conversion will fail
pass
else:
comps = np.asarray(comps)
values = np.asarray(values)

# GH11232
# work-around for numpy < 1.8 and comparisions on py3
# faster for larger cases to use np.in1d
if (_np_version_under1p8 and compat.PY3) or len(comps) > 1000000:
f = lambda x, y: np.in1d(x, np.asarray(list(y)))
else:
f = lambda x, y: lib.ismember_int64(x, set(y))

# may need i8 conversion for proper membership testing
if is_datetime64_dtype(comps):
from pandas.tseries.tools import to_datetime
values = to_datetime(values)._values.view('i8')
comps = comps.view('i8')
elif is_timedelta64_dtype(comps):
from pandas.tseries.timedeltas import to_timedelta
values = to_timedelta(values)._values.view('i8')
comps = comps.view('i8')
elif is_int64_dtype(comps):
pass
f = lambda x, y: lib.ismember_int64(x, set(y))
else:
f = lambda x, y: lib.ismember(x, set(values))

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ def test_hash_collisions(self):
names=['one', 'two'])
result = index.get_indexer(index.values)
self.assert_numpy_array_equal(result,
np.arange(len(index), dtype='int64'))
np.arange(len(index), dtype='intp'))

for i in [0, 1, len(index) - 2, len(index) - 1]:
result = index.get_loc(index[i])
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/tools/test_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ 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])
tm.assert_numpy_array_equal(result, desired,
expected = np.array([1, 1, 1, 1, 1])
tm.assert_numpy_array_equal(result, expected,
check_dtype=False)

def test_bins(self):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tools/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pandas.types.missing import isnull
from pandas.types.common import (is_float, is_integer,
is_scalar)
is_scalar, _ensure_int64)

from pandas.core.api import Series
from pandas.core.categorical import Categorical
Expand Down Expand Up @@ -215,7 +215,7 @@ def _bins_to_cuts(x, bins, right=True, labels=None,
bins = unique_bins

side = 'left' if right else 'right'
ids = bins.searchsorted(x, side=side)
ids = _ensure_int64(bins.searchsorted(x, side=side))

if include_lowest:
ids[x == bins[0]] = 1
Expand Down