Helper to check that the loop types are ordered. The legacy type resolver (and potentially downstream) may pick use the first loop to which operands can be cast safely.
(types1, types2)
| 93 | |
| 94 | |
| 95 | def _check_order(types1, types2): |
| 96 | """ |
| 97 | Helper to check that the loop types are ordered. The legacy type resolver |
| 98 | (and potentially downstream) may pick use the first loop to which operands |
| 99 | can be cast safely. |
| 100 | """ |
| 101 | # Insert kK (int64) after all other ints (assumes long long isn't larger) |
| 102 | dtype_order = bints + 'kK' + times + flts + cmplxP + "O" |
| 103 | for t1, t2 in zip(types1, types2): |
| 104 | # We have no opinion on object or time ordering for now: |
| 105 | if t1 in "OP" or t2 in "OP": |
| 106 | return True |
| 107 | if t1 in "mM" or t2 in "mM": |
| 108 | return True |
| 109 | |
| 110 | t1i = dtype_order.index(t1) |
| 111 | t2i = dtype_order.index(t2) |
| 112 | if t1i < t2i: |
| 113 | return |
| 114 | if t2i > t1i: |
| 115 | break |
| 116 | |
| 117 | if types1 == "QQ?" and types2 == "qQ?": |
| 118 | # Explicitly allow this mixed case, rather than figure out what order |
| 119 | # is nicer or how to encode it. |
| 120 | return |
| 121 | |
| 122 | raise TypeError( |
| 123 | f"Input dtypes are unsorted or duplicate: {types1} and {types2}") |
| 124 | |
| 125 | |
| 126 | def check_td_order(tds): |
no test coverage detected
searching dependent graphs…