argiope/mesh.py
def split(self, into = "edges", loc = None, 
            at = "labels", sort_index = True):
    """
    Returns the decomposition of the elements.
    
    Inputs:
    * into: must be in ['edges', 'faces', 'simplices', 'angles']
    * loc: None or labels of the chosen elements.
    * at: must be in ['labels', 'coords']
    """
    if type(loc) == type(None):
      elements = self.elements
    else:  
      elements = self.elements.loc[loc]
    out = []
    for etype, group in elements.groupby([("type", "argiope", "")]):
      try:
        output_maps = getattr(ELEMENTS[etype], into)
        for om in range(len(output_maps)):
          oshape = len(output_maps[om])
          conn = group.conn
          columns = pd.MultiIndex.from_product([(om,), np.arange(oshape)], 
                                                names = [into, "vertex"])
          data = (conn.values[:, output_maps[om]].reshape(len(conn), oshape))
          df = pd.DataFrame(data = data, 
                            columns = columns,
                            index = conn.index).stack((0,1))
          out.append(df)
      except:
        print("Can not extract '{0}' from '{1}'".format(into, etype))                           
    if len(out) != 0:
      out = pd.concat(out)
      out.sort_index(inplace = True)
      if at == "coords":
        data = self.nodes.coords.loc[out.values].values
        out = pd.DataFrame(index = out.index, data = data, 
                           columns = ["x", "y", "z"])
      return out
def split(self, into = "edges", loc = None, 
            at = "labels", sort_index = True):
    """
    Returns the decomposition of the elements.
    
    Inputs:
    * into: must be in ['edges', 'faces', 'simplices', 'angles']
    * loc: None or labels of the chosen elements.
    * at: must be in ['labels', 'coords']
    """
    if type(loc) == type(None):
      elements = self.elements
    else:  
      elements = self.elements.loc[loc]
    out = []
    for etype, group in elements.groupby([("type", "argiope", "")]):
      try:
        output_maps = getattr(ELEMENTS[etype], into)
        for om in range(len(output_maps)):
          oshape = len(output_maps[om])
          conn = group.conn
          columns = pd.MultiIndex.from_product([(om,), np.arange(oshape)], 
                                                names = [into, "vertex"])
          data = (conn.values[:, output_maps[om]].reshape(len(conn), oshape))
          df = pd.DataFrame(data = data, 
                            columns = columns,
                            index = conn.index).stack((0,1))
          out.append(df)
      except:
        print("Can not extract '{0}' from '{1}'".format(into, etype))                           
    if len(out) != 0:
      out = pd.concat(out)
      out.sort_index(inplace = True)
      if at == "coords":
        data = self.nodes.coords.loc[out.values].values
        out = pd.DataFrame(index = out.index, data = data, 
                           columns = ["x", "y", "z"])
      return out
def split ( self , into = "edges" , loc = None , at = "labels" , sort_index = True ) : if type ( loc ) == type ( None ) : elements = self . elements else : elements = self . elements . loc [ loc ] out = [ ] for etype , group in elements . groupby ( [ ( "type" , "argiope" , "" ) ] ) : try : output_maps = getattr ( ELEMENTS [ etype ] , into ) for om in range ( len ( output_maps ) ) : oshape = len ( output_maps [ om ] ) conn = group . conn columns = pd . MultiIndex . from_product ( [ ( om , ) , np . arange ( oshape ) ] , names = [ into , "vertex" ] ) data = ( conn . values [ : , output_maps [ om ] ] . reshape ( len ( conn ) , oshape ) ) df = pd . DataFrame ( data = data , columns = columns , index = conn . index ) . stack ( ( 0 , 1 ) ) out . append ( df ) except : print ( "Can not extract '{0}' from '{1}'" . format ( into , etype ) ) if len ( out ) != 0 : out = pd . concat ( out ) out . sort_index ( inplace = True ) if at == "coords" : data = self . nodes . coords . loc [ out . values ] . values out = pd . DataFrame ( index = out . index , data = data , columns = [ "x" , "y" , "z" ] ) return out
Returns the decomposition of the elements.
    
    Inputs:
    * into: must be in ['edges', 'faces', 'simplices', 'angles']
    * loc: None or labels of the chosen elements.
    * at: must be in ['labels', 'coords']
Returns the decomposition of the elements . Inputs : * into : must be in [ edges faces simplices angles ] * loc : None or labels of the chosen elements . * at : must be in [ labels coords ]