Skip to content

Fix make_trap dispatch passing a spurious self to bound methods#11

Open
zhaozhiwen wants to merge 1 commit into
gemc:mainfrom
zhaozhiwen:fix/120-make-trap-self
Open

Fix make_trap dispatch passing a spurious self to bound methods#11
zhaozhiwen wants to merge 1 commit into
gemc:mainfrom
zhaozhiwen:fix/120-make-trap-self

Conversation

@zhaozhiwen

Copy link
Copy Markdown
Collaborator

make_trap() called self.make_trap_from_right_angular_wedges(self, *params, lunit1) and self.make_trap_from_vertices(self, *params, lunit1). These are already-bound instance methods, so self is supplied automatically; the extra self (plus a positional lunit1) overflowed the parameter list and raised TypeError. The 4-param and 24-param trap constructors were completely broken; only the 11-param path worked.

Drop the spurious self and pass the unit by keyword (unit=/lunit1=).

Validation: 4-param, 24-param, and 11-param make_trap() all build a G4Trap (the 4- and 24-param paths previously raised TypeError), with the length unit correctly applied (Python 3.12).

Fixes #5

make_trap() called self.make_trap_from_right_angular_wedges(self, *params,
lunit1) and self.make_trap_from_vertices(self, *params, lunit1). These are
already-bound instance methods, so self is supplied automatically; the
extra self (plus a positional lunit1) overflowed the parameter list and
raised TypeError. The 4-param and 24-param trap constructors were
completely broken; only the 11-param path worked.

Drop the spurious self and pass the unit by keyword so it maps to the
unit/lunit1 parameter rather than overflowing positionals.

Verified: 4-param, 24-param, and 11-param make_trap() all build a G4Trap
(the 4- and 24-param paths previously raised TypeError), with the length
unit correctly applied (Python 3.12).

Fixes gemc#5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[High] make_trap() passes an extra self to already-bound methods, raising TypeError

1 participant