MCPcopy
hub / github.com/numpy/numpy / _check_order

Function _check_order

numpy/_core/code_generators/generate_umath.py:95–123  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

93
94
95def _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
126def check_td_order(tds):

Callers 1

check_td_orderFunction · 0.85

Calls 1

indexMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…