Ejemplo n.º 1
0
    def visit_Subscript(self, node):
        # print ast.dump(node)
        self.generic_visit(node)
        is_store = isinstance(node.ctx, ast.Store)
        self.is_slice_assign = is_store and node.type.is_array

        if is_store:
            if nodes.is_ellipsis(node.slice):
                return node.value
        elif node.value.type.is_array and node.type.is_array:
            node = slicenodes.rewrite_slice(node, self.nopython)

        return node
Ejemplo n.º 2
0
    def visit_Subscript(self, node):
        # print ast.dump(node)
        self.generic_visit(node)
        is_store = isinstance(node.ctx, ast.Store)
        self.is_slice_assign = is_store and node.type.is_array

        if is_store:
            if nodes.is_ellipsis(node.slice):
                return node.value
        elif node.value.type.is_array and node.type.is_array:
            node = slicenodes.rewrite_slice(node, self.nopython)

        return node
Ejemplo n.º 3
0
    def visit_Assign(self, node):
        self.is_slice_assign = False
        self.visitlist(node.targets)

        target_node = node.targets[0]
        is_slice_assign = self.is_slice_assign

        self.nesting_level = self.is_slice_assign
        node.value = self.visit(node.value)
        self.nesting_level = 0

        elementwise = self.elementwise
        if (len(node.targets) == 1 and is_slice_assign and
                is_elementwise_assignment(node)): # and elementwise):
            target_node = slicenodes.rewrite_slice(target_node,
                                                      self.nopython)
            return self.register_array_expression(node.value, lhs=target_node)

        return node
Ejemplo n.º 4
0
    def visit_Assign(self, node):
        self.is_slice_assign = False
        self.visitlist(node.targets)

        target_node = node.targets[0]
        is_slice_assign = self.is_slice_assign

        self.nesting_level = self.is_slice_assign
        node.value = self.visit(node.value)
        self.nesting_level = 0

        elementwise = self.elementwise

        if (len(node.targets) == 1 and is_slice_assign and
                is_elementwise_assignment(self.context, node)):
            target_node = slicenodes.rewrite_slice(target_node,
                                                      self.nopython)
            return self.register_array_expression(node.value, lhs=target_node)

        return node