irsim.util.decorator#
Decorators shared by IR-SIM environments and utilities.
bind_env, plot_only and normalize_actions wrap EnvBase
methods; time_it / time_it2 are general timing helpers.
Functions#
|
Decorator to measure function execution time. |
|
Decorator making |
|
Decorator making an env plotting helper a no-op when the env has no figure. |
|
Decorator to normalize (action, action_id) into an aligned actions list. |
|
Decorator to measure function execution time with instance attribute check. |
Module Contents#
- irsim.util.decorator.time_it(name: str = 'Function') Any[源代码]#
Decorator to measure function execution time.
- 参数:
name (str) -- Function name for logging (default "Function").
- 返回:
Wrapped function with timing.
- 返回类型:
function
- irsim.util.decorator.bind_env(method)[源代码]#
Decorator making
selfthe current environment beforemethodruns.Object ids, the random generator, and context-free logging are reached through the module-level
env_param/world_paramproxies, so methods that construct objects or draw random numbers bind their environment first.
- irsim.util.decorator.plot_only(method)[源代码]#
Decorator making an env plotting helper a no-op when the env has no figure.
EnvBasecreates noEnvPlotin headless mode, so rendering, drawing, and saving helpers decorated with this simply returnNonein that case.
- irsim.util.decorator.normalize_actions(func)[源代码]#
Decorator to normalize (action, action_id) into an aligned actions list.
The wrapped method must belong to a class that has a
objectsattribute. It receivesactions, a list aligned withself.objects(Nonewhere nothing was given).actionis one action, a list of actions, or a dict{name: action};action_idis an object id (obj.id) or name (Nonefor the first object), or a list of them. A single action is applied to every id; a list of actions is applied to the given ids, or to consecutive objects starting from the given id. Surplus actions (or ids) are dropped with a warning; an unknown id or name raises.