Unverified 提交 676e10cf authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Simplify callbacks.py return (#7333)

* Simplify callbacks.py return * Indent args (pytorch convention) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ciCo-authored-by: 's avatarpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
上级 5783de26
...@@ -38,9 +38,9 @@ class Callbacks: ...@@ -38,9 +38,9 @@ class Callbacks:
Register a new action to a callback hook Register a new action to a callback hook
Args: Args:
hook The callback hook name to register the action to hook: The callback hook name to register the action to
name The name of the action for later reference name: The name of the action for later reference
callback The callback to fire callback: The callback to fire
""" """
assert hook in self._callbacks, f"hook '{hook}' not found in callbacks {self._callbacks}" assert hook in self._callbacks, f"hook '{hook}' not found in callbacks {self._callbacks}"
assert callable(callback), f"callback '{callback}' is not callable" assert callable(callback), f"callback '{callback}' is not callable"
...@@ -51,21 +51,18 @@ class Callbacks: ...@@ -51,21 +51,18 @@ class Callbacks:
Returns all the registered actions by callback hook Returns all the registered actions by callback hook
Args: Args:
hook The name of the hook to check, defaults to all hook: The name of the hook to check, defaults to all
""" """
if hook: return self._callbacks[hook] if hook else self._callbacks
return self._callbacks[hook]
else:
return self._callbacks
def run(self, hook, *args, **kwargs): def run(self, hook, *args, **kwargs):
""" """
Loop through the registered actions and fire all callbacks Loop through the registered actions and fire all callbacks
Args: Args:
hook The name of the hook to check, defaults to all hook: The name of the hook to check, defaults to all
args Arguments to receive from YOLOv5 args: Arguments to receive from YOLOv5
kwargs Keyword Arguments to receive from YOLOv5 kwargs: Keyword Arguments to receive from YOLOv5
""" """
assert hook in self._callbacks, f"hook '{hook}' not found in callbacks {self._callbacks}" assert hook in self._callbacks, f"hook '{hook}' not found in callbacks {self._callbacks}"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论