Skip to content

Commit

Permalink
Fix replacement bug 0 -> 0j -> j -> 1j
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Muenker <mail@chipmuenk.de>
  • Loading branch information
chipmuenk committed Nov 4, 2022
1 parent 0d85353 commit 36dcf47
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyfda/libs/pyfda_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,9 @@ def safe_numexpr_eval(expr: str, fallback=None,
f"'{type(expr).__name__}', replacing with zero.")
expr = "0.0"

expr = expr.lstrip('0') # remove trailing zeros which cannot be processed
# Find one or more redundant zeros '0+' at the beginning '^' leading a number [0-9]
# Group the number(s) '(...)' and write it '\1' to the resulting string.
expr = re.sub(r'^0+([0-9])', r'\1', expr)
if len(expr) == 0:
expr = "0"
else:
Expand Down

0 comments on commit 36dcf47

Please sign in to comment.