Skip to content

Commit 6f11ca6

Browse files
h-vetinariPingviinituutti
authored andcommitted
CLN/DEPS: Clean up post numpy bump to 1.12 (pandas-dev#23796)
1 parent 0496bc2 commit 6f11ca6

35 files changed

+40
-191
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pip install pandas
171171
```
172172

173173
## Dependencies
174-
- [NumPy](https://www.numpy.org): 1.9.0 or higher
174+
- [NumPy](https://www.numpy.org): 1.12.0 or higher
175175
- [python-dateutil](https://labix.org/python-dateutil): 2.5.0 or higher
176176
- [pytz](https://pythonhosted.org/pytz): 2011k or higher
177177

ci/azure/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
maxParallel: 11
1111
matrix:
12-
py27_np_19:
12+
py27_np_120:
1313
ENV_FILE: ci/deps/azure-27-compat.yaml
1414
CONDA_PY: "27"
1515
TEST_ARGS: "--skip-slow --skip-network"

pandas/_libs/algos_rank_helper.pxi.in

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,7 @@ def rank_1d_{{dtype}}(object in_arr, ties_method='average',
102102
ranks = np.empty(n, dtype='f8')
103103

104104
{{if dtype == 'object'}}
105-
106-
try:
107-
_as = np.lexsort(keys=order)
108-
except TypeError:
109-
# lexsort on object array will raise TypeError for numpy version
110-
# earlier than 1.11.0. Use argsort with order argument instead.
111-
_dt = [('values', 'O'), ('mask', '?')]
112-
_values = np.asarray(list(zip(order[0], order[1])), dtype=_dt)
113-
_as = np.argsort(_values, kind='mergesort', order=('mask', 'values'))
105+
_as = np.lexsort(keys=order)
114106
{{else}}
115107
if tiebreak == TIEBREAK_FIRST:
116108
# need to use a stable sort here

pandas/_libs/lib.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,7 @@ def astype_intsafe(ndarray[object] arr, new_dtype):
518518
bint is_datelike
519519
ndarray result
520520

521-
# on 32-bit, 1.6.2 numpy M8[ns] is a subdtype of integer, which is weird
522-
is_datelike = new_dtype in ['M8[ns]', 'm8[ns]']
523-
521+
is_datelike = new_dtype == 'm8[ns]'
524522
result = np.empty(n, dtype=new_dtype)
525523
for i in range(n):
526524
val = arr[i]

pandas/_libs/sparse.pyx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ from numpy cimport (ndarray, uint8_t, int64_t, int32_t, int16_t, int8_t,
88
cnp.import_array()
99

1010

11-
from distutils.version import LooseVersion
12-
13-
# numpy versioning
14-
_np_version = np.version.short_version
15-
_np_version_under1p10 = LooseVersion(_np_version) < LooseVersion('1.10')
16-
_np_version_under1p11 = LooseVersion(_np_version) < LooseVersion('1.11')
17-
18-
1911
# -----------------------------------------------------------------------------
2012
# Preamble stuff
2113

pandas/_libs/sparse_op_helper.pxi.in

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ cdef inline sparse_t __mod__(sparse_t a, sparse_t b):
4242
cdef inline sparse_t __floordiv__(sparse_t a, sparse_t b):
4343
if b == 0:
4444
if sparse_t is float64_t:
45-
# numpy >= 1.11 returns NaN
46-
# for a // 0, rather than +-inf
47-
if _np_version_under1p11:
48-
if a > 0:
49-
return INF
50-
elif a < 0:
51-
return -INF
5245
return NaN
5346
else:
5447
return 0

pandas/core/arrays/categorical.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def f(self, other):
9898
ret[na_mask] = False
9999
return ret
100100

101-
# Numpy-1.9 and earlier may convert a scalar to a zerodim array during
101+
# Numpy < 1.13 may convert a scalar to a zerodim array during
102102
# comparison operation when second arg has higher priority, e.g.
103103
#
104104
# cat[0] < cat
@@ -2038,15 +2038,7 @@ def __setitem__(self, key, value):
20382038
elif isinstance(key, slice):
20392039
pass
20402040

2041-
# Array of True/False in Series or Categorical
2042-
else:
2043-
# There is a bug in numpy, which does not accept a Series as a
2044-
# indexer
2045-
# https://github.com/pandas-dev/pandas/issues/6168
2046-
# https://github.com/numpy/numpy/issues/4240 -> fixed in numpy 1.9
2047-
# FIXME: remove when numpy 1.9 is the lowest numpy version pandas
2048-
# accepts...
2049-
key = np.asarray(key)
2041+
# else: array of True/False in Series or Categorical
20502042

20512043
lindexer = self.categories.get_indexer(rvalue)
20522044
lindexer = self._maybe_coerce_indexer(lindexer)

pandas/core/arrays/datetimelike.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,7 @@ def __isub__(self, other):
835835
def _evaluate_compare(self, other, op):
836836
"""
837837
We have been called because a comparison between
838-
8 aware arrays. numpy >= 1.11 will
839-
now warn about NaT comparisons
838+
8 aware arrays. numpy will warn about NaT comparisons
840839
"""
841840
# Called by comparison methods when comparing datetimelike
842841
# with datetimelike

pandas/core/arrays/sparse.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,9 +1015,6 @@ def __getitem__(self, key):
10151015
key = np.asarray(key)
10161016

10171017
if com.is_bool_indexer(key) and len(self) == len(key):
1018-
# TODO(numpy 1.11): Remove this asarray.
1019-
# Old NumPy didn't treat array-like as boolean masks.
1020-
key = np.asarray(key)
10211018
return self.take(np.arange(len(key), dtype=np.int32)[key])
10221019
elif hasattr(key, '__len__'):
10231020
return self.take(key)

pandas/core/dtypes/cast.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -263,28 +263,10 @@ def maybe_promote(dtype, fill_value=np.nan):
263263
fill_value = np.nan
264264

265265
# returns tuple of (dtype, fill_value)
266-
if issubclass(dtype.type, (np.datetime64, np.timedelta64)):
267-
# for now: refuse to upcast datetime64
268-
# (this is because datetime64 will not implicitly upconvert
269-
# to object correctly as of numpy 1.6.1)
270-
if isna(fill_value):
271-
fill_value = iNaT
272-
else:
273-
if issubclass(dtype.type, np.datetime64):
274-
try:
275-
fill_value = tslibs.Timestamp(fill_value).value
276-
except Exception:
277-
# the proper thing to do here would probably be to upcast
278-
# to object (but numpy 1.6.1 doesn't do this properly)
279-
fill_value = iNaT
280-
elif issubclass(dtype.type, np.timedelta64):
281-
try:
282-
fill_value = tslibs.Timedelta(fill_value).value
283-
except Exception:
284-
# as for datetimes, cannot upcast to object
285-
fill_value = iNaT
286-
else:
287-
fill_value = iNaT
266+
if issubclass(dtype.type, np.datetime64):
267+
fill_value = tslibs.Timestamp(fill_value).value
268+
elif issubclass(dtype.type, np.timedelta64):
269+
fill_value = tslibs.Timedelta(fill_value).value
288270
elif is_datetimetz(dtype):
289271
if isna(fill_value):
290272
fill_value = iNaT

0 commit comments

Comments
 (0)