Changeset 247


Ignore:
Timestamp:
Oct 30, 2009, 1:39:05 PM (11 years ago)
Author:
jjbot
Message:

Fieldnames are no longer renamed when doing things like unions and all the fieldnames are the same between the two containers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • container/itypes_py.py

    r202 r247  
    539539                        raise TypeError, "Containers with unequal number of fields > 1 cannot be operated on"
    540540                    else: #both are larger than 1
    541                         nr = [Field("result",binop_type(lfield.type,rfield.type,operator),sourceids=(lfield.id,rfield.id)) for lfield,rfield in zip(left,right)]
    542 
     541                        if left == right:
     542                            # If fieldnames are equal in both containers:
     543                            nr = [
     544                                    Field(
     545                                            lfield.name, binop_type(lfield.type, rfield.type, operator),
     546                                            sourceids=(lfield.id,rfield.id)
     547                                    )
     548                                    for lfield, rfield in zip(left, right)
     549                                 ]
     550                        else:
     551                            # Fieldnames are not equal in both containers:
     552                            comb = zip(left, right)
     553                            nr = []
     554                            for i in range(len(comb)):
     555                                lfield, rfield = comb[i]
     556                                nr.append(
     557                                    Field("result_" + str(i), binop_type(lfield.type, rfield.type, operator),
     558                                            sourceids=(lfield.id, rfield.id))
     559                                )
     560                            #nr = [Field("result",binop_type(lfield.type,rfield.type,operator),sourceids=(lfield.id,rfield.id)) for lfield,rfield in zip(left,right)]
    543561        return nr
    544562
Note: See TracChangeset for help on using the changeset viewer.