Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyBourne committed Mar 6, 2024
2 parents dcc626c + e3c5b60 commit 6bf3aa2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ All notable changes to this project will be documented in this file.

### Added

### Fixed

### Changed

### Deprecated

## \[1.11.2\] - 2024-03-05

### Added

- #1689 : Add Python support for list method `append()`.
- #1692 : Add Python support for list method `insert()`.
- #1690 : Add Python support for list method `pop()`.
Expand All @@ -25,6 +35,7 @@ All notable changes to this project will be documented in this file.
- #1575 : Fixed inhomogeneous tuple (due to incompatible sizes) being treated as homogeneous tuple.
- #1182 : Fix tuples containing objects with different ranks.
- #1575 : Fix duplication operator for non-homogeneous tuples with a non-literal but constant multiplier.
- #1779 : Fix standalone partial templates.

### Changed

Expand Down
3 changes: 2 additions & 1 deletion pyccel/parser/semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3800,7 +3800,8 @@ def _visit_FunctionDef(self, expr):
arg_annotations = [annot for a in templatable_args for annot in (a.type_list \
if isinstance(a, UnionTypeAnnotation) else [a]) \
if isinstance(annot, SyntacticTypeAnnotation)]
used_type_names = set(a.dtype for a in arg_annotations)
type_names = [a.dtype for a in arg_annotations]
used_type_names = set(d.base if isinstance(d, IndexedElement) else d for d in type_names)
templates = {t: v for t,v in templates.items() if t in used_type_names}

template_combinations = list(product(*[v.type_list for v in templates.values()]))
Expand Down
2 changes: 1 addition & 1 deletion pyccel/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
Module specifying the current version string for pyccel
"""
__version__ = "1.11.1"
__version__ = "1.11.2"
25 changes: 24 additions & 1 deletion tests/epyccel/test_epyccel_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
import numpy as np
from pyccel.epyccel import epyccel
from pyccel.decorators import private, inline
from pyccel.decorators import private, inline, template

@pytest.mark.parametrize( 'lang', (
pytest.param("fortran", marks = pytest.mark.fortran),
Expand Down Expand Up @@ -146,3 +146,26 @@ def get_val(x : int = None , y : int = None):
g = epyccel(f, language=language)

assert f() == g()

def test_indexed_template(language):
@template(name='T', types=[float, complex])
def my_sum(v: 'T[:]'):
return v.sum()

pyccel_sum = epyccel(my_sum, language=language)

x = np.ones(4, dtype=float)

python_fl = my_sum(x)
pyccel_fl = pyccel_sum(x)

assert python_fl == pyccel_fl
assert isinstance(python_fl, type(pyccel_fl))

y = np.full(4, 1 + 3j)

python_cmplx = my_sum(y)
pyccel_cmplx = pyccel_sum(y)

assert python_cmplx == pyccel_cmplx
assert isinstance(python_cmplx, type(pyccel_cmplx))

0 comments on commit 6bf3aa2

Please sign in to comment.