# AUTOGENERATED! DO NOT EDIT! File to edit: 00_utils.ipynb (unless otherwise specified).

__all__ = ['suppress_stdout', 'timing', 'timefn', 'browse_images']

# Cell
from time import time, sleep
from functools import wraps

from contextlib import contextmanager
import sys, os
import ipywidgets as wgt
from IPython.display import Image, display

# Cell
@contextmanager
def suppress_stdout():
    with open(os.devnull, "w") as devnull:
        old_stdout = sys.stdout
        sys.stdout = devnull
        try:
            yield
        finally:
            sys.stdout = old_stdout

# Cell
@contextmanager
def timing(description: str = 'Time') -> None:
    try:
        start = time()
        yield
    finally:
        ellapsed_time = time() - start
        print(f'{description}: {ellapsed_time}')


# Cell
def timefn(fn):
    @wraps(fn)
    def measure_time(*args, **kwargs):
        t1 = time()
        result = fn(*args, **kwargs)
        t2 = time()
        print(f"@timefn: {fn.__name__} took {str(t2 -t1)} seconds")
        return result
    return measure_time


# Cell
def browse_images(paths):
    def view_image(image_path):
        display(Image(image_path))
    return wgt.interact(view_image, image_path=paths)
# AUTOGENERATED! DO NOT EDIT! File to edit: 00_utils.ipynb (unless otherwise specified).

__all__ = ['suppress_stdout', 'timing', 'timefn', 'browse_images']

# Cell
from time import time, sleep
from functools import wraps

from contextlib import contextmanager
import sys, os
import ipywidgets as wgt
from IPython.display import Image, display

# Cell
@contextmanager
def suppress_stdout():
    with open(os.devnull, "w") as devnull:
        old_stdout = sys.stdout
        sys.stdout = devnull
        try:
            yield
        finally:
            sys.stdout = old_stdout

# Cell
@contextmanager
def timing(description: str = 'Time') -> None:
    try:
        start = time()
        yield
    finally:
        ellapsed_time = time() - start
        print(f'{description}: {ellapsed_time}')


# Cell
def timefn(fn):
    @wraps(fn)
    def measure_time(*args, **kwargs):
        t1 = time()
        result = fn(*args, **kwargs)
        t2 = time()
        print(f"@timefn: {fn.__name__} took {str(t2 -t1)} seconds")
        return result
    return measure_time


# Cell
def browse_images(paths):
    def view_image(image_path):
        display(Image(image_path))
    return wgt.interact(view_image, image_path=paths)
# AUTOGENERATED! DO NOT EDIT! File to edit: 00_utils.ipynb (unless otherwise specified). # Cell # Cell # Cell # Cell # Cell