Exemplo n.º 1
0
    def __init__(self, slices):
        assert len(set([slice.dims for slice in slices])) == 1, "Group index slices should have same dimension"
        assert all([isinstance(slice.type,rtypes.TypeArray) for slice in slices]), "Group index slices should be arrays"
        ndims = slices[0].dims
         
        newdims = []
        dep = (True,) * len(ndims)
        for pos, slice in enumerate(slices):
            xdep = (False,) * pos + dep
            newdims.append(dimensions.Dim(UNDEFINED,dependent=xdep,name="g" + slice.name))

        sdim = dimensions.Dim(UNDEFINED,(True,) * (len(ndims) + len(newdims)),name="g" + slices[0].type.dims[0].name)
        stype = rtypes.TypeInt64()
        rtype = dimpaths.dimsToArrays(dimpaths.DimPath(sdim), stype)
        rtype = dimpaths.dimsToArrays(dimpaths.DimPath(*newdims), rtype)
        MultiUnaryOp.__init__(self,slices, name="groupindex", rtype=rtype, dims=ndims)#}}}
Exemplo n.º 2
0
 def __init__(self, pslice, ndim=1):
     assert len(pslice.dims) >= ndim, "Op does not have enough dimensions to pack as " + str(ndim) + "-dimensional array"
     
     dims = pslice.dims[-ndim:]
     self.pack_dims = dims
     ntype = dimpaths.dimsToArrays(dims,pslice.type)
     UnaryUnaryOp.__init__(self, pslice, rtype=ntype, dims=pslice.dims[:-ndim])#}}}
Exemplo n.º 3
0
    def __init__(self,slice,constraint, ndim,refconstraint=None):
        if refconstraint is None:
            refconstraint = constraint

        stype = slice.type
        assert isinstance(stype, rtypes.TypeArray), "Filter on non-array type not possible"
        
        if(isinstance(constraint.type,rtypes.TypeArray)):
            has_missing = constraint.type.subtypes[0].has_missing
        else:
            has_missing = constraint.type.has_missing
        self.has_missing = has_missing            

        sdims = stype.dims
        if(ndim is None):
            sdims, subtype = sdims.removeDim(0, refconstraint, stype.subtypes[0], sdims[0].has_missing)
        else:
            sdims, subtype = sdims.updateDim(0, ndim, stype.subtypes[0])
        
        
        if(sdims):
            ntype = dimpaths.dimsToArrays(sdims, subtype)
        else:
            ntype = subtype
        
        if(has_missing):
            ntype = ntype.setHasMissing(True)
            if not subtype.hasMissingValInfo():
                slice = DetectFixedShapesOp(slice)
      
        self.constraint = constraint
        UnaryUnaryOp.__init__(self, slice, rtype=ntype)#}}}
Exemplo n.º 4
0
    def __init__(self, slices, field="data"):
        assert len(slices) == 2, "Index dict op should have two slices"
        assert slices[0].dims == slices[1].dims, "Key and value of dict should have same dimension"

        slices = [PackArrayOp(slice) for slice in slices]
        ndims = dimpaths.DimPath(dimensions.Dim(UNDEFINED, (), name="dict"))
        subtypes = [dimpaths.dimsToArrays(ndims, slice.type.subtypes[0]) for slice in slices]
        
        fieldnames = [slice.name for slice in slices]
        ntype = self.ocls(False, tuple(subtypes), tuple(fieldnames))
        nbookmarks = reduce(set.union,[slice.bookmarks for slice in slices])
        MultiUnaryOp.__init__(self, slices, name=field, rtype=ntype, dims=slices[0].dims, bookmarks=nbookmarks)#}}}