-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
move is_null_datetimelike to nattype for self-containment #21692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
bbb7903
e8b0de7
d933cf8
1b798bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
# cython: profile=False | ||
|
||
cdef bint is_null_datetimelike(object val) | ||
from tslibs.nattype cimport is_null_datetimelike | ||
# pass-through so other modules can cimport is_null_datetimelike from here | ||
|
||
cpdef bint checknull(object val) | ||
cpdef bint checknull_old(object val) | ||
|
||
cdef bint is_null_datetime64(v) | ||
cdef bint is_null_timedelta64(v) | ||
cdef bint is_null_period(v) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ cimport numpy as cnp | |
from numpy cimport int64_t | ||
cnp.import_array() | ||
|
||
cimport util | ||
from util cimport (get_nat, | ||
is_integer_object, is_float_object, | ||
is_datetime64_object, is_timedelta64_object) | ||
|
@@ -587,3 +588,28 @@ cdef inline bint checknull_with_nat(object val): | |
""" utility to check if a value is a nat or not """ | ||
return val is None or ( | ||
PyFloat_Check(val) and val != val) or val is NaT | ||
|
||
|
||
cdef inline bint is_null_datetimelike(object val): | ||
""" | ||
Determine if we have a null for a timedelta/datetime (or integer versions) | ||
Parameters | ||
---------- | ||
val : object | ||
Returns | ||
------- | ||
null_datetimelike : bool | ||
""" | ||
if util._checknull(val): | ||
return True | ||
elif val is NaT: | ||
return True | ||
elif util.is_timedelta64_object(val): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why import this from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I understand the question. This PR is moving this function from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and by moving the function should not change the import? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these util functions of basically c versions of isinstance checks, so this is ok. |
||
return val.view('int64') == NPY_NAT | ||
elif util.is_datetime64_object(val): | ||
return val.view('int64') == NPY_NAT | ||
elif util.is_integer_object(val): | ||
return val == NPY_NAT | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this comment needed? this is for api simplicity yes? if so i don’t think really necessary for a comment