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)
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_)
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))
def __lt__(self, other): return ConstraintExpression('%s<%s' % (self.id, encode_atom(other))) def reorder(order, data, level):
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)))
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)))
def __lt__(self, other): return ConstraintExpression('%s<%s' % (self.id, encode_atom(other)))