Marble Diagrams with RxPY

This is a fantastic feature to produce and visualize streams and to verify how various operators work on them.

Have also a look at rxmarbles for interactive visualisations.

ONE DASH IS 100 MILLISECONDS!


In [3]:
%run startup.py

Create Streams from Strings: from_marbles


In [4]:
rst(O.from_marbles)
ts = time.time()
# producing a stream
s = O.from_marbles('1-2-3|')
# mapping into real time:
s2 = s.to_blocking()
# adding times
s3 = s2.map(lambda x: 'val: %s, dt: %s' % (x, time.time()-ts))
# subscribing to it:
d = s3.subscribe(print)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-f357afe7d2ae> in <module>()
----> 1 rst(O.from_marbles)
      2 ts = time.time()
      3 # producing a stream
      4 s = O.from_marbles('1-2-3|')
      5 # mapping into real time:

F:\src\learning\python\libs\rxpy\support\startup.py in reset_start_time(show_doc_for, title, sleep)
     27         if d:
     28             if title == True:
---> 29                 title = d.func_name
     30         header(title)
     31     if not d:

AttributeError: 'function' object has no attribute 'func_name'

Visualize Streams as Marble Strings: to_marbles


In [5]:
rst(rx.core.blockingobservable.BlockingObservable.to_marbles)
s1 = O.from_marbles('1---2-3|')
s2 = O.from_marbles('-a-b-c-|')
print(s1.merge(s2).to_blocking().to_marbles())


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-f8abcafe245f> in <module>()
----> 1 rst(rx.core.blockingobservable.BlockingObservable.to_marbles)
      2 s1 = O.from_marbles('1---2-3|')
      3 s2 = O.from_marbles('-a-b-c-|')
      4 print(s1.merge(s2).to_blocking().to_marbles())

F:\src\learning\python\libs\rxpy\support\startup.py in reset_start_time(show_doc_for, title, sleep)
     27         if d:
     28             if title == True:
---> 29                 title = d.func_name
     30         header(title)
     31     if not d:

AttributeError: 'function' object has no attribute 'func_name'

In [ ]: