Similar to NumPy, pandas has modified the __module__ attribute of various
objects to point to their public location rather than where they are
defined in the code. Somewhat recently, we realized that this has silently
prevented many of our doctests from running. This is due to the __module__
of the class no longer agreeing with the __module__ of the methods on said
class. When this occurs, CPython skips running the doctest on the method
due to this check:

https://github.com/python/cpython/blob/9bf5100037f661f3a369d3ee539bec06f063b650/Lib/doctest.py#L1069-L1072

since `self._from_module(module, val))` results in False. In pandas, we've
hacked our way around this check here:

https://github.com/pandas-dev/pandas/blob/91514c363604506f447e53380d3aa00520f1037b/pandas/conftest.py#L122-L131

I've spot-checked a few of the doctest from a recent PR in NumPy, and from
what I can tell NumPy is _not_ impacted by this. It seems to me that on
classes where the __module__ is being modified, the doctests are still
running. However I have not been able to tell why this is, so I am sending
this only out of caution in case I've missed something.

Best,
Richard
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]

Reply via email to