From 45eef013c6bad52686151475ea6e2018cc1df4eb Mon Sep 17 00:00:00 2001 From: Rebecca Chen <rechen@google.com> Date: Wed, 30 Aug 2023 15:34:11 -0700 Subject: [PATCH 1/3] Remove usage of deprecated np.alltrue(). np.alltrue is recently deprecated: https://numpy.org/doc/stable/release/1.25.0-notes.html#deprecations. I left np.all aliased to alltrue because `all` is also the name of a builtin, and some linters complain if you overwrite a builtin. --- numexpr/tests/test_numexpr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numexpr/tests/test_numexpr.py b/numexpr/tests/test_numexpr.py index ff80206..d296b50 100644 --- a/numexpr/tests/test_numexpr.py +++ b/numexpr/tests/test_numexpr.py @@ -20,7 +20,7 @@ import numpy as np from numpy import ( array, arange, empty, zeros, int32, int64, uint16, complex_, float64, rec, - copy, ones_like, where, alltrue, linspace, + copy, ones_like, where, all as alltrue, linspace, sum, prod, sqrt, fmod, floor, ceil, sin, cos, tan, arcsin, arccos, arctan, arctan2, sinh, cosh, tanh, arcsinh, arccosh, arctanh, From 4f46368b45d3c749dccca3e5f5c65615a8f107c8 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT <thomas.vincent@esrf.fr> Date: Wed, 13 Sep 2023 10:58:47 +0200 Subject: [PATCH 2/3] allow digits after . --- numexpr/necompiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numexpr/necompiler.py b/numexpr/necompiler.py index 0414ed0..f5ef5b7 100644 --- a/numexpr/necompiler.py +++ b/numexpr/necompiler.py @@ -265,7 +265,7 @@ def __str__(self): _flow_pat = r'[\;\[\:]' _dunder_pat = r'__[\w]+__' -_attr_pat = r'\.\b(?!(real|imag|[eE]?[+-]?\d+)\b)' +_attr_pat = r'\.\b(?!(real|imag|\d*[eE]?[+-]?\d+)\b)' _blacklist_re = re.compile(f'{_flow_pat}|{_dunder_pat}|{_attr_pat}') def stringToExpression(s, types, context, sanitize: bool=True): From 167a072e0ba4e03b9bcab622ce1de974f88c9a0f Mon Sep 17 00:00:00 2001 From: Thomas VINCENT <thomas.vincent@esrf.fr> Date: Wed, 13 Sep 2023 10:59:01 +0200 Subject: [PATCH 3/3] add tests --- numexpr/tests/test_numexpr.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/numexpr/tests/test_numexpr.py b/numexpr/tests/test_numexpr.py index c45f822..ca3f377 100644 --- a/numexpr/tests/test_numexpr.py +++ b/numexpr/tests/test_numexpr.py @@ -568,6 +568,8 @@ def test_sanitize(self): evaluate('a*2e-5') evaluate('a*2e+5') evaluate('a*2E-5') + evaluate('a*2.0e5') + evaluate('a*2.2e5') evaluate('2.+a') # pass .real and .imag