Skip to content

Fix CSA_motor_efficiency UnboundLocalError for unsupported pole counts - #98

Open
yuhuavit-hash wants to merge 1 commit into
CalebBell:masterfrom
yuhuavit-hash:fix-csa-motor-efficiency-poles
Open

Fix CSA_motor_efficiency UnboundLocalError for unsupported pole counts#98
yuhuavit-hash wants to merge 1 commit into
CalebBell:masterfrom
yuhuavit-hash:fix-csa-motor-efficiency-poles

Conversation

@yuhuavit-hash

Copy link
Copy Markdown

CSA_motor_efficiency raises an UnboundLocalError (instead of a clear error) when the requested pole count has no standard table: 8-pole motors have no high-efficiency values, and pole counts other than 2/4/6/8 are not in any table.

>>> from fluids.pump import CSA_motor_efficiency
>>> from fluids.constants import hp
>>> CSA_motor_efficiency(100*hp, poles=8, high_efficiency=True)
UnboundLocalError: cannot access local variable 'efficiency'

This adds input validation up front, raising a ValueError with a clear message for unsupported pole counts (matching the style of current_ideal's phase validation), and documents the supported pole counts in the docstring.

Changes

  • fluids/pump.py: validate poles before table lookup
  • tests/test_pump.py: add boundary cases (poles=8 + high_efficiency, poles=3)

Verification

  • python -m pytest tests/test_pump.py — 12 passed
  • python -m pytest -m "not slow" — 1764 passed

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.

1 participant