Skip to content

Commit

Permalink
fix binary/octal numbers
Browse files Browse the repository at this point in the history
complete a fix few commits back
  • Loading branch information
idanpa committed Apr 12, 2024
1 parent 3446719 commit 338ccca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions calcpy/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ def auto_prod_replace(match):
return match[0]

if ip.calcpy.auto_product:
# number - binary | hex | engineering number | number
num_pat = r'0[bB][01]*|0[xX][0-9a-fA-F]*|\d*\.?\d+e-?\d+|\d*\.?\d+'
# number - binary/octal/hex | engineering number | number
num_pat = r'0[bBoOxX][0-9a-fA-F]*|\d*\.?\d+e-?\d+|\d*\.?\d+'
# prod - (format spec|middle of name detection)?(number)(var name)?
prod_pat = rf'(: *|[^\d\W])?({num_pat})({var_pat})?'
code = re.sub(prod_pat, auto_prod_replace, code)

# pattern is (right parentheses)(binary | hex | engineering number | number | var name)
prod_pat = rf'(\))(0[bB][01]*|0[xX][0-9a-fA-F]*|\d*\.?\d+e-?\d+|\d*\.?\d+|{var_pat})'
# pattern is (right parentheses)(binary/octal/hex | engineering number | number | var name)
prod_pat = rf'(\))(0[bBoOxX][0-9a-fA-F]*|\d*\.?\d+e-?\d+|\d*\.?\d+|{var_pat})'
code = re.sub(prod_pat, r'\1*\2', code)

for key, val in latex_matches.items():
Expand Down

0 comments on commit 338ccca

Please sign in to comment.