How to use the pyccel.ast.core.DottedName function in pyccel

To help you get started, we’ve selected a few pyccel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyccel / pyccel / pyccel / ast / core.py View on Github external
def _construct_arg_Range(name):
            if not isinstance(name, DottedName):
                raise TypeError('Expecting a DottedName, given  {0}'.format(type(name)))

            if not var_name:
                return DottedName(it.name.name[0], name.name[1])
            else:
                return DottedName(var_name, name.name[1])
github pyccel / pyccel / pyccel / ast / core.py View on Github external
def _construct_arg_Range(name):
            if not isinstance(name, DottedName):
                raise TypeError('Expecting a DottedName, given  {0}'.format(type(name)))

            if not var_name:
                return DottedName(it.name.name[0], name.name[1])
            else:
                return DottedName(var_name, name.name[1])

        # ...

        cls_base = it.cls_base

        if isinstance(cls_base, Range):
            if not isinstance(it.name, DottedName):
                raise TypeError('Expecting a DottedName, given  {0}'.format(type(it.name)))

            args = []
            for i in [cls_base.start, cls_base.stop, cls_base.step]:
                if isinstance(i, (Variable, IndexedVariable)):
                    arg_name = _construct_arg_Range(i.name)
                    arg = i.clone(arg_name)
                elif isinstance(i, IndexedElement):
                    arg_name = _construct_arg_Range(i.base.name)
                    base = i.base.clone(arg_name)
                    indices = i.indices
                    arg = base[indices]
                else:
                    raise TypeError('Wrong type, given {0}'.format(type(i)))
                args += [arg]
github pyccel / pyccel / pyccel / ast / core.py View on Github external
def _construct_arg_Range(name):
            if not isinstance(name, DottedName):
                raise TypeError('Expecting a DottedName, given '
                                ' {0}'.format(type(name)))

            if not var_name:
                return DottedName(it.name.name[0], name.name[1])
            else:
                return DottedName(var_name, name.name[1])
        # ...
github pyccel / pyccel / src_old / syntax_core.py View on Github external
# for the moment, inside the definition of the class, cls_base is of
        # type str
        attributs = []
        if isinstance(cls_base, ClassDef):
            d_attributs = cls_base.attributs_as_dict
            if not(arg in d_attributs):
                raise ValueError('{0} is not a member of '
                                 '{1}'.format(arg, expr))

            attribut = d_attributs[arg]

            var_name = DottedName(expr.name, arg)
            var = attribut.clone(var_name)
            return var
        elif isinstance(cls_base, str):
            var_name = DottedName(expr.name, arg)
            if str(var_name) in namespace:
                expr = namespace[str(var_name)]
            else:
                if not(expr.name in namespace):
                    raise ValueError("Undefined variable {}".format(expr.name))

                expr = DottedName(expr, arg)

                attr = get_class_attribut(expr)
                if not(attr is None):
                    return attr
                else:
                    # now, we insert the class attribut as a sympy Symbol in the
                    # namespace. Later, this will be decorated, when processing an
                    # AssignStmt.
                    namespace[str(expr)] = Symbol(str(expr))
github pyccel / pyccel / pyccel / ast / core.py View on Github external
def __new__(cls, module, funcs=None, as_lambda=False, nargs=1):
        if not isinstance(module, (str, DottedName, list, tuple, Tuple)):
            raise TypeError('Expecting a string or DottedName, given'
                            ' {0}'.format(type(module)))

        # see syntax
        if isinstance(module, str):
            module = module.replace('__', '.')

        if isinstance(module, (list, tuple, Tuple)):
            module = DottedName(*module)

        if funcs:
            if not isinstance(funcs, (str, DottedName, list, tuple, Tuple)):
                raise TypeError('Expecting a string or DottedName')

            if isinstance(funcs, str):
                funcs = [funcs]
            elif not isinstance(funcs, (list, tuple, Tuple)):
                raise TypeError('Expecting a string, list, tuple, Tuple')

        if not isinstance(as_lambda, (BooleanTrue, BooleanFalse, bool)):
            raise TypeError('Expecting a boolean, given {0}'.format(as_lambda))

        return Basic.__new__(cls, module, funcs, as_lambda, nargs)
github pyccel / pyccel / pyccel / ast / parallel / openacc.py View on Github external
elif isinstance(expr, ConstructorCall):
        # arguments[0] is 'self'
        # TODO must be improved in syntax, so that a['value'] is a sympy object
        for a in expr.arguments[1:]:
            if isinstance(a, dict):
                # we add '_' tp be conform with the private variables convention
                d_args['_{0}'.format(a['key'])] = a['value']
    else:
        return None, None
    # ...

    # ... get initial values for all attributs
    #     TODO do we keep 'self' hard coded?
    d = {}
    for k,v in d_attributs.items():
        i = DottedName('self', k)
        d[k] = get_initial_value(expr, i)
    # ...

    # ... update the dictionary with the class parameters
    for k,v in d_args.items():
        d[k] = d_args[k]
    # ...

    # ... initial values for clauses
    _collapse    = None
    _gang        = None
    _worker      = None
    _vector      = None
    _seq         = None
    _auto        = None
    _tile        = None
github pyccel / pyccel / pyccel / ast / core.py View on Github external
def _construct_arg_Range(name):
            if not isinstance(name, DottedName):
                raise TypeError('Expecting a DottedName, given  {0}'.format(type(name)))

            if not var_name:
                return DottedName(it.name.name[0], name.name[1])
            else:
                return DottedName(var_name, name.name[1])
github pyccel / pyccel / pyccel / ast / parallel / openmp.py View on Github external
elif isinstance(expr, ConstructorCall):
        # arguments[0] is 'self'
        # TODO must be improved in syntax, so that a['value'] is a sympy object
        for a in expr.arguments[1:]:
            if isinstance(a, dict):
                # we add '_' tp be conform with the private variables convention
                d_args['_{0}'.format(a['key'])] = a['value']
    else:
        return None, None
    # ...

    # ... get initial values for all attributs
    #     TODO do we keep 'self' hard coded?
    d = {}
    for k,v in d_attributs.items():
        i = DottedName('self', k)
        d[k] = get_initial_value(expr, i)
    # ...

    # ... update the dictionary with the class parameters
    for k,v in d_args.items():
        d[k] = d_args[k]
    # ...

    # ... initial values for clauses
    nowait       = None

    collapse     = None
    private      = None
    firstprivate = None
    lastprivate  = None
    reduction    = None