QuantEcon / QuantEcon/QuantEcon.py
RFC: Decompose the four grade-D complexity hotspots
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.4k
- Forks
- 2.3k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 3
Description
Problem
Radon rates exactly four functions at cyclomatic-complexity grade D — everything else in the package is C or better, so the complexity is concentrated and tractable:
| Function | Location | CC |
|---|---|---|
_compute_fixed_point_ig |
_compute_fp.py:159 |
25 |
DiscreteDP.__init__ |
markov/ddp.py:299 |
24 |
brent_max |
optimize/scalar_maximization.py:5 |
24 |
polym_lcp_solver |
game_theory/howson_lcp.py:36 |
23 |
DiscreteDP.__init__ alone dispatches dense/sparse × full/state-action-pairs input forms inline; _compute_fixed_point_ig interleaves algorithm and bookkeeping. High-CC plus hand-verified numerics is where regressions hide.
Proposed change
One PR per function; behavior-preserving extraction only:
DiscreteDP.__init__→ extract_parse_full_form(...)/_parse_sa_form(...)validators returning a normalized bundle._compute_fixed_point_ig→ separate the iteration loop from error/logging bookkeeping.brent_maxis Numba-jitted — some branching is inherent to Brent; treat as best-effort.- Guard with before/after output equality on existing tests (coverage in these regions is strong).
Related context: #480 (repeated logic in several modules).
Acceptance criteria
- Radon grade ≤ C for the three non-jitted functions; no public API change
- Suite green with unchanged numerical outputs
From the July 2026 technical-debt audit (AI-assisted; claims verified against 28d4b3b on 2026-07-25).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the four named entry points: _compute_fp.py:159, markov/ddp.py:299, optimize/scalar_maximization.py:5, and game_theory/howson_lcp.py:36, then run the existing suite and Radon. Work on one function per PR, preserving public APIs and numerical outputs; done means the three non-jitted functions reach Radon grade C or better and the suite remains green.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100