pg.auto_call_functors

Accessible via pg.auto_call_functors, pg.symbolic.auto_call_functors.

auto_call_functors(enabled=True)[source]

Returns a context manager to enable or disable auto call for functors.

auto_call_functors is thread-safe and can be nested. For example:

@pg.symbolize
def foo(x, y):
  return x + y

with pg.auto_call_functors(True):
  a = foo(1, 2)
  assert a == 3
  with pg.auto_call_functors(False):
    b = foo(1, 2)
    assert isinstance(b, foo)
Return type:

ContextManager[None]

Parameters:

enabled – If True, enable auto call for functors. Otherwise, auto call will be disabled.

Returns:

A context manager for enabling/disabling auto call for functors.