@@ -67,9 +67,7 @@ def __init__(
6767 # atom_properties and bond_properties are given as lists containing class_paths
6868 if properties is not None :
6969 properties = [resolve_property (prop ) for prop in properties ]
70- properties = sorted (
71- properties , key = lambda prop : self .get_property_path (prop )
72- )
70+ properties = self ._sort_properties (properties )
7371 else :
7472 properties = []
7573 self .properties = properties
@@ -78,6 +76,11 @@ def __init__(
7876 )
7977 self .transform = transform
8078
79+ def _sort_properties (
80+ self , properties : list [MolecularProperty ]
81+ ) -> list [MolecularProperty ]:
82+ return sorted (properties , key = lambda prop : self .get_property_path (prop ))
83+
8184 def _setup_properties (self ) -> None :
8285 """
8386 Process and cache molecular properties to disk.
@@ -301,14 +304,16 @@ class GraphPropAsPerNodeType(DataPropertiesSetter, ABC):
301304 def __init__ (self , properties = None , transform = None , ** kwargs ):
302305 super ().__init__ (properties , transform , ** kwargs )
303306 # Sort properties so that AllNodeTypeProperty instances come first, rest of the properties order remain same
304- first = [
305- prop for prop in self .properties if isinstance (prop , AllNodeTypeProperty )
306- ]
307- rest = [
308- prop
309- for prop in self .properties
310- if not isinstance (prop , AllNodeTypeProperty )
311- ]
307+ first = self ._sort_properties (
308+ [prop for prop in self .properties if isinstance (prop , AllNodeTypeProperty )]
309+ )
310+ rest = self ._sort_properties (
311+ [
312+ prop
313+ for prop in self .properties
314+ if not isinstance (prop , AllNodeTypeProperty )
315+ ]
316+ )
312317 self .properties = first + rest
313318 print (
314319 "Properties are sorted so that `AllNodeTypeProperty` properties are first in sequence and rest of the order remains same\n " ,
0 commit comments