[Numpy-discussion] code review for datetime arange
Thu Jun 9 18:44:53 CDT 2011
On Thu, Jun 9, 2011 at 6:28 PM, Robert Kern <email@example.com> wrote:
> On Thu, Jun 9, 2011 at 16:27, Robert Kern <firstname.lastname@example.org> wrote:
> > On Thu, Jun 9, 2011 at 15:01, Mark Wiebe <email@example.com> wrote:
> >> I've replaced the previous two pull requests with a single pull request
> >> rolling up all the changes so far. The newest changes include finishing
> >> generic unit and np.arange function support.
> >> https://github.com/numpy/numpy/pull/87
> >> Because of the nature of datetime and timedelta, arange has to be
> >> different than with all the other types. In particular, for datetime the
> >> primary signature is np.arange(datetime, datetime, timedelta).
> >> I've implemented a simple extension which allows for another way to
> >> a date range, as np.arange(datetime, timedelta, timedelta). Here (start,
> >> delta) represents the datetime range [start, start+delta). Some
> >>>>> np.arange('2011', '2020', dtype='M8[Y]')
> >> array(['2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018',
> >> '2019'], dtype='datetime64[Y]')
> >>>>> np.arange('today', 10, 3, dtype='M8')
> >> array(['2011-06-09', '2011-06-12', '2011-06-15', '2011-06-18'],
> >> dtype='datetime64[D]')
> > I would prefer that we not further overload the signature of
> > np.arange() for this case. A new function dtrange() that can take a
> > delta would be preferable.
> Alternately, a general np.deltarange(start, delta[, step])
> might be useful, too. I know I've done the following quite a few
> times, even with just integers:
> np.arange(start, start+delta)
I like this approach.
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
> NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion