Skip to content

CLN: post-post numpy bump #24365

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

Merged
merged 2 commits into from
Dec 22, 2018
Merged
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
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
Copy link
Contributor

@TomAugspurger TomAugspurger Dec 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what section of code this was referring to (I don't immediately see one)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomAugspurger
I don't see something particularly kludge-y either. Also, there is a timedelta scalar nowadays. It just seems like a severely outdated comment.

"""
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 @@ -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)

Expand All @@ -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
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 @@ -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
Expand Down