This class provides utility methods for split lists of pdg.WorkItem instances based on attribute values.
Methods ¶
Static methods ¶
batchByFrame(work_items)
→ tuple
Splits the work items in the input list into batches consisting of increasing frame ranges. Returns a list of lists of work items in each batch, as well as a separate list of work items that have no frame assigned.
For example, given input work items with the frame values [1, 1, 1, 2, 2, 2, 3, 3, 4]
, the following output would be produced:
`
[
]
`
splitByAttribute(work_items, attrib_names, partial_matches=False)
→ tuple
Splits the work items in the input list by the specified attribute name(s). Returns a map of attribute values to the list of work items that have that value, as well as the list of work items that are missing the attribute and the list of unique values. The unique value list is sorted in ascending order of value.
The values for attrib_name
on the work items do not all have to be the same type. All attribute values are converted to strings. Multiple attribute names can be passed in as a space-separate string. When multiple names are passed into the function, the attribute values are treated as a tuple instead of as a single value.
When multiple attribute names are specified, the partial_matches
flag indicates that work items with only some of the attributes should be still be added to partially matching map entries.
For example:
attribute = "wedgeindex" (value_map, missing, unique) = pdg.AttributePattern.splitByAttribute(node.work_items, attribute) print("Attribute {} has {} unique values".format(attribute, len(unique))) for work_item in missing: print("Work Item {} is missing attrib {}".format(attribute)) for entry in value_map: print("{} work items have value {}".format(len(value_map[entry]), entry))
splitByFloat(work_items, attrib_name)
→ tuple
Splits the input work items by the specified float attribute name.
This function is the same as splitByAttribute
, but it will not convert attribute values to strings. Work items that have an attribute with the specified name, but a different type, will be considered as missing the attribute.
splitByInt(work_items, attrib_name)
→ tuple
Splits the input work items by the specified integer attribute name.
This function is the same as splitByAttribute
, but it will not convert attribute values to strings. Work items that have an attribute with the specified name, but a different type, will be considered as missing the attribute.
splitByString(work_items, attrib_name)
→ tuple
Splits the input work items by the specified integer attribute name.
This function is the same as splitByAttribute
, but it will not convert attribute values to strings. Work items that have an attribute with the specified name, but a different type, will be considered as missing the attribute.