Generate between 2 numbers w/ optional step, optionally include upper bound
(start, stop, step=1.0, include_stop=False)
| 47 | |
| 48 | |
| 49 | def drange(start, stop, step=1.0, include_stop=False): |
| 50 | """ |
| 51 | Generate between 2 numbers w/ optional step, optionally include upper bound |
| 52 | """ |
| 53 | if step == 0: |
| 54 | step = 0.01 |
| 55 | r = start |
| 56 | |
| 57 | if include_stop: |
| 58 | while r <= stop: |
| 59 | yield r |
| 60 | r += step |
| 61 | r = round(r, 10) |
| 62 | else: |
| 63 | while r < stop: |
| 64 | yield r |
| 65 | r += step |
| 66 | r = round(r, 10) |
| 67 | |
| 68 | |
| 69 | def abbreviate(labels, rfill=' '): |