Skip to content

TST: Run the IVJIVE docstring examples quietly under pytest -v - #854

Merged
bashtage merged 3 commits into
mainfrom
fix-853-freebsd-tests
Oct 22, 2026
Merged

bashtage merged 3 commits into
mainfrom
fix-853-freebsd-tests

Conversation

@bashtage

Copy link
Copy Markdown
Owner

test_jive_docstring_examples_run collects everything that doctest writes as a
failure. DocTestRunner's default verbose=None is verbose when "-v" is in sys.argv,
so under "pytest -v" every example that passes ("Trying: ... ok") was written too
and the test failed on every platform. This was one of the failures in the
FreeBSD report (xref #853), whose test run uses -v.

The runner now uses verbose=False, so that only failing examples are written. A
docstring with a wrong expected value is still reported, with and without -v.

test_jive_docstring_examples_run collects everything that doctest writes as a
failure. DocTestRunner's default verbose=None is verbose when "-v" is in sys.argv,
so under "pytest -v" every example that passes ("Trying: ... ok") was written too
and the test failed on every platform. This was one of the failures in the
FreeBSD report (xref #853), whose test run uses -v.

The runner now uses verbose=False, so that only failing examples are written. A
docstring with a wrong expected value is still reported, with and without -v.
…full rank

The IVSystemGMM tests of the kernel bandwidth with few observations used two
exactly identified equations, each with a constant, an endogenous regressor and
one instrument. Their 4 moment conditions sum to zero at the estimates, so they
have rank nobs - 1 or less, and with 3 or 4 observations the covariance that the
GMM weights invert is singular in exact arithmetic (condition numbers 3e16 to
5e18). The fits only worked up to rounding. On FreeBSD the inversion raised
"Singular matrix" in three tests (xref #853), and on Windows, refitting with the
data changed in the last bit raised it in 8% to 22% of 200 refits and changed the
estimates by a factor of up to 100.

The IVSystemGMM tests in test_kernel_bandwidth_few_observations.py now use
gmm_equations: the same data without the constant, so 2 moment conditions with
full rank from 3 observations. The condition numbers are 5 to 24 (1.6e3 for the
quadratic spectral kernel with 6 observations), and the 200 refits per case raise
nothing, change the estimates by 1e-14 or less and give the same bandwidths. The
assertions are unchanged: the bandwidth rule raises below the fewest
observations, an explicit bandwidth and optimal_bw=False work there, and the
automatic bandwidth works with the fewest observations.

test_system_gmm_covariance_raises_when_fit_with_too_few_observations had only
(parzen, 4), (qs, 4) and (qs, 5), because the robust weights of the old equations
fail with 3 observations and are singular with 4. It now covers every number of
observations from 3 to one less than each kernel needs (6 cases). The SUR and
IV3SLS tests keep system_equations, since they do not invert the moment
covariance.
pytest loads every plugin installed in the environment, and the strict test
configuration turns a marker that a plugin uses but linearmodels does not
register into an error. In the FreeBSD report (xref #853), test_runner and
test_extra_args failed with "'gpu' not found in markers configuration option":
linearmodels.test() starts a second pytest session in the same process, and a
plugin of that environment used the marker there.

The README now shows how to run the tests, and how to run them with
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 and pytest-xdist loaded explicitly. A stand-in
plugin that uses an unregistered marker fails the same two tests with the same
message, and they pass with the environment variable. The testing requirements
also list xarray, which the tests import, and pytest-xdist.
@bashtage bashtage mentioned this pull request Oct 22, 2026
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.68%. Comparing base (b7c5c17) to head (dcbaae3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #854   +/-   ##
=======================================
  Coverage   99.68%   99.68%           
=======================================
  Files         199      199           
  Lines       37870    37873    +3     
  Branches     2436     2436           
=======================================
+ Hits        37751    37754    +3     
  Misses         51       51           
  Partials       68       68           
Flag Coverage Δ
adder 99.67% <100.00%> (+<0.01%) ⬆️
subtractor 99.67% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bashtage
bashtage merged commit d564bac into main Oct 22, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant