MCPcopy Create free account
hub / github.com/numpy/numpy / assert_no_gc_cycles

Function assert_no_gc_cycles

numpy/testing/_private/utils.py:2334–2366  ·  view source on GitHub ↗

Fail if the given callable produces any reference cycles. If called with all arguments omitted, may be used as a context manager: with assert_no_gc_cycles(): do_something() .. versionadded:: 1.15.0 Parameters ---------- func : callable The cal

(*args, **kwargs)

Source from the content-addressed store, hash-verified

2332
2333
2334def assert_no_gc_cycles(*args, **kwargs):
2335 """
2336 Fail if the given callable produces any reference cycles.
2337
2338 If called with all arguments omitted, may be used as a context manager:
2339
2340 with assert_no_gc_cycles():
2341 do_something()
2342
2343 .. versionadded:: 1.15.0
2344
2345 Parameters
2346 ----------
2347 func : callable
2348 The callable to test.
2349 \\*args : Arguments
2350 Arguments passed to `func`.
2351 \\*\\*kwargs : Kwargs
2352 Keyword arguments passed to `func`.
2353
2354 Returns
2355 -------
2356 Nothing. The result is deliberately discarded to ensure that all cycles
2357 are found.
2358
2359 """
2360 if not args:
2361 return _assert_no_gc_cycles_context()
2362
2363 func = args[0]
2364 args = args[1:]
2365 with _assert_no_gc_cycles_context(name=func.__name__):
2366 func(*args, **kwargs)
2367
2368
2369def break_cycles():

Callers 4

test_load_refcountFunction · 0.90
test_passesMethod · 0.90
test_assertsMethod · 0.90
test_failsMethod · 0.90

Calls 2

funcFunction · 0.50

Tested by 4

test_load_refcountFunction · 0.72
test_passesMethod · 0.72
test_assertsMethod · 0.72
test_failsMethod · 0.72