Skip to content

CLN/STY: Nitpicks #32961

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

Merged
merged 2 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ cimport pandas._libs.util as util
from pandas._libs.util cimport numeric, get_nat

from pandas._libs.khash cimport (
khiter_t, kh_destroy_int64, kh_put_int64, kh_init_int64, kh_int64_t,
kh_resize_int64, kh_get_int64)
kh_destroy_int64,
kh_get_int64,
kh_init_int64,
kh_int64_t,
kh_put_int64,
kh_resize_int64,
khiter_t,
)


import pandas._libs.missing as missing

Expand Down Expand Up @@ -791,8 +798,13 @@ ctypedef fused rank_t:

@cython.wraparound(False)
@cython.boundscheck(False)
def rank_1d(rank_t[:] in_arr, ties_method='average',
ascending=True, na_option='keep', pct=False):
def rank_1d(
rank_t[:] in_arr,
ties_method="average",
bint ascending=True,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added bint

na_option="keep",
bint pct=False,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added bint

):
"""
Fast NaN-friendly version of ``scipy.stats.rankdata``.
"""
Expand Down Expand Up @@ -1009,8 +1021,14 @@ def rank_1d(rank_t[:] in_arr, ties_method='average',
return ranks


def rank_2d(rank_t[:, :] in_arr, axis=0, ties_method='average',
ascending=True, na_option='keep', pct=False):
def rank_2d(
rank_t[:, :] in_arr,
int axis=0,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added int

ties_method="average",
bint ascending=True,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added bint

na_option="keep",
bint pct=False,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added bint

):
"""
Fast NaN-friendly version of ``scipy.stats.rankdata``.
"""
Expand Down Expand Up @@ -1190,9 +1208,12 @@ ctypedef fused out_t:

@cython.boundscheck(False)
@cython.wraparound(False)
def diff_2d(diff_t[:, :] arr,
out_t[:, :] out,
Py_ssize_t periods, int axis):
def diff_2d(
diff_t[:, :] arr,
out_t[:, :] out,
Py_ssize_t periods,
int axis,
):
cdef:
Py_ssize_t i, j, sx, sy, start, stop
bint f_contig = arr.is_f_contig()
Expand Down
21 changes: 15 additions & 6 deletions pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ import warnings

import numpy as np
cimport numpy as cnp
from numpy cimport (ndarray, intp_t,
float64_t, float32_t,
int64_t, int32_t, int16_t, int8_t,
uint64_t, uint32_t, uint16_t, uint8_t
from numpy cimport (
float32_t,
float64_t,
int8_t,
int16_t,
int32_t,
int64_t,
intp_t,
ndarray,
uint8_t,
uint16_t,
uint32_t,
uint64_t,
)
cnp.import_array()

Expand Down Expand Up @@ -364,7 +373,7 @@ cdef class ObjectEngine(IndexEngine):

cdef class DatetimeEngine(Int64Engine):

cdef _get_box_dtype(self):
cdef str _get_box_dtype(self):
return 'M8[ns]'

cdef int64_t _unbox_scalar(self, scalar) except? -1:
Expand Down Expand Up @@ -454,7 +463,7 @@ cdef class DatetimeEngine(Int64Engine):

cdef class TimedeltaEngine(DatetimeEngine):

cdef _get_box_dtype(self):
cdef str _get_box_dtype(self):
return 'm8[ns]'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not gonna change to double-quotes while you're here?


cdef int64_t _unbox_scalar(self, scalar) except? -1:
Expand Down
3 changes: 2 additions & 1 deletion pandas/_libs/indexing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cdef class _NDFrameIndexerBase:
"""
A base class for _NDFrameIndexer for fast instantiation and attribute access.
"""
cdef public object obj, name, _ndim
cdef public:
object obj, name, _ndim

def __init__(self, name, obj):
self.obj = obj
Expand Down
23 changes: 19 additions & 4 deletions pandas/_libs/interval.pyx
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
import numbers
from operator import le, lt

from cpython.object cimport (Py_EQ, Py_NE, Py_GT, Py_LT, Py_GE, Py_LE,
PyObject_RichCompare)
from cpython.object cimport (
Py_EQ,
Py_GE,
Py_GT,
Py_LE,
Py_LT,
Py_NE,
PyObject_RichCompare,
)


import cython
from cython import Py_ssize_t

import numpy as np
cimport numpy as cnp
from numpy cimport (
int64_t, int32_t, float64_t, float32_t, uint64_t,
NPY_QUICKSORT,
PyArray_ArgSort,
PyArray_Take,
float32_t,
float64_t,
int32_t,
int64_t,
ndarray,
PyArray_ArgSort, NPY_QUICKSORT, PyArray_Take)
uint64_t,
)
cnp.import_array()


Expand Down
12 changes: 10 additions & 2 deletions pandas/_libs/ops.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import operator

from cpython.object cimport (PyObject_RichCompareBool,
Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT, Py_GE)
from cpython.object cimport (
Py_EQ,
Py_GE,
Py_GT,
Py_LE,
Py_LT,
Py_NE,
PyObject_RichCompareBool,
)


import cython
from cython import Py_ssize_t
Expand Down
3 changes: 1 addition & 2 deletions pandas/_libs/properties.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from cython import Py_ssize_t

from cpython.dict cimport (
PyDict_Contains, PyDict_GetItem, PyDict_SetItem)
from cpython.dict cimport PyDict_Contains, PyDict_GetItem, PyDict_SetItem


cdef class CachedProperty:
Expand Down