Beispiel #1
0
 def __init__(self, address, value):
     super(ConstantNode, self).__init__(address)
     if isinstance(value, VentureValue):
         # Possible for programmatic construction, e.g. builtin.py
         # Will also occur for literal atoms, since there's no other way
         # to tell them apart from literal numbers.
         self.value = value
     else:  # In eval
         self.value = ExpressionType().asVentureValue(value)
Beispiel #2
0
 def parse_expr(self, expr, command):
     special_names = [VentureSymbol(x) for x in ['iter', 'time', 'score']]
     if (isinstance(expr, VentureArray) and expr.lookup(VentureInteger(0))
             == VentureSymbol('labelled')):
         # The first element is the command, the second is the label for
         # the command
         stack_dict = expr.lookup(VentureInteger(1)).asStackDict()
         name = expr.lookup(VentureInteger(2)).symbol
     elif command == 'printf' and expr in special_names:
         name = expr.getSymbol()
         stack_dict = None
     else:
         # Generate the default name, get the stack dict
         stack_dict = expr.asStackDict()
         name = self.default_name_for_exp(ExpressionType().asPython(expr))
     return name, stack_dict
Beispiel #3
0
 def unboxExpression(self, exp):
     return ExpressionType().asPython(VentureValue.fromStackDict(exp))
Beispiel #4
0
 def default_names_from_exprs(self, exprs):
     return [
         self.default_name_for_exp(ExpressionType().asPython(e))
         for e in exprs
     ]
Beispiel #5
0
 def plotf_to_file(self, basenames, spec, dataset):
     filenames = ExpressionType().asPython(basenames)
     spec = ExpressionType().asPython(spec)
     spec = self._canonicalize_tree(spec)
     PlotSpec(spec).plot(dataset.asPandas(), dataset.ind_names,
                         self._format_filenames(filenames, spec))
Beispiel #6
0
 def plotf(self, spec, dataset):
     spec = ExpressionType().asPython(spec)
     spec = self._canonicalize_tree(spec)
     PlotSpec(spec).plot(dataset.asPandas(), dataset.ind_names)