Skip to content

Commit

Permalink
Closes #3354 import scipy.stats functions to arkouda.scipy.stats
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpotts committed Jun 25, 2024
1 parent 5b3ee15 commit c7209d4
Show file tree
Hide file tree
Showing 16 changed files with 383 additions and 30 deletions.
2 changes: 1 addition & 1 deletion PROTO_tests/tests/dataframe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import arkouda as ak
from arkouda import io_util
from arkouda.scipy import chisquare as akchisquare
from arkouda.scipy.stats import chisquare as akchisquare


def alternating_1_0(n):
Expand Down
2 changes: 1 addition & 1 deletion PROTO_tests/tests/groupby_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import arkouda as ak
from arkouda.groupbyclass import GroupByReductionType
from arkouda.scipy import chisquare as akchisquare
from arkouda.scipy.stats import chisquare as akchisquare


def to_tuple_dict(labels, values):
Expand Down
2 changes: 1 addition & 1 deletion PROTO_tests/tests/random_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from scipy import stats as sp_stats

import arkouda as ak
from arkouda.scipy import chisquare as akchisquare
from arkouda.scipy.stats import chisquare as akchisquare


class TestRandom:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from scipy.stats import power_divergence as scipy_power_divergence

import arkouda as ak
from arkouda.scipy import chisquare as ak_chisquare
from arkouda.scipy import power_divergence as ak_power_divergence
from arkouda.scipy.stats import chisquare as ak_chisquare
from arkouda.scipy.stats import power_divergence as ak_power_divergence

DDOF = [0, 1, 2, 3, 4, 5]
PAIRS = [
Expand Down
4 changes: 1 addition & 3 deletions arkouda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,4 @@
is_registered,
broadcast_dims,
)
from arkouda.scipy.special import *
from arkouda.scipy import *
from arkouda.random import *
from arkouda.random import *
4 changes: 1 addition & 3 deletions arkouda/scipy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from ._stats_py import Power_divergenceResult, chisquare, power_divergence

__all__ = ["power_divergence", "chisquare", "Power_divergenceResult"]
__all__ = ["special", "stats"]
291 changes: 289 additions & 2 deletions arkouda/scipy/stats/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,291 @@
# mypy: ignore-errors
from scipy.stats import chi2 # type: ignore[import-untyped]
from scipy.stats import ( # noqa
ConstantInputWarning,
DegenerateDataWarning,
FitError,
NearConstantInputWarning,
alpha,
anglit,
arcsine,
argus,
bernoulli,
beta,
betabinom,
biasedurn,
binom,
binomtest,
boltzmann,
bradford,
burr,
burr12,
cauchy,
chi,
chi2,
contingency,
cosine,
crystalball,
dgamma,
distributions,
dlaplace,
dweibull,
erlang,
expon,
exponnorm,
exponpow,
exponweib,
f,
fatiguelife,
fisk,
foldcauchy,
foldnorm,
gamma,
gausshyper,
genexpon,
genextreme,
gengamma,
genhalflogistic,
genhyperbolic,
geninvgauss,
genlogistic,
gennorm,
genpareto,
geom,
gibrat,
gompertz,
gumbel_l,
gumbel_r,
halfcauchy,
halfgennorm,
halflogistic,
halfnorm,
hypergeom,
hypsecant,
invgamma,
invgauss,
invweibull,
johnsonsb,
johnsonsu,
kappa3,
kappa4,
kde,
ksone,
kstwo,
kstwobign,
laplace,
laplace_asymmetric,
levy,
levy_l,
levy_stable,
loggamma,
logistic,
loglaplace,
lognorm,
logser,
loguniform,
lomax,
maxwell,
mielke,
morestats,
moyal,
mstats_basic,
mstats_extras,
mvn,
nakagami,
nbinom,
ncf,
nchypergeom_fisher,
nchypergeom_wallenius,
nct,
ncx2,
nhypergeom,
norm,
norminvgauss,
pareto,
pearson3,
planck,
poisson,
poisson_means_test,
powerlaw,
powerlognorm,
powernorm,
randint,
rayleigh,
rdist,
recipinvgauss,
reciprocal,
rice,
sampling,
semicircular,
skellam,
skewcauchy,
skewnorm,
stats,
studentized_range,
t,
trapezoid,
trapz,
triang,
truncexpon,
truncnorm,
truncpareto,
truncweibull_min,
tukeylambda,
uniform,
vonmises,
vonmises_line,
wald,
weibull_max,
weibull_min,
wrapcauchy,
yulesimon,
zipf,
zipfian,
)

__all__ = ["chi2"]
from ._stats_py import Power_divergenceResult, chisquare, power_divergence # noqa

scipy_imports = [
"ConstantInputWarning",
"DegenerateDataWarning",
"FitError",
"NearConstantInputWarning",
"alpha",
"anglit",
"arcsine",
"argus",
"bernoulli",
"beta",
"betabinom",
"biasedurn",
"binom",
"binomtest",
"boltzmann",
"bradford",
"burr",
"burr12",
"cauchy",
"chi",
"chi2",
"contingency",
"cosine",
"crystalball",
"dgamma",
"distributions",
"dlaplace",
"dweibull",
"erlang",
"expon",
"exponnorm",
"exponpow",
"exponweib",
"f",
"fatiguelife",
"fisk",
"foldcauchy",
"foldnorm",
"gamma",
"gausshyper",
"genexpon",
"genextreme",
"gengamma",
"genhalflogistic",
"genhyperbolic",
"geninvgauss",
"genlogistic",
"gennorm",
"genpareto",
"geom",
"gibrat",
"gompertz",
"gumbel_l",
"gumbel_r",
"halfcauchy",
"halfgennorm",
"halflogistic",
"halfnorm",
"hypergeom",
"hypsecant",
"invgamma",
"invgauss",
"invweibull",
"johnsonsb",
"johnsonsu",
"kappa3",
"kappa4",
"kde",
"ksone",
"kstwo",
"kstwobign",
"laplace",
"laplace_asymmetric",
"levy",
"levy_l",
"levy_stable",
"loggamma",
"logistic",
"loglaplace",
"lognorm",
"logser",
"loguniform",
"lomax",
"maxwell",
"mielke",
"morestats",
"moyal",
"mstats_basic",
"mstats_extras",
"mvn",
"nakagami",
"nbinom",
"ncf",
"nchypergeom_fisher",
"nchypergeom_wallenius",
"nct",
"ncx2",
"nhypergeom",
"norm",
"norminvgauss",
"pareto",
"pearson3",
"planck",
"poisson",
"poisson_means_test",
"powerlaw",
"powerlognorm",
"powernorm",
"randint",
"rayleigh",
"rdist",
"recipinvgauss",
"reciprocal",
"rice",
"sampling",
"semicircular",
"skellam",
"skewcauchy",
"skewnorm",
"stats",
"studentized_range",
"t",
"test",
"trapezoid",
"trapz",
"triang",
"truncexpon",
"truncnorm",
"truncpareto",
"truncweibull_min",
"tukeylambda",
"uniform",
"vonmises",
"vonmises_line",
"wald",
"weibull_max",
"weibull_min",
"wrapcauchy",
"yulesimon",
"zipf",
"zipfian",
]

__all__ = scipy_imports + ["Power_divergenceResult", "power_divergence", "chisquare"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import numpy as np
from numpy import asarray
from scipy.stats import chi2 # type: ignore
from scipy.stats import chi2 # type:ignore

import arkouda as ak
from arkouda.scipy.special import xlogy
from arkouda.dtypes import float64 as akfloat64
from arkouda.scipy.special import xlogy

__all__ = ["power_divergence", "chisquare", "Power_divergenceResult"]
__all__ = ["Power_divergenceResult", "power_divergence", "chisquare"]


class Power_divergenceResult(namedtuple("Power_divergenceResult", ("statistic", "pvalue"))):
Expand Down Expand Up @@ -74,7 +74,7 @@ def power_divergence(f_obs, f_exp=None, ddof=0, lambda_=None):
>>> import arkouda as ak
>>> ak.connect()
>>> from arkouda.stats import power_divergence
>>> from arkouda.scipy.stats import power_divergence
>>> x = ak.array([10, 20, 30, 10])
>>> y = ak.array([10, 30, 20, 10])
>>> power_divergence(x, y, lambda_="pearson")
Expand Down
Loading

0 comments on commit c7209d4

Please sign in to comment.