How to use the wurlitzer.STDOUT 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
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
    # manually delete it to free memory
    del cost_matrix
github hanzhi713 / image-collage-maker / make_img.py View on Github external
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]

    del cost_matrix

    paired = np.array(imgs)[cols]

    white = np.ones(imgs[0].shape, np.uint8)
    white[:, :, :] = [background[2], background[1], background[0]]

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