@@ -399,10 +399,23 @@ def assign_property(self, key, value):
399
399
return self
400
400
401
401
def obtain_property (self , key ):
402
+ r"""Returns a list with the values of all the graphs defined for the string property name `key`. If none of
403
+ the graphs in the list have this property, returns None.
404
+
405
+ Args:
406
+ key (str): The string name of the property to be retrieved for all the graphs contained in this list
407
+ """
408
+ # "_list" is a list of GraphNumpyContainers, which means "prop_list" here will be a list of all the property
409
+ # values for teach of the graphs which make up this list.
402
410
prop_list = [x .obtain_property (key ) for x in self ._list ]
411
+
412
+ # If a certain string property is not set for a GraphNumpyContainer, it will still return None. Here we check:
413
+ # If all the items for our given property name are None then we know that this property is generally not
414
+ # defined for any of the graphs in the list.
403
415
if all ([x is None for x in prop_list ]):
404
416
self .logger .warning ("Property %s is not set on any graph." % key )
405
417
return None
418
+
406
419
return prop_list
407
420
408
421
def __setattr__ (self , key , value ):
@@ -494,6 +507,14 @@ def map_list(self, fun, **kwargs):
494
507
return self
495
508
496
509
def clean (self , inputs : list ):
510
+ """Given a list of property names, this method removes all elements from the internal list of
511
+ GraphNumpyContainers, which do not define at least one of those properties. Aka only those graphs remain in
512
+ the list which definitely define all of the properties.
513
+
514
+ Args:
515
+ inputs (list): A list of strings, where each string is supposed to be a property name, which the graphs
516
+ in this list may possess.
517
+ """
497
518
invalid_graphs = []
498
519
for item in inputs :
499
520
if isinstance (item , dict ):
0 commit comments