Skip to content

Reference Count Testing

Sebastian Berg edited this page Jul 4, 2019 · 8 revisions

(Please update or delete the page when it becomes outdated.)

It is possible to test numpy reference counts using pytest-leaks which as of now (July 2019) runs mostly clean through with NumPy.

To do this you need to:

  1. Have a python debug build available (I use the python3-dbg as provided by debian)
  2. Install pytest-leaks:
  3. Make sure you have an up to date Cython (as of July 2019 the dev version) you may also want to apply https://github.com/cython/cython/pull/3027. Alternatively: Ignore any cython related leaks...
  4. Run git clean -xdf in the numpy directory (make sure not to delete any new work related files)
  5. Apply https://github.com/numpy/numpy/pull/13871 or any test involving object arrays (and sometimes it is hard to see temporary ones) will cause false positives!

You can now run: python3-dbg runtests.py -v -- -R 2:3 (runs each test 2 times for "warm up" and then checks that the reference count does not change for another 3 runs).

The numpy tests in master run cleanly (with the exception of f2py, distutils, and one corner case), so using a debug install of NumPy, the same process can be used to test SciPy.