File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -262,10 +262,18 @@ def _union(*types: str) -> str:
262
262
263
263
def _join (* types : str ) -> str :
264
264
"""Find the common base type, i.e. union + upcast."""
265
+ if len (types ) == 1 :
266
+ return types [0 ]
267
+
265
268
numbers , other = __group_types (* types )
266
269
if other and numbers :
267
270
raise NotImplementedError (f"join of non-number types: { types } " )
268
271
272
+ if len (types ) == len (numbers ) == 2 and not other :
273
+ # union two types if they're different kinds, e.g. `np.int8 | np.uint8` instead
274
+ # of `np.integer`
275
+ return " | " .join (kind_types [0 ] for kind_types in numbers .values ())
276
+
269
277
# special case for accidental `bool` return from `timedelta64.__eq__` on numpy <2.3
270
278
if not numbers and len (other ) == 2 and set (other ) == {f"{ NP } .bool" , "bool" }:
271
279
return f"{ NP } .bool"
You can’t perform that action at this time.
0 commit comments