[Numpy-discussion] code review for datetime arange

Mark Wiebe mwwiebe@gmail....
Thu Jun 9 18:44:53 CDT 2011


On Thu, Jun 9, 2011 at 6:28 PM, Robert Kern <robert.kern@gmail.com> wrote:

> On Thu, Jun 9, 2011 at 16:27, Robert Kern <robert.kern@gmail.com> wrote:
> > On Thu, Jun 9, 2011 at 15:01, Mark Wiebe <mwwiebe@gmail.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
> the
> >> 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
> slightly
> >> 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
> specify
> >> a date range, as np.arange(datetime, timedelta, timedelta). Here (start,
> >> delta) represents the datetime range [start, start+delta). Some
> examples:
> >>>>> 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])


+1

function
> 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.

-Mark


> --
> 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
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110609/000c64b7/attachment.html 


More information about the NumPy-Discussion mailing list