Skip to content

Commit

Permalink
CLN: post-post numpy bump (pandas-dev#24365)
Browse files Browse the repository at this point in the history
* CLN: post-post numpy bumpy

* Lint
  • Loading branch information
h-vetinari authored and Pingviinituutti committed Feb 28, 2019
1 parent e2e12eb commit b85f044
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 22 deletions.
8 changes: 4 additions & 4 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ def is_scalar(val: object) -> bool:
"""

return (cnp.PyArray_IsAnyScalar(val)
# As of numpy-1.9, PyArray_IsAnyScalar misses bytearrays on Py3.
or isinstance(val, (bytes, Fraction, Number))
# We differ from numpy (as of 1.10), which claims that None is
# not scalar in np.isscalar().
# PyArray_IsAnyScalar is always False for bytearrays on Py3
or isinstance(val, (Fraction, Number))
# We differ from numpy, which claims that None is not scalar;
# see np.isscalar
or val is None
or PyDate_Check(val)
or PyDelta_Check(val)
Expand Down
3 changes: 0 additions & 3 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ cpdef convert_to_timedelta64(object ts, object unit):
- None/NaT
Return an ns based int64
# kludgy here until we have a timedelta scalar
# handle the numpy < 1.7 case
"""
if checknull_with_nat(ts):
return np.timedelta64(NPY_NAT)
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/arrays/categorical/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ def test_codes_immutable(self):
c.codes = np.array([0, 1, 2, 0, 1], dtype='int8')

# changes in the codes array should raise
# np 1.6.1 raises RuntimeError rather than ValueError
codes = c.codes

with pytest.raises(ValueError):
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/indexes/datetimes/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def test_datetimeindex_accessors(self):
assert sum(dti.is_year_end) == 1

# Ensure is_start/end accessors throw ValueError for CustomBusinessDay,
# CBD requires np >= 1.7
bday_egypt = offsets.CustomBusinessDay(weekmask='Sun Mon Tue Wed Thu')
dti = date_range(datetime(2013, 4, 30), periods=5, freq=bday_egypt)
pytest.raises(ValueError, lambda: dti.is_month_start)
Expand Down
18 changes: 6 additions & 12 deletions pandas/tests/indexes/timedeltas/test_arithmetic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

from datetime import timedelta
from distutils.version import LooseVersion

import numpy as np
import pytest
Expand Down Expand Up @@ -197,15 +196,13 @@ def test_ops_ndarray(self):
other = pd.to_timedelta(['1 day']).values
expected = pd.to_timedelta(['2 days']).values
tm.assert_numpy_array_equal(td + other, expected)
if LooseVersion(np.__version__) >= LooseVersion('1.8'):
tm.assert_numpy_array_equal(other + td, expected)
tm.assert_numpy_array_equal(other + td, expected)
pytest.raises(TypeError, lambda: td + np.array([1]))
pytest.raises(TypeError, lambda: np.array([1]) + td)

expected = pd.to_timedelta(['0 days']).values
tm.assert_numpy_array_equal(td - other, expected)
if LooseVersion(np.__version__) >= LooseVersion('1.8'):
tm.assert_numpy_array_equal(-other + td, expected)
tm.assert_numpy_array_equal(-other + td, expected)
pytest.raises(TypeError, lambda: td - np.array([1]))
pytest.raises(TypeError, lambda: np.array([1]) - td)

Expand All @@ -217,21 +214,18 @@ def test_ops_ndarray(self):

tm.assert_numpy_array_equal(td / other,
np.array([1], dtype=np.float64))
if LooseVersion(np.__version__) >= LooseVersion('1.8'):
tm.assert_numpy_array_equal(other / td,
np.array([1], dtype=np.float64))
tm.assert_numpy_array_equal(other / td,
np.array([1], dtype=np.float64))

# timedelta, datetime
other = pd.to_datetime(['2000-01-01']).values
expected = pd.to_datetime(['2000-01-02']).values
tm.assert_numpy_array_equal(td + other, expected)
if LooseVersion(np.__version__) >= LooseVersion('1.8'):
tm.assert_numpy_array_equal(other + td, expected)
tm.assert_numpy_array_equal(other + td, expected)

expected = pd.to_datetime(['1999-12-31']).values
tm.assert_numpy_array_equal(-td + other, expected)
if LooseVersion(np.__version__) >= LooseVersion('1.8'):
tm.assert_numpy_array_equal(other - td, expected)
tm.assert_numpy_array_equal(other - td, expected)

def test_tdi_ops_attributes(self):
rng = timedelta_range('2 days', periods=5, freq='2D', name='x')
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/util/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def test_rands_array_2d():


def test_numpy_err_state_is_default():
# The defaults since numpy 1.6.0
expected = {"over": "warn", "divide": "warn",
"invalid": "warn", "under": "ignore"}
import numpy as np
Expand Down

0 comments on commit b85f044

Please sign in to comment.