(self, name, incr)
| 1869 | ('unbound', 0), |
| 1870 | ]) |
| 1871 | def test_frompyfunc_leaks(self, name, incr): |
| 1872 | # exposed in gh-11867 as np.vectorized, but the problem stems from |
| 1873 | # frompyfunc. |
| 1874 | # class.attribute = np.frompyfunc(<method>) creates a |
| 1875 | # reference cycle if <method> is a bound class method. It requires a |
| 1876 | # gc collection cycle to break the cycle (on CPython 3) |
| 1877 | import gc |
| 1878 | A_func = getattr(self.A, name) |
| 1879 | gc.disable() |
| 1880 | try: |
| 1881 | refcount = sys.getrefcount(A_func) |
| 1882 | for i in range(self.A.iters): |
| 1883 | a = self.A() |
| 1884 | a.f = np.frompyfunc(getattr(a, name), 1, 1) |
| 1885 | out = a.f(np.arange(10)) |
| 1886 | a = None |
| 1887 | # A.func is part of a reference cycle if incr is non-zero |
| 1888 | assert_equal(sys.getrefcount(A_func), refcount + incr) |
| 1889 | for i in range(5): |
| 1890 | gc.collect() |
| 1891 | assert_equal(sys.getrefcount(A_func), refcount) |
| 1892 | finally: |
| 1893 | gc.enable() |
| 1894 | |
| 1895 | |
| 1896 | class TestDigitize: |
nothing calls this directly
no test coverage detected