Skip to content

Commit

Permalink
Fix typo that causes several NaT methods to have incorrect docstrings (
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and alanbato committed Nov 10, 2017
1 parent 867c512 commit 76e46f9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,4 @@ Other
- The ``Series`` constructor with no arguments would have an index like ``Index([], dtype='object')`` instead of ``RangeIndex(start=0, stop=0, step=1)``
- Bug in ``.isin()`` in which checking membership in empty ``Series`` objects raised an error (:issue:`16991`)
- Bug in :func:`unique` where checking a tuple of strings raised a ``TypeError`` (:issue:`17108`)
- Several ``NaT`` method docstrings (e.g. :func:`NaT.ctime`) were incorrect (:issue:`17327`)
7 changes: 4 additions & 3 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# cython: profile=False

import warnings
Expand Down Expand Up @@ -3922,7 +3923,7 @@ for _method_name in _nat_methods:
def f(*args, **kwargs):
return NaT
f.__name__ = func_name
f.__doc__ = _get_docstring(_method_name)
f.__doc__ = _get_docstring(func_name)
return f

setattr(NaTType, _method_name, _make_nat_func(_method_name))
Expand All @@ -3934,7 +3935,7 @@ for _method_name in _nan_methods:
def f(*args, **kwargs):
return np.nan
f.__name__ = func_name
f.__doc__ = _get_docstring(_method_name)
f.__doc__ = _get_docstring(func_name)
return f

setattr(NaTType, _method_name, _make_nan_func(_method_name))
Expand All @@ -3952,7 +3953,7 @@ for _maybe_method_name in dir(NaTType):
def f(*args, **kwargs):
raise ValueError("NaTType does not support " + func_name)
f.__name__ = func_name
f.__doc__ = _get_docstring(_method_name)
f.__doc__ = _get_docstring(func_name)
return f

setattr(NaTType, _maybe_method_name,
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/scalar/test_nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,8 @@ def test_nat_arithmetic_index():
tm.assert_index_equal(right + left, exp)
tm.assert_index_equal(left - right, exp)
tm.assert_index_equal(right - left, exp)


def test_nat_pinned_docstrings():
# GH17327
assert NaT.ctime.__doc__ == datetime.ctime.__doc__

0 comments on commit 76e46f9

Please sign in to comment.