Skip to content

Commit 6917234

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into tslibs-conversion11
2 parents 8170c8d + 17e0b13 commit 6917234

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+149
-2376
lines changed

ci/lint.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RET=0
99
if [ "$LINT" ]; then
1010

1111
# pandas/_libs/src is C code, so no need to search there.
12-
echo "Linting *.py"
12+
echo "Linting *.py"
1313
flake8 pandas --filename=*.py --exclude pandas/_libs/src
1414
if [ $? -ne "0" ]; then
1515
RET=1
@@ -38,10 +38,20 @@ if [ "$LINT" ]; then
3838
if [ $? -ne "0" ]; then
3939
RET=1
4040
fi
41-
4241
done
4342
echo "Linting *.pxi.in DONE"
4443

44+
echo "Linting *.pxd"
45+
for path in '_libs'
46+
do
47+
echo "linting -> pandas/$path"
48+
flake8 pandas/$path --filename=*.pxd --select=E501,E302,E203,E111,E114,E221,E303,E231,E126,F403
49+
if [ $? -ne "0" ]; then
50+
RET=1
51+
fi
52+
done
53+
echo "Linting *.pxd DONE"
54+
4555
# readability/casting: Warnings about C casting instead of C++ casting
4656
# runtime/int: Warnings about using C number types instead of C++ ones
4757
# build/include_subdir: Warnings about prefacing included header files with directory

doc/source/api.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ Interval
18221822
Properties
18231823
~~~~~~~~~~
18241824
.. autosummary::
1825-
:toctree generated/
1825+
:toctree: generated/
18261826

18271827
Interval.closed
18281828
Interval.closed_left
@@ -1843,7 +1843,7 @@ Timedelta
18431843
Properties
18441844
~~~~~~~~~~
18451845
.. autosummary::
1846-
:toctree generated/
1846+
:toctree: generated/
18471847

18481848
Timedelta.asm8
18491849
Timedelta.components
@@ -1860,7 +1860,7 @@ Properties
18601860
Methods
18611861
~~~~~~~
18621862
.. autosummary::
1863-
:toctree generated/
1863+
:toctree: generated/
18641864

18651865
Timedelta.ceil
18661866
Timedelta.floor

doc/source/computation.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ columns of a ``DataFrame``:
670670

671671
.. ipython:: python
672672
:okexcept:
673+
:okwarning:
673674
674675
r.agg({'A' : np.sum,
675676
'B' : lambda x: np.std(x, ddof=1)})

doc/source/conf.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,12 @@
358358
# latex_use_modindex = True
359359

360360

361-
# Example configuration for intersphinx: refer to the Python standard library.
362361
intersphinx_mapping = {
363362
'statsmodels': ('http://www.statsmodels.org/devel/', None),
364363
'matplotlib': ('http://matplotlib.org/', None),
365-
'python': ('http://docs.python.org/3', None),
366-
'numpy': ('http://docs.scipy.org/doc/numpy', None),
367-
'scipy': ('http://docs.scipy.org/doc/scipy/reference', None),
364+
'python': ('https://docs.python.org/3/', None),
365+
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
366+
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
368367
'py': ('https://pylib.readthedocs.io/en/latest/', None)
369368
}
370369
import glob
@@ -573,6 +572,15 @@ def remove_flags_docstring(app, what, name, obj, options, lines):
573572
if what == "attribute" and name.endswith(".flags"):
574573
del lines[:]
575574

575+
576+
suppress_warnings = [
577+
# We "overwrite" autosummary with our PandasAutosummary, but
578+
# still want the regular autosummary setup to run. So we just
579+
# suppress this warning.
580+
'app.add_directive'
581+
]
582+
583+
576584
def setup(app):
577585
app.connect("autodoc-process-docstring", remove_flags_docstring)
578586
app.add_autodocumenter(AccessorDocumenter)

doc/source/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Bug reports must:
6060

6161
The issue will then show up to the *pandas* community and be open to comments/ideas from others.
6262

63-
.. _contributing.github
63+
.. _contributing.github:
6464

6565
Working with the code
6666
=====================

doc/source/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ header : int or list of ints, default ``'infer'``
115115
names : array-like, default ``None``
116116
List of column names to use. If file contains no header row, then you should
117117
explicitly pass ``header=None``. Duplicates in this list will cause
118-
a ``UserWarning`` to be issued.
118+
a ``UserWarning`` to be issued.
119119
index_col : int or sequence or ``False``, default ``None``
120120
Column to use as the row labels of the DataFrame. If a sequence is given, a
121121
MultiIndex is used. If you have a malformed file with delimiters at the end of

doc/source/whatsnew/v0.15.2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Other enhancements:
163163
p.all()
164164

165165
- Added support for ``utcfromtimestamp()``, ``fromtimestamp()``, and ``combine()`` on `Timestamp` class (:issue:`5351`).
166-
- Added Google Analytics (`pandas.io.ga`) basic documentation (:issue:`8835`). See `here<http://pandas.pydata.org/pandas-docs/version/0.15.2/remote_data.html#remote-data-ga>`__.
166+
- Added Google Analytics (`pandas.io.ga`) basic documentation (:issue:`8835`). See `here <http://pandas.pydata.org/pandas-docs/version/0.15.2/remote_data.html#remote-data-ga>`__.
167167
- ``Timedelta`` arithmetic returns ``NotImplemented`` in unknown cases, allowing extensions by custom classes (:issue:`8813`).
168168
- ``Timedelta`` now supports arithemtic with ``numpy.ndarray`` objects of the appropriate dtype (numpy 1.8 or newer only) (:issue:`8884`).
169169
- Added ``Timedelta.to_timedelta64()`` method to the public API (:issue:`8884`).

doc/source/whatsnew/v0.19.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ contained the values ``[0, 3]``.
216216
**New behavior**:
217217

218218
.. ipython:: python
219+
:okwarning:
219220

220221
pd.read_csv(StringIO(data), names=names)
221222

doc/source/whatsnew/v0.20.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,7 @@ Convert to a MultiIndex DataFrame
13751375
Convert to an xarray DataArray
13761376

13771377
.. ipython:: python
1378+
:okwarning:
13781379

13791380
p.to_xarray()
13801381

pandas/_libs/period.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ cdef class _Period(object):
967967
def strftime(self, fmt):
968968
"""
969969
Returns the string representation of the :class:`Period`, depending
970-
on the selected :keyword:`format`. :keyword:`format` must be a string
970+
on the selected ``fmt``. ``fmt`` must be a string
971971
containing one or several directives. The method recognizes the same
972972
directives as the :func:`time.strftime` function of the standard Python
973973
distribution, as well as the specific additional directives ``%f``,

pandas/_libs/src/datetime.pxd

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ cdef extern from "datetime/np_datetime.h":
4444
npy_int64 year
4545
npy_int32 month, day, hour, min, sec, us, ps, as
4646

47-
npy_datetime pandas_datetimestruct_to_datetime(PANDAS_DATETIMEUNIT fr,
48-
pandas_datetimestruct *d) nogil
47+
npy_datetime pandas_datetimestruct_to_datetime(
48+
PANDAS_DATETIMEUNIT fr, pandas_datetimestruct *d) nogil
49+
4950
void pandas_datetime_to_datetimestruct(npy_datetime val,
5051
PANDAS_DATETIMEUNIT fr,
5152
pandas_datetimestruct *result) nogil
@@ -58,12 +59,12 @@ cdef extern from "datetime/np_datetime.h":
5859
cdef extern from "datetime/np_datetime_strings.h":
5960

6061
int parse_iso_8601_datetime(char *str, int len, PANDAS_DATETIMEUNIT unit,
61-
NPY_CASTING casting, pandas_datetimestruct *out,
62+
NPY_CASTING casting,
63+
pandas_datetimestruct *out,
6264
int *out_local, int *out_tzoffset,
6365
PANDAS_DATETIMEUNIT *out_bestunit,
6466
npy_bool *out_special)
6567

66-
6768
cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts,
6869
int* out_local, int* out_tzoffset) except? -1:
6970
cdef int result
@@ -89,5 +90,6 @@ cdef inline int _cstring_to_dts(char *val, int length,
8990

9091
result = parse_iso_8601_datetime(val, length, PANDAS_FR_ns,
9192
NPY_UNSAFE_CASTING,
92-
dts, out_local, out_tzoffset, &out_bestunit, &special)
93+
dts, out_local, out_tzoffset,
94+
&out_bestunit, &special)
9395
return result

pandas/_libs/src/numpy.pxd

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ cdef extern from "numpy/arrayobject.h":
152152

153153
npy_intp NPY_MAX_ELSIZE
154154

155-
ctypedef void (*PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *, void *)
155+
ctypedef void (*PyArray_VectorUnaryFunc)(
156+
void *, void *, npy_intp, void *, void *)
156157

157158
ctypedef class numpy.dtype [object PyArray_Descr]:
158159
# Use PyDataType_* macros when possible, however there are no macros
@@ -225,7 +226,9 @@ cdef extern from "numpy/arrayobject.h":
225226
if copy_shape:
226227
# Allocate new buffer for strides and shape info.
227228
# This is allocated as one block, strides first.
228-
info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
229+
info.strides = <Py_ssize_t*>stdlib.malloc(
230+
sizeof(Py_ssize_t) * <size_t>ndim * 2)
231+
229232
info.shape = info.strides + ndim
230233
for i in range(ndim):
231234
info.strides[i] = PyArray_STRIDES(self)[i]
@@ -275,7 +278,8 @@ cdef extern from "numpy/arrayobject.h":
275278
elif t == NPY_CLONGDOUBLE: f = "Zg"
276279
elif t == NPY_OBJECT: f = "O"
277280
else:
278-
raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
281+
raise ValueError(
282+
u"unknown dtype code in numpy.pxd (%d)" % t)
279283
info.format = f
280284
return
281285
else:
@@ -294,7 +298,6 @@ cdef extern from "numpy/arrayobject.h":
294298
stdlib.free(info.strides)
295299
# info.shape was stored after info.strides in the same block
296300

297-
298301
ctypedef signed char npy_bool
299302

300303
ctypedef signed char npy_byte
@@ -462,7 +465,6 @@ cdef extern from "numpy/arrayobject.h":
462465
bint PyArray_ISBEHAVED(ndarray)
463466
bint PyArray_ISBEHAVED_RO(ndarray)
464467

465-
466468
bint PyDataType_ISNOTSWAPPED(dtype)
467469
bint PyDataType_ISBYTESWAPPED(dtype)
468470

@@ -475,7 +477,6 @@ cdef extern from "numpy/arrayobject.h":
475477
# bint PyArray_HasArrayInterfaceType(object, dtype, object, object&)
476478
# bint PyArray_HasArrayInterface(op, out)
477479

478-
479480
bint PyArray_IsZeroDim(object)
480481
# Cannot be supported due to ## ## in macro:
481482
# bint PyArray_IsScalar(object, verbatim work)
@@ -502,24 +503,28 @@ cdef extern from "numpy/arrayobject.h":
502503
unsigned char PyArray_EquivArrTypes(ndarray a1, ndarray a2)
503504
bint PyArray_EquivByteorders(int b1, int b2)
504505
object PyArray_SimpleNew(int nd, npy_intp* dims, int typenum)
505-
object PyArray_SimpleNewFromData(int nd, npy_intp* dims, int typenum, void* data)
506+
object PyArray_SimpleNewFromData(int nd, npy_intp* dims,
507+
int typenum, void* data)
506508
#object PyArray_SimpleNewFromDescr(int nd, npy_intp* dims, dtype descr)
507509
object PyArray_ToScalar(void* data, ndarray arr)
508510

509511
void* PyArray_GETPTR1(ndarray m, npy_intp i)
510512
void* PyArray_GETPTR2(ndarray m, npy_intp i, npy_intp j)
511513
void* PyArray_GETPTR3(ndarray m, npy_intp i, npy_intp j, npy_intp k)
512-
void* PyArray_GETPTR4(ndarray m, npy_intp i, npy_intp j, npy_intp k, npy_intp l)
514+
void* PyArray_GETPTR4(ndarray m, npy_intp i,
515+
npy_intp j, npy_intp k, npy_intp l)
513516

514517
void PyArray_XDECREF_ERR(ndarray)
515518
# Cannot be supported due to out arg
516519
# void PyArray_DESCR_REPLACE(descr)
517520

518-
519521
object PyArray_Copy(ndarray)
520-
object PyArray_FromObject(object op, int type, int min_depth, int max_depth)
521-
object PyArray_ContiguousFromObject(object op, int type, int min_depth, int max_depth)
522-
object PyArray_CopyFromObject(object op, int type, int min_depth, int max_depth)
522+
object PyArray_FromObject(object op, int type,
523+
int min_depth, int max_depth)
524+
object PyArray_ContiguousFromObject(object op, int type,
525+
int min_depth, int max_depth)
526+
object PyArray_CopyFromObject(object op, int type,
527+
int min_depth, int max_depth)
523528

524529
object PyArray_Cast(ndarray mp, int type_num)
525530
object PyArray_Take(ndarray ap, object items, int axis)
@@ -598,8 +603,8 @@ cdef extern from "numpy/arrayobject.h":
598603
object PyArray_Dumps (object, int)
599604
int PyArray_ValidType (int)
600605
void PyArray_UpdateFlags (ndarray, int)
601-
object PyArray_New (type, int, npy_intp *, int, npy_intp *, void *, int, int, object)
602-
#object PyArray_NewFromDescr (type, dtype, int, npy_intp *, npy_intp *, void *, int, object)
606+
object PyArray_New (type, int, npy_intp *, int, npy_intp *,
607+
void *, int, int, object)
603608
#dtype PyArray_DescrNew (dtype)
604609
dtype PyArray_DescrNewFromType (int)
605610
double PyArray_GetPriority (object, double)
@@ -611,7 +616,8 @@ cdef extern from "numpy/arrayobject.h":
611616
int PyArray_Broadcast (broadcast)
612617
void PyArray_FillObjectArray (ndarray, object)
613618
int PyArray_FillWithScalar (ndarray, object)
614-
npy_bool PyArray_CheckStrides (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *)
619+
npy_bool PyArray_CheckStrides (
620+
int, int, npy_intp, npy_intp, npy_intp *, npy_intp *)
615621
dtype PyArray_DescrNewByteorder (dtype, char)
616622
object PyArray_IterAllButAxis (object, int *)
617623
#object PyArray_CheckFromAny (object, dtype, int, int, int, object)
@@ -782,9 +788,11 @@ cdef inline object PyArray_MultiIterNew4(a, b, c, d):
782788
return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
783789

784790
cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
785-
return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
791+
return PyArray_MultiIterNew(5, <void*>a, <void*>b,
792+
<void*>c, <void*> d, <void*> e)
786793

787-
cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
794+
cdef inline char* _util_dtypestring(dtype descr, char* f,
795+
char* end, int* offset) except NULL:
788796
# Recursive utility function used in __getbuffer__ to get format
789797
# string. The new location in the format string is returned.
790798

@@ -800,7 +808,8 @@ cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset
800808
child, new_offset = fields
801809

802810
if (end - f) - (new_offset - offset[0]) < 15:
803-
raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
811+
raise RuntimeError(
812+
u"Format string allocated too short, see comment in numpy.pxd")
804813

805814
if ((child.byteorder == '>' and little_endian) or
806815
(child.byteorder == '<' and not little_endian)):
@@ -860,7 +869,8 @@ cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset
860869

861870
cdef extern from "numpy/ufuncobject.h":
862871

863-
ctypedef void (*PyUFuncGenericFunction) (char **, npy_intp *, npy_intp *, void *)
872+
ctypedef void (*PyUFuncGenericFunction) (char **, npy_intp *,
873+
npy_intp *, void *)
864874

865875
ctypedef extern class numpy.ufunc [object PyUFuncObject]:
866876
cdef:
@@ -968,14 +978,14 @@ cdef extern from "numpy/ufuncobject.h":
968978

969979

970980
cdef inline void set_array_base(ndarray arr, object base):
971-
cdef PyObject* baseptr
972-
if base is None:
973-
baseptr = NULL
974-
else:
975-
Py_INCREF(base) # important to do this before decref below!
976-
baseptr = <PyObject*>base
977-
Py_XDECREF(arr.base)
978-
arr.base = baseptr
981+
cdef PyObject* baseptr
982+
if base is None:
983+
baseptr = NULL
984+
else:
985+
Py_INCREF(base) # important to do this before decref below!
986+
baseptr = <PyObject*>base
987+
Py_XDECREF(arr.base)
988+
arr.base = baseptr
979989

980990
cdef inline object get_array_base(ndarray arr):
981991
if arr.base is NULL:

pandas/_libs/src/util.pxd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ cdef inline bint _checknull_old(object val):
115115
cdef double INF = <double> np.inf
116116
cdef double NEGINF = -INF
117117
try:
118-
return val is None or (cpython.PyFloat_Check(val) and (val != val or val == INF or val == NEGINF))
118+
return val is None or (cpython.PyFloat_Check(val) and
119+
(val != val or val == INF or val == NEGINF))
119120
except ValueError:
120121
return False
121122

0 commit comments

Comments
 (0)