[Numpy-discussion] code review for datetime arange
Thu Jun 9 16:27:38 CDT 2011
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 the
> generic unit and np.arange function support.
> 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'],
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 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
More information about the NumPy-Discussion