|
| 1 | +# type-tests for `sem` from `stats/_stats_py.pyi` |
| 2 | + |
| 3 | +from typing import assert_type |
| 4 | + |
| 5 | +import numpy as np |
| 6 | +import optype.numpy as onp |
| 7 | +import optype.numpy.compat as npc |
| 8 | + |
| 9 | +from scipy.stats import sem |
| 10 | + |
| 11 | +py_i_1d: list[int] |
| 12 | +py_i_2d: list[list[int]] |
| 13 | + |
| 14 | +py_f_1d: list[float] |
| 15 | +py_f_2d: list[list[float]] |
| 16 | + |
| 17 | +bool_1d: onp.Array1D[np.bool_] |
| 18 | +bool_2d: onp.Array2D[np.bool_] |
| 19 | + |
| 20 | +i16_1d: onp.Array1D[np.int16] |
| 21 | +i16_2d: onp.Array2D[np.int16] |
| 22 | + |
| 23 | +f32_1d: onp.Array1D[np.float32] |
| 24 | +f32_2d: onp.Array2D[np.float32] |
| 25 | + |
| 26 | +f64_1d: onp.Array1D[np.float64] |
| 27 | +f64_2d: onp.Array2D[np.float64] |
| 28 | + |
| 29 | +c64_1d: onp.Array1D[np.complex64] |
| 30 | +c64_2d: onp.Array2D[np.complex64] |
| 31 | + |
| 32 | +c128_1d: onp.Array1D[np.complex128] |
| 33 | +c128_2d: onp.Array2D[np.complex128] |
| 34 | + |
| 35 | +### |
| 36 | + |
| 37 | +assert_type(sem(py_i_1d), np.float64) |
| 38 | +assert_type(sem(py_f_1d), np.float64) |
| 39 | +assert_type(sem(bool_1d), np.float64) |
| 40 | +assert_type(sem(i16_1d), np.float64) |
| 41 | +assert_type(sem(f32_1d), npc.floating) |
| 42 | +assert_type(sem(f64_1d), np.float64) |
| 43 | +assert_type(sem(c64_1d), npc.floating) |
| 44 | +assert_type(sem(c128_1d), np.float64) |
| 45 | + |
| 46 | +assert_type(sem(py_i_2d), onp.ArrayND[np.float64]) |
| 47 | +assert_type(sem(py_f_2d), onp.ArrayND[np.float64]) |
| 48 | +assert_type(sem(bool_2d), onp.ArrayND[np.float64]) |
| 49 | +assert_type(sem(i16_2d), onp.ArrayND[np.float64]) |
| 50 | +assert_type(sem(f32_2d), onp.ArrayND[npc.floating]) |
| 51 | +assert_type(sem(f64_2d), onp.ArrayND[np.float64]) |
| 52 | +assert_type(sem(c64_2d), onp.ArrayND[npc.floating]) |
| 53 | +assert_type(sem(c128_2d), onp.ArrayND[np.float64]) |
| 54 | + |
| 55 | +assert_type(sem(py_i_1d, axis=None), np.float64) |
| 56 | +assert_type(sem(py_f_1d, axis=None), np.float64) |
| 57 | +assert_type(sem(bool_1d, axis=None), np.float64) |
| 58 | +assert_type(sem(i16_1d, axis=None), np.float64) |
| 59 | +assert_type(sem(f32_1d, axis=None), npc.floating) |
| 60 | +assert_type(sem(f64_1d, axis=None), np.float64) |
| 61 | +assert_type(sem(c64_1d, axis=None), npc.floating) |
| 62 | +assert_type(sem(c128_1d, axis=None), np.float64) |
| 63 | + |
| 64 | +assert_type(sem(py_i_2d, axis=None), np.float64) |
| 65 | +assert_type(sem(py_f_2d, axis=None), np.float64) |
| 66 | +assert_type(sem(bool_2d, axis=None), np.float64) |
| 67 | +assert_type(sem(i16_2d, axis=None), np.float64) |
| 68 | +assert_type(sem(f32_2d, axis=None), npc.floating) |
| 69 | +assert_type(sem(f64_2d, axis=None), np.float64) |
| 70 | +assert_type(sem(c64_2d, axis=None), npc.floating) |
| 71 | +assert_type(sem(c128_2d, axis=None), np.float64) |
| 72 | + |
| 73 | +assert_type(sem(py_i_1d, keepdims=True), onp.ArrayND[np.float64]) |
| 74 | +assert_type(sem(py_f_1d, keepdims=True), onp.ArrayND[np.float64]) |
| 75 | +assert_type(sem(bool_1d, keepdims=True), onp.ArrayND[np.float64]) |
| 76 | +assert_type(sem(i16_1d, keepdims=True), onp.ArrayND[np.float64]) |
| 77 | +assert_type(sem(f32_1d, keepdims=True), onp.ArrayND[npc.floating]) |
| 78 | +assert_type(sem(f64_1d, keepdims=True), onp.ArrayND[np.float64]) |
| 79 | +assert_type(sem(c64_1d, keepdims=True), onp.ArrayND[npc.floating]) |
| 80 | +assert_type(sem(c128_1d, keepdims=True), onp.ArrayND[np.float64]) |
| 81 | + |
| 82 | +assert_type(sem(py_i_2d, keepdims=True), onp.ArrayND[np.float64]) |
| 83 | +assert_type(sem(py_f_2d, keepdims=True), onp.ArrayND[np.float64]) |
| 84 | +assert_type(sem(bool_2d, keepdims=True), onp.ArrayND[np.float64]) |
| 85 | +assert_type(sem(i16_2d, keepdims=True), onp.ArrayND[np.float64]) |
| 86 | +assert_type(sem(f32_2d, keepdims=True), onp.ArrayND[npc.floating]) |
| 87 | +assert_type(sem(f64_2d, keepdims=True), onp.ArrayND[np.float64]) |
| 88 | +assert_type(sem(c64_2d, keepdims=True), onp.ArrayND[npc.floating]) |
| 89 | +assert_type(sem(c128_2d, keepdims=True), onp.ArrayND[np.float64]) |
0 commit comments