[Numpy-discussion] code review for datetime arange

Charles R Harris charlesr.harris@gmail....
Thu Jun 9 16:55:07 CDT 2011


On Thu, Jun 9, 2011 at 3:27 PM, 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.
>
>
I wonder if it would be better to have separate functions for the normal
range and (later) linspace functions. Dates are sufficiently different from
the usual run of numeric types that it might be better to have functions of
similar functionality but different names so that it is always clear what is
being asked for.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110609/15d33647/attachment.html 


More information about the NumPy-Discussion mailing list