Skip to content

Commit

Permalink
fix scipy.stats.mstats stubtests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenham committed Oct 12, 2024
1 parent fd371ba commit 5b5b6af
Show file tree
Hide file tree
Showing 7 changed files with 895 additions and 288 deletions.
5 changes: 4 additions & 1 deletion scipy-stubs/_typing.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Helper types for internal use (type-check only).
# NOTE(scipy-stubs): This ia a module only exists `if typing.TYPE_CHECKING: ...`

from os import PathLike
from collections.abc import Callable, Sequence
from typing import IO, Any, Literal, Protocol, TypeAlias, type_check_only
Expand All @@ -10,6 +11,7 @@ import optype.numpy as onpt

__all__ = [
"RNG",
"Alternative",
"AnyBool",
"AnyChar",
"AnyComplex",
Expand Down Expand Up @@ -74,6 +76,7 @@ CorrelateMode: TypeAlias = Literal["valid", "same", "full"]

# scipy literals
NanPolicy: TypeAlias = Literal["raise", "propagate", "omit"]
Alternative: TypeAlias = Literal["two-sided", "less", "greater"]

# used in `scipy.linalg.blas` and `scipy.linalg.lapack`
@type_check_only
Expand Down
62 changes: 37 additions & 25 deletions scipy-stubs/stats/_mstats_basic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ trimdoc: str
def argstoarray(*args) -> Untyped: ...
def find_repeats(arr) -> Untyped: ...
def count_tied_groups(x, use_missing: bool = False) -> Untyped: ...
def rankdata(data, axis: Untyped | None = None, use_missing: bool = False) -> Untyped: ...
def rankdata(data, axis: int | None = None, use_missing: bool = False) -> Untyped: ...
def mode(a, axis: int = 0) -> Untyped: ...
def msign(x) -> Untyped: ...
def pearsonr(x, y) -> Untyped: ...
def spearmanr(
x,
y: Untyped | None = None,
use_ties: bool = True,
axis: Untyped | None = None,
axis: int | None = None,
nan_policy: str = "propagate",
alternative: str = "two-sided",
) -> Untyped: ...
Expand All @@ -164,80 +164,92 @@ def kruskal(*args) -> Untyped: ...
def ks_1samp(x, cdf, args=(), alternative: str = "two-sided", method: str = "auto") -> Untyped: ...
def ks_2samp(data1, data2, alternative: str = "two-sided", method: str = "auto") -> Untyped: ...
def kstest(data1, data2, args=(), alternative: str = "two-sided", method: str = "auto") -> Untyped: ...
def trima(a, limits: Untyped | None = None, inclusive=(True, True)) -> Untyped: ...
def trimr(a, limits: Untyped | None = None, inclusive=(True, True), axis: Untyped | None = None) -> Untyped: ...
def trima(a, limits: Untyped | None = None, inclusive: tuple[bool, bool] = (True, True)) -> Untyped: ...
def trimr(a, limits: Untyped | None = None, inclusive: tuple[bool, bool] = (True, True), axis: int | None = None) -> Untyped: ...
def trim(
a,
limits: Untyped | None = None,
inclusive=(True, True),
inclusive: tuple[bool, bool] = (True, True),
relative: bool = False,
axis: Untyped | None = None,
axis: int | None = None,
) -> Untyped: ...
def trimboth(
data,
proportiontocut: float = 0.2,
inclusive=(True, True),
axis: Untyped | None = None,
inclusive: tuple[bool, bool] = (True, True),
axis: int | None = None,
) -> Untyped: ...
def trimtail(
data,
proportiontocut: float = 0.2,
tail: str = "left",
inclusive=(True, True),
axis: Untyped | None = None,
inclusive: tuple[bool, bool] = (True, True),
axis: int | None = None,
) -> Untyped: ...
def trimmed_mean(
a,
limits=(0.1, 0.1),
inclusive=(1, 1),
inclusive: tuple[bool, bool] = (1, 1),
relative: bool = True,
axis: Untyped | None = None,
axis: int | None = None,
) -> Untyped: ...
def trimmed_var(
a,
limits=(0.1, 0.1),
inclusive=(1, 1),
inclusive: tuple[bool, bool] = (1, 1),
relative: bool = True,
axis: Untyped | None = None,
axis: int | None = None,
ddof: int = 0,
) -> Untyped: ...
def trimmed_std(
a,
limits=(0.1, 0.1),
inclusive=(1, 1),
inclusive: tuple[bool, bool] = (1, 1),
relative: bool = True,
axis: Untyped | None = None,
axis: int | None = None,
ddof: int = 0,
) -> Untyped: ...
def trimmed_stde(a, limits=(0.1, 0.1), inclusive=(1, 1), axis: Untyped | None = None) -> Untyped: ...
def tmean(a, limits: Untyped | None = None, inclusive=(True, True), axis: Untyped | None = None) -> Untyped: ...
def tvar(a, limits: Untyped | None = None, inclusive=(True, True), axis: int = 0, ddof: int = 1) -> Untyped: ...
def trimmed_stde(a, limits=(0.1, 0.1), inclusive: tuple[bool, bool] = (1, 1), axis: int | None = None) -> Untyped: ...
def tmean(a, limits: Untyped | None = None, inclusive: tuple[bool, bool] = (True, True), axis: int | None = None) -> Untyped: ...
def tvar(
a,
limits: Untyped | None = None,
inclusive: tuple[bool, bool] = (True, True),
axis: int = 0,
ddof: int = 1,
) -> Untyped: ...
def tmin(a, lowerlimit: Untyped | None = None, axis: int = 0, inclusive: bool = True) -> Untyped: ...
def tmax(a, upperlimit: Untyped | None = None, axis: int = 0, inclusive: bool = True) -> Untyped: ...
def tsem(a, limits: Untyped | None = None, inclusive=(True, True), axis: int = 0, ddof: int = 1) -> Untyped: ...
def tsem(
a,
limits: Untyped | None = None,
inclusive: tuple[bool, bool] = (True, True),
axis: int = 0,
ddof: int = 1,
) -> Untyped: ...
def winsorize(
a,
limits: Untyped | None = None,
inclusive=(True, True),
inclusive: tuple[bool, bool] = (True, True),
inplace: bool = False,
axis: Untyped | None = None,
axis: int | None = None,
nan_policy: str = "propagate",
) -> Untyped: ...
def moment(a, moment: int = 1, axis: int = 0) -> Untyped: ...
def variation(a, axis: int = 0, ddof: int = 0) -> Untyped: ...
def skew(a, axis: int = 0, bias: bool = True) -> Untyped: ...
def kurtosis(a, axis: int = 0, fisher: bool = True, bias: bool = True) -> Untyped: ...
def describe(a, axis: int = 0, ddof: int = 0, bias: bool = True) -> Untyped: ...
def stde_median(data, axis: Untyped | None = None) -> Untyped: ...
def stde_median(data, axis: int | None = None) -> Untyped: ...
def skewtest(a, axis: int = 0, alternative: str = "two-sided") -> Untyped: ...
def kurtosistest(a, axis: int = 0, alternative: str = "two-sided") -> Untyped: ...
def normaltest(a, axis: int = 0) -> Untyped: ...
def mquantiles(
a,
prob=(0.25, 0.5, 0.75),
prob=[0.25, 0.5, 0.75],
alphap: float = 0.4,
betap: float = 0.4,
axis: Untyped | None = None,
axis: int | None = None,
limit=(),
) -> Untyped: ...
def scoreatpercentile(data, per, limit=(), alphap: float = 0.4, betap: float = 0.4) -> Untyped: ...
Expand Down
16 changes: 8 additions & 8 deletions scipy-stubs/stats/_mstats_extras.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ __all__ = [
"trimmed_mean_ci",
]

def hdquantiles(data, prob=(0.25, 0.5, 0.75), axis: Untyped | None = None, var: bool = False) -> Untyped: ...
def hdquantiles(data, prob=[0.25, 0.5, 0.75], axis: int | None = None, var: bool = False) -> Untyped: ...
def hdmedian(data, axis: int = -1, var: bool = False) -> Untyped: ...
def hdquantiles_sd(data, prob=(0.25, 0.5, 0.75), axis: Untyped | None = None) -> Untyped: ...
def hdquantiles_sd(data, prob=[0.25, 0.5, 0.75], axis: int | None = None) -> Untyped: ...
def trimmed_mean_ci(
data,
limits=(0.2, 0.2),
inclusive=(True, True),
alpha: float = 0.05,
axis: Untyped | None = None,
axis: int | None = None,
) -> Untyped: ...
def mjci(data, prob=(0.25, 0.5, 0.75), axis: Untyped | None = None) -> Untyped: ...
def mquantiles_cimj(data, prob=(0.25, 0.5, 0.75), alpha: float = 0.05, axis: Untyped | None = None) -> Untyped: ...
def median_cihs(data, alpha: float = 0.05, axis: Untyped | None = None) -> Untyped: ...
def compare_medians_ms(group_1, group_2, axis: Untyped | None = None) -> Untyped: ...
def idealfourths(data, axis: Untyped | None = None) -> Untyped: ...
def mjci(data, prob=[0.25, 0.5, 0.75], axis: int | None = None) -> Untyped: ...
def mquantiles_cimj(data, prob=[0.25, 0.5, 0.75], alpha: float = 0.05, axis: int | None = None) -> Untyped: ...
def median_cihs(data, alpha: float = 0.05, axis: int | None = None) -> Untyped: ...
def compare_medians_ms(group_1, group_2, axis: int | None = None) -> Untyped: ...
def idealfourths(data, axis: int | None = None) -> Untyped: ...
def rsh(data, points: Untyped | None = None) -> Untyped: ...
59 changes: 54 additions & 5 deletions scipy-stubs/stats/_stats_mstats_common.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,57 @@
from scipy._typing import Untyped
from typing import Any, Literal, TypeAlias
from typing_extensions import Self

import numpy as np
import numpy.typing as npt
from . import distributions as distributions
from ._typing import BaseBunch

__all__ = ["_find_repeats", "siegelslopes", "theilslopes"]

_Method: TypeAlias = Literal["hierarchical", "separate"]

class SiegelslopesResult(BaseBunch[float, float]):
def __new__(_cls, slope: float, intercept: float) -> Self: ...
def __init__(self, /, slope: float, intercept: float) -> None: ...
@property
def slope(self, /) -> float: ...
@property
def intercept(self, /) -> float: ...

TheilslopesResult: Untyped
SiegelslopesResult: Untyped
class TheilslopesResult(BaseBunch[np.float64, np.float64, np.float64, np.float64]):
def __new__(
_cls,
slope: np.float64,
intercept: np.float64,
low_slope: np.float64,
high_slope: np.float64,
) -> Self: ...
def __init__(
self,
/,
slope: np.float64,
intercept: np.float64,
low_slope: np.float64,
high_slope: np.float64,
) -> None: ...
@property
def slope(self, /) -> np.float64: ...
@property
def intercept(self, /) -> np.float64: ...
@property
def low_slope(self, /) -> np.float64: ...
@property
def high_slope(self, /) -> np.float64: ...

def theilslopes(y, x: Untyped | None = None, alpha: float = 0.95, method: str = "separate") -> Untyped: ...
def siegelslopes(y, x: Untyped | None = None, method: str = "hierarchical") -> Untyped: ...
def _find_repeats(arr: npt.NDArray[np.number[Any]]) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.intp]]: ...
def siegelslopes(
y: npt.ArrayLike,
x: npt.ArrayLike | None = None,
method: _Method = "hierarchical",
) -> SiegelslopesResult: ...
def theilslopes(
y: npt.ArrayLike,
x: npt.ArrayLike | None = None,
alpha: float | np.floating[Any] = 0.95,
method: _Method = "separate",
) -> TheilslopesResult: ...
Loading

0 comments on commit 5b5b6af

Please sign in to comment.