Skip to content

acpiv uses an incorrect chained comparison for validation (if S == I is None:) #136

@marcostfermin

Description

@marcostfermin

Describe the bug

acpiv() validates inputs using if S == I is None:, which is a chained comparison equivalent to (S == I) and (I is None). This is not the intended “too few args” check and can let invalid argument combinations slip through (or behave inconsistently).

https://electricpy.readthedocs.io/en/latest/_modules/electricpy.html

Reproduction Code

# Setup
import electricpy as ep

# Code which causes failure
# Only S is provided; I and voltages are missing.
# This should be rejected early as "too few arguments" / insufficient specification,
# but the current check is not actually checking "S is None and I is None".
try:
    ep.acpiv(S=550)
except Exception as e:
    print("Raised:", type(e).__name__, e)
else:
    print("No exception raised (unexpected for insufficient inputs).")

Expected behavior

A clear, deterministic validation error for insufficient inputs (e.g., ValueError) before later operations attempt to use missing values.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Linux]
  • Python Version [3.11.6]
  • Version [0.4.0]

Additional context

That line should almost certainly be something like:

if (S is None) and (I is None): ...
(or a fuller validation that enforces “exactly two of {S, I, V*} must be provided”, etc.).

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions