Skip to content

Six objects in the deprecated shims' __all__ are missing from the top-level quantecon namespace #853

Open

Description

@mmcky

Summary

While refreshing the API-reference docs in #850, I found that six objects are listed in the deprecated compatibility shims' __all__ but were never re-exported into the top-level quantecon namespace. As a result, from quantecon import <name> raises ImportError for these six today — even though each shim's own DeprecationWarning explicitly tells users to import them "from the quantecon namespace."

The six objects

Object Shim (in its __all__) Implementation module Re-exported in quantecon/__init__.py?
ckron quantecon.ce_util _ce_util No
gridmake quantecon.ce_util _ce_util No
annotate_nodes quantecon.graph_tools _graph_tools No
num_compositions_jit quantecon.gridtools _gridtools No
simulate_linear_model quantecon.lss _lss No
solve_discrete_riccati_system quantecon.matrix_eqn _matrix_eqn No

The curation looks deliberate — sibling objects in the same modules are promoted while these are not: LinearStateSpace but not simulate_linear_model; solve_discrete_riccati but not solve_discrete_riccati_system; num_compositions but not num_compositions_jit. _ce_util is not imported into __init__.py at all. There is even a #->Propose Delete From Top Level block in __init__.py, so the top-level surface has clearly been managed by hand.

Why it matters

1. The deprecation guidance is currently broken for these six. Accessing one through its shim, e.g. quantecon.lss.simulate_linear_model, emits:

Please use simulate_linear_model from the quantecon namespace, the quantecon.lss namespace is deprecated. You can use the following instead: from quantecon import simulate_linear_model.

…but from quantecon import simulate_linear_model then raises ImportError. A user who follows the warning hits a dead end. This is independent of the docs — it's a package-level inconsistency.

2. It surfaced as a docs question in #850. That PR moves the base-level API pages from documenting the deprecated shim / private module to documenting the public objects in the quantecon namespace. Because these six aren't in that namespace, they can't be documented as quantecon.<name>. For reference, how each version represents them:

Version Rendered heading for these six
Published latest (main) quantecon.lss.simulate_linear_model, quantecon.ce_util.ckron, … (deprecated shim namespace)
#850 head, earlier commit quantecon._lss.simulate_linear_model, … (private implementation module)
#850 head, current commit dropped from the docs (they don't resolve as quantecon.<name>)

Options (from the #850 discussion)

  1. Promote to quantecon.* — add the six to quantecon/__init__.py. The docs then render quantecon.simulate_linear_model etc. cleanly and consistently, and the shims' "import from the quantecon namespace" guidance finally works. This expands the public API surface by six names.
  2. Document via the implementation module — the docs generator falls back to quantecon._lss.simulate_linear_model for just these six. No API change and nothing is dropped, but those six pages show a private _module heading.
  3. Omit from the API reference — treat all six as internal. Cleanest public reference and no API change, but drops six functions that the currently-published docs still show.

For discussion

A per-object call may make sense rather than one blanket choice — e.g. num_compositions_jit reads as a deliberately-internal numba-jitted variant of the public num_compositions and is a natural "keep internal", whereas simulate_linear_model and solve_discrete_riccati_system look like reasonable public functions whose omission may simply be an oversight.

Whatever we decide, two cleanups fall out of it:

Raised so the team can weigh in — happy to implement whichever direction we land on. Related: #850, #852.

Activity

  1. mmcky commented on Jul 23, 2026

    @mmcky
    ContributorAuthor

    Re-confirmed this while auditing the docs in #864. Three things turned up that I think narrow the decision.

    None of the six has ever been in quantecon/__init__.py. git log -S<name> -- quantecon/__init__.py returns no commits for any of them. So this is not a regression or an accidental omission — the shims' __all__ mirrors the private implementation module's public surface, not the top-level namespace. Read that way, the __all__ lists are over-broad rather than the namespace being under-populated, which slightly favours stripping over exporting.

    annotate_nodes has no docstring at all. The other five do. Promoting an undocumented function to public API seems like the wrong direction, and it would render as an empty entry on the graph_tools page.

    Emptying ce_util.__all__ is not a clean option. write_base_module in qe_apidoc.py falls back to a plain automodule directive when __all__ is empty or absent:

    if not (os.path.exists(impl) and public_names):
        f.write(module_template.format(mod_name=name, equals=equals))
        return

    For ce_util, whose entire __all__ is ['ckron', 'gridmake'], stripping both would emit .. automodule:: quantecon.ce_util — re-importing the deprecated shim during the docs build and emitting DeprecationWarnings on every attribute access. That is exactly the behaviour #850 set out to eliminate. So ckron and gridmake must either be exported or lose their page entirely; there is no quiet middle option for that module. The other four shims keep other entries, so stripping a single name from graph_tools, gridtools, lss or matrix_eqn leaves those pages intact.

    Suggested split, if it is useful as a starting point: export ckron, gridmake, simulate_linear_model and solve_discrete_riccati_system — all documented, all genuinely user-facing, and all already reachable via the shim path the deprecation message points at. Strip annotate_nodes (undocumented) and num_compositions_jit (a jit dispatcher, and an implementation detail alongside the already-public num_compositions) from graph_tools.__all__ and gridtools.__all__.

    For context on urgency: these six are the only remaining warnings in the Sphinx build after #864, and docs/source/tools/ce_util.rst currently renders with a title and no body. #864 deliberately leaves them untouched, and its CI docs job builds without -W for that reason — resolving this would let the build be made warning-clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions