Skip to content

Commit 892af67

Browse files
authored
More accurate coverage (#62)
* Update codecov.yml * More coverage * Add lxml * Remove unused result_type function * Fix syntax * Add yaml checker * Actually save coverage * Don't report xarray/groupby tests. We want flox coverage, not xarray.
1 parent 4f2408f commit 892af67

File tree

6 files changed

+33
-30
lines changed

6 files changed

+33
-30
lines changed

.github/workflows/ci-additional.yaml

+21-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ jobs:
7171
conda list
7272
- name: Run doctests
7373
run: |
74-
python -m pytest --doctest-modules flox --ignore flox/tests
74+
python -m pytest --doctest-modules flox --ignore flox/tests --cov=./ --cov-report=xml
75+
- name: Upload code coverage to Codecov
76+
uses: codecov/[email protected]
77+
with:
78+
file: ./coverage.xml
79+
flags: unittests
80+
env_vars: RUNNER_OS
81+
name: codecov-umbrella
82+
fail_ci_if_error: false
7583

7684
mypy:
7785
name: Mypy
@@ -97,12 +105,12 @@ jobs:
97105
uses: mamba-org/provision-with-micromamba@v14
98106
with:
99107
environment-file: ${{env.CONDA_ENV_FILE}}
100-
environment-name: xarray-tests
108+
environment-name: flox-tests
101109
extra-specs: |
102110
python=${{env.PYTHON_VERSION}}
103111
cache-env: true
104112
cache-env-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
105-
- name: Install xarray
113+
- name: Install flox
106114
run: |
107115
python -m pip install --no-deps -e .
108116
- name: Version info
@@ -115,4 +123,13 @@ jobs:
115123
116124
- name: Run mypy
117125
run: |
118-
python -m mypy --install-types --non-interactive
126+
python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report
127+
128+
- name: Upload mypy coverage to Codecov
129+
uses: codecov/[email protected]
130+
with:
131+
file: mypy_report/cobertura.xml
132+
flags: mypy
133+
env_vars: PYTHON_VERSION
134+
name: codecov-umbrella
135+
fail_ci_if_error: false

.github/workflows/ci.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@ jobs:
8989
python -m pip install --no-deps -e .
9090
- name: Run tests
9191
run: |
92-
python -m pytest -n auto
92+
python -m pytest -n auto --cov=./ --cov-report=xml
93+
- name: Upload code coverage to Codecov
94+
uses: codecov/[email protected]
95+
with:
96+
file: ./coverage.xml
97+
flags: unittests
98+
env_vars: RUNNER_OS
99+
name: codecov-umbrella
100+
fail_ci_if_error: false
93101

94102
upstream-dev:
95103
name: upstream-dev

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
66
rev: v4.4.0
77
hooks:
8+
- id: check-yaml
89
- id: trailing-whitespace
910
- id: end-of-file-fixer
1011
- id: check-docstring-first

ci/environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies:
99
- netcdf4
1010
- pandas
1111
- numpy>=1.20
12+
- lxml # for mypy coverage report
1213
- matplotlib
1314
- pip
1415
- pytest

codecov.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ codecov:
55
comment: false
66

77
ignore:
8+
- 'benchmarks/*.py'
89
- 'tests/*.py'
910
- 'setup.py'
1011

flox/xrdtypes.py

-25
Original file line numberDiff line numberDiff line change
@@ -152,28 +152,3 @@ def get_neg_infinity(dtype, min_for_int=False):
152152
def is_datetime_like(dtype):
153153
"""Check if a dtype is a subclass of the numpy datetime types"""
154154
return np.issubdtype(dtype, np.datetime64) or np.issubdtype(dtype, np.timedelta64)
155-
156-
157-
def result_type(*arrays_and_dtypes):
158-
"""Like np.result_type, but with type promotion rules matching pandas.
159-
160-
Examples of changed behavior:
161-
number + string -> object (not string)
162-
bytes + unicode -> object (not unicode)
163-
164-
Parameters
165-
----------
166-
*arrays_and_dtypes : list of arrays and dtypes
167-
The dtype is extracted from both numpy and dask arrays.
168-
169-
Returns
170-
-------
171-
numpy.dtype for the result.
172-
"""
173-
types = {np.result_type(t).type for t in arrays_and_dtypes}
174-
175-
for left, right in PROMOTE_TO_OBJECT:
176-
if any(issubclass(t, left) for t in types) and any(issubclass(t, right) for t in types):
177-
return np.dtype(object)
178-
179-
return np.result_type(*arrays_and_dtypes)

0 commit comments

Comments
 (0)