From f17d55b54481bfd6510bb3a8e3884866c460a73d Mon Sep 17 00:00:00 2001 From: EmilyBourne Date: Tue, 9 Apr 2024 15:31:14 +0200 Subject: [PATCH] Fix boolean cast in Fortran code (#1789) Add missing cast when creating an array from an object with a different datatype. Fixes #1785 In order to call the cast on the argument passed to `np.array` (which may be a `InhomogeneousTupleType`) fix the type of the cast functions. Modify `InhomogeneousTupleType.datatype` to return a `FixedSizeType` if the datatypes of all elements are equivalent. Also fix some minor bugs after #1756 --- CHANGELOG.md | 1 + pyccel/ast/builtins.py | 5 - pyccel/ast/datatypes.py | 16 +- pyccel/ast/numpyext.py | 19 ++- pyccel/codegen/printing/ccode.py | 2 +- pyccel/codegen/printing/fcode.py | 11 +- tests/epyccel/modules/python_annotations.py | 8 +- .../recognised_functions/test_numpy_funcs.py | 19 +-- tests/epyccel/test_array_as_func_args.py | 16 +- tests/epyccel/test_arrays.py | 144 ------------------ .../test_epyccel_python_annotations.py | 16 +- 11 files changed, 64 insertions(+), 193 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6765b21f6c..2840984203 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file. - #1792 : Fix array unpacking. - #1795 : Fix bug when returning slices in C. - #1732 : Fix multidimensional list indexing in Python. +- #1785 : Add missing cast when creating an array of booleans from non-boolean values. ### Changed - #1720 : functions with the `@inline` decorator are no longer exposed to Python in the shared library. diff --git a/pyccel/ast/builtins.py b/pyccel/ast/builtins.py index 8866f4689d..e8399de319 100644 --- a/pyccel/ast/builtins.py +++ b/pyccel/ast/builtins.py @@ -513,11 +513,6 @@ def __init__(self, *args): # Get possible datatypes dtypes = [a.class_type.datatype for a in args] - # Extract all dtypes inside any inhomogeneous tuples - while any(isinstance(d, InhomogeneousTupleType) for d in dtypes): - dtypes = [di for d in dtypes for di in ((d_elem.datatype for d_elem in d) - if isinstance(d, InhomogeneousTupleType) - else [d])] # Create a set of dtypes using the same key for compatible types dtypes = set((d.primitive_type, d.precision) if isinstance(d, FixedSizeNumericType) else d for d in dtypes) diff --git a/pyccel/ast/datatypes.py b/pyccel/ast/datatypes.py index 9c90394822..03f9576f1a 100644 --- a/pyccel/ast/datatypes.py +++ b/pyccel/ast/datatypes.py @@ -714,10 +714,14 @@ class InhomogeneousTupleType(ContainerType, TupleType, metaclass = ArgumentSingl *args : tuple of DataTypes The datatypes stored in the inhomogeneous tuple. """ - __slots__ = ('_element_types',) + __slots__ = ('_element_types', '_datatype') def __init__(self, *args): self._element_types = args + + possible_types = set(t.datatype for t in self._element_types) + dtype = possible_types.pop() + self._datatype = dtype if all(d == dtype for d in possible_types) else self super().__init__() def __str__(self): @@ -754,13 +758,11 @@ def datatype(self): """ The datatype of the object. - The datatype of the object. + The datatype of the object. For an inhomogeneous tuple the datatype is the type + of the tuple unless the tuple is comprised of containers which are all based on + compatible data types. In this case one of the underlying types is returned. """ - possible_types = set(t.datatype for t in self._element_types) - if len(possible_types) == 1: - return possible_types.pop() - else: - return self + return self._datatype class DictType(ContainerType, metaclass = ArgumentSingleton): """ diff --git a/pyccel/ast/numpyext.py b/pyccel/ast/numpyext.py index d4154e37fc..13f7a13441 100644 --- a/pyccel/ast/numpyext.py +++ b/pyccel/ast/numpyext.py @@ -184,12 +184,14 @@ class NumpyFloat(PythonFloat): The argument passed to the function. """ __slots__ = ('_rank','_shape','_order','_class_type') + _static_type = NumpyFloat64Type() name = 'float' + def __init__(self, arg): self._shape = arg.shape self._rank = arg.rank self._order = arg.order - self._class_type = arg.class_type.switch_basic_type(self.static_type()) + self._class_type = NumpyNDArrayType(self.static_type()) if self._rank else self.static_type() super().__init__(arg) @property @@ -250,7 +252,7 @@ def __init__(self, arg): self._shape = arg.shape self._rank = arg.rank self._order = arg.order - self._class_type = arg.class_type.switch_basic_type(self.static_type()) + self._class_type = NumpyNDArrayType(self.static_type()) if self._rank else self.static_type() super().__init__(arg) @property @@ -277,12 +279,14 @@ class NumpyInt(PythonInt): The argument passed to the function. """ __slots__ = ('_shape','_rank','_order','_class_type') + _static_type = numpy_precision_map[(PrimitiveIntegerType(), PythonInt._static_type.precision)] name = 'int' + def __init__(self, arg=None, base=10): self._shape = arg.shape self._rank = arg.rank self._order = arg.order - self._class_type = arg.class_type.switch_basic_type(self.static_type()) + self._class_type = NumpyNDArrayType(self.static_type()) if self._rank else self.static_type() super().__init__(arg) @property @@ -374,7 +378,10 @@ class NumpyReal(PythonReal): name = 'real' def __new__(cls, arg): if isinstance(arg.dtype, PythonNativeBool): - return NumpyInt(arg) + if arg.rank: + return NumpyInt(arg) + else: + return PythonInt(arg) else: return super().__new__(cls, arg) @@ -452,14 +459,16 @@ class NumpyComplex(PythonComplex): _real_cast = NumpyReal _imag_cast = NumpyImag __slots__ = ('_rank','_shape','_order','_class_type') + _static_type = NumpyComplex128Type() name = 'complex' + def __init__(self, arg0, arg1 = None): if arg1 is not None: raise NotImplementedError("Use builtin complex function not deprecated np.complex") self._shape = arg0.shape self._rank = arg0.rank self._order = arg0.order - self._class_type = arg0.class_type.switch_basic_type(self.static_type()) + self._class_type = NumpyNDArrayType(self.static_type()) if self._rank else self.static_type() super().__init__(arg0) @property diff --git a/pyccel/codegen/printing/ccode.py b/pyccel/codegen/printing/ccode.py index 88794c13c7..a8b277e1fc 100644 --- a/pyccel/codegen/printing/ccode.py +++ b/pyccel/codegen/printing/ccode.py @@ -1242,7 +1242,7 @@ def get_declare_type(self, expr): else: errors.report(PYCCEL_RESTRICTION_TODO+' (rank>0)', symbol=expr, severity='fatal') elif not isinstance(class_type, CustomDataType): - dtype = self.find_in_dtype_registry(class_type) + dtype = self.find_in_dtype_registry(expr.dtype) else: dtype = self._print(expr.class_type) diff --git a/pyccel/codegen/printing/fcode.py b/pyccel/codegen/printing/fcode.py index 9a6766d636..dc86daf7db 100644 --- a/pyccel/codegen/printing/fcode.py +++ b/pyccel/codegen/printing/fcode.py @@ -1190,12 +1190,17 @@ def _print_NumpyWhere(self, expr): return stmt def _print_NumpyArray(self, expr): - expr_args = (expr.arg,) if isinstance(expr.arg, Variable) else expr.arg order = expr.order + + try : + cast_func = DtypePrecisionToCastFunction[expr.dtype] + except KeyError: + errors.report(PYCCEL_RESTRICTION_TODO, severity='fatal') + arg = expr.arg if expr.arg.dtype == expr.dtype else cast_func(expr.arg) # If Numpy array is stored with column-major ordering, transpose values # use reshape with order for rank > 2 if expr.rank <= 2: - rhs_code = self._print(expr.arg) + rhs_code = self._print(arg) if expr.arg.order and expr.arg.order != expr.order: rhs_code = f'transpose({rhs_code})' if expr.arg.rank < expr.rank: @@ -1205,6 +1210,8 @@ def _print_NumpyArray(self, expr): shape_code = ', '.join(self._print(i) for i in expr.shape[::-1]) rhs_code = f"reshape({rhs_code}, [{shape_code}])" else: + expr_args = (expr.arg,) if isinstance(expr.arg, Variable) else expr.arg + expr_args = tuple(a if a.dtype == expr.dtype else cast_func(a) for a in expr_args) new_args = [] inv_order = 'C' if order == 'F' else 'F' for a in expr_args: diff --git a/tests/epyccel/modules/python_annotations.py b/tests/epyccel/modules/python_annotations.py index 746ff26791..c3f79ad9f5 100644 --- a/tests/epyccel/modules/python_annotations.py +++ b/tests/epyccel/modules/python_annotations.py @@ -12,13 +12,13 @@ def array_int32_2d_F_add( x:'int32[:,:](order=F)', y:'int32[:,:](order=F)' ): def array_int_1d_scalar_add( x:'int[:]', a:'int' ): x[:] += a -def array_real_1d_scalar_add( x:'real[:]', a:'real' ): +def array_float_1d_scalar_add( x:'float[:]', a:'float' ): x[:] += a -def array_real_2d_F_scalar_add( x:'real[:,:](order=F)', a:'real' ): +def array_float_2d_F_scalar_add( x:'float[:,:](order=F)', a:'float' ): x[:,:] += a -def array_real_2d_F_add( x:'real[:,:](order=F)', y:'real[:,:](order=F)' ): +def array_float_2d_F_add( x:'float[:,:](order=F)', y:'float[:,:](order=F)' ): x[:,:] += y def array_int32_2d_F_complex_3d_expr( x:'int32[:,:](order=F)', y:'int32[:,:](order=F)' ): @@ -26,7 +26,7 @@ def array_int32_2d_F_complex_3d_expr( x:'int32[:,:](order=F)', y:'int32[:,:](ord z = full((2,3),5,order='F', dtype=int32) x[:] = (x // y) * x + z -def array_real_1d_complex_3d_expr( x:'real[:]', y:'real[:]' ): +def array_float_1d_complex_3d_expr( x:'float[:]', y:'float[:]' ): from numpy import full z = full(3,5) x[:] = (x // y) * x + z diff --git a/tests/epyccel/recognised_functions/test_numpy_funcs.py b/tests/epyccel/recognised_functions/test_numpy_funcs.py index 7f256d72f9..e4757c250a 100644 --- a/tests/epyccel/recognised_functions/test_numpy_funcs.py +++ b/tests/epyccel/recognised_functions/test_numpy_funcs.py @@ -2160,25 +2160,26 @@ def create_array_tuple_ref(a : 'int[:,:]'): tmp_arr = np.ones((3,4), dtype=int) assert np.allclose(array_tuple_ref(tmp_arr), create_array_tuple_ref(tmp_arr)) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = pytest.mark.fortran), - pytest.param("c", marks = [ - pytest.mark.skip(reason="Changing dtype is broken in C. See #1641"), - pytest.mark.c] - ), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_array_new_dtype(language): def create_float_array_tuple_ref(a : 'int[:,:]'): from numpy import array b = (a[0,:], a[1,:]) c = array(b, dtype=float) return c + def create_bool_array_tuple_ref(a : 'int[:,:]'): + from numpy import array + b = (a[0,:], a[1,:]) + c = array(b, dtype=bool) + return c + array_float_tuple_ref = epyccel(create_float_array_tuple_ref, language = language) tmp_arr = np.ones((3,4), dtype=int) assert np.allclose(array_float_tuple_ref(tmp_arr), create_float_array_tuple_ref(tmp_arr)) + array_bool_tuple_ref = epyccel(create_float_array_tuple_ref, language = language) + tmp_arr = np.ones((3,4), dtype=int) + assert np.allclose(array_bool_tuple_ref(tmp_arr), create_bool_array_tuple_ref(tmp_arr)) + @pytest.mark.parametrize( 'language', ( pytest.param("fortran", marks = pytest.mark.fortran), pytest.param("c", marks = [ diff --git a/tests/epyccel/test_array_as_func_args.py b/tests/epyccel/test_array_as_func_args.py index 194d269dba..879eadb9ef 100644 --- a/tests/epyccel/test_array_as_func_args.py +++ b/tests/epyccel/test_array_as_func_args.py @@ -31,12 +31,12 @@ def array_int_1d_scalar_add(x : 'T[:]', a : 'T', x_len : int): assert np.array_equal( x1, x2 ) -def test_array_real_1d_scalar_add(language): - @template('T', ['float32', 'double']) - def array_real_1d_scalar_add(x : 'T[:]', a : 'T', x_len : int): +def test_array_float_1d_scalar_add(language): + @template('T', ['float32', 'float']) + def array_float_1d_scalar_add(x : 'T[:]', a : 'T', x_len : int): for i in range(x_len): x[i] += a - f1 = array_real_1d_scalar_add + f1 = array_float_1d_scalar_add f2 = epyccel(f1, language=language) for t in float_types: @@ -92,13 +92,13 @@ def array_int_2d_scalar_add( x : 'T[:,:]', a : 'T', d1 : int, d2 : int): assert np.array_equal( x1, x2 ) -def test_array_real_2d_scalar_add(language): - @template('T', ['float32', 'double']) - def array_real_2d_scalar_add(x : 'T[:,:]', a : 'T', d1 : int, d2 : int): +def test_array_float_2d_scalar_add(language): + @template('T', ['float32', 'float']) + def array_float_2d_scalar_add(x : 'T[:,:]', a : 'T', d1 : int, d2 : int): for i in range(d1): for j in range(d2): x[i, j] += a - f1 = array_real_2d_scalar_add + f1 = array_float_2d_scalar_add f2 = epyccel(f1, language=language) for t in float_types: diff --git a/tests/epyccel/test_arrays.py b/tests/epyccel/test_arrays.py index 77324a9b55..5320bda40e 100644 --- a/tests/epyccel/test_arrays.py +++ b/tests/epyccel/test_arrays.py @@ -3970,14 +3970,6 @@ def test_array_ndmin_2_order(language): check_array_equal(f1(d), f2(d)) check_array_equal(f1(e), f2(e)) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_dtype_conversion_to_bool_from_other_types(language): size = (2, 2) @@ -4172,14 +4164,6 @@ def test_dtype_conversion_to_int64_from_other_types(language): assert epyccel_func(cmplx64) == arrays.dtype_convert_to_int64(cmplx64) assert epyccel_func(cmplx128) == arrays.dtype_convert_to_int64(cmplx128) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_dtype_conversion_to_float32_from_other_types(language): size = (2, 2) @@ -4214,14 +4198,6 @@ def test_dtype_conversion_to_float32_from_other_types(language): assert epyccel_func(cmplx64) == arrays.dtype_convert_to_float32(cmplx64) assert epyccel_func(cmplx128) == arrays.dtype_convert_to_float32(cmplx128) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_dtype_conversion_to_float64_from_other_types(language): size = (2, 2) @@ -4256,14 +4232,6 @@ def test_dtype_conversion_to_float64_from_other_types(language): assert epyccel_func(cmplx64) == arrays.dtype_convert_to_float64(cmplx64) assert epyccel_func(cmplx128) == arrays.dtype_convert_to_float64(cmplx128) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_dtype_conversion_to_complex64_from_other_types(language): size = (2, 2) @@ -4297,14 +4265,6 @@ def test_dtype_conversion_to_complex64_from_other_types(language): assert epyccel_func(cmplx64) == arrays.dtype_convert_to_cfloat(cmplx64) assert epyccel_func(cmplx128) == arrays.dtype_convert_to_cfloat(cmplx128) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_dtype_conversion_to_complex128_from_other_types(language): size = (2, 2) @@ -4379,14 +4339,6 @@ def test_dtype_conversion_to_pyint_from_other_types(language): assert epyccel_func(cmplx64) == arrays.dtype_convert_to_pyint(cmplx64) assert epyccel_func(cmplx128) == arrays.dtype_convert_to_pyint(cmplx128) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_dtype_conversion_to_pyfloat_from_other_types(language): size = (2, 2) @@ -4421,14 +4373,6 @@ def test_dtype_conversion_to_pyfloat_from_other_types(language): assert epyccel_func(cmplx64) == arrays.dtype_convert_to_pyfloat(cmplx64) assert epyccel_func(cmplx128) == arrays.dtype_convert_to_pyfloat(cmplx128) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_bool(language): size = (1,2) @@ -4774,14 +4718,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_int64(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_int64(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_int64(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_float32(language): size = (1,2) @@ -4851,14 +4787,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_float32(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_float32(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_float32(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_float64(language): size = (1,2) @@ -4928,14 +4856,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_float64(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_float64(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_float64(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_cfloat(language): size = (1,2) @@ -5005,14 +4925,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_cfloat(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_cfloat(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_cfloat(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_cdouble(language): size = (1,2) @@ -5151,14 +5063,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_pyint(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_pyint(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_pyint(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_pyfloat(language): size = (1,2) @@ -5228,14 +5132,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_pyfloat(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_pyfloat(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_pyfloat(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_bool_orderF(language): size = (1,2) @@ -5581,14 +5477,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_int64_orderF(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_int64_orderF(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_int64_orderF(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_float32_orderF(language): size = (1,2) @@ -5658,14 +5546,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_float32_orderF(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_float32_orderF(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_float32_orderF(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_float64_orderF(language): size = (1,2) @@ -5735,14 +5615,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_float64_orderF(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_float64_orderF(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_float64_orderF(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_cfloat_orderF(language): size = (1,2) @@ -5812,14 +5684,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_cfloat_orderF(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_cfloat_orderF(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_cfloat_orderF(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_cdouble_orderF(language): size = (1,2) @@ -5958,14 +5822,6 @@ def test_src_dest_array_diff_sizes_dtype_conversion_to_pyint_orderF(language): assert epyccel_func(cmplx64_1, cmplx64_2, cmplx64_3) == arrays.src_dest_diff_sizes_dtype_convert_to_pyint_orderF(cmplx64_1, cmplx64_2, cmplx64_3) assert epyccel_func(cmplx128_1, cmplx128_2, cmplx128_3) == arrays.src_dest_diff_sizes_dtype_convert_to_pyint_orderF(cmplx128_1, cmplx128_2, cmplx128_3) -@pytest.mark.parametrize( 'language', ( - pytest.param("fortran", marks = [ - pytest.mark.skip(reason=("Missing boolean cast in Fortran code, see #1785")), - pytest.mark.fortran]), - pytest.param("c", marks = pytest.mark.c), - pytest.param("python", marks = pytest.mark.python) - ) -) def test_src_dest_array_diff_sizes_dtype_conversion_to_pyfloat_orderF(language): size = (1,2) diff --git a/tests/epyccel/test_epyccel_python_annotations.py b/tests/epyccel/test_epyccel_python_annotations.py index 51b50bd4b2..dfe2915f22 100644 --- a/tests/epyccel/test_epyccel_python_annotations.py +++ b/tests/epyccel/test_epyccel_python_annotations.py @@ -61,9 +61,9 @@ def test_array_int_1d_scalar_add(language): assert np.array_equal( x1, x2 ) -def test_array_real_1d_scalar_add(language): +def test_array_float_1d_scalar_add(language): - f1 = python_annotations.array_real_1d_scalar_add + f1 = python_annotations.array_float_1d_scalar_add f2 = epyccel( f1, language = language ) x1 = np.array( [1.,2.,3.] ) @@ -76,9 +76,9 @@ def test_array_real_1d_scalar_add(language): assert np.array_equal( x1, x2 ) -def test_array_real_2d_F_scalar_add(language): +def test_array_float_2d_F_scalar_add(language): - f1 = python_annotations.array_real_2d_F_scalar_add + f1 = python_annotations.array_float_2d_F_scalar_add f2 = epyccel( f1, language = language ) x1 = np.array( [[1.,2.,3.], [4.,5.,6.]], order='F' ) @@ -90,9 +90,9 @@ def test_array_real_2d_F_scalar_add(language): assert np.array_equal( x1, x2 ) -def test_array_real_2d_F_add(language): +def test_array_float_2d_F_add(language): - f1 = python_annotations.array_real_2d_F_add + f1 = python_annotations.array_float_2d_F_add f2 = epyccel( f1, language = language ) x1 = np.array( [[1.,2.,3.], [4.,5.,6.]], order='F' ) @@ -118,9 +118,9 @@ def test_array_int32_2d_F_complex_3d_expr(language): assert np.array_equal( x1, x2 ) -def test_array_real_1d_complex_3d_expr(language): +def test_array_float_1d_complex_3d_expr(language): - f1 = python_annotations.array_real_1d_complex_3d_expr + f1 = python_annotations.array_float_1d_complex_3d_expr f2 = epyccel( f1, language = language ) x1 = np.array( [1.,2.,3.] )