Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

TST: numpy 1.7 datetimeunit enum gap fix

  • Loading branch information...
commit b142a328d04eb9fe1c4f72a9fe3cc13cc4bd2e11 1 parent 31af052
Wes McKinney wesm authored

Showing 2 changed files with 19 additions and 28 deletions. Show diff stats Hide diff stats

  1. +4 14 pandas/src/datetime.pyx
  2. +15 14 pandas/src/datetime/np_datetime.h
18 pandas/src/datetime.pyx
@@ -26,8 +26,6 @@ PyDateTime_IMPORT
26 26 # in numpy 1.7, will prob need the following:
27 27 # numpy_pydatetime_import
28 28
29   -cdef bint numpy_16 = np.__version__ < '1.7'
30   -
31 29 try:
32 30 basestring
33 31 except NameError: # py3
@@ -637,12 +635,8 @@ cdef inline _get_datetime64_nanos(object val):
637 635 npy_datetime ival
638 636
639 637 unit = get_datetime64_unit(val)
640   - if numpy_16:
641   - if unit == 3:
642   - raise ValueError('NumPy 1.6.1 business freq not supported')
643   -
644   - if unit > 3:
645   - unit = <PANDAS_DATETIMEUNIT> ((<int>unit) - 1)
  638 + if unit == 3:
  639 + raise ValueError('NumPy 1.6.1 business freq not supported')
646 640
647 641 ival = get_datetime64_value(val)
648 642
@@ -668,12 +662,8 @@ def cast_to_nanoseconds(ndarray arr):
668 662 iresult = result.ravel().view(np.int64)
669 663
670 664 unit = get_datetime64_unit(arr.flat[0])
671   - if numpy_16:
672   - if unit == 3:
673   - raise ValueError('NumPy 1.6.1 business freq not supported')
674   -
675   - if unit > 3:
676   - unit = <PANDAS_DATETIMEUNIT> ((<int>unit) - 1)
  665 + if unit == 3:
  666 + raise ValueError('NumPy 1.6.1 business freq not supported')
677 667
678 668 for i in range(n):
679 669 pandas_datetime_to_datetimestruct(ivalues[i], unit, &dts)
29 pandas/src/datetime/np_datetime.h
@@ -9,20 +9,21 @@
9 9 #include <numpy/ndarraytypes.h>
10 10
11 11 typedef enum {
12   - PANDAS_FR_Y, /* Years */
13   - PANDAS_FR_M, /* Months */
14   - PANDAS_FR_W, /* Weeks */
15   - PANDAS_FR_D, /* Days */
16   - PANDAS_FR_h, /* hours */
17   - PANDAS_FR_m, /* minutes */
18   - PANDAS_FR_s, /* seconds */
19   - PANDAS_FR_ms,/* milliseconds */
20   - PANDAS_FR_us,/* microseconds */
21   - PANDAS_FR_ns,/* nanoseconds */
22   - PANDAS_FR_ps,/* picoseconds */
23   - PANDAS_FR_fs,/* femtoseconds */
24   - PANDAS_FR_as,/* attoseconds */
25   - PANDAS_FR_GENERIC /* Generic, unbound units, can convert to anything */
  12 + PANDAS_FR_Y = 0, /* Years */
  13 + PANDAS_FR_M = 1, /* Months */
  14 + PANDAS_FR_W = 2, /* Weeks */
  15 + /* Gap where NPY_FR_B was */
  16 + PANDAS_FR_D = 4, /* Days */
  17 + PANDAS_FR_h = 5, /* hours */
  18 + PANDAS_FR_m = 6, /* minutes */
  19 + PANDAS_FR_s = 7, /* seconds */
  20 + PANDAS_FR_ms = 8,/* milliseconds */
  21 + PANDAS_FR_us = 9,/* microseconds */
  22 + PANDAS_FR_ns = 10,/* nanoseconds */
  23 + PANDAS_FR_ps = 11,/* picoseconds */
  24 + PANDAS_FR_fs = 12,/* femtoseconds */
  25 + PANDAS_FR_as = 13,/* attoseconds */
  26 + PANDAS_FR_GENERIC = 14 /* Generic, unbound units, can convert to anything */
26 27 } PANDAS_DATETIMEUNIT;
27 28
28 29 #define PANDAS_DATETIME_NUMUNITS 13

0 comments on commit b142a32

Please sign in to comment.
Something went wrong with that request. Please try again.