Repository navigation
TST: Run the IVJIVE docstring examples quietly under pytest -v - #854
Merged
Merged
Conversation
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.
Closed
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.