From f607bc5bc464cf12ca6de025633c634c8b959dd4 Mon Sep 17 00:00:00 2001 From: AjaySDwivedi1 Date: Wed, 20 Mar 2024 18:36:42 -0400 Subject: [PATCH 1/4] Add support for char as a type annotation --- pyccel/ast/type_annotations.py | 1 + tests/pyccel/test_pyccel.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/pyccel/ast/type_annotations.py b/pyccel/ast/type_annotations.py index bafc7373ec..739fd25ff5 100644 --- a/pyccel/ast/type_annotations.py +++ b/pyccel/ast/type_annotations.py @@ -348,4 +348,5 @@ def __eq__(self, o): 'void' : VoidType(), '*' : GenericType(), 'str' : StringType(), + 'char' : CharType(), } diff --git a/tests/pyccel/test_pyccel.py b/tests/pyccel/test_pyccel.py index 1297224d6a..c333b1e285 100644 --- a/tests/pyccel/test_pyccel.py +++ b/tests/pyccel/test_pyccel.py @@ -1189,3 +1189,12 @@ def test_time_execution_flag(): assert 'Total' in result_lines[-2] for l in result_lines[1:-1]: assert ' : ' in l + +#------------------------------------------------------------------------------ +def test_char: + if __name__ == '__main__': + string = np.empty((2, 5), dtype='c') + string[0] = "HELLO" + string[1] = "WORLD" + for i in range(5): + print(string[0,i], end='') \ No newline at end of file From 3802f70911bba565ee3f826f42c50d081c04dbba Mon Sep 17 00:00:00 2001 From: AjaySDwivedi1 Date: Fri, 22 Mar 2024 15:10:45 -0400 Subject: [PATCH 2/4] Changed the test file --- tests/pyccel/test_pyccel.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/pyccel/test_pyccel.py b/tests/pyccel/test_pyccel.py index c333b1e285..fad112a55b 100644 --- a/tests/pyccel/test_pyccel.py +++ b/tests/pyccel/test_pyccel.py @@ -1191,10 +1191,6 @@ def test_time_execution_flag(): assert ' : ' in l #------------------------------------------------------------------------------ -def test_char: - if __name__ == '__main__': - string = np.empty((2, 5), dtype='c') - string[0] = "HELLO" - string[1] = "WORLD" - for i in range(5): - print(string[0,i], end='') \ No newline at end of file +def test_char(language): + types = str + pyccel_test("scripts/c_arrays.py", language = language, output_dtype = types) \ No newline at end of file From 5598f1ad3228cb8485bafa1131a6d685cb5afb8f Mon Sep 17 00:00:00 2001 From: AjaySDwivedi1 Date: Thu, 28 Mar 2024 09:35:58 -0400 Subject: [PATCH 3/4] Made a couple of changes for the type_annotations. Still creating the test functions --- pyccel/ast/type_annotations.py | 2 +- pyccel/stdlib/internal/lapack.pyh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pyccel/ast/type_annotations.py b/pyccel/ast/type_annotations.py index 739fd25ff5..6dd0b0dd4a 100644 --- a/pyccel/ast/type_annotations.py +++ b/pyccel/ast/type_annotations.py @@ -13,7 +13,7 @@ from .core import FunctionDefArgument -from .datatypes import PythonNativeBool, PythonNativeInt, PythonNativeFloat, PythonNativeComplex +from .datatypes import CharType, PythonNativeBool, PythonNativeInt, PythonNativeFloat, PythonNativeComplex from .datatypes import VoidType, GenericType, StringType from .variable import DottedName, AnnotatedPyccelSymbol, IndexedElement diff --git a/pyccel/stdlib/internal/lapack.pyh b/pyccel/stdlib/internal/lapack.pyh index 4478bf3e1d..c42f71e261 100644 --- a/pyccel/stdlib/internal/lapack.pyh +++ b/pyccel/stdlib/internal/lapack.pyh @@ -286,12 +286,12 @@ #$ header function sgetrf(int32, int32, float32[:,:](order=F), int32, int32 [:], int32) #$ header function dgetrf(int32, int32, float64 [:,:](order=F), int32, int32 [:], int32) -#$ header function sgetrs(str, int32, int32, float32 [:,:](order=F), int32, float32 [:], float32 [:,:](order=F), int32, int32) -#$ header function dgetrs(str, int32, int32, float64 [:,:](order=F), int32, int32 [:], float64 [:,:](order=F), int32, int32) +#$ header function sgetrs(char, int32, int32, float32 [:,:](order=F), int32, float32 [:], float32 [:,:](order=F), int32, int32) +#$ header function dgetrs(char, int32, int32, float64 [:,:](order=F), int32, int32 [:], float64 [:,:](order=F), int32, int32) -#$ header function sgecon(str, int32, float32 [:,:](order=F), int32, float32, float32, float32 [:], int32 [:], int32) -#$ header function dgecon(str, int32, float64 [:,:](order=F), int32, float64, float64, float64 [:], int32 [:], int32) +#$ header function sgecon(char, int32, float32 [:,:](order=F), int32, float32, float32, float32 [:], int32 [:], int32) +#$ header function dgecon(char, int32, float64 [:,:](order=F), int32, float64, float64, float64 [:], int32 [:], int32) #$ header function sgerfs(str, int32, int32, float32 [:,:](order=F), int32, float32 [:,:](order=F), int32, int32 [:], float32 [:,:](order=F), int32, float32 [:,:](order=F), int32, float32 [:], float32 [:], float32 [:], int32 [:], int32) #$ header function dgerfs(str, int32, int32, float64 [:,:](order=F), int32, float64 [:,:](order=F), int32, int32 [:], float64 [:,:](order=F), int32, float64 [:,:](order=F), int32, float64 [:], float64 [:], float64 [:], int32 [:], int32) @@ -309,8 +309,8 @@ #$ header function dgbtrf(int32, int32, int32, int32, float64 [:,:](order=F), int32, int32 [:], int32) -#$ header function sgbtrs(str, int32, int32, int32, int32, float32 [:,:](order=F), int32, int32 [:], float32 [:,:](order=F), int32, int32) -#$ header function dgbtrs(str, int32, int32, int32, int32, float64 [:,:](order=F), int32, int32 [:], float64 [:,:](order=F), int32, int32) +#$ header function sgbtrs(char, int32, int32, int32, int32, float32 [:,:](order=F), int32, int32 [:], float32 [:,:](order=F), int32, int32) +#$ header function dgbtrs(char, int32, int32, int32, int32, float64 [:,:](order=F), int32, int32 [:], float64 [:,:](order=F), int32, int32) #$ header function sgbcon(str, int32, int32, int32, float32 [:,:](order=F), int32, int32 [:], float32, float32, float32 [:], int32 [:], int32) #$ header function dgbcon(str, int32, int32, int32, float64 [:,:](order=F), int32, int32 [:], float64, float64, float64 [:], int32 [:], int32) From 6d78b8e7a976be227da5b95b15889bff3ada4019 Mon Sep 17 00:00:00 2001 From: AjaySDwivedi1 Date: Thu, 28 Mar 2024 09:41:56 -0400 Subject: [PATCH 4/4] Took my code out of test_pyccel.py Testing still not complete --- tests/pyccel/test_pyccel.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/pyccel/test_pyccel.py b/tests/pyccel/test_pyccel.py index fad112a55b..fc7c97145c 100644 --- a/tests/pyccel/test_pyccel.py +++ b/tests/pyccel/test_pyccel.py @@ -1190,7 +1190,3 @@ def test_time_execution_flag(): for l in result_lines[1:-1]: assert ' : ' in l -#------------------------------------------------------------------------------ -def test_char(language): - types = str - pyccel_test("scripts/c_arrays.py", language = language, output_dtype = types) \ No newline at end of file