pyhgf.model.builder.resolve_coupling_fn#

pyhgf.model.builder.resolve_coupling_fn(name_or_fn)[source]#

Resolve a coupling function name to a callable.

Parameters:

name_or_fn (Optional[str | Callable]) – Either a string name (“gelu”, “relu”, “identity”, etc.), a callable, or None (returns None).

Returns:

The resolved function, or None if input is None.

Return type:

Optional[Callable]

Raises:

ValueError – If the name is not recognized.

Examples

>>> fn = resolve_coupling_fn("gelu")
>>> fn is jax.nn.gelu
True
>>> resolve_coupling_fn(None) is None
True
>>> resolve_coupling_fn(lambda x: x)  # Already callable
<function <lambda> at ...>