@@ -3647,11 +3647,6 @@ def test_numpy_arange_into_slice(language):
3647
3647
f2 (x )
3648
3648
np .testing .assert_allclose (x , x_expected , rtol = RTOL , atol = ATOL )
3649
3649
3650
- def test_iterate_slice (language ):
3651
- f1 = arrays .iterate_slice
3652
- f2 = epyccel (f1 , language = language )
3653
- i = randint (2 , 10 )
3654
- assert f1 (i ) == f2 (i )
3655
3650
##==============================================================================
3656
3651
## TEST NESTED ARRAYS INITIALIZATION WITH ORDER C
3657
3652
##==============================================================================
@@ -3975,11 +3970,65 @@ def test_array_ndmin_2_order(language):
3975
3970
check_array_equal (f1 (d ), f2 (d ))
3976
3971
check_array_equal (f1 (e ), f2 (e ))
3977
3972
3973
+ ##==============================================================================
3974
+ ## TEST ITERATION
3975
+ ##==============================================================================
3976
+
3977
+ def test_iterate_slice (language ):
3978
+ f1 = arrays .iterate_slice
3979
+ f2 = epyccel (f1 , language = language )
3980
+ i = randint (2 , 10 )
3981
+ assert f1 (i ) == f2 (i )
3982
+
3983
+ @pytest .mark .parametrize ( 'language' , (
3984
+ pytest .param ("fortran" , marks = [
3985
+ pytest .mark .xfail (reason = ("Cannot return a non-contiguous slice. See #1796" )),
3986
+ pytest .mark .fortran ]),
3987
+ pytest .param ("c" , marks = pytest .mark .c ),
3988
+ pytest .param ("python" , marks = pytest .mark .python )
3989
+ )
3990
+ )
3991
+ def test_unpacking (language ):
3992
+ f1 = arrays .unpack_array
3993
+ f2 = epyccel (f1 , language = language )
3994
+
3995
+ arr = np .arange (3 , dtype = int )
3996
+ assert f1 (arr ) == f2 (arr )
3997
+
3998
+ arr = np .arange (12 , dtype = int ).reshape ((3 ,4 ))
3999
+ x1 , y1 , z1 = f1 (arr )
4000
+ x2 , y2 , z2 = f2 (arr )
4001
+ check_array_equal (x1 , x2 )
4002
+ check_array_equal (y1 , y2 )
4003
+ check_array_equal (z1 , z2 )
3978
4004
3979
- #def teardown_module():
3980
- # import os, glob
3981
- # dirname = os.path.dirname( arrays.__file__ )
3982
- # pattern = os.path.join( dirname, '__epyccel__*' )
3983
- # filelist = glob.glob( pattern )
3984
- # for f in filelist:
3985
- # os.remove( f )
4005
+ arr = np .arange (24 , dtype = int ).reshape ((3 ,4 ,2 ))
4006
+ x1 , y1 , z1 = f1 (arr )
4007
+ x2 , y2 , z2 = f2 (arr )
4008
+ check_array_equal (x1 , x2 )
4009
+ check_array_equal (y1 , y2 )
4010
+ check_array_equal (z1 , z2 )
4011
+
4012
+ arr = np .arange (12 , dtype = int ).reshape ((3 ,4 ), order = 'F' )
4013
+ x1 , y1 , z1 = f1 (arr )
4014
+ x2 , y2 , z2 = f2 (arr )
4015
+ check_array_equal (x1 , x2 )
4016
+ check_array_equal (y1 , y2 )
4017
+ check_array_equal (z1 , z2 )
4018
+
4019
+ arr = np .arange (24 , dtype = int ).reshape ((3 ,4 ,2 ), order = 'F' )
4020
+ x1 , y1 , z1 = f1 (arr )
4021
+ x2 , y2 , z2 = f2 (arr )
4022
+ check_array_equal (x1 , x2 )
4023
+ check_array_equal (y1 , y2 )
4024
+ check_array_equal (z1 , z2 )
4025
+
4026
+ def test_unpacking_of_known_size (language ):
4027
+ f1 = arrays .unpack_array_of_known_size
4028
+ f2 = epyccel (f1 , language = language )
4029
+ assert f1 () == f2 ()
4030
+
4031
+ def test_unpacking_2D_of_known_size (language ):
4032
+ f1 = arrays .unpack_array_2D_of_known_size
4033
+ f2 = epyccel (f1 , language = language )
4034
+ assert f1 () == f2 ()
0 commit comments