Return a sequence of equally spaced Matplotlib dates. The dates start at *dstart* and reach up to, but not including *dend*. They are spaced by *delta*. Parameters ---------- dstart, dend : `~datetime.datetime` The date limits. delta : `datetime.timedelta`
(dstart, dend, delta)
| 537 | |
| 538 | |
| 539 | def drange(dstart, dend, delta): |
| 540 | """ |
| 541 | Return a sequence of equally spaced Matplotlib dates. |
| 542 | |
| 543 | The dates start at *dstart* and reach up to, but not including *dend*. |
| 544 | They are spaced by *delta*. |
| 545 | |
| 546 | Parameters |
| 547 | ---------- |
| 548 | dstart, dend : `~datetime.datetime` |
| 549 | The date limits. |
| 550 | delta : `datetime.timedelta` |
| 551 | Spacing of the dates. |
| 552 | |
| 553 | Returns |
| 554 | ------- |
| 555 | drange : `numpy.array` |
| 556 | A list floats representing Matplotlib dates. |
| 557 | |
| 558 | """ |
| 559 | f1 = date2num(dstart) |
| 560 | f2 = date2num(dend) |
| 561 | step = delta.total_seconds() / SEC_PER_DAY |
| 562 | |
| 563 | # calculate the difference between dend and dstart in times of delta |
| 564 | num = int(np.ceil((f2 - f1) / step)) |
| 565 | |
| 566 | # calculate end of the interval which will be generated |
| 567 | dinterval_end = dstart + num * delta |
| 568 | |
| 569 | # ensure, that an half open interval will be generated [dstart, dend) |
| 570 | if dinterval_end >= dend: |
| 571 | # if the endpoint is greated than dend, just subtract one delta |
| 572 | dinterval_end -= delta |
| 573 | num -= 1 |
| 574 | |
| 575 | f2 = date2num(dinterval_end) # new float-endpoint |
| 576 | return np.linspace(f1, f2, num + 1) |
| 577 | |
| 578 | ### date tickers and formatters ### |
| 579 |
nothing calls this directly
no test coverage detected