Refactor the _build_step_func dispatch in core_solver.py (around L1850) to reduce cyclomatic complexity.
Problem
The current dispatch logic triggers C901 (too complex) and is suppressed with a noqa comment. As solver methods grow, this will become increasingly unmaintainable.
Proposed approach
Replace the if/elif chain with a _PLAN_TO_STEP_FUNC mapping dict as Tim suggested:
_PLAN_TO_STEP_FUNC: dict[MethodName, Callable] = { ... }
if (step_func := _PLAN_TO_STEP_FUNC.get(plan.method)) is not None:
if plan.jacobian is None:
raise RuntimeError(_INTERNAL_ERROR_OP_AXIS_MSG)
return step_func(rhs_func, step=step, jacobian=plan.jacobian)
Related
Ref: PR #18 review by @TimothyWillard (L1850, L1918)
Refactor the
_build_step_funcdispatch incore_solver.py(around L1850) to reduce cyclomatic complexity.Problem
The current dispatch logic triggers C901 (too complex) and is suppressed with a
noqacomment. As solver methods grow, this will become increasingly unmaintainable.Proposed approach
Replace the if/elif chain with a
_PLAN_TO_STEP_FUNCmapping dict as Tim suggested:Related
Ref: PR #18 review by @TimothyWillard (L1850, L1918)