Skip to content

CLN: Some code cleanups #32176

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 1 commit into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions pandas/_libs/indexing.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cdef class _NDFrameIndexerBase:
"""
A base class for _NDFrameIndexer for fast instantiation and attribute
access.
A base class for _NDFrameIndexer for fast instantiation and attribute access.
"""
cdef public object obj, name, _ndim

Expand Down
13 changes: 4 additions & 9 deletions pandas/_libs/sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ cdef class IntIndex(SparseIndex):
return -1

@cython.wraparound(False)
cpdef ndarray[int32_t] lookup_array(self, ndarray[
int32_t, ndim=1] indexer):
cpdef ndarray[int32_t] lookup_array(self, ndarray[int32_t, ndim=1] indexer):
"""
Vectorized lookup, returns ndarray[int32_t]
"""
Expand Down Expand Up @@ -424,12 +423,9 @@ cdef class BlockIndex(SparseIndex):
"""
Intersect two BlockIndex objects

Parameters
----------

Returns
-------
intersection : BlockIndex
BlockIndex
"""
cdef:
BlockIndex y
Expand Down Expand Up @@ -518,7 +514,7 @@ cdef class BlockIndex(SparseIndex):

Returns
-------
union : BlockIndex
BlockIndex
"""
return BlockUnion(self, y.to_block_index()).result

Expand Down Expand Up @@ -548,8 +544,7 @@ cdef class BlockIndex(SparseIndex):
return -1

@cython.wraparound(False)
cpdef ndarray[int32_t] lookup_array(self, ndarray[
int32_t, ndim=1] indexer):
cpdef ndarray[int32_t] lookup_array(self, ndarray[int32_t, ndim=1] indexer):
"""
Vectorized lookup, returns ndarray[int32_t]
"""
Expand Down
5 changes: 2 additions & 3 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,11 @@ def ensure_datetime64ns(arr: ndarray, copy: bool=True):
Parameters
----------
arr : ndarray
copy : boolean, default True
copy : bool, default True

Returns
-------
result : ndarray with dtype datetime64[ns]

ndarray with dtype datetime64[ns]
"""
cdef:
Py_ssize_t i, n = arr.size
Expand Down
41 changes: 21 additions & 20 deletions pandas/_libs/tslibs/resolution.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def get_freq_group(freq) -> int:
"""
Return frequency code group of given frequency str or offset.

Example
-------
Examples
--------
>>> get_freq_group('W-MON')
4000

Expand Down Expand Up @@ -193,8 +193,8 @@ class Resolution:
"""
Return resolution str against resolution code.

Example
-------
Examples
--------
>>> Resolution.get_str(Resolution.RESO_SEC)
'second'
"""
Expand All @@ -205,8 +205,8 @@ class Resolution:
"""
Return resolution str against resolution code.

Example
-------
Examples
--------
>>> Resolution.get_reso('second')
2

Expand All @@ -220,8 +220,8 @@ class Resolution:
"""
Return frequency str against resolution str.

Example
-------
Examples
--------
>>> f.Resolution.get_freq_group('day')
4000
"""
Expand All @@ -232,8 +232,8 @@ class Resolution:
"""
Return frequency str against resolution str.

Example
-------
Examples
--------
>>> f.Resolution.get_freq('day')
'D'
"""
Expand All @@ -244,8 +244,8 @@ class Resolution:
"""
Return resolution str against frequency str.

Example
-------
Examples
--------
>>> Resolution.get_str_from_freq('H')
'hour'
"""
Expand All @@ -256,8 +256,8 @@ class Resolution:
"""
Return resolution code against frequency str.

Example
-------
Examples
--------
>>> Resolution.get_reso_from_freq('H')
4

Expand All @@ -273,17 +273,17 @@ class Resolution:

Parameters
----------
value : integer or float
freq : string
value : int or float
freq : str
Frequency string

Raises
------
ValueError
If the float cannot be converted to an integer at any resolution.

Example
-------
Examples
--------
>>> Resolution.get_stride_from_decimal(1.5, 'T')
(90, 'S')

Expand All @@ -298,8 +298,9 @@ class Resolution:
else:
start_reso = cls.get_reso_from_freq(freq)
if start_reso == 0:
raise ValueError("Could not convert to integer offset "
"at any resolution")
raise ValueError(
"Could not convert to integer offset at any resolution"
)

next_value = cls._reso_mult_map[start_reso] * value
next_name = cls._reso_str_bump_map[freq]
Expand Down
Loading