@@ -53,14 +53,14 @@ PyDateTime_IMPORT
5353
5454from tslibs.np_datetime cimport get_timedelta64_value, get_datetime64_value
5555
56- from tslib cimport _check_all_nulls
5756from tslib import NaT, Timestamp, Timedelta, array_to_datetime
5857from interval import Interval
58+ from missing cimport checknull
5959
6060cdef int64_t NPY_NAT = util.get_nat()
6161
6262cimport util
63- from util cimport is_array, _checknull, _checknan
63+ from util cimport is_array, _checknull
6464
6565from libc.math cimport sqrt, fabs
6666
@@ -112,54 +112,6 @@ def memory_usage_of_objects(ndarray[object, ndim=1] arr):
112112
113113
114114# ----------------------------------------------------------------------
115- # isnull / notnull related
116-
117- cdef double INF = < double > np.inf
118- cdef double NEGINF = - INF
119-
120-
121- cpdef bint checknull(object val):
122- if util.is_float_object(val) or util.is_complex_object(val):
123- return val != val # and val != INF and val != NEGINF
124- elif util.is_datetime64_object(val):
125- return get_datetime64_value(val) == NPY_NAT
126- elif val is NaT:
127- return True
128- elif util.is_timedelta64_object(val):
129- return get_timedelta64_value(val) == NPY_NAT
130- elif is_array(val):
131- return False
132- else :
133- return _checknull(val)
134-
135-
136- cpdef bint checknull_old(object val):
137- if util.is_float_object(val) or util.is_complex_object(val):
138- return val != val or val == INF or val == NEGINF
139- elif util.is_datetime64_object(val):
140- return get_datetime64_value(val) == NPY_NAT
141- elif val is NaT:
142- return True
143- elif util.is_timedelta64_object(val):
144- return get_timedelta64_value(val) == NPY_NAT
145- elif is_array(val):
146- return False
147- else :
148- return _checknull(val)
149-
150-
151- cpdef bint isposinf_scalar(object val):
152- if util.is_float_object(val) and val == INF:
153- return True
154- else :
155- return False
156-
157-
158- cpdef bint isneginf_scalar(object val):
159- if util.is_float_object(val) and val == NEGINF:
160- return True
161- else :
162- return False
163115
164116
165117cpdef bint isscalar(object val):
@@ -212,78 +164,6 @@ def item_from_zerodim(object val):
212164 return util.unbox_if_zerodim(val)
213165
214166
215- @ cython.wraparound (False )
216- @ cython.boundscheck (False )
217- def isnaobj (ndarray arr ):
218- cdef Py_ssize_t i, n
219- cdef object val
220- cdef ndarray[uint8_t] result
221-
222- assert arr.ndim == 1 , " 'arr' must be 1-D."
223-
224- n = len (arr)
225- result = np.empty(n, dtype = np.uint8)
226- for i from 0 <= i < n:
227- val = arr[i]
228- result[i] = _check_all_nulls(val)
229- return result.view(np.bool_)
230-
231-
232- @ cython.wraparound (False )
233- @ cython.boundscheck (False )
234- def isnaobj_old (ndarray arr ):
235- cdef Py_ssize_t i, n
236- cdef object val
237- cdef ndarray[uint8_t] result
238-
239- assert arr.ndim == 1 , " 'arr' must be 1-D."
240-
241- n = len (arr)
242- result = np.zeros(n, dtype = np.uint8)
243- for i from 0 <= i < n:
244- val = arr[i]
245- result[i] = val is NaT or util._checknull_old(val)
246- return result.view(np.bool_)
247-
248-
249- @ cython.wraparound (False )
250- @ cython.boundscheck (False )
251- def isnaobj2d (ndarray arr ):
252- cdef Py_ssize_t i, j, n, m
253- cdef object val
254- cdef ndarray[uint8_t, ndim= 2 ] result
255-
256- assert arr.ndim == 2 , " 'arr' must be 2-D."
257-
258- n, m = (< object > arr).shape
259- result = np.zeros((n, m), dtype = np.uint8)
260- for i from 0 <= i < n:
261- for j from 0 <= j < m:
262- val = arr[i, j]
263- if checknull(val):
264- result[i, j] = 1
265- return result.view(np.bool_)
266-
267-
268- @ cython.wraparound (False )
269- @ cython.boundscheck (False )
270- def isnaobj2d_old (ndarray arr ):
271- cdef Py_ssize_t i, j, n, m
272- cdef object val
273- cdef ndarray[uint8_t, ndim= 2 ] result
274-
275- assert arr.ndim == 2 , " 'arr' must be 2-D."
276-
277- n, m = (< object > arr).shape
278- result = np.zeros((n, m), dtype = np.uint8)
279- for i from 0 <= i < n:
280- for j from 0 <= j < m:
281- val = arr[i, j]
282- if checknull_old(val):
283- result[i, j] = 1
284- return result.view(np.bool_)
285-
286-
287167@ cython.wraparound (False )
288168@ cython.boundscheck (False )
289169cpdef ndarray[object ] list_to_object_array(list obj):
0 commit comments