From e830b0fc05de8cebead3196eff451c09e5c38709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Mon, 10 Jul 2023 10:53:31 -0600 Subject: [PATCH] Remove global variables Due to #2129, the global variables do not always work well. Until that issue is fixed, a simple workaround is to move these global variables into local variables. Reference tests updated. --- src/runtime/lpython_intrinsic_numpy.py | 7 ++++--- tests/reference/c-bindc_06-a30d20f.json | 2 +- tests/reference/c-bindc_06-a30d20f.stdout | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/runtime/lpython_intrinsic_numpy.py b/src/runtime/lpython_intrinsic_numpy.py index 17243dd994..43b1f3a8d7 100644 --- a/src/runtime/lpython_intrinsic_numpy.py +++ b/src/runtime/lpython_intrinsic_numpy.py @@ -1,8 +1,5 @@ from lpython import i32, i64, f64, f32, ccall, vectorize, overload -pi_64: f64 = f64(3.141592653589793238462643383279502884197) -pi_32: f32 = f32(3.141592653589793238462643383279502884197) - ########## sin ########## @ccall @@ -274,11 +271,13 @@ def arctan(x: f32) -> f32: @overload @vectorize def degrees(x: f64) -> f64: + pi_64: Const[f64] = f64(3.141592653589793238462643383279502884197) return x*180.0/pi_64 @overload @vectorize def degrees(x: f32) -> f32: + pi_32: Const[f32] = f32(3.141592653589793238462643383279502884197) return x*f32(f32(180)/pi_32) ########## radians ########## @@ -286,11 +285,13 @@ def degrees(x: f32) -> f32: @overload @vectorize def radians(x: f64) -> f64: + pi_64: Const[f64] = f64(3.141592653589793238462643383279502884197) return x*pi_64/180.0 @overload @vectorize def radians(x: f32) -> f32: + pi_32: Const[f32] = f32(3.141592653589793238462643383279502884197) return x*f32(pi_32/f32(180)) ########## arcsinh ########## diff --git a/tests/reference/c-bindc_06-a30d20f.json b/tests/reference/c-bindc_06-a30d20f.json index 2b91aefedc..6449300ee9 100644 --- a/tests/reference/c-bindc_06-a30d20f.json +++ b/tests/reference/c-bindc_06-a30d20f.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-bindc_06-a30d20f.stdout", - "stdout_hash": "6a93f686a1c2fe616c5de50dd3e339f5db7d226f48b29e5569412402", + "stdout_hash": "7fdf946af48e4b286aa2a5a328ed8edb8e50b98c252f7290f273d1a0", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-bindc_06-a30d20f.stdout b/tests/reference/c-bindc_06-a30d20f.stdout index a9e0d8e2fe..e99f8e9dcc 100644 --- a/tests/reference/c-bindc_06-a30d20f.stdout +++ b/tests/reference/c-bindc_06-a30d20f.stdout @@ -81,8 +81,6 @@ float _lfortran_caimag(float complex x); double _lfortran_zaimag(double complex x); -float pi_32 = 3.14159265358979312e+00; -double pi_64 = 3.14159265358979312e+00; double _lfortran_dacos(double x); double _lfortran_dacosh(double x);