copperhead
copperhead copied to clipboard
[FIXED] some issues running tests (args not flattened and negative array ranges not working well?)
Hi I was trying to run the copperhead tests and I have found that some of them do not run, I suppose mainly for 3 reasons:
- some required functions in prelude.py are commented
- nested function's formal arguments seems to be not flattened before line 725 of rewrite.py
[FIX] I think I fixed it by moving the name_tuples step before the inline one
diff --git a/copperhead/compiler/passes.py b/copperhead/compiler/passes.py
index 6d5fa29..672e5bd 100644
--- a/copperhead/compiler/passes.py
+++ b/copperhead/compiler/passes.py
@@ -243,6 +243,7 @@ frontend = Pipeline('frontend', [gather_source,
procedure_flatten,
expression_flatten,
syntax_check,
+ name_tuples, # FIX: moved here to avoid inline errors with nested argument lists
inline,
cast_literals,
- [FIXED] there it seems to be an error in handling negative slices of arrays, e.g. test_rotate.py fails when the rotation is negative. This can be fixed by changing copperhead/prelude_impl.py by making the resulting index always positive
--- a/copperhead/prelude_impl.py
+++ b/copperhead/prelude_impl.py
@@ -88,7 +88,7 @@ def shift(x, a, d):
@cu
def rotate(x, a):
def torus_index(i, a, b):
- return (i + a) % b
+ return (i + a + b) % b # FIX: to be sure that the resulting value is positive
def rotate_el(i):
return x[torus_index(i, a, len(x))]
All the best AndreaS