How to use the wurlitzer.Wurlitzer.flush_interval function in wurlitzer

To help you get started, we’ve selected a few wurlitzer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hanzhi713 / image-collage-maker / make_img.py View on Github external
# compute pair-wise distances
    cost_matrix = cdist(img_keys, dest_img, metric=metric)

    np_ctype = eval("np." + ctype)
    cost_matrix = np_ctype(cost_matrix)

    print("Computing optimal assignment on a {}x{} matrix...".format(
        cost_matrix.shape[0], cost_matrix.shape[1]))

    from lapjv import lapjv

    if v is not None and (platform.system() == "Linux" or platform.system() == "Darwin") and v.gui:
        try:
            from wurlitzer import pipes, STDOUT
            from wurlitzer import Wurlitzer
            Wurlitzer.flush_interval = 0.1
            wrapper = JVOutWrapper(v)
            with pipes(stdout=wrapper, stderr=STDOUT):
                _, cols, cost = lapjv(cost_matrix, verbose=1)
                wrapper.finish()
        except ImportError:
            _, cols, cost = lapjv(cost_matrix)

    else:
        _, cols, cost = lapjv(cost_matrix)

    cost = cost[0]

    print("Total assignment cost:", cost)
    print("Time taken: {}s".format((np.round(time.time() - t, 2))))

    # sometimes the cost matrix may be extremely large

wurlitzer

Capture C-level output in context managers

MIT
Latest version published 5 months ago

Package Health Score

77 / 100
Full package analysis

Similar packages