Exemplo n.º 1
0
def _base(var, printname):
    if printname:
        yield var.id
        yield '\n'

    data = numpy.asarray(var.data).flat
    if var.shape:
        for indexes, value in itertools.izip(numpy.ndindex(var.shape), data):
            index = '[%s]' % ']['.join(str(idx) for idx in indexes)
            yield '%s %s\n' % (index, encode_atom(value))
    else:
        yield encode_atom(var.data)
Exemplo n.º 2
0
def _base(var, printname):
    if printname:
        yield var.id
        yield '\n'

    data = numpy.asarray(var.data).flat
    if var.shape:
        for indexes, value in itertools.izip(numpy.ndindex(var.shape), data):
            index = '[%s]' % ']['.join(str(idx) for idx in indexes)
            yield '%s %s\n' % (index, encode_atom(value))
    else:
        yield encode_atom(var.data)
Exemplo n.º 3
0
 def __call__(self, *args):
     params = []
     for arg in args:
         if isinstance(arg, (DapType, ServerFunctionResult)):
             params.append(arg.id)
         else:
             params.append(encode_atom(arg))
     id_ = self.name + '(' + ','.join(params) + ')'
     return ServerFunctionResult(self.baseurl, id_)
Exemplo n.º 4
0
def _recursive_build(attr, values, level=0):
    """
    Recursive function to build the DAS.
    
    """
    # Check for metadata.
    if isinstance(values, dict):
        yield '%s%s {\n' % ((level+1) * INDENT, attr)
        for k, v in values.items():
            for line in _recursive_build(k, v, level+1):
                yield line
        yield '%s}\n' % ((level+1) * INDENT)
    else:
        type_ = get_type(values).descriptor
        if not isiterable(values):
            values = [values]

        # Encode values
        values = [encode_atom(atom) for atom in values]
        yield '%s%s %s %s;\n' % ((level+1) * INDENT, type_,
                attr.replace(' ', '_'), ', '.join(values))
Exemplo n.º 5
0
    def __lt__(self, other): return ConstraintExpression('%s<%s' % (self.id, encode_atom(other)))


def reorder(order, data, level):
Exemplo n.º 6
0
 def __gt__(self, other): return ConstraintExpression('%s>%s' % (self.id, encode_atom(other)))
 def __lt__(self, other): return ConstraintExpression('%s<%s' % (self.id, encode_atom(other)))
Exemplo n.º 7
0
 def __ne__(self, other): return ConstraintExpression('%s!=%s' % (self.id, encode_atom(other)))
 def __ge__(self, other): return ConstraintExpression('%s>=%s' % (self.id, encode_atom(other)))
Exemplo n.º 8
0
 def __lt__(self, other):
     return ConstraintExpression('%s<%s' % (self.id, encode_atom(other)))