Skip to content

attributes

Operator Attributes Utility API

This module provides utility functions for handling operator attributes.

Functions:

Copyright 2025 Ambiq. All Rights Reserved.

Classes

Functions

op_attributes_matches

op_attributes_matches(rule: OperatorAttributeRule, op_type: str, op_ident: int) -> bool

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

op_attributes_rule_specificity(rule: OperatorAttributeRule) -> tuple[int, int]

Compute the specificity of an operator attribute rule. The specificity is determined by the presence of type and identifier.

Parameters:

Returns:

  • tuple[int, int]

    tuple[int,int]: A tuple representing the specificity of the rule.

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:

  • dict[str, Any]

    dict[str, Any]: Merged dictionary of operator attributes.