Exemplo n.º 1
0
    def __init__(self, inputs, *args, **kwargs):

        # create a new converter from an operator
        if len(args) == 3:
            self.extra_op, self.oldname, self.newname = args
        else:
            self.extra_op, self.oldname, self.newname = None, None, None

        self.converters = [lambda x: x] * len(inputs)
        outputs = copy.deepcopy(inputs)
        for i in xrange(0, len(inputs)):
            if 'Properties/UnitofMeasure' in inputs[i]:
                unit, converter = self.find_conversion(inputs[i])

                # make a closure with the converter
                def make_converter():
                    _converter = converter
                    if callable(_converter):
                        return _converter([inputs[i]])
                    else:
                        return lambda x: np.dstack((x[0][:, 0], _converter *
                                                    (x[0][:, 1])))

                self.converters[i] = make_converter()
                outputs[i]['Properties/UnitofMeasure'] = unit
        Operator.__init__(self, inputs, outputs)
Exemplo n.º 2
0
 def __init__(self, inputs):
     outputs = [{} for x in xrange(0, len(inputs))]
     for i, stream in enumerate(inputs):
         for k, v in stream.iteritems():
             if not k.startswith('Metadata/'):
                 outputs[i][k] = v
     Operator.__init__(self, inputs, outputs)
Exemplo n.º 3
0
    def __init__(self, inputs, *args, **kwargs):

        # create a new converter from an operator
        if len(args) == 3:
            self.extra_op, self.oldname, self.newname = args
        else:
            self.extra_op, self.oldname, self.newname = None, None, None

        self.converters = [lambda x: x] * len(inputs)
        outputs = copy.deepcopy(inputs)
        for i in xrange(0, len(inputs)):
            if "Properties/UnitofMeasure" in inputs[i]:
                unit, converter = self.find_conversion(inputs[i])

                # make a closure with the converter
                def make_converter():
                    _converter = converter
                    if callable(_converter):
                        return _converter([inputs[i]])
                    else:
                        return lambda x: np.dstack((x[0][:, 0], _converter * (x[0][:, 1])))

                self.converters[i] = make_converter()
                outputs[i]["Properties/UnitofMeasure"] = unit
        Operator.__init__(self, inputs, outputs)
Exemplo n.º 4
0
    def __init__(self, inputs, cols="1", operator=None):

        self.cols = make_colspec(cols)
        self.ops = map(lambda x: operator([x]), inputs)
        self.name = "catcol(%s, %s)" % (",".join(map(str, self.cols)), str(self.ops[0]))
        # print self.cols, self.ops
        Operator.__init__(self, inputs, operators.OP_N_TO_N)
Exemplo n.º 5
0
 def __init__(self, inputs):
     outputs = [{} for x in xrange(0, len(inputs))]
     for i, stream in enumerate(inputs):
         for k, v in stream.iteritems():
             if not k.startswith("Metadata/"):
                 outputs[i][k] = v
     Operator.__init__(self, inputs, outputs)
Exemplo n.º 6
0
    def __init__(self, inputs, cols="1", operator=None):

        self.cols = make_colspec(cols)
        self.ops = map(lambda x: operator([x]), inputs)
        self.name = 'catcol(%s, %s)' % (','.join(map(
            str, self.cols)), str(self.ops[0]))
        # print self.cols, self.ops
        Operator.__init__(self, inputs, operators.OP_N_TO_N)
Exemplo n.º 7
0
 def __init__(self, inputs, tag, newname):
     self.name = "rename(%s, %s)" % (tag, newname)
     output = copy.deepcopy(inputs)
     for s in output:
         if tag in s:
             s[newname] = s[tag]
             del s[tag]
     Operator.__init__(self, inputs, output)
Exemplo n.º 8
0
Arquivo: util.py Projeto: rraabb/smap
 def __init__(self, inputs, tag, newname):
     self.name = 'rename(%s, %s)' % (tag, newname)
     output = copy.deepcopy(inputs)
     for s in output:
         if tag in s:
             s[newname] = s[tag]
             del s[tag]
     Operator.__init__(self, inputs, output)
Exemplo n.º 9
0
 def __init__(self, inputs, tag, newname, remove=True):
     self.name = 'rename(%s, %s)' % (tag, newname)
     output = copy.deepcopy(inputs)
     for s in output:
         if tag in s:
             s[newname] = s[tag]
             if remove: 
                 del s[tag]
     Operator.__init__(self, inputs, output)
Exemplo n.º 10
0
 def __init__(self, inputs):
     # don't change uuids
     Operator.__init__(self, inputs, inputs)
Exemplo n.º 11
0
 def __init__(self, inputs, key, value):
     # don't change uuids
     outputs = copy.deepcopy(inputs)
     for o in outputs:
         o[key] = value
     Operator.__init__(self, inputs, outputs)
Exemplo n.º 12
0
 def __init__(self, inputs):
     # don't change uuids
     Operator.__init__(self, inputs, inputs)
Exemplo n.º 13
0
 def __init__(self, inputs, key, value):
     # don't change uuids
     outputs = copy.deepcopy(inputs)
     for o in outputs:
         o[key] = value
     Operator.__init__(self, inputs, outputs)
Exemplo n.º 14
0
 def __init__(self, inputs, *vals, **kwargs):
     tag = kwargs.get('tag', 'uuid')
     keys = map(lambda x: x.get(tag, None), inputs)
     self.order = map(lambda val: keys.index(val), vals)
     Operator.__init__(self, inputs, [inputs[i] for i in self.order])
Exemplo n.º 15
0
 def __init__(self, inputs, *vals, **kwargs):
     tag = kwargs.get('tag', 'uuid')
     keys = map(lambda x: x.get(tag, None), inputs)
     self.order = map(lambda val: keys.index(val), vals)
     Operator.__init__(self, inputs, [inputs[i] for i in self.order])
Exemplo n.º 16
0
 def __init__(self, inputs, days="1,2,3,4,5"):
     self.days = map(int, days.split(','))
     self.tzs = map(lambda x: dtutil.gettz(x['Properties/Timezone']),
                    inputs)
     Operator.__init__(self, inputs, OP_N_TO_N)