| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
from ._dispatcher import get_type |
| 4 |
|
| 5 |
__all__ = [ |
| 6 |
"check_arraytypes_compatible", |
| 7 |
] |
| 8 |
|
| 9 |
|
| 10 |
def check_arraytypes_compatible(*args): |
| 11 |
"""Check array types are compatible. |
| 12 |
|
| 13 |
For arrays to be compatible they must either have the same type, |
| 14 |
or a dask array where the chunks match the same array type. |
| 15 |
|
| 16 |
Examples of compatible arrays: |
| 17 |
* Two (or more) numpy arrays |
| 18 |
* A dask array with numpy chunks, and a numpy array |
| 19 |
|
| 20 |
Examples of incompatible arrays: |
| 21 |
* A numpy array and a cupy array |
| 22 |
""" |
| 23 |
arraytypes = [get_type(arg) for arg in args] |
| 24 |
if len(set(arraytypes)) != 1: |
| 25 |
raise ValueError("Array types must be compatible.") |