uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
04a95c8cd35b97bcd046ed30
train
function
def pymc_random_discrete( dist, paramdomains, valuedomain=None, ref_rand=None, size=100000, alpha=0.05, fails=20, ): if valuedomain is None: valuedomain = Domain([0], edges=(None, None)) model, param_vars = build_model(dist, valuedomain, paramdomains) model_dist = change...
def pymc_random_discrete( dist, paramdomains, valuedomain=None, ref_rand=None, size=100000, alpha=0.05, fails=20, ):
if valuedomain is None: valuedomain = Domain([0], edges=(None, None)) model, param_vars = build_model(dist, valuedomain, paramdomains) model_dist = change_rv_size(model.named_vars["value"], size, expand=True) pymc_rand = aesara.function([], model_dist) domains = paramdomains.copy() for...
while p <= alpha and f > 0: s0 = pymc_rand() s1 = floatX(ref_rand(size=size, **pt)) _, p = st.ks_2samp(np.atleast_1d(s0).flatten(), np.atleast_1d(s1).flatten()) f -= 1 assert p > alpha, str(pt) def pymc_random_discrete( dist, paramdomains, valu...
123
123
412
43
80
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
pymc_random_discrete
pymc_random_discrete
107
152
107
115
1fbd3d6685630e75532562fe9ef3e592f844e38f
bigcode/the-stack
train
d19c0332ce2bf5e3e270bf96
train
class
class TestBeta(BaseTestDistribution): pymc_dist = pm.Beta pymc_dist_params = {"alpha": 2.0, "beta": 5.0} expected_rv_op_params = {"alpha": 2.0, "beta": 5.0} reference_dist_params = {"a": 2.0, "b": 5.0} size = 15 reference_dist = lambda self: functools.partial( clipped_beta_rvs, random_st...
class TestBeta(BaseTestDistribution):
pymc_dist = pm.Beta pymc_dist_params = {"alpha": 2.0, "beta": 5.0} expected_rv_op_params = {"alpha": 2.0, "beta": 5.0} reference_dist_params = {"a": 2.0, "b": 5.0} size = 15 reference_dist = lambda self: functools.partial( clipped_beta_rvs, random_state=self.get_random_state() ) ...
pm.Normal pymc_dist_params = {"sd": 5.0} expected_rv_op_params = {"mu": 0.0, "sigma": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"] class TestBeta(BaseTestDistribution):
63
64
151
7
56
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestBeta
TestBeta
874
887
874
874
6f155e1eb682ff8445b859c9f520bb9a42b5a794
bigcode/the-stack
train
1ead4f525c7c02a84e8d7029
train
class
class TestTruncatedNormal(BaseTestDistribution): pymc_dist = pm.TruncatedNormal lower, upper, mu, sigma = -2.0, 2.0, 0, 1.0 pymc_dist_params = {"mu": mu, "sigma": sigma, "lower": lower, "upper": upper} expected_rv_op_params = {"mu": mu, "sigma": sigma, "lower": lower, "upper": upper} reference_dist_...
class TestTruncatedNormal(BaseTestDistribution):
pymc_dist = pm.TruncatedNormal lower, upper, mu, sigma = -2.0, 2.0, 0, 1.0 pymc_dist_params = {"mu": mu, "sigma": sigma, "lower": lower, "upper": upper} expected_rv_op_params = {"mu": mu, "sigma": sigma, "lower": lower, "upper": upper} reference_dist_params = { "loc": mu, "scale": si...
.0} reference_dist = seeded_kumaraswamy_rng_fn tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestTruncatedNormal(BaseTestDistribution):
63
64
196
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestTruncatedNormal
TestTruncatedNormal
617
633
617
617
c26fe7ec1683ba6ce16cdcaf91a5e3f10a36ae60
bigcode/the-stack
train
7d9458416600f138ad306288
train
class
class TestMvStudentTTau(BaseTestDistribution): pymc_dist = pm.MvStudentT pymc_dist_params = { "nu": 5, "mu": np.array([1.0, 2.0]), "tau": np.array([[2.0, 0.0], [0.0, 3.5]]), } expected_rv_op_params = { "nu": 5, "mu": np.array([1.0, 2.0]), "cov": quaddist_m...
class TestMvStudentTTau(BaseTestDistribution):
pymc_dist = pm.MvStudentT pymc_dist_params = { "nu": 5, "mu": np.array([1.0, 2.0]), "tau": np.array([[2.0, 0.0], [0.0, 3.5]]), } expected_rv_op_params = { "nu": 5, "mu": np.array([1.0, 2.0]), "cov": quaddist_matrix(tau=pymc_dist_params["tau"]).eval(), ...
"mu": np.array([1.0, 2.0]), "cov": quaddist_matrix(chol=pymc_dist_params["chol"]).eval(), } tests_to_run = ["check_pymc_params_match_rv_op"] class TestMvStudentTTau(BaseTestDistribution):
63
64
149
10
53
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestMvStudentTTau
TestMvStudentTTau
1,148
1,160
1,148
1,148
9836a53f2184e979d744b7aef882e10a6324310d
bigcode/the-stack
train
aa91c0d66dd51f9401f301db
train
class
class TestMvStudentTChol(BaseTestDistribution): pymc_dist = pm.MvStudentT pymc_dist_params = { "nu": 5, "mu": np.array([1.0, 2.0]), "chol": np.array([[2.0, 0.0], [0.0, 3.5]]), } expected_rv_op_params = { "nu": 5, "mu": np.array([1.0, 2.0]), "cov": quaddist...
class TestMvStudentTChol(BaseTestDistribution):
pymc_dist = pm.MvStudentT pymc_dist_params = { "nu": 5, "mu": np.array([1.0, 2.0]), "chol": np.array([[2.0, 0.0], [0.0, 3.5]]), } expected_rv_op_params = { "nu": 5, "mu": np.array([1.0, 2.0]), "cov": quaddist_matrix(chol=pymc_dist_params["chol"]).eval(), ...
.mvstudentt_rng_fn, rng=self.get_random_state() ) tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestMvStudentTChol(BaseTestDistribution):
63
64
150
11
52
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestMvStudentTChol
TestMvStudentTChol
1,133
1,145
1,133
1,133
b0b9e463179983993548703b71006aa425de7a4c
bigcode/the-stack
train
1f09ab673c7c7b01eb8ab45c
train
class
class TestOrderedLogistic(BaseTestDistribution): pymc_dist = _OrderedLogistic pymc_dist_params = {"eta": 0, "cutpoints": np.array([-2, 0, 2])} expected_rv_op_params = {"p": np.array([0.11920292, 0.38079708, 0.38079708, 0.11920292])} tests_to_run = [ "check_pymc_params_match_rv_op", "chec...
class TestOrderedLogistic(BaseTestDistribution):
pymc_dist = _OrderedLogistic pymc_dist_params = {"eta": 0, "cutpoints": np.array([-2, 0, 2])} expected_rv_op_params = {"p": np.array([0.11920292, 0.38079708, 0.38079708, 0.11920292])} tests_to_run = [ "check_pymc_params_match_rv_op", "check_rv_size", ]
reference_dist = seeded_zero_inflated_negbinomial_rng_fn tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestOrderedLogistic(BaseTestDistribution):
63
64
115
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestOrderedLogistic
TestOrderedLogistic
1,505
1,512
1,505
1,505
7e7d3915f903ed7ab3cca7070aa919ee43ed5690
bigcode/the-stack
train
88c7aae52f79123edcc3325d
train
class
class TestNormal(BaseTestDistribution): pymc_dist = pm.Normal pymc_dist_params = {"mu": 5.0, "sigma": 10.0} expected_rv_op_params = {"mu": 5.0, "sigma": 10.0} reference_dist_params = {"loc": 5.0, "scale": 10.0} size = 15 reference_dist = seeded_numpy_distribution_builder("normal") tests_to_r...
class TestNormal(BaseTestDistribution):
pymc_dist = pm.Normal pymc_dist_params = {"mu": 5.0, "sigma": 10.0} expected_rv_op_params = {"mu": 5.0, "sigma": 10.0} reference_dist_params = {"loc": 5.0, "scale": 10.0} size = 15 reference_dist = seeded_numpy_distribution_builder("normal") tests_to_run = [ "check_pymc_params_match_...
} reference_dist_params = {"df": 5.0, "loc": -1.0, "scale": sigma} reference_dist = seeded_scipy_distribution_builder("t") tests_to_run = ["check_pymc_params_match_rv_op"] class TestNormal(BaseTestDistribution):
63
64
136
7
56
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestNormal
TestNormal
785
796
785
785
e7140b5208be806f68a9db1d1b2436b49d5f9d08
bigcode/the-stack
train
421ed1af85bf28ca8007f811
train
class
class TestLognormalTau(BaseTestDistribution): pymc_dist = pm.Lognormal tau, sigma = get_tau_sigma(tau=25.0) pymc_dist_params = {"mu": 1.0, "tau": 25.0} expected_rv_op_params = {"mu": 1.0, "sigma": sigma} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestLognormalTau(BaseTestDistribution):
pymc_dist = pm.Lognormal tau, sigma = get_tau_sigma(tau=25.0) pymc_dist_params = {"mu": 1.0, "tau": 25.0} expected_rv_op_params = {"mu": 1.0, "sigma": sigma} tests_to_run = ["check_pymc_params_match_rv_op"]
mu": 1.0, "sigma": 5.0} expected_rv_op_params = {"mu": 1.0, "sigma": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"] class TestLognormalTau(BaseTestDistribution):
63
64
92
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestLognormalTau
TestLognormalTau
1,281
1,286
1,281
1,281
cd615cdd24910b4d954c2a5e5a8a34e224c1b577
bigcode/the-stack
train
e6341ffa37dfc2aee2c71cb9
train
class
class TestConstant(BaseTestDistribution): def constant_rng_fn(self, size, c): if size is None: return c return np.full(size, c) pymc_dist = pm.Constant pymc_dist_params = {"c": 3} expected_rv_op_params = {"c": 3} reference_dist_params = {"c": 3} reference_dist = lamb...
class TestConstant(BaseTestDistribution):
def constant_rng_fn(self, size, c): if size is None: return c return np.full(size, c) pymc_dist = pm.Constant pymc_dist_params = {"c": 3} expected_rv_op_params = {"c": 3} reference_dist_params = {"c": 3} reference_dist = lambda self: self.constant_rng_fn tests_to...
.partial( self.discrete_uniform_rng_fn, rng=self.get_random_state() ) tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestConstant(BaseTestDistribution):
63
64
130
7
56
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestConstant
TestConstant
1,390
1,405
1,390
1,390
2ba96038a2810018c4875fb42118c1b6c4eece68
bigcode/the-stack
train
735899cb19b7d7f004f08a23
train
class
class TestSkewNormalTau(BaseTestDistribution): pymc_dist = pm.SkewNormal tau, sigma = get_tau_sigma(tau=2.0) pymc_dist_params = {"mu": 0.0, "tau": tau, "alpha": 5.0} expected_rv_op_params = {"mu": 0.0, "sigma": sigma, "alpha": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestSkewNormalTau(BaseTestDistribution):
pymc_dist = pm.SkewNormal tau, sigma = get_tau_sigma(tau=2.0) pymc_dist_params = {"mu": 0.0, "tau": tau, "alpha": 5.0} expected_rv_op_params = {"mu": 0.0, "sigma": sigma, "alpha": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"]
reference_dist = seeded_scipy_distribution_builder("skewnorm") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestSkewNormalTau(BaseTestDistribution):
63
64
107
10
53
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestSkewNormalTau
TestSkewNormalTau
745
750
745
745
98e9807e686e0bf507bfdc903a77e8bc58d45927
bigcode/the-stack
train
2a880e440fe158569265a7b6
train
class
class TestGammaMuSigma(BaseTestDistribution): pymc_dist = pm.Gamma pymc_dist_params = {"mu": 0.5, "sigma": 0.25} expected_alpha, expected_beta = pm.Gamma.get_alpha_beta( mu=pymc_dist_params["mu"], sigma=pymc_dist_params["sigma"] ) expected_rv_op_params = {"alpha": expected_alpha, "beta": 1 /...
class TestGammaMuSigma(BaseTestDistribution):
pymc_dist = pm.Gamma pymc_dist_params = {"mu": 0.5, "sigma": 0.25} expected_alpha, expected_beta = pm.Gamma.get_alpha_beta( mu=pymc_dist_params["mu"], sigma=pymc_dist_params["sigma"] ) expected_rv_op_params = {"alpha": expected_alpha, "beta": 1 / expected_beta} tests_to_run = ["check_pym...
, "scale": 1 / 5.0} reference_dist = seeded_numpy_distribution_builder("gamma") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", ] class TestGammaMuSigma(BaseTestDistribution):
63
64
113
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestGammaMuSigma
TestGammaMuSigma
948
955
948
948
73183975d6a7ffc12d90ddc1359ba76f18cad182
bigcode/the-stack
train
780c0dc6b0862e3d9db588e2
train
class
class TestCauchy(BaseTestDistribution): pymc_dist = pm.Cauchy pymc_dist_params = {"alpha": 2.0, "beta": 5.0} expected_rv_op_params = {"alpha": 2.0, "beta": 5.0} reference_dist_params = {"loc": 2.0, "scale": 5.0} reference_dist = seeded_scipy_distribution_builder("cauchy") tests_to_run = [ ...
class TestCauchy(BaseTestDistribution):
pymc_dist = pm.Cauchy pymc_dist_params = {"alpha": 2.0, "beta": 5.0} expected_rv_op_params = {"alpha": 2.0, "beta": 5.0} reference_dist_params = {"loc": 2.0, "scale": 5.0} reference_dist = seeded_scipy_distribution_builder("cauchy") tests_to_run = [ "check_pymc_params_match_rv_op", ...
1.0 / pymc_dist_params["lam"]} reference_dist = seeded_numpy_distribution_builder("exponential") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", ] class TestCauchy(BaseTestDistribution):
63
64
131
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestCauchy
TestCauchy
912
921
912
912
5d5bd44da8f160e73e133cd979e2d75c1d7190a0
bigcode/the-stack
train
6bc89b9e18d8d667c1063e14
train
class
class TestInverseGamma(BaseTestDistribution): pymc_dist = pm.InverseGamma pymc_dist_params = {"alpha": 2.0, "beta": 5.0} expected_rv_op_params = {"alpha": 2.0, "beta": 5.0} reference_dist_params = {"a": 2.0, "scale": 5.0} reference_dist = seeded_scipy_distribution_builder("invgamma") tests_to_ru...
class TestInverseGamma(BaseTestDistribution):
pymc_dist = pm.InverseGamma pymc_dist_params = {"alpha": 2.0, "beta": 5.0} expected_rv_op_params = {"alpha": 2.0, "beta": 5.0} reference_dist_params = {"a": 2.0, "scale": 5.0} reference_dist = seeded_scipy_distribution_builder("invgamma") tests_to_run = [ "check_pymc_params_match_rv_op",...
c_dist_params["mu"], sigma=pymc_dist_params["sigma"] ) expected_rv_op_params = {"alpha": expected_alpha, "beta": 1 / expected_beta} tests_to_run = ["check_pymc_params_match_rv_op"] class TestInverseGamma(BaseTestDistribution):
63
64
130
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestInverseGamma
TestInverseGamma
958
967
958
958
ee0508f0ee068a3ecd6a59cb06cc3119cd36d159
bigcode/the-stack
train
619d5856adc19a8af7224da4
train
class
class TestMvNormalCov(BaseTestDistribution): pymc_dist = pm.MvNormal pymc_dist_params = { "mu": np.array([1.0, 2.0]), "cov": np.array([[2.0, 0.0], [0.0, 3.5]]), } expected_rv_op_params = { "mu": np.array([1.0, 2.0]), "cov": np.array([[2.0, 0.0], [0.0, 3.5]]), } si...
class TestMvNormalCov(BaseTestDistribution):
pymc_dist = pm.MvNormal pymc_dist_params = { "mu": np.array([1.0, 2.0]), "cov": np.array([[2.0, 0.0], [0.0, 3.5]]), } expected_rv_op_params = { "mu": np.array([1.0, 2.0]), "cov": np.array([[2.0, 0.0], [0.0, 3.5]]), } sizes_to_check = [None, (1), (2, 3)] sizes_...
_match_rv_op"] class TestPoisson(BaseTestDistribution): pymc_dist = pm.Poisson pymc_dist_params = {"mu": 4.0} expected_rv_op_params = {"mu": 4.0} tests_to_run = ["check_pymc_params_match_rv_op"] class TestMvNormalCov(BaseTestDistribution):
78
79
265
9
69
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestMvNormalCov
TestMvNormalCov
1,049
1,070
1,049
1,049
a658e803ac95196eafff02b20b0ccb2615b28b50
bigcode/the-stack
train
4afc8c5bd06a2defcb4132db
train
class
class TestNormalSd(BaseTestDistribution): pymc_dist = pm.Normal pymc_dist_params = {"mu": 1.0, "sd": 5.0} expected_rv_op_params = {"mu": 1.0, "sigma": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestNormalSd(BaseTestDistribution):
pymc_dist = pm.Normal pymc_dist_params = {"mu": 1.0, "sd": 5.0} expected_rv_op_params = {"mu": 1.0, "sigma": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"]
pymc_dist_params = {"mu": 1.0, "tau": tau} expected_rv_op_params = {"mu": 1.0, "sigma": sigma} tests_to_run = ["check_pymc_params_match_rv_op"] class TestNormalSd(BaseTestDistribution):
63
64
77
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestNormalSd
TestNormalSd
833
837
833
833
3fce70d2a570394d803f81709ed5af64941a60c4
bigcode/the-stack
train
fc23aa4e1186142c7c9cd1a0
train
class
class TestBernoulli(BaseTestDistribution): pymc_dist = pm.Bernoulli pymc_dist_params = {"p": 0.33} expected_rv_op_params = {"p": 0.33} reference_dist_params = {"p": 0.33} reference_dist = seeded_scipy_distribution_builder("bernoulli") tests_to_run = [ "check_pymc_params_match_rv_op", ...
class TestBernoulli(BaseTestDistribution):
pymc_dist = pm.Bernoulli pymc_dist_params = {"p": 0.33} expected_rv_op_params = {"p": 0.33} reference_dist_params = {"p": 0.33} reference_dist = seeded_scipy_distribution_builder("bernoulli") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", ...
alpha=pymc_dist_params["alpha"], n=None, p=None, ) expected_rv_op_params = {"n": expected_n, "p": expected_p} tests_to_run = ["check_pymc_params_match_rv_op"] class TestBernoulli(BaseTestDistribution):
63
64
108
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestBernoulli
TestBernoulli
1,023
1,032
1,023
1,023
096f16ddcb61e69dbd9b0ea52308340da77dc16f
bigcode/the-stack
train
cdbf2e2d255ff2385b352cb8
train
class
@pytest.mark.xfail(reason="This distribution has not been refactored for v4") class TestMvGaussianRandomWalk(SeededTest): @pytest.mark.parametrize( ["sample_shape", "dist_shape", "mu_shape", "param"], generate_shapes(include_params=True), ids=str, ) def test_with_np_arrays(self, samp...
@pytest.mark.xfail(reason="This distribution has not been refactored for v4") class TestMvGaussianRandomWalk(SeededTest): @pytest.mark.parametrize( ["sample_shape", "dist_shape", "mu_shape", "param"], generate_shapes(include_params=True), ids=str, )
def test_with_np_arrays(self, sample_shape, dist_shape, mu_shape, param): dist = pm.MvGaussianRandomWalk.dist( mu=np.ones(mu_shape), **{param: np.eye(3)}, shape=dist_shape ) output_shape = to_tuple(sample_shape) + dist_shape assert dist.random(size=sample_shape).shape == ...
acked_triangular(D, packedL, lower=True) Sigma = pm.Deterministic("Sigma", L.dot(L.T)) # D x D covariance mu = pm.MatrixNormal( "mu", mu=mu_0, rowcov=(1 / lambd) * Sigma, colcov=np.eye(K), shape=(D, K) ) prior = pm.sample_prior_predictive(2) assert prior["mu"].shape == ...
165
165
552
64
101
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestMvGaussianRandomWalk
TestMvGaussianRandomWalk
2,309
2,357
2,309
2,315
1fe7a2f63d9d85446d13573cf1896990c3af034d
bigcode/the-stack
train
98f729672b4436d32ba450ba
train
class
class TestHalfCauchy(BaseTestDistribution): pymc_dist = pm.HalfCauchy pymc_dist_params = {"beta": 5.0} expected_rv_op_params = {"alpha": 0.0, "beta": 5.0} reference_dist_params = {"loc": 0.0, "scale": 5.0} reference_dist = seeded_scipy_distribution_builder("halfcauchy") tests_to_run = [ ...
class TestHalfCauchy(BaseTestDistribution):
pymc_dist = pm.HalfCauchy pymc_dist_params = {"beta": 5.0} expected_rv_op_params = {"alpha": 0.0, "beta": 5.0} reference_dist_params = {"loc": 0.0, "scale": 5.0} reference_dist = seeded_scipy_distribution_builder("halfcauchy") tests_to_run = [ "check_pymc_params_match_rv_op", "ch...
scale": 5.0} reference_dist = seeded_scipy_distribution_builder("cauchy") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", ] class TestHalfCauchy(BaseTestDistribution):
63
64
127
10
53
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestHalfCauchy
TestHalfCauchy
924
933
924
924
7b555b2fe7708b66680f9ecafd9e62faec8776ca
bigcode/the-stack
train
940696d6c0d334c64c3b8ab5
train
class
class TestDirichletMultinomial_1d_n_2d_a(BaseTestDistribution): pymc_dist = pm.DirichletMultinomial pymc_dist_params = { "n": np.array([23, 29]), "a": np.array([[0.25, 0.25, 0.25, 0.25], [0.25, 0.25, 0.25, 0.25]]), } sizes_to_check = [None, 1, (4,), (3, 4)] sizes_expected = [(2, 4), ...
class TestDirichletMultinomial_1d_n_2d_a(BaseTestDistribution):
pymc_dist = pm.DirichletMultinomial pymc_dist_params = { "n": np.array([23, 29]), "a": np.array([[0.25, 0.25, 0.25, 0.25], [0.25, 0.25, 0.25, 0.25]]), } sizes_to_check = [None, 1, (4,), (3, 4)] sizes_expected = [(2, 4), (1, 2, 4), (4, 2, 4), (3, 4, 2, 4)] tests_to_run = ["check_r...
2] <= 2)) assert np.all((draws.sum(-2)[:, :, 3] > 3) & (draws.sum(-2)[:, :, 3] <= 5)) class TestDirichletMultinomial_1d_n_2d_a(BaseTestDistribution):
64
64
172
20
44
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestDirichletMultinomial_1d_n_2d_a
TestDirichletMultinomial_1d_n_2d_a
1,223
1,231
1,223
1,223
8c1cbce1d9d4e521dc95186eef2869d759feec76
bigcode/the-stack
train
4c31e7e02f55e2d9eae862c9
train
class
class TestWeibull(BaseTestDistribution): def weibull_rng_fn(self, size, alpha, beta, std_weibull_rng_fct): return beta * std_weibull_rng_fct(alpha, size=size) def seeded_weibul_rng_fn(self): std_weibull_rng_fct = functools.partial( getattr(np.random.RandomState, "weibull"), self.get...
class TestWeibull(BaseTestDistribution):
def weibull_rng_fn(self, size, alpha, beta, std_weibull_rng_fct): return beta * std_weibull_rng_fct(alpha, size=size) def seeded_weibul_rng_fn(self): std_weibull_rng_fct = functools.partial( getattr(np.random.RandomState, "weibull"), self.get_random_state() ) return ...
Mises pymc_dist_params = {"mu": -2.1, "kappa": 5} expected_rv_op_params = {"mu": -2.1, "kappa": 5} tests_to_run = ["check_pymc_params_match_rv_op"] class TestWeibull(BaseTestDistribution):
71
72
240
9
62
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestWeibull
TestWeibull
1,315
1,334
1,315
1,315
a6048be155388d126081ed72482b4980b0d0af82
bigcode/the-stack
train
b05dd7a259832b52a7ac1dd6
train
class
class TestRiceNu(BaseTestDistribution): pymc_dist = pm.Rice nu = sigma = 2 pymc_dist_params = {"nu": nu, "sigma": sigma} expected_rv_op_params = {"b": nu / sigma, "sigma": sigma} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestRiceNu(BaseTestDistribution):
pymc_dist = pm.Rice nu = sigma = 2 pymc_dist_params = {"nu": nu, "sigma": sigma} expected_rv_op_params = {"b": nu / sigma, "sigma": sigma} tests_to_run = ["check_pymc_params_match_rv_op"]
scale": sigma} reference_dist = seeded_scipy_distribution_builder("rice") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestRiceNu(BaseTestDistribution):
63
64
76
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestRiceNu
TestRiceNu
767
772
767
767
18f85b2d13cb5ec9223b0b9bd61c302f16335552
bigcode/the-stack
train
1df4102b66f5d006ac60b353
train
class
class TestTruncatedNormalUpperTau(BaseTestDistribution): pymc_dist = pm.TruncatedNormal lower, upper, mu, tau = -np.inf, 2.0, 0, 1.0 tau, sigma = get_tau_sigma(tau=tau, sigma=None) pymc_dist_params = {"mu": mu, "tau": tau, "upper": upper} expected_rv_op_params = {"mu": mu, "sigma": sigma, "lower": l...
class TestTruncatedNormalUpperTau(BaseTestDistribution):
pymc_dist = pm.TruncatedNormal lower, upper, mu, tau = -np.inf, 2.0, 0, 1.0 tau, sigma = get_tau_sigma(tau=tau, sigma=None) pymc_dist_params = {"mu": mu, "tau": tau, "upper": upper} expected_rv_op_params = {"mu": mu, "sigma": sigma, "lower": lower, "upper": upper} tests_to_run = [ "check...
"lower": lower} expected_rv_op_params = {"mu": mu, "sigma": sigma, "lower": lower, "upper": upper} tests_to_run = [ "check_pymc_params_match_rv_op", ] class TestTruncatedNormalUpperTau(BaseTestDistribution):
63
64
131
11
52
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestTruncatedNormalUpperTau
TestTruncatedNormalUpperTau
658
666
658
658
80964409311cbe090441035f4b6e3c580c202150
bigcode/the-stack
train
cc490b577d979c7765ff065e
train
class
class TestZeroInflatedPoisson(BaseTestDistribution): def zero_inflated_poisson_rng_fn(self, size, psi, theta, poisson_rng_fct, random_rng_fct): return poisson_rng_fct(theta, size=size) * (random_rng_fct(size=size) < psi) def seeded_zero_inflated_poisson_rng_fn(self): poisson_rng_fct = functools...
class TestZeroInflatedPoisson(BaseTestDistribution):
def zero_inflated_poisson_rng_fn(self, size, psi, theta, poisson_rng_fct, random_rng_fct): return poisson_rng_fct(theta, size=size) * (random_rng_fct(size=size) < psi) def seeded_zero_inflated_poisson_rng_fn(self): poisson_rng_fct = functools.partial( getattr(np.random.RandomState, ...
3} expected_rv_op_params = {"c": 3} reference_dist_params = {"c": 3} reference_dist = lambda self: self.constant_rng_fn tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestZeroInflatedPoisson(BaseTestDistribution...
88
89
298
11
77
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestZeroInflatedPoisson
TestZeroInflatedPoisson
1,408
1,436
1,408
1,408
5a857ed33644866992995cc08ccc058cb8ca60eb
bigcode/the-stack
train
621d52f3be06d082fe106f38
train
class
class TestLogNormal(BaseTestDistribution): pymc_dist = pm.LogNormal pymc_dist_params = {"mu": 1.0, "sigma": 5.0} expected_rv_op_params = {"mu": 1.0, "sigma": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestLogNormal(BaseTestDistribution):
pymc_dist = pm.LogNormal pymc_dist_params = {"mu": 1.0, "sigma": 5.0} expected_rv_op_params = {"mu": 1.0, "sigma": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"]
{"mu": 1.0, "s": 2.0} expected_rv_op_params = {"mu": 1.0, "s": 2.0} tests_to_run = ["check_pymc_params_match_rv_op"] class TestLogNormal(BaseTestDistribution):
63
64
78
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestLogNormal
TestLogNormal
1,274
1,278
1,274
1,274
fbffb96d83fd2c9e246d2baa7e6c42ecc12a869d
bigcode/the-stack
train
4c18fb185a5cdecdaa142da3
train
class
class TestSkewNormal(BaseTestDistribution): pymc_dist = pm.SkewNormal pymc_dist_params = {"mu": 0.0, "sigma": 1.0, "alpha": 5.0} expected_rv_op_params = {"mu": 0.0, "sigma": 1.0, "alpha": 5.0} reference_dist_params = {"loc": 0.0, "scale": 1.0, "a": 5.0} reference_dist = seeded_scipy_distribution_bui...
class TestSkewNormal(BaseTestDistribution):
pymc_dist = pm.SkewNormal pymc_dist_params = {"mu": 0.0, "sigma": 1.0, "alpha": 5.0} expected_rv_op_params = {"mu": 0.0, "sigma": 1.0, "alpha": 5.0} reference_dist_params = {"loc": 0.0, "scale": 1.0, "a": 5.0} reference_dist = seeded_scipy_distribution_builder("skewnorm") tests_to_run = [ ...
": phi, "alpha": alpha} expected_rv_op_params = {"mu": mu_rv, "lam": lam_rv, "alpha": alpha} tests_to_run = [ "check_pymc_params_match_rv_op", ] class TestSkewNormal(BaseTestDistribution):
63
64
163
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestSkewNormal
TestSkewNormal
732
742
732
732
74fb5a0be3653f055b76b82a356a4702cabec86d
bigcode/the-stack
train
e27443a2e2f7cbc82e7acc3d
train
class
class TestAsymmetricLaplace(BaseTestDistribution): def asymmetriclaplace_rng_fn(self, b, kappa, mu, size, uniform_rng_fct): u = uniform_rng_fct(size=size) switch = kappa ** 2 / (1 + kappa ** 2) non_positive_x = mu + kappa * np.log(u * (1 / switch)) / b positive_x = mu - np.log((1 - u...
class TestAsymmetricLaplace(BaseTestDistribution):
def asymmetriclaplace_rng_fn(self, b, kappa, mu, size, uniform_rng_fct): u = uniform_rng_fct(size=size) switch = kappa ** 2 / (1 + kappa ** 2) non_positive_x = mu + kappa * np.log(u * (1 / switch)) / b positive_x = mu - np.log((1 - u) * (1 + kappa ** 2)) / (kappa * b) draws =...
_rv_op_params = {"mu": 0.0, "b": 1.0} reference_dist_params = {"loc": 0.0, "scale": 1.0} reference_dist = seeded_scipy_distribution_builder("laplace") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestAsymmetricLapl...
104
105
351
10
94
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestAsymmetricLaplace
TestAsymmetricLaplace
499
524
499
499
62ccea15d3c19799cd323e10b5fc78addd249bcc
bigcode/the-stack
train
d4eb6c469c4f7e078358ad02
train
class
class TestCategorical(BaseTestDistribution): pymc_dist = pm.Categorical pymc_dist_params = {"p": np.array([0.28, 0.62, 0.10])} expected_rv_op_params = {"p": np.array([0.28, 0.62, 0.10])} tests_to_run = [ "check_pymc_params_match_rv_op", "check_rv_size", ]
class TestCategorical(BaseTestDistribution):
pymc_dist = pm.Categorical pymc_dist_params = {"p": np.array([0.28, 0.62, 0.10])} expected_rv_op_params = {"p": np.array([0.28, 0.62, 0.10])} tests_to_run = [ "check_pymc_params_match_rv_op", "check_rv_size", ]
, 4)] sizes_expected = [(2, 4), (1, 2, 4), (4, 2, 4), (3, 4, 2, 4)] tests_to_run = ["check_rv_size"] class TestCategorical(BaseTestDistribution):
63
64
99
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestCategorical
TestCategorical
1,234
1,241
1,234
1,234
ff5a0111ad18e4903cb639684730e5f9aeeaf395
bigcode/the-stack
train
5e4e1ea9c75c54f240fbb6a6
train
class
class TestExponential(BaseTestDistribution): pymc_dist = pm.Exponential pymc_dist_params = {"lam": 10.0} expected_rv_op_params = {"mu": 1.0 / pymc_dist_params["lam"]} reference_dist_params = {"scale": 1.0 / pymc_dist_params["lam"]} reference_dist = seeded_numpy_distribution_builder("exponential") ...
class TestExponential(BaseTestDistribution):
pymc_dist = pm.Exponential pymc_dist_params = {"lam": 10.0} expected_rv_op_params = {"mu": 1.0 / pymc_dist_params["lam"]} reference_dist_params = {"scale": 1.0 / pymc_dist_params["lam"]} reference_dist = seeded_numpy_distribution_builder("exponential") tests_to_run = [ "check_pymc_params...
mu=pymc_dist_params["mu"], sigma=pymc_dist_params["sigma"] ) expected_rv_op_params = {"alpha": expected_alpha, "beta": expected_beta} tests_to_run = ["check_pymc_params_match_rv_op"] class TestExponential(BaseTestDistribution):
63
64
116
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestExponential
TestExponential
900
909
900
900
3e2f05c03479a0a5947530f6d69277f86d45578e
bigcode/the-stack
train
ca6e71011e9090f9621399ee
train
class
class TestBetaMuSigma(BaseTestDistribution): pymc_dist = pm.Beta pymc_dist_params = {"mu": 0.5, "sigma": 0.25} expected_alpha, expected_beta = pm.Beta.get_alpha_beta( mu=pymc_dist_params["mu"], sigma=pymc_dist_params["sigma"] ) expected_rv_op_params = {"alpha": expected_alpha, "beta": expect...
class TestBetaMuSigma(BaseTestDistribution):
pymc_dist = pm.Beta pymc_dist_params = {"mu": 0.5, "sigma": 0.25} expected_alpha, expected_beta = pm.Beta.get_alpha_beta( mu=pymc_dist_params["mu"], sigma=pymc_dist_params["sigma"] ) expected_rv_op_params = {"alpha": expected_alpha, "beta": expected_beta} tests_to_run = ["check_pymc_para...
( clipped_beta_rvs, random_state=self.get_random_state() ) tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestBetaMuSigma(BaseTestDistribution):
63
64
110
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestBetaMuSigma
TestBetaMuSigma
890
897
890
890
ebe257468a8bfbaa3b983194fda6f6628c1cdc4a
bigcode/the-stack
train
f1dffd96233c243bbed112ad
train
class
class TestLaplace(BaseTestDistribution): pymc_dist = pm.Laplace pymc_dist_params = {"mu": 0.0, "b": 1.0} expected_rv_op_params = {"mu": 0.0, "b": 1.0} reference_dist_params = {"loc": 0.0, "scale": 1.0} reference_dist = seeded_scipy_distribution_builder("laplace") tests_to_run = [ "check_...
class TestLaplace(BaseTestDistribution):
pymc_dist = pm.Laplace pymc_dist_params = {"mu": 0.0, "b": 1.0} expected_rv_op_params = {"mu": 0.0, "b": 1.0} reference_dist_params = {"loc": 0.0, "scale": 1.0} reference_dist = seeded_scipy_distribution_builder("laplace") tests_to_run = [ "check_pymc_params_match_rv_op", "check_...
.0} reference_dist = seeded_scipy_distribution_builder("pareto") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestLaplace(BaseTestDistribution):
63
64
136
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestLaplace
TestLaplace
486
496
486
486
bd1385e472c9a6a888a05544f7c53b6c17d6511b
bigcode/the-stack
train
45c83cc2b0ef28485d104ace
train
class
class TestDensityDist: @pytest.mark.parametrize("size", [(), (3,), (3, 2)], ids=str) def test_density_dist_with_random(self, size): with pm.Model() as model: mu = pm.Normal("mu", 0, 1) obs = pm.DensityDist( "density_dist", mu, rando...
class TestDensityDist: @pytest.mark.parametrize("size", [(), (3,), (3, 2)], ids=str)
def test_density_dist_with_random(self, size): with pm.Model() as model: mu = pm.Normal("mu", 0, 1) obs = pm.DensityDist( "density_dist", mu, random=lambda mu, rng=None, size=None: rng.normal(loc=mu, scale=1, size=size), ...
to be refactored rand0, rand1, rand2, rand3 = [None] * 4 # draw_values( # [like0, like1, like2, like3], point=m.initial_point, size=100 # ) assert rand0.shape == (100, 20) assert rand1.shape == (100, 20) assert rand2.shape == (100, 20) assert rand3.shape == (100, 20) class TestDensityD...
133
133
445
27
106
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestDensityDist
TestDensityDist
1,842
1,890
1,842
1,843
159e54ebb8589323a8c7fcb2785741ca3b905baf
bigcode/the-stack
train
46d4bfbb52fa2324aaec5036
train
class
class TestMvNormalChol(BaseTestDistribution): pymc_dist = pm.MvNormal pymc_dist_params = { "mu": np.array([1.0, 2.0]), "chol": np.array([[2.0, 0.0], [0.0, 3.5]]), } expected_rv_op_params = { "mu": np.array([1.0, 2.0]), "cov": quaddist_matrix(chol=pymc_dist_params["chol"])...
class TestMvNormalChol(BaseTestDistribution):
pymc_dist = pm.MvNormal pymc_dist_params = { "mu": np.array([1.0, 2.0]), "chol": np.array([[2.0, 0.0], [0.0, 3.5]]), } expected_rv_op_params = { "mu": np.array([1.0, 2.0]), "cov": quaddist_matrix(chol=pymc_dist_params["chol"]).eval(), } tests_to_run = ["check_pymc...
} reference_dist = seeded_numpy_distribution_builder("multivariate_normal") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestMvNormalChol(BaseTestDistribution):
63
64
134
10
53
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestMvNormalChol
TestMvNormalChol
1,073
1,083
1,073
1,073
81c6bb99a4939b017ff91e7559f5fd7d824bcd47
bigcode/the-stack
train
9820869909db2b220a119e6b
train
class
class TestStudentT(BaseTestDistribution): pymc_dist = pm.StudentT pymc_dist_params = {"nu": 5.0, "mu": -1.0, "sigma": 2.0} expected_rv_op_params = {"nu": 5.0, "mu": -1.0, "sigma": 2.0} reference_dist_params = {"df": 5.0, "loc": -1.0, "scale": 2.0} reference_dist = seeded_scipy_distribution_builder("...
class TestStudentT(BaseTestDistribution):
pymc_dist = pm.StudentT pymc_dist_params = {"nu": 5.0, "mu": -1.0, "sigma": 2.0} expected_rv_op_params = {"nu": 5.0, "mu": -1.0, "sigma": 2.0} reference_dist_params = {"df": 5.0, "loc": -1.0, "scale": 2.0} reference_dist = seeded_scipy_distribution_builder("t") tests_to_run = [ "check_py...
"scale": 3.0} reference_dist = seeded_scipy_distribution_builder("gumbel_r") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", ] class TestStudentT(BaseTestDistribution):
63
64
158
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestStudentT
TestStudentT
569
579
569
569
0e46c6363b9b2e7f9a9c244a83dd17123e1166de
bigcode/the-stack
train
8f262ad515589224bebe91a6
train
class
class TestBinomial(BaseTestDistribution): pymc_dist = pm.Binomial pymc_dist_params = {"n": 100, "p": 0.33} expected_rv_op_params = {"n": 100, "p": 0.33} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestBinomial(BaseTestDistribution):
pymc_dist = pm.Binomial pymc_dist_params = {"n": 100, "p": 0.33} expected_rv_op_params = {"n": 100, "p": 0.33} tests_to_run = ["check_pymc_params_match_rv_op"]
2.0} reference_dist = seeded_numpy_distribution_builder("chisquare") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestBinomial(BaseTestDistribution):
63
64
75
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestBinomial
TestBinomial
996
1,000
996
996
2a63df46ea23289614d7da3885ea5ddf74b327f5
bigcode/the-stack
train
3aedf377ff53a7125e46d8d0
train
class
class TestHalfNormalSd(BaseTestDistribution): pymc_dist = pm.Normal pymc_dist_params = {"sd": 5.0} expected_rv_op_params = {"mu": 0.0, "sigma": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestHalfNormalSd(BaseTestDistribution):
pymc_dist = pm.Normal pymc_dist_params = {"sd": 5.0} expected_rv_op_params = {"mu": 0.0, "sigma": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"]
(tau=25.0) pymc_dist_params = {"tau": tau} expected_rv_op_params = {"mu": 0.0, "sigma": sigma} tests_to_run = ["check_pymc_params_match_rv_op"] class TestHalfNormalSd(BaseTestDistribution):
63
64
70
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestHalfNormalSd
TestHalfNormalSd
867
871
867
867
e6fa9180099b872f9ccba7e0bbba54879677bb74
bigcode/the-stack
train
f7e28521d9bf9fa30fd9e721
train
class
class TestHyperGeometric(BaseTestDistribution): pymc_dist = pm.HyperGeometric pymc_dist_params = {"N": 20, "k": 12, "n": 5} expected_rv_op_params = { "ngood": pymc_dist_params["k"], "nbad": pymc_dist_params["N"] - pymc_dist_params["k"], "nsample": pymc_dist_params["n"], } ref...
class TestHyperGeometric(BaseTestDistribution):
pymc_dist = pm.HyperGeometric pymc_dist_params = {"N": 20, "k": 12, "n": 5} expected_rv_op_params = { "ngood": pymc_dist_params["k"], "nbad": pymc_dist_params["N"] - pymc_dist_params["k"], "nsample": pymc_dist_params["n"], } reference_dist_params = expected_rv_op_params r...
pymc_dist = pm.Geometric pymc_dist_params = {"p": 0.9} expected_rv_op_params = {"p": 0.9} tests_to_run = ["check_pymc_params_match_rv_op"] class TestHyperGeometric(BaseTestDistribution):
63
64
153
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestHyperGeometric
TestHyperGeometric
1,251
1,264
1,251
1,251
e2f01f4923ce47fb99ea18d8bf567945676f06e7
bigcode/the-stack
train
68b86d3d88e3dd89827fb36e
train
class
class BaseTestDistribution(SeededTest): """ This class provides a base for tests that new RandomVariables are correctly implemented, and that the mapping of parameters between the PyMC Distribution and the respective RandomVariable is correct. Three default tests are provided which check: 1. Ex...
class BaseTestDistribution(SeededTest):
""" This class provides a base for tests that new RandomVariables are correctly implemented, and that the mapping of parameters between the PyMC Distribution and the respective RandomVariable is correct. Three default tests are provided which check: 1. Expected inputs are passed to the `rv_op` ...
.sample_random_variable(rv, size)) assert ( expected == actual ), f"Sample size {size} from {shape}-shaped RV had shape {actual}. Expected: {expected}" @pytest.mark.xfail(reason="This distribution has not been refactored for v4") class TestGaussianRandomWalk(BaseTestCases.BaseT...
256
256
1,507
9
247
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
BaseTestDistribution
BaseTestDistribution
270
406
270
270
33d4d81a8b74398ac750aff1b169e8ed4812be9c
bigcode/the-stack
train
1525268bee1d65092dc78b78
train
class
class TestKroneckerNormal(BaseTestDistribution): def kronecker_rng_fn(self, size, mu, covs=None, sigma=None, rng=None): cov = pm.math.kronecker(covs[0], covs[1]).eval() cov += sigma ** 2 * np.identity(cov.shape[0]) return st.multivariate_normal.rvs(mean=mu, cov=cov, size=size) pymc_dist...
class TestKroneckerNormal(BaseTestDistribution):
def kronecker_rng_fn(self, size, mu, covs=None, sigma=None, rng=None): cov = pm.math.kronecker(covs[0], covs[1]).eval() cov += sigma ** 2 * np.identity(cov.shape[0]) return st.multivariate_normal.rvs(mean=mu, cov=cov, size=size) pymc_dist = pm.KroneckerNormal n = 3 N = n ** 2 ...
x_points = np.linspace(mu - 5 * sigma, mu + 5 * sigma, 100) pdf_points = st.norm.pdf(x_points, loc=mu, scale=sigma) return super().dist(x_points=x_points, pdf_points=pdf_points, **kwargs) pymc_random( TestedInte...
103
103
346
10
93
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestKroneckerNormal
TestKroneckerNormal
1,691
1,717
1,691
1,691
e2ccbbb63b016b896f974a2c12151fc7dd81052b
bigcode/the-stack
train
b9552e36a4c7b64d39567cce
train
class
class TestMoyal(BaseTestDistribution): pymc_dist = pm.Moyal pymc_dist_params = {"mu": 0.0, "sigma": 1.0} expected_rv_op_params = {"mu": 0.0, "sigma": 1.0} reference_dist_params = {"loc": 0.0, "scale": 1.0} reference_dist = seeded_scipy_distribution_builder("moyal") tests_to_run = [ "chec...
class TestMoyal(BaseTestDistribution):
pymc_dist = pm.Moyal pymc_dist_params = {"mu": 0.0, "sigma": 1.0} expected_rv_op_params = {"mu": 0.0, "sigma": 1.0} reference_dist_params = {"loc": 0.0, "scale": 1.0} reference_dist = seeded_scipy_distribution_builder("moyal") tests_to_run = [ "check_pymc_params_match_rv_op", "ch...
2.0} reference_dist = seeded_scipy_distribution_builder("t") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestMoyal(BaseTestDistribution):
63
64
135
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestMoyal
TestMoyal
582
592
582
582
e7f93e8b42d791b74e7832136d3b158940424433
bigcode/the-stack
train
fea240a47ffa1959645f84ef
train
class
@pytest.mark.skip(reason="This test is covered by Aesara") class TestMvNormal(SeededTest): @pytest.mark.parametrize( ["sample_shape", "dist_shape", "mu_shape", "param"], generate_shapes(include_params=True), ids=str, ) def test_with_np_arrays(self, sample_shape, dist_shape, mu_shape,...
@pytest.mark.skip(reason="This test is covered by Aesara") class TestMvNormal(SeededTest): @pytest.mark.parametrize( ["sample_shape", "dist_shape", "mu_shape", "param"], generate_shapes(include_params=True), ids=str, )
def test_with_np_arrays(self, sample_shape, dist_shape, mu_shape, param): dist = pm.MvNormal.dist(mu=np.ones(mu_shape), **{param: np.eye(3)}, shape=dist_shape) output_shape = to_tuple(sample_shape) + dist_shape assert dist.random(size=sample_shape).shape == output_shape @pytest.mark.par...
_params=False): # fmt: off mudim_as_event = [ [None, 1, 3, 10, (10, 3), 100], [(3,)], [(1,), (3,)], ["cov", "chol", "tau"] ] # fmt: on mudim_as_dist = [ [None, 1, 3, 10, (10, 3), 100], [(10, 3)], [(1,), (3,), (1, 1), (1, 3), (10, 1), (10, 3)], ...
256
256
912
58
197
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestMvNormal
TestMvNormal
2,201
2,282
2,201
2,207
99a8e69fd19d77c72a0063afbeb17814738805d2
bigcode/the-stack
train
7f3c83bf05830b0a15d3075d
train
class
class TestNormalTau(BaseTestDistribution): pymc_dist = pm.Normal tau, sigma = get_tau_sigma(tau=25.0) pymc_dist_params = {"mu": 1.0, "tau": tau} expected_rv_op_params = {"mu": 1.0, "sigma": sigma} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestNormalTau(BaseTestDistribution):
pymc_dist = pm.Normal tau, sigma = get_tau_sigma(tau=25.0) pymc_dist_params = {"mu": 1.0, "tau": tau} expected_rv_op_params = {"mu": 1.0, "sigma": sigma} tests_to_run = ["check_pymc_params_match_rv_op"]
pymc_dist_params = {"mu": 1.0, "tau": tau} expected_rv_op_params = {"mu": 1.0, "sigma": sigma} tests_to_run = ["check_pymc_params_match_rv_op"] class TestNormalTau(BaseTestDistribution):
63
64
86
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestNormalTau
TestNormalTau
825
830
825
825
5e24c0fbdc3d802599b9a7fbf28e936ec3429ade
bigcode/the-stack
train
df6435d4b812deb874872ba4
train
function
@pytest.mark.xfail(reason="This distribution has not been refactored for v4") def test_mixture_random_shape(): # test the shape broadcasting in mixture random y = np.concatenate([nr.poisson(5, size=10), nr.poisson(9, size=10)]) with pm.Model() as m: comp0 = pm.Poisson.dist(mu=np.ones(2)) w0 ...
@pytest.mark.xfail(reason="This distribution has not been refactored for v4") def test_mixture_random_shape(): # test the shape broadcasting in mixture random
y = np.concatenate([nr.poisson(5, size=10), nr.poisson(9, size=10)]) with pm.Model() as m: comp0 = pm.Poisson.dist(mu=np.ones(2)) w0 = pm.Dirichlet("w0", a=np.ones(2), shape=(2,)) like0 = pm.Mixture("like0", w=w0, comp_dists=comp0, observed=y) comp1 = pm.Poisson.dist(mu=np.ones(...
extra_args={"comp_shape": 2}, size=1000, ref_rand=ref_rand, ) pymc_random( pm.NormalMixture, { "w": Simplex(3), "mu": Domain([[-5.0, 1.0, 2.5]], edges=(None, None)), "sigma": Domain([[1.5, 2.0, 3....
162
162
540
35
127
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
test_mixture_random_shape
test_mixture_random_shape
1,773
1,808
1,773
1,775
9615dd9f95b0d4358e0ce800274f11f9757fcead
bigcode/the-stack
train
cfb8ab07fb05f4f59929f59a
train
class
class BaseTestCases: class BaseTestCase(SeededTest): shape = 5 # the following are the default values of the distribution that take effect # when the parametrized shape/size in the test case is None. # For every distribution that defaults to non-scalar shapes they must be # s...
class BaseTestCases:
class BaseTestCase(SeededTest): shape = 5 # the following are the default values of the distribution that take effect # when the parametrized shape/size in the test case is None. # For every distribution that defaults to non-scalar shapes they must be # specified by the inher...
, v in pt.items(): nv = param_vars.get(k, model.named_vars.get(k)) if nv.name in param_vars: param_vars[nv.name].set_value(v) # Allow Chisq test to fail (i.e., the samples be different) # a certain number of times. f = fails while p <= alpha and f...
256
256
1,021
5
251
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
BaseTestCases
BaseTestCases
155
248
155
155
f18074f920c0113845a7b432eb6dcea4ab2dda58
bigcode/the-stack
train
66d205067f8978eb89ce53f8
train
function
def pymc_random( dist, paramdomains, ref_rand, valuedomain=None, size=10000, alpha=0.05, fails=10, extra_args=None, model_args=None, ): if valuedomain is None: valuedomain = Domain([0], edges=(None, None)) if model_args is None: model_args = {} model, pa...
def pymc_random( dist, paramdomains, ref_rand, valuedomain=None, size=10000, alpha=0.05, fails=10, extra_args=None, model_args=None, ):
if valuedomain is None: valuedomain = Domain([0], edges=(None, None)) if model_args is None: model_args = {} model, param_vars = build_model(dist, valuedomain, paramdomains, extra_args) model_dist = change_rv_size(model.named_vars["value"], size, expand=True) pymc_rand = aesara.fun...
_tuple from pymc.tests.helpers import SeededTest, select_by_precision from pymc.tests.test_distributions import ( Domain, R, RandomPdMatrix, Rplus, Simplex, build_model, product, ) def pymc_random( dist, paramdomains, ref_rand, valuedomain=None, size=10000, alpha=0.05...
102
102
343
50
52
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
pymc_random
pymc_random
63
104
63
73
976b1be4d632af92a54dd9301bef35fba623eced
bigcode/the-stack
train
bca42d6358f31130172d9e5c
train
class
class TestPareto(BaseTestDistribution): pymc_dist = pm.Pareto pymc_dist_params = {"alpha": 3.0, "m": 2.0} expected_rv_op_params = {"alpha": 3.0, "m": 2.0} reference_dist_params = {"b": 3.0, "scale": 2.0} reference_dist = seeded_scipy_distribution_builder("pareto") tests_to_run = [ "check...
class TestPareto(BaseTestDistribution):
pymc_dist = pm.Pareto pymc_dist_params = {"alpha": 3.0, "m": 2.0} expected_rv_op_params = {"alpha": 3.0, "m": 2.0} reference_dist_params = {"b": 3.0, "scale": 2.0} reference_dist = seeded_scipy_distribution_builder("pareto") tests_to_run = [ "check_pymc_params_match_rv_op", "chec...
2.0} reference_dist = seeded_discrete_weibul_rng_fn tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestPareto(BaseTestDistribution):
63
64
136
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestPareto
TestPareto
473
483
473
473
ca512038dd3b375ed60f4b996c02ab028f07c993
bigcode/the-stack
train
89662870ed353d81ad7bb744
train
class
class TestBernoulliLogitP(BaseTestDistribution): pymc_dist = pm.Bernoulli pymc_dist_params = {"logit_p": 1.0} expected_rv_op_params = {"p": expit(1.0)} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestBernoulliLogitP(BaseTestDistribution):
pymc_dist = pm.Bernoulli pymc_dist_params = {"logit_p": 1.0} expected_rv_op_params = {"p": expit(1.0)} tests_to_run = ["check_pymc_params_match_rv_op"]
0.33} reference_dist = seeded_scipy_distribution_builder("bernoulli") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", ] class TestBernoulliLogitP(BaseTestDistribution):
63
64
72
12
51
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestBernoulliLogitP
TestBernoulliLogitP
1,035
1,039
1,035
1,035
a5d856973bc06791c3c33afcc4b8ab325363338f
bigcode/the-stack
train
de3a4272d187ab898aa73bc1
train
class
class TestDirichletMultinomial(BaseTestDistribution): pymc_dist = pm.DirichletMultinomial pymc_dist_params = {"n": 85, "a": np.array([1.0, 2.0, 1.5, 1.5])} expected_rv_op_params = {"n": 85, "a": np.array([1.0, 2.0, 1.5, 1.5])} sizes_to_check = [None, 1, (4,), (3, 4)] sizes_expected = [(4,), (1, 4)...
class TestDirichletMultinomial(BaseTestDistribution):
pymc_dist = pm.DirichletMultinomial pymc_dist_params = {"n": 85, "a": np.array([1.0, 2.0, 1.5, 1.5])} expected_rv_op_params = {"n": 85, "a": np.array([1.0, 2.0, 1.5, 1.5])} sizes_to_check = [None, 1, (4,), (3, 4)] sizes_expected = [(4,), (1, 4), (4, 4), (3, 4, 4)] tests_to_run = [ "ch...
1), (4,), (3, 2)] sizes_expected = [(3,), (1, 3), (4, 3), (3, 2, 3)] reference_dist_params = {"n": 85, "pvals": np.array([0.28, 0.62, 0.10])} reference_dist = seeded_numpy_distribution_builder("multinomial") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_refere...
135
136
456
12
123
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestDirichletMultinomial
TestDirichletMultinomial
1,193
1,220
1,193
1,193
6f4d4df9a3b8516c7821ad92fd111e670608ec3c
bigcode/the-stack
train
ecd9ed65c3663d4482838684
train
class
class TestUniform(BaseTestDistribution): pymc_dist = pm.Uniform pymc_dist_params = {"lower": 0.5, "upper": 1.5} expected_rv_op_params = {"lower": 0.5, "upper": 1.5} tests_to_run = ["check_pymc_params_match_rv_op"]
class TestUniform(BaseTestDistribution):
pymc_dist = pm.Uniform pymc_dist_params = {"lower": 0.5, "upper": 1.5} expected_rv_op_params = {"lower": 0.5, "upper": 1.5} tests_to_run = ["check_pymc_params_match_rv_op"]
= {"mu": 1.0, "sd": 5.0} expected_rv_op_params = {"mu": 1.0, "sigma": 5.0} tests_to_run = ["check_pymc_params_match_rv_op"] class TestUniform(BaseTestDistribution):
63
64
77
7
56
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestUniform
TestUniform
840
844
840
840
fa07f9e003d66c91568e1358ab5ece270f4141c8
bigcode/the-stack
train
5f1ef292533c78282331fe5f
train
class
class TestExGaussian(BaseTestDistribution): def exgaussian_rng_fn(self, mu, sigma, nu, size, normal_rng_fct, exponential_rng_fct): return normal_rng_fct(mu, sigma, size=size) + exponential_rng_fct(scale=nu, size=size) def seeded_exgaussian_rng_fn(self): normal_rng_fct = functools.partial( ...
class TestExGaussian(BaseTestDistribution):
def exgaussian_rng_fn(self, mu, sigma, nu, size, normal_rng_fct, exponential_rng_fct): return normal_rng_fct(mu, sigma, size=size) + exponential_rng_fct(scale=nu, size=size) def seeded_exgaussian_rng_fn(self): normal_rng_fct = functools.partial( getattr(np.random.RandomState, "norma...
.0} reference_dist_params = {"b": 1.0, "kappa": 1.0, "mu": 0.0} reference_dist = seeded_asymmetriclaplace_rng_fn tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestExGaussian(BaseTestDistribution):
91
92
309
8
83
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestExGaussian
TestExGaussian
527
554
527
527
616740fd487265746db59a467f5db77d6c33c4b6
bigcode/the-stack
train
5094e8e93c1a2f1c83e79e45
train
class
class TestOrderedProbit(BaseTestDistribution): pymc_dist = _OrderedProbit pymc_dist_params = {"eta": 0, "cutpoints": np.array([-2, 0, 2])} expected_rv_op_params = {"p": np.array([0.02275013, 0.47724987, 0.47724987, 0.02275013])} tests_to_run = [ "check_pymc_params_match_rv_op", "check_rv...
class TestOrderedProbit(BaseTestDistribution):
pymc_dist = _OrderedProbit pymc_dist_params = {"eta": 0, "cutpoints": np.array([-2, 0, 2])} expected_rv_op_params = {"p": np.array([0.02275013, 0.47724987, 0.47724987, 0.02275013])} tests_to_run = [ "check_pymc_params_match_rv_op", "check_rv_size", ]
.11920292, 0.38079708, 0.38079708, 0.11920292])} tests_to_run = [ "check_pymc_params_match_rv_op", "check_rv_size", ] class TestOrderedProbit(BaseTestDistribution):
63
64
115
9
54
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestOrderedProbit
TestOrderedProbit
1,515
1,522
1,515
1,515
15abce76bf071747695e0b2c3b2f3377eb70c6e2
bigcode/the-stack
train
f0fdf61508e36129d93729e5
train
class
class TestMultinomial(BaseTestDistribution): pymc_dist = pm.Multinomial pymc_dist_params = {"n": 85, "p": np.array([0.28, 0.62, 0.10])} expected_rv_op_params = {"n": 85, "p": np.array([0.28, 0.62, 0.10])} sizes_to_check = [None, (1), (4,), (3, 2)] sizes_expected = [(3,), (1, 3), (4, 3), (3, 2, 3)] ...
class TestMultinomial(BaseTestDistribution):
pymc_dist = pm.Multinomial pymc_dist_params = {"n": 85, "p": np.array([0.28, 0.62, 0.10])} expected_rv_op_params = {"n": 85, "p": np.array([0.28, 0.62, 0.10])} sizes_to_check = [None, (1), (4,), (3, 2)] sizes_expected = [(3,), (1, 3), (4, 3), (3, 2, 3)] reference_dist_params = {"n": 85, "pvals":...
.0])} reference_dist = seeded_numpy_distribution_builder("dirichlet") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestMultinomial(BaseTestDistribution):
64
65
218
9
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestMultinomial
TestMultinomial
1,178
1,190
1,178
1,178
387afc1487ea3b23dc041b4e43fd2510be51b127
bigcode/the-stack
train
c86d441c5362c3ed67231311
train
class
class TestZeroInflatedBinomial(BaseTestDistribution): def zero_inflated_binomial_rng_fn(self, size, psi, n, p, binomial_rng_fct, random_rng_fct): return binomial_rng_fct(n, p, size=size) * (random_rng_fct(size=size) < psi) def seeded_zero_inflated_binomial_rng_fn(self): binomial_rng_fct = funct...
class TestZeroInflatedBinomial(BaseTestDistribution):
def zero_inflated_binomial_rng_fn(self, size, psi, n, p, binomial_rng_fct, random_rng_fct): return binomial_rng_fct(n, p, size=size) * (random_rng_fct(size=size) < psi) def seeded_zero_inflated_binomial_rng_fn(self): binomial_rng_fct = functools.partial( getattr(np.random.RandomStat...
0.9, "theta": 4.0} reference_dist_params = {"psi": 0.9, "theta": 4.0} reference_dist = seeded_zero_inflated_poisson_rng_fn tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", "check_rv_size", ] class TestZeroInflatedBinomial(BaseTestDistribution)...
96
97
324
11
85
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestZeroInflatedBinomial
TestZeroInflatedBinomial
1,439
1,467
1,439
1,439
e939f3abb249392ab73924e15af3b98a90f18036
bigcode/the-stack
train
470d134e912eb4e80aacba3d
train
class
class TestHalfNormal(BaseTestDistribution): pymc_dist = pm.HalfNormal pymc_dist_params = {"sigma": 10.0} expected_rv_op_params = {"mean": 0, "sigma": 10.0} reference_dist_params = {"loc": 0, "scale": 10.0} reference_dist = seeded_scipy_distribution_builder("halfnorm") tests_to_run = [ "c...
class TestHalfNormal(BaseTestDistribution):
pymc_dist = pm.HalfNormal pymc_dist_params = {"sigma": 10.0} expected_rv_op_params = {"mean": 0, "sigma": 10.0} reference_dist_params = {"loc": 0, "scale": 10.0} reference_dist = seeded_scipy_distribution_builder("halfnorm") tests_to_run = [ "check_pymc_params_match_rv_op", "chec...
{"lower": 0.5, "upper": 1.5} expected_rv_op_params = {"lower": 0.5, "upper": 1.5} tests_to_run = ["check_pymc_params_match_rv_op"] class TestHalfNormal(BaseTestDistribution):
63
64
118
8
55
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestHalfNormal
TestHalfNormal
847
856
847
847
e75421bbabcb503a1370d76e082d027a7160363b
bigcode/the-stack
train
d37f101d472ecf7110950fc0
train
class
@pytest.mark.xfail(reason="This distribution has not been refactored for v4") class TestZeroInflatedBinomial(BaseTestCases.BaseTestCase): distribution = pm.ZeroInflatedBinomial params = {"n": 10, "p": 0.6, "psi": 0.3}
@pytest.mark.xfail(reason="This distribution has not been refactored for v4") class TestZeroInflatedBinomial(BaseTestCases.BaseTestCase):
distribution = pm.ZeroInflatedBinomial params = {"n": 10, "p": 0.6, "psi": 0.3}
atedNegativeBinomial params = {"mu": 1.0, "alpha": 1.0, "psi": 0.3} @pytest.mark.xfail(reason="This distribution has not been refactored for v4") class TestZeroInflatedBinomial(BaseTestCases.BaseTestCase):
64
64
67
32
32
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestZeroInflatedBinomial
TestZeroInflatedBinomial
264
267
264
265
b122d90129583dce95b4b3edfc4d4e2fbf3ccf6e
bigcode/the-stack
train
b73d3f89e52f014a8dd4d93d
train
class
class TestTruncatedNormalLowerTau(BaseTestDistribution): pymc_dist = pm.TruncatedNormal lower, upper, mu, tau = -2.0, np.inf, 0, 1.0 tau, sigma = get_tau_sigma(tau=tau, sigma=None) pymc_dist_params = {"mu": mu, "tau": tau, "lower": lower} expected_rv_op_params = {"mu": mu, "sigma": sigma, "lower": l...
class TestTruncatedNormalLowerTau(BaseTestDistribution):
pymc_dist = pm.TruncatedNormal lower, upper, mu, tau = -2.0, np.inf, 0, 1.0 tau, sigma = get_tau_sigma(tau=tau, sigma=None) pymc_dist_params = {"mu": mu, "tau": tau, "lower": lower} expected_rv_op_params = {"mu": mu, "sigma": sigma, "lower": lower, "upper": upper} tests_to_run = [ "check...
"upper": upper} expected_rv_op_params = {"mu": mu, "sigma": sigma, "lower": lower, "upper": upper} tests_to_run = [ "check_pymc_params_match_rv_op", ] class TestTruncatedNormalLowerTau(BaseTestDistribution):
63
64
130
11
52
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestTruncatedNormalLowerTau
TestTruncatedNormalLowerTau
647
655
647
647
bd68aec0e9e3320c1625191a45bf1bb0e78308d8
bigcode/the-stack
train
24a56bb84c5dcbcd34312889
train
class
class TestGamma(BaseTestDistribution): pymc_dist = pm.Gamma pymc_dist_params = {"alpha": 2.0, "beta": 5.0} expected_rv_op_params = {"alpha": 2.0, "beta": 1 / 5.0} reference_dist_params = {"shape": 2.0, "scale": 1 / 5.0} reference_dist = seeded_numpy_distribution_builder("gamma") tests_to_run = [...
class TestGamma(BaseTestDistribution):
pymc_dist = pm.Gamma pymc_dist_params = {"alpha": 2.0, "beta": 5.0} expected_rv_op_params = {"alpha": 2.0, "beta": 1 / 5.0} reference_dist_params = {"shape": 2.0, "scale": 1 / 5.0} reference_dist = seeded_numpy_distribution_builder("gamma") tests_to_run = [ "check_pymc_params_match_rv_op...
, "scale": 5.0} reference_dist = seeded_scipy_distribution_builder("halfcauchy") tests_to_run = [ "check_pymc_params_match_rv_op", "check_pymc_draws_match_reference", ] class TestGamma(BaseTestDistribution):
63
64
130
7
56
MarcoGorelli/pymc
pymc/tests/test_distributions_random.py
Python
TestGamma
TestGamma
936
945
936
936
1bff2d1d909a3900b9118fb608b7e4242ded7c87
bigcode/the-stack
train
f79df05607d679e474c23fbc
train
function
def cpu_events_per_second(data: str, **kwargs) -> float: """Returns events per second.""" return float(re.compile(STD_REGEX).search(data).group(1))
def cpu_events_per_second(data: str, **kwargs) -> float:
"""Returns events per second.""" return float(re.compile(STD_REGEX).search(data).group(1))
"cpu": SAMPLE_CPU_DATA, "memory": SAMPLE_MEMORY_DATA, "mutex": SAMPLE_MUTEX_DATA, "randwr": SAMPLE_CPU_DATA } return switch[test] # pylint: disable=unused-argument def cpu_events_per_second(data: str, **kwargs) -> float:
64
64
38
15
48
Simon-Zh-0409/gvisor
benchmarks/workloads/sysbench/__init__.py
Python
cpu_events_per_second
cpu_events_per_second
137
139
137
137
a0a009e7ae7db18e41aa90b4d9eea1ba4b2f573a
bigcode/the-stack
train
deb9c1da07b05228297e5c64
train
function
def mutex_deviation(data: str, **kwargs) -> float: """Returns deviation for threads.""" return float(re.compile(ALT_REGEX).search(data).group(2))
def mutex_deviation(data: str, **kwargs) -> float:
"""Returns deviation for threads.""" return float(re.compile(ALT_REGEX).search(data).group(2))
search(data).group(1)) contention = float(threads) / float(locks) scale = contention * float(count) / 100000000.0 return value / scale # pylint: disable=unused-argument def mutex_deviation(data: str, **kwargs) -> float:
64
64
37
14
49
Simon-Zh-0409/gvisor
benchmarks/workloads/sysbench/__init__.py
Python
mutex_deviation
mutex_deviation
159
161
159
159
197a7337abc8a010760e0152c056494ea3078001
bigcode/the-stack
train
33867161b5d015bf28bbf55c
train
function
def mutex_latency(data: str, **kwargs) -> float: """Returns average mutex latency.""" return float(re.compile(AVG_REGEX).search(data).group(1))
def mutex_latency(data: str, **kwargs) -> float:
"""Returns average mutex latency.""" return float(re.compile(AVG_REGEX).search(data).group(1))
=unused-argument def mutex_deviation(data: str, **kwargs) -> float: """Returns deviation for threads.""" return float(re.compile(ALT_REGEX).search(data).group(2)) # pylint: disable=unused-argument def mutex_latency(data: str, **kwargs) -> float:
64
64
36
13
50
Simon-Zh-0409/gvisor
benchmarks/workloads/sysbench/__init__.py
Python
mutex_latency
mutex_latency
165
167
165
165
4006300088de441bb784435511533d1e02f9dd76
bigcode/the-stack
train
eb7f978a16262b5ea2ac1f55
train
function
def mutex_time(data: str, count: int, locks: int, threads: int, **kwargs) -> float: """Returns normalized mutex time (lower is better).""" value = float(re.compile(ALT_REGEX).search(data).group(1)) contention = float(threads) / float(locks) scale = contention * float(count) / 100000000.0 return...
def mutex_time(data: str, count: int, locks: int, threads: int, **kwargs) -> float:
"""Returns normalized mutex time (lower is better).""" value = float(re.compile(ALT_REGEX).search(data).group(1)) contention = float(threads) / float(locks) scale = contention * float(count) / 100000000.0 return value / scale
kwargs) -> float: """Returns memory operations per second.""" return float(re.compile(MEM_REGEX).search(data).group(1)) # pylint: disable=unused-argument def mutex_time(data: str, count: int, locks: int, threads: int, **kwargs) -> float:
64
64
89
26
37
Simon-Zh-0409/gvisor
benchmarks/workloads/sysbench/__init__.py
Python
mutex_time
mutex_time
149
155
149
150
707646b8860c0cde7be5ae3d7c486401dbed9359
bigcode/the-stack
train
416d618c64927017bed1ed0c
train
function
def memory_ops_per_second(data: str, **kwargs) -> float: """Returns memory operations per second.""" return float(re.compile(MEM_REGEX).search(data).group(1))
def memory_ops_per_second(data: str, **kwargs) -> float:
"""Returns memory operations per second.""" return float(re.compile(MEM_REGEX).search(data).group(1))
argument def cpu_events_per_second(data: str, **kwargs) -> float: """Returns events per second.""" return float(re.compile(STD_REGEX).search(data).group(1)) # pylint: disable=unused-argument def memory_ops_per_second(data: str, **kwargs) -> float:
64
64
39
15
48
Simon-Zh-0409/gvisor
benchmarks/workloads/sysbench/__init__.py
Python
memory_ops_per_second
memory_ops_per_second
143
145
143
143
155a57ae0de19377e153de4394823f961286a057
bigcode/the-stack
train
1511dd4aa8be6593745a2f51
train
function
def sample(test, **kwargs): switch = { "cpu": SAMPLE_CPU_DATA, "memory": SAMPLE_MEMORY_DATA, "mutex": SAMPLE_MUTEX_DATA, "randwr": SAMPLE_CPU_DATA } return switch[test]
def sample(test, **kwargs):
switch = { "cpu": SAMPLE_CPU_DATA, "memory": SAMPLE_MEMORY_DATA, "mutex": SAMPLE_MUTEX_DATA, "randwr": SAMPLE_CPU_DATA } return switch[test]
30032.28 Threads fairness: events (avg/stddev): 1.0000/0.00 execution time (avg/stddev): 3.7540/0.03 """ # pylint: disable=unused-argument def sample(test, **kwargs):
64
64
51
7
56
Simon-Zh-0409/gvisor
benchmarks/workloads/sysbench/__init__.py
Python
sample
sample
126
133
126
126
f8eb74909b55c60a4b4a555ff742b018c4ca2db7
bigcode/the-stack
train
a24418003f97650b8ad5f316
train
function
def generate_launch_description(): num_samples = LaunchConfiguration('num_samples') chain_start = LaunchConfiguration('chain_start') chain_end = LaunchConfiguration('chain_end') timeout = LaunchConfiguration('timeout') pkg_share = FindPackageShare('trac_ik_examples').find('trac_ik_examples') ur...
def generate_launch_description():
num_samples = LaunchConfiguration('num_samples') chain_start = LaunchConfiguration('chain_start') chain_end = LaunchConfiguration('chain_end') timeout = LaunchConfiguration('timeout') pkg_share = FindPackageShare('trac_ik_examples').find('trac_ik_examples') urdf_file = os.path.join(pkg_share, '...
OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration from launch_ros.actions i...
76
76
254
5
70
CosmicRadiance/trac_ik
trac_ik_examples/launch/pr2_arm.launch.py
Python
generate_launch_description
generate_launch_description
24
56
24
24
3353b6f616f23f34799920275db2e257f139e0fe
bigcode/the-stack
train
f7d8e2e2db18cea78f9e0bb6
train
class
class Capability: def _version(self, version): return version def __init__(self, data) -> None: # self.component = data["components"][0]["id"] # for capabilities in data["components"][0]["capabilities"][0]: # setattr(self, ) for key, value in data.items(): ...
class Capability:
def _version(self, version): return version def __init__(self, data) -> None: # self.component = data["components"][0]["id"] # for capabilities in data["components"][0]["capabilities"][0]: # setattr(self, ) for key, value in data.items(): setattr(self, k...
", "HDMI5", "HDMI6", "digitalTv", "USB", "YouTube", "aux", "bluetooth", "digital", ...
64
64
101
3
61
viktorfreiman/smartthings-rest
p.py
Python
Capability
Capability
117
130
117
117
5d7678daaedbd9561950ba398f7d314c14834274
bigcode/the-stack
train
b9e2829ab4ebeea9f6244b4c
train
class
class ConvBNLayer(nn.Layer): def __init__(self, input_channels, filter_size, output_channels, stride=1, num_groups=1, padding_type="SAME", conv_act=None, bn_act="swish", ...
class ConvBNLayer(nn.Layer):
def __init__(self, input_channels, filter_size, output_channels, stride=1, num_groups=1, padding_type="SAME", conv_act=None, bn_act="swish", use_bn=True, ...
act, padding=padding, weight_attr=param_attr, bias_attr=bias_attr) def forward(self, inputs): x = self._conv(inputs) if self.act == "swish": x = F.swish(x) elif self.act == "sigmoid": x = F.sigmoid(x) if self.need_crop: ...
99
99
333
7
91
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
ConvBNLayer
ConvBNLayer
337
389
337
337
aec396760c06b00ad0be8364a2c56d5a6de42c7a
bigcode/the-stack
train
3434f3b025df0cafb8725a7a
train
function
def round_filters(filters, global_params): """ Calculate and round number of filters based on depth multiplier. """ multiplier = global_params.width_coefficient if not multiplier: return filters divisor = global_params.depth_divisor min_depth = global_params.min_depth filters *= multipli...
def round_filters(filters, global_params):
""" Calculate and round number of filters based on depth multiplier. """ multiplier = global_params.width_coefficient if not multiplier: return filters divisor = global_params.depth_divisor min_depth = global_params.min_depth filters *= multiplier min_depth = min_depth or divisor ...
efficient=d, dropout_rate=p) else: raise NotImplementedError('model name is not pre-defined: %s' % model_name) if override_params: global_params = global_params._replace(**override_params) return blocks_args, global_params def round_filters(filters, global_p...
64
64
128
8
55
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
round_filters
round_filters
108
121
108
108
b02bacb37735332547f512ab06a7144feaad5a2c
bigcode/the-stack
train
bb040725bf54d83faa7d0814
train
class
class ExpandConvNorm(nn.Layer): def __init__(self, input_channels, block_args, padding_type, name=None, model_name=None, cur_stage=None): super(ExpandConvNorm, self).__init__() self.oup = block_arg...
class ExpandConvNorm(nn.Layer):
def __init__(self, input_channels, block_args, padding_type, name=None, model_name=None, cur_stage=None): super(ExpandConvNorm, self).__init__() self.oup = block_args.input_filters * block_args.exp...
param_attr=param_attr, bias_attr=bias_attr) def forward(self, inputs): if self.use_bn: x = self._conv(inputs) x = self._bn(x) return x else: return self._conv(inputs) class ExpandConvNorm(nn.Layer):
64
64
182
7
57
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
ExpandConvNorm
ExpandConvNorm
392
422
392
392
528427d63de3357cf20b05d03c5d9d6e31675322
bigcode/the-stack
train
4fe3db276c68d5cf2f30e9c7
train
function
def efficientnet_params(model_name): """ Map EfficientNet model name to parameter coefficients. """ params_dict = { # Coefficients: width,depth,resolution,dropout 'efficientnet-b0': (1.0, 1.0, 224, 0.2), 'efficientnet-b1': (1.0, 1.1, 240, 0.2), 'efficientnet-b2': (1.1, 1.2, 260...
def efficientnet_params(model_name):
""" Map EfficientNet model name to parameter coefficients. """ params_dict = { # Coefficients: width,depth,resolution,dropout 'efficientnet-b0': (1.0, 1.0, 224, 0.2), 'efficientnet-b1': (1.0, 1.1, 240, 0.2), 'efficientnet-b2': (1.1, 1.2, 260, 0.3), 'efficientnet-b3': (1...
', 'num_repeat', 'input_filters', 'output_filters', 'expand_ratio', 'id_skip', 'stride', 'se_ratio' ]) GlobalParams.__new__.__defaults__ = (None, ) * len(GlobalParams._fields) BlockArgs.__new__.__defaults__ = (None, ) * len(BlockArgs._fields) def efficientnet_params(model_name):
75
75
250
7
68
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
efficientnet_params
efficientnet_params
48
61
48
48
664bf99527fd2bfac9d0f2fa014e4383d31d4bb4
bigcode/the-stack
train
09080e31cf511b7b081a71a1
train
class
class EfficientNet(nn.Layer): def __init__(self, name="b0", padding_type="SAME", override_params=None, use_se=True, class_dim=1000): super(EfficientNet, self).__init__() model_name = 'efficientnet-' + name ...
class EfficientNet(nn.Layer):
def __init__(self, name="b0", padding_type="SAME", override_params=None, use_se=True, class_dim=1000): super(EfficientNet, self).__init__() model_name = 'efficientnet-' + name self.name = name self....
_sublayer( "block." + str(idx) + ".", MbConvBlock( block_args.input_filters, block_args, padding_type=padding_type, use_se=use_se, name="_blocks." + str(idx) + ...
153
153
510
6
146
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNet
EfficientNet
722
793
722
722
17a44d8f61a6104c998471b0aa940268489bc87c
bigcode/the-stack
train
5152ae9fd5e328cd040dc59a
train
class
class ExtractFeatures(nn.Layer): def __init__(self, input_channels, _block_args, _global_params, padding_type, use_se, model_name=None): super(ExtractFeatures, self).__init__() self._global_params ...
class ExtractFeatures(nn.Layer):
def __init__(self, input_channels, _block_args, _global_params, padding_type, use_se, model_name=None): super(ExtractFeatures, self).__init__() self._global_params = _global_params self._c...
.output_filters: if self.drop_connect_rate: x = _drop_connect(x, self.drop_connect_rate, not self.training) x = paddle.add(x, inputs) return x class ConvStemNorm(nn.Layer): def __init__(self, input_channels, padding_type, ...
200
200
667
6
194
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
ExtractFeatures
ExtractFeatures
631
719
631
631
c5f83b3fd1a476f668c9763966794d2c197b92fd
bigcode/the-stack
train
c38305f00475b8ae89365de8
train
function
def EfficientNetB5(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs): model = EfficientNet( name='b5', padding_type=padding_type, override_params...
def EfficientNetB5(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
model = EfficientNet( name='b5', padding_type=padding_type, override_params=override_params, use_se=use_se, **kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB5"]) return model
kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB4"]) return model def EfficientNetB5(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
64
64
99
38
25
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNetB5
EfficientNetB5
905
918
905
910
1d0ea3a906540699ff10ab3e5116c5ee7e1cd0b4
bigcode/the-stack
train
0d46f6ed463e9083fedd8d73
train
function
def init_batch_norm_layer(name="batch_norm"): param_attr = ParamAttr(name=name + "_scale") bias_attr = ParamAttr(name=name + "_offset") return param_attr, bias_attr
def init_batch_norm_layer(name="batch_norm"):
param_attr = ParamAttr(name=name + "_scale") bias_attr = ParamAttr(name=name + "_offset") return param_attr, bias_attr
initial_type(name, use_bias=False): param_attr = ParamAttr(name=name + "_weights") if use_bias: bias_attr = ParamAttr(name=name + "_offset") else: bias_attr = False return param_attr, bias_attr def init_batch_norm_layer(name="batch_norm"):
64
64
42
10
53
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
init_batch_norm_layer
init_batch_norm_layer
218
221
218
218
4fcd9425a40ccb7e04f88de0a6aa485f5d3f528d
bigcode/the-stack
train
2387b8bf3f100055d35d5493
train
function
def EfficientNetB4(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs): model = EfficientNet( name='b4', padding_type=padding_type, override_params...
def EfficientNetB4(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
model = EfficientNet( name='b4', padding_type=padding_type, override_params=override_params, use_se=use_se, **kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB4"]) return model
kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB3"]) return model def EfficientNetB4(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
64
64
99
38
25
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNetB4
EfficientNetB4
889
902
889
894
036a33f3715b20e1694a3a805f7f7cb3d38b583a
bigcode/the-stack
train
7d04e030bfc68547df33f7f1
train
function
def EfficientNetB1(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs): model = EfficientNet( name='b1', padding_type=padding_type, override_params...
def EfficientNetB1(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
model = EfficientNet( name='b1', padding_type=padding_type, override_params=override_params, use_se=use_se, **kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB1"]) return model
kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB0"]) return model def EfficientNetB1(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
64
64
99
38
25
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNetB1
EfficientNetB1
841
854
841
846
e4d97b431e5ec8110be814fa67c77783637ec3bb
bigcode/the-stack
train
8c4e6f64f6fd5f6017aa3fac
train
function
def EfficientNetB3(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs): model = EfficientNet( name='b3', padding_type=padding_type, override_params...
def EfficientNetB3(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
model = EfficientNet( name='b3', padding_type=padding_type, override_params=override_params, use_se=use_se, **kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB3"]) return model
kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB2"]) return model def EfficientNetB3(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
64
64
99
38
25
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNetB3
EfficientNetB3
873
886
873
878
f6018537ca418f11a79cb7451934983537fc3603
bigcode/the-stack
train
a50087506be176db43a8acb1
train
function
def _load_pretrained(pretrained, model, model_url, use_ssld=False): if pretrained is False: pass elif pretrained is True: load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) elif isinstance(pretrained, str): load_dygraph_pretrain(model, pretrained) else: r...
def _load_pretrained(pretrained, model, model_url, use_ssld=False):
if pretrained is False: pass elif pretrained is True: load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld) elif isinstance(pretrained, str): load_dygraph_pretrain(model, pretrained) else: raise RuntimeError( "pretrained type is not available. Pl...
(x) if self._global_params.dropout_rate: x = self._drop(x) x = paddle.squeeze(x, axis=[2, 3]) x = self._fc(x) return x def _load_pretrained(pretrained, model, model_url, use_ssld=False):
63
64
105
18
44
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
_load_pretrained
_load_pretrained
796
806
796
796
60d0effb911fc78b70f586d8a18bcb1c042fb326
bigcode/the-stack
train
1f2b0cbc87b628bcf0573743
train
class
class Conv2ds(nn.Layer): def __init__(self, input_channels, output_channels, filter_size, stride=1, padding=0, groups=None, name="conv2d", act=None, use_bias=False...
class Conv2ds(nn.Layer):
def __init__(self, input_channels, output_channels, filter_size, stride=1, padding=0, groups=None, name="conv2d", act=None, use_bias=False, paddin...
264, 132, 66, 33, 33, 17], "b7": [600, 300, 300, 150, 75, 38, 38, 19] } def _drop_connect(inputs, prob, is_test): if is_test: output = inputs else: keep_prob = 1.0 - prob inputs_shape = paddle.shape(inputs) random_tensor = keep_prob + paddle.rand( shape=[inputs_...
151
151
505
7
143
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
Conv2ds
Conv2ds
265
334
265
265
fa304a3488414e83556103e404346d7443be2d7f
bigcode/the-stack
train
1a42a6b2fac31ebf731e8a82
train
function
def EfficientNetB6(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs): model = EfficientNet( name='b6', padding_type=padding_type, override_params...
def EfficientNetB6(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
model = EfficientNet( name='b6', padding_type=padding_type, override_params=override_params, use_se=use_se, **kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB6"]) return model
kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB5"]) return model def EfficientNetB6(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
64
64
99
38
25
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNetB6
EfficientNetB6
921
934
921
926
8375e8ca5fdbe8785c164430fc7f83ccb6ef85fc
bigcode/the-stack
train
788afe8c1c68c0b50ca0d0f8
train
function
def _drop_connect(inputs, prob, is_test): if is_test: output = inputs else: keep_prob = 1.0 - prob inputs_shape = paddle.shape(inputs) random_tensor = keep_prob + paddle.rand( shape=[inputs_shape[0], 1, 1, 1]) binary_tensor = paddle.floor(random_tensor) ...
def _drop_connect(inputs, prob, is_test):
if is_test: output = inputs else: keep_prob = 1.0 - prob inputs_shape = paddle.shape(inputs) random_tensor = keep_prob + paddle.rand( shape=[inputs_shape[0], 1, 1, 1]) binary_tensor = paddle.floor(random_tensor) output = paddle.multiply(inputs, binary_...
528, 264, 264, 132, 66, 33, 33, 17], "b7": [600, 300, 300, 150, 75, 38, 38, 19] } def _drop_connect(inputs, prob, is_test):
64
64
97
11
53
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
_drop_connect
_drop_connect
252
262
252
252
9597dbd59106d58b3f919ea8f32f55d3a42827d7
bigcode/the-stack
train
4a00df5b70a13f9f4e4bc584
train
class
class ConvStemNorm(nn.Layer): def __init__(self, input_channels, padding_type, _global_params, name=None, model_name=None, cur_stage=None): super(ConvStemNorm, self).__init__() output_channels = ro...
class ConvStemNorm(nn.Layer):
def __init__(self, input_channels, padding_type, _global_params, name=None, model_name=None, cur_stage=None): super(ConvStemNorm, self).__init__() output_channels = round_filters(32, _global_params...
.stride == 1 and \ self.block_args.input_filters == self.block_args.output_filters: if self.drop_connect_rate: x = _drop_connect(x, self.drop_connect_rate, not self.training) x = paddle.add(x, inputs) return x class ConvStemNorm(nn.Layer):
64
64
154
7
56
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
ConvStemNorm
ConvStemNorm
603
628
603
603
1fca530e99a26954205f92e610b2805d2ba31bb1
bigcode/the-stack
train
13dcc883ca218158eeea29fc
train
function
def get_model_params(model_name, override_params): """ Get the block args and global params for a given model """ if model_name.startswith('efficientnet'): w, d, _, p = efficientnet_params(model_name) blocks_args, global_params = efficientnet( width_coefficient=w, depth_coefficient=d...
def get_model_params(model_name, override_params):
""" Get the block args and global params for a given model """ if model_name.startswith('efficientnet'): w, d, _, p = efficientnet_params(model_name) blocks_args, global_params = efficientnet( width_coefficient=w, depth_coefficient=d, dropout_rate=p) else: raise NotImplem...
drop_connect_rate=drop_connect_rate, num_classes=1000, width_coefficient=width_coefficient, depth_coefficient=depth_coefficient, depth_divisor=8, min_depth=None) return blocks_args, global_params def get_model_params(model_name, override_params):
64
64
121
10
53
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
get_model_params
get_model_params
94
105
94
94
493ee70cb17114cce374f7dedeb1c7897b7250fe
bigcode/the-stack
train
7d63d6473b35abd26b46fd0c
train
class
class MbConvBlock(nn.Layer): def __init__(self, input_channels, block_args, padding_type, use_se, name=None, drop_connect_rate=None, model_name=None, cur_stage=None): super...
class MbConvBlock(nn.Layer):
def __init__(self, input_channels, block_args, padding_type, use_se, name=None, drop_connect_rate=None, model_name=None, cur_stage=None): super(MbConvBlock, self).__init__(...
._conv1 = Conv2ds( input_channels, num_squeezed_channels, 1, use_bias=True, padding_type=padding_type, act="swish", name=name + "_se_reduce") self._conv2 = Conv2ds( num_squeezed_channels, oup, ...
155
155
518
7
147
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
MbConvBlock
MbConvBlock
525
600
525
525
cd25120a901d06751cb46b27326a33503e0a7732
bigcode/the-stack
train
6cbfc05d56d34c6f2ad2fb80
train
function
def initial_type(name, use_bias=False): param_attr = ParamAttr(name=name + "_weights") if use_bias: bias_attr = ParamAttr(name=name + "_offset") else: bias_attr = False return param_attr, bias_attr
def initial_type(name, use_bias=False):
param_attr = ParamAttr(name=name + "_weights") if use_bias: bias_attr = ParamAttr(name=name + "_offset") else: bias_attr = False return param_attr, bias_attr
namedtuples of block args :return: a list of strings, each string is a notation of block """ block_strings = [] for block in blocks_args: block_strings.append(BlockDecoder._encode_block_string(block)) return block_strings def initial_type(name, use_bias=False):
64
64
55
9
54
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
initial_type
initial_type
209
215
209
209
b35df9a8580371122dd63ce2decdbc6424e64e6c
bigcode/the-stack
train
aa43adfecbce60f3504be591
train
class
class DepthwiseConvNorm(nn.Layer): def __init__(self, input_channels, block_args, padding_type, name=None, model_name=None, cur_stage=None): super(DepthwiseConvNorm, self).__init__() self.k = block...
class DepthwiseConvNorm(nn.Layer):
def __init__(self, input_channels, block_args, padding_type, name=None, model_name=None, cur_stage=None): super(DepthwiseConvNorm, self).__init__() self.k = block_args.kernel_size self.s = ...
=name + "_expand_conv", bn_name="_bn0", model_name=model_name, cur_stage=cur_stage) def forward(self, inputs): if self.expand_ratio != 1: return self._conv(inputs) else: return inputs class DepthwiseConvNorm(nn.Layer):
64
64
200
8
55
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
DepthwiseConvNorm
DepthwiseConvNorm
425
456
425
425
6045dccaa5d4ff9e20dcbc91a812040c44b60d6a
bigcode/the-stack
train
fb67429e0edc98774e23370f
train
function
def init_fc_layer(name="fc"): param_attr = ParamAttr(name=name + "_weights") bias_attr = ParamAttr(name=name + "_offset") return param_attr, bias_attr
def init_fc_layer(name="fc"):
param_attr = ParamAttr(name=name + "_weights") bias_attr = ParamAttr(name=name + "_offset") return param_attr, bias_attr
bias_attr = False return param_attr, bias_attr def init_batch_norm_layer(name="batch_norm"): param_attr = ParamAttr(name=name + "_scale") bias_attr = ParamAttr(name=name + "_offset") return param_attr, bias_attr def init_fc_layer(name="fc"):
64
64
40
8
55
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
init_fc_layer
init_fc_layer
224
227
224
224
9f51911966a9a2a8693b4feac2c03e32a02442e3
bigcode/the-stack
train
bb8c95a454d745488d377579
train
function
def EfficientNetB2(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs): model = EfficientNet( name='b2', padding_type=padding_type, override_params...
def EfficientNetB2(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
model = EfficientNet( name='b2', padding_type=padding_type, override_params=override_params, use_se=use_se, **kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB2"]) return model
kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB1"]) return model def EfficientNetB2(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
64
64
99
38
25
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNetB2
EfficientNetB2
857
870
857
862
94e64460555b8f41ff33faec8ab4cc9807c4439c
bigcode/the-stack
train
c8e59b60226027ed992e704f
train
function
def efficientnet(width_coefficient=None, depth_coefficient=None, dropout_rate=0.2, drop_connect_rate=0.2): """ Get block arguments according to parameter and coefficients. """ blocks_args = [ 'r1_k3_s11_e1_i32_o16_se0.25', 'r2_k3_s22_e6_i16_o24_...
def efficientnet(width_coefficient=None, depth_coefficient=None, dropout_rate=0.2, drop_connect_rate=0.2):
""" Get block arguments according to parameter and coefficients. """ blocks_args = [ 'r1_k3_s11_e1_i32_o16_se0.25', 'r2_k3_s22_e6_i16_o24_se0.25', 'r2_k5_s22_e6_i24_o40_se0.25', 'r3_k3_s22_e6_i40_o80_se0.25', 'r3_k5_s11_e6_i80_o112_se0.25', 'r4_k5_s22_e6_i112_o192...
': (1.8, 2.6, 528, 0.5), 'efficientnet-b7': (2.0, 3.1, 600, 0.5), } return params_dict[model_name] def efficientnet(width_coefficient=None, depth_coefficient=None, dropout_rate=0.2, drop_connect_rate=0.2):
85
85
284
31
54
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
efficientnet
efficientnet
64
91
64
67
ec29e07cf6565860b19ebea4182c8a6555a68f1d
bigcode/the-stack
train
de699b2801b7344ff706e518
train
class
class ProjectConvNorm(nn.Layer): def __init__(self, input_channels, block_args, padding_type, name=None, model_name=None, cur_stage=None): super(ProjectConvNorm, self).__init__() final_oup = block_...
class ProjectConvNorm(nn.Layer):
def __init__(self, input_channels, block_args, padding_type, name=None, model_name=None, cur_stage=None): super(ProjectConvNorm, self).__init__() final_oup = block_args.output_filters self...
=None, padding_type=padding_type, name=name, conv_name=name + "_depthwise_conv", bn_name="_bn1", model_name=model_name, cur_stage=cur_stage) def forward(self, inputs): return self._conv(inputs) class ProjectConvNorm(nn.Layer):
64
64
141
7
57
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
ProjectConvNorm
ProjectConvNorm
459
484
459
459
1707e4cabc3c9d3042fcecb310d6c21724dcc5cc
bigcode/the-stack
train
9cece1077faf520c38653f2f
train
function
def cal_padding(img_size, stride, filter_size, dilation=1): """Calculate padding size.""" if img_size % stride == 0: out_size = max(filter_size - stride, 0) else: out_size = max(filter_size - (img_size % stride), 0) return out_size // 2, out_size - out_size // 2
def cal_padding(img_size, stride, filter_size, dilation=1):
"""Calculate padding size.""" if img_size % stride == 0: out_size = max(filter_size - stride, 0) else: out_size = max(filter_size - (img_size % stride), 0) return out_size // 2, out_size - out_size // 2
") return param_attr, bias_attr def init_fc_layer(name="fc"): param_attr = ParamAttr(name=name + "_weights") bias_attr = ParamAttr(name=name + "_offset") return param_attr, bias_attr def cal_padding(img_size, stride, filter_size, dilation=1):
64
64
81
15
48
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
cal_padding
cal_padding
230
236
230
230
2aa6ba362548ce1a82387872d5469608cf0aff1f
bigcode/the-stack
train
05d3fc4dfb85f6ebd4cbaa2a
train
function
def round_repeats(repeats, global_params): """ Round number of filters based on depth multiplier. """ multiplier = global_params.depth_coefficient if not multiplier: return repeats return int(math.ceil(multiplier * repeats))
def round_repeats(repeats, global_params):
""" Round number of filters based on depth multiplier. """ multiplier = global_params.depth_coefficient if not multiplier: return repeats return int(math.ceil(multiplier * repeats))
max(min_depth, int(filters + divisor / 2) // divisor * divisor) if new_filters < 0.9 * filters: # prevent rounding by more than 10% new_filters += divisor return int(new_filters) def round_repeats(repeats, global_params):
64
64
52
12
52
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
round_repeats
round_repeats
124
129
124
124
e9d4d7aa23837bdcc4ef860a7578af5c6f835b41
bigcode/the-stack
train
fe20b9b6fa7d9ac1242024ef
train
function
def EfficientNetB0(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs): model = EfficientNet( name='b0', padding_type=padding_type, override_params...
def EfficientNetB0(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
model = EfficientNet( name='b0', padding_type=padding_type, override_params=override_params, use_se=use_se, **kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB0"]) return model
) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB0_small"]) return model def EfficientNetB0(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
64
64
99
38
25
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNetB0
EfficientNetB0
825
838
825
830
0d0cfd334935b9b3beac3af1bd8f0a0d3d1a89c0
bigcode/the-stack
train
ecdbddb9e0fda468b35134cd
train
function
def EfficientNetB7(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs): model = EfficientNet( name='b7', padding_type=padding_type, override_params...
def EfficientNetB7(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
model = EfficientNet( name='b7', padding_type=padding_type, override_params=override_params, use_se=use_se, **kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB7"]) return model
kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB6"]) return model def EfficientNetB7(padding_type='SAME', override_params=None, use_se=True, pretrained=False, use_ssld=False, **kwargs):
64
64
98
38
25
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNetB7
EfficientNetB7
937
950
937
942
b08d9506d2664cfe245738b78e486a8ac9ebb3a3
bigcode/the-stack
train
2731518c53605d3322929915
train
class
class BlockDecoder(object): """ Block Decoder, straight from the official TensorFlow repository. """ @staticmethod def _decode_block_string(block_string): """ Gets a block through a string notation of arguments. """ assert isinstance(block_string, str) ops = block_string.sp...
class BlockDecoder(object):
""" Block Decoder, straight from the official TensorFlow repository. """ @staticmethod def _decode_block_string(block_string): """ Gets a block through a string notation of arguments. """ assert isinstance(block_string, str) ops = block_string.split('_') options = {...
_params): """ Calculate and round number of filters based on depth multiplier. """ multiplier = global_params.width_coefficient if not multiplier: return filters divisor = global_params.depth_divisor min_depth = global_params.min_depth filters *= multiplier min_depth = min_depth or d...
179
179
598
5
174
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
BlockDecoder
BlockDecoder
132
206
132
132
0cd758f5d8715be90063b5150c4dd3f688b6c146
bigcode/the-stack
train
b6e4b6eca44776e7d547a50b
train
class
class SEBlock(nn.Layer): def __init__(self, input_channels, num_squeezed_channels, oup, padding_type, name=None, model_name=None, cur_stage=None): super(SEBlock, self).__init__() s...
class SEBlock(nn.Layer):
def __init__(self, input_channels, num_squeezed_channels, oup, padding_type, name=None, model_name=None, cur_stage=None): super(SEBlock, self).__init__() self._pool = AdaptiveAvgPo...
bn_act=None, padding_type=padding_type, name=name, conv_name=name + "_project_conv", bn_name="_bn2", model_name=model_name, cur_stage=cur_stage) def forward(self, inputs): return self._conv(inputs) class SEBlock(nn.Layer):
65
65
219
6
59
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
SEBlock
SEBlock
487
522
487
487
4f88a8e55bb1e04cffd6482735cc18db524c8569
bigcode/the-stack
train
971d67df42f03725a931fc57
train
function
def EfficientNetB0_small(padding_type='DYNAMIC', override_params=None, use_se=False, pretrained=False, use_ssld=False, **kwargs): model = EfficientNet( name='b0', padding_ty...
def EfficientNetB0_small(padding_type='DYNAMIC', override_params=None, use_se=False, pretrained=False, use_ssld=False, **kwargs):
model = EfficientNet( name='b0', padding_type=padding_type, override_params=override_params, use_se=use_se, **kwargs) _load_pretrained(pretrained, model, MODEL_URLS["EfficientNetB0_small"]) return model
Error( "pretrained type is not available. Please use `string` or `boolean` type." ) def EfficientNetB0_small(padding_type='DYNAMIC', override_params=None, use_se=False, pretrained=False, use_ssld=Fal...
63
64
101
39
24
qili93/PaddleClas
ppcls/arch/backbone/model_zoo/efficientnet.py
Python
EfficientNetB0_small
EfficientNetB0_small
809
822
809
814
1ef9d8b85d1258331d1a4165eb1d96361910e82c
bigcode/the-stack
train
8a241261fbdbdea07977304d
train
function
def test(rng="Sobol", mode="unipolar", bitwidth=8, total_cnt=100, depth=5, savepdf=False): stype = torch.float rtype = torch.float print("========================================================") print(mode) print("=============================...
def test(rng="Sobol", mode="unipolar", bitwidth=8, total_cnt=100, depth=5, savepdf=False):
stype = torch.float rtype = torch.float print("========================================================") print(mode) print("========================================================") # all input values are non-negative low_bound = 0 if mode == "unipolar": up_bound = 2**bitw...
# %% import torch from UnarySim.kernel.sqrt import GainesSqrt from UnarySim.stream.gen import RNG, SourceGen, BSGen from UnarySim.metric.metric import ProgError import matplotlib.pyplot as plt import time import math import numpy as np # %% device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") rng = ...
126
256
1,041
42
84
jingjieli95/UnarySim
test/kernel/test_kernel_sqrt_gaines.py
Python
test
test
16
116
16
21
31236e4e2606beed3685c4c15e365a54989a7c57
bigcode/the-stack
train
26021d688a7ebb9fdc1d7609
train
function
def run(): exercise() print(format_cpu_times())
def run():
exercise() print(format_cpu_times())
=="O" and n2 in ["D1","D2"] and a1.resname=="HOH"): assert approx_equal(dist(a1.xyz, a2.xyz), 0.95, tolerance) cntr += 1 assert cntr == 11, cntr def run():
64
64
12
3
60
dperl-sol/cctbx_project
mmtbx/monomer_library/tst_neutron_distance.py
Python
run
run
125
127
125
125
fac0c5b88390ae1204006597a843db94010114fc
bigcode/the-stack
train
217c6ac57a0bd8485c065ae3
train
function
def exercise(tolerance=0.01): for use_neutron_distances in [True, False]: mon_lib_srv = monomer_library.server.server() ener_lib = monomer_library.server.ener_lib() inp = iotbx.pdb.input(lines=pdb_str.splitlines(), source_info=None) params = iotbx.phil.parse( input_string=grand_master_phil_s...
def exercise(tolerance=0.01):
for use_neutron_distances in [True, False]: mon_lib_srv = monomer_library.server.server() ener_lib = monomer_library.server.ener_lib() inp = iotbx.pdb.input(lines=pdb_str.splitlines(), source_info=None) params = iotbx.phil.parse( input_string=grand_master_phil_str, process_includes=True).ext...
28 8.000 3.505 4.139 0.50 10.00 H ATOM 21 DH BTYR A 28 7.469 4.025 3.773 0.50 10.00 D TER HETATM 25 O HOH C 1 11.274 5.928 4.656 1.00 10.00 O HETATM 26 D1 HOH C 1 12.360 4.699 5.619 1.00 10.00 D HETATM 27 D2 HOH C ...
256
256
997
9
247
dperl-sol/cctbx_project
mmtbx/monomer_library/tst_neutron_distance.py
Python
exercise
exercise
48
123
48
48
b96fc5f39c8ae770aab6f00f5f1adefd3810e456
bigcode/the-stack
train
14afa811cfb372c02a9f6fc2
train
function
def dist(a,b): return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2 + (a[2]-b[2])**2)
def dist(a,b):
return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2 + (a[2]-b[2])**2)
1.00 10.00 D HETATM 27 D2 HOH C 1 10.422 5.411 6.216 1.00 10.00 D TER END """ def dist(a,b):
64
64
45
5
59
dperl-sol/cctbx_project
mmtbx/monomer_library/tst_neutron_distance.py
Python
dist
dist
45
46
45
45
7629d6d4066c407fb2dbbd8d247c577106833d56
bigcode/the-stack
train
fb9c0184458a13f041097461
train
class
class IdentifierNode(Node): """Class representing the identifier node. An identifier could be a single latin letter (uppercase/lowercase) or a greek letter represented by the symbol name. """ def __init__(self, token): """Initializes an IdentifierNode object. Args: toke...
class IdentifierNode(Node):
"""Class representing the identifier node. An identifier could be a single latin letter (uppercase/lowercase) or a greek letter represented by the symbol name. """ def __init__(self, token): """Initializes an IdentifierNode object. Args: token: Token. The token represen...
self, left, right): """Initializes an PowerOperatorNode object. Args: left: Node. Left child of the operator. right: Node. Right child of the operator. """ super(PowerOperatorNode, self).__init__([left, right]) class IdentifierNode(Node):
64
64
94
5
59
ReshuKumari/oppia
core/domain/expression_parser.py
Python
IdentifierNode
IdentifierNode
362
375
362
362
1431d69041d506426dff6ab04dba18a8c6ea9e18
bigcode/the-stack
train