@@ -161,6 +161,7 @@ def data(self, data):
161161 dfa = data .get ('dfa' ) or {}
162162 dca = data .get ('dca' ) or {}
163163 vertex = data .get ('vertex' ) or {}
164+ halfface = data .get ('halfface' ) or {}
164165 cell = data .get ('cell' ) or {}
165166 edge_data = data .get ('edge_data' ) or {}
166167 face_data = data .get ('face_data' ) or {}
@@ -190,12 +191,17 @@ def data(self, data):
190191 attr = vertex [v ] or {}
191192 self .add_vertex (int (v ), attr_dict = attr )
192193
194+ for f in halfface :
195+ attr = face_data .get (f ) or {}
196+ self .add_halfface (halfface [f ], fkey = int (f ), attr_dict = attr )
197+
193198 for c in cell :
194199 attr = cell_data .get (c ) or {}
195200 faces = []
196201 for u in cell [c ]:
197202 for v in cell [c ][u ]:
198- faces .append (cell [c ][u ][v ])
203+ f = cell [c ][u ][v ]
204+ faces .append (halfface [str (f )])
199205 self .add_cell (faces , ckey = int (c ), attr_dict = attr )
200206
201207 for e in edge_data :
@@ -268,28 +274,34 @@ def get_any_face_vertex(self, face):
268274 """
269275 return choice (self .halfface_vertices (face ))
270276
271- def vertex_index (self ):
277+ def key_index (self ):
272278 """Returns a dictionary that maps vertex dictionary keys to the
273279 corresponding index in a vertex list or array.
274280
275281 Returns
276282 -------
277283 dict
278- A dictionary of vertex-index pairs.
284+ A dictionary of key-index pairs.
285+
279286 """
280- return {vertex : index for index , vertex in enumerate (self .vertices ())}
287+ return {key : index for index , key in enumerate (self .vertices ())}
288+
289+ vertex_index = key_index
281290
282- def index_vertex (self ):
291+ def index_key (self ):
283292 """Returns a dictionary that maps the indices of a vertex list to
284- keys in the vertex dictionary.
293+ keys in a vertex dictionary.
285294
286295 Returns
287296 -------
288297 dict
289- A dictionary of index-vertex pairs.
298+ A dictionary of index-key pairs.
299+
290300 """
291301 return dict (enumerate (self .vertices ()))
292302
303+ index_vertex = index_key
304+
293305 # --------------------------------------------------------------------------
294306 # builders
295307 # --------------------------------------------------------------------------
@@ -748,7 +760,8 @@ def vertices_where_predicate(self, predicate, data=False):
748760 Parameters
749761 ----------
750762 predicate : callable
751- The condition you want to evaluate. The callable takes 2 parameters: ``key``, ``attr`` and should return ``True`` or ``False``.
763+ The condition you want to evaluate. The callable takes 2 parameters:
764+ ``key``, ``attr`` and should return ``True`` or ``False``.
752765 data : bool, optional
753766 Yield the vertices and their data attributes.
754767 Default is ``False``.
@@ -833,7 +846,8 @@ def edges_where_predicate(self, predicate, data=False):
833846 Parameters
834847 ----------
835848 predicate : callable
836- The condition you want to evaluate. The callable takes 3 parameters: ``u``, ``v``, ``attr`` and should return ``True`` or ``False``.
849+ The condition you want to evaluate. The callable takes 3 parameters:
850+ ``u``, ``v``, ``attr`` and should return ``True`` or ``False``.
837851 data : bool, optional
838852 Yield the vertices and their data attributes.
839853 Default is ``False``.
@@ -919,7 +933,8 @@ def faces_where_predicate(self, predicate, data=False):
919933 Parameters
920934 ----------
921935 predicate : callable
922- The condition you want to evaluate. The callable takes 2 parameters: ``key``, ``attr`` and should return ``True`` or ``False``.
936+ The condition you want to evaluate. The callable takes 2 parameters:
937+ ``key``, ``attr`` and should return ``True`` or ``False``.
923938 data : bool, optional
924939 Yield the faces and their data attributes.
925940 Default is ``False``.
@@ -1005,7 +1020,8 @@ def cells_where_predicate(self, predicate, data=False):
10051020 Parameters
10061021 ----------
10071022 predicate : callable
1008- The condition you want to evaluate. The callable takes 2 parameters: ``key``, ``attr`` and should return ``True`` or ``False``.
1023+ The condition you want to evaluate. The callable takes 2 parameters:
1024+ ``key``, ``attr`` and should return ``True`` or ``False``.
10091025 data : bool, optional
10101026 Yield the cells and their data attributes.
10111027 Default is ``False``.
@@ -1352,7 +1368,9 @@ def edge_attributes(self, edge, names=None, values=None):
13521368 self ._edge_data [key ][name ] = value
13531369 return
13541370 if not names :
1355- return EdgeAttributeView (self .default_edge_attributes , self ._edge_data , key )
1371+ key = str (tuple (sorted (edge )))
1372+ return EdgeAttributeView (self .default_edge_attributes ,
1373+ self ._edge_data .setdefault (key , {}))
13561374 values = []
13571375 for name in names :
13581376 value = self .edge_attribute (edge , name )
@@ -1547,7 +1565,8 @@ def face_attributes(self, face, names=None, values=None):
15471565 self ._face_data [key ][name ] = value
15481566 return
15491567 if not names :
1550- return FaceAttributeView (self .default_face_attributes , self ._face_data , key )
1568+ return FaceAttributeView (self .default_face_attributes ,
1569+ self ._face_data .setdefault (key , {}))
15511570 values = []
15521571 for name in names :
15531572 value = self .face_attribute (face , name )
0 commit comments