Skip to content

Commit 025edf1

Browse files
authored
Merge pull request #150 from pandas-dev/master
Sync Fork from Upstream Repo
2 parents f40ed9d + 38640d1 commit 025edf1

Some content is hidden

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

55 files changed

+488
-529
lines changed

.github/workflows/ci.yml

+8-37
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ jobs:
141141
data_manager:
142142
name: Test experimental data manager
143143
runs-on: ubuntu-latest
144+
strategy:
145+
matrix:
146+
pattern: ["not slow and not network and not clipboard", "slow"]
144147
steps:
145148

146149
- name: Checkout
@@ -152,43 +155,11 @@ jobs:
152155
- name: Run tests
153156
env:
154157
PANDAS_DATA_MANAGER: array
158+
PATTERN: ${{ matrix.pattern }}
159+
PYTEST_WORKERS: "auto"
155160
run: |
156161
source activate pandas-dev
162+
ci/run_tests.sh
157163
158-
pytest pandas/tests/frame/
159-
pytest pandas/tests/reductions/
160-
pytest pandas/tests/generic/test_generic.py
161-
pytest pandas/tests/arithmetic/
162-
pytest pandas/tests/groupby/
163-
pytest pandas/tests/resample/
164-
pytest pandas/tests/reshape/merge
165-
pytest pandas/tests/series/
166-
pytest pandas/tests/indexing/
167-
168-
pytest pandas/tests/test_*
169-
pytest pandas/tests/api/
170-
pytest pandas/tests/apply/
171-
pytest pandas/tests/arrays/
172-
pytest pandas/tests/base/
173-
pytest pandas/tests/computation/
174-
pytest pandas/tests/config/
175-
pytest pandas/tests/dtypes/
176-
pytest pandas/tests/extension/
177-
pytest pandas/tests/generic/
178-
pytest pandas/tests/indexes/
179-
pytest pandas/tests/internals/
180-
pytest pandas/tests/io/test_* -m "not slow and not clipboard"
181-
pytest pandas/tests/io/excel/ -m "not slow and not clipboard"
182-
pytest pandas/tests/io/formats/ -m "not slow and not clipboard"
183-
pytest pandas/tests/io/parser/ -m "not slow and not clipboard"
184-
pytest pandas/tests/io/sas/ -m "not slow and not clipboard"
185-
pytest pandas/tests/io/xml/ -m "not slow and not clipboard"
186-
pytest pandas/tests/libs/
187-
pytest pandas/tests/plotting/
188-
pytest pandas/tests/scalar/
189-
pytest pandas/tests/strings/
190-
pytest pandas/tests/tools/
191-
pytest pandas/tests/tseries/
192-
pytest pandas/tests/tslibs/
193-
pytest pandas/tests/util/
194-
pytest pandas/tests/window/
164+
- name: Print skipped tests
165+
run: python ci/print_skipped.py

.github/workflows/database.yml

+9-93
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@ env:
1212
PYTEST_WORKERS: "auto"
1313
PANDAS_CI: 1
1414
PATTERN: ((not slow and not network and not clipboard) or (single and db))
15+
COVERAGE: true
1516

1617
jobs:
17-
Linux_py37_locale:
18+
Linux_py37_IO:
1819
runs-on: ubuntu-latest
1920
defaults:
2021
run:
2122
shell: bash -l {0}
2223

23-
env:
24-
ENV_FILE: ci/deps/actions-37-locale.yaml
25-
LOCALE_OVERRIDE: zh_CN.UTF-8
24+
strategy:
25+
matrix:
26+
ENV_FILE: [ci/deps/actions-37-db-min.yaml, ci/deps/actions-37-db.yaml]
27+
fail-fast: false
2628

2729
services:
2830
mysql:
@@ -63,106 +65,20 @@ jobs:
6365
with:
6466
path: ~/conda_pkgs_dir
6567
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
66-
hashFiles('${{ env.ENV_FILE }}') }}
68+
hashFiles('${{ matrix.ENV_FILE }}') }}
6769

6870
- uses: conda-incubator/setup-miniconda@v2
6971
with:
7072
activate-environment: pandas-dev
7173
channel-priority: strict
72-
environment-file: ${{ env.ENV_FILE }}
74+
environment-file: ${{ matrix.ENV_FILE }}
7375
use-only-tar-bz2: true
7476

7577
- name: Build Pandas
7678
uses: ./.github/actions/build_pandas
7779

7880
- name: Test
79-
run: ci/run_tests.sh
80-
if: always()
81-
82-
- name: Build Version
83-
run: pushd /tmp && python -c "import pandas; pandas.show_versions();" && popd
84-
85-
- name: Publish test results
86-
uses: actions/upload-artifact@master
87-
with:
88-
name: Test results
89-
path: test-data.xml
90-
if: failure()
91-
92-
- name: Print skipped tests
93-
run: python ci/print_skipped.py
94-
95-
- name: Upload coverage to Codecov
96-
uses: codecov/codecov-action@v1
97-
with:
98-
flags: unittests
99-
name: codecov-pandas
100-
fail_ci_if_error: false
101-
102-
Linux_py37_cov:
103-
runs-on: ubuntu-latest
104-
defaults:
105-
run:
106-
shell: bash -l {0}
107-
108-
env:
109-
ENV_FILE: ci/deps/actions-37-cov.yaml
110-
PANDAS_TESTING_MODE: deprecate
111-
COVERAGE: true
112-
113-
services:
114-
mysql:
115-
image: mysql
116-
env:
117-
MYSQL_ALLOW_EMPTY_PASSWORD: yes
118-
MYSQL_DATABASE: pandas
119-
options: >-
120-
--health-cmd "mysqladmin ping"
121-
--health-interval 10s
122-
--health-timeout 5s
123-
--health-retries 5
124-
ports:
125-
- 3306:3306
126-
127-
postgres:
128-
image: postgres
129-
env:
130-
POSTGRES_USER: postgres
131-
POSTGRES_PASSWORD: postgres
132-
POSTGRES_DB: pandas
133-
options: >-
134-
--health-cmd pg_isready
135-
--health-interval 10s
136-
--health-timeout 5s
137-
--health-retries 5
138-
ports:
139-
- 5432:5432
140-
141-
steps:
142-
- name: Checkout
143-
uses: actions/checkout@v1
144-
145-
- name: Cache conda
146-
uses: actions/cache@v1
147-
env:
148-
CACHE_NUMBER: 0
149-
with:
150-
path: ~/conda_pkgs_dir
151-
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
152-
hashFiles('${{ env.ENV_FILE }}') }}
153-
154-
- uses: conda-incubator/setup-miniconda@v2
155-
with:
156-
activate-environment: pandas-dev
157-
channel-priority: strict
158-
environment-file: ${{ env.ENV_FILE }}
159-
use-only-tar-bz2: true
160-
161-
- name: Build Pandas
162-
uses: ./.github/actions/build_pandas
163-
164-
- name: Test
165-
run: ci/run_tests.sh
81+
run: pytest -m "${{ env.PATTERN }}" -n 2 --dist=loadfile -s --strict-markers --durations=30 --junitxml=test-data.xml -s --cov=pandas --cov-report=xml pandas/tests/io
16682
if: always()
16783

16884
- name: Build Version

.pre-commit-config.yaml

+12-26
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ repos:
5050
rev: 5.7.0
5151
hooks:
5252
- id: isort
53-
- repo: https://github.com/MarcoGorelli/no-string-hints
54-
rev: v0.1.7
55-
hooks:
56-
- id: no-string-hints
5753
- repo: https://github.com/asottile/pyupgrade
5854
rev: v2.10.0
5955
hooks:
@@ -111,12 +107,6 @@ repos:
111107
pandas/tests/io/excel/test_writers\.py
112108
|pandas/tests/io/pytables/common\.py
113109
|pandas/tests/io/pytables/test_store\.py$
114-
- id: no-pandas-api-types
115-
name: Check code for instances of pd.api.types
116-
entry: (pd|pandas)\.api\.types\.
117-
language: pygrep
118-
types: [python]
119-
files: ^pandas/tests/
120110
- id: non-standard-imports
121111
name: Check for non-standard imports
122112
language: pygrep
@@ -128,6 +118,11 @@ repos:
128118
129119
# Check for imports from collections.abc instead of `from collections import abc`
130120
|from\ collections\.abc\ import
121+
122+
# Numpy
123+
|from\ numpy\ import\ random
124+
|from\ numpy\.random\ import
125+
types: [python]
131126
- id: non-standard-imports-in-tests
132127
name: Check for non-standard imports in test suite
133128
language: pygrep
@@ -143,26 +138,17 @@ repos:
143138
144139
# Check for use of pandas.testing instead of tm
145140
|pd\.testing\.
141+
142+
# Check for pd.api.types instead of from pandas.api.types import ...
143+
|(pd|pandas)\.api\.types\.
146144
types: [python]
147145
files: ^pandas/tests/
148-
- id: non-standard-numpy-random-related-imports
149-
name: Check for non-standard numpy.random-related imports excluding pandas/_testing.py
150-
language: pygrep
151-
exclude: pandas/_testing.py
146+
- id: np-bool-and-np-object
147+
name: Check for use of np.bool/np.object instead of np.bool_/np.object_
152148
entry: |
153149
(?x)
154-
# Check for imports from np.random.<method> instead of `from numpy import random` or `from numpy.random import <method>`
155-
from\ numpy\ import\ random
156-
|from\ numpy.random\ import
157-
types: [python]
158-
- id: np-bool
159-
name: Check for use of np.bool instead of np.bool_
160-
entry: np\.bool[^_8]
161-
language: pygrep
162-
types_or: [python, cython, rst]
163-
- id: np-object
164-
name: Check for use of np.object instead of np.object_
165-
entry: np\.object[^_8]
150+
np\.bool[^_8]
151+
|np\.object[^_8]
166152
language: pygrep
167153
types_or: [python, cython, rst]
168154
- id: pip-to-conda

ci/deps/actions-37-locale.yaml renamed to ci/deps/actions-37-db-min.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies:
77
# tools
88
- cython>=0.29.21
99
- pytest>=5.0.1
10+
- pytest-cov
1011
- pytest-xdist>=1.21
1112
- hypothesis>=3.58.0
1213

File renamed without changes.

pandas/_libs/algos.pyx

+9-6
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,23 @@ def groupsort_indexer(const int64_t[:] index, Py_ssize_t ngroups):
199199
200200
Returns
201201
-------
202-
tuple
203-
1-d indexer ordered by groups, group counts.
202+
ndarray[intp_t, ndim=1]
203+
Indexer
204+
ndarray[int64_t, ndim=1]
205+
Group Counts
204206
205207
Notes
206208
-----
207209
This is a reverse of the label factorization process.
208210
"""
209211
cdef:
210212
Py_ssize_t i, loc, label, n
211-
ndarray[int64_t] counts, where, result
213+
ndarray[int64_t] counts, where
214+
ndarray[intp_t] indexer
212215

213216
counts = np.zeros(ngroups + 1, dtype=np.int64)
214217
n = len(index)
215-
result = np.zeros(n, dtype=np.int64)
218+
indexer = np.zeros(n, dtype=np.intp)
216219
where = np.zeros(ngroups + 1, dtype=np.int64)
217220

218221
with nogil:
@@ -228,10 +231,10 @@ def groupsort_indexer(const int64_t[:] index, Py_ssize_t ngroups):
228231
# this is our indexer
229232
for i in range(n):
230233
label = index[i] + 1
231-
result[where[label]] = i
234+
indexer[where[label]] = i
232235
where[label] += 1
233236

234-
return result, counts
237+
return indexer, counts
235238

236239

237240
@cython.boundscheck(False)

pandas/_libs/algos_take_helper.pxi.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def take_1d_{{name}}_{{dest}}(const {{c_type_in}}[:] values,
6666
{{else}}
6767
def take_1d_{{name}}_{{dest}}(ndarray[{{c_type_in}}, ndim=1] values,
6868
{{endif}}
69-
const int64_t[:] indexer,
69+
const intp_t[:] indexer,
7070
{{c_type_out}}[:] out,
7171
fill_value=np.nan):
7272

@@ -102,7 +102,7 @@ def take_2d_axis0_{{name}}_{{dest}}(const {{c_type_in}}[:, :] values,
102102
{{else}}
103103
def take_2d_axis0_{{name}}_{{dest}}(ndarray[{{c_type_in}}, ndim=2] values,
104104
{{endif}}
105-
ndarray[int64_t] indexer,
105+
ndarray[intp_t] indexer,
106106
{{c_type_out}}[:, :] out,
107107
fill_value=np.nan):
108108
cdef:
@@ -156,7 +156,7 @@ def take_2d_axis1_{{name}}_{{dest}}(const {{c_type_in}}[:, :] values,
156156
{{else}}
157157
def take_2d_axis1_{{name}}_{{dest}}(ndarray[{{c_type_in}}, ndim=2] values,
158158
{{endif}}
159-
ndarray[int64_t] indexer,
159+
ndarray[intp_t] indexer,
160160
{{c_type_out}}[:, :] out,
161161
fill_value=np.nan):
162162

pandas/_libs/groupby.pyx

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ from numpy cimport (
1919
int16_t,
2020
int32_t,
2121
int64_t,
22+
intp_t,
2223
ndarray,
2324
uint8_t,
2425
uint16_t,
@@ -141,6 +142,7 @@ def group_median_float64(ndarray[float64_t, ndim=2] out,
141142
Py_ssize_t i, j, N, K, ngroups, size
142143
ndarray[int64_t] _counts
143144
ndarray[float64_t, ndim=2] data
145+
ndarray[intp_t] indexer
144146
float64_t* ptr
145147

146148
assert min_count == -1, "'min_count' only used in add and prod"

0 commit comments

Comments
 (0)