Skip to content

Commit 93fc052

Browse files
authored
Merge pull request #83 from pandas-dev/master
Sync Fork from Upstream Repo
2 parents 8523cfa + 684a291 commit 93fc052

File tree

8 files changed

+459
-115
lines changed

8 files changed

+459
-115
lines changed

ci/code_checks.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,6 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
267267
-k"-nonzero -reindex -searchsorted -to_dict"
268268
RET=$(($RET + $?)) ; echo $MSG "DONE"
269269

270-
MSG='Doctests generic.py' ; echo $MSG
271-
pytest -q --doctest-modules pandas/core/generic.py \
272-
-k"-_set_axis_name -_xs -describe -groupby -interpolate -pct_change -pipe -reindex -reindex_axis -to_json -transpose -values -xs -to_clipboard"
273-
RET=$(($RET + $?)) ; echo $MSG "DONE"
274-
275270
MSG='Doctests groupby.py' ; echo $MSG
276271
pytest -q --doctest-modules pandas/core/groupby/groupby.py -k"-cumcount -describe -pipe"
277272
RET=$(($RET + $?)) ; echo $MSG "DONE"
@@ -311,6 +306,17 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
311306
pytest -q --doctest-modules pandas/core/arrays/boolean.py
312307
RET=$(($RET + $?)) ; echo $MSG "DONE"
313308

309+
MSG='Doctests base.py' ; echo $MSG
310+
pytest -q --doctest-modules pandas/core/base.py
311+
RET=$(($RET + $?)) ; echo $MSG "DONE"
312+
313+
MSG='Doctests construction.py' ; echo $MSG
314+
pytest -q --doctest-modules pandas/core/construction.py
315+
RET=$(($RET + $?)) ; echo $MSG "DONE"
316+
317+
MSG='Doctests generic.py' ; echo $MSG
318+
pytest -q --doctest-modules pandas/core/generic.py
319+
RET=$(($RET + $?)) ; echo $MSG "DONE"
314320
fi
315321

316322
### DOCSTRINGS ###
@@ -320,6 +326,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
320326
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL03,GL04,GL05,GL06,GL07,GL09,GL10,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA02,SA03,SA05
321327
RET=$(($RET + $?)) ; echo $MSG "DONE"
322328

329+
MSG='Validate correct capitalization among titles in documentation' ; echo $MSG
330+
$BASE_DIR/scripts/validate_rst_title_capitalization.py $BASE_DIR/doc/source/development/contributing.rst
331+
RET=$(($RET + $?)) ; echo $MSG "DONE"
332+
323333
fi
324334

325335
### DEPENDENCIES ###

doc/source/development/contributing.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ requires a C compiler and Python environment. If you're making documentation
146146
changes, you can skip to :ref:`contributing.documentation` but you won't be able
147147
to build the documentation locally before pushing your changes.
148148

149-
Using a Docker Container
149+
Using a Docker container
150150
~~~~~~~~~~~~~~~~~~~~~~~~
151151

152152
Instead of manually setting up a development environment, you can use Docker to
@@ -754,7 +754,7 @@ You can then verify the changes look ok, then git :ref:`commit <contributing.com
754754

755755
.. _contributing.pre-commit:
756756

757-
Pre-Commit
757+
Pre-commit
758758
~~~~~~~~~~
759759

760760
You can run many of these styling checks manually as we have described above. However,
@@ -822,12 +822,12 @@ See :ref:`contributing.warnings` for more.
822822

823823
.. _contributing.type_hints:
824824

825-
Type Hints
825+
Type hints
826826
----------
827827

828828
*pandas* strongly encourages the use of :pep:`484` style type hints. New development should contain type hints and pull requests to annotate existing code are accepted as well!
829829

830-
Style Guidelines
830+
Style guidelines
831831
~~~~~~~~~~~~~~~~
832832

833833
Types imports should follow the ``from typing import ...`` convention. So rather than
@@ -903,7 +903,7 @@ The limitation here is that while a human can reasonably understand that ``is_nu
903903
904904
With custom types and inference this is not always possible so exceptions are made, but every effort should be exhausted to avoid ``cast`` before going down such paths.
905905

906-
Pandas-specific Types
906+
pandas-specific types
907907
~~~~~~~~~~~~~~~~~~~~~
908908

909909
Commonly used types specific to *pandas* will appear in `pandas._typing <https://github.com/pandas-dev/pandas/blob/master/pandas/_typing.py>`_ and you should use these where applicable. This module is private for now but ultimately this should be exposed to third party libraries who want to implement type checking against pandas.
@@ -919,7 +919,7 @@ For example, quite a few functions in *pandas* accept a ``dtype`` argument. This
919919
920920
This module will ultimately house types for repeatedly used concepts like "path-like", "array-like", "numeric", etc... and can also hold aliases for commonly appearing parameters like `axis`. Development of this module is active so be sure to refer to the source for the most up to date list of available types.
921921

922-
Validating Type Hints
922+
Validating type hints
923923
~~~~~~~~~~~~~~~~~~~~~
924924

925925
*pandas* uses `mypy <http://mypy-lang.org>`_ to statically analyze the code base and type hints. After making any change you can ensure your type hints are correct by running
@@ -1539,7 +1539,7 @@ The branch will still exist on GitHub, so to delete it there do::
15391539
.. _Gitter: https://gitter.im/pydata/pandas
15401540

15411541

1542-
Tips for a successful Pull Request
1542+
Tips for a successful pull request
15431543
==================================
15441544

15451545
If you have made it to the `Review your code`_ phase, one of the core contributors may

pandas/core/base.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,41 +1473,49 @@ def factorize(self, sort=False, na_sentinel=-1):
14731473
14741474
Examples
14751475
--------
1476-
>>> x = pd.Series([1, 2, 3])
1477-
>>> x
1476+
>>> ser = pd.Series([1, 2, 3])
1477+
>>> ser
14781478
0 1
14791479
1 2
14801480
2 3
14811481
dtype: int64
14821482
1483-
>>> x.searchsorted(4)
1483+
>>> ser.searchsorted(4)
14841484
3
14851485
1486-
>>> x.searchsorted([0, 4])
1486+
>>> ser.searchsorted([0, 4])
14871487
array([0, 3])
14881488
1489-
>>> x.searchsorted([1, 3], side='left')
1489+
>>> ser.searchsorted([1, 3], side='left')
14901490
array([0, 2])
14911491
1492-
>>> x.searchsorted([1, 3], side='right')
1492+
>>> ser.searchsorted([1, 3], side='right')
14931493
array([1, 3])
14941494
1495-
>>> x = pd.Categorical(['apple', 'bread', 'bread',
1496-
'cheese', 'milk'], ordered=True)
1495+
>>> ser = pd.Categorical(
1496+
... ['apple', 'bread', 'bread', 'cheese', 'milk'], ordered=True
1497+
... )
1498+
>>> ser
14971499
[apple, bread, bread, cheese, milk]
14981500
Categories (4, object): [apple < bread < cheese < milk]
14991501
1500-
>>> x.searchsorted('bread')
1502+
>>> ser.searchsorted('bread')
15011503
1
15021504
1503-
>>> x.searchsorted(['bread'], side='right')
1505+
>>> ser.searchsorted(['bread'], side='right')
15041506
array([3])
15051507
15061508
If the values are not monotonically sorted, wrong locations
15071509
may be returned:
15081510
1509-
>>> x = pd.Series([2, 1, 3])
1510-
>>> x.searchsorted(1)
1511+
>>> ser = pd.Series([2, 1, 3])
1512+
>>> ser
1513+
0 2
1514+
1 1
1515+
2 3
1516+
dtype: int64
1517+
1518+
>>> ser.searchsorted(1) # doctest: +SKIP
15111519
0 # wrong result, correct would be 1
15121520
"""
15131521

pandas/core/construction.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
These should not depend on core.internals.
66
"""
7+
78
from typing import TYPE_CHECKING, Any, Optional, Sequence, Union, cast
89

910
import numpy as np
@@ -200,12 +201,12 @@ def array(
200201
201202
>>> pd.array([1, 2, np.nan])
202203
<IntegerArray>
203-
[1, 2, NaN]
204+
[1, 2, <NA>]
204205
Length: 3, dtype: Int64
205206
206207
>>> pd.array(["a", None, "c"])
207208
<StringArray>
208-
['a', nan, 'c']
209+
['a', <NA>, 'c']
209210
Length: 3, dtype: string
210211
211212
>>> pd.array([pd.Period('2000', freq="D"), pd.Period("2000", freq="D")])

0 commit comments

Comments
 (0)