diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 2736133a79d8e..3bc39979b0fc1 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -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) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index a70e245fa1504..219d3cd3ece75 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -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) diff --git a/pandas/tests/arrays/categorical/test_api.py b/pandas/tests/arrays/categorical/test_api.py index 505c2a8eab7cd..348bb947efef7 100644 --- a/pandas/tests/arrays/categorical/test_api.py +++ b/pandas/tests/arrays/categorical/test_api.py @@ -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): diff --git a/pandas/tests/indexes/datetimes/test_misc.py b/pandas/tests/indexes/datetimes/test_misc.py index 8d9f496b70079..cec181161fc11 100644 --- a/pandas/tests/indexes/datetimes/test_misc.py +++ b/pandas/tests/indexes/datetimes/test_misc.py @@ -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) diff --git a/pandas/tests/indexes/timedeltas/test_arithmetic.py b/pandas/tests/indexes/timedeltas/test_arithmetic.py index 82337ac37fbee..75b1e9daff058 100644 --- a/pandas/tests/indexes/timedeltas/test_arithmetic.py +++ b/pandas/tests/indexes/timedeltas/test_arithmetic.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from datetime import timedelta -from distutils.version import LooseVersion import numpy as np import pytest @@ -413,15 +412,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) @@ -433,21 +430,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_timedelta_ops_with_missing_values(self): # setup diff --git a/pandas/tests/util/test_util.py b/pandas/tests/util/test_util.py index e4b2f0a75051a..f6f2d2dcdbdf8 100644 --- a/pandas/tests/util/test_util.py +++ b/pandas/tests/util/test_util.py @@ -25,7 +25,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