Skip to content

Commit e8b0491

Browse files
authored
Merge pull request #670 from bashtage/cython-cov-attempt
CI: Attempt to manually get cython coverage
2 parents e210522 + 6169cd4 commit e8b0491

File tree

9 files changed

+93
-127
lines changed

9 files changed

+93
-127
lines changed

.coveragerc

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[run]
2+
source = linearmodels
3+
branch = True
4+
omit =
5+
*/results/*
6+
*/_version.py
7+
*/compat/*
8+
*/conftest.py
9+
plugins = Cython.Coverage
10+
11+
[report]
12+
# Regexes for lines to exclude from consideration
13+
exclude_lines =
14+
# Have to re-enable the standard pragma
15+
pragma: no cover
16+
17+
# Don't complain if tests don't hit defensive assertion code:
18+
raise NotImplementedError
19+
except NotImplementedError
20+
raise AssertionError
21+
22+
# Ignore pass
23+
pass
24+
25+
# Do not complain about missing debug-only code:
26+
def __repr__
27+
if self\\.debug
28+
29+
# Ignore failure messages
30+
pytest.xfail
31+
32+
# Ignore ImportError protection
33+
raise ImportError
34+
except ImportError
35+
36+
# Ignore type checking code
37+
if TYPE_CHECKING
38+
elif TYPE_CHECKING
39+
40+
# Cython function declarations
41+
cdef
42+
43+
# Cython functions with void
44+
cdef void
45+
46+
# Numba jit decorators
47+
@jit
48+
49+
# Do not complain if non-runnable code is not run:
50+
if 0:
51+
if __name__ == .__main__.:
52+
53+
include = */linearmodels/*
54+
omit =
55+
*/_version.py
56+
*/compat/*
57+
*recursions.py
58+
*samplers.py
59+
ignore_errors = True
60+
61+
[html]
62+
directory = coverage_html_report

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ variables:
1313
PYTHONHASHSEED: 12345678 # Ensure tests are correctly gathered by xdist
1414
TEST_INSTALL: false
1515
MPLBACKEND: agg
16+
PYTEST_PATTERN: "(not slow)"
1617
coverage: true
1718
test.install: false
1819
pip.pre: false

ci/azure_template_posix.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ jobs:
1616
vmImage: ${{ parameters.vmImage }}
1717
strategy:
1818
matrix:
19-
python310_minimums_wheel:
19+
python310_minimums:
2020
python.version: '3.10'
2121
NUMPY: 1.22.3
2222
SCIPY: 1.8.0
2323
PANDAS: 1.3.0
2424
STATSMODELS: 0.13.1
2525
XARRAY: 0.21.0
2626
FORMULAIC: 1.2.1
27-
test.wheel: true
27+
PYTEST_PATTERN: "(slow or not slow)"
2828
python310_mid_sdist:
2929
python.version: '3.10'
3030
NUMPY: 1.23.0
@@ -62,11 +62,15 @@ jobs:
6262
XXHASH: true
6363
PYARROW: true
6464
BUILD_FLAGS: '-Csetup-args=-Dno-binary=true'
65+
python312_cython_coverage:
66+
python.version: '3.12'
67+
BUILD_FLAGS: '-Csetup-args=-Dcython-coverage=true'
68+
cython.coverage: true
6569
python313_latest:
6670
python.version: '3.13'
6771
XXHASH: true
6872
PYARROW: true
69-
BUILD_FLAGS: '-Csetup-args=-Dcython-coverage=true'
73+
PYTEST_PATTERN: "(slow or not slow)"
7074
python313_copy_on_write:
7175
python.version: '3.12'
7276
XXHASH: true
@@ -92,8 +96,7 @@ jobs:
9296
jupyter kernelspec list
9397
displayName: 'Install dependencies'
9498
95-
- script: |
96-
python -m pip list
99+
- script: python -m pip list
97100
displayName: 'List Configuration'
98101

99102
- script: |
@@ -126,6 +129,13 @@ jobs:
126129
displayName: 'Install linearmodels (editable)'
127130
condition: and(ne(variables['test.wheel'], 'true'), ne(variables['test.sdist'], 'true'))
128131
132+
- script: |
133+
pushd linearmodels/panel
134+
cython --verbose -M --fast-fail -3 -X cpow=True -X boundscheck=False -X wraparound=False -X cdivision=True -X binding=True -X linetrace=True _utility.pyx
135+
popd
136+
displayName: 'Transpile Cython to C for coverage support'
137+
condition: eq(variables['cython.coverage'], 'true')
138+
129139
- script: |
130140
echo "Testing site packages"
131141
mkdir test_run_dir
@@ -137,16 +147,16 @@ jobs:
137147
138148
- script: |
139149
echo "Testing editable install"
140-
export COVERAGE_OPTS="--cov=linearmodels --cov-report xml:coverage.xml --cov-report term"
141-
echo pytest -m "${PYTEST_PATTERN}" --junitxml=junit/test-results.xml -n auto --durations=25 ${COVERAGE_OPTS} ${BUILD_FLAGS} linearmodels/tests
150+
export COVERAGE_OPTS="--cov-config=.coveragerc --cov=linearmodels --cov-branch --cov-report xml:coverage.xml --cov-report term"
151+
echo pytest -m "${PYTEST_PATTERN}" --junitxml=junit/test-results.xml -n auto --durations=25 ${COVERAGE_OPTS} linearmodels/tests
142152
pytest -m "${PYTEST_PATTERN}" --junitxml=junit/test-results.xml -n auto --durations=25 ${COVERAGE_OPTS} linearmodels/tests
143153
displayName: 'Run tests (editable)'
144154
condition: and(and(ne(variables['test.wheel'], 'true'), ne(variables['test.sdist'], 'true')), ne(variables['pip.pre'], 'true'))
145155
146156
- script: |
147157
echo "Testing pip-pre"
148-
export COVERAGE_OPTS="--cov=linearmodels --cov-report xml:coverage.xml --cov-report term"
149-
echo pytest -m "${PYTEST_PATTERN}" --junitxml=junit/test-results.xml -n auto --durations=25 ${COVERAGE_OPTS} ${BUILD_FLAGS} linearmodels/tests
158+
export COVERAGE_OPTS="--cov-config=.coveragerc --cov=linearmodels --cov-branch --cov-report=xml:coverage.xml --cov-report=term"
159+
echo pytest -m "${PYTEST_PATTERN}" --junitxml=junit/test-results.xml -n auto --durations=25 ${COVERAGE_OPTS} linearmodels/tests
150160
pytest -m "${PYTEST_PATTERN}" --junitxml=junit/test-results.xml -n auto --durations=25 ${COVERAGE_OPTS} linearmodels/tests
151161
displayName: 'Run tests (pip pre)'
152162
condition: eq(variables['pip.pre'], 'true')

linearmodels/meson.build

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@ inc_np = include_directories(incdir_numpy, is_system: true)
2929
# Copy the main __init__.py to the build dir.
3030
# Some submodules (linalg, special, optimize) add pxd files to this.
3131
# Needed to trick Cython, it won't do a relative import outside a package
32+
_cython_tree = [fs.copyfile('__init__.py')]
3233
cython_args = [
33-
'-Xcpow=True',
34-
'-Xboundscheck=False',
35-
'-Xwraparound=False',
36-
'-Xcdivision=True',
37-
'-Xbinding=True'
34+
'-X cpow=True',
35+
'-X boundscheck=False',
36+
'-X wraparound=False',
37+
'-X cdivision=True',
38+
'-X binding=True'
3839
]
3940
cython_c_args = ['-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION']
4041
if get_option('cython-coverage')
4142
message('Building with Cython coverage support')
42-
cython_args += ['-Xlinetrace=True']
43+
cython_args += ['-X linetrace=True']
4344
cython_c_args += ['-DCYTHON_TRACE=1']
4445
endif
4546

linearmodels/panel/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if not get_option('no-binary')
55
install: true,
66
include_directories: [inc_np],
77
subdir: 'linearmodels/panel',
8-
cython_args: cython_args,
98
c_args: cython_c_args,
9+
cython_args: cython_args,
1010
)
1111
endif

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ include_trailing_comma=true
311311
use_parentheses=true
312312

313313
[tool.coverage.run]
314-
source = ["linearmodels"]
314+
source = [ "linearmodels" ]
315315
branch = true
316-
plugins = ["Cython.Coverage"]
316+
plugins = [ "Cython.Coverage" ]
317317
omit = [
318318
# Version file
319319
"*/_version.py",

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
black[jupyter]==24.4.0
1+
black[jupyter]~=25.9.0
22
coverage
33
flake8
44
isort

setup.cfg

Whitespace-only changes.

setup.py

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)