Skip to content

Guard to_lab_frame/to_cm_frame against undefined product/residual#74

Merged
beykyle merged 2 commits intowip-elmfrom
copilot/sub-pr-73
Feb 28, 2026
Merged

Guard to_lab_frame/to_cm_frame against undefined product/residual#74
beykyle merged 2 commits intowip-elmfrom
copilot/sub-pr-73

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 28, 2026

Reaction.to_lab_frame() and to_cm_frame() unconditionally dereferenced self.product and self.residual, causing an opaque AttributeError for reaction types where these are None (e.g. tot, non, x).

Changes

  • reaction.py: Both methods now validate self.product and self.residual upfront, raising a descriptive ValueError before any dereference occurs.
# Before: silent AttributeError at runtime
rxn = Reaction("tot", ...)
rxn.to_lab_frame(theta, Ecm, Q)  # AttributeError: 'NoneType' has no attribute 'm0'

# After: clear ValueError with context
# ValueError: to_lab_frame() requires both product and residual to be defined.
# This reaction (tot) does not have a defined product and/or residual.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: beykyle <22779182+beykyle@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback from PR #73 review Guard to_lab_frame/to_cm_frame against undefined product/residual Feb 28, 2026
@beykyle beykyle marked this pull request as ready for review February 28, 2026 18:08
@beykyle beykyle merged commit deaef0f into wip-elm Feb 28, 2026
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.

2 participants