concatenate() with better dtype promotion rules.
(arrays, axis=0)
| 443 | |
| 444 | |
| 445 | def concatenate(arrays, axis=0): |
| 446 | """concatenate() with better dtype promotion rules.""" |
| 447 | # TODO: `concat` is the xp compliant name, but fallback to concatenate for |
| 448 | # older numpy and for cupy |
| 449 | xp = get_array_namespace(*arrays) |
| 450 | if hasattr(xp, "concat"): |
| 451 | return xp.concat(as_shared_dtype(arrays, xp=xp), axis=axis) |
| 452 | else: |
| 453 | return xp.concatenate(as_shared_dtype(arrays, xp=xp), axis=axis) |
| 454 | |
| 455 | |
| 456 | def stack(arrays, axis=0): |
searching dependent graphs…