attributes
Operator Attributes Utility API
This module provides utility functions for handling operator attributes.
Functions:
-
op_attributes_matches
–Check if an operator attribute rule matches a given operator type and identifier.
-
op_attributes_rule_specificity
–Compute the specificity of an operator attribute rule.
-
compute_operator_attributes
–Compute the operator attributes for a given operator type and identifier.
Copyright 2025 Ambiq. All Rights Reserved.
Classes
Functions
op_attributes_matches
Determine if an operator attribute rule matches a given operator type and identifier.
Parameters:
-
rule
OperatorAttributeRule
) –The operator attribute rule.
-
op_type
str
) –The operator type.
-
op_ident
int
) –The operator identifier.
Returns:
-
bool
(bool
) –True if the rule matches, False otherwise.
op_attributes_rule_specificity
Compute the specificity of an operator attribute rule. The specificity is determined by the presence of type and identifier.
Parameters:
-
rule
OperatorAttributeRule
) –The operator attribute rule.
Returns:
compute_operator_attributes
compute_operator_attributes(operatorAttributes: list[OperatorAttributeRule], op_type: str, op_ident: int) -> dict[str, Any]
Compute the operator attributes for a given operator type and identifier.
This function collects all matching rules, sorts them by specificity and index, and merges them into a final dictionary of attributes. The specificity is determined by the presence of type and identifier. The index is the order in which the rules were defined in the YAML file.
Parameters:
-
operatorAttributes
list[OperatorAttributeRule]
) –List of operator attribute rules.
-
op_type
str
) –The operator type.
-
op_ident
int
) –The operator identifier.
Returns: