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)
| 506 | |
| 507 | |
| 508 | def drange(dstart, dend, delta): |
| 509 | """ |
| 510 | Return a sequence of equally spaced Matplotlib dates. |
| 511 | |
| 512 | The dates start at *dstart* and reach up to, but not including *dend*. |
| 513 | They are spaced by *delta*. |
| 514 | |
| 515 | Parameters |
| 516 | ---------- |
| 517 | dstart, dend : `~datetime.datetime` |
| 518 | The date limits. |
| 519 | delta : `datetime.timedelta` |
| 520 | Spacing of the dates. |
| 521 | |
| 522 | Returns |
| 523 | ------- |
| 524 | `numpy.array` |
| 525 | A list floats representing Matplotlib dates. |
| 526 | |
| 527 | """ |
| 528 | f1 = date2num(dstart) |
| 529 | f2 = date2num(dend) |
| 530 | step = delta.total_seconds() / SEC_PER_DAY |
| 531 | |
| 532 | # calculate the difference between dend and dstart in times of delta |
| 533 | num = int(np.ceil((f2 - f1) / step)) |
| 534 | |
| 535 | # calculate end of the interval which will be generated |
| 536 | dinterval_end = dstart + num * delta |
| 537 | |
| 538 | # ensure, that a half open interval will be generated [dstart, dend) |
| 539 | if dinterval_end >= dend: |
| 540 | # if the endpoint is greater than or equal to dend, |
| 541 | # just subtract one delta |
| 542 | dinterval_end -= delta |
| 543 | num -= 1 |
| 544 | |
| 545 | f2 = date2num(dinterval_end) # new float-endpoint |
| 546 | return np.linspace(f1, f2, num + 1) |
| 547 | |
| 548 | |
| 549 | def _wrap_in_tex(text): |
no test coverage detected
searching dependent graphs…