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 jreback committed Aug 29, 2017
1 parent 0618f99 commit 0d676a3
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 @@ -425,3 +425,4 @@ Categorical
Other
^^^^^
- Bug in :func:`eval` where the ``inplace`` parameter was being incorrectly handled (:issue:`16732`)
- 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 0d676a3

Please sign in to comment.