fix: inverted loop condition in chaos_machine.py prevents execution - #14777
aeyjeyaryan wants to merge 5 commits into
Conversation
The while loop condition was inverted — it should be . The loop that pulls output data and prompts the user for exit never executed. Also: - Add type hints to all functions - Add module-level docstring with references - Add docstrings with doctests to pull() - Fix reset() to copy K instead of aliasing it (prevented repeated reset) - Remove deprecated in favor of built-in
Co-authored-by: Christian Clauss <cclauss@me.com>
|
@priya-sundaram-dev, please review. |
|
Thanks @cclauss — reviewed. Mixed bag here; the title oversells and there's some dead code, but there's one genuinely good fix buried in it. Title is inaccurate. The PR is titled "inverted loop condition ... prevents execution," but the diff doesn't change any loop condition — both The real, worthwhile fix: Dead code to remove: the new nested Nice: the added docstrings + doctests are welcome and pass locally. Net: if the author (1) fixes the title, (2) removes or wires-up the unused |
Describe your change:
Fixes an inverted while-loop condition in
hashes/chaos_machine.pythat prevented the output-pulling loop from ever executing.Checklist:
Summary of changes
Bug fix: The while-loop condition on line 98 was
while inp in ("e", "E"):. Sinceinpis initialized as"", the loop never executed. Changed towhile inp not in ("e", "E"):.Additional improvements:
push,pull,reset)pull()reset()to copyKwithK.copy()instead of aliasing it (buffer_space = K), preventing mutation of the constant initial state on repeatedreset()callstyping.Listwith built-inlistAll checks pass:
ruff,ruff format,mypy, anddoctest.