Changeset 49


Ignore:
Timestamp:
May 14, 2009, 8:05:34 AM (11 years ago)
Author:
marchulsman
Message:

Bugfixes + field transform in node

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • container/container.py

    r48 r49  
    276276
    277277    # equals ( == )
    278     def __eqr__(self, other):
     278    def __eq__(self, other):
    279279        if(isinstance(other,context.Context)):
    280280            return other.__eq__(self)
     
    282282
    283283    # not-equals ( != )
    284     def __ner__(self, other):
     284    def __ne__(self, other):
    285285        if(isinstance(other,context.Context)):
    286286            return other.__ne__(self)
  • container/itypes_py.py

    r48 r49  
    118118
    119119
     120
     121cmp_ops = set(['__ne__','__eq__','__le__','__ge__','__gt__','__lt__'])
    120122def binop_type(left,right,operator):
    121123    if(isinstance(left,IType)):
     
    123125            if(not left.typecode & types['RSEQUENCE']):
    124126                if(not right.typecode & types['RSEQUENCE']): #both types are scalars
    125                     r = chooseType(getConvertableTypes(left.typecode) & getConvertableTypes(right.typecode))
     127                    if(operator in cmp_ops):
     128                        return IType(typecode=types['bool'])
     129                    else:
     130                        r = chooseType(getConvertableTypes(left.typecode) & getConvertableTypes(right.typecode))
    126131
    127132                    #handle str,unicode,bytes data type
  • container/opcon.py

    r48 r49  
    272272                rtype = itypes_py.getType(sright)
    273273                self._fields = itypes_py.binop_type(sleft._activefields,rtype,operator)
    274                 self._actidx = range(len(self._fields))
     274                self._actidx = numpy.arange(len(self._fields))
    275275                self._noFieldProps(sleft)
    276276            else:
    277277                self._fields = itypes_py.binop_type(sleft._activefields,sright._activefields,operator)
    278                 self._actidx = range(len(self._fields))
     278                self._actidx = numpy.arange(len(self._fields))
    279279                self._noFieldProps(sleft,sright)
    280280            self._invar.update['_fields'] = self._fields
     281            self._invar.update['_actidx'] = self._actidx
     282            self._invar.update['_props'] = self._props
    281283
    282284        MultiOpCon.__init__(self, sleft, sright,operator)
     
    432434       
    433435        if(source._invar.register(self,ivkey)):
     436            self._fields = source._fields
     437            self._actidx = source._actidx
    434438            self._rowChgProps(source)
     439            #store results
     440            self._invar.update['_fields'] = self._fields
     441            self._invar.update['_actidx'] = self._actidx
     442            self._invar.update['_props'] = self._props
    435443
    436444class SelectCon(MultiOpCon):
     
    450458           #apply col_constraint to currently active fields
    451459           self._actidx = source._actidx.dim1(col_constraint)
     460           self._actFieldChgProps(source)
     461
    452462           #store results
    453463           self._invar.update['_fields'] = self._fields
    454464           self._invar.update['_actidx'] = self._actidx
    455 
    456            self._actFieldChgProps(source)
     465           self._invar.update['_props'] = self._props
     466
    457467       
    458468        self._source = (source,col_constraint)
  • container/qg_rewrite.py

    r38 r49  
    229229            name = str(node.obj)
    230230
    231         self.graph.add_node(id(node),label=name)
     231        fieldnames = node.fields.name[node.actidx]
     232        lbl = "{" + name + "|{" + "|".join(fieldnames) + "}}".replace(" ","\ ")
     233        self.graph.add_node(id(node),shape="record",label=lbl,rankdir="LR")
    232234        for s in node.source:
    233235            s_id = self.visit(s)
     
    237239
    238240
     241
     242class FieldTransformPass(NodeVisitorFactory(),Pass):
     243   
     244    @classmethod
     245    def run(cls,query):
     246        self = cls(query.params)
     247
     248    def visitnode(self,node,used_fields):
     249       
     250
     251        pass
     252
     253
     254
     255
     256
     257
    239258pe = PassManager()
    240259pe.register(DrawNodeTreeVisitor)
  • src/qgraph.c

    r38 r49  
    2020    PyObject * actidx;
    2121    PyObject * props;
     22
     23    PyObject * in_trans;
     24    PyObject * out_trans;
     25    PyObject * out_fieldnr;
    2226} Node;
    2327
     
    3236    Py_XDECREF(self->actidx);
    3337    Py_XDECREF(self->props);
     38   
     39    Py_XDECREF(self->in_trans);
     40    Py_XDECREF(self->out_trans);
     41    Py_XDECREF(self->out_fieldnr);
    3442    self->ob_type->tp_free((PyObject*)self);
    3543}
     
    195203Node_getProps(Node *self, void *closure)
    196204{
    197     if(!self->actidx)
     205    if(!self->props)
    198206    {
    199207        Py_INCREF(Py_None);
     
    210218    Py_INCREF(value);
    211219    self->props = value;
     220    Py_XDECREF(tmp);
     221    return 0;
     222}
     223
     224
     225static PyObject *
     226Node_getInTrans(Node *self, void *closure)
     227{
     228    if(!self->in_trans)
     229    {
     230        Py_INCREF(Py_None);
     231        self->in_trans = Py_None;
     232    }
     233    Py_INCREF(self->in_trans);
     234    return self->in_trans;
     235}
     236static int
     237Node_setInTrans(Node *self, PyObject *value, void *closure)
     238{
     239    PyObject *tmp;
     240    tmp = self->in_trans;
     241    Py_INCREF(value);
     242    self->in_trans = value;
     243    Py_XDECREF(tmp);
     244    return 0;
     245}
     246static PyObject *
     247Node_getOutTrans(Node *self, void *closure)
     248{
     249    if(!self->out_trans)
     250    {
     251        Py_INCREF(Py_None);
     252        self->out_trans = Py_None;
     253    }
     254    Py_INCREF(self->out_trans);
     255    return self->out_trans;
     256}
     257static int
     258Node_setOutTrans(Node *self, PyObject *value, void *closure)
     259{
     260    PyObject *tmp;
     261    tmp = self->out_trans;
     262    Py_INCREF(value);
     263    self->out_trans = value;
     264    Py_XDECREF(tmp);
     265    return 0;
     266}
     267static PyObject *
     268Node_getOutFieldNr(Node *self, void *closure)
     269{
     270    if(!self->out_fieldnr)
     271    {
     272        Py_INCREF(Py_None);
     273        self->out_fieldnr = Py_None;
     274    }
     275    Py_INCREF(self->out_fieldnr);
     276    return self->out_fieldnr;
     277}
     278static int
     279Node_setOutFieldNr(Node *self, PyObject *value, void *closure)
     280{
     281    PyObject *tmp;
     282    tmp = self->out_fieldnr;
     283    Py_INCREF(value);
     284    self->out_fieldnr = value;
    212285    Py_XDECREF(tmp);
    213286    return 0;
     
    238311     (getter)Node_getActIdx, (setter)Node_setActIdx,
    239312     "Active field indexes",
     313     NULL},
     314    {"in_trans",
     315     (getter)Node_getInTrans, (setter)Node_setInTrans,
     316     "In field transformation",
     317     NULL},
     318    {"out_trans",
     319     (getter)Node_getOutTrans, (setter)Node_setOutTrans,
     320     "Out field transformation",
     321     NULL},
     322    {"out_fieldnr",
     323     (getter)Node_getOutFieldNr, (setter)Node_setOutFieldNr,
     324     "Out field nr.",
    240325     NULL},
    241326    {NULL}  /* Sentinel */
Note: See TracChangeset for help on using the changeset viewer.