Esempio n. 1
0
    def EdgeAttributes(self, edges=None, attributes=None):
        if(isinstance(edges,representor.Representor)):
            edges = edges.ToPython()
        if(isinstance(attributes, representor.Representor)):
            attributes = attributes.ToPython()

        if edges is None:
            edges = self._server.getEdges(self._networkid)      

        xattributes = self.EdgeAttributeInfo()
        if attributes is None:
            attributes = xattributes
        else:   
            attributes = xattributes[_.name |In| attributes]

        columns = []
        fieldnames = []
        fieldtypes = []
        dimpath=dimpaths.DimPath(dimensions.Dim(shape=UNDEFINED,has_missing=False,dependent=(),name="edge_attributes"))
        for attribute, atype in attributes.Tuple()():
            atype = self._prepareType(atype)
            has_attribute = util.darray(self._server.edgesHaveAttribute(attribute,edges) ,bool)
            if False in has_attribute:
                atype.has_missing=True
                res = util.darray([Missing] * len(edges))
                fedges = list(util.darray(edges)[has_attribute])
                res[has_attribute] = self._server.getEdgesAttributes(attribute,fedges)
            else:
                res = self._server.getEdgesAttributes(attribute, edges)
            columns.append(res)
            fieldnames.append(util.valid_name(attribute))
            fieldtypes.append(rtypes.TypeArray(dims=dimpath,subtypes=(atype,)))
            
        dtype = rtypes.TypeTuple(fieldnames=tuple(fieldnames),subtypes=tuple(fieldtypes))
        return Rep(columns,dtype=dtype)
Esempio n. 2
0
 def setUp(self):
     nnmatrix = util.darray([[[[1,2],[3,4]],[[5,6],[7,9],[9,8]],[[8,9]]],[[[1,4]],[[2,5]]],[[[1,5],[4,7],[8,5]]]])
     self.data = util.darray([nnmatrix, nnmatrix, nnmatrix])
     self.transpose_couples = [((1,2,3,4,0),(4,0,1,2,3)),((1,0,2,3,4),(1,0,2,3,4)),((1,2,0,3,4),(2,0,1,3,4)),((1,2,3,0,4),(3,0,1,2,4))]
Esempio n. 3
0
 def setUp(self):
     self.data = util.darray([[[1,2],[3,4],[5,6]],[[4,5,6],[7,8,9]]])
     self.dtype=["[arr]<[var1:.]<[var2:*.]<int64"]
     self.fres0 = util.darray([[1,3,5],[4,7]])
     self.transpose_couples = [((0,2,1),(0,2,1))]
Esempio n. 4
0
 def setUp(self):
     self.data = util.darray([[[[1,2],[3,4]],[[5,6],[7,9],[9,8]],[[4,9]]],[[[1,4]],[[2,5]]],[[[1,5],[4,7],[8,5]]]])
     self.transpose_couples = [((0,1,3,2),(0,1,3,2)),((0,3,1,2),(0,2,3,1)),((3,0,1,2),(1,2,3,0))]
Esempio n. 5
0
 def setUp(self):
     self.data = util.darray([[[1,2],[2,3,3,3,4,5],[]],[[1],[2]],[[1,4,5]]])
     self.fres0 = util.darray([[1,2,[]],[1,2],[1]])
Esempio n. 6
0
 def setUp(self):
     self.data = util.darray([[["abc","abcd"],["def","defg"],["abg","fev"]],[["zeK","sdf"],["sdf","sdfff"]],[["sdf","kjl"]]])
     self.fres0 = util.darray([["abc","def","abg"],["zeK","sdf"],["sdf"]])
     self.transpose_couples = [((0,2,1),(0,2,1)),((2,0,1),(1,2,0))]
Esempio n. 7
0
 def setUp(self):
     self.data = util.darray([[[1,2],[2,4],[3,5]],[[1,3],[5,2]],[[1,2]]])
     self.fres0 = util.darray([[1,2,3],[1,5],[1]])
     self.transpose_couples = [((0,2,1),(0,2,1)),((2,0,1),(1,2,0))]
Esempio n. 8
0
 def setUp(self):
     self.data = util.darray([[1,2,3],[1,2],[1]])
     self.fres0 = util.darray([1,1,1])