Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankanand007 committed Dec 16, 2021
1 parent 4fef185 commit d08b954
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 9 additions & 3 deletions python/cudf/cudf/_lib/cpp/datetime.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ cdef extern from "cudf/datetime.hpp" namespace "cudf::datetime" nogil:
MICROSECOND "cudf::datetime::rounding_frequency::MICROSECOND"
NANOSECOND "cudf::datetime::rounding_frequency::NANOSECOND"

cdef unique_ptr[column] ceil_datetimes(const column_view& column, rounding_frequency freq) except +
cdef unique_ptr[column] floor_datetimes(const column_view& column, rounding_frequency freq) except +
cdef unique_ptr[column] round_datetimes(const column_view& column, rounding_frequency freq) except +
cdef unique_ptr[column] ceil_datetimes(
const column_view& column, rounding_frequency freq
) except +
cdef unique_ptr[column] floor_datetimes(
const column_view& column, rounding_frequency freq
) except +
cdef unique_ptr[column] round_datetimes(
const column_view& column, rounding_frequency freq
) except +

cdef unique_ptr[column] add_calendrical_months(
const column_view& timestamps,
Expand Down
11 changes: 8 additions & 3 deletions python/cudf/cudf/_lib/datetime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def extract_datetime_component(Column col, object field):

return result


cdef libcudf_datetime.rounding_frequency _get_rounding_frequency(object freq):
cdef libcudf_datetime.rounding_frequency freq_val

Expand All @@ -83,10 +84,12 @@ cdef libcudf_datetime.rounding_frequency _get_rounding_frequency(object freq):
raise ValueError(f"Invalid resolution: '{freq}'")
return freq_val


def ceil_datetime(Column col, object freq):
cdef unique_ptr[column] c_result
cdef column_view col_view = col.view()
cdef libcudf_datetime.rounding_frequency freq_val = _get_rounding_frequency(freq)
cdef libcudf_datetime.rounding_frequency freq_val = \
_get_rounding_frequency(freq)

with nogil:
c_result = move(libcudf_datetime.ceil_datetimes(col_view, freq_val))
Expand All @@ -98,7 +101,8 @@ def ceil_datetime(Column col, object freq):
def floor_datetime(Column col, object freq):
cdef unique_ptr[column] c_result
cdef column_view col_view = col.view()
cdef libcudf_datetime.rounding_frequency freq_val = _get_rounding_frequency(freq)
cdef libcudf_datetime.rounding_frequency freq_val = \
_get_rounding_frequency(freq)

with nogil:
c_result = move(libcudf_datetime.floor_datetimes(col_view, freq_val))
Expand All @@ -110,7 +114,8 @@ def floor_datetime(Column col, object freq):
def round_datetime(Column col, object freq):
cdef unique_ptr[column] c_result
cdef column_view col_view = col.view()
cdef libcudf_datetime.rounding_frequency freq_val = _get_rounding_frequency(freq)
cdef libcudf_datetime.rounding_frequency freq_val = \
_get_rounding_frequency(freq)

with nogil:
c_result = move(libcudf_datetime.round_datetimes(col_view, freq_val))
Expand Down

0 comments on commit d08b954

Please sign in to comment.