Skip to content

MAINT: Add tests for quantecon/timings and deduplicate its accessors #889

Closed as not planned

Description

@mmcky

Problem

quantecon/timings/ is the only subpackage with no test file at all, yet it exposes public API — qe.timings.float_precision() is reachable from the top-level namespace. It is 66 lines with two public functions and a module-level mutable global. Three things to address:

  1. No tests. float_precision() has a validation branch (ValueError for non-integer or negative input) and get/set dual behaviour, neither exercised. The module-level global means tests need to restore state — worth getting right in the first test rather than retrofitting.
  2. Two names for one read. float_precision() called with no argument and get_default_precision() return the same value by the same mechanism. One can go, or the relationship should be documented — as it stands a reader cannot tell which is canonical.
  3. Docstring examples are doctest-shaped but never executed (adjacent: Run docstring examples in CI (--doctest-modules) #866 on running doctests in CI), so they are unverified prose that reads as tested.

Acceptance criteria

  • A test module covering get, set, validation errors, and state restoration between tests
  • The duplicate accessor removed, or its relationship to float_precision() documented
  • Doctest examples either run under a configured doctest collector or are reformatted so they don't claim to be tested

From the July 2026 technical-debt audit (AI-assisted; claims verified against 28d4b3b on 2026-07-25).

Activity

  1. lntutor commented on Jul 26, 2026

    @lntutor

    I’m taking this. I’ll add isolated coverage for the get/set/error paths with state restoration, document the accessor relationship without breaking compatibility, and revise the uncollected doctest-style examples.

  2. quantecon-services commented on Sep 9, 2026

    @quantecon-services
    Collaborator

    Closing this with a correction, since the premise turned out to be only partly right.

    Criterion 1 (no tests) was already satisfied when the issue was opened. quantecon/timings/ has no test directory, but the module is fully exercised by TestGlobalPrecision in quantecon/util/tests/test_timing.py: get, set, all three ValueError paths (negative int, float, string), and state restoration via setup_method/teardown_method. Running that file alone gives 100% line coverage of quantecon/timings/timings.py on main. The audit checked for a test file per directory rather than by coverage, which is how this slipped through.

    Criterion 2 (accessor relationship undocumented) was real but small. Removing get_default_precision() is not an option since quantecon/util/timing.py calls it in three places as the read-only accessor. #959 documents the relationship in its docstring.

    Criterion 3 (doctest examples never run) is being handled more broadly. The only thing that fails under strict doctest is the print(...) line with no expected output; #959 repairs that single line and keeps the >>> examples so the module is ready for the package-wide docstring sweep in #920.

    Two PRs were opened against this issue and both authors put in careful work:

    Sorry to both of you for the wasted effort here. The issue description sent you after a problem that was already solved, and that is on us, not you.


    Generated by Claude Code

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions