|
475 | 475 | <body> |
476 | 476 |
|
477 | 477 | <div id="toc_container" style="position:fixed;width: 200px;left:1em;top:1em"> |
478 | | -<h3> <font color=#e2e6ee> RedBlackPy </font> </h3> |
| 478 | +<h3> <font color=#e2e6ee> RedBlackPy 0.1.0 </font> </h3> |
479 | 479 | <h4> <font color=#e2e6ee> Table of contents: </font> </h4> |
480 | 480 | <div id="expanded" style="display: true"> |
481 | 481 | <a href="./doc_index.html" class="button">Main</a> <br> |
@@ -547,6 +547,47 @@ <h2 id="toc_2">Interpolation</h2> |
547 | 547 |
|
548 | 548 | </code></pre></div> |
549 | 549 |
|
| 550 | +<h2 id="toc_3">SeriesIterator</h2> |
| 551 | + |
| 552 | +<div><pre><code class="language-python">import redblackpy as rb |
| 553 | +import random |
| 554 | + |
| 555 | +def create_random_series(length): |
| 556 | + |
| 557 | + data = random.sample(range(5000000), length) |
| 558 | + # with no loss of generality using one list for index and values |
| 559 | + return rb.Series(index=data, values=data, dtype='int64') |
| 560 | + |
| 561 | + |
| 562 | +#------------------------------------------------------------------------ |
| 563 | +# create timer for executing time evaluation |
| 564 | +timer = rb.Timer() |
| 565 | + |
| 566 | +# create list of 10 Series, each contains 100k values |
| 567 | +series_list = [ create_random_series(100000) for i in range(10) ] |
| 568 | + |
| 569 | +# start time evaluation, we including initialization of SeriesIterator |
| 570 | +timer.start() |
| 571 | +iterator = rb.SeriesIterator(series_list) |
| 572 | +# iterating over union of ten Series |
| 573 | +for key in iterator(): |
| 574 | + key |
| 575 | +# stop timer |
| 576 | +time_forward = timer.stop() |
| 577 | + |
| 578 | +# the same procedure, but for reverse iterator |
| 579 | +timer.start() |
| 580 | +# iterating over union of ten Series |
| 581 | +for key in iterator('reverse'): |
| 582 | + key |
| 583 | +# stop timer |
| 584 | +time_reverse = timer.stop() |
| 585 | +# obtain the results |
| 586 | +output_str = 'Time forward: {:}; Time reverse: {:}'.format( time_forward, |
| 587 | + time_reverse ) |
| 588 | +print(output_str) |
| 589 | +</code></pre></div> |
| 590 | + |
550 | 591 |
|
551 | 592 |
|
552 | 593 | <script type="text/javascript"> |
|
0 commit comments