From abcf694721cf12b367cb1efac9dc38bc7b698f2e Mon Sep 17 00:00:00 2001 From: Eliza Sorber <53704365+elizasorber@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:16:46 -0400 Subject: [PATCH] Deprecating `lambdify` decorator (#1823) Deprecated `lambdify` decorator. The decorator is removed from `pyccel/decorators.py` and the tests that use it are removed (`tests/symbolic/scripts/lambdas.py`, and `tests/symbolic/scripts/neural_net.py`) --------- Co-authored-by: EmilyBourne --- CHANGELOG.md | 1 + pyccel/decorators.py | 11 ----------- tests/symbolic/scripts/lambdas.py | 14 -------------- tests/symbolic/scripts/neural_net.py | 22 ---------------------- 4 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 tests/symbolic/scripts/lambdas.py delete mode 100644 tests/symbolic/scripts/neural_net.py diff --git a/CHANGELOG.md b/CHANGELOG.md index d9473fc4af..b6803082eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ All notable changes to this project will be documented in this file. ### Deprecated +- #1820 : Deprecated unused decorator `@lambdify` - #1786 : Remove support for `real` and `integer` as type annotations. - #1812 : Stop allowing multiple main blocks inside a module. - \[INTERNALS\] Remove property `ast.basic.TypedAstNode.precision`. diff --git a/pyccel/decorators.py b/pyccel/decorators.py index a12f13b36f..9946a2a1f8 100644 --- a/pyccel/decorators.py +++ b/pyccel/decorators.py @@ -13,7 +13,6 @@ 'bypass', 'elemental', 'inline', - 'lambdify', 'private', 'pure', 'stack_array', @@ -22,16 +21,6 @@ 'types', ) -def lambdify(f): - - args = f.__code__.co_varnames - from sympy import symbols - args = symbols(args) - expr = f(*args) - def wrapper(*vals): - return expr.subs(zip(args,vals)).doit() - - return wrapper def sympy(f): return f diff --git a/tests/symbolic/scripts/lambdas.py b/tests/symbolic/scripts/lambdas.py deleted file mode 100644 index 828674e593..0000000000 --- a/tests/symbolic/scripts/lambdas.py +++ /dev/null @@ -1,14 +0,0 @@ -# pylint: disable=missing-function-docstring, missing-module-docstring -# coding: utf-8 - -f1 = lambda x: x**2 + 1 -f2 = lambda x,y: x**2 + f1(y)*f1(x) -g1 = lambda x: f1(x)**2 + 1 - -# lambda expressions can be printed - -#$ header m1(double) -m1 = lambdify(g1) -print(f1) -print(f2) -print(g1) diff --git a/tests/symbolic/scripts/neural_net.py b/tests/symbolic/scripts/neural_net.py deleted file mode 100644 index 2d491fad8f..0000000000 --- a/tests/symbolic/scripts/neural_net.py +++ /dev/null @@ -1,22 +0,0 @@ -# pylint: disable=missing-function-docstring, missing-module-docstring -#$ header function f(double[:],double[:,:,:],int) -@sympy -def g(v,w,i): - from sympy import Lambda, Function ,symbols ,IndexedBase,Idx ,Max, Sum - x = Function('x') - i, n, j, dim, k =symbols('i, n, j, dim, k') - v=IndexedBase('v') - w=IndexedBase('w') - net = Lambda((i, n, dim, k), Max(0.0, Sum(x(k)*w[n, k, i], (k, 0, dim-1)))) - dim = [10**4]*10 - index =[symbols('i%s'%m) for m in range(len(dim)+1)] - y = [0]*len(dim) - new = v[index[0]] - for n in range(len(dim)): - y[n] = net(index[n+1], n, dim[n], index[n]) - y[n] = y[n].subs(x(index[n]), new) - new = y[n] - return y[-1] - -f=lambdify(g) -