Skip to content

ENH: Export IVJIVE and the first-stage rank tests from the public API - #765

Open
bashtage wants to merge 2 commits into
mainfrom
lm71-doc1-exports
Open

bashtage wants to merge 2 commits into
mainfrom
lm71-doc1-exports

Conversation

@bashtage

Copy link
Copy Markdown
Owner

IVJIVE could only be imported from linearmodels.iv, while every other
estimator can be imported from linearmodels. Import it in
linearmodels/init.py and add it to all. The list of estimators in
the docstring of the package omitted IVJIVE and AbsorbingLS, so add both.

The first-stage rank tests cragg_donald, cragg_donald_f, kleibergen_paap
and kleibergen_paap_f could only be imported from linearmodels.iv.common.
Import them in linearmodels/iv/init.py and add them to its all, so
that from linearmodels.iv import cragg_donald works.

iv/common.py and iv/results.py had no all, so everything they import
counted as public: from linearmodels.iv.common import * returned 35 names,
including the NumPy functions, the GMM weight matrix classes and annihilate,
and the same import from iv.results returned 49, including cragg_donald and
cragg_donald_f. Add all to list only the public names:

  • iv.common: the four rank tests. find_constant and f_statistic are used by
    the models and stay importable, but are not listed.
  • iv.results: AbsorbingLSResults, FirstStageResults, IVGMMResults,
    IVModelComparison, IVResults, OLSResults and compare. stub_concat and
    table_concat are used by panel.results and stay importable, but are not
    listed.

Nothing that could be imported before has been removed, so only the star
import and tools that read all see a difference. The reference pages in
doc/source/iv/reference.rst document the same objects as before. A Sphinx
build of them and of the IV introduction gives the same warnings and the
same pages as main, apart from the source listings of the two modules.

linearmodels/tests/test_exports.py checks that:

  • every estimator in the all of linearmodels.iv, panel, system and
    asset_pricing (the classes that have a fit method) is exported by
    linearmodels and is the same object. The 18 estimators are also listed in
    the test, so that none can be dropped from the public API unnoticed;
  • IVJIVE is exported from linearmodels;
  • the four rank tests in linearmodels.iv are the objects in
    linearmodels.iv.common;
  • the all of iv.common and iv.results contain exactly the names above,
    and every all of the modules above has no duplicates or missing names.

10 of the 33 tests fail on main.

IVJIVE could only be imported from linearmodels.iv, while every other
estimator can be imported from linearmodels. Import it in
linearmodels/__init__.py and add it to __all__. The list of estimators in
the docstring of the package omitted IVJIVE and AbsorbingLS, so add both.

The first-stage rank tests cragg_donald, cragg_donald_f, kleibergen_paap
and kleibergen_paap_f could only be imported from linearmodels.iv.common.
Import them in linearmodels/iv/__init__.py and add them to its __all__, so
that `from linearmodels.iv import cragg_donald` works.

iv/common.py and iv/results.py had no __all__, so everything they import
counted as public: `from linearmodels.iv.common import *` returned 35 names,
including the NumPy functions, the GMM weight matrix classes and annihilate,
and the same import from iv.results returned 49, including cragg_donald and
cragg_donald_f. Add __all__ to list only the public names:

- iv.common: the four rank tests. find_constant and f_statistic are used by
  the models and stay importable, but are not listed.
- iv.results: AbsorbingLSResults, FirstStageResults, IVGMMResults,
  IVModelComparison, IVResults, OLSResults and compare. stub_concat and
  table_concat are used by panel.results and stay importable, but are not
  listed.

Nothing that could be imported before has been removed, so only the star
import and tools that read __all__ see a difference. The reference pages in
doc/source/iv/reference.rst document the same objects as before. A Sphinx
build of them and of the IV introduction gives the same warnings and the
same pages as main, apart from the source listings of the two modules.

linearmodels/tests/test_exports.py checks that:

- every estimator in the __all__ of linearmodels.iv, panel, system and
  asset_pricing (the classes that have a fit method) is exported by
  linearmodels and is the same object. The 18 estimators are also listed in
  the test, so that none can be dropped from the public API unnoticed;
- IVJIVE is exported from linearmodels;
- the four rank tests in linearmodels.iv are the objects in
  linearmodels.iv.common;
- the __all__ of iv.common and iv.results contain exactly the names above,
  and every __all__ of the modules above has no duplicates or missing names.

10 of the 33 tests fail on main.
The summary in the docstring of linearmodels/__init__.py ran over two lines
and ended with a colon, which numpydoc validation reports as SS06 (the
summary should fit in a single line) and SS03 (the summary does not end
with a period). Make the first sentence the summary and move the rest into
the extended summary. The words are unchanged.
@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.58%. Comparing base (208845b) to head (f64d558).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #765   +/-   ##
=======================================
  Coverage   99.58%   99.58%           
=======================================
  Files         110      111    +1     
  Lines       20328    20392   +64     
  Branches     1600     1607    +7     
=======================================
+ Hits        20244    20308   +64     
  Misses         31       31           
  Partials       53       53           
Flag Coverage Δ
adder 99.57% <100.00%> (+<0.01%) ⬆️
subtractor 99.57% <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.

This branch has not been deployed

No deployments
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