Permalink
Browse files

TST: numpy 1.7 datetimeunit enum gap fix

  • Loading branch information...
1 parent 31af052 commit b142a328d04eb9fe1c4f72a9fe3cc13cc4bd2e11 @wesm wesm committed Jun 16, 2012
Showing with 19 additions and 28 deletions.
  1. +4 −14 pandas/src/datetime.pyx
  2. +15 −14 pandas/src/datetime/np_datetime.h
View
@@ -26,8 +26,6 @@ PyDateTime_IMPORT
# in numpy 1.7, will prob need the following:
# numpy_pydatetime_import
-cdef bint numpy_16 = np.__version__ < '1.7'
-
try:
basestring
except NameError: # py3
@@ -637,12 +635,8 @@ cdef inline _get_datetime64_nanos(object val):
npy_datetime ival
unit = get_datetime64_unit(val)
- if numpy_16:
- if unit == 3:
- raise ValueError('NumPy 1.6.1 business freq not supported')
-
- if unit > 3:
- unit = <PANDAS_DATETIMEUNIT> ((<int>unit) - 1)
+ if unit == 3:
+ raise ValueError('NumPy 1.6.1 business freq not supported')
ival = get_datetime64_value(val)
@@ -668,12 +662,8 @@ def cast_to_nanoseconds(ndarray arr):
iresult = result.ravel().view(np.int64)
unit = get_datetime64_unit(arr.flat[0])
- if numpy_16:
- if unit == 3:
- raise ValueError('NumPy 1.6.1 business freq not supported')
-
- if unit > 3:
- unit = <PANDAS_DATETIMEUNIT> ((<int>unit) - 1)
+ if unit == 3:
+ raise ValueError('NumPy 1.6.1 business freq not supported')
for i in range(n):
pandas_datetime_to_datetimestruct(ivalues[i], unit, &dts)
@@ -9,20 +9,21 @@
#include <numpy/ndarraytypes.h>
typedef enum {
- PANDAS_FR_Y, /* Years */
- PANDAS_FR_M, /* Months */
- PANDAS_FR_W, /* Weeks */
- PANDAS_FR_D, /* Days */
- PANDAS_FR_h, /* hours */
- PANDAS_FR_m, /* minutes */
- PANDAS_FR_s, /* seconds */
- PANDAS_FR_ms,/* milliseconds */
- PANDAS_FR_us,/* microseconds */
- PANDAS_FR_ns,/* nanoseconds */
- PANDAS_FR_ps,/* picoseconds */
- PANDAS_FR_fs,/* femtoseconds */
- PANDAS_FR_as,/* attoseconds */
- PANDAS_FR_GENERIC /* Generic, unbound units, can convert to anything */
+ PANDAS_FR_Y = 0, /* Years */
+ PANDAS_FR_M = 1, /* Months */
+ PANDAS_FR_W = 2, /* Weeks */
+ /* Gap where NPY_FR_B was */
+ PANDAS_FR_D = 4, /* Days */
+ PANDAS_FR_h = 5, /* hours */
+ PANDAS_FR_m = 6, /* minutes */
+ PANDAS_FR_s = 7, /* seconds */
+ PANDAS_FR_ms = 8,/* milliseconds */
+ PANDAS_FR_us = 9,/* microseconds */
+ PANDAS_FR_ns = 10,/* nanoseconds */
+ PANDAS_FR_ps = 11,/* picoseconds */
+ PANDAS_FR_fs = 12,/* femtoseconds */
+ PANDAS_FR_as = 13,/* attoseconds */
+ PANDAS_FR_GENERIC = 14 /* Generic, unbound units, can convert to anything */
} PANDAS_DATETIMEUNIT;
#define PANDAS_DATETIME_NUMUNITS 13

0 comments on commit b142a32

Please sign in to comment.