|
| 1 | +# type-tests for `scipy.stats.chi2_contingency` top-level export |
| 2 | + |
| 3 | +from typing import assert_type |
| 4 | + |
| 5 | +import numpy as np |
| 6 | +import optype.numpy as onp |
| 7 | + |
| 8 | +from scipy.stats import chi2_contingency |
| 9 | +from scipy.stats.contingency import Chi2ContingencyResult |
| 10 | + |
| 11 | +### |
| 12 | + |
| 13 | +_f32_2d: onp.Array2D[np.float32] |
| 14 | +_f64_2d: onp.Array2D[np.float64] |
| 15 | +_f64_3d: onp.Array3D[np.float64] |
| 16 | +_f64_nd: onp.ArrayND[np.float64] |
| 17 | + |
| 18 | +### |
| 19 | + |
| 20 | +assert_type(chi2_contingency(_f32_2d, correction=False), Chi2ContingencyResult[tuple[int, int]]) |
| 21 | +assert_type(chi2_contingency(_f64_2d, correction=False), Chi2ContingencyResult[tuple[int, int]]) |
| 22 | +assert_type(chi2_contingency(_f64_3d, correction=False), Chi2ContingencyResult[tuple[int, int, int]]) |
| 23 | +assert_type(chi2_contingency(_f64_nd, correction=False), Chi2ContingencyResult) |
| 24 | +assert_type(chi2_contingency(_f64_2d), Chi2ContingencyResult[tuple[int, int]]) |
| 25 | +assert_type(chi2_contingency(_f64_2d, lambda_="log-likelihood"), Chi2ContingencyResult[tuple[int, int]]) |
| 26 | + |
| 27 | +### |
| 28 | + |
| 29 | +res = chi2_contingency(_f64_2d) |
| 30 | +assert_type(res.statistic, np.float64) |
| 31 | +assert_type(res.pvalue, np.float64) |
| 32 | +assert_type(res.dof, int) |
| 33 | +assert_type(res.expected_freq, onp.Array2D[np.float64]) |
0 commit comments