Skip to content

Commit f4de157

Browse files
committed
PEP: use triple-double-quotes rather than triple-single-quotes around doc-strings in cython
as per PEP closes #12994
1 parent 59082e9 commit f4de157

31 files changed

+334
-345
lines changed

pandas/algos.pyx

+18-18
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,9 @@ cdef inline kth_smallest_c(float64_t* a, Py_ssize_t k, Py_ssize_t n):
838838

839839

840840
cpdef numeric median(numeric[:] arr):
841-
'''
841+
"""
842842
A faster median
843-
'''
843+
"""
844844
cdef Py_ssize_t n = arr.size
845845

846846
if n == 0:
@@ -999,7 +999,7 @@ def roll_mean(ndarray[double_t] input,
999999
# Exponentially weighted moving average
10001000

10011001
def ewma(ndarray[double_t] input, double_t com, int adjust, int ignore_na, int minp):
1002-
'''
1002+
"""
10031003
Compute exponentially-weighted moving average using center-of-mass.
10041004
10051005
Parameters
@@ -1013,7 +1013,7 @@ def ewma(ndarray[double_t] input, double_t com, int adjust, int ignore_na, int m
10131013
Returns
10141014
-------
10151015
y : ndarray
1016-
'''
1016+
"""
10171017

10181018
cdef Py_ssize_t N = len(input)
10191019
cdef ndarray[double_t] output = np.empty(N, dtype=float)
@@ -1061,7 +1061,7 @@ def ewma(ndarray[double_t] input, double_t com, int adjust, int ignore_na, int m
10611061

10621062
def ewmcov(ndarray[double_t] input_x, ndarray[double_t] input_y,
10631063
double_t com, int adjust, int ignore_na, int minp, int bias):
1064-
'''
1064+
"""
10651065
Compute exponentially-weighted moving variance using center-of-mass.
10661066
10671067
Parameters
@@ -1077,7 +1077,7 @@ def ewmcov(ndarray[double_t] input_x, ndarray[double_t] input_y,
10771077
Returns
10781078
-------
10791079
y : ndarray
1080-
'''
1080+
"""
10811081

10821082
cdef Py_ssize_t N = len(input_x)
10831083
if len(input_y) != N:
@@ -1761,9 +1761,9 @@ cdef _roll_min_max(ndarray[numeric] a, int window, int minp, bint is_max):
17611761

17621762
def roll_quantile(ndarray[float64_t, cast=True] input, int win,
17631763
int minp, double quantile):
1764-
'''
1764+
"""
17651765
O(N log(window)) implementation using skip list
1766-
'''
1766+
"""
17671767
cdef double val, prev, midpoint
17681768
cdef IndexableSkiplist skiplist
17691769
cdef Py_ssize_t nobs = 0, i
@@ -1997,12 +1997,12 @@ def groupby_indices(ndarray values):
19971997
@cython.wraparound(False)
19981998
@cython.boundscheck(False)
19991999
def group_labels(ndarray[object] values):
2000-
'''
2000+
"""
20012001
Compute label vector from input values and associated useful data
20022002
20032003
Returns
20042004
-------
2005-
'''
2005+
"""
20062006
cdef:
20072007
Py_ssize_t i, n = len(values)
20082008
ndarray[int64_t] labels = np.empty(n, dtype=np.int64)
@@ -2074,9 +2074,9 @@ def group_nth_object(ndarray[object, ndim=2] out,
20742074
ndarray[object, ndim=2] values,
20752075
ndarray[int64_t] labels,
20762076
int64_t rank):
2077-
'''
2077+
"""
20782078
Only aggregates on axis=0
2079-
'''
2079+
"""
20802080
cdef:
20812081
Py_ssize_t i, j, N, K, lab
20822082
object val
@@ -2117,9 +2117,9 @@ def group_nth_bin_object(ndarray[object, ndim=2] out,
21172117
ndarray[int64_t] counts,
21182118
ndarray[object, ndim=2] values,
21192119
ndarray[int64_t] bins, int64_t rank):
2120-
'''
2120+
"""
21212121
Only aggregates on axis=0
2122-
'''
2122+
"""
21232123
cdef:
21242124
Py_ssize_t i, j, N, K, ngroups, b
21252125
object val
@@ -2167,9 +2167,9 @@ def group_last_object(ndarray[object, ndim=2] out,
21672167
ndarray[int64_t] counts,
21682168
ndarray[object, ndim=2] values,
21692169
ndarray[int64_t] labels):
2170-
'''
2170+
"""
21712171
Only aggregates on axis=0
2172-
'''
2172+
"""
21732173
cdef:
21742174
Py_ssize_t i, j, N, K, lab
21752175
object val
@@ -2209,9 +2209,9 @@ def group_last_bin_object(ndarray[object, ndim=2] out,
22092209
ndarray[int64_t] counts,
22102210
ndarray[object, ndim=2] values,
22112211
ndarray[int64_t] bins):
2212-
'''
2212+
"""
22132213
Only aggregates on axis=0
2214-
'''
2214+
"""
22152215
cdef:
22162216
Py_ssize_t i, j, N, K, ngroups, b
22172217
object val

pandas/compat/chainmap_impl.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def wrapper(self):
3333

3434

3535
class ChainMap(MutableMapping):
36-
''' A ChainMap groups multiple dicts (or other mappings) together
36+
""" A ChainMap groups multiple dicts (or other mappings) together
3737
to create a single, updateable view.
3838
3939
The underlying mappings are stored in a list. That list is public and can
@@ -43,13 +43,13 @@ class ChainMap(MutableMapping):
4343
In contrast, writes, updates, and deletions only operate on the first
4444
mapping.
4545
46-
'''
46+
"""
4747

4848
def __init__(self, *maps):
49-
'''Initialize a ChainMap by setting *maps* to the given mappings.
49+
"""Initialize a ChainMap by setting *maps* to the given mappings.
5050
If no mappings are provided, a single empty dictionary is used.
5151
52-
'''
52+
"""
5353
self.maps = list(maps) or [{}] # always at least one map
5454

5555
def __missing__(self, key):
@@ -101,10 +101,10 @@ def copy(self):
101101
__copy__ = copy
102102

103103
def new_child(self, m=None): # like Django's Context.push()
104-
'''
104+
"""
105105
New ChainMap with a new map followed by all previous maps. If no
106106
map is provided, an empty dict is used.
107-
'''
107+
"""
108108
if m is None:
109109
m = {}
110110
return self.__class__(m, *self.maps)

pandas/core/groupby.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1566,10 +1566,9 @@ def size(self):
15661566

15671567
@cache_readonly
15681568
def _max_groupsize(self):
1569-
'''
1569+
"""
15701570
Compute size of largest group
1571-
1572-
'''
1571+
"""
15731572
# For many items in each group this is much faster than
15741573
# self.size().max(), in worst case marginally slower
15751574
if self.indices:

pandas/core/series.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1129,15 +1129,15 @@ def to_sparse(self, kind='block', fill_value=None):
11291129
fill_value=fill_value).__finalize__(self)
11301130

11311131
def _set_name(self, name, inplace=False):
1132-
'''
1132+
"""
11331133
Set the Series name.
11341134
11351135
Parameters
11361136
----------
11371137
name : str
11381138
inplace : bool
11391139
whether to modify `self` directly or return a copy
1140-
'''
1140+
"""
11411141
ser = self if inplace else self.copy()
11421142
ser.name = name
11431143
return ser

pandas/index.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ cdef class IndexEngine:
101101
return val in self.mapping
102102

103103
cpdef get_value(self, ndarray arr, object key, object tz=None):
104-
'''
104+
"""
105105
arr : 1-dimensional ndarray
106-
'''
106+
"""
107107
cdef:
108108
object loc
109109
void* data_ptr
@@ -119,9 +119,9 @@ cdef class IndexEngine:
119119
return util.get_value_at(arr, loc)
120120

121121
cpdef set_value(self, ndarray arr, object key, object value):
122-
'''
122+
"""
123123
arr : 1-dimensional ndarray
124-
'''
124+
"""
125125
cdef:
126126
object loc
127127
void* data_ptr

pandas/indexes/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2569,10 +2569,10 @@ def _join_level(self, other, level, how='left', return_indexers=False,
25692569
from .multi import MultiIndex
25702570

25712571
def _get_leaf_sorter(labels):
2572-
'''
2572+
"""
25732573
returns sorter for the inner most level while preserving the
25742574
order of higher levels
2575-
'''
2575+
"""
25762576
if labels[0].size == 0:
25772577
return np.empty(0, dtype='int64')
25782578

pandas/indexes/multi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ def get_loc(self, key, method=None):
15281528
'currently supported for MultiIndex')
15291529

15301530
def _maybe_to_slice(loc):
1531-
'''convert integer indexer to boolean mask or slice if possible'''
1531+
"""convert integer indexer to boolean mask or slice if possible"""
15321532
if not isinstance(loc, np.ndarray) or loc.dtype != 'int64':
15331533
return loc
15341534

pandas/io/tests/test_sql.py

-4
Original file line numberDiff line numberDiff line change
@@ -2385,8 +2385,6 @@ def test_uquery(self):
23852385
sys.stdout = sys.__stdout__
23862386

23872387
def test_keyword_as_column_names(self):
2388-
'''
2389-
'''
23902388
df = DataFrame({'From': np.ones(5)})
23912389
sql.to_sql(df, con=self.conn, name='testkeywords', index=False)
23922390

@@ -2751,8 +2749,6 @@ def test_uquery(self):
27512749
sys.stdout = sys.__stdout__
27522750

27532751
def test_keyword_as_column_names(self):
2754-
'''
2755-
'''
27562752
_skip_if_no_pymysql()
27572753
df = DataFrame({'From': np.ones(5)})
27582754
sql.to_sql(df, con=self.conn, name='testkeywords',

pandas/io/wb.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ def _get_data(indicator="NY.GNS.ICTR.GN.ZS", country='US',
228228
return out,"Success"
229229

230230
def get_countries():
231-
'''Query information about countries
232-
'''
231+
"""Query information about countries
232+
"""
233233
url = 'http://api.worldbank.org/countries/?per_page=1000&format=json'
234234
with urlopen(url) as response:
235235
data = response.read()
@@ -243,8 +243,8 @@ def get_countries():
243243
return data
244244

245245
def get_indicators():
246-
'''Download information about all World Bank data series
247-
'''
246+
"""Download information about all World Bank data series
247+
"""
248248
url = 'http://api.worldbank.org/indicators?per_page=50000&format=json'
249249
with urlopen(url) as response:
250250
data = response.read()

pandas/lib.pyx

+14-14
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ def values_from_object(object o):
9595
return o
9696

9797
cpdef map_indices_list(list index):
98-
'''
98+
"""
9999
Produce a dict mapping the values of the input array to their respective
100100
locations.
101101
102102
Example:
103103
array(['hi', 'there']) --> {'hi' : 0 , 'there' : 1}
104104
105105
Better to do this with Cython because of the enormous speed boost.
106-
'''
106+
"""
107107
cdef Py_ssize_t i, length
108108
cdef dict result = {}
109109

@@ -134,7 +134,7 @@ def ismember_nans(float64_t[:] arr, set values, bint hasnans):
134134

135135

136136
def ismember(ndarray arr, set values):
137-
'''
137+
"""
138138
Checks whether
139139
140140
Parameters
@@ -145,7 +145,7 @@ def ismember(ndarray arr, set values):
145145
Returns
146146
-------
147147
ismember : ndarray (boolean dtype)
148-
'''
148+
"""
149149
cdef:
150150
Py_ssize_t i, n
151151
ndarray[uint8_t] result
@@ -160,7 +160,7 @@ def ismember(ndarray arr, set values):
160160
return result.view(np.bool_)
161161

162162
def ismember_int64(ndarray[int64_t] arr, set values):
163-
'''
163+
"""
164164
Checks whether
165165
166166
Parameters
@@ -171,7 +171,7 @@ def ismember_int64(ndarray[int64_t] arr, set values):
171171
Returns
172172
-------
173173
ismember : ndarray (boolean dtype)
174-
'''
174+
"""
175175
cdef:
176176
Py_ssize_t i, n
177177
ndarray[uint8_t] result
@@ -404,10 +404,10 @@ def isnullobj2d_old(ndarray[object, ndim=2] arr):
404404
@cython.wraparound(False)
405405
@cython.boundscheck(False)
406406
cpdef ndarray[object] list_to_object_array(list obj):
407-
'''
407+
"""
408408
Convert list to object ndarray. Seriously can\'t believe I had to write this
409409
function
410-
'''
410+
"""
411411
cdef:
412412
Py_ssize_t i, n = len(obj)
413413
ndarray[object] arr = np.empty(n, dtype=object)
@@ -542,9 +542,9 @@ def dicts_to_array(list dicts, list columns):
542542
return result
543543

544544
def fast_zip(list ndarrays):
545-
'''
545+
"""
546546
For zipping multiple ndarrays into an ndarray of tuples
547-
'''
547+
"""
548548
cdef:
549549
Py_ssize_t i, j, k, n
550550
ndarray[object] result
@@ -959,9 +959,9 @@ cpdef ndarray[object] astype_str(ndarray arr):
959959
return result
960960

961961
def clean_index_list(list obj):
962-
'''
962+
"""
963963
Utility used in pandas.core.index._ensure_index
964-
'''
964+
"""
965965
cdef:
966966
ndarray[object] converted
967967
Py_ssize_t i, n = len(obj)
@@ -1325,9 +1325,9 @@ cdef class _PandasNull:
13251325
pandas_null = _PandasNull()
13261326

13271327
def fast_zip_fillna(list ndarrays, fill_value=pandas_null):
1328-
'''
1328+
"""
13291329
For zipping multiple ndarrays into an ndarray of tuples
1330-
'''
1330+
"""
13311331
cdef:
13321332
Py_ssize_t i, j, k, n
13331333
ndarray[object] result

pandas/parser.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ _NA_VALUES = [b'-1.#IND', b'1.#QNAN', b'1.#IND', b'-1.#QNAN',
248248

249249

250250
cdef class TextReader:
251-
'''
251+
"""
252252
253253
# source: StringIO or file object
254254
255-
'''
255+
"""
256256

257257
cdef:
258258
parser_t *parser

0 commit comments

Comments
 (0)