(self, name, incr)
| 2126 | ) |
| 2127 | @pytest.mark.slow |
| 2128 | def test_frompyfunc_leaks(self, name, incr): |
| 2129 | # exposed in gh-11867 as np.vectorized, but the problem stems from |
| 2130 | # frompyfunc. |
| 2131 | # class.attribute = np.frompyfunc(<method>) creates a |
| 2132 | # reference cycle if <method> is a bound class method. |
| 2133 | # It requires a gc collection cycle to break the cycle. |
| 2134 | import gc |
| 2135 | A_func = getattr(self.A, name) |
| 2136 | gc.disable() |
| 2137 | try: |
| 2138 | refcount = sys.getrefcount(A_func) |
| 2139 | for i in range(self.A.iters): |
| 2140 | a = self.A() |
| 2141 | a.f = np.frompyfunc(getattr(a, name), 1, 1) |
| 2142 | out = a.f(np.arange(10)) |
| 2143 | a = None |
| 2144 | # A.func is part of a reference cycle if incr is non-zero |
| 2145 | assert_equal(sys.getrefcount(A_func), refcount + incr) |
| 2146 | for i in range(5): |
| 2147 | gc.collect() |
| 2148 | assert_equal(sys.getrefcount(A_func), refcount) |
| 2149 | finally: |
| 2150 | gc.enable() |
| 2151 | |
| 2152 | |
| 2153 | class TestDigitize: |
nothing calls this directly
no test coverage detected