scipy / scipy_doctest

Floating-point aware doctesting
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

pytest doctest collection skips C-implemented functions #99

Open ev-br opened 12 months ago

ev-br commented 12 months ago

Figure out why doctests in c-implemented functions (ufuncs in scipy.special, LinearNDInterpolator etc) are not collected by vanilla pytest doctest collection. Maybe it's something to fix on the pytest side? We'll then be able to remove quite a few workarounds.

ev-br commented 12 months ago

Asked a question upstream: https://github.com/pytest-dev/pytest/discussions/11450 @Sheila-nk

ev-br commented 12 months ago

Per response at pytest-dev/pytest#11450, the canonic issue over at pytest-dev is https://github.com/pytest-dev/pytest/issues/11388.

For us, it needs a bit of testing because simply using inspect.isroutine is not enough:

In [42]: from scipy import special as s

In [43]: import numpy as np

In [57]: for obj in [s.erf, np.add, LinearNDInterpolator, LinearNDInterpolator.__call__]:
    ...:     print(obj, inspect.isfunction(obj), inspect.isroutine(obj), inspect.isbuilt
    ...: in(obj), inspect.isclass(obj), isinstance(obj, np.ufunc))
    ...:
<ufunc 'erf'> False False False False True
<ufunc 'add'> False False False False True
<class 'scipy.interpolate.interpnd.LinearNDInterpolator'> False False False True False
<cyfunction NDInterpolatorBase.__call__ at 0x7fa04ee17440> False True False False False

we'll need to check if an object is a routine or a class of a ufunc. Will need testing and checking the log.

EDIT: In fact, there are two separate issues here. One is indeed https://github.com/pytest-dev/pytest/issues/11388; the more immediate is that the .so files are not collected via pytest_collect_file. More details are at pytest-dev/pytest#11450.