def run(self, node, expr=None, func=None,
            fname=None, lineno=None, with_raise=False):
        """executes parsed Ast representation for an expression"""
        # Note: keep the 'node is None' test: internal code here may run
        #    run(None) and expect a None in return.
        # print(" Run", node, expr)
        if node is None:
            return None
        if isinstance(node, str):
            node = self.parse(node)
        if lineno is not None:
            self.lineno = lineno
        if fname  is not None:
            self.fname  = fname
        if expr  is not None:
            self.expr   = expr
        if func is not None:
            self.func = func

        # get handler for this node:
        #   on_xxx with handle nodes of type 'xxx', etc
        if node.__class__.__name__.lower() not in self.node_handlers:
            return self.unimplemented(node)
        handler = self.node_handlers[node.__class__.__name__.lower()]
        # run the handler:  this will likely generate
        # recursive calls into this run method.
        try:
            out = handler(node)
        except:
            self.raise_exception(node, expr=self.expr,
                                 fname=self.fname, lineno=self.lineno)
        else:
            # for some cases (especially when using Parameter objects),
            # a calculation returns an otherwise numeric array, but with
            # dtype 'object'. fix here, trying (float, complex, list).
            if isinstance(out, numpy.ndarray):
                if out.dtype == numpy.object:
                    try:
                        out = out.astype(float)
                    except __HOLE__:
                        try:
                            out = out.astype(complex)
                        except TypeError:
                            out = list(out)
            # enumeration objects are list-ified here...
            if isinstance(out, enumerate):
                out = list(out)
            return out
dataset/ETHPy150Open xraypy/xraylarch/lib/interpreter.py/Interpreter.run