Skip to content

Commit be29fd2

Browse files
committed
Merge pull request #6960 from jreback/warnings
COMPAT: fix numpy 1.9-dev deprecation warnings in test suite
2 parents aaa592b + 3be3444 commit be29fd2

32 files changed

+244
-132
lines changed

ci/script.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ fi
1616
"$TRAVIS_BUILD_DIR"/ci/build_docs.sh 2>&1 > /tmp/doc.log &
1717
# doc build log will be shown after tests
1818

19+
# export the testing mode
20+
if [ -n "$NUMPY_BUILD" ]; then
21+
22+
export PANDAS_TESTING_MODE="numpy_deprecate"
23+
24+
fi
25+
1926
echo nosetests --exe -w /tmp -A "$NOSE_ARGS" pandas --with-xunit --xunit-file=/tmp/nosetests.xml
2027
nosetests --exe -w /tmp -A "$NOSE_ARGS" pandas --with-xunit --xunit-file=/tmp/nosetests.xml
2128

doc/source/release.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ Prior Version Deprecations/Changes
240240
- Remove ``time_rule`` from several rolling-moment statistical functions, such
241241
as :func:`rolling_sum` (:issue:`1042`)
242242

243+
- Removed neg (-) boolean operations on numpy arrays in favor of inv (~), as this is going to
244+
be deprecated in numpy 1.9 (:issue:`6960`)
245+
243246
Experimental Features
244247
~~~~~~~~~~~~~~~~~~~~~
245248

doc/source/v0.14.0.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ There are prior version deprecations that are taking effect as of 0.14.0.
368368
( `commit 3136390 <https://github.com/pydata/pandas/commit/3136390>`__ )
369369
- Remove ``time_rule`` from several rolling-moment statistical functions, such
370370
as :func:`rolling_sum` (:issue:`1042`)
371+
- Removed neg (-) boolean operations on numpy arrays in favor of inv (~), as this is going to
372+
be deprecated in numpy 1.9 (:issue:`6960`)
371373

372374
.. _whatsnew_0140.deprecations:
373375

pandas/algos.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def rank_1d_generic(object in_arr, bint retry=1, ties_method='average',
510510
if not retry:
511511
raise
512512

513-
valid_locs = (-mask).nonzero()[0]
513+
valid_locs = (~mask).nonzero()[0]
514514
ranks.put(valid_locs, rank_1d_generic(values.take(valid_locs), 0,
515515
ties_method=ties_method,
516516
ascending=ascending))

pandas/computation/ops.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ class Term(StringMixin):
4242
def __new__(cls, name, env, side=None, encoding=None):
4343
klass = Constant if not isinstance(name, string_types) else cls
4444
supr_new = super(Term, klass).__new__
45-
if PY3:
46-
return supr_new(klass)
47-
return supr_new(klass, name, env, side=side, encoding=encoding)
45+
return supr_new(klass)
4846

4947
def __init__(self, name, env, side=None, encoding=None):
5048
self._name = name

pandas/computation/pytables.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ class Term(ops.Term):
3333
def __new__(cls, name, env, side=None, encoding=None):
3434
klass = Constant if not isinstance(name, string_types) else cls
3535
supr_new = StringMixin.__new__
36-
if PY3:
37-
return supr_new(klass)
38-
return supr_new(klass, name, env, side=side, encoding=encoding)
36+
return supr_new(klass)
3937

4038
def __init__(self, name, env, side=None, encoding=None):
4139
super(Term, self).__init__(name, env, side=side, encoding=encoding)

pandas/core/algorithms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def quantile(x, q, interpolation_method='fraction'):
329329
x = np.asarray(x)
330330
mask = com.isnull(x)
331331

332-
x = x[-mask]
332+
x = x[~mask]
333333

334334
values = np.sort(x)
335335

@@ -339,7 +339,7 @@ def _get_score(at):
339339

340340
idx = at * (len(values) - 1)
341341
if idx % 1 == 0:
342-
score = values[idx]
342+
score = values[int(idx)]
343343
else:
344344
if interpolation_method == 'fraction':
345345
score = _interpolate(values[int(idx)], values[int(idx) + 1],

pandas/core/common.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def _isnull_ndarraylike_old(obj):
248248
# this is the NaT pattern
249249
result = values.view('i8') == tslib.iNaT
250250
else:
251-
result = -np.isfinite(values)
251+
result = ~np.isfinite(values)
252252

253253
# box
254254
if isinstance(obj, ABCSeries):
@@ -280,12 +280,22 @@ def notnull(obj):
280280
res = isnull(obj)
281281
if np.isscalar(res):
282282
return not res
283-
return -res
283+
return ~res
284284

285285
def _is_null_datelike_scalar(other):
286286
""" test whether the object is a null datelike, e.g. Nat
287287
but guard against passing a non-scalar """
288-
return (np.isscalar(other) and (isnull(other) or other == tslib.iNaT)) or other is pd.NaT or other is None
288+
if other is pd.NaT or other is None:
289+
return True
290+
elif np.isscalar(other):
291+
292+
# a timedelta
293+
if hasattr(other,'dtype'):
294+
return other.view('i8') == tslib.iNaT
295+
elif is_integer(other) and other == tslib.iNaT:
296+
return True
297+
return isnull(other)
298+
return False
289299

290300
def array_equivalent(left, right):
291301
"""
@@ -363,7 +373,7 @@ def mask_missing(arr, values_to_mask):
363373
values_to_mask = np.array(values_to_mask, dtype=object)
364374

365375
na_mask = isnull(values_to_mask)
366-
nonna = values_to_mask[-na_mask]
376+
nonna = values_to_mask[~na_mask]
367377

368378
mask = None
369379
for x in nonna:

pandas/core/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ def _get_format_timedelta64(values):
18611861
def impl(x):
18621862
if x is None or lib.checknull(x):
18631863
return 'NaT'
1864-
elif format_short and x == 0:
1864+
elif format_short and com.is_integer(x) and x.view('int64') == 0:
18651865
return "0 days" if even_days else "00:00:00"
18661866
else:
18671867
return lib.repr_timedelta64(x, format=format)

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3041,7 +3041,7 @@ def update(self, other, join='left', overwrite=True, filter_func=None,
30413041
this = self[col].values
30423042
that = other[col].values
30433043
if filter_func is not None:
3044-
mask = -filter_func(this) | isnull(that)
3044+
mask = ~filter_func(this) | isnull(that)
30453045
else:
30463046
if raise_conflict:
30473047
mask_this = notnull(that)

0 commit comments

Comments
 (0)