Skip to content

Commit eaa520e

Browse files
Merge pull request #451 from t20100/fix-scientific-notation
Fix scientific notation support
2 parents 51f66ec + 167a072 commit eaa520e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

numexpr/necompiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def __str__(self):
265265

266266
_flow_pat = r'[\;\[\:]'
267267
_dunder_pat = r'__[\w]+__'
268-
_attr_pat = r'\.\b(?!(real|imag|[eE]?[+-]?\d+)\b)'
268+
_attr_pat = r'\.\b(?!(real|imag|\d*[eE]?[+-]?\d+)\b)'
269269
_blacklist_re = re.compile(f'{_flow_pat}|{_dunder_pat}|{_attr_pat}')
270270

271271
def stringToExpression(s, types, context, sanitize: bool=True):

numexpr/tests/test_numexpr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ def test_sanitize(self):
568568
evaluate('a*2e-5')
569569
evaluate('a*2e+5')
570570
evaluate('a*2E-5')
571+
evaluate('a*2.0e5')
572+
evaluate('a*2.2e5')
571573
evaluate('2.+a')
572574

573575
# pass .real and .imag

0 commit comments

Comments
 (0)