python : Updated code with better display, documentation and format_time
This commit is contained in:
@ -2,6 +2,14 @@ from typing import Callable, Iterable, Union, Any
|
||||
from tqdm import tqdm
|
||||
|
||||
def njit(f: Union[Callable, str] = None, *args, **kwargs) -> Callable:
|
||||
"""Wrapper for optional numba's njit decorator
|
||||
|
||||
Args:
|
||||
f (Union[Callable, str], optional): Function to wrap with numba. Defaults to None.
|
||||
|
||||
Returns:
|
||||
Callable: Wrapped function.
|
||||
"""
|
||||
def decorator(func: Callable) -> Any:
|
||||
return func
|
||||
|
||||
@ -10,4 +18,13 @@ def njit(f: Union[Callable, str] = None, *args, **kwargs) -> Callable:
|
||||
return decorator
|
||||
|
||||
def tqdm_iter(iter: Iterable, desc: str):
|
||||
return tqdm(iter, leave = False, desc = desc)
|
||||
"""Wrapper for optional tqdm iterator progress bar.
|
||||
|
||||
Args:
|
||||
iter (Iterable): Object to iterate over.
|
||||
desc (str): Description written to stdout.
|
||||
|
||||
Returns:
|
||||
_type_: Wrapped iterator.
|
||||
"""
|
||||
return tqdm(iter, leave = False, desc = desc)
|
Reference in New Issue
Block a user