1
1
# cython: profile=False
2
- cimport numpy as np
3
- cimport cython
4
- import numpy as np
5
- import sys
2
+ import operator
6
3
7
- cdef bint PY3 = (sys.version_info[0 ] >= 3 )
8
-
9
- from numpy cimport *
4
+ cimport cython
5
+ from cython cimport Py_ssize_t
10
6
7
+ import numpy as np
8
+ cimport numpy as np
9
+ from numpy cimport (ndarray, PyArray_NDIM, PyArray_GETITEM, PyArray_SETITEM,
10
+ PyArray_ITER_DATA, PyArray_ITER_NEXT, PyArray_IterNew,
11
+ flatiter, NPY_OBJECT,
12
+ int64_t,
13
+ float32_t, float64_t,
14
+ uint8_t, uint64_t,
15
+ complex128_t)
11
16
# initialize numpy
12
17
np.import_array()
13
18
np.import_ufunc()
@@ -57,9 +62,9 @@ from tslib import NaT, Timestamp, Timedelta, array_to_datetime
57
62
from interval import Interval
58
63
from missing cimport checknull
59
64
60
- cdef int64_t NPY_NAT = util.get_nat()
61
65
62
66
cimport util
67
+ cdef int64_t NPY_NAT = util.get_nat()
63
68
from util cimport is_array, _checknull
64
69
65
70
from libc.math cimport fabs
@@ -497,7 +502,6 @@ def maybe_booleans_to_slice(ndarray[uint8_t] mask):
497
502
@ cython.wraparound (False )
498
503
@ cython.boundscheck (False )
499
504
def scalar_compare (ndarray[object] values , object val , object op ):
500
- import operator
501
505
cdef:
502
506
Py_ssize_t i, n = len (values)
503
507
ndarray[uint8_t, cast= True ] result
@@ -532,7 +536,7 @@ def scalar_compare(ndarray[object] values, object val, object op):
532
536
result[i] = True
533
537
else :
534
538
try :
535
- result[i] = cpython. PyObject_RichCompareBool(x, val, flag)
539
+ result[i] = PyObject_RichCompareBool(x, val, flag)
536
540
except (TypeError ):
537
541
result[i] = True
538
542
elif flag == cpython.Py_EQ:
@@ -544,7 +548,7 @@ def scalar_compare(ndarray[object] values, object val, object op):
544
548
result[i] = False
545
549
else :
546
550
try :
547
- result[i] = cpython. PyObject_RichCompareBool(x, val, flag)
551
+ result[i] = PyObject_RichCompareBool(x, val, flag)
548
552
except (TypeError ):
549
553
result[i] = False
550
554
@@ -556,7 +560,7 @@ def scalar_compare(ndarray[object] values, object val, object op):
556
560
elif isnull_val:
557
561
result[i] = False
558
562
else :
559
- result[i] = cpython. PyObject_RichCompareBool(x, val, flag)
563
+ result[i] = PyObject_RichCompareBool(x, val, flag)
560
564
561
565
return result.view(bool )
562
566
@@ -585,7 +589,6 @@ cpdef bint array_equivalent_object(object[:] left, object[:] right):
585
589
@ cython.wraparound (False )
586
590
@ cython.boundscheck (False )
587
591
def vec_compare (ndarray[object] left , ndarray[object] right , object op ):
588
- import operator
589
592
cdef:
590
593
Py_ssize_t i, n = len (left)
591
594
ndarray[uint8_t, cast= True ] result
@@ -620,7 +623,7 @@ def vec_compare(ndarray[object] left, ndarray[object] right, object op):
620
623
if checknull(x) or checknull(y):
621
624
result[i] = True
622
625
else :
623
- result[i] = cpython. PyObject_RichCompareBool(x, y, flag)
626
+ result[i] = PyObject_RichCompareBool(x, y, flag)
624
627
else :
625
628
for i in range (n):
626
629
x = left[i]
@@ -629,7 +632,7 @@ def vec_compare(ndarray[object] left, ndarray[object] right, object op):
629
632
if checknull(x) or checknull(y):
630
633
result[i] = False
631
634
else :
632
- result[i] = cpython. PyObject_RichCompareBool(x, y, flag)
635
+ result[i] = PyObject_RichCompareBool(x, y, flag)
633
636
634
637
return result.view(bool )
635
638
0 commit comments