FunctionClamp#
- class braincell.FunctionClamp(fn)[source]#
Arbitrary-callable current clamp.
- Parameters:
fn (
Callable) – A functionf(t) -> Quantity[nA]called each step with the absolute simulation time. Use explicit conditions insidefnfor windowed current injection.
Notes
Equality and hashing follow identity on
fn(frozen dataclass auto-generated dunder methods compare lambdas by==, which falls back to identity). TwoFunctionClampinstances built from two separatelambdadefinitions with identical bodies are considered distinct.The runtime layer fingerprints
fnby bytecode + closure cells so structurally identical lambdas can merge into one layout. Closure cells holding opaque, non-hashable objects fall back toid(value)and therefore defeat dedup. Such lambdas trigger a one-shotRuntimeWarning— hoist to module level with a named functionto recover dedup.