Skip to content

Commit 6eaaa0c

Browse files
authored
Merge pull request #226 from bashtage/add-appveyor
TST: Add smoke decorator and appveyor
2 parents a83811d + 4acc346 commit 6eaaa0c

18 files changed

+119
-13
lines changed

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
global:
1010
- PANDAS=pandas
1111
- COVERAGE=true
12-
- SKIPSLOW=""
12+
- SKIP=""
1313
- DOCTR_PUSH_TYPE=""
1414
- XARRAY=
1515
- OPENBLAS=0
@@ -56,7 +56,7 @@ matrix:
5656
- SCIPY=1.0
5757
- PANDAS=0.23
5858
- STATSMODELS=0.9
59-
- SKIPSLOW="--skip-slow"
59+
- SKIP="--skip-slow --skip-smoke"
6060
- python: 3.6
6161
env:
6262
- PYTHON=3.6
@@ -66,7 +66,7 @@ matrix:
6666
- XARRAY=0.10
6767
- STATSMODELS=0.10
6868
- PIP_PACKAGES="xxhash"
69-
- SKIPSLOW="--skip-slow"
69+
- SKIP="--skip-slow --skip-smoke"
7070
- python: 3.7
7171
env:
7272
- PYTHON=3.7
@@ -79,13 +79,13 @@ matrix:
7979
- python: 3.8
8080
env:
8181
- PIP_PRE=true
82-
- SKIPSLOW=--skip-slow
82+
- SKIP="--skip-slow --skip-smoke"
8383

8484
allow_failures:
8585
- python: 3.8
8686
env:
8787
- PIP_PRE=true
88-
- SKIPSLOW=--skip-slow
88+
- SKIP="--skip-slow --skip-smoke"
8989

9090

9191
before_install:
@@ -129,7 +129,7 @@ script:
129129
mkdir empty && cd empty
130130
python -c "import linearmodels;linearmodels.test()"
131131
else
132-
pytest -n 2 --cov-config .coveragerc --cov=linearmodels linearmodels --durations=10 ${SKIPSLOW}
132+
pytest -n 2 --cov-config .coveragerc --cov=linearmodels linearmodels --durations=10 ${SKIP}
133133
fi
134134
- flake8 linearmodels
135135
- set -e

appveyor.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
skip_tags: true
2+
clone_depth: 50
3+
4+
matrix:
5+
fast_finish: false
6+
7+
environment:
8+
global:
9+
OMP_NUM_THREADS: 1
10+
MKL_NUM_THREADS: 1
11+
VML_NUM_THREADS: 1
12+
PYTHONHASHSEED: 31211999
13+
14+
matrix:
15+
- PYTHON: C:\Python38-x64
16+
PYTHON_VERSION: 3.8
17+
PYTHON_ARCH: 64
18+
19+
- PYTHON: C:\Python38
20+
PYTHON_VERSION: 3.8
21+
PYTHON_ARCH: 32
22+
23+
24+
# We always use a 64-bit machine, but can build x86 distributions
25+
# with the TARGET_ARCH variable.
26+
platform:
27+
- x64
28+
29+
install:
30+
- git submodule update --init --recursive
31+
- git fetch --all --tags
32+
33+
# Set path
34+
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
35+
36+
# Check that we have the expected version and architecture for Python
37+
- python --version
38+
- python -m pip install --upgrade pip wheel
39+
40+
build_script:
41+
# Install build requirements
42+
- pip install cython numpy scipy statsmodels pandas xarray property_cached mypy-extensions pytest pytest-xdist
43+
- python setup.py bdist_wheel
44+
- ls dist/*
45+
46+
test_script:
47+
# install from wheel
48+
- pip install --no-index --find-links dist/ linearmodels
49+
50+
# run tests from install wheel
51+
- mkdir _for_testing
52+
- cd _for_testing
53+
- python -c "import linearmodels; linearmodels.test(['-n 2','--skip-slow','--skip-smoke','--durations=25'])"

linearmodels/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test(extra_args=None, exit=True, append=True):
8181
except ImportError:
8282
raise ImportError("Need pytest to run tests")
8383

84-
cmd = ["--tb=short", "--disable-pytest-warnings"]
84+
cmd = ["--tb=auto"]
8585
if extra_args:
8686
if not isinstance(extra_args, list):
8787
extra_args = [extra_args]

linearmodels/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
import pytest
22

33

4+
def pytest_configure(config):
5+
# Minimal config to simplify running tests from lm.test()
6+
config.addinivalue_line("markers", "slow: mark a test as slow")
7+
config.addinivalue_line(
8+
"markers", "smoke: mark a test as a coding error (smoke) test"
9+
)
10+
config.addinivalue_line(
11+
"filterwarnings", "ignore:Method .ptp is deprecated:FutureWarning"
12+
)
13+
14+
415
def pytest_addoption(parser):
516
parser.addoption("--skip-slow", action="store_true", help="skip slow tests")
617
parser.addoption("--only-slow", action="store_true", help="run only slow tests")
18+
parser.addoption("--skip-smoke", action="store_true", help="skip smoke tests")
19+
parser.addoption("--only-smoke", action="store_true", help="run only smoke tests")
720

821

922
def pytest_runtest_setup(item):
@@ -12,3 +25,9 @@ def pytest_runtest_setup(item):
1225

1326
if "slow" not in item.keywords and item.config.getoption("--only-slow"):
1427
pytest.skip("skipping due to --only-slow")
28+
29+
if "smoke" in item.keywords and item.config.getoption("--skip-smoke"):
30+
pytest.skip("skipping due to --skip-smoke")
31+
32+
if "smoke" not in item.keywords and item.config.getoption("--only-smoke"):
33+
pytest.skip("skipping due to --only-smoke")

linearmodels/panel/utility.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,18 @@ def check_absorbed(x: np.ndarray, variables: List[str]):
388388
variables : List[str]
389389
List of variable names
390390
"""
391-
if np.linalg.matrix_rank(x) < x.shape[1]:
391+
rank = np.linalg.matrix_rank(x)
392+
if rank < x.shape[1]:
392393
xpx = x.T @ x
393394
vals, vecs = np.linalg.eigh(xpx)
394-
tol = vals.max() * x.shape[1] * np.finfo(np.float64).eps
395-
absorbed = vals < tol
396-
nabsorbed = absorbed.sum()
395+
nabsorbed = x.shape[1] - rank
396+
tol = np.sort(vals)[nabsorbed - 1]
397+
absorbed = vals <= tol
397398
absorbed_vecs = vecs[:, absorbed]
398399
rows = []
399400
for i in range(nabsorbed):
401+
abs_vec = np.abs(absorbed_vecs[:, i])
402+
tol = abs_vec.max() * np.finfo(np.float64).eps * abs_vec.shape[0]
400403
vars_idx = np.where(np.abs(absorbed_vecs[:, i]) > tol)[0]
401404
rows.append(" " * 10 + ", ".join((variables[vi] for vi in vars_idx)))
402405
absorbed_variables = "\n".join(rows)

linearmodels/tests/asset_pricing/test_linear_factor_gmm.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ def test_linear_model_gmm_moments_jacobian(data):
6969
get_all(res)
7070

7171

72+
@pytest.mark.smoke
7273
def test_linear_model_gmm_smoke_iterate(data):
7374
mod = LinearFactorModelGMM(data.portfolios, data.factors)
7475
res = mod.fit(cov_type="robust", disp=5, steps=20)
7576
get_all(res)
7677

7778

79+
@pytest.mark.smoke
7880
def test_linear_model_gmm_smoke_risk_free(data):
7981
mod = LinearFactorModelGMM(data.portfolios, data.factors, risk_free=True)
8082
res = mod.fit(cov_type="robust", disp=10)
@@ -84,6 +86,7 @@ def test_linear_model_gmm_smoke_risk_free(data):
8486
str(res._cov_est.config)
8587

8688

89+
@pytest.mark.smoke
8790
def test_linear_model_gmm_kernel_smoke(data):
8891
mod = LinearFactorModelGMM(data.portfolios, data.factors)
8992
res = mod.fit(cov_type="kernel", disp=10)
@@ -93,12 +96,14 @@ def test_linear_model_gmm_kernel_smoke(data):
9396
str(res._cov_est.config)
9497

9598

99+
@pytest.mark.smoke
96100
def test_linear_model_gmm_kernel_bandwidth_smoke(data):
97101
mod = LinearFactorModelGMM(data.portfolios, data.factors)
98102
res = mod.fit(cov_type="kernel", bandwidth=10, disp=10)
99103
get_all(res)
100104

101105

106+
@pytest.mark.smoke
102107
def test_linear_model_gmm_cue_smoke(data):
103108
mod = LinearFactorModelGMM(data.portfolios, data.factors, risk_free=True)
104109
res = mod.fit(cov_type="robust", disp=10, use_cue=True)

linearmodels/tests/asset_pricing/test_model.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,42 @@ def data(request):
2222
return generate_data(nportfolio=10, output=request.param)
2323

2424

25+
@pytest.mark.smoke
2526
def test_linear_model_gmm_smoke(data):
2627
mod = LinearFactorModelGMM(data.portfolios, data.factors)
2728
res = mod.fit(cov_type="robust", disp=5)
2829
get_all(res)
2930

3031

32+
@pytest.mark.smoke
3133
def test_linear_model_gmm_smoke_iterate(data):
3234
mod = LinearFactorModelGMM(data.portfolios, data.factors)
3335
res = mod.fit(cov_type="robust", disp=5, steps=20)
3436
get_all(res)
3537

3638

39+
@pytest.mark.smoke
3740
def test_linear_model_gmm_smoke_risk_free(data):
3841
mod = LinearFactorModelGMM(data.portfolios, data.factors, risk_free=True)
3942
res = mod.fit(cov_type="robust", disp=10)
4043
get_all(res)
4144

4245

46+
@pytest.mark.smoke
4347
def test_linear_model_gmm_kernel_smoke(data):
4448
mod = LinearFactorModelGMM(data.portfolios, data.factors)
4549
res = mod.fit(cov_type="kernel", disp=10)
4650
get_all(res)
4751

4852

53+
@pytest.mark.smoke
4954
def test_linear_model_gmm_kernel_bandwidth_smoke(data):
5055
mod = LinearFactorModelGMM(data.portfolios, data.factors)
5156
res = mod.fit(cov_type="kernel", bandwidth=10, disp=10)
5257
get_all(res)
5358

5459

60+
@pytest.mark.smoke
5561
def test_linear_model_gmm_cue_smoke(data):
5662
mod = LinearFactorModelGMM(data.portfolios, data.factors, risk_free=True)
5763
res = mod.fit(cov_type="robust", disp=10, use_cue=True)
@@ -112,6 +118,7 @@ def test_linear_model_time_series(data):
112118
assert_allclose(1.0 - stats.chi2.cdf(stat_direct, nport), res.j_statistic.pval)
113119

114120

121+
@pytest.mark.smoke
115122
def test_linear_model_time_series_kernel_smoke(data):
116123
mod = TradedFactorModel(data.portfolios, data.factors)
117124
mod.fit(cov_type="kernel")

linearmodels/tests/iv/test_absorbing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ def ols_data(request):
238238
return generate_data(*request.param)
239239

240240

241+
@pytest.mark.smoke
241242
def test_smoke(data):
242243
mod = AbsorbingLS(
243244
data.y,

linearmodels/tests/iv/test_covariance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def test_unknown_kernel(self, data, kernel):
309309

310310

311311
class TestAutomaticBandwidth(object):
312+
@pytest.mark.smoke
312313
def test_smoke(self, data, kernel):
313314
# TODO: This should be improved from a smoke test
314315
u = data.e.copy()

linearmodels/tests/iv/test_model.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,27 +241,31 @@ def test_2sls_just_identified(data):
241241
get_all(fs)
242242

243243

244+
@pytest.mark.smoke
244245
def test_durbin_smoke(data):
245246
mod = IV2SLS(data.dep, data.exog, data.endog, data.instr)
246247
res = mod.fit()
247248
res.durbin()
248249
res.durbin([mod.endog.cols[1]])
249250

250251

252+
@pytest.mark.smoke
251253
def test_wu_hausman_smoke(data):
252254
mod = IV2SLS(data.dep, data.exog, data.endog, data.instr)
253255
res = mod.fit()
254256
res.wu_hausman()
255257
res.wu_hausman([mod.endog.cols[1]])
256258

257259

260+
@pytest.mark.smoke
258261
def test_wooldridge_smoke(data):
259262
mod = IV2SLS(data.dep, data.exog, data.endog, data.instr)
260263
res = mod.fit()
261264
res.wooldridge_regression
262265
res.wooldridge_score
263266

264267

268+
@pytest.mark.smoke
265269
def test_model_summary_smoke(data):
266270
res = IV2SLS(data.dep, data.exog, data.endog, data.instr).fit()
267271
res.__repr__()

linearmodels/tests/iv/test_postestimation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def test_basmann_f(data):
108108
assert_allclose(res.basmann_f.pval, 0.6760, rtol=1e-3)
109109

110110

111+
@pytest.mark.smoke
111112
def test_c_stat_smoke(data):
112113
res = IVGMM(data.dep, data.exog, data.endog, data.instr).fit(cov_type="robust")
113114
c_stat = res.c_stat()

linearmodels/tests/panel/test_fama_macbeth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def test_unknown_cov_type(data):
6767
FamaMacBeth(data.y, data.x).fit(cov_type="unknown")
6868

6969

70+
@pytest.mark.smoke
7071
def test_fama_macbeth_kernel_smoke(data):
7172
FamaMacBeth(data.y, data.x).fit(cov_type="kernel")
7273
FamaMacBeth(data.y, data.x).fit(cov_type="kernel", kernel="bartlett")

linearmodels/tests/panel/test_model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ def test_absorbing_effect(data, intercept):
216216
mod = PanelOLS(data.y, x, entity_effects=True)
217217
mod.fit()
218218
var_names = mod.exog.vars
219-
print([var_names[i] in str(exc_info.value) for i in range(len(var_names))])
220-
print(str(exc_info.value))
219+
221220
assert var_names[3] in str(exc_info.value)
222221
assert (" " * (2 - intercept) + var_names[-1]) in str(exc_info.value)
223222

linearmodels/tests/panel/test_panel_covariance.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def setup_class(cls):
2424
cls.cluster4 = np.random.randint(0, 10, (cls.n * cls.t, 2))
2525
cls.cluster5 = np.random.randint(0, 10, (cls.n * cls.t, 3))
2626

27+
@pytest.mark.smoke
2728
def test_heteroskedastic_smoke(self):
2829
cov = HeteroskedasticCovariance(
2930
self.y, self.x, self.params, self.entity_ids, self.time_ids, extra_df=0
@@ -34,6 +35,7 @@ def test_heteroskedastic_smoke(self):
3435
).cov
3536
assert cov.shape == (self.k, self.k)
3637

38+
@pytest.mark.smoke
3739
def test_homoskedastic_smoke(self):
3840
cov = HomoskedasticCovariance(
3941
self.y, self.x, self.params, self.entity_ids, self.time_ids, extra_df=0
@@ -44,6 +46,7 @@ def test_homoskedastic_smoke(self):
4446
).cov
4547
assert cov.shape == (self.k, self.k)
4648

49+
@pytest.mark.smoke
4750
def test_clustered_covariance_smoke(self):
4851
cov = ClusteredCovariance(
4952
self.y, self.x, self.params, self.entity_ids, self.time_ids, extra_df=0
@@ -141,6 +144,7 @@ def test_clustered_covariance_error(self):
141144
clusters=self.cluster4[::2],
142145
)
143146

147+
@pytest.mark.smoke
144148
def test_driscoll_kraay_smoke(self):
145149
cov = DriscollKraay(
146150
self.y, self.x, self.params, self.entity_ids, self.time_ids
@@ -155,6 +159,7 @@ def test_driscoll_kraay_smoke(self):
155159
).cov
156160
assert cov.shape == (self.k, self.k)
157161

162+
@pytest.mark.smoke
158163
def test_ac_covariance_smoke(self):
159164
cov = ACCovariance(
160165
self.y, self.x, self.params, self.entity_ids, self.time_ids

linearmodels/tests/panel/test_panel_ols.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,7 @@ def test_cov_equiv_cluster(data):
10821082
assert_results_equal(res, res2)
10831083

10841084

1085+
@pytest.mark.smoke
10851086
def test_cluster_smoke(data):
10861087
mod = PanelOLS(data.y, data.x, entity_effects=True)
10871088
mod.fit(cov_type="clustered", cluster_time=True, debiased=False)
@@ -1180,6 +1181,7 @@ def test_entity_other(data):
11801181
assert_results_equal(res, res2)
11811182

11821183

1184+
@pytest.mark.smoke
11831185
def test_other_weighted_smoke(data):
11841186
mod = PanelOLS(data.y, data.x, weights=data.w, other_effects=data.c)
11851187
mod.fit(debiased=False)

linearmodels/tests/system/test_gmm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def test_weight_options(data):
207207
res = mod.fit(cov_type="robust")
208208

209209

210+
@pytest.mark.smoke
210211
def test_no_constant_smoke():
211212
eqns = generate_3sls_data_v2(k=3, const=False)
212213
mod = IVSystemGMM(eqns)

0 commit comments

Comments
 (0)