Skip to content

DOC: Cleaned pandas/_libs/algos.pyx docstrings #30155

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
Dec 10, 2019
Merged
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
32 changes: 18 additions & 14 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ from libc.stdlib cimport malloc, free
from libc.string cimport memmove
from libc.math cimport fabs, sqrt

from typing import Tuple

import numpy as np
cimport numpy as cnp
from numpy cimport (ndarray,
Expand Down Expand Up @@ -49,8 +51,9 @@ cdef inline bint are_diff(object left, object right):


class Infinity:
""" provide a positive Infinity comparison method for ranking """

"""
Provide a positive Infinity comparison method for ranking.
"""
__lt__ = lambda self, other: False
__le__ = lambda self, other: isinstance(other, Infinity)
__eq__ = lambda self, other: isinstance(other, Infinity)
Expand All @@ -61,8 +64,9 @@ class Infinity:


class NegInfinity:
""" provide a negative Infinity comparison method for ranking """

"""
Provide a negative Infinity comparison method for ranking.
"""
__lt__ = lambda self, other: (not isinstance(other, NegInfinity) and
not missing.checknull(other))
__le__ = lambda self, other: not missing.checknull(other)
Expand Down Expand Up @@ -158,20 +162,19 @@ def groupsort_indexer(const int64_t[:] index, Py_ssize_t ngroups):
Parameters
----------
index: int64 ndarray
mappings from group -> position
Mappings from group -> position.
ngroups: int64
number of groups
Number of groups.

Returns
-------
tuple
1-d indexer ordered by groups, group counts
1-d indexer ordered by groups, group counts.

Notes
-----
This is a reverse of the label factorization process.
"""

cdef:
Py_ssize_t i, loc, label, n
ndarray[int64_t] counts, where, result
Expand Down Expand Up @@ -674,12 +677,15 @@ def backfill_2d_inplace(algos_t[:, :] values,

@cython.boundscheck(False)
@cython.wraparound(False)
def is_monotonic(ndarray[algos_t, ndim=1] arr, bint timelike):
def is_monotonic(ndarray[algos_t, ndim=1] arr,
bint timelike) -> Tuple[bool, bool, bool]:
"""
Returns
-------
tuple
is_monotonic_inc, is_monotonic_dec, is_unique
is_monotonic_inc : bool
is_monotonic_dec : bool
is_unique : bool
"""
cdef:
Py_ssize_t i, n
Expand Down Expand Up @@ -774,9 +780,8 @@ ctypedef fused rank_t:
def rank_1d(rank_t[:] in_arr, ties_method='average',
ascending=True, na_option='keep', pct=False):
"""
Fast NaN-friendly version of scipy.stats.rankdata
Fast NaN-friendly version of ``scipy.stats.rankdata``.
"""

cdef:
Py_ssize_t i, j, n, dups = 0, total_tie_count = 0, non_na_idx = 0

Expand Down Expand Up @@ -995,9 +1000,8 @@ def rank_1d(rank_t[:] in_arr, ties_method='average',
def rank_2d(rank_t[:, :] in_arr, axis=0, ties_method='average',
ascending=True, na_option='keep', pct=False):
"""
Fast NaN-friendly version of scipy.stats.rankdata
Fast NaN-friendly version of ``scipy.stats.rankdata``.
"""

cdef:
Py_ssize_t i, j, z, k, n, dups = 0, total_tie_count = 0

Expand Down