Skip to content

Reverse numpy compat changes to tslib.pyx #13246

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 0 additions & 1 deletion doc/source/whatsnew/v0.18.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ API changes


- Non-convertible dates in an excel date column will be returned without conversion and the column will be ``object`` dtype, rather than raising an exception (:issue:`10001`)
- Compat with ``np.round`` and timestamps (:issue:`12811`)
- An ``UnsupportedFunctionCall`` error is now raised if numpy ufuncs like ``np.mean`` are called on groupby or resample objects (:issue:`12811`)

.. _whatsnew_0182.api.tolist:
Expand Down
14 changes: 2 additions & 12 deletions pandas/tseries/tests/test_tslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,14 +1337,11 @@ def test_shift_months(self):
tm.assert_index_equal(actual, expected)

def test_round(self):
# see gh-12811
stamp = Timestamp('2000-01-05 05:09:15.13')

def _check_round(freq, expected):
result = stamp.round(freq=freq)
npResult = np.round(stamp, freq)
self.assertEqual(result, expected)
self.assertEqual(npResult, expected)

for freq, expected in [
('D', Timestamp('2000-01-05 00:00:00')),
Expand All @@ -1353,16 +1350,9 @@ def _check_round(freq, expected):
]:
_check_round(freq, expected)

msg = "the 'out' parameter is not supported"
tm.assertRaisesRegexp(ValueError, msg, np.round,
stamp, 'D', out=[])

# 'freq' is a required parameter, so we cannot
# assign a default should the user accidentally
# assign a 'decimals' input instead
msg = "Could not evaluate"
tm.assertRaisesRegexp(ValueError, msg, np.round,
stamp, 2)
tm.assertRaisesRegexp(ValueError, msg,
stamp.round, 'foo')


class TestTimestampOps(tm.TestCase):
Expand Down
4 changes: 1 addition & 3 deletions pandas/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class Timestamp(_Timestamp):
result = result.tz_localize(self.tz)
return result

def round(self, freq, *args, **kwargs):
def round(self, freq):
"""
Round the Timestamp to the specified resolution

Expand All @@ -403,8 +403,6 @@ class Timestamp(_Timestamp):
------
ValueError if the freq cannot be converted
"""
from pandas.compat.numpy.function import validate_round
validate_round(args, kwargs)
return self._round(freq, np.round)

def floor(self, freq):
Expand Down