Skip to content

Commit

Permalink
Show phasor if single cpt in superposition
Browse files Browse the repository at this point in the history
  • Loading branch information
mph- committed Jan 3, 2025
1 parent c444fca commit e52c18c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lcapy/super.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ def _representation(self):
key = list(decomp)[0]
if key in ('dc', 't'):
return decomp[key]
if key in ('s', 'f', 'omega'):
elif key in ('s', 'f', 'omega'):
expr = decomp[key]
if expr.has(expr.var):
return decomp[key]
# Have something like s * 0 + 1 so don't display as 1
# since not a dc value.
elif not isinstance(key, str):
# Have phasor
return decomp[key]

# Have a superposition.
# It is probably less confusing to a user to display
Expand Down Expand Up @@ -355,8 +358,11 @@ def _is_s_arg(x):

x = expr(x)
# Perhaps check if a constant?
if x.is_undefined:
x = x.as_quantity(self.quantity)
try:
if x.is_undefined:
x = x.as_quantity(self.quantity)
except:
pass

if x.quantity != self.quantity:
raise ValueError('Incompatible quantities %s and %s' %
Expand Down

0 comments on commit e52c18c

Please sign in to comment.