We created a library that uses the massive (with inheritance) numpy MaskedArrays. But I want to run sphinx make doctestwithout testing the inherited methods from numpy, because they make about 100 crashes.
It looks like this:
class _frommethod:
"""
Adapted from numpy.ma._frommethod
"""
def __init__(self, func_name):
self.__name__ = func_name
self.__doc__ = getattr(MaskedArray, func_name).__doc__
self.obj = None
def __get__(self, obj, objtype=None):
self.obj = obj
return self
def __call__(self, a, *args, **params):
method_name = self.__name__
method = getattr(a, method_name, None)
if method is not None:
return method(*args, **params)
method = getattr(MaskedTimeData, method_name, None)
if method is not None:
return method(MaskedTimeData(a), *args, **params)
method = getattr(np, method_name)
And now that our library also supports numpy functions, we use:
min = _frommethod('min')
max = _frommethod('max')
...
If disabled self.__doc__ = getattr(MaskedArray, func_name).__doc__, the failure make doctestwill disappear. But I would like to keep the legacy documentation; so users can still use mylibrary.min?in ipython.
Does anyone know how I can prevent the sphinx from following these โinheritedโ doctrines?
source
share