|
| 1 | +# defined in scipy/stats/_stats.pyx |
| 2 | + |
| 3 | +from collections.abc import Callable |
| 4 | +from typing import Final, Literal, TypeAlias, TypedDict, overload, type_check_only |
| 5 | +from typing_extensions import CapsuleType, ReadOnly |
| 6 | + |
| 7 | +import numpy as np |
| 8 | +import optype.numpy as onp |
| 9 | +import optype.numpy.compat as npc |
| 10 | + |
| 11 | +### |
| 12 | + |
| 13 | +# matches the `ctypedef fused ordered` |
| 14 | +_Ordered: TypeAlias = np.int32 | np.int64 | np.float32 | np.float64 |
| 15 | + |
| 16 | +# matches the `ctypedef fused real` |
| 17 | +_Real: TypeAlias = np.float32 | np.float64 | np.longdouble |
| 18 | + |
| 19 | +# castable to `_Real` |
| 20 | +_AsReal: TypeAlias = npc.floating | npc.integer | np.bool_ |
| 21 | + |
| 22 | +# castable to a real distance matrix |
| 23 | +_Dist2D: TypeAlias = onp.Array2D[_AsReal] |
| 24 | + |
| 25 | +# the (presumed) type of the `global_corr` parameters |
| 26 | +_GlobalCorr: TypeAlias = Literal["mgc", "mantel", "biased", "rank"] |
| 27 | + |
| 28 | +### |
| 29 | + |
| 30 | +@type_check_only |
| 31 | +class _CApiDict(TypedDict): |
| 32 | + _geninvgauss_pdf: ReadOnly[CapsuleType] |
| 33 | + _studentized_range_cdf: ReadOnly[CapsuleType] |
| 34 | + _studentized_range_cdf_asymptotic: ReadOnly[CapsuleType] |
| 35 | + _studentized_range_pdf: ReadOnly[CapsuleType] |
| 36 | + _studentized_range_pdf_asymptotic: ReadOnly[CapsuleType] |
| 37 | + _studentized_range_moment: ReadOnly[CapsuleType] |
| 38 | + _genhyperbolic_pdf: ReadOnly[CapsuleType] |
| 39 | + _genhyperbolic_logpdf: ReadOnly[CapsuleType] |
| 40 | + |
| 41 | +### |
| 42 | + |
| 43 | +__pyx_capi__: Final[_CApiDict] = ... # undocumented |
| 44 | + |
| 45 | +def von_mises_cdf(k_obj: onp.ToFloatND, x_obj: onp.ToFloatND) -> onp.ArrayND[np.float64]: ... # undocumented |
| 46 | +def _kendall_dis(x: onp.Array1D[np.intp], y: onp.Array1D[np.intp]) -> int: ... # undocumented |
| 47 | +def _toint64(x: onp.ToIntND) -> onp.Array1D[np.int64]: ... # undocumented |
| 48 | +def _weightedrankedtau( |
| 49 | + x: onp.Array1D[_Ordered], |
| 50 | + y: onp.Array1D[_Ordered], |
| 51 | + rank: onp.Array1D[np.intp], |
| 52 | + weigher: Callable[[float], onp.ToFloat], |
| 53 | + additive: bool, |
| 54 | +) -> np.float64: ... # undocumented |
| 55 | +def _rank_distance_matrix(distx: onp.Array2D[npc.floating | npc.integer]) -> onp.Array2D[np.intp]: ... # undocumented |
| 56 | + |
| 57 | +# |
| 58 | +@overload |
| 59 | +def _center_distance_matrix( |
| 60 | + distx: _Dist2D, global_corr: _GlobalCorr = "mgc", is_ranked: onp.ToTrue = True |
| 61 | +) -> tuple[onp.Array2D[np.float64], onp.Array2D[np.intp]]: ... |
| 62 | +@overload |
| 63 | +def _center_distance_matrix( |
| 64 | + distx: _Dist2D, global_corr: _GlobalCorr, is_ranked: onp.ToFalse |
| 65 | +) -> tuple[onp.Array2D[np.float64], onp.Array1D[np.float64]]: ... |
| 66 | +@overload |
| 67 | +def _center_distance_matrix( |
| 68 | + distx: _Dist2D, global_corr: _GlobalCorr = "mgc", *, is_ranked: onp.ToFalse |
| 69 | +) -> tuple[onp.Array2D[np.float64], onp.Array1D[np.float64]]: ... # undocumented |
| 70 | + |
| 71 | +# |
| 72 | +@overload |
| 73 | +def _transform_distance_matrix( |
| 74 | + distx: _Dist2D, disty: _Dist2D, global_corr: _GlobalCorr = "mgc", is_ranked: onp.ToTrue = True |
| 75 | +) -> dict[str, onp.Array2D[np.float64] | onp.Array2D[np.intp]]: ... |
| 76 | +@overload |
| 77 | +def _transform_distance_matrix( |
| 78 | + distx: _Dist2D, disty: _Dist2D, global_corr: _GlobalCorr, is_ranked: onp.ToFalse |
| 79 | +) -> dict[str, onp.Array2D[np.float64] | onp.Array1D[np.float64]]: ... |
| 80 | +@overload |
| 81 | +def _transform_distance_matrix( |
| 82 | + distx: _Dist2D, disty: _Dist2D, global_corr: _GlobalCorr = "mgc", *, is_ranked: onp.ToFalse |
| 83 | +) -> dict[str, onp.Array2D[np.float64] | onp.Array1D[np.float64]]: ... # undocumented |
| 84 | + |
| 85 | +# |
| 86 | +def _local_covariance( |
| 87 | + distx: _Dist2D, disty: _Dist2D, rank_distx: onp.ArrayND[_AsReal], rank_disty: onp.ArrayND[_AsReal] |
| 88 | +) -> onp.Array2D[np.float64]: ... # undocumented |
| 89 | +def _local_correlations( |
| 90 | + distx: _Dist2D, disty: _Dist2D, global_corr: _GlobalCorr = "mgc" |
| 91 | +) -> onp.Array2D[np.float64]: ... # undocumented |
| 92 | +def geninvgauss_logpdf(x: float, p: float, b: float) -> float: ... # undocumented |
| 93 | +def _studentized_range_cdf_logconst(k: float, df: float) -> float: ... # undocumented |
| 94 | +def _studentized_range_pdf_logconst(k: float, df: float) -> float: ... # undocumented |
| 95 | +def genhyperbolic_pdf(x: float, p: float, a: float, b: float) -> float: ... # undocumented |
| 96 | +def genhyperbolic_logpdf(x: float, p: float, a: float, b: float) -> float: ... # undocumented |
| 97 | + |
| 98 | +# keep in sync with `gaussian_kernel_estimate_log` |
| 99 | +@overload |
| 100 | +def gaussian_kernel_estimate( # type: ignore[overload-overlap] |
| 101 | + points: onp.Array2D[_AsReal], |
| 102 | + values: onp.Array2D[_Real], |
| 103 | + xi: onp.Array2D[_AsReal], |
| 104 | + cho_cov: onp.Array2D[_AsReal], |
| 105 | + dtype: onp.AnyFloat32DType, |
| 106 | + _: _Real | float = 0.0, |
| 107 | +) -> onp.Array2D[np.float32]: ... |
| 108 | +@overload |
| 109 | +def gaussian_kernel_estimate( |
| 110 | + points: onp.Array2D[_AsReal], |
| 111 | + values: onp.Array2D[_Real], |
| 112 | + xi: onp.Array2D[_AsReal], |
| 113 | + cho_cov: onp.Array2D[_AsReal], |
| 114 | + dtype: onp.AnyFloat64DType, |
| 115 | + _: _Real | float = 0.0, |
| 116 | +) -> onp.Array2D[np.float64]: ... |
| 117 | +@overload |
| 118 | +def gaussian_kernel_estimate( |
| 119 | + points: onp.Array2D[_AsReal], |
| 120 | + values: onp.Array2D[_Real], |
| 121 | + xi: onp.Array2D[_AsReal], |
| 122 | + cho_cov: onp.Array2D[_AsReal], |
| 123 | + dtype: onp.AnyLongDoubleDType, |
| 124 | + _: _Real | float = 0.0, |
| 125 | +) -> onp.Array2D[np.longdouble]: ... # undocumented |
| 126 | + |
| 127 | +# keep in sync with `gaussian_kernel_estimate` |
| 128 | +@overload |
| 129 | +def gaussian_kernel_estimate_log( # type: ignore[overload-overlap] |
| 130 | + points: onp.Array2D[_AsReal], |
| 131 | + values: onp.Array2D[_Real], |
| 132 | + xi: onp.Array2D[_AsReal], |
| 133 | + cho_cov: onp.Array2D[_AsReal], |
| 134 | + dtype: onp.AnyFloat32DType, |
| 135 | + _: _Real | float = 0.0, |
| 136 | +) -> onp.Array2D[np.float32]: ... |
| 137 | +@overload |
| 138 | +def gaussian_kernel_estimate_log( |
| 139 | + points: onp.Array2D[_AsReal], |
| 140 | + values: onp.Array2D[_Real], |
| 141 | + xi: onp.Array2D[_AsReal], |
| 142 | + cho_cov: onp.Array2D[_AsReal], |
| 143 | + dtype: onp.AnyFloat64DType, |
| 144 | + _: _Real | float = 0.0, |
| 145 | +) -> onp.Array2D[np.float64]: ... |
| 146 | +@overload |
| 147 | +def gaussian_kernel_estimate_log( |
| 148 | + points: onp.Array2D[_AsReal], |
| 149 | + values: onp.Array2D[_Real], |
| 150 | + xi: onp.Array2D[_AsReal], |
| 151 | + cho_cov: onp.Array2D[_AsReal], |
| 152 | + dtype: onp.AnyLongDoubleDType, |
| 153 | + _: _Real | float = 0.0, |
| 154 | +) -> onp.Array2D[np.longdouble]: ... # undocumented |
0 commit comments