Esempio n. 1
0
    def Slice(self, node):
        # Slice(start, stop, step){id(node), 'get'|'set'}
        array, start, stop, step = node.operands

        if start:
            start = self.visit(start)
        if stop:
            stop = self.visit(stop)
        if step:
            step = self.visit(step)

        return aappl(
            aterm("Slice"), [self.visit(array), start or aterm("None"), stop or aterm("None"), step or aterm("None")]
        )
Esempio n. 2
0
 def Literal(self, node):
     if node.vtype == int:
         return aint(node.val)
     if node.vtype == float:
         return areal(node.val)
     else:
         return aterm(node.val)
Esempio n. 3
0
def annotate_dshape(ds):
    """
    Convert a datashape instance into Aterm annotation

    >>> ds = dshape('2, 2, int32')
    >>> anno = dshape_anno(ds)
    dshape("2, 2, int32")
    >>> type(anno)
    <class 'AAppl'>
    """

    assert isinstance(ds, DataShape)
    return aappl(aterm("dshape"), [astr(str(ds))])
Esempio n. 4
0
 def Assign(self, node):
     return aappl(aterm("Assign"), self.visit(node.operands))
Esempio n. 5
0
 def IndexNode(self, node):
     return aappl(aterm("Index"), self.visit(node.operands))
Esempio n. 6
0
 def Indexable(self, node):
     self.operands.append(node)
     return aappl(aterm("Array"), [])
Esempio n. 7
0
 def Op(self, node):
     opname = node.__class__.__name__
     return aappl(aterm(opname), self.visit(node.children))