GithubHelp home page GithubHelp logo

Make RX like graphs about streamz HOT 3 OPEN

CJ-Wright avatar CJ-Wright commented on June 6, 2024
Make RX like graphs

from streamz.

Comments (3)

CJ-Wright avatar CJ-Wright commented on June 6, 2024
import time
from streams import Stream
from operator import add
import matplotlib.pyplot as plt


def star(f):
    """Take tuple and unpack it into args"""
    @ft.wraps(f)
    def wraps(args):
        return f(*args)

    return wraps

a = Stream()
b = Stream()
c = a.zip(b)

# Make the combo data
d = c.map(star(add))

def timer(*args):
    return time.time()

# Get the times
Ls = [s.map(timer).sink_to_list() for s in [a, b, c]]

# Get the labels
lab = [s.sink_to_list() for s in [a, b, d]]


# do the specific time trial(s)
t0 = time.time()
for i in range(5):
    a.emit(str(i))
for j in ['A', 'B', 'C', 'D', 'E']:
    b.emit(j)

for j, (L, M) in enumerate(zip(Ls, lab)):
    for l, m in zip(L, M):
        plt.scatter(l - t0, (3-j) * .01, marker=r"$ {} $".format(m), s=1000)
    plt.axhline((3-j) * .01)
fLs = [item - t0 for sublist in Ls for item in sublist]
plt.xlim(min(fLs) * .9, max(fLs) * 1.1)
plt.show()

This almost works, except on my machine the timings aren't just right. Is there any way I can slow each node down?

from streamz.

CJ-Wright avatar CJ-Wright commented on June 6, 2024

@mrocklin is there a way to have the map function delay asynchronously? It seems that the map (and it's timer sink) are actually executed before the b timer sink.

from streamz.

jrmlhermitte avatar jrmlhermitte commented on June 6, 2024

FYI after discussion with @CJ-Wright we may try to follow Rx (the figures are interactive)
http://rxmarbles.com/

combine_latest here

from streamz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.