MCPcopy Index your code
hub / github.com/numpy/numpy / assert_no_gc_cycles

Function assert_no_gc_cycles

numpy/testing/_private/utils.py:2632–2662  ·  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() Parameters ---------- func : callable The callable to test. \\*args :

(*args, **kwargs)

Source from the content-addressed store, hash-verified

2630
2631
2632def assert_no_gc_cycles(*args, **kwargs):
2633 """
2634 Fail if the given callable produces any reference cycles.
2635
2636 If called with all arguments omitted, may be used as a context manager::
2637
2638 with assert_no_gc_cycles():
2639 do_something()
2640
2641 Parameters
2642 ----------
2643 func : callable
2644 The callable to test.
2645 \\*args : Arguments
2646 Arguments passed to `func`.
2647 \\*\\*kwargs : Kwargs
2648 Keyword arguments passed to `func`.
2649
2650 Returns
2651 -------
2652 Nothing. The result is deliberately discarded to ensure that all cycles
2653 are found.
2654
2655 """
2656 if not args:
2657 return _assert_no_gc_cycles_context()
2658
2659 func = args[0]
2660 args = args[1:]
2661 with _assert_no_gc_cycles_context(name=func.__name__):
2662 func(*args, **kwargs)
2663
2664
2665def 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…