Repository navigation
motors: name anchors after the machine, not their position in the file - #27
Conversation
|
Please use git mv instead of a hard-copy so that I can see the actual changes. |
fc0d469 to
745560c
Compare
`Geometry2`/`Computation2` are named for being the second machine defined, not for the machine they describe. Nothing in the name says 5-phase or 40-slot, and nothing distinguishes it from the other 5-phase variants people run on branches. One module per anchor, named `<class>_<phases>f_<slots>s`: motors/motor1.py -> motors/synrm_3f_36s.py motors/motor2.py -> motors/synrm_5f_40s.py Each exports plain `Geometry` and `Computation`, so the module name carries the identity and the class names stay uniform. The numbering existed only because both machines shared a namespace; per-anchor modules remove the need for it. from motors.synrm_5f_40s import Computation, Geometry The name carries only what the anchor fixes for good -- class, phases, slots. Turns are deliberately left out: `Nc` is routinely swept, so a name containing it goes stale. Same reasoning for currents and bus voltage. Also restores the anchor definition to CONTRIBUTING (it survives on the `contributing` branch but was dropped in #23, leaving "anchor" used three times and never defined, and the sentence "add an **motors**" mid-substitution), and fixes that sentence. No behaviour change: the two anchor modules were diffed against the `motor1.py` / `motor2.py` they replace, with the class renames normalised away, and are identical apart from a one-line docstring -- including the fixes from #28 and #29, which landed in `motor2.py` while this branch was open and had to be carried across by hand. Callers must update their import path; there is no compatibility shim, so a stale import fails loudly rather than silently resolving to an aliased class. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Good catch — I did use Dropped the shims and force-pushed. It now reports as renames: 39/15 instead of the previous 741/699. The only content changes are a one-line docstring per anchor module, the class renames in the 5-phase one, and import paths. I also reverted the test-fixture renames I'd made ( Verified independently of the diff: both anchor modules were compared against the One consequence of dropping the shims: callers must update the import path, and there is no alias, so a stale import fails loudly instead of silently resolving. That affects |
745560c to
a27793b
Compare
Closes #26.
The problem
Geometry2/Computation2are named for being the second machine defined, not for the machine they describe.CONTRIBUTING.mduses the word "anchor" three times and never defines it — the defining section survives on thecontributingbranch and was dropped in #23, leaving line 63 reading "add an motors" mid-substitution. Detail in #26.What changed
Pure rename plus docs — no behaviour change.
motors/motor1.py→Geometry,Computationmotors/synrm_3f_36s.py→Geometry,Computationmotors/motor2.py→Geometry2,Computation2motors/synrm_5f_40s.py→Geometry,ComputationOne module per anchor, named
<class>_<phases>f_<slots>s. Each exports plainGeometry/Computation, so the module name carries the identity and the class names stay uniform:The numbering existed only because both machines shared one namespace. Per-anchor modules remove the need for it, rather than trading
Geometry2for a longer awkward class name.Turns are deliberately not in the name.
Ncis routinely swept, so a name containing it goes stale; the name carries only what the anchor fixes for good — class, phases, slots. Same reasoning for currents and bus voltage.Old paths kept as deprecation shims.
motors/motor1.pyandmotors/motor2.pyre-export the old names, so branches predating this keep importing and migrate on their own schedule. Verified:motors.motor2.Geometry2 is motors.synrm_5f_40s.Geometry→True.Also: each anchor module gets a one-line docstring naming its machine, the two test modules follow the anchor names, and CONTRIBUTING regains the anchor definition with the
motors/layout row and the "add an motors" sentence fixed.Verification
Both anchor modules were diffed against the
motor1.py/motor2.pythey replace, with the class renames normalised away: identical apart from the rename and the docstring.pytest→ 26 passed, 1 deselected — same asmainruff check ./ruff format . --check→ cleanOne thing reviewers should know about renames
#28 and #29 both landed in
motor2.pywhile this branch was open, and this PR produced no merge conflict for either — because moving a file makes the new path an unrelated add, so git replays the branch's copy verbatim and silently drops what landed meanwhile. Both fixes (np.arrayunit conversion + itsimport numpy as np, and theset_derived_paramsstub removal) had to be carried across by hand and re-verified by diff.That is an argument for landing a rename promptly rather than letting it age: every subsequent fix to the moved file has to be hand-carried, with nothing to warn you.