pyccel.ast package

Submodules

pyccel.ast.basic module

class pyccel.ast.basic.Basic[source]

Bases: sympy.core.basic.Basic

Basic class for Pyccel AST.

default_assumptions = {}
fst
set_fst(fst)[source]

Sets the redbaron fst.

pyccel.ast.core module

class pyccel.ast.core.AddOp[source]

Bases: pyccel.ast.core.NativeOp

default_assumptions = {}
class pyccel.ast.core.AliasAssign[source]

Bases: pyccel.ast.basic.Basic

Represents aliasing for code generation. An alias is any statement of the form lhs := rhs where

lhs : Symbol
at this point we don’t know yet all information about lhs, this is why a Symbol is the appropriate type.
rhs : Variable, IndexedVariable, IndexedElement
an assignable variable can be of any rank and any datatype, however its shape must be known (not None)

Examples

>>> from sympy import Symbol
>>> from pyccel.ast.core import AliasAssign
>>> from pyccel.ast.core import Variable
>>> n = Variable('int', 'n')
>>> x = Variable('int', 'x', rank=1, shape=[n])
>>> y = Symbol('y')
>>> AliasAssign(y, x)
default_assumptions = {}
lhs
rhs
class pyccel.ast.core.AnnotatedComment[source]

Bases: pyccel.ast.basic.Basic

Represents a Annotated Comment in the code.

accel : str
accelerator id. One among {‘omp’, ‘acc’}
txt: str
statement to print

Examples

>>> from pyccel.ast.core import AnnotatedComment
>>> AnnotatedComment('omp', 'parallel')
AnnotatedComment(omp, parallel)
accel
default_assumptions = {}
txt
class pyccel.ast.core.Argument[source]

Bases: sympy.core.symbol.Symbol

An abstract Argument data structure.

Examples

>>> from pyccel.ast.core import Argument
>>> n = Argument('n')
>>> n
n
default_assumptions = {}
class pyccel.ast.core.AsName[source]

Bases: pyccel.ast.basic.Basic

Represents a renaming of a variable, used with Import.

Examples

>>> from pyccel.ast.core import AsName
>>> AsName('new', 'old')
new as old
default_assumptions = {}
name
target
class pyccel.ast.core.Assert[source]

Bases: pyccel.ast.basic.Basic

Represents a assert statement in the code.

test: Expr
boolean expression to check

Examples

default_assumptions = {}
test
class pyccel.ast.core.Assign[source]

Bases: pyccel.ast.basic.Basic

Represents variable assignment for code generation.

lhs : Expr
Sympy object representing the lhs of the expression. These should be singular objects, such as one would use in writing code. Notable types include Symbol, MatrixSymbol, MatrixElement, and Indexed. Types that subclass these types are also supported.
rhs : Expr
Sympy object representing the rhs of the expression. This can be any type, provided its shape corresponds to that of the lhs. For example, a Matrix type can be assigned to MatrixSymbol, but not to Symbol, as the dimensions will not align.
strict: bool
if True, we do some verifications. In general, this can be more complicated and is treated in pyccel.syntax.
status: None, str
if lhs is not allocatable, then status is None. otherwise, status is {‘allocated’, ‘unallocated’}
like: None, Variable
contains the name of the variable from which the lhs will be cloned.

Examples

>>> from sympy import symbols, MatrixSymbol, Matrix
>>> from pyccel.ast.core import Assign
>>> x, y, z = symbols('x, y, z')
>>> Assign(x, y)
x := y
>>> Assign(x, 0)
x := 0
>>> A = MatrixSymbol('A', 1, 3)
>>> mat = Matrix([x, y, z]).T
>>> Assign(A, mat)
A := Matrix([[x, y, z]])
>>> Assign(A[0, 1], x)
A[0, 1] := x
default_assumptions = {}
expr
is_alias

Returns True if the assignment is an alias.

is_symbolic_alias

Returns True if the assignment is a symbolic alias.

lhs
like
rhs
status
strict
class pyccel.ast.core.AugAssign[source]

Bases: pyccel.ast.basic.Basic

Represents augmented variable assignment for code generation.

lhs : Expr
Sympy object representing the lhs of the expression. These should be singular objects, such as one would use in writing code. Notable types include Symbol, MatrixSymbol, MatrixElement, and Indexed. Types that subclass these types are also supported.
op : NativeOp
Operator (+, -, /, *, %).
rhs : Expr
Sympy object representing the rhs of the expression. This can be any type, provided its shape corresponds to that of the lhs. For example, a Matrix type can be assigned to MatrixSymbol, but not to Symbol, as the dimensions will not align.
strict: bool
if True, we do some verifications. In general, this can be more complicated and is treated in pyccel.syntax.
status: None, str
if lhs is not allocatable, then status is None. otherwise, status is {‘allocated’, ‘unallocated’}
like: None, Variable
contains the name of the variable from which the lhs will be cloned.

Examples

>>> from pyccel.ast.core import Variable
>>> from pyccel.ast.core import AugAssign
>>> s = Variable('int', 's')
>>> t = Variable('int', 't')
>>> AugAssign(s, '+', 2 * t + 1)
s += 1 + 2*t
default_assumptions = {}
lhs
like
op
rhs
status
strict
class pyccel.ast.core.Block[source]

Bases: pyccel.ast.basic.Basic

Represents a block in the code. A block consists of the following inputs

variables: list
list of the variables that appear in the block.
declarations: list
list of declarations of the variables that appear in the block.
body: list
a list of statements

Examples

>>> from pyccel.ast.core import Variable, Assign, Block
>>> n = Variable('int', 'n')
>>> x = Variable('int', 'x')
>>> Block([n, x], [Assign(x,2.*n + 1.), Assign(n, n + 1)])
Block([n, x], [x := 1.0 + 2.0*n, n := 1 + n])
body
declarations
default_assumptions = {}
name
variables
class pyccel.ast.core.Break[source]

Bases: pyccel.ast.basic.Basic

Represents a break in the code.

default_assumptions = {}
class pyccel.ast.core.ClassDef[source]

Bases: pyccel.ast.basic.Basic

Represents a class definition.

name : str
The name of the class.
attributs: iterable
The attributs to the class.
methods: iterable
Class methods
options: list, tuple
list of options (‘public’, ‘private’, ‘abstract’)
imports: list, tuple
list of needed imports
parent : str
parent’s class name

Examples

>>> from pyccel.ast.core import Variable, Assign
>>> from pyccel.ast.core import ClassDef, FunctionDef
>>> x = Variable('real', 'x')
>>> y = Variable('real', 'y')
>>> z = Variable('real', 'z')
>>> t = Variable('real', 't')
>>> a = Variable('real', 'a')
>>> b = Variable('real', 'b')
>>> body = [Assign(y,x+a)]
>>> translate = FunctionDef('translate', [x,y,a,b], [z,t], body)
>>> attributs   = [x,y]
>>> methods     = [translate]
>>> ClassDef('Point', attributs, methods)
ClassDef(Point, (x, y), (FunctionDef(translate, (x, y, a, b), (z, t), [y := a + x], [], [], None, False, function),), [public])
attributes
attributes_as_dict

Returns a dictionary that contains all attributs, where the key is the attribut’s name.

default_assumptions = {}
get_attribute(O, attr)[source]

Returns the attribute attr of the class O of instance self.

hide
imports
interfaces
is_iterable

Returns True if the class has an iterator.

is_with_construct

Returns True if the class is a with construct.

methods
methods_as_dict

Returns a dictionary that contains all methods, where the key is the method’s name.

name
options
parent
class pyccel.ast.core.CodeBlock[source]

Bases: pyccel.ast.basic.Basic

Represents a list of stmt for code generation. we use it when a single statement in python produce multiple statement in the targeted language

body
default_assumptions = {}
lhs
class pyccel.ast.core.Comment[source]

Bases: pyccel.ast.basic.Basic

Represents a Comment in the code.

text : str
the comment line

Examples

>>> from pyccel.ast.core import Comment
>>> Comment('this is a comment')
# this is a comment
default_assumptions = {}
text
class pyccel.ast.core.CommentBlock[source]

Bases: pyccel.ast.basic.Basic

Represents a Block of Comments txt : str

comments
default_assumptions = {}
class pyccel.ast.core.Concatinate[source]

Bases: pyccel.ast.basic.Basic

Represents the String concatination operation.

left : Symbol or string or List

right : Symbol or string or List

Examples

>>> from sympy import symbols
>>> from pyccel.ast.core import Concatinate
>>> x = symbols('x')
>>> Concatinate('some_string',x)
some_string+x
>>> Concatinate('some_string','another_string')
'some_string' + 'another_string'
args
default_assumptions = {}
is_list
class pyccel.ast.core.Constant[source]

Bases: pyccel.ast.core.ValuedVariable

Examples

default_assumptions = {}
class pyccel.ast.core.ConstructorCall[source]

Bases: sympy.core.expr.AtomicExpr

It serves as a constructor for undefined function classes.

func: FunctionDef, str
an instance of FunctionDef or function name
arguments: list, tuple, None
a list of arguments.
kind: str
‘function’ or ‘procedure’. default value: ‘function’
arguments
cls_variable
default_assumptions = {'commutative': True}
func
is_commutative = True
kind
name
class pyccel.ast.core.Continue[source]

Bases: pyccel.ast.basic.Basic

Represents a continue in the code.

default_assumptions = {}
class pyccel.ast.core.Declare[source]

Bases: pyccel.ast.basic.Basic

Represents a variable declaration in the code.

dtype : DataType
The type for the declaration.
variable(s)
A single variable or an iterable of Variables. If iterable, all Variables must be of the same type.
intent: None, str
one among {‘in’, ‘out’, ‘inout’}
value: Expr
variable value
static: bool
True for a static declaration of an array.

Examples

>>> from pyccel.ast.core import Declare, Variable
>>> Declare('int', Variable('int', 'n'))
Declare(NativeInteger(), (n,), None)
>>> Declare('real', Variable('real', 'x'), intent='out')
Declare(NativeReal(), (x,), out)
default_assumptions = {}
dtype
intent
static
value
variable
class pyccel.ast.core.Del[source]

Bases: pyccel.ast.basic.Basic

Represents a memory deallocation in the code.

variables : list, tuple
a list of pyccel variables

Examples

>>> from pyccel.ast.core import Del, Variable
>>> x = Variable('real', 'x', rank=2, shape=(10,2), allocatable=True)
>>> Del([x])
Del([x])
default_assumptions = {}
variables
class pyccel.ast.core.DivOp[source]

Bases: pyccel.ast.core.NativeOp

default_assumptions = {}
class pyccel.ast.core.Dlist[source]

Bases: pyccel.ast.basic.Basic

this is equivalent to the zeros function of numpy arrays for the python list.

value : Expr
a sympy expression which represents the initilized value of the list

shape : the shape of the array

default_assumptions = {}
length
val
class pyccel.ast.core.DottedName[source]

Bases: pyccel.ast.basic.Basic

Represents a dotted variable.

Examples

>>> from pyccel.ast.core import DottedName
>>> DottedName('matrix', 'n_rows')
matrix.n_rows
>>> DottedName('pyccel', 'stdlib', 'parallel')
pyccel.stdlib.parallel
default_assumptions = {}
name
class pyccel.ast.core.DottedVariable[source]

Bases: sympy.core.expr.AtomicExpr, sympy.logic.boolalg.Boolean

Represents a dotted variable.

cls_base
default_assumptions = {}
dtype
lhs
name
names

Return list of names as strings.

rank
rhs
class pyccel.ast.core.EmptyLine[source]

Bases: pyccel.ast.basic.Basic

Represents a EmptyLine in the code.

text : str
the comment line

Examples

>>> from pyccel.ast.core import EmptyLine
>>> EmptyLine()
default_assumptions = {}
class pyccel.ast.core.Enumerate[source]

Bases: pyccel.ast.basic.Basic

Reresents the enumerate stmt

default_assumptions = {}
element
class pyccel.ast.core.ErrorExit[source]

Bases: pyccel.ast.core.Exit

Exist with error.

default_assumptions = {}
class pyccel.ast.core.Eval[source]

Bases: pyccel.ast.basic.Basic

Basic class for eval instruction.

default_assumptions = {}
class pyccel.ast.core.Exit[source]

Bases: pyccel.ast.basic.Basic

Basic class for exists.

default_assumptions = {}
class pyccel.ast.core.For[source]

Bases: pyccel.ast.basic.Basic

Represents a ‘for-loop’ in the code.

Expressions are of the form:
“for target in iter:
body…”
target : symbol
symbol representing the iterator
iter : iterable
iterable object. for the moment only Range is used
body : sympy expr
list of statements representing the body of the For statement.

Examples

>>> from sympy import symbols, MatrixSymbol
>>> from pyccel.ast.core import Assign, For
>>> i,b,e,s,x = symbols('i,b,e,s,x')
>>> A = MatrixSymbol('A', 1, 3)
>>> For(i, (b,e,s), [Assign(x,x-1), Assign(A[0, 1], x)])
For(i, Range(b, e, s), (x := x - 1, A[0, 1] := x))
body
default_assumptions = {}
insert2body(stmt)[source]
iterable
target
class pyccel.ast.core.ForIterator[source]

Bases: pyccel.ast.core.For

Class that describes iterable classes defined by the user.

default_assumptions = {}
depth
ranges
class pyccel.ast.core.FunctionCall[source]

Bases: pyccel.ast.basic.Basic

Represents a function call in the code.

arguments
default_assumptions = {}
func
class pyccel.ast.core.FunctionDef[source]

Bases: pyccel.ast.basic.Basic

Represents a function definition.

name : str
The name of the function.
arguments : iterable
The arguments to the function.
results : iterable
The direct outputs of the function.
body : iterable
The body of the function.
local_vars : list of Symbols
These are used internally by the routine.
global_vars : list of Symbols
Variables which will not be passed into the function.
cls_name: str
Class name if the function is a method of cls_name
hide: bool
if True, the function definition will not be generated.
kind: str
‘function’ or ‘procedure’. default value: ‘function’
is_static: bool
True for static functions. Needed for f2py
imports: list, tuple
a list of needed imports
decorators: list, tuple
a list of proporties

Examples

>>> from pyccel.ast.core import Assign, Variable, FunctionDef
>>> x = Variable('real', 'x')
>>> y = Variable('real', 'y')
>>> args        = [x]
>>> results     = [y]
>>> body        = [Assign(y,x+1)]
>>> FunctionDef('incr', args, results, body)
FunctionDef(incr, (x,), (y,), [y := 1 + x], [], [], None, False, function)

One can also use parametrized argument, using ValuedArgument

>>> from pyccel.ast.core import Variable
>>> from pyccel.ast.core import Assign
>>> from pyccel.ast.core import FunctionDef
>>> from pyccel.ast.core import ValuedArgument
>>> from pyccel.ast.core import GetDefaultFunctionArg
>>> n = ValuedArgument('n', 4)
>>> x = Variable('real', 'x')
>>> y = Variable('real', 'y')
>>> args        = [x, n]
>>> results     = [y]
>>> body        = [Assign(y,x+n)]
>>> FunctionDef('incr', args, results, body)
FunctionDef(incr, (x, n=4), (y,), [y := 1 + x], [], [], None, False, function, [])
arguments
body
cls_name
decorators
default_assumptions = {}
global_vars
header
hide
imports
is_compatible_header(header)[source]

Returns True if the header is compatible with the given FunctionDef.

header: Header
a pyccel header suppose to describe the FunctionDef
is_procedure

Returns True if a procedure.

is_recursive
is_static
kind
local_vars
name
print_body()[source]
rename(newname)[source]

Rename the FunctionDef name by creating a new FunctionDef with newname.

newname: str
new name for the FunctionDef
results
set_recursive()[source]
vectorize(body, header)[source]

return vectorized FunctionDef

class pyccel.ast.core.FunctionalFor[source]

Bases: pyccel.ast.basic.Basic

.

default_assumptions = {}
index
indexes
loops
target
class pyccel.ast.core.FunctionalMap[source]

Bases: pyccel.ast.core.FunctionalFor, pyccel.ast.core.GeneratorComprehension

default_assumptions = {}
class pyccel.ast.core.FunctionalMax[source]

Bases: pyccel.ast.core.FunctionalFor, pyccel.ast.core.GeneratorComprehension

default_assumptions = {}
name = 'max'
class pyccel.ast.core.FunctionalMin[source]

Bases: pyccel.ast.core.FunctionalFor, pyccel.ast.core.GeneratorComprehension

default_assumptions = {}
name = 'min'
class pyccel.ast.core.FunctionalSum[source]

Bases: pyccel.ast.core.FunctionalFor, pyccel.ast.core.GeneratorComprehension

default_assumptions = {}
name = 'sum'
class pyccel.ast.core.GeneratorComprehension[source]

Bases: pyccel.ast.basic.Basic

default_assumptions = {}
class pyccel.ast.core.GetDefaultFunctionArg[source]

Bases: pyccel.ast.basic.Basic

Creates a FunctionDef for handling optional arguments in the code.

arg: ValuedArgument, ValuedVariable
argument for which we want to create the function returning the default value
func: FunctionDef
the function/subroutine in which the optional arg is used

Examples

>>> from pyccel.ast.core import Variable
>>> from pyccel.ast.core import Assign
>>> from pyccel.ast.core import FunctionDef
>>> from pyccel.ast.core import ValuedArgument
>>> from pyccel.ast.core import GetDefaultFunctionArg
>>> n = ValuedArgument('n', 4)
>>> x = Variable('real', 'x')
>>> y = Variable('real', 'y')
>>> args        = [x, n]
>>> results     = [y]
>>> body        = [Assign(y,x+n)]
>>> incr = FunctionDef('incr', args, results, body)
>>> get_n = GetDefaultFunctionArg(n, incr)
>>> get_n.name
get_default_incr_n
>>> get_n
get_default_incr_n(n=4)

You can also use ValuedVariable as in the following example

>>> from pyccel.ast.core import ValuedVariable
>>> n = ValuedVariable('int', 'n', value=4)
>>> x = Variable('real', 'x')
>>> y = Variable('real', 'y')
>>> args        = [x, n]
>>> results     = [y]
>>> body        = [Assign(y,x+n)]
>>> incr = FunctionDef('incr', args, results, body)
>>> get_n = GetDefaultFunctionArg(n, incr)
>>> get_n
get_default_incr_n(n=4)
argument
default_assumptions = {}
func
name
class pyccel.ast.core.If[source]

Bases: pyccel.ast.basic.Basic

Represents a if statement in the code.

args :
every argument is a tuple and is defined as (cond, expr) where expr is a valid ast element and cond is a boolean test.

Examples

>>> from sympy import Symbol
>>> from pyccel.ast.core import Assign, If
>>> n = Symbol('n')
>>> If(((n>1), [Assign(n,n-1)]), (True, [Assign(n,n+1)]))
If(((n>1), [Assign(n,n-1)]), (True, [Assign(n,n+1)]))
bodies
default_assumptions = {}
class pyccel.ast.core.IfTernaryOperator[source]

Bases: pyccel.ast.core.If

class for the Ternery operator

default_assumptions = {}
class pyccel.ast.core.Import[source]

Bases: pyccel.ast.basic.Basic

Represents inclusion of dependencies in the code.

target : str, list, tuple, Tuple
targets to import

Examples

>>> from pyccel.ast.core import Import
>>> from pyccel.ast.core import DottedName
>>> Import('foo')
import foo
>>> abc = DottedName('foo', 'bar', 'baz')
>>> Import(abc)
import foo.bar.baz
>>> Import(['foo', abc])
import foo, foo.bar.baz
default_assumptions = {}
source
target
class pyccel.ast.core.IndexedElement[source]

Bases: sympy.tensor.indexed.Indexed

Represents a mathematical object with indices.

Examples

>>> from sympy import symbols, Idx
>>> from pyccel.ast.core import IndexedVariable
>>> i, j = symbols('i j', cls=Idx)
>>> IndexedElement('A', i, j)
A[i, j]

It is recommended that IndexedElement objects be created via IndexedVariable:

>>> from pyccel.ast.core import IndexedElement
>>> A = IndexedVariable('A')
>>> IndexedElement('A', i, j) == A[i, j]
False

todo: fix bug. the last result must be : True

default_assumptions = {'commutative': True}
dtype
is_commutative = True
order
precision
rank

Returns the rank of the IndexedElement object.

Examples

>>> from sympy import Indexed, Idx, symbols
>>> i, j, k, l, m = symbols('i:m', cls=Idx)
>>> Indexed('A', i, j).rank
2
>>> q = Indexed('A', i, j, k, l, m)
>>> q.rank
5
>>> q.rank == len(q.indices)
True
class pyccel.ast.core.IndexedVariable[source]

Bases: sympy.tensor.indexed.IndexedBase

Represents an indexed variable, like x in x[i], in the code.

Examples

>>> from sympy import symbols, Idx
>>> from pyccel.ast.core import IndexedVariable
>>> A = IndexedVariable('A'); A
A
>>> type(A)
<class 'pyccel.ast.core.IndexedVariable'>

When an IndexedVariable object receives indices, it returns an array with named axes, represented by an IndexedElement object:

>>> i, j = symbols('i j', integer=True)
>>> A[i, j, 2]
A[i, j, 2]
>>> type(A[i, j, 2])
<class 'pyccel.ast.core.IndexedElement'>

The IndexedVariable constructor takes an optional shape argument. If given, it overrides any shape information in the indices. (But not the index ranges!)

>>> m, n, o, p = symbols('m n o p', integer=True)
>>> i = Idx('i', m)
>>> j = Idx('j', n)
>>> A[i, j].shape
(m, n)
>>> B = IndexedVariable('B', shape=(o, p))
>>> B[i, j].shape
(m, n)

todo: fix bug. the last result must be : (o,p)

clone(name)[source]
default_assumptions = {'commutative': True}
dtype
is_commutative = True
kw_args
name
order
precision
rank
class pyccel.ast.core.Interface[source]

Bases: pyccel.ast.basic.Basic

Represent an Interface

cls_name
decorators
default_assumptions = {}
functions
global_vars
hide
imports
is_procedure
kind
name
rename(newname)[source]
class pyccel.ast.core.Is[source]

Bases: pyccel.ast.basic.Basic

Represents a is expression in the code.

Examples

>>> from pyccel.ast import Is
>>> from pyccel.ast import Nil
>>> from sympy.abc import x
>>> Is(x, Nil())
Is(x, None)
default_assumptions = {}
lhs
rhs
class pyccel.ast.core.Len[source]

Bases: sympy.core.function.Function

Represents a ‘len’ expression in the code.

arg
default_assumptions = {}
dtype
class pyccel.ast.core.List[source]

Bases: sympy.core.containers.Tuple

Represent lists in the code with dynamic memory management.

default_assumptions = {}
class pyccel.ast.core.Load[source]

Bases: pyccel.ast.basic.Basic

Similar to ‘importlib’ in python. In addition, we can also provide the functions we want to import.

module: str, DottedName
name of the module to load.
funcs: str, list, tuple, Tuple
a string representing the function to load, or a list of strings.
as_lambda: bool
load as a Lambda expression, if True
nargs: int
number of arguments of the function to load. (default = 1)

Examples

>>> from pyccel.ast.core import Load
as_lambda
default_assumptions = {}
execute()[source]
funcs
module
nargs
class pyccel.ast.core.Map[source]

Bases: pyccel.ast.basic.Basic

Reresents the map stmt

default_assumptions = {}
class pyccel.ast.core.ModOp[source]

Bases: pyccel.ast.core.NativeOp

default_assumptions = {}
class pyccel.ast.core.Module[source]

Bases: pyccel.ast.basic.Basic

Represents a module in the code. A block consists of the following inputs

variables: list
list of the variables that appear in the block.
declarations: list
list of declarations of the variables that appear in the block.
funcs: list
a list of FunctionDef instances
classes: list
a list of ClassDef instances
imports: list, tuple
list of needed imports

Examples

>>> from pyccel.ast.core import Variable, Assign
>>> from pyccel.ast.core import ClassDef, FunctionDef, Module
>>> x = Variable('real', 'x')
>>> y = Variable('real', 'y')
>>> z = Variable('real', 'z')
>>> t = Variable('real', 't')
>>> a = Variable('real', 'a')
>>> b = Variable('real', 'b')
>>> body = [Assign(y,x+a)]
>>> translate = FunctionDef('translate', [x,y,a,b], [z,t], body)
>>> attributs   = [x,y]
>>> methods     = [translate]
>>> Point = ClassDef('Point', attributs, methods)
>>> incr = FunctionDef('incr', [x], [y], [Assign(y,x+1)])
>>> decr = FunctionDef('decr', [x], [y], [Assign(y,x-1)])
>>> Module('my_module', [], [incr, decr], [Point])
Module(my_module, [], [FunctionDef(incr, (x,), (y,), [y := 1 + x], [], [], None, False, function), FunctionDef(decr, (x,), (y,), [y := -1 + x], [], [], None, False, function)], [ClassDef(Point, (x, y), (FunctionDef(translate, (x, y, a, b), (z, t), [y := a + x], [], [], None, False, function),), [public])])
body
classes
declarations
default_assumptions = {}
funcs
imports
interfaces
name
variables
class pyccel.ast.core.MulOp[source]

Bases: pyccel.ast.core.NativeOp

default_assumptions = {}
class pyccel.ast.core.NativeOp[source]

Bases: pyccel.ast.basic.Basic

Base type for native operands.

default_assumptions = {}
class pyccel.ast.core.NewLine[source]

Bases: pyccel.ast.basic.Basic

Represents a NewLine in the code.

text : str
the comment line

Examples

>>> from pyccel.ast.core import NewLine
>>> NewLine()
default_assumptions = {}
class pyccel.ast.core.Nil[source]

Bases: pyccel.ast.basic.Basic

class for None object in the code.

default_assumptions = {}
class pyccel.ast.core.ParallelBlock[source]

Bases: pyccel.ast.core.Block

Represents a parallel block in the code. In addition to block inputs, there is

clauses: list
a list of clauses

Examples

>>> from pyccel.ast.core import ParallelBlock
>>> from pyccel.ast.core import Variable, Assign, Block
>>> n = Variable('int', 'n')
>>> x = Variable('int', 'x')
>>> body = [Assign(x,2.*n + 1.), Assign(n, n + 1)]
>>> variables = [x,n]
>>> clauses = []
>>> ParallelBlock(clauses, variables, body)
# parallel
x := 1.0 + 2.0*n
n := 1 + n
clauses
default_assumptions = {}
prefix
class pyccel.ast.core.ParallelRange[source]

Bases: pyccel.ast.core.Range

Representes a parallel range using OpenMP/OpenACC.

Examples

>>> from pyccel.ast.core import Variable
default_assumptions = {}
class pyccel.ast.core.Pass[source]

Bases: pyccel.ast.basic.Basic

Basic class for pass instruction.

default_assumptions = {}
class pyccel.ast.core.Pow[source]

Bases: sympy.core.power.Pow

default_assumptions = {}
class pyccel.ast.core.Print[source]

Bases: pyccel.ast.basic.Basic

Represents a print function in the code.

expr : sympy expr
The expression to return.

Examples

>>> from sympy import symbols
>>> from pyccel.ast.core import Print
>>> n,m = symbols('n,m')
>>> Print(('results', n,m))
Print((results, n, m))
default_assumptions = {}
expr
class pyccel.ast.core.Product[source]

Bases: pyccel.ast.basic.Basic

Represents a Product stmt.

default_assumptions = {}
elements
class pyccel.ast.core.Program[source]

Bases: pyccel.ast.basic.Basic

Represents a Program in the code. A block consists of the following inputs

variables: list
list of the variables that appear in the block.
declarations: list
list of declarations of the variables that appear in the block.
funcs: list
a list of FunctionDef instances
classes: list
a list of ClassDef instances
body: list
a list of statements
imports: list, tuple
list of needed imports
modules: list, tuple
list of needed modules

Examples

>>> from pyccel.ast.core import Variable, Assign
>>> from pyccel.ast.core import ClassDef, FunctionDef, Module
>>> x = Variable('real', 'x')
>>> y = Variable('real', 'y')
>>> z = Variable('real', 'z')
>>> t = Variable('real', 't')
>>> a = Variable('real', 'a')
>>> b = Variable('real', 'b')
>>> body = [Assign(y,x+a)]
>>> translate = FunctionDef('translate', [x,y,a,b], [z,t], body)
>>> attributs   = [x,y]
>>> methods     = [translate]
>>> Point = ClassDef('Point', attributs, methods)
>>> incr = FunctionDef('incr', [x], [y], [Assign(y,x+1)])
>>> decr = FunctionDef('decr', [x], [y], [Assign(y,x-1)])
>>> Module('my_module', [], [incr, decr], [Point])
Module(my_module, [], [FunctionDef(incr, (x,), (y,), [y := 1 + x], [], [], None, False, function), FunctionDef(decr, (x,), (y,), [y := -1 + x], [], [], None, False, function)], [ClassDef(Point, (x, y), (FunctionDef(translate, (x, y, a, b), (z, t), [y := a + x], [], [], None, False, function),), [public])])
body
classes
declarations
default_assumptions = {}
funcs
imports
interfaces
modules
name
variables
class pyccel.ast.core.PythonFunction[source]

Bases: pyccel.ast.core.FunctionDef

Represents a Python-Function definition.

default_assumptions = {}
rename(newname)[source]

Rename the PythonFunction name by creating a new PythonFunction with newname.

newname: str
new name for the PythonFunction
class pyccel.ast.core.Raise[source]

Bases: pyccel.ast.basic.Basic

Represents a raise in the code.

default_assumptions = {}
class pyccel.ast.core.Random[source]

Bases: sympy.core.function.Function

Represents a ‘random’ number in the code.

default_assumptions = {}
seed
class pyccel.ast.core.Range[source]

Bases: pyccel.ast.basic.Basic

Represents a range.

Examples

>>> from pyccel.ast.core import Variable
>>> from pyccel.ast.core import Range
>>> from sympy import Symbol
>>> s = Variable('int', 's')
>>> e = Symbol('e')
>>> Range(s, e, 1)
Range(0, n, 1)
default_assumptions = {}
size
start
step
stop
class pyccel.ast.core.Return[source]

Bases: pyccel.ast.basic.Basic

Represents a function return in the code.

expr : sympy expr
The expression to return.

stmts :represent assign stmts in the case of expression return

default_assumptions = {}
expr
stmt
class pyccel.ast.core.SeparatorComment[source]

Bases: pyccel.ast.core.Comment

Represents a Separator Comment in the code.

mark : str
marker

Examples

>>> from pyccel.ast.core import SeparatorComment
>>> SeparatorComment(n=40)
# ........................................
default_assumptions = {}
class pyccel.ast.core.Slice[source]

Bases: pyccel.ast.basic.Basic

Represents a slice in the code.

start : Symbol or int
starting index
end : Symbol or int
ending index

Examples

>>> from sympy import symbols
>>> from pyccel.ast.core import Slice
>>> m, n = symbols('m, n', integer=True)
>>> Slice(m,n)
m : n
>>> Slice(None,n)
 : n
>>> Slice(m,None)
m :
default_assumptions = {}
end
start
class pyccel.ast.core.String[source]

Bases: pyccel.ast.basic.Basic

Represents the String

arg
default_assumptions = {}
class pyccel.ast.core.SubOp[source]

Bases: pyccel.ast.core.NativeOp

default_assumptions = {}
class pyccel.ast.core.Subroutine(*args, **kwargs)[source]

Bases: sympy.core.function.UndefinedFunction

class pyccel.ast.core.SumFunction[source]

Bases: pyccel.ast.basic.Basic

Represents a Sympy Sum Function.

body: Expr Sympy Expr in which the sum will be performed.

iterator: a tuple that containts the index of the sum and it’s range.

body
default_assumptions = {}
iterator
stmts
class pyccel.ast.core.SymbolicAssign[source]

Bases: pyccel.ast.basic.Basic

Represents symbolic aliasing for code generation. An alias is any statement of the form lhs := rhs where

lhs : Symbol

rhs : Range

Examples

>>> from sympy import Symbol
>>> from pyccel.ast.core import SymbolicAssign
>>> from pyccel.ast.core import Range
>>> r = Range(0, 3)
>>> y = Symbol('y')
>>> SymbolicAssign(y, r)
default_assumptions = {}
lhs
rhs
class pyccel.ast.core.SymbolicPrint[source]

Bases: pyccel.ast.basic.Basic

Represents a print function of symbolic expressions in the code.

expr : sympy expr
The expression to return.

Examples

>>> from sympy import symbols
>>> from pyccel.ast.core import Print
>>> n,m = symbols('n,m')
>>> Print(('results', n,m))
Print((results, n, m))
default_assumptions = {}
expr
class pyccel.ast.core.SympyFunction[source]

Bases: pyccel.ast.core.FunctionDef

Represents a function definition.

default_assumptions = {}
rename(newname)[source]

Rename the SympyFunction name by creating a new SympyFunction with newname.

newname: str
new name for the SympyFunction
class pyccel.ast.core.Tensor[source]

Bases: pyccel.ast.basic.Basic

Base class for tensor.

Examples

>>> from pyccel.ast.core import Variable
>>> from pyccel.ast.core import Range, Tensor
>>> from sympy import Symbol
>>> s1 = Variable('int', 's1')
>>> s2 = Variable('int', 's2')
>>> e1 = Variable('int', 'e1')
>>> e2 = Variable('int', 'e2')
>>> r1 = Range(s1, e1, 1)
>>> r2 = Range(s2, e2, 1)
>>> Tensor(r1, r2)
Tensor(Range(s1, e1, 1), Range(s2, e2, 1), name=tensor)
default_assumptions = {}
dim
name
ranges
class pyccel.ast.core.Tile[source]

Bases: pyccel.ast.core.Range

Representes a tile.

Examples

>>> from pyccel.ast.core import Variable
>>> from pyccel.ast.core import Tile
>>> from sympy import Symbol
>>> s = Variable('int', 's')
>>> e = Symbol('e')
>>> Tile(s, e, 1)
Tile(0, n, 1)
default_assumptions = {}
size
start
stop
class pyccel.ast.core.TupleImport[source]

Bases: pyccel.ast.basic.Basic

default_assumptions = {}
imports
class pyccel.ast.core.ValuedArgument[source]

Bases: pyccel.ast.basic.Basic

Represents a valued argument in the code.

Examples

>>> from pyccel.ast.core import ValuedArgument
>>> n = ValuedArgument('n', 4)
>>> n
n=4
argument
default_assumptions = {}
name
value
class pyccel.ast.core.ValuedVariable[source]

Bases: pyccel.ast.core.Variable

Represents a valued variable in the code.

variable: Variable
A single variable
value: Variable, or instance of Native types
value associated to the variable

Examples

>>> from pyccel.ast.core import ValuedVariable
>>> n  = ValuedVariable('int', 'n', value=4)
>>> n
n := 4
default_assumptions = {}
value
class pyccel.ast.core.Variable[source]

Bases: sympy.core.symbol.Symbol

Represents a typed variable.

dtype : str, DataType
The type of the variable. Can be either a DataType, or a str (bool, int, real).
name : str, list, DottedName
The sympy object the variable represents. This can be either a string or a dotted name, when using a Class attribut.
rank : int
used for arrays. [Default value: 0]
allocatable: False
used for arrays, if we need to allocate memory [Default value: False]
shape: int or list
shape of the array. [Default value: None]
cls_base: class
class base if variable is an object or an object member

Examples

>>> from sympy import symbols
>>> from pyccel.ast.core import Variable
>>> Variable('int', 'n')
n
>>> Variable('real', x, rank=2, shape=(n,2), allocatable=True)
x
>>> Variable('int', ('matrix', 'n_rows'))
matrix.n_rows
allocatable
clone(name)[source]
cls_base
cls_parameters
default_assumptions = {}
dtype
inspect()[source]

inspects the variable.

is_ndarray

user friendly method to check if the variable is an ndarray: 1. have a rank > 0 2. dtype is one among {int, bool, real, complex}

is_optional
is_pointer
is_polymorphic
is_target
name
order
precision
rank
shape
class pyccel.ast.core.Void[source]

Bases: pyccel.ast.basic.Basic

default_assumptions = {}
class pyccel.ast.core.VoidFunction[source]

Bases: pyccel.ast.basic.Basic

default_assumptions = {}
class pyccel.ast.core.While[source]

Bases: pyccel.ast.basic.Basic

Represents a ‘while’ statement in the code.

Expressions are of the form:
“while test:
body…”
test : expression
test condition given as a sympy expression
body : sympy expr
list of statements representing the body of the While statement.

Examples

>>> from sympy import Symbol
>>> from pyccel.ast.core import Assign, While
>>> n = Symbol('n')
>>> While((n>1), [Assign(n,n-1)])
While(n > 1, (n := n - 1,))
body
default_assumptions = {}
test
class pyccel.ast.core.With[source]

Bases: pyccel.ast.basic.Basic

Represents a ‘with’ statement in the code.

Expressions are of the form:
“while test:
body…”
test : expression
test condition given as a sympy expression
body : sympy expr
list of statements representing the body of the With statement.

Examples

block
body
default_assumptions = {}
settings
test
class pyccel.ast.core.ZerosLike[source]

Bases: sympy.core.function.Function

Represents variable assignment using numpy.zeros_like for code generation.

lhs : Expr
Sympy object representing the lhs of the expression. These should be singular objects, such as one would use in writing code. Notable types include Symbol, MatrixSymbol, MatrixElement, and Indexed. Types that subclass these types are also supported.
rhs : Variable
the input variable

Examples

>>> from sympy import symbols
>>> from pyccel.ast.core import Zeros, ZerosLike
>>> n,m,x = symbols('n,m,x')
>>> y = Zeros(x, (n,m))
>>> z = ZerosLike(y)
default_assumptions = {}
init_value
lhs
rhs
class pyccel.ast.core.Zip[source]

Bases: pyccel.ast.basic.Basic

Represents a zip stmt.

default_assumptions = {}
element
pyccel.ast.core.allocatable_like(expr, verbose=False)[source]

finds attributs of an expression

expr: Expr
a pyccel expression
verbose: bool
talk more
pyccel.ast.core.atom(e)[source]

Return atom-like quantities as far as substitution is concerned: Functions , DottedVarviables. contrary to _atom we return atoms that are inside such quantities too

pyccel.ast.core.float2int(expr)[source]
pyccel.ast.core.get_assigned_symbols(expr)[source]

Returns all assigned symbols (as sympy Symbol) in the AST.

expr: Expression
any AST valid expression
pyccel.ast.core.get_initial_value(expr, var)[source]

Returns the first assigned value to var in the Expression expr.

expr: Expression
any AST valid expression
var: str, Variable, DottedName, list, tuple
variable name
pyccel.ast.core.get_iterable_ranges(it, var_name=None)[source]

Returns ranges of an iterable object.

pyccel.ast.core.inline(func, args)[source]
pyccel.ast.core.int2float(expr)[source]
pyccel.ast.core.is_simple_assign(expr)[source]
pyccel.ast.core.operator(op)[source]

Returns the operator singleton for the given operator

pyccel.ast.core.subs(expr, new_elements)[source]

Substitutes old for new in an expression after sympifying args.

new_elements : list of tuples like [(x,2)(y,3)]

pyccel.ast.datatypes module

class pyccel.ast.datatypes.CustomDataType(name='__UNDEFINED__')[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.DataType[source]

Bases: pyccel.ast.basic.Basic

Base class representing native datatypes

default_assumptions = {}
name
pyccel.ast.datatypes.DataTypeFactory(name, argnames=['_name'], BaseClass=<class 'pyccel.ast.datatypes.CustomDataType'>, prefix=None, alias=None, is_iterable=False, is_with_construct=False, is_polymorphic=True)[source]
class pyccel.ast.datatypes.FunctionType(domains)[source]

Bases: pyccel.ast.datatypes.DataType

codomain
default_assumptions = {}
domain
class pyccel.ast.datatypes.NativeBool[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeComplex[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeComplexList[source]

Bases: pyccel.ast.datatypes.NativeComplex, pyccel.ast.datatypes.NativeList

default_assumptions = {}
class pyccel.ast.datatypes.NativeGeneric[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeInteger[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeIntegerList[source]

Bases: pyccel.ast.datatypes.NativeInteger, pyccel.ast.datatypes.NativeList

default_assumptions = {}
class pyccel.ast.datatypes.NativeList[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeNil[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeParallelRange[source]

Bases: pyccel.ast.datatypes.NativeRange

default_assumptions = {}
class pyccel.ast.datatypes.NativeRange[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeReal[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeRealList[source]

Bases: pyccel.ast.datatypes.NativeReal, pyccel.ast.datatypes.NativeList

default_assumptions = {}
class pyccel.ast.datatypes.NativeString[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeSymbol[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeTensor[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.NativeVoid[source]

Bases: pyccel.ast.datatypes.DataType

default_assumptions = {}
class pyccel.ast.datatypes.UnionType[source]

Bases: pyccel.ast.basic.Basic

args
default_assumptions = {}
class pyccel.ast.datatypes.VariableType(rhs, alias)[source]

Bases: pyccel.ast.datatypes.DataType

alias
default_assumptions = {}
pyccel.ast.datatypes.datatype(arg)[source]

Returns the datatype singleton for the given dtype.

arg : str or sympy expression
If a str (‘bool’, ‘int’, ‘real’,’complex’, or ‘void’), return the singleton for the corresponding dtype. If a sympy expression, return the datatype that best fits the expression. This is determined from the assumption system. For more control, use the DataType class directly.
Returns:
DataType
pyccel.ast.datatypes.get_default_value(dtype)[source]

Returns the default value of a native datatype.

pyccel.ast.datatypes.is_iterable_datatype(dtype)[source]

Returns True if dtype is an iterable class.

pyccel.ast.datatypes.is_pyccel_datatype(expr)[source]
pyccel.ast.datatypes.is_with_construct_datatype(dtype)[source]

Returns True if dtype is an with_construct class.

pyccel.ast.datatypes.sp_dtype(expr)[source]

return the datatype of a sympy types expression

pyccel.ast.datatypes.str_dtype(dtype)[source]

return a sympy datatype as string dtype: str, Native Type

pyccel.ast.fortran module

class pyccel.ast.fortran.Ceil[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.fortran.Dot[source]

Bases: sympy.core.function.Function

Represents a ‘dot’ expression in the code.

expr_l: variable
first variable
expr_r: variable
second variable
default_assumptions = {}
expr_l
expr_r
class pyccel.ast.fortran.Max[source]

Bases: sympy.core.function.Function

Represents a ‘max’ expression in the code.

default_assumptions = {}
class pyccel.ast.fortran.Min[source]

Bases: sympy.core.function.Function

Represents a ‘min’ expression in the code.

default_assumptions = {}
class pyccel.ast.fortran.Mod[source]

Bases: sympy.core.function.Function

Represents a ‘mod’ expression in the code.

default_assumptions = {}
class pyccel.ast.fortran.Sign[source]

Bases: sympy.core.basic.Basic

default_assumptions = {}
rhs

pyccel.ast.headers module

class pyccel.ast.headers.ClassHeader[source]

Bases: pyccel.ast.headers.Header

Represents class header in the code.

name: str
class name
options: str, list, tuple
a list of options

Examples

>>> from pyccel.ast.core import ClassHeader
>>> ClassHeader('Matrix', ('abstract', 'public'))
ClassHeader(Matrix, (abstract, public))
default_assumptions = {}
name
options
class pyccel.ast.headers.FunctionHeader[source]

Bases: pyccel.ast.headers.Header

Represents function/subroutine header in the code.

func: str
function/subroutine name
dtypes: tuple/list
a list of datatypes. an element of this list can be str/DataType of a tuple (str/DataType, attr, allocatable)
results: tuple/list
a list of datatypes. an element of this list can be str/DataType of a tuple (str/DataType, attr, allocatable)
kind: str
‘function’ or ‘procedure’. default value: ‘function’
is_static: bool
True if we want to pass arrays in f2py mode. every argument of type array will be preceeded by its shape, the later will appear in the argument declaration. default value: False

Examples

>>> from pyccel.ast.core import FunctionHeader
>>> FunctionHeader('f', ['double'])
FunctionHeader(f, [(NativeDouble(), [])])
create_definition()[source]

Returns a FunctionDef with empy body.

default_assumptions = {}
dtypes
func
is_static
kind
results
to_static()[source]

returns a static function header. needed for f2py

vectorize(index)[source]

add a dimension to one of the arguments specified by it’s position

class pyccel.ast.headers.Header[source]

Bases: pyccel.ast.basic.Basic

default_assumptions = {}
class pyccel.ast.headers.InterfaceHeader[source]

Bases: pyccel.ast.basic.Basic

default_assumptions = {}
funcs
name
class pyccel.ast.headers.MacroFunction[source]

Bases: pyccel.ast.headers.Header

.

apply(args, results=None)[source]

returns the appropriate arguments.

arguments
default_assumptions = {}
master
master_arguments
name
results
class pyccel.ast.headers.MacroVariable[source]

Bases: pyccel.ast.headers.Header

.

default_assumptions = {}
master
name
class pyccel.ast.headers.MetaVariable[source]

Bases: pyccel.ast.headers.Header

Represents the MetaVariable.

default_assumptions = {}
name
value
class pyccel.ast.headers.MethodHeader[source]

Bases: pyccel.ast.headers.FunctionHeader

Represents method header in the code.

name: iterable
method name as a list/tuple
dtypes: tuple/list
a list of datatypes. an element of this list can be str/DataType of a tuple (str/DataType, attr)
results: tuple/list
a list of datatypes. an element of this list can be str/DataType of a tuple (str/DataType, attr)
kind: str
‘function’ or ‘procedure’. default value: ‘function’
is_static: bool
True if we want to pass arrays in f2py mode. every argument of type array will be preceeded by its shape, the later will appear in the argument declaration. default value: False

Examples

>>> from pyccel.ast.core import MethodHeader
>>> m = MethodHeader(('point', 'rotate'), ['double'])
>>> m
MethodHeader((point, rotate), [(NativeDouble(), [])], [])
>>> m.name
'point.rotate'
default_assumptions = {}
dtypes
is_static
kind
name
results
class pyccel.ast.headers.VariableHeader[source]

Bases: pyccel.ast.headers.Header

Represents a variable header in the code.

name: str
variable name
dtypes: dict
a dictionary for typing

Examples

default_assumptions = {}
dtypes
name

pyccel.ast.macros module

class pyccel.ast.macros.Macro[source]

Bases: sympy.core.expr.AtomicExpr

.

argument
default_assumptions = {}
name
class pyccel.ast.macros.MacroCount[source]

Bases: pyccel.ast.macros.Macro

.

default_assumptions = {}
class pyccel.ast.macros.MacroShape[source]

Bases: pyccel.ast.macros.Macro

.

default_assumptions = {}
index
class pyccel.ast.macros.MacroType[source]

Bases: pyccel.ast.macros.Macro

.

default_assumptions = {}
pyccel.ast.macros.construct_macro(name, argument, parameter=None)[source]

.

pyccel.ast.numpyext module

class pyccel.ast.numpyext.Abs[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Acos[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Acot[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Acsc[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Array[source]

Bases: sympy.core.function.Function

Represents a call to numpy.array for code generation.

arg : list ,tuple ,Tuple,List

arg
default_assumptions = {}
dtype
fprint(printer, lhs)[source]

Fortran print.

order
precision
rank
shape
class pyccel.ast.numpyext.Asec[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Asin[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Atan[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Complex[source]

Bases: sympy.core.function.Function

Represents a call to numpy.complex for code generation.

arg : Variable, Float, Integer

default_assumptions = {}
dtype
fprint(printer)[source]

Fortran print.

imag_part
precision
rank
real_part
shape
class pyccel.ast.numpyext.Complex128[source]

Bases: pyccel.ast.numpyext.Complex

default_assumptions = {}
class pyccel.ast.numpyext.Complex64[source]

Bases: pyccel.ast.numpyext.Complex

default_assumptions = {}
precision
class pyccel.ast.numpyext.Cosh[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Empty[source]

Bases: pyccel.ast.numpyext.Zeros

Represents a call to numpy.empty for code generation.

shape : int or list of integers

default_assumptions = {}
fprint(printer, lhs)[source]

Fortran print.

class pyccel.ast.numpyext.Float32[source]

Bases: pyccel.ast.numpyext.Real

default_assumptions = {}
precision
class pyccel.ast.numpyext.Float64[source]

Bases: pyccel.ast.numpyext.Real

default_assumptions = {}
class pyccel.ast.numpyext.Int[source]

Bases: sympy.core.function.Function

Represents a call to numpy.int for code generation.

arg : Variable, Real, Integer, Complex

arg
default_assumptions = {}
dtype
fprint(printer)[source]

Fortran print.

precision
rank
shape
class pyccel.ast.numpyext.Int32[source]

Bases: pyccel.ast.numpyext.Int

default_assumptions = {}
class pyccel.ast.numpyext.Int64[source]

Bases: pyccel.ast.numpyext.Int

default_assumptions = {}
precision
class pyccel.ast.numpyext.Log[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Max[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Min[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Ones[source]

Bases: pyccel.ast.numpyext.Zeros

Represents a call to numpy.ones for code generation.

shape : int or list of integers

default_assumptions = {}
init_value
class pyccel.ast.numpyext.Rand[source]

Bases: pyccel.ast.numpyext.Real

Represents a call to numpy.random.random or numpy.random.rand for code generation.

arg : list ,tuple ,Tuple,List

arg
default_assumptions = {}
fprint(printer)[source]

Fortran print.

rank
class pyccel.ast.numpyext.Real[source]

Bases: sympy.core.function.Function

Represents a call to numpy.Real for code generation.

arg : Variable, Float, Integer, Complex

arg
default_assumptions = {}
dtype
fprint(printer)[source]

Fortran print.

precision
rank
shape
class pyccel.ast.numpyext.Shape[source]

Bases: pyccel.ast.numpyext.Array

Represents a call to numpy.shape for code generation.

arg : list ,tuple ,Tuple,List, Variable

arg
default_assumptions = {}
dtype
fprint(printer, lhs=None)[source]

Fortran print.

index
rank
shape
class pyccel.ast.numpyext.Sinh[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Sqrt[source]

Bases: pyccel.ast.core.Pow

default_assumptions = {}
class pyccel.ast.numpyext.Sum[source]

Bases: sympy.core.function.Function

Represents a call to numpy.sum for code generation.

arg : list , tuple , Tuple, List, Variable

arg
default_assumptions = {}
dtype
fprint(printer, lhs=None)[source]

Fortran print.

rank
class pyccel.ast.numpyext.Tanh[source]

Bases: sympy.core.function.Function

default_assumptions = {}
class pyccel.ast.numpyext.Zeros[source]

Bases: sympy.core.function.Function

Represents a call to numpy.zeros for code generation.

shape : int, list, tuple
int or list of integers
dtype: str, DataType
datatype for the constructed array

Examples

default_assumptions = {}
dtype
fprint(printer, lhs)[source]

Fortran print.

init_value
order
precision
rank
shape

pyccel.ast.utilities module

pyccel.ast.utilities.builtin_function(expr, args=None)[source]

Returns a builtin-function call applied to given arguments.

pyccel.ast.utilities.builtin_import(expr)[source]

Returns a builtin pyccel-extension function/object from an import.

Module contents