Parse label strings for all input operands. Parameters ---------- labelstr: The equation's label string operands: The input operands Returns ------- list of full label strings for all input operands
(labelstr: str, operands: Sequence[Tensor])
| 80 | |
| 81 | |
| 82 | def parse_labels(labelstr: str, operands: Sequence[Tensor]) -> list[str]: |
| 83 | ''' |
| 84 | Parse label strings for all input operands. |
| 85 | |
| 86 | Parameters |
| 87 | ---------- |
| 88 | labelstr: |
| 89 | The equation's label string |
| 90 | operands: |
| 91 | The input operands |
| 92 | |
| 93 | Returns |
| 94 | ------- |
| 95 | list of full label strings for all input operands |
| 96 | ''' |
| 97 | |
| 98 | nop_labels = labelstr.split(',') |
| 99 | assert len(nop_labels) == len(operands), ( |
| 100 | f"Invalid equation: the number of operands is {len(operands)}, " |
| 101 | f"but found {len(nop_labels)} segments in the label equation." |
| 102 | ) |
| 103 | |
| 104 | return list(map(parse_op_labels, nop_labels, operands)) |
| 105 | |
| 106 | |
| 107 | def validate_rhs( |
no test coverage detected