|
| 1 | +from typing import Any, assert_type |
| 2 | + |
| 3 | +import numpy as np |
| 4 | +import numpy.typing as npt |
| 5 | + |
| 6 | +from scipy.sparse import coo_array |
| 7 | +from scipy.sparse.linalg import LinearOperator, expm_multiply |
| 8 | + |
| 9 | +_dense_i8_1d: np.ndarray[tuple[int], np.dtype[np.int8]] |
| 10 | +_dense_i8_2d: np.ndarray[tuple[int, int], np.dtype[np.int8]] |
| 11 | +_dense_i8_nd: npt.NDArray[np.int8] |
| 12 | + |
| 13 | +_dense_f32_1d: np.ndarray[tuple[int], np.dtype[np.float32]] |
| 14 | +_dense_f32_2d: np.ndarray[tuple[int, int], np.dtype[np.float32]] |
| 15 | +_dense_f32_nd: npt.NDArray[np.float32] |
| 16 | + |
| 17 | +_sparse_i8_1d: coo_array[np.int8, tuple[int]] |
| 18 | +_sparse_i8_2d: coo_array[np.int8, tuple[int, int]] |
| 19 | +_sparse_i8_nd: coo_array[np.int8] |
| 20 | + |
| 21 | +_sparse_f32_1d: coo_array[np.float32, tuple[int]] |
| 22 | +_sparse_f32_2d: coo_array[np.float32, tuple[int, int]] |
| 23 | +_sparse_f32_nd: coo_array[np.float32] |
| 24 | + |
| 25 | +_linop_i8: LinearOperator[np.int8] |
| 26 | +_linop_f32: LinearOperator[np.float32] |
| 27 | + |
| 28 | +# |
| 29 | + |
| 30 | +assert_type(expm_multiply(_dense_i8_2d, _dense_f32_1d), np.ndarray[tuple[int], np.dtype[np.float64]]) |
| 31 | +assert_type(expm_multiply(_dense_i8_2d, _dense_f32_2d), np.ndarray[tuple[int, int], np.dtype[np.float64]]) |
| 32 | +assert_type(expm_multiply(_dense_i8_2d, _dense_f32_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float64]]) |
| 33 | + |
| 34 | +assert_type(expm_multiply(_dense_i8_nd, _dense_f32_1d), np.ndarray[tuple[int], np.dtype[np.float64]]) |
| 35 | +assert_type(expm_multiply(_dense_i8_nd, _dense_f32_2d), np.ndarray[tuple[int, int], np.dtype[np.float64]]) |
| 36 | +assert_type(expm_multiply(_dense_i8_nd, _dense_f32_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float64]]) |
| 37 | + |
| 38 | +assert_type(expm_multiply(_sparse_i8_2d, _dense_f32_1d), np.ndarray[tuple[int], np.dtype[np.float64]]) |
| 39 | +assert_type(expm_multiply(_sparse_i8_2d, _dense_f32_2d), np.ndarray[tuple[int, int], np.dtype[np.float64]]) |
| 40 | +assert_type(expm_multiply(_sparse_i8_2d, _dense_f32_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float64]]) |
| 41 | + |
| 42 | +assert_type(expm_multiply(_linop_i8, _dense_f32_1d), np.ndarray[tuple[int], np.dtype[np.float64]]) |
| 43 | +assert_type(expm_multiply(_linop_i8, _dense_f32_2d), np.ndarray[tuple[int, int], np.dtype[np.float64]]) |
| 44 | +assert_type(expm_multiply(_linop_i8, _dense_f32_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float64]]) |
| 45 | + |
| 46 | +# |
| 47 | + |
| 48 | +assert_type(expm_multiply(_dense_i8_2d, _dense_i8_1d), np.ndarray[tuple[int], np.dtype[np.float64]]) |
| 49 | +assert_type(expm_multiply(_dense_i8_2d, _dense_i8_2d), np.ndarray[tuple[int, int], np.dtype[np.float64]]) |
| 50 | +assert_type(expm_multiply(_dense_i8_2d, _dense_i8_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float64]]) |
| 51 | + |
| 52 | +assert_type(expm_multiply(_dense_i8_nd, _dense_i8_1d), np.ndarray[tuple[int], np.dtype[np.float64]]) |
| 53 | +assert_type(expm_multiply(_dense_i8_nd, _dense_i8_2d), np.ndarray[tuple[int, int], np.dtype[np.float64]]) |
| 54 | +assert_type(expm_multiply(_dense_i8_nd, _dense_i8_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float64]]) |
| 55 | + |
| 56 | +assert_type(expm_multiply(_sparse_i8_2d, _dense_i8_1d), np.ndarray[tuple[int], np.dtype[np.float64]]) |
| 57 | +assert_type(expm_multiply(_sparse_i8_2d, _dense_i8_2d), np.ndarray[tuple[int, int], np.dtype[np.float64]]) |
| 58 | +assert_type(expm_multiply(_sparse_i8_2d, _dense_i8_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float64]]) |
| 59 | + |
| 60 | +assert_type(expm_multiply(_linop_i8, _dense_i8_1d), np.ndarray[tuple[int], np.dtype[np.float64]]) |
| 61 | +assert_type(expm_multiply(_linop_i8, _dense_i8_2d), np.ndarray[tuple[int, int], np.dtype[np.float64]]) |
| 62 | +assert_type(expm_multiply(_linop_i8, _dense_i8_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float64]]) |
| 63 | + |
| 64 | +# |
| 65 | + |
| 66 | +assert_type(expm_multiply(_dense_f32_2d, _dense_f32_1d), np.ndarray[tuple[int], np.dtype[np.float32]]) |
| 67 | +assert_type(expm_multiply(_dense_f32_2d, _dense_f32_2d), np.ndarray[tuple[int, int], np.dtype[np.float32]]) |
| 68 | +assert_type(expm_multiply(_dense_f32_2d, _dense_f32_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float32]]) |
| 69 | + |
| 70 | +assert_type(expm_multiply(_dense_f32_nd, _dense_f32_1d), np.ndarray[tuple[int], np.dtype[np.float32]]) |
| 71 | +assert_type(expm_multiply(_dense_f32_nd, _dense_f32_2d), np.ndarray[tuple[int, int], np.dtype[np.float32]]) |
| 72 | +assert_type(expm_multiply(_dense_f32_nd, _dense_f32_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float32]]) |
| 73 | + |
| 74 | +assert_type(expm_multiply(_sparse_f32_2d, _dense_f32_1d), np.ndarray[tuple[int], np.dtype[np.float32]]) |
| 75 | +assert_type(expm_multiply(_sparse_f32_2d, _dense_f32_2d), np.ndarray[tuple[int, int], np.dtype[np.float32]]) |
| 76 | +assert_type(expm_multiply(_sparse_f32_2d, _dense_f32_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float32]]) |
| 77 | + |
| 78 | +assert_type(expm_multiply(_linop_f32, _dense_f32_1d), np.ndarray[tuple[int], np.dtype[np.float32]]) |
| 79 | +assert_type(expm_multiply(_linop_f32, _dense_f32_2d), np.ndarray[tuple[int, int], np.dtype[np.float32]]) |
| 80 | +assert_type(expm_multiply(_linop_f32, _dense_f32_nd), np.ndarray[tuple[Any, ...], np.dtype[np.float32]]) |
0 commit comments