scipy / scipy_doctest

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

ModuleNotFoundError: cupy, torch, sympy #94

Open Sheila-nk opened 10 months ago

Sheila-nk commented 10 months ago

Pytest collection fails on an attempt at importing cupy and pytorch for _lib/array_api_compat and sympy for _interpnd_info.py.

To reproduce on the Scipy shell:

pytest --doctest-modules build-install/lib/python3.11/site-packages/scipy -v
ERROR build-install/lib/python3.11/site-packages/scipy/_lib/array_api_compat/array_api_compat/cupy/__init__.py - ModuleNotFoundError: No module named 'cupy'
ERROR build-install/lib/python3.11/site-packages/scipy/_lib/array_api_compat/array_api_compat/cupy/_aliases.py - ModuleNotFoundError: No module named 'cupy'
ERROR build-install/lib/python3.11/site-packages/scipy/_lib/array_api_compat/array_api_compat/cupy/_typing.py - ModuleNotFoundError: No module named 'cupy'
ERROR build-install/lib/python3.11/site-packages/scipy/_lib/array_api_compat/array_api_compat/cupy/linalg.py - ModuleNotFoundError: No module named 'cupy'
ERROR build-install/lib/python3.11/site-packages/scipy/_lib/array_api_compat/array_api_compat/torch/__init__.py - ModuleNotFoundError: No module named 'torch'
ERROR build-install/lib/python3.11/site-packages/scipy/_lib/array_api_compat/array_api_compat/torch/_aliases.py - ModuleNotFoundError: No module named 'torch'
ERROR build-install/lib/python3.11/site-packages/scipy/_lib/array_api_compat/array_api_compat/torch/linalg.py - ModuleNotFoundError: No module named 'torch'
ERROR build-install/lib/python3.11/site-packages/scipy/interpolate/_interpnd_info.py - ModuleNotFoundError: No module named 'sympy'

The current solution is to exclude _lib/array_api_compat and _interpnd_info.py from doctesting:

pytest --doctest-modules build-install/lib/python3.11/site-packages/scipy -v --ignore=build-install/lib/python3.11/site-packages/scipy/_lib/array_api_compat --ignore=build-install/lib/python3.11/site-packages/scipy/interpolate/_interpnd_info.py
ev-br commented 4 months ago

This is a problem for testing installed scipy: pytest --pyargs scipy fails collection. For dev installs, we can add explicit ignores indeed. Otherwise, we probably want to invent a way to add a way to blacklist modules and to skip collection of things which try to import blacklisted things.