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
6ba63b2ff5c4000cfc89aee8
train
class
class TestItemfreq(object): a = [5, 7, 1, 2, 1, 5, 7] * 10 b = [1, 2, 5, 7] def test_numeric_types(self): # Check itemfreq works for all dtypes (adapted from np.unique tests) def _check_itemfreq(dt): a = np.array(self.a, dt) v = stats.itemfreq(a) assert_a...
class TestItemfreq(object):
a = [5, 7, 1, 2, 1, 5, 7] * 10 b = [1, 2, 5, 7] def test_numeric_types(self): # Check itemfreq works for all dtypes (adapted from np.unique tests) def _check_itemfreq(dt): a = np.array(self.a, dt) v = stats.itemfreq(a) assert_array_equal(v[:, 0], [1, 2, 5...
_method='foobar') assert_raises(ValueError, stats.scoreatpercentile, [1], 101) assert_raises(ValueError, stats.scoreatpercentile, [1], -1) def test_empty(self): assert_equal(stats.scoreatpercentile([], 50), np.nan) assert_equal(stats.scoreatpercentile(np.array([[], []]), 50), np.nan...
111
111
370
6
105
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestItemfreq
TestItemfreq
1,161
1,195
1,161
1,161
a259568607b8495ab6b7d60ba4917c1b36f988c3
bigcode/the-stack
train
f09dc6c94af6599bce24e4b7
train
class
class TestFindRepeats(TestCase): def test_basic(self): a = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 5] res, nums = stats.find_repeats(a) assert_array_equal(res, [1, 2, 3, 4]) assert_array_equal(nums, [3, 3, 2, 2]) def test_empty_result(self): # Check that empty arrays are returne...
class TestFindRepeats(TestCase):
def test_basic(self): a = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 5] res, nums = stats.find_repeats(a) assert_array_equal(res, [1, 2, 3, 4]) assert_array_equal(nums, [3, 3, 2, 2]) def test_empty_result(self): # Check that empty arrays are returned when there are no repeats. ...
, stats.kendalltau, x, x, nan_policy='foobar') # test unequal length inputs x = np.arange(10.) y = np.arange(20.) assert_raises(ValueError, stats.kendalltau, x, y) class TestFindRepeats(TestCase):
64
64
168
8
56
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestFindRepeats
TestFindRepeats
623
636
623
624
c88dc0e58ce08762b5b5c55568344b0a4b9dea3e
bigcode/the-stack
train
130a1df7abfa1860efaaeaed
train
class
class TestHistogram(TestCase): # Tests that histogram works as it should, and keeps old behaviour # # what is untested: # - multidimensional arrays (since 'a' is ravel'd as the first line in the method) # - very large arrays # - Nans, Infs, empty and otherwise bad inputs # sample arrays to ...
class TestHistogram(TestCase): # Tests that histogram works as it should, and keeps old behaviour # # what is untested: # - multidimensional arrays (since 'a' is ravel'd as the first line in the method) # - very large arrays # - Nans, Infs, empty and otherwise bad inputs # sample arrays to ...
low_values = np.array([0.2, 0.3, 0.4, 0.5, 0.5, 0.6, 0.7, 0.8, 0.9, 1.1, 1.2], dtype=float) # 11 values high_range = np.array([2, 3, 4, 2, 21, 32, 78, 95, 65, 66, 66, 66, 66, 4], dtype=float) # 14 values low_range = np.array([2, 3, 3, 2, 3, 2.4, 2.1, 3.1...
test. slope, intercept, lower, upper = stats.theilslopes([0,1,1]) assert_almost_equal(slope, 0.5) assert_almost_equal(intercept, 0.5) # Test of confidence intervals. x = [1, 2, 3, 4, 10, 12, 18] y = [9, 15, 19, 20, 45, 55, 78] slope, intercept, lower, upper = stats.theilslopes(y, x, 0.07) ...
256
256
1,827
85
171
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestHistogram
TestHistogram
791
923
791
799
68d8614b4243901d886c49a880330a3651739cbf
bigcode/the-stack
train
c9bde9a17f5b0006f7a78be5
train
class
class TestJarqueBera(TestCase): def test_jarque_bera_stats(self): np.random.seed(987654321) x = np.random.normal(0, 1, 100000) y = np.random.chisquare(10000, 100000) z = np.random.rayleigh(1, 100000) assert_(stats.jarque_bera(x)[1] > stats.jarque_bera(y)[1]) assert_(...
class TestJarqueBera(TestCase):
def test_jarque_bera_stats(self): np.random.seed(987654321) x = np.random.normal(0, 1, 100000) y = np.random.chisquare(10000, 100000) z = np.random.rayleigh(1, 100000) assert_(stats.jarque_bera(x)[1] > stats.jarque_bera(y)[1]) assert_(stats.jarque_bera(x)[1] > stats....
raise') assert_raises(ValueError, stats.normaltest, x, nan_policy='foobar') class TestRankSums(TestCase): def test_ranksums_result_attributes(self): res = stats.ranksums(np.arange(5), np.arange(25)) attributes = ('statistic', 'pvalue') check_named_results(res, attributes) class TestJar...
83
83
279
9
74
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestJarqueBera
TestJarqueBera
2,677
2,700
2,677
2,677
77707b1696ead0e1cffe4dad01490d3558e7a216
bigcode/the-stack
train
531a8c59a79881e6e7b09e33
train
function
def _desc_stats(x1, x2, axis=0): def _stats(x, axis=0): x = np.asarray(x) mu = np.mean(x, axis=axis) std = np.std(x, axis=axis, ddof=1) nobs = x.shape[axis] return mu, std, nobs return _stats(x1, axis) + _stats(x2, axis)
def _desc_stats(x1, x2, axis=0):
def _stats(x, axis=0): x = np.asarray(x) mu = np.mean(x, axis=axis) std = np.std(x, axis=axis, ddof=1) nobs = x.shape[axis] return mu, std, nobs return _stats(x1, axis) + _stats(x2, axis)
# test incorrect input shape raise an error x = np.arange(24) assert_raises(ValueError, stats.ttest_rel, x.reshape((8, 3)), x.reshape((2, 3, 4))) def _desc_stats(x1, x2, axis=0):
63
64
93
14
49
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
_desc_stats
_desc_stats
2,264
2,271
2,264
2,264
8c84d62e36877a7b2567121dc1a8152e2c8f87a0
bigcode/the-stack
train
a6b556f622eb14893f4888a9
train
function
def test_obrientransform(): # A couple tests calculated by hand. x1 = np.array([0, 2, 4]) t1 = stats.obrientransform(x1) expected = [7, -2, 7] assert_allclose(t1[0], expected) x2 = np.array([0, 3, 6, 9]) t2 = stats.obrientransform(x2) expected = np.array([30, 0, 0, 30]) assert_allcl...
def test_obrientransform(): # A couple tests calculated by hand.
x1 = np.array([0, 2, 4]) t1 = stats.obrientransform(x1) expected = [7, -2, 7] assert_allclose(t1[0], expected) x2 = np.array([0, 3, 6, 9]) t2 = stats.obrientransform(x2) expected = np.array([30, 0, 0, 30]) assert_allclose(t2[0], expected) # Test two arguments. a, b = stats.obri...
.3,2.1,1.7,1.7,1.5,1.3,1.3,1.2,1.2,1.1, 0.8,0.7,0.6,0.5,0.2,0.2,0.1] assert_almost_equal(stats.pointbiserialr(x, y)[0], 0.36149, 5) # test for namedtuple attribute results attributes = ('correlation', 'pvalue') res = stats.pointbiserialr(x, y) check_named_results(res, attributes) def test_...
153
153
513
17
136
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_obrientransform
test_obrientransform
2,858
2,898
2,858
2,859
aba2d5941131b8091c632f30ca8a22906253dfe8
bigcode/the-stack
train
78a3ded05497bff5b4cf4d88
train
function
def test_ttest_rel(): # regression test tr,pr = 0.81248591389165692, 0.41846234511362157 tpr = ([tr,-tr],[pr,pr]) rvs1 = np.linspace(1,100,100) rvs2 = np.linspace(1.01,99.989,100) rvs1_2D = np.array([np.linspace(1,100,100), np.linspace(1.01,99.989,100)]) rvs2_2D = np.array([np.linspace(1.01...
def test_ttest_rel(): # regression test
tr,pr = 0.81248591389165692, 0.41846234511362157 tpr = ([tr,-tr],[pr,pr]) rvs1 = np.linspace(1,100,100) rvs2 = np.linspace(1.01,99.989,100) rvs1_2D = np.array([np.linspace(1,100,100), np.linspace(1.01,99.989,100)]) rvs2_2D = np.array([np.linspace(1.01,99.989,100), np.linspace(1,100,100)]) ...
62))) assert_almost_equal( np.array(stats.ks_2samp(np.linspace(1,100,100), np.linspace(1,100,100)+2-0.1)), np.array((0.020000000000000018, 0.99999999999999933))) # these are just regression tests assert_almost_equal( np.array(stats.ks_2samp(np.linspace(1...
256
256
995
11
245
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_ttest_rel
test_ttest_rel
2,186
2,261
2,186
2,187
3755e676b3544278500eecd490a0fdba3cf86e84
bigcode/the-stack
train
91199db698146e93025be921
train
function
def test_power_divergence_against_cressie_read_data(): # Test stats.power_divergence against tables 4 and 5 from # Cressie and Read, "Multimonial Goodness-of-Fit Tests", # J. R. Statist. Soc. B (1984), Vol 46, No. 3, pp. 440-464. # This tests the calculation for several values of lambda. # `table4`...
def test_power_divergence_against_cressie_read_data(): # Test stats.power_divergence against tables 4 and 5 from # Cressie and Read, "Multimonial Goodness-of-Fit Tests", # J. R. Statist. Soc. B (1984), Vol 46, No. 3, pp. 440-464. # This tests the calculation for several values of lambda. # `table4`...
table4 = np.array([ # observed, expected, 15, 15.171, 11, 13.952, 14, 12.831, 17, 11.800, 5, 10.852, 11, 9.9796, 10, 9.1777, 4, 8.4402, 8, 7.7620, 10, 7.1383, 7, 6.5647, 9, 6.0371, 11, 5.5520, 3, ...
(): warnings.filterwarnings('ignore') chisq, p = stats.chisquare(empty3.T) assert_(isinstance(chisq, np.ma.MaskedArray)) assert_equal(chisq.shape, (3,)) assert_(np.all(chisq.mask)) def test_power_divergence_against_cressie_read_data(): # Test stats.power_divergence against table...
169
169
566
111
58
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_power_divergence_against_cressie_read_data
test_power_divergence_against_cressie_read_data
2,010
2,061
2,010
2,016
447daa32f02aaecbc14e7abae1bc386c8076bc15
bigcode/the-stack
train
d777ba60c71ad9de901f385b
train
class
class TestCombinePvalues(TestCase): def test_fisher(self): # Example taken from http://en.wikipedia.org/wiki/Fisher's_exact_test#Example xsq, p = stats.combine_pvalues([.01, .2, .3], method='fisher') assert_approx_equal(p, 0.02156, significant=4) def test_stouffer(self): Z, p =...
class TestCombinePvalues(TestCase):
def test_fisher(self): # Example taken from http://en.wikipedia.org/wiki/Fisher's_exact_test#Example xsq, p = stats.combine_pvalues([.01, .2, .3], method='fisher') assert_approx_equal(p, 0.02156, significant=4) def test_stouffer(self): Z, p = stats.combine_pvalues([.01, .2, .3],...
kal(x, x), (np.nan, np.nan)) assert_almost_equal(stats.kruskal(x, x, nan_policy='omit'), (0.0, 1.0)) assert_raises(ValueError, stats.kruskal, x, x, nan_policy='raise') assert_raises(ValueError, stats.kruskal, x, x, nan_policy='foobar') class TestCombinePvalues(TestCase):
90
90
301
8
82
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestCombinePvalues
TestCombinePvalues
3,473
3,496
3,473
3,474
c3ab2f37bc9495478448f1753845446729ee6a97
bigcode/the-stack
train
5f9826945da85fc4df46486d
train
function
def test_chisquare_masked_arrays(): # Test masked arrays. obs = np.array([[8, 8, 16, 32, -1], [-1, -1, 3, 4, 5]]).T mask = np.array([[0, 0, 0, 0, 1], [1, 1, 0, 0, 0]]).T mobs = np.ma.masked_array(obs, mask) expected_chisq = np.array([24.0, 0.5]) expected_g = np.array([2*(2*8*np.log(0.5) + 32*np....
def test_chisquare_masked_arrays(): # Test masked arrays.
obs = np.array([[8, 8, 16, 32, -1], [-1, -1, 3, 4, 5]]).T mask = np.array([[0, 0, 0, 0, 1], [1, 1, 0, 0, 0]]).T mobs = np.ma.masked_array(obs, mask) expected_chisq = np.array([24.0, 0.5]) expected_g = np.array([2*(2*8*np.log(0.5) + 32*np.log(2.0)), 2*(3*np.log(0.75) + 5*np...
", case.chi2) yield (self.check_power_divergence, case.f_obs, case.f_exp, case.ddof, case.axis, "log-likelihood", case.log) yield (self.check_power_divergence, case.f_obs, case.f_exp, case.ddof, case.axis, ...
256
256
977
15
241
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_chisquare_masked_arrays
test_chisquare_masked_arrays
1,935
2,007
1,935
1,936
f09ddefdf40647fbc9c4da9ffa9d10d931f3a2d3
bigcode/the-stack
train
e9580a7d231748eb74dd75b9
train
class
class TestPowerDivergence(object): def check_power_divergence(self, f_obs, f_exp, ddof, axis, lambda_, expected_stat): f_obs = np.asarray(f_obs) if axis is None: num_obs = f_obs.size else: b = np.broadcast(f_obs, f_exp) num_...
class TestPowerDivergence(object):
def check_power_divergence(self, f_obs, f_exp, ddof, axis, lambda_, expected_stat): f_obs = np.asarray(f_obs) if axis is None: num_obs = f_obs.size else: b = np.broadcast(f_obs, f_exp) num_obs = b.shape[axis] stat, p ...
_obs=[], f_exp=None, ddof=0, axis=0, chi2=0, log=0, mod_log=0, cr=0), # Shape is (0, 3). This is 3 data sets, but each data set has # length 0, so the computed test statistic should be [0, 0, 0]. PowerDivCase(f_obs=np.array([[],[],[]]).T, f_exp=None, ddof=...
256
256
1,723
8
248
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestPowerDivergence
TestPowerDivergence
1,778
1,932
1,778
1,779
fbf11c30697254cc3277acb6ae2d43035654d12d
bigcode/the-stack
train
62a8816d884977501120aa2a
train
class
class TestKruskal(TestCase): def test_simple(self): x = [1] y = [2] h, p = stats.kruskal(x, y) assert_equal(h, 1.0) assert_approx_equal(p, stats.distributions.chi2.sf(h, 1)) h, p = stats.kruskal(np.array(x), np.array(y)) assert_equal(h, 1.0) assert_app...
class TestKruskal(TestCase):
def test_simple(self): x = [1] y = [2] h, p = stats.kruskal(x, y) assert_equal(h, 1.0) assert_approx_equal(p, stats.distributions.chi2.sf(h, 1)) h, p = stats.kruskal(np.array(x), np.array(y)) assert_equal(h, 1.0) assert_approx_equal(p, stats.distributi...
'] for test_case in filenames: rtol = 1e-7 fname = os.path.abspath(os.path.join(os.path.dirname(__file__), 'data/nist_anova', test_case)) with open(fname, 'r') as f: content = f.read().split('\n') c...
256
256
976
8
248
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestKruskal
TestKruskal
3,397
3,470
3,397
3,397
640ef4a22f0228bd9437e68a0eb1d6d52ecb3527
bigcode/the-stack
train
894c3233ffa53ce89db9071b
train
function
def test_percentileofscore(): pcos = stats.percentileofscore assert_equal(pcos([1,2,3,4,5,6,7,8,9,10],4), 40.0) for (kind, result) in [('mean', 35.0), ('strict', 30.0), ('weak', 40.0)]: yield assert_equal, pcos(np.arange(10) + 1, ...
def test_percentileofscore():
pcos = stats.percentileofscore assert_equal(pcos([1,2,3,4,5,6,7,8,9,10],4), 40.0) for (kind, result) in [('mean', 35.0), ('strict', 30.0), ('weak', 40.0)]: yield assert_equal, pcos(np.arange(10) + 1, ...
assert_array_almost_equal(p, self.P1_1) t, p = stats.ttest_1samp(self.X1, 2) assert_array_almost_equal(t, self.T1_2) assert_array_almost_equal(p, self.P1_2) # check nan policy np.random.seed(7654567) x = stats.norm.rvs(loc=5, scale=10, size=51) x[50] = ...
256
256
954
7
249
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_percentileofscore
test_percentileofscore
1,630
1,713
1,630
1,630
f971b14eb36d9ff7571b0b4d9eae48f6c59028b1
bigcode/the-stack
train
f135f68013c1189fea7b9e80
train
function
def test_binomtest2(): # test added for issue #2384 res2 = [ [1.0, 1.0], [0.5,1.0,0.5], [0.25,1.00,1.00,0.25], [0.125,0.625,1.000,0.625,0.125], [0.0625,0.3750,1.0000,1.0000,0.3750,0.0625], [0.03125,0.21875,0.68750,1.00000,0.68750,0.21875,0.03125], [0.015625,0.125000,0.453125,1.000000...
def test_binomtest2(): # test added for issue #2384
res2 = [ [1.0, 1.0], [0.5,1.0,0.5], [0.25,1.00,1.00,0.25], [0.125,0.625,1.000,0.625,0.125], [0.0625,0.3750,1.0000,1.0000,0.3750,0.0625], [0.03125,0.21875,0.68750,1.00000,0.68750,0.21875,0.03125], [0.015625,0.125000,0.453125,1.000000,1.000000,0.453125,0.125000,0.015625], [0.0078125,0....
0.027120993063129286, 2.6102587134694721e-006] for p, res in zip(pp,results): assert_approx_equal(stats.binom_test(x, n, p), res, significant=12, err_msg='fail forp=%f' % p) assert_approx_equal(stats.binom_test(50,100,0.1), 5.8320387857343647e-024, ...
134
134
448
17
117
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_binomtest2
test_binomtest2
3,117
3,137
3,117
3,118
ec1ef41163f0351e0c0035a801b70e0d0342d6b6
bigcode/the-stack
train
74db1c196a056bb62957b047
train
function
def test_pointbiserial(): # same as mstats test except for the nan # Test data: http://support.sas.com/ctx/samples/index.jsp?sid=490&tab=output x = [1,0,1,1,1,1,0,1,0,0,0,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0, 0,0,0,0,1] y = [14.8,13.8,12.4,10.1,7.1,6.1,5.8,4.6,4.3,3.5,3.3,3.2,3.0, 2.8,2...
def test_pointbiserial(): # same as mstats test except for the nan # Test data: http://support.sas.com/ctx/samples/index.jsp?sid=490&tab=output
x = [1,0,1,1,1,1,0,1,0,0,0,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0, 0,0,0,0,1] y = [14.8,13.8,12.4,10.1,7.1,6.1,5.8,4.6,4.3,3.5,3.3,3.2,3.0, 2.8,2.8,2.5,2.4,2.3,2.1,1.7,1.7,1.5,1.3,1.3,1.2,1.2,1.1, 0.8,0.7,0.6,0.5,0.2,0.2,0.1] assert_almost_equal(stats.pointbiserialr(x, y)[0], 0.36149...
itneyu_result_attribuets(self): # test for namedtuple attribute results attributes = ('statistic', 'pvalue') res = stats.mannwhitneyu(self.X, self.Y) check_named_results(res, attributes) def test_pointbiserial(): # same as mstats test except for the nan # Test data: http://suppor...
99
99
330
45
54
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_pointbiserial
test_pointbiserial
2,842
2,855
2,842
2,844
cd1a129326c79b878cbff2ad944fec5cfd02bcb9
bigcode/the-stack
train
9154823008404d6070f69807
train
class
class TestFisherExact(TestCase): """Some tests to show that fisher_exact() works correctly. Note that in SciPy 0.9.0 this was not working well for large numbers due to inaccuracy of the hypergeom distribution (see #1218). Fixed now. Also note that R and Scipy have different argument formats for their ...
class TestFisherExact(TestCase):
"""Some tests to show that fisher_exact() works correctly. Note that in SciPy 0.9.0 this was not working well for large numbers due to inaccuracy of the hypergeom distribution (see #1218). Fixed now. Also note that R and Scipy have different argument formats for their hypergeometric distribution f...
ROUNDROUND(self): y = stats.pearsonr(ROUND,ROUND) r = y[0] assert_approx_equal(r,1.0) def test_r_exactly_pos1(self): a = arange(3.0) b = a r, prob = stats.pearsonr(a,b) assert_equal(r, 1.0) assert_equal(prob, 0.0) def test_r_exactly_neg1(self): ...
256
256
1,823
8
248
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestFisherExact
TestFisherExact
272
399
272
272
f790f90c25d60069558d277b79d6fa2b5cc85020
bigcode/the-stack
train
b932626949c3d8daf48416ce
train
class
class TestTrimmedStats(TestCase): # TODO: write these tests to handle missing values properly dprec = np.finfo(np.float64).precision def test_tmean(self): y = stats.tmean(X, (2, 8), (True, True)) assert_approx_equal(y, 5.0, significant=self.dprec) y1 = stats.tmean(X, limits=(2, 8),...
class TestTrimmedStats(TestCase): # TODO: write these tests to handle missing values properly
dprec = np.finfo(np.float64).precision def test_tmean(self): y = stats.tmean(X, (2, 8), (True, True)) assert_approx_equal(y, 5.0, significant=self.dprec) y1 = stats.tmean(X, limits=(2, 8), inclusive=(False, False)) y2 = stats.tmean(X, limits=None) assert_approx_equal(y1...
94,99999995,99999996,99999997, 99999998,99999999], float) LITTLE = array([0.99999991,0.99999992,0.99999993,0.99999994,0.99999995,0.99999996, 0.99999997,0.99999998,0.99999999], float) HUGE = array([1e+12,2e+12,3e+12,4e+12,5e+12,6e+12,7e+12,8e+12,9e+12], float) TINY = array([1e-12,2e-12,3e-12...
256
256
881
21
235
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestTrimmedStats
TestTrimmedStats
54
132
54
55
61222862fc18c98f17c9abc8eaca9cfdb5c9f849
bigcode/the-stack
train
830778baf7f514deafe4e3bc
train
function
def test_gh5686(): mean1, mean2 = np.array([1, 2]), np.array([3, 4]) std1, std2 = np.array([5, 3]), np.array([4, 5]) nobs1, nobs2 = np.array([130, 140]), np.array([100, 150]) # This will raise a TypeError unless gh-5686 is fixed. stats.ttest_ind_from_stats(mean1, std1, nobs1, mean2, std2, nobs2)
def test_gh5686():
mean1, mean2 = np.array([1, 2]), np.array([3, 4]) std1, std2 = np.array([5, 3]), np.array([4, 5]) nobs1, nobs2 = np.array([130, 140]), np.array([100, 150]) # This will raise a TypeError unless gh-5686 is fixed. stats.ttest_ind_from_stats(mean1, std1, nobs1, mean2, std2, nobs2)
1, np.nan], [-1, 1]]) assert_equal(stats.ttest_ind(anan, np.zeros((2, 2)), equal_var=False), ([0, np.nan], [1, np.nan])) finally: np.seterr(**olderr) def test_gh5686():
64
64
121
7
57
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_gh5686
test_gh5686
2,463
2,468
2,463
2,463
574a2733171c5aa209912b5fa96a64f6a6b9f31f
bigcode/the-stack
train
ff6cc60df59485fe2c1e9d8a
train
function
def test_ttest_1samp_new(): n1, n2, n3 = (10,15,20) rvn1 = stats.norm.rvs(loc=5,scale=10,size=(n1,n2,n3)) # check multidimensional array and correct axis handling # deterministic rvn1 and rvn2 would be better as in test_ttest_rel t1,p1 = stats.ttest_1samp(rvn1[:,:,:], np.ones((n2,n3)),axis=0) t...
def test_ttest_1samp_new():
n1, n2, n3 = (10,15,20) rvn1 = stats.norm.rvs(loc=5,scale=10,size=(n1,n2,n3)) # check multidimensional array and correct axis handling # deterministic rvn1 and rvn2 would be better as in test_ttest_rel t1,p1 = stats.ttest_1samp(rvn1[:,:,:], np.ones((n2,n3)),axis=0) t2,p2 = stats.ttest_1samp(rvn...
anan = np.array([[1, np.nan], [-1, 1]]) assert_equal(stats.ttest_ind(anan, np.zeros((2, 2)), equal_var=False), ([0, np.nan], [1, np.nan])) finally: np.seterr(**olderr) def test_gh5686(): mean1, mean2 = np.array([1, 2]), np.array([3, 4]) std1, std2 = np.array([5, 3]), ...
194
194
648
10
184
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_ttest_1samp_new
test_ttest_1samp_new
2,471
2,511
2,471
2,471
9415eb03ca9b72448c8fd42964dab7785f26b142
bigcode/the-stack
train
4c611d4fa11048b0bdcf9950
train
class
class TestHMean(TestCase): def test_1D_list(self): a = (1,2,3,4) actual = stats.hmean(a) desired = 4. / (1./1 + 1./2 + 1./3 + 1./4) assert_almost_equal(actual, desired, decimal=14) desired1 = stats.hmean(array(a),axis=-1) assert_almost_equal(actual, desired1, decimal...
class TestHMean(TestCase):
def test_1D_list(self): a = (1,2,3,4) actual = stats.hmean(a) desired = 4. / (1./1 + 1./2 + 1./3 + 1./4) assert_almost_equal(actual, desired, decimal=14) desired1 = stats.hmean(array(a),axis=-1) assert_almost_equal(actual, desired1, decimal=14) def test_1D_array...
,2,3,4), (1,2,3,4))) actual = stats.gmean(a, axis=1) v = power(1*2*3*4,1./4.) desired = array((v,v,v)) assert_array_almost_equal(actual, desired, decimal=14) def test_large_values(self): a = array([1e100, 1e200, 1e300]) actual = stats.gmean(a) ...
126
126
421
7
119
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestHMean
TestHMean
1,003
1,041
1,003
1,003
98e14b1d9b64a96304489ce81ba01ee1e38aa3f0
bigcode/the-stack
train
55bdb8443528ff9eff6be275
train
class
class TestMode(TestCase): def test_empty(self): vals, counts = stats.mode([]) assert_equal(vals, np.array([])) assert_equal(counts, np.array([])) def test_scalar(self): vals, counts = stats.mode(4.) assert_equal(vals, np.array([4.])) assert_equal(counts, np.array...
class TestMode(TestCase):
def test_empty(self): vals, counts = stats.mode([]) assert_equal(vals, np.array([])) assert_equal(counts, np.array([])) def test_scalar(self): vals, counts = stats.mode(4.) assert_equal(vals, np.array([4.])) assert_equal(counts, np.array([1])) def test_basic...
assert_array_equal(v[:, 1], np.array([20, 10, 20, 20], dtype=dt)) dtypes = [np.int32, np.int64, np.float32, np.float64, np.complex64, np.complex128] for dt in dtypes: yield _check_itemfreq, dt def test_object_arrays(self): a, b = self.a, self.b ...
255
256
1,043
6
249
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestMode
TestMode
1,198
1,299
1,198
1,198
22879713282f2d4a7f06371f4997b28fda5f053b
bigcode/the-stack
train
0dd8ea145b8c88d61254cf41
train
class
class TestRankSums(TestCase): def test_ranksums_result_attributes(self): res = stats.ranksums(np.arange(5), np.arange(25)) attributes = ('statistic', 'pvalue') check_named_results(res, attributes)
class TestRankSums(TestCase):
def test_ranksums_result_attributes(self): res = stats.ranksums(np.arange(5), np.arange(25)) attributes = ('statistic', 'pvalue') check_named_results(res, attributes)
91) assert_array_almost_equal(stats.normaltest(x, nan_policy='omit'), expected) assert_raises(ValueError, stats.normaltest, x, nan_policy='raise') assert_raises(ValueError, stats.normaltest, x, nan_policy='foobar') class TestRankSums(TestCase):
64
64
54
8
56
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestRankSums
TestRankSums
2,670
2,674
2,670
2,670
d910d3a2708c3e13c68fa96d03bc171464c03acf
bigcode/the-stack
train
8300206062831d07ee6269b6
train
function
def test_ks_2samp(): # exact small sample solution data1 = np.array([1.0,2.0]) data2 = np.array([1.0,2.0,3.0]) assert_almost_equal(np.array(stats.ks_2samp(data1+0.01,data2)), np.array((0.33333333333333337, 0.99062316386915694))) assert_almost_equal(np.array(stats.ks_2samp(data1-0.01,...
def test_ks_2samp(): # exact small sample solution
data1 = np.array([1.0,2.0]) data2 = np.array([1.0,2.0,3.0]) assert_almost_equal(np.array(stats.ks_2samp(data1+0.01,data2)), np.array((0.33333333333333337, 0.99062316386915694))) assert_almost_equal(np.array(stats.ks_2samp(data1-0.01,data2)), np.array((0.66666666666666674,...
769)), 15) assert_almost_equal(np.array(stats.kstest(x,'norm', alternative='less')), np.array((0.12464329735846891, 0.040989164077641749)), 15) # this 'greater' test fails with precision of decimal=14 assert_almost_equal(np.array(stats.kstest(x,'norm', alternative='greater')), ...
136
136
456
16
119
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_ks_2samp
test_ks_2samp
2,153
2,183
2,153
2,154
af1d38ab9573d6f2a816e570a0f4a32958b51466
bigcode/the-stack
train
f09e8b6e83201b870d75c810
train
class
class TestSigamClip(object): def test_sigmaclip1(self): a = np.concatenate((np.linspace(9.5,10.5,31),np.linspace(0,20,5))) fact = 4 # default c, low, upp = stats.sigmaclip(a) assert_(c.min() > low) assert_(c.max() < upp) assert_equal(low, c.mean() - fact*c.std()) ...
class TestSigamClip(object):
def test_sigmaclip1(self): a = np.concatenate((np.linspace(9.5,10.5,31),np.linspace(0,20,5))) fact = 4 # default c, low, upp = stats.sigmaclip(a) assert_(c.min() > low) assert_(c.max() < upp) assert_equal(low, c.mean() - fact*c.std()) assert_equal(upp, c.mean...
2/6., axis=axis) res2 = stats.trim_mean(np.rollaxis(a, axis), 2/6.) assert_equal(res1, res2) res1 = stats.trim_mean(a, 2/6., axis=None) res2 = stats.trim_mean(a.ravel(), 2/6.) assert_equal(res1, res2) assert_raises(ValueError, stats.trim_mean, a, 0.6) #...
138
138
462
7
131
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestSigamClip
TestSigamClip
3,299
3,337
3,299
3,299
02038a7c138c64462845238d96a7264d648b40de
bigcode/the-stack
train
e65e393be4feaf6c5c9c00b9
train
function
def test_kstest(): # from numpy.testing import assert_almost_equal # comparing with values from R x = np.linspace(-1,1,9) D,p = stats.kstest(x,'norm') assert_almost_equal(D, 0.15865525393145705, 12) assert_almost_equal(p, 0.95164069201518386, 1) x = np.linspace(-15,15,9) D,p = stats.ks...
def test_kstest(): # from numpy.testing import assert_almost_equal # comparing with values from R
x = np.linspace(-1,1,9) D,p = stats.kstest(x,'norm') assert_almost_equal(D, 0.15865525393145705, 12) assert_almost_equal(p, 0.95164069201518386, 1) x = np.linspace(-15,15,9) D,p = stats.kstest(x,'norm') assert_almost_equal(D, 0.44435602715924361, 15) assert_almost_equal(p, 0.03885014008...
2[2],x2[3]), # (18.9428571428571, 0.000280938375189499)) assert_array_almost_equal(mstats.friedmanchisquare(x3[0], x3[1], x3[2], x3[3]), (10.68, 0.0135882729582176)) np.testing.assert_raises(ValueE...
131
131
438
24
107
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_kstest
test_kstest
2,117
2,148
2,117
2,120
3a85fc0c45139b9e53806553dfed1df78772f1ae
bigcode/the-stack
train
4171a7d64c4ebe8d4634cc34
train
function
def test_theilslopes(): # Basic slope test. slope, intercept, lower, upper = stats.theilslopes([0,1,1]) assert_almost_equal(slope, 0.5) assert_almost_equal(intercept, 0.5) # Test of confidence intervals. x = [1, 2, 3, 4, 10, 12, 18] y = [9, 15, 19, 20, 45, 55, 78] slope, intercept, lowe...
def test_theilslopes(): # Basic slope test.
slope, intercept, lower, upper = stats.theilslopes([0,1,1]) assert_almost_equal(slope, 0.5) assert_almost_equal(intercept, 0.5) # Test of confidence intervals. x = [1, 2, 3, 4, 10, 12, 18] y = [9, 15, 19, 20, 45, 55, 78] slope, intercept, lower, upper = stats.theilslopes(y, x, 0.07) ass...
] = np.nan with warnings.catch_warnings(): warnings.simplefilter("ignore", RuntimeWarning) assert_array_equal(stats.linregress(x, x), (np.nan, np.nan, np.nan, np.nan, np.nan)) def test_theilslopes(): # Basic slope test.
64
64
182
13
51
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_theilslopes
test_theilslopes
776
788
776
777
22564fad84af6333a41cc4581bcdd1c77ee0c868
bigcode/the-stack
train
d4d84e7e765fe46e2ad2a5a4
train
function
def test_relfreq(): a = np.array([1, 4, 2, 1, 3, 1]) relfreqs, lowlim, binsize, extrapoints = stats.relfreq(a, numbins=4) assert_array_almost_equal(relfreqs, array([0.5, 0.16666667, 0.16666667, 0.16666667])) # test for namedtuple attribute results attributes = ('freque...
def test_relfreq():
a = np.array([1, 4, 2, 1, 3, 1]) relfreqs, lowlim, binsize, extrapoints = stats.relfreq(a, numbins=4) assert_array_almost_equal(relfreqs, array([0.5, 0.16666667, 0.16666667, 0.16666667])) # test for namedtuple attribute results attributes = ('frequency', 'lowerlimit', ...
tuple attribute results attributes = ('cumcount', 'lowerlimit', 'binsize', 'extrapoints') res = stats.cumfreq(x, numbins=4, defaultreallimits=(1.5, 5)) check_named_results(res, attributes) def test_relfreq():
64
64
209
6
58
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_relfreq
test_relfreq
940
954
940
940
948487502e2c7ffeb61942603d7674d603904d15
bigcode/the-stack
train
034db0ec1fa58c9f7de4aec5
train
class
class TestHarMean(HarMeanTestCase, TestCase): def do(self, a, b, axis=None, dtype=None): x = stats.hmean(a, axis=axis, dtype=dtype) assert_almost_equal(b, x) assert_equal(x.dtype, dtype)
class TestHarMean(HarMeanTestCase, TestCase):
def do(self, a, b, axis=None, dtype=None): x = stats.hmean(a, axis=axis, dtype=dtype) assert_almost_equal(b, x) assert_equal(x.dtype, dtype)
90, 100, 110, 120]] b = np.matrix([[19.2, 63.03939962, 103.80078637]]).T self.do(np.matrix(a), b, axis=1) class TestHarMean(HarMeanTestCase, TestCase):
64
64
61
13
51
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestHarMean
TestHarMean
2,971
2,975
2,971
2,971
747308a404dea2060ce385dbfa18a5a454ebef12
bigcode/the-stack
train
cd4e1be8b3ed4dd2d8142e42
train
function
def test_ttest_ind(): # regression test tr = 1.0912746897927283 pr = 0.27647818616351882 tpr = ([tr,-tr],[pr,pr]) rvs2 = np.linspace(1,100,100) rvs1 = np.linspace(5,105,100) rvs1_2D = np.array([rvs1, rvs2]) rvs2_2D = np.array([rvs2, rvs1]) t,p = stats.ttest_ind(rvs1, rvs2, axis=0) ...
def test_ttest_ind(): # regression test
tr = 1.0912746897927283 pr = 0.27647818616351882 tpr = ([tr,-tr],[pr,pr]) rvs2 = np.linspace(1,100,100) rvs1 = np.linspace(5,105,100) rvs1_2D = np.array([rvs1, rvs2]) rvs2_2D = np.array([rvs2, rvs1]) t,p = stats.ttest_ind(rvs1, rvs2, axis=0) assert_array_almost_equal([t,p],(tr,pr))...
, 0, 0]), (np.nan, np.nan)) olderr = np.seterr(all='ignore') try: # check that nan in input array result in nan output anan = np.array([[1, np.nan], [-1, 1]]) assert_equal(stats.ttest_rel(anan, np.zeros((2, 2))), ([0, np.nan], [1, np.nan])) finally: np.s...
256
256
970
11
245
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_ttest_ind
test_ttest_ind
2,274
2,349
2,274
2,275
74ca2a8cd8490fdfdea993155413688dbcb06be4
bigcode/the-stack
train
970280929c936c022ffe9dd9
train
class
class TestGeoMean(GeoMeanTestCase, TestCase): def do(self, a, b, axis=None, dtype=None): # Note this doesn't test when axis is not specified x = stats.gmean(a, axis=axis, dtype=dtype) assert_almost_equal(b, x) assert_equal(x.dtype, dtype)
class TestGeoMean(GeoMeanTestCase, TestCase):
def do(self, a, b, axis=None, dtype=None): # Note this doesn't test when axis is not specified x = stats.gmean(a, axis=axis, dtype=dtype) assert_almost_equal(b, x) assert_equal(x.dtype, dtype)
80, 90, -1]) b = 41.4716627439 olderr = np.seterr(all='ignore') try: self.do(a, b) finally: np.seterr(**olderr) class TestGeoMean(GeoMeanTestCase, TestCase):
64
64
73
13
51
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestGeoMean
TestGeoMean
3,087
3,092
3,087
3,087
4e7894d9adf2e507e9f2faa1ba962ccb63b6d2aa
bigcode/the-stack
train
a4d46a461454cb310677c4ef
train
function
def test_kurtosistest_too_few_samples(): # Regression test for ticket #1425. # kurtosistest requires at least 5 samples; 4 should raise a ValueError. x = np.arange(4.0) assert_raises(ValueError, stats.kurtosistest, x)
def test_kurtosistest_too_few_samples(): # Regression test for ticket #1425. # kurtosistest requires at least 5 samples; 4 should raise a ValueError.
x = np.arange(4.0) assert_raises(ValueError, stats.kurtosistest, x)
.arange(7.0) assert_raises(ValueError, stats.skewtest, x) def test_kurtosistest_too_few_samples(): # Regression test for ticket #1425. # kurtosistest requires at least 5 samples; 4 should raise a ValueError.
64
64
70
44
20
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_kurtosistest_too_few_samples
test_kurtosistest_too_few_samples
2,710
2,714
2,710
2,712
d1128ab728359cb5e1defb63598efc079c5fafbe
bigcode/the-stack
train
14c524fde5665693e1a19ffc
train
class
class TestTrim(object): # test trim functions def test_trim1(self): a = np.arange(11) assert_equal(np.sort(stats.trim1(a, 0.1)), np.arange(10)) assert_equal(np.sort(stats.trim1(a, 0.2)), np.arange(9)) assert_equal(np.sort(stats.trim1(a, 0.2, tail='left')), np...
class TestTrim(object): # test trim functions
def test_trim1(self): a = np.arange(11) assert_equal(np.sort(stats.trim1(a, 0.1)), np.arange(10)) assert_equal(np.sort(stats.trim1(a, 0.2)), np.arange(9)) assert_equal(np.sort(stats.trim1(a, 0.2, tail='left')), np.arange(2, 11)) assert_equal(np.sort(stats...
0.7205416252126137, 0.722454130389843, 0.723956813292035, 0.823802947998047, 0.701255953767043, 0.715928221686075, 0.723772209289768, 0.7286603031173616, 0.7319999279787631, 0.7344267920995765, 0.736270323773157, 0.737718376096348 ]) res4_p1 = [stats.binom_test(v+1, v*k,...
256
256
1,056
11
245
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestTrim
TestTrim
3,224
3,296
3,224
3,225
b7563b02ea3b23001d91852e4c7271f2ff6b2442
bigcode/the-stack
train
7ea6bfeae15feb9631c0e4c0
train
class
class TestCorrSpearmanr(TestCase): """ W.II.D. Compute a correlation matrix on all the variables. All the correlations, except for ZERO and MISS, shoud be exactly 1. ZERO and MISS should have undefined or missing correlations with the other variables. The same should go for SPEARMAN corela...
class TestCorrSpearmanr(TestCase):
""" W.II.D. Compute a correlation matrix on all the variables. All the correlations, except for ZERO and MISS, shoud be exactly 1. ZERO and MISS should have undefined or missing correlations with the other variables. The same should go for SPEARMAN corelations, if your program has ...
0149169715733], [1.0, 2.0056578803889148e-122], [1.0, 5.7284374608319831e-44], [0.7416227, 0.2959826], # Exact: [0.1, 1.0], [0.7, 0.9], [1.0, 0.3], [2./3, 1.0], [1.0, 1./3], ) for table, pval ...
255
256
1,204
9
246
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestCorrSpearmanr
TestCorrSpearmanr
402
537
402
402
403340806b3a43acf4d476a5fc3de8f4467229cf
bigcode/the-stack
train
bcabc82419b61cebd645c1ba
train
class
class TestRegression(TestCase): def test_linregressBIGX(self): # W.II.F. Regress BIG on X. # The constant should be 99999990 and the regression coefficient should be 1. y = stats.linregress(X,BIG) intercept = y[1] r = y[2] assert_almost_equal(intercept,99999990) ...
class TestRegression(TestCase):
def test_linregressBIGX(self): # W.II.F. Regress BIG on X. # The constant should be 99999990 and the regression coefficient should be 1. y = stats.linregress(X,BIG) intercept = y[1] r = y[2] assert_almost_equal(intercept,99999990) assert_almost_equal(r,1.0) ...
raises(ValueError, stats.kendalltau, x, x, nan_policy='raise') assert_raises(ValueError, stats.kendalltau, x, x, nan_policy='foobar') # test unequal length inputs x = np.arange(10.) y = np.arange(20.) assert_raises(ValueError, stats.kendalltau, x, y) class TestFindRepeats(TestCase): def test...
255
256
1,786
6
249
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestRegression
TestRegression
639
773
639
639
72829d2bc65765e6bc5ec2b283028cedf887c411
bigcode/the-stack
train
f56235ac8d81d5bac91a6c4f
train
function
def test_cumfreq(): x = [1, 4, 2, 1, 3, 1] cumfreqs, lowlim, binsize, extrapoints = stats.cumfreq(x, numbins=4) assert_array_almost_equal(cumfreqs, np.array([3., 4., 5., 6.])) cumfreqs, lowlim, binsize, extrapoints = stats.cumfreq(x, numbins=4, defau...
def test_cumfreq():
x = [1, 4, 2, 1, 3, 1] cumfreqs, lowlim, binsize, extrapoints = stats.cumfreq(x, numbins=4) assert_array_almost_equal(cumfreqs, np.array([3., 4., 5., 6.])) cumfreqs, lowlim, binsize, extrapoints = stats.cumfreq(x, numbins=4, defaultreallimits=(1.5, 5...
.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) res = stats.histogram(self.low_range, numbins=20) attributes = ('count', 'lowerlimit', 'binsize', 'extrapoints') check_named_results(res, attributes) def test_cumfreq():
64
64
189
6
58
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_cumfreq
test_cumfreq
926
937
926
926
73fe683e755080db36a82ed1d5357deb9ba7f35c
bigcode/the-stack
train
007c607cd39bd273d3483c62
train
class
class TestStudentTest(TestCase): X1 = np.array([-1, 0, 1]) X2 = np.array([0, 1, 2]) T1_0 = 0 P1_0 = 1 T1_1 = -1.732051 P1_1 = 0.2254033 T1_2 = -3.464102 P1_2 = 0.0741799 T2_0 = 1.732051 P2_0 = 0.2254033 def test_onesample(self): with warnings.catch_warnings(): ...
class TestStudentTest(TestCase):
X1 = np.array([-1, 0, 1]) X2 = np.array([0, 1, 2]) T1_0 = 0 P1_0 = 1 T1_1 = -1.732051 P1_1 = 0.2254033 T1_2 = -3.464102 P1_2 = 0.0741799 T2_0 = 1.732051 P2_0 = 0.2254033 def test_onesample(self): with warnings.catch_warnings(): warnings.filterwarnings('ig...
_basic(self): a = [-1, 2, 3, 4, 5, -1, -2] with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=DeprecationWarning) assert_array_equal(stats.threshold(a), a) assert_array_equal(stats.threshold(a, 3, None, 0), [0, 0,...
180
180
601
7
173
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestStudentTest
TestStudentTest
1,572
1,627
1,572
1,572
053e3865608cdc5dee4dd395756a7f45abd731f1
bigcode/the-stack
train
ff96c0214f383ce91a3dc1c9
train
class
class TestScoreatpercentile(TestCase): def setUp(self): self.a1 = [3, 4, 5, 10, -3, -5, 6] self.a2 = [3, -6, -2, 8, 7, 4, 2, 1] self.a3 = [3., 4, 5, 10, -3, -5, -6, 7.0] def test_basic(self): x = arange(8) * 0.5 assert_equal(stats.scoreatpercentile(x, 0), 0.) ass...
class TestScoreatpercentile(TestCase):
def setUp(self): self.a1 = [3, 4, 5, 10, -3, -5, 6] self.a2 = [3, -6, -2, 8, 7, 4, 2, 1] self.a3 = [3., 4, 5, 10, -3, -5, -6, 7.0] def test_basic(self): x = arange(8) * 0.5 assert_equal(stats.scoreatpercentile(x, 0), 0.) assert_equal(stats.scoreatpercentile(x, 10...
=14) desired1 = stats.hmean(a,axis=-1) assert_almost_equal(actual, desired1, decimal=14) def test_2D_array_default(self): a = array(((1,2,3,4), (1,2,3,4), (1,2,3,4))) actual = stats.hmean(a) desired = array((1.,2.,3.,4.)) assert...
256
256
1,513
9
247
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestScoreatpercentile
TestScoreatpercentile
1,044
1,158
1,044
1,044
a168474cbd6e24dccac4b34b21a5b5606afab0e4
bigcode/the-stack
train
0ee6fc81e1fdfc18c468b95b
train
class
class GeoMeanTestCase: def test_1dlist(self): # Test a 1d list a = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] b = 45.2872868812 self.do(a, b) def test_1darray(self): # Test a 1d array a = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) b = 45.2872868...
class GeoMeanTestCase:
def test_1dlist(self): # Test a 1d list a = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] b = 45.2872868812 self.do(a, b) def test_1darray(self): # Test a 1d array a = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) b = 45.2872868812 self.do(a, ...
a = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]] b = np.matrix([[22.88135593, 39.13043478, 52.90076336, 65.45454545]]) self.do(np.matrix(a), b, axis=0) def test_2dmatrixaxis1(self): # Test a 2d list with axis=1 a = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100,...
256
256
1,410
6
250
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
GeoMeanTestCase
GeoMeanTestCase
2,978
3,084
2,978
2,978
3087cd39ef5e6187e7a2e2b851a5f97287819bd8
bigcode/the-stack
train
30e7ac0534fa8b978c82ea04
train
class
class TestPoloidalFieldCoilCaseSetFC(unittest.TestCase): def setUp(self): self.pf_coils_set = paramak.PoloidalFieldCoilSet( heights=[10, 10, 20, 20], widths=[10, 10, 20, 40], center_points=[(100, 100), (100, 150), (50, 200), (50, 50)], ) self.test_shape ...
class TestPoloidalFieldCoilCaseSetFC(unittest.TestCase):
def setUp(self): self.pf_coils_set = paramak.PoloidalFieldCoilSet( heights=[10, 10, 20, 20], widths=[10, 10, 20, 40], center_points=[(100, 100), (100, 150), (50, 200), (50, 50)], ) self.test_shape = paramak.PoloidalFieldCoilCaseSetFC( pf_coils...
import math import unittest import paramak import pytest class TestPoloidalFieldCoilCaseSetFC(unittest.TestCase):
29
256
2,668
15
13
moatazharb/paramak
tests/test_parametric_components/test_PoloidalFieldCoilCaseSetFC.py
Python
TestPoloidalFieldCoilCaseSetFC
TestPoloidalFieldCoilCaseSetFC
9
215
9
10
499a251a72865adfe6ade1d269eeb9bbe9e19945
bigcode/the-stack
train
39cffedde75638e214465f44
train
function
def osascript(*args): subprocess.check_call(["osascript"] + list(args))
def osascript(*args):
subprocess.check_call(["osascript"] + list(args))
import subprocess def osascript(*args):
10
64
19
7
2
fredcallaway/SendCode
code_sender/applescript.py
Python
osascript
osascript
4
5
4
4
d47c5376f2115b4ce39629095b06351301467509
bigcode/the-stack
train
876d95666b8c8dd5e22b126d
train
class
class V1ReplicaSetSpec(object): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ """ Attributes: openapi_types (dict): The key is attribute name and the value is attribute type....
class V1ReplicaSetSpec(object):
"""NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ """ Attributes: openapi_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The...
# coding: utf-8 """ Kubernetes No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 OpenAPI spec version: v1.15.7 Generated by: https://openapi-generator.tech """ import pprint import re # noqa: F401 import six class V1ReplicaSet...
87
256
1,405
8
78
itholic/python
kubernetes/client/models/v1_replica_set_spec.py
Python
V1ReplicaSetSpec
V1ReplicaSetSpec
19
195
19
19
71e756a00514bea34f08bb8575a9c430e581018a
bigcode/the-stack
train
101db2af9cae675751dac402
train
class
class TransformerDecoderLayer(TransformerDecoderLayerBase): def __init__( self, args, no_encoder_attn=False, add_bias_kv=False, add_zero_attn=False ): super().__init__( TransformerConfig.from_namespace(args), no_encoder_attn=no_encoder_attn, add_bias_kv=add_bi...
class TransformerDecoderLayer(TransformerDecoderLayerBase):
def __init__( self, args, no_encoder_attn=False, add_bias_kv=False, add_zero_attn=False ): super().__init__( TransformerConfig.from_namespace(args), no_encoder_attn=no_encoder_attn, add_bias_kv=add_bias_kv, add_zero_attn=add_zero_attn, ) ...
n, self_attn_state return x, attn, None def make_generation_fast_(self, need_attn: bool = False, **kwargs): self.need_attn = need_attn # backward compatible with the legacy argparse format class TransformerDecoderLayer(TransformerDecoderLayerBase):
64
64
196
10
53
marcinkusz/fairseq
fairseq/modules/transformer_layer.py
Python
TransformerDecoderLayer
TransformerDecoderLayer
430
456
430
430
deafbb3d835760537b66c067d868c7cc4c69b948
bigcode/the-stack
train
c49b85f47b351683406356b0
train
class
class TransformerEncoderLayer(TransformerEncoderLayerBase): def __init__(self, args): super().__init__(TransformerConfig.from_namespace(args)) self.args = args def build_self_attention(self, embed_dim, args): return super().build_self_attention( embed_dim, TransformerConfig....
class TransformerEncoderLayer(TransformerEncoderLayerBase):
def __init__(self, args): super().__init__(TransformerConfig.from_namespace(args)) self.args = args def build_self_attention(self, embed_dim, args): return super().build_self_attention( embed_dim, TransformerConfig.from_namespace(args) )
= self.fc2(x) x = self.dropout_module(x) x = self.residual_connection(x, residual) if not self.normalize_before: x = self.final_layer_norm(x) return x # backward compatible with the legacy argparse format class TransformerEncoderLayer(TransformerEncoderLayerBase):
64
64
68
10
53
marcinkusz/fairseq
fairseq/modules/transformer_layer.py
Python
TransformerEncoderLayer
TransformerEncoderLayer
166
174
166
166
cf35833b874737e7bb0dd9e66ea199f88dcf6b09
bigcode/the-stack
train
e9816c50e1c0db6ec6a797d7
train
class
class TransformerEncoderLayerBase(nn.Module): """Encoder layer block. In the original paper each operation (multi-head attention or FFN) is postprocessed with: `dropout -> add residual -> layernorm`. In the tensor2tensor code they suggest that learning is more robust when preprocessing each layer w...
class TransformerEncoderLayerBase(nn.Module):
"""Encoder layer block. In the original paper each operation (multi-head attention or FFN) is postprocessed with: `dropout -> add residual -> layernorm`. In the tensor2tensor code they suggest that learning is more robust when preprocessing each layer with layernorm and postprocessing with: `dr...
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict, List, Optional import torch import torch.nn as nn from fairseq import utils from fairseq.modules import LayerNorm, M...
126
256
1,294
8
118
marcinkusz/fairseq
fairseq/modules/transformer_layer.py
Python
TransformerEncoderLayerBase
TransformerEncoderLayerBase
20
162
20
20
e94e02d2a7ffb078e691c36e2594d5c73965ba94
bigcode/the-stack
train
d52705bdedf007957f7c50ba
train
class
class TransformerDecoderLayerBase(nn.Module): """Decoder layer block. In the original paper each operation (multi-head attention, encoder attention or FFN) is postprocessed with: `dropout -> add residual -> layernorm`. In the tensor2tensor code they suggest that learning is more robust when preproc...
class TransformerDecoderLayerBase(nn.Module):
"""Decoder layer block. In the original paper each operation (multi-head attention, encoder attention or FFN) is postprocessed with: `dropout -> add residual -> layernorm`. In the tensor2tensor code they suggest that learning is more robust when preprocessing each layer with layernorm and postproce...
x, _ = self.self_attn( query=x, key=x, value=x, key_padding_mask=encoder_padding_mask, need_weights=False, attn_mask=attn_mask, ) x = self.dropout_module(x) x = self.residual_connection(x, residual) if not se...
256
256
2,126
8
248
marcinkusz/fairseq
fairseq/modules/transformer_layer.py
Python
TransformerDecoderLayerBase
TransformerDecoderLayerBase
177
426
177
177
05842247ee6adba02b1c5685c33587e0d32cadd2
bigcode/the-stack
train
188dded7ecdd3eb24855be60
train
function
def reserva(): py.click(x=1919, y=1076) try: py.leftClick(py.locateOnScreen(Imagens.Imagens.mais)) sleep(2) py.doubleClick(py.locateOnScreen(Imagens.Imagens.razer2, confidence=0.9)) sleep(2) aaaaa = py.locateOnScreen(Imagens.Imagens.teste) py.moveTo(aaaaa[0] + 20...
def reserva():
py.click(x=1919, y=1076) try: py.leftClick(py.locateOnScreen(Imagens.Imagens.mais)) sleep(2) py.doubleClick(py.locateOnScreen(Imagens.Imagens.razer2, confidence=0.9)) sleep(2) aaaaa = py.locateOnScreen(Imagens.Imagens.teste) py.moveTo(aaaaa[0] + 200, aaaaa[1] + 1...
")) sleep(0.5) webbrowser.get('chrome').open('https://mail.google.com/mail/u/0/?zx=7quikovz9bly#inbox') sleep(1) sleep(0.5) if f != 0: reserva() def reserva():
64
64
165
3
61
GabrielCoutz/Automa--es
Auto.py
Python
reserva
reserva
239
255
239
239
26f82eebeb0ea8105c581c156521e947445318c9
bigcode/the-stack
train
2dda410c8a3e87baffaa073a
train
function
def google(): sites = ['https://www.youtube.com', 'https://www.imissmybar.com/', 'https://mail.google.com/mail/u/0/?zx=7quikovz9bly#inbox'] webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(r"C:\Program Files\Google\Chrome\Application\c...
def google():
sites = ['https://www.youtube.com', 'https://www.imissmybar.com/', 'https://mail.google.com/mail/u/0/?zx=7quikovz9bly#inbox'] webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(r"C:\Program Files\Google\Chrome\Application\chrome.exe")) ...
0.2) sleep(1) try: py.leftClick(Imagens.Imagens.conf2) except: py.leftClick(Imagens.Imagens.conf) pos1 = py.position() py.doubleClick(pos1[0] - 34, pos1[1] + 82) py.doubleClick(pos1[0] - 34, pos1[1] + 82) py.doubleClick(pos1[0] - 34, pos1[1] + 82) sleep(1.5) pos = ...
201
201
673
3
198
GabrielCoutz/Automa--es
Auto.py
Python
google
google
145
224
145
145
8e2293fb0cbfa68f129150ffc89f1a7dfc0b55cb
bigcode/the-stack
train
dd1eabbacd5dd37f8c762514
train
function
def verificar(imagem, left=None, top=None, width=None, height=None): if left: if py.locateOnScreen(imagem, region=(left, top, width, height)): return True return False else: if py.locateCenterOnScreen(imagem, confidence=0.9): return True else: ...
def verificar(imagem, left=None, top=None, width=None, height=None):
if left: if py.locateOnScreen(imagem, region=(left, top, width, height)): return True return False else: if py.locateCenterOnScreen(imagem, confidence=0.9): return True else: return False
a += 1 log3 = py.locateCenterOnScreen(r'E:\Backup\backup PC\Imagens\log33.png') if log3: py.click(log3) sleep(4) def verificar(imagem, left=None, top=None, width=None, height=None):
64
64
80
17
47
GabrielCoutz/Automa--es
Auto.py
Python
verificar
verificar
57
66
57
57
02ea29b1292c94e26e1c35d943f0194f1be5b29b
bigcode/the-stack
train
5ad32380e1ddf891d9c46f43
train
function
def login(x, y): py.click(x, y) while verificar(Imagens.Imagens.conta1) is False: sleep(0.1) py.press('tab', 5) sleep(1) py.press('enter') sleep(1.5) a = 0 while verificar(Imagens.Imagens.log33) is False and a != 5: sleep(1) a += 1 log3 = py.locateCenterOnScre...
def login(x, y):
py.click(x, y) while verificar(Imagens.Imagens.conta1) is False: sleep(0.1) py.press('tab', 5) sleep(1) py.press('enter') sleep(1.5) a = 0 while verificar(Imagens.Imagens.log33) is False and a != 5: sleep(1) a += 1 log3 = py.locateCenterOnScreen(r'E:\Backup\ba...
# Biblioteca de Imagens spec = importlib.util.spec_from_file_location( "name", "C:\\Users\\Gabri\\PycharmProjects\\pythonProject\\Imagens.py") Imagens = importlib.util.module_from_spec(spec) spec.loader.exec_module(Imagens) def login(x, y):
64
64
137
6
58
GabrielCoutz/Automa--es
Auto.py
Python
login
login
39
54
39
39
a2c8f1a9601989311f81bd37ef126447abaacc07
bigcode/the-stack
train
9150b5ccc6298b82b736c321
train
function
def inicio(): r = randint(1, 5) winsound.PlaySound(f'E:\\Backup\\Musicas\\intro{r}.wav', winsound.SND_ASYNC)
def inicio():
r = randint(1, 5) winsound.PlaySound(f'E:\\Backup\\Musicas\\intro{r}.wav', winsound.SND_ASYNC)
)): return True return False else: if py.locateCenterOnScreen(imagem, confidence=0.9): return True else: return False def esperar(imagem): while verificar(imagem) is False: sleep(0.2) def inicio():
64
64
39
3
61
GabrielCoutz/Automa--es
Auto.py
Python
inicio
inicio
74
76
74
74
0a5972a2eb4f9feeb0f6819e7a8caa54523981e7
bigcode/the-stack
train
e8c3ad32fb179ce4bd3965a0
train
function
def googlefds(): webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(r"C:\Program Files\Google\Chrome\Application\chrome.exe")) sleep(0.5) webbrowser.get('chrome').open('https://mail.google.com/mail/u/0/?zx=7quikovz9bly#inbox') sleep(1) sl...
def googlefds():
webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(r"C:\Program Files\Google\Chrome\Application\chrome.exe")) sleep(0.5) webbrowser.get('chrome').open('https://mail.google.com/mail/u/0/?zx=7quikovz9bly#inbox') sleep(1) sleep(0.5) if f...
ra, barras[a]) sleep(0.5) for b, c in enumerate(plays): py.leftClick(play, plays[b]) sleep(0.5) py.leftClick(x=25, y=14) if f != 0: reserva() def googlefds():
64
64
93
4
60
GabrielCoutz/Automa--es
Auto.py
Python
googlefds
googlefds
227
236
227
227
8c224cecbd087aa618542e67e24d501c51e6855c
bigcode/the-stack
train
d53ee2bb232401907085db44
train
function
def powersheel(comando): os.system(f'powershell /c {comando}')
def powersheel(comando):
os.system(f'powershell /c {comando}')
(imagem): while verificar(imagem) is False: sleep(0.2) def inicio(): r = randint(1, 5) winsound.PlaySound(f'E:\\Backup\\Musicas\\intro{r}.wav', winsound.SND_ASYNC) def powersheel(comando):
64
64
19
6
58
GabrielCoutz/Automa--es
Auto.py
Python
powersheel
powersheel
79
80
79
79
3d15be2acd6a6926a2f3e654ecd4933b4022cdfd
bigcode/the-stack
train
7df47aca61745a94b3f3b0ce
train
function
def resolver(): global c powersheel(r'Start-Process -WindowStyle hidden -FilePath C:\Users\Gabri\Documents\dpclat.exe') while not window.getWindowsWithTitle("Error"): sleep(0.2) c += 1 if c == 5: break if window.getWindowsWithTitle("Error"): window.getWindowsW...
def resolver():
global c powersheel(r'Start-Process -WindowStyle hidden -FilePath C:\Users\Gabri\Documents\dpclat.exe') while not window.getWindowsWithTitle("Error"): sleep(0.2) c += 1 if c == 5: break if window.getWindowsWithTitle("Error"): window.getWindowsWithTitle("Error"...
2) def inicio(): r = randint(1, 5) winsound.PlaySound(f'E:\\Backup\\Musicas\\intro{r}.wav', winsound.SND_ASYNC) def powersheel(comando): os.system(f'powershell /c {comando}') def resolver():
63
64
124
3
60
GabrielCoutz/Automa--es
Auto.py
Python
resolver
resolver
83
93
83
83
c473664f849df80d23e2e630bd7bb17e36292913
bigcode/the-stack
train
175ed07e53f293ad45db0bbb
train
function
def esperar(imagem): while verificar(imagem) is False: sleep(0.2)
def esperar(imagem):
while verificar(imagem) is False: sleep(0.2)
if py.locateOnScreen(imagem, region=(left, top, width, height)): return True return False else: if py.locateCenterOnScreen(imagem, confidence=0.9): return True else: return False def esperar(imagem):
64
64
21
5
58
GabrielCoutz/Automa--es
Auto.py
Python
esperar
esperar
69
71
69
69
917c7676802f6acd1ac5f9bd00ac82804b0288f7
bigcode/the-stack
train
7838c74fd9e13afa0dbb9c49
train
function
def som(): global f py.click(Imagens.Imagens.mais) if verificar(Imagens.Imagens.razeratt) is False: try: esperar(Imagens.Imagens.razer2) py.doubleClick(py.locateOnScreen(Imagens.Imagens.razer2, confidence=0.9)) esperar(Imagens.Imagens.teste) if verifi...
def som():
global f py.click(Imagens.Imagens.mais) if verificar(Imagens.Imagens.razeratt) is False: try: esperar(Imagens.Imagens.razer2) py.doubleClick(py.locateOnScreen(Imagens.Imagens.razer2, confidence=0.9)) esperar(Imagens.Imagens.teste) if verificar(Imagens...
def resolver(): global c powersheel(r'Start-Process -WindowStyle hidden -FilePath C:\Users\Gabri\Documents\dpclat.exe') while not window.getWindowsWithTitle("Error"): sleep(0.2) c += 1 if c == 5: break if window.getWindowsWithTitle("Error"): window.getWindowsW...
127
127
426
3
124
GabrielCoutz/Automa--es
Auto.py
Python
som
som
96
142
96
96
e7fe583f6bf43a739c538ffe53ca70d1251b8cb4
bigcode/the-stack
train
bf762b167249a025f1c2853c
train
function
def test_attri2vec_constructor(): attri2vec = Attri2Vec( layer_sizes=[4], input_dim=2, node_num=4, multiplicity=2, normalize="l2" ) assert attri2vec.dims == [2, 4] assert attri2vec.input_node_num == 4 assert attri2vec.n_layers == 1 assert attri2vec.bias == False # Check incorrect ac...
def test_attri2vec_constructor():
attri2vec = Attri2Vec( layer_sizes=[4], input_dim=2, node_num=4, multiplicity=2, normalize="l2" ) assert attri2vec.dims == [2, 4] assert attri2vec.input_node_num == 4 assert attri2vec.n_layers == 1 assert attri2vec.bias == False # Check incorrect activation flag with pytest.rais...
implied. # See the License for the specific language governing permissions and # limitations under the License. """ Attri2Vec tests """ from stellargraph.core.graph import StellarGraph from stellargraph.mapper import Attri2VecNodeGenerator from stellargraph.layer.attri2vec import * from tensorflow import keras imp...
115
115
386
8
106
timpitman/stellargraph
tests/layer/test_attri2vec.py
Python
test_attri2vec_constructor
test_attri2vec_constructor
37
87
37
37
52c498407d0d7607926a6fae8ef64f601d3586ca
bigcode/the-stack
train
802335c2b3f16993d503e752
train
function
def test_attri2vec_serialize(): attri2vec = Attri2Vec( layer_sizes=[4], bias=False, input_dim=2, node_num=4, multiplicity=2, activation="linear", normalize=None, ) inp = keras.Input(shape=(2,)) out = attri2vec(inp) model = keras.Model(inputs=i...
def test_attri2vec_serialize():
attri2vec = Attri2Vec( layer_sizes=[4], bias=False, input_dim=2, node_num=4, multiplicity=2, activation="linear", normalize=None, ) inp = keras.Input(shape=(2,)) out = attri2vec(inp) model = keras.Model(inputs=inp, outputs=out) # Save mod...
w in model4.get_weights()] model4.set_weights(model_weights4) actual = model4.predict([x1, x2]) assert pytest.approx(y1) == actual[0] assert pytest.approx(y2) == actual[1] def test_attri2vec_serialize():
64
64
211
9
55
timpitman/stellargraph
tests/layer/test_attri2vec.py
Python
test_attri2vec_serialize
test_attri2vec_serialize
143
173
143
143
48e34a5aae6e2e1c9060f9607be3d8c84db3276a
bigcode/the-stack
train
3e709b7e9d833f6b007b9520
train
function
def test_attri2vec_apply(): attri2vec = Attri2Vec( layer_sizes=[2, 2, 2], bias=False, input_dim=2, node_num=4, multiplicity=2, activation="linear", normalize=None, ) x = np.array([[1, 2]]) expected = np.array([[12, 12]]) inp = keras.Input(sha...
def test_attri2vec_apply():
attri2vec = Attri2Vec( layer_sizes=[2, 2, 2], bias=False, input_dim=2, node_num=4, multiplicity=2, activation="linear", normalize=None, ) x = np.array([[1, 2]]) expected = np.array([[12, 12]]) inp = keras.Input(shape=(2,)) out = attri2vec...
requirement for generator or input_dim and node_num & multiplicity with pytest.raises(KeyError): Attri2Vec(layer_sizes=[4]) # Construction from generator G = example_graph(feature_size=3) gen = Attri2VecNodeGenerator(G, batch_size=2) attri2vec = Attri2Vec(layer_sizes=[4, 8], generator=gen,...
146
146
487
8
137
timpitman/stellargraph
tests/layer/test_attri2vec.py
Python
test_attri2vec_apply
test_attri2vec_apply
90
140
90
90
962de08b6e4c7dc6e6be29bf96c5851239424cff
bigcode/the-stack
train
cc58d053ca868301626623c3
train
function
def main() -> typing.NoReturn: n = int(input()) edges = set() for i in range(n - 1): for j in range(i + 1, n): edges.add((i, j)) if n & 1: for i in range(n // 2): edges.remove((i, n - 2 - i)) else: for i in range(n // 2): edg...
def main() -> typing.NoReturn:
n = int(input()) edges = set() for i in range(n - 1): for j in range(i + 1, n): edges.add((i, j)) if n & 1: for i in range(n // 2): edges.remove((i, n - 2 - i)) else: for i in range(n // 2): edges.remove((i, n - 1 - i)) ...
import typing def main() -> typing.NoReturn:
11
64
131
8
2
kagemeka/atcoder-submissions
jp.atcoder/agc032/agc032_b/27917968.py
Python
main
main
4
21
4
4
cb0747145702962f4132673acfe05717656afd07
bigcode/the-stack
train
fdde0c20f2ad02c71136bcf8
train
function
def get_one_process(proc_name): try: global processDataList # print(proc_name) # proclist = process_list() oneProcData = {} current_process = psutil.pids() if int(proc_name) in current_process: dtime = datetime.now().strftime("%H:%M:%S") # 只有时分秒 ...
def get_one_process(proc_name):
try: global processDataList # print(proc_name) # proclist = process_list() oneProcData = {} current_process = psutil.pids() if int(proc_name) in current_process: dtime = datetime.now().strftime("%H:%M:%S") # 只有时分秒 oneProcData["datetime"] = dt...
(): procs = psutil.pids() proclist = [] for aPid in procs: # print(a) aProcName = psutil.Process(aPid).name() proc_data = (aPid, aProcName) proclist.append(proc_data) return proclist def get_one_process(proc_name):
73
73
246
7
65
re0phimes/FlaskTest
FlaskApp/test.py
Python
get_one_process
get_one_process
22
45
22
22
d23ad27fec1dac468448b4d2d9b47b69d7400175
bigcode/the-stack
train
72b62a851b5ae0b4ba1e5187
train
function
def process_list(): procs = psutil.pids() proclist = [] for aPid in procs: # print(a) aProcName = psutil.Process(aPid).name() proc_data = (aPid, aProcName) proclist.append(proc_data) return proclist
def process_list():
procs = psutil.pids() proclist = [] for aPid in procs: # print(a) aProcName = psutil.Process(aPid).name() proc_data = (aPid, aProcName) proclist.append(proc_data) return proclist
from threading import Timer import time, schedule import psutil from datetime import datetime from forms import ProcessForm from getPCmemory import get_one_process processDataList = [] def process_list():
43
64
69
4
39
re0phimes/FlaskTest
FlaskApp/test.py
Python
process_list
process_list
11
19
11
11
493f36df2affcbdb86c353685388151289ac30f3
bigcode/the-stack
train
77b3b51fb7fec104b9560405
train
function
def test_func(): schedule.every(1).seconds.do(get_one_process,6700) while True: schedule.run_pending()
def test_func():
schedule.every(1).seconds.do(get_one_process,6700) while True: schedule.run_pending()
else: processDataList = processDataList[1:] processDataList.append(oneProcData) print(processDataList) else: print("no such process") except Exception as e: print(e) print("eror in get_one_process") def test_func():
63
64
28
4
59
re0phimes/FlaskTest
FlaskApp/test.py
Python
test_func
test_func
49
52
49
49
39c7f343d7fb1b76b1a4ba17a450267abaa6b302
bigcode/the-stack
train
3dcada7f4f9d96eb842832d4
train
class
class Migration(migrations.Migration): dependencies = [ ('sources_main', '0018_migrate_sourcetypes'), ] operations = [ migrations.AlterField( model_name='source', name='doctype', field=models.CharField(choices=[('DOC', 'Document'), ('PDF', 'Pdf'), ('IMG'...
class Migration(migrations.Migration):
dependencies = [ ('sources_main', '0018_migrate_sourcetypes'), ] operations = [ migrations.AlterField( model_name='source', name='doctype', field=models.CharField(choices=[('DOC', 'Document'), ('PDF', 'Pdf'), ('IMG', 'Image'), ('LINK', 'Weblink'), ('VIDEO...
# Generated by Django 2.1 on 2018-11-22 18:22 from django.db import migrations, models class Migration(migrations.Migration):
36
64
122
7
28
DOSSIER-dev/DOSSIER-Sources
app/sources_main/migrations/0019_auto_20181122_1822.py
Python
Migration
Migration
6
18
6
7
367aedcc77f54efbdfc02868ee98c884e78de86c
bigcode/the-stack
train
d25e6805bdf979eaf1e5fc5c
train
class
class TestLinearRegression(unittest.TestCase): def test_basic_linear_regression(self): import numpy as np from mlp.regression.linear import BasicLinearRegression X = np.array([[x] for x in range(6)]) y = np.array([x for x in range(6)]) model = BasicLinearRegression() ...
class TestLinearRegression(unittest.TestCase):
def test_basic_linear_regression(self): import numpy as np from mlp.regression.linear import BasicLinearRegression X = np.array([[x] for x in range(6)]) y = np.array([x for x in range(6)]) model = BasicLinearRegression() model.fit(X, y) self.assertEqual(2,...
import unittest class TestLinearRegression(unittest.TestCase):
11
64
143
8
2
guidj/mlp
tests/linear.py
Python
TestLinearRegression
TestLinearRegression
4
23
4
4
2e5fc4475566d7ca7e6dfce82f302aa4fefca60e
bigcode/the-stack
train
2c973d5364a5bb95153b0872
train
class
class PowerSeo2016(PowerSpectrumFit): """ P(k) model inspired from Seo 2016. See https://ui.adsabs.harvard.edu/abs/2016MNRAS.460.2453S for details. """ def __init__( self, name="Pk Seo 2016", fix_params=("om", "f"), smooth_type="hinton2017", recon=False, postprocess=None, smooth=False, correct...
class PowerSeo2016(PowerSpectrumFit):
""" P(k) model inspired from Seo 2016. See https://ui.adsabs.harvard.edu/abs/2016MNRAS.460.2453S for details. """ def __init__( self, name="Pk Seo 2016", fix_params=("om", "f"), smooth_type="hinton2017", recon=False, postprocess=None, smooth=False, correction=None, isotropic=True ): ...
import logging from functools import lru_cache import numpy as np from scipy import integrate from barry.models.bao_power import PowerSpectrumFit from scipy.interpolate import splev, splrep class PowerSeo2016(PowerSpectrumFit):
52
256
4,532
10
41
nam8/Barry
barry/models/bao_power_Seo2016.py
Python
PowerSeo2016
PowerSeo2016
10
298
10
10
8d3a6a96d6465d4c69ec08cb3404440cc59ad250
bigcode/the-stack
train
0e79a012375ea927993c88ab
train
class
@skipIf(NO_MOCK, NO_MOCK_REASON) class MysqlGrantsTestCase(TestCase): ''' Test cases for salt.states.mysql_grants ''' # 'present' function tests: 1 def test_present(self): ''' Test to ensure that the grant is present with the specified properties. ''' name = 'frank_e...
@skipIf(NO_MOCK, NO_MOCK_REASON) class MysqlGrantsTestCase(TestCase):
''' Test cases for salt.states.mysql_grants ''' # 'present' function tests: 1 def test_present(self): ''' Test to ensure that the grant is present with the specified properties. ''' name = 'frank_exampledb' ret = {'name': name, 'result': True,...
# -*- coding: utf-8 -*- ''' :codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>` ''' # Import Python libs from __future__ import absolute_import # Import Salt Testing Libs from salttesting import skipIf, TestCase from salttesting.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) from...
155
256
886
21
134
preoctopus/salt
tests/unit/states/mysql_grants_test.py
Python
MysqlGrantsTestCase
MysqlGrantsTestCase
27
119
27
28
2396b2a98fe010233eef8a45323929b5c4de39f9
bigcode/the-stack
train
0277a83f36de5100fac15950
train
class
class ProjectView(BumfViewSet): queryset = Project.objects.all() serializer_class = ProjectSerializer user_relation = 'user'
class ProjectView(BumfViewSet):
queryset = Project.objects.all() serializer_class = ProjectSerializer user_relation = 'user'
from bumf.api.serializers import ProjectSerializer from bumf.api.views.base import BumfViewSet from bumf.core.models import Project class ProjectView(BumfViewSet):
39
64
30
9
29
bumfiness/bumf
server/bumf/api/views/project.py
Python
ProjectView
ProjectView
6
9
6
6
01be3ff2e60f95cc366576a478999d1ad8f0cd08
bigcode/the-stack
train
7b9c0c6de20e08e83e5e43c5
train
function
async def watch_statefulsets(queue): v1 = client.AppsV1Api() async for event in watch.Watch().stream(v1.list_stateful_set_for_all_namespaces): await queue.put(event)
async def watch_statefulsets(queue):
v1 = client.AppsV1Api() async for event in watch.Watch().stream(v1.list_stateful_set_for_all_namespaces): await queue.put(event)
_all_namespaces): await queue.put(event) async def watch_daemonsets(queue): v1 = client.AppsV1Api() async for event in watch.Watch().stream(v1.list_daemon_set_for_all_namespaces): await queue.put(event) async def watch_statefulsets(queue):
64
64
46
8
56
snebel29/kwatchman
prototype/async_kwatchman.py
Python
watch_statefulsets
watch_statefulsets
23
26
23
23
f4364073f031d0d940d740bd5f1a0f5ad76d23d4
bigcode/the-stack
train
f86f35184beb0fb1c765de12
train
function
async def sync_up(has_synced): # The naive approach is to just use a timer... start_time = time() while time() - start_time < 5: await asyncio.sleep(0.5) # Simple types assigment is an atomic operation has_synced.done = True print('sync-up')
async def sync_up(has_synced): # The naive approach is to just use a timer...
start_time = time() while time() - start_time < 5: await asyncio.sleep(0.5) # Simple types assigment is an atomic operation has_synced.done = True print('sync-up')
_cronjobs(queue): v1 = client.BatchV1beta1Api() async for event in watch.Watch().stream(v1.list_cron_job_for_all_namespaces): await queue.put(event) async def sync_up(has_synced): # The naive approach is to just use a timer...
64
64
72
20
44
snebel29/kwatchman
prototype/async_kwatchman.py
Python
sync_up
sync_up
34
42
34
35
1b6215641fb035c29e5e87cc96cfbb3fb7d6c85f
bigcode/the-stack
train
f98f441f567fc60dcb953fa5
train
function
async def watch_cronjobs(queue): v1 = client.BatchV1beta1Api() async for event in watch.Watch().stream(v1.list_cron_job_for_all_namespaces): await queue.put(event)
async def watch_cronjobs(queue):
v1 = client.BatchV1beta1Api() async for event in watch.Watch().stream(v1.list_cron_job_for_all_namespaces): await queue.put(event)
_all_namespaces): await queue.put(event) async def watch_statefulsets(queue): v1 = client.AppsV1Api() async for event in watch.Watch().stream(v1.list_stateful_set_for_all_namespaces): await queue.put(event) async def watch_cronjobs(queue):
64
64
47
8
56
snebel29/kwatchman
prototype/async_kwatchman.py
Python
watch_cronjobs
watch_cronjobs
28
31
28
28
138082753fcfff076d8400258d1ec26711ba2cc5
bigcode/the-stack
train
27cb132507eae8c4c816f2c5
train
function
async def consume_events(queue, has_synced, func): storage = {} count = 0 while True: event = await queue.get() count += 1 func(event, storage, has_synced, count)
async def consume_events(queue, has_synced, func):
storage = {} count = 0 while True: event = await queue.get() count += 1 func(event, storage, has_synced, count)
start_time = time() while time() - start_time < 5: await asyncio.sleep(0.5) # Simple types assigment is an atomic operation has_synced.done = True print('sync-up') async def consume_events(queue, has_synced, func):
64
64
51
12
52
snebel29/kwatchman
prototype/async_kwatchman.py
Python
consume_events
consume_events
44
50
44
44
b7be2b4b9f9b8f02bb88418ef7ffa6ca6aa31298
bigcode/the-stack
train
62d1f3eefbfd83321228c7e8
train
class
class StatefulSet(WorkloadsResource): pass
class StatefulSet(WorkloadsResource):
pass
resource_version'] = None meta['generation'] = None spec = str(self.obj.spec) return '{}\n{}'.format(str(meta), spec) class Deployment(WorkloadsResource): pass class DaemonSet(WorkloadsResource): pass class StatefulSet(WorkloadsResource):
64
64
11
8
55
snebel29/kwatchman
prototype/async_kwatchman.py
Python
StatefulSet
StatefulSet
87
88
87
87
25bacb18f71aeff758fda43b2cc6d2b28ccd4c40
bigcode/the-stack
train
b90cf15595a3a69b6f1c8f7d
train
function
def _notify_event(action, kind, name, event_count, diff): print(action, kind, name, event_count) print(diff) webhook_url = os.environ['SLACK_WEBHOOK_URL'] short_message = "{} {}/{}".format(action, kind, name) if action == 'ADDED': color = "#7CD197" if action == 'DELETED': color = "#ff0000" ...
def _notify_event(action, kind, name, event_count, diff):
print(action, kind, name, event_count) print(diff) webhook_url = os.environ['SLACK_WEBHOOK_URL'] short_message = "{} {}/{}".format(action, kind, name) if action == 'ADDED': color = "#7CD197" if action == 'DELETED': color = "#ff0000" if action == 'MODIFIED': color = "#ff9900" slack_dat...
(str(meta), spec) class Deployment(WorkloadsResource): pass class DaemonSet(WorkloadsResource): pass class StatefulSet(WorkloadsResource): pass class CronJob(WorkloadsResource): pass def _notify_event(action, kind, name, event_count, diff):
64
64
207
15
48
snebel29/kwatchman
prototype/async_kwatchman.py
Python
_notify_event
_notify_event
93
120
93
93
de56f7bb4dda891355f600f2248db40afd112045
bigcode/the-stack
train
19bf25c52e949fbef6463cae
train
class
class HasSynced(object): def __init__(self): self.done = False
class HasSynced(object):
def __init__(self): self.done = False
print('sync-up') async def consume_events(queue, has_synced, func): storage = {} count = 0 while True: event = await queue.get() count += 1 func(event, storage, has_synced, count) class HasSynced(object):
64
64
19
6
58
snebel29/kwatchman
prototype/async_kwatchman.py
Python
HasSynced
HasSynced
52
54
52
52
2b9f89c59a8c156c2a70b30d19c89bfa74118882
bigcode/the-stack
train
e2e04e9c58ba6300b769dc92
train
function
def _compare_manifests(a, b): diff = '\n'.join( filter( lambda x: not x.startswith('@@') and not x.startswith('---') and not x.startswith('+++'), difflib.unified_diff( str(a).split('\n'), str(b).split('\n'), n=0, linet...
def _compare_manifests(a, b):
diff = '\n'.join( filter( lambda x: not x.startswith('@@') and not x.startswith('---') and not x.startswith('+++'), difflib.unified_diff( str(a).split('\n'), str(b).split('\n'), n=0, lineterm='' ) )...
} response = requests.post( webhook_url, data=json.dumps(slack_data), headers={'Content-Type': 'application/json'} ) if response.status_code != 200: print('ERROR: slack webhook status code {}'.format(response.status_code)) def _compare_manifests(a, b):
64
64
91
10
54
snebel29/kwatchman
prototype/async_kwatchman.py
Python
_compare_manifests
_compare_manifests
123
135
123
123
61561929bdcf53e86651cd9408fb99f69121af03
bigcode/the-stack
train
652a555d2c3cbedaa476448a
train
function
def _handle_event(event, storage, has_synced, count): try: kind = event['object'].kind action = event['type'] klasses = { 'Deployment': Deployment, 'DaemonSet': DaemonSet, 'StatefulSet': StatefulSet, 'CronJob': CronJob } ...
def _handle_event(event, storage, has_synced, count):
try: kind = event['object'].kind action = event['type'] klasses = { 'Deployment': Deployment, 'DaemonSet': DaemonSet, 'StatefulSet': StatefulSet, 'CronJob': CronJob } if kind in klasses: obj = klasses[ki...
: not x.startswith('@@') and not x.startswith('---') and not x.startswith('+++'), difflib.unified_diff( str(a).split('\n'), str(b).split('\n'), n=0, lineterm='' ) ) ) return diff def _handle_event(event, storage, h...
81
81
270
14
66
snebel29/kwatchman
prototype/async_kwatchman.py
Python
_handle_event
_handle_event
137
176
137
137
050f0bf6708c109244461772c60df3ff071517b7
bigcode/the-stack
train
56f67a18e00deb7fff62dbd3
train
class
class Deployment(WorkloadsResource): pass
class Deployment(WorkloadsResource):
pass
annotations' in meta and meta['annotations'] != None: meta['annotations'] = None meta['resource_version'] = None meta['generation'] = None spec = str(self.obj.spec) return '{}\n{}'.format(str(meta), spec) class Deployment(WorkloadsResource):
64
64
10
7
57
snebel29/kwatchman
prototype/async_kwatchman.py
Python
Deployment
Deployment
81
82
81
81
1e227a269d3ca9a70fc56cef2ba4c43ea02befc6
bigcode/the-stack
train
a5816fcb1fcb0b053d975491
train
class
class CronJob(WorkloadsResource): pass
class CronJob(WorkloadsResource):
pass
= None spec = str(self.obj.spec) return '{}\n{}'.format(str(meta), spec) class Deployment(WorkloadsResource): pass class DaemonSet(WorkloadsResource): pass class StatefulSet(WorkloadsResource): pass class CronJob(WorkloadsResource):
64
64
11
8
55
snebel29/kwatchman
prototype/async_kwatchman.py
Python
CronJob
CronJob
90
91
90
90
4cce2ab83f1167d4aed920ebfebd81e846be1b16
bigcode/the-stack
train
24d7a6d7b4b8ce74a6a0c4d4
train
function
async def watch_daemonsets(queue): v1 = client.AppsV1Api() async for event in watch.Watch().stream(v1.list_daemon_set_for_all_namespaces): await queue.put(event)
async def watch_daemonsets(queue):
v1 = client.AppsV1Api() async for event in watch.Watch().stream(v1.list_daemon_set_for_all_namespaces): await queue.put(event)
ernetes_asyncio import client, config, watch async def watch_deployments(queue): v1 = client.AppsV1Api() async for event in watch.Watch().stream(v1.list_deployment_for_all_namespaces): await queue.put(event) async def watch_daemonsets(queue):
64
64
46
8
56
snebel29/kwatchman
prototype/async_kwatchman.py
Python
watch_daemonsets
watch_daemonsets
18
21
18
18
64e0ad589e215175afe94a3d1506415d7369657c
bigcode/the-stack
train
a9038edc74dab3a183e6ef3d
train
function
async def watch_deployments(queue): v1 = client.AppsV1Api() async for event in watch.Watch().stream(v1.list_deployment_for_all_namespaces): await queue.put(event)
async def watch_deployments(queue):
v1 = client.AppsV1Api() async for event in watch.Watch().stream(v1.list_deployment_for_all_namespaces): await queue.put(event)
s event streams without threads.""" import asyncio import json import copy import difflib import os, sys, traceback import requests from time import time from abc import ABC, abstractmethod from kubernetes_asyncio import client, config, watch async def watch_deployments(queue):
64
64
45
8
55
snebel29/kwatchman
prototype/async_kwatchman.py
Python
watch_deployments
watch_deployments
13
16
13
13
cf08252ff67b413cf2dba790c66feda27fc3741f
bigcode/the-stack
train
f1adb34f0256a44b2eff3ad6
train
class
class WorkloadsResource(ABC): def __init__(self, event): self.obj = event['object'] self.kind = event['object'].kind self.name = event['object'].metadata.name self.namespace = event['object'].metadata.namespace self.version = event['object'].metadata.resourc...
class WorkloadsResource(ABC):
def __init__(self, event): self.obj = event['object'] self.kind = event['object'].kind self.name = event['object'].metadata.name self.namespace = event['object'].metadata.namespace self.version = event['object'].metadata.resource_version @property d...
storage = {} count = 0 while True: event = await queue.get() count += 1 func(event, storage, has_synced, count) class HasSynced(object): def __init__(self): self.done = False class WorkloadsResource(ABC):
64
64
191
7
56
snebel29/kwatchman
prototype/async_kwatchman.py
Python
WorkloadsResource
WorkloadsResource
56
79
56
56
1bf63ecd53036b0a0a9368b90b3f1824516e6686
bigcode/the-stack
train
495016d6c85ebac26faedc59
train
class
class DaemonSet(WorkloadsResource): pass
class DaemonSet(WorkloadsResource):
pass
meta['annotations'] = None meta['resource_version'] = None meta['generation'] = None spec = str(self.obj.spec) return '{}\n{}'.format(str(meta), spec) class Deployment(WorkloadsResource): pass class DaemonSet(WorkloadsResource):
64
64
12
9
54
snebel29/kwatchman
prototype/async_kwatchman.py
Python
DaemonSet
DaemonSet
84
85
84
84
fe97e3c0d5ae8d69889e8d6ecd9b4e2442e7ffec
bigcode/the-stack
train
d5e6c47a7a26a1d10059d0f9
train
function
def get_nlp_credentials(): config = ConfigObj("users" + os.sep + "config.ini") return config["nlp_user"], config["nlp_password"]
def get_nlp_credentials():
config = ConfigObj("users" + os.sep + "config.ini") return config["nlp_user"], config["nlp_password"]
# Web resource resp = requests.get(banner) return resp.text else: # File name in templates/ dir banner = config["banner"] banner = open(prefix + "templates" + os.sep + banner).read() return banner def get_nlp_credentials():
64
64
34
6
57
CopticScriptorium/gitdox
paths.py
Python
get_nlp_credentials
get_nlp_credentials
36
38
36
36
f6fca33d96103c0e63aa712816c1d96fd470ef42
bigcode/the-stack
train
774a06ae4707c398dbd66e4d
train
function
def get_menu(): config = ConfigObj(prefix + "users" + os.sep + "config.ini") if "banner" not in config: return "" banner = config["banner"] if banner.startswith("http"): # Web resource resp = requests.get(banner) return resp.text else: # File name in templates/ dir banner = config["banner"] banner = ...
def get_menu():
config = ConfigObj(prefix + "users" + os.sep + "config.ini") if "banner" not in config: return "" banner = config["banner"] if banner.startswith("http"): # Web resource resp = requests.get(banner) return resp.text else: # File name in templates/ dir banner = config["banner"] banner = open(prefix + "t...
project root try: ether_url = ConfigObj(gitdox_root + os.sep + "users" + os.sep + "config.ini")["ether_url"] if not ether_url.endswith(os.sep): ether_url += os.sep except KeyError: ether_url = "" def get_menu():
64
64
104
4
60
CopticScriptorium/gitdox
paths.py
Python
get_menu
get_menu
20
33
20
20
9cdc3caa575657cc3293df4e7f0d8285817b27c2
bigcode/the-stack
train
71045fdad32f7cd726256ab0
train
function
@pytest.fixture def root(): return ProjectPackage("root", "1.2.3")
@pytest.fixture def root():
return ProjectPackage("root", "1.2.3")
import MockEnv as BaseMockEnv from tests.helpers import get_dependency from subprocess import CalledProcessError class MockEnv(BaseMockEnv): def run(self, bin, *args): raise EnvCommandError(CalledProcessError(1, "python", output="")) @pytest.fixture def root():
63
64
20
6
57
mgasner/poetry
tests/puzzle/test_provider.py
Python
root
root
27
29
27
28
92645f879a90fec175039532f2112c5eb7f5a728
bigcode/the-stack
train
f1f83c4cead9f49c950fbca4
train
function
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4") def test_search_for_directory_setup_read_setup(provider, mocker): mocker.patch("poetry.utils.env.EnvManager.get", return_value=MockEnv()) dependency = DirectoryDependency( "demo", Path(__file__).parent.parent ...
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4") def test_search_for_directory_setup_read_setup(provider, mocker):
mocker.patch("poetry.utils.env.EnvManager.get", return_value=MockEnv()) dependency = DirectoryDependency( "demo", Path(__file__).parent.parent / "fixtures" / "git" / "github.com" / "demo" / "demo", ) package = provider.search_for_directory(depend...
tras == { "foo": [get_dependency("cleo")], "bar": [get_dependency("tomlkit")], } @pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4") def test_search_for_directory_setup_read_setup(provider, mocker):
64
64
186
35
29
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_directory_setup_read_setup
test_search_for_directory_setup_read_setup
177
199
177
178
a1b8046964b1c14e865a7ff6d92351c826e60779
bigcode/the-stack
train
e5f38c4dca44b0d44743d9e1
train
function
def test_search_for_directory_setup_egg_info(provider): dependency = DirectoryDependency( "demo", Path(__file__).parent.parent / "fixtures" / "git" / "github.com" / "demo" / "demo", ) package = provider.search_for_directory(dependency)[0] assert ...
def test_search_for_directory_setup_egg_info(provider):
dependency = DirectoryDependency( "demo", Path(__file__).parent.parent / "fixtures" / "git" / "github.com" / "demo" / "demo", ) package = provider.search_for_directory(dependency)[0] assert package.name == "demo" assert package.version.text =...
("poetry.utils.env.EnvManager.get", return_value=MockEnv()) dependency = VCSDependency("demo", "git", "https://github.com/demo/no-version.git") with pytest.raises(RuntimeError): provider.search_for_vcs(dependency) def test_search_for_directory_setup_egg_info(provider):
64
64
143
11
53
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_directory_setup_egg_info
test_search_for_directory_setup_egg_info
129
148
129
129
381bba147e684b94646bb6ec5460c3321457e356
bigcode/the-stack
train
9b131e78f55fc2f96d0fed27
train
function
def test_search_for_vcs_setup_egg_info_with_extras(provider): dependency = VCSDependency("demo", "git", "https://github.com/demo/demo.git") dependency.extras.append("foo") package = provider.search_for_vcs(dependency)[0] assert package.name == "demo" assert package.version.text == "0.1.2" asse...
def test_search_for_vcs_setup_egg_info_with_extras(provider):
dependency = VCSDependency("demo", "git", "https://github.com/demo/demo.git") dependency.extras.append("foo") package = provider.search_for_vcs(dependency)[0] assert package.name == "demo" assert package.version.text == "0.1.2" assert package.requires == [ get_dependency("pendulum", ">...
== [get_dependency("pendulum", ">=1.4.4")] assert package.extras == { "foo": [get_dependency("cleo")], "bar": [get_dependency("tomlkit")], } def test_search_for_vcs_setup_egg_info_with_extras(provider):
64
64
143
15
49
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_vcs_setup_egg_info_with_extras
test_search_for_vcs_setup_egg_info_with_extras
64
79
64
64
6e94750be20e11b45ae85b5ae7015f63488a340d
bigcode/the-stack
train
4db6a5d8420f18df8603d5a8
train
function
def test_search_for_vcs_read_setup_raises_error_if_no_version(provider, mocker): mocker.patch("poetry.utils.env.EnvManager.get", return_value=MockEnv()) dependency = VCSDependency("demo", "git", "https://github.com/demo/no-version.git") with pytest.raises(RuntimeError): provider.search_for_vcs(dep...
def test_search_for_vcs_read_setup_raises_error_if_no_version(provider, mocker):
mocker.patch("poetry.utils.env.EnvManager.get", return_value=MockEnv()) dependency = VCSDependency("demo", "git", "https://github.com/demo/no-version.git") with pytest.raises(RuntimeError): provider.search_for_vcs(dependency)
"), get_dependency("cleo", optional=True), ] assert package.extras == { "foo": [get_dependency("cleo")], "bar": [get_dependency("tomlkit")], } def test_search_for_vcs_read_setup_raises_error_if_no_version(provider, mocker):
64
64
76
19
45
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_vcs_read_setup_raises_error_if_no_version
test_search_for_vcs_read_setup_raises_error_if_no_version
120
126
120
120
23ad95f5a18d2d1d444f0abdd17eb162dcaf7cb3
bigcode/the-stack
train
d6a0e4f7ddc6a28375defa81
train
function
@pytest.fixture def repository(): return Repository()
@pytest.fixture def repository():
return Repository()
Error class MockEnv(BaseMockEnv): def run(self, bin, *args): raise EnvCommandError(CalledProcessError(1, "python", output="")) @pytest.fixture def root(): return ProjectPackage("root", "1.2.3") @pytest.fixture def repository():
64
64
10
6
58
mgasner/poetry
tests/puzzle/test_provider.py
Python
repository
repository
32
34
32
33
3ceed9fd5e871d50002fb4422b452d74920d63d8
bigcode/the-stack
train
183e0f7392e527f825abd445
train
function
def test_search_for_directory_setup_egg_info_with_extras(provider): dependency = DirectoryDependency( "demo", Path(__file__).parent.parent / "fixtures" / "git" / "github.com" / "demo" / "demo", ) dependency.extras.append("foo") package = provider....
def test_search_for_directory_setup_egg_info_with_extras(provider):
dependency = DirectoryDependency( "demo", Path(__file__).parent.parent / "fixtures" / "git" / "github.com" / "demo" / "demo", ) dependency.extras.append("foo") package = provider.search_for_directory(dependency)[0] assert package.name == "dem...
.requires == [get_dependency("pendulum", ">=1.4.4")] assert package.extras == { "foo": [get_dependency("cleo")], "bar": [get_dependency("tomlkit")], } def test_search_for_directory_setup_egg_info_with_extras(provider):
64
64
166
14
50
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_directory_setup_egg_info_with_extras
test_search_for_directory_setup_egg_info_with_extras
151
174
151
151
42227209d5428e72b08f2b53982f765f2f0fa4be
bigcode/the-stack
train
6c08d7bc621d984ccae0fd07
train
function
@pytest.fixture def provider(root, pool): return Provider(root, pool, NullIO())
@pytest.fixture def provider(root, pool):
return Provider(root, pool, NullIO())
="")) @pytest.fixture def root(): return ProjectPackage("root", "1.2.3") @pytest.fixture def repository(): return Repository() @pytest.fixture def pool(repository): pool = Pool() pool.add_repository(repository) return pool @pytest.fixture def provider(root, pool):
64
64
19
9
54
mgasner/poetry
tests/puzzle/test_provider.py
Python
provider
provider
45
47
45
46
4aef81b2c9384caab560aafc5a846d808f410d92
bigcode/the-stack
train
3ca694bd86f6495c900dc405
train
function
def test_search_for_file_wheel_with_extras(provider): dependency = FileDependency( "demo", Path(__file__).parent.parent / "fixtures" / "distributions" / "demo-0.1.0-py2.py3-none-any.whl", ) dependency.extras.append("foo") package = provider.search_for_file(depend...
def test_search_for_file_wheel_with_extras(provider):
dependency = FileDependency( "demo", Path(__file__).parent.parent / "fixtures" / "distributions" / "demo-0.1.0-py2.py3-none-any.whl", ) dependency.extras.append("foo") package = provider.search_for_file(dependency)[0] assert package.name == "demo" assert...
assert package.requires == [get_dependency("pendulum", ">=1.4.4")] assert package.extras == { "foo": [get_dependency("cleo")], "bar": [get_dependency("tomlkit")], } def test_search_for_file_wheel_with_extras(provider):
64
64
169
12
52
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_file_wheel_with_extras
test_search_for_file_wheel_with_extras
350
371
350
350
fbb7a0698139925ad1329efaac4f2f2ddd36f947
bigcode/the-stack
train
dc59ae631695617030dd40a9
train
function
def test_search_for_directory_poetry(provider): dependency = DirectoryDependency( "demo", Path(__file__).parent.parent / "fixtures" / "project_with_extras" ) package = provider.search_for_directory(dependency)[0] assert package.name == "project-with-extras" assert package.version.text == "...
def test_search_for_directory_poetry(provider):
dependency = DirectoryDependency( "demo", Path(__file__).parent.parent / "fixtures" / "project_with_extras" ) package = provider.search_for_directory(dependency)[0] assert package.name == "project-with-extras" assert package.version.text == "1.2.3" assert package.requires == [] ass...
/ "no-dependencies", ) package = provider.search_for_directory(dependency)[0] assert package.name == "demo" assert package.version.text == "0.1.2" assert package.requires == [] assert package.extras == {} def test_search_for_directory_poetry(provider):
63
64
132
9
54
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_directory_poetry
test_search_for_directory_poetry
253
266
253
253
db5bec9cfb86b8ff16a9c0b7bd2615dd82f9e9f7
bigcode/the-stack
train
afda4f511030d9215dcb9d9a
train
function
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4") def test_search_for_vcs_read_setup(provider, mocker): mocker.patch("poetry.utils.env.EnvManager.get", return_value=MockEnv()) dependency = VCSDependency("demo", "git", "https://github.com/demo/demo.git") package = provider.s...
@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4") def test_search_for_vcs_read_setup(provider, mocker):
mocker.patch("poetry.utils.env.EnvManager.get", return_value=MockEnv()) dependency = VCSDependency("demo", "git", "https://github.com/demo/demo.git") package = provider.search_for_vcs(dependency)[0] assert package.name == "demo" assert package.version.text == "0.1.2" assert package.requires =...
tras == { "foo": [get_dependency("cleo")], "bar": [get_dependency("tomlkit")], } @pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4") def test_search_for_vcs_read_setup(provider, mocker):
64
64
162
35
29
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_vcs_read_setup
test_search_for_vcs_read_setup
82
96
82
83
29f619553ac1b58433370206bc897cbc2eb9d5df
bigcode/the-stack
train
2229c134f1b3875d6ff5c97e
train
function
def test_search_for_vcs_setup_egg_info(provider): dependency = VCSDependency("demo", "git", "https://github.com/demo/demo.git") package = provider.search_for_vcs(dependency)[0] assert package.name == "demo" assert package.version.text == "0.1.2" assert package.requires == [get_dependency("pendulum...
def test_search_for_vcs_setup_egg_info(provider):
dependency = VCSDependency("demo", "git", "https://github.com/demo/demo.git") package = provider.search_for_vcs(dependency)[0] assert package.name == "demo" assert package.version.text == "0.1.2" assert package.requires == [get_dependency("pendulum", ">=1.4.4")] assert package.extras == { ...
") @pytest.fixture def repository(): return Repository() @pytest.fixture def pool(repository): pool = Pool() pool.add_repository(repository) return pool @pytest.fixture def provider(root, pool): return Provider(root, pool, NullIO()) def test_search_for_vcs_setup_egg_info(provider):
64
64
120
12
52
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_vcs_setup_egg_info
test_search_for_vcs_setup_egg_info
50
61
50
50
2e341e918fcf0d554c6eccebaed2f306b22c4cae
bigcode/the-stack
train
4dbab70ee7ea7a8b73776f21
train
function
def test_search_for_directory_poetry_with_extras(provider): dependency = DirectoryDependency( "demo", Path(__file__).parent.parent / "fixtures" / "project_with_extras" ) dependency.extras.append("extras_a") package = provider.search_for_directory(dependency)[0] assert package.name == "proj...
def test_search_for_directory_poetry_with_extras(provider):
dependency = DirectoryDependency( "demo", Path(__file__).parent.parent / "fixtures" / "project_with_extras" ) dependency.extras.append("extras_a") package = provider.search_for_directory(dependency)[0] assert package.name == "project-with-extras" assert package.version.text == "1.2.3" ...
assert package.extras == { "extras_a": [get_dependency("pendulum", ">=1.4.4")], "extras_b": [get_dependency("cachy", ">=0.2.0")], } def test_search_for_directory_poetry_with_extras(provider):
64
64
158
12
52
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_directory_poetry_with_extras
test_search_for_directory_poetry_with_extras
269
283
269
269
0dc6d563864d809a005cd2367a5452919811ab96
bigcode/the-stack
train
16e4cf2d238662541ec7b41a
train
function
def test_search_for_file_sdist_with_extras(provider): dependency = FileDependency( "demo", Path(__file__).parent.parent / "fixtures" / "distributions" / "demo-0.1.0.tar.gz", ) dependency.extras.append("foo") package = provider.search_for_file(dependency)[0] ...
def test_search_for_file_sdist_with_extras(provider):
dependency = FileDependency( "demo", Path(__file__).parent.parent / "fixtures" / "distributions" / "demo-0.1.0.tar.gz", ) dependency.extras.append("foo") package = provider.search_for_file(dependency)[0] assert package.name == "demo" assert package.versi...
assert package.requires == [get_dependency("pendulum", ">=1.4.4")] assert package.extras == { "foo": [get_dependency("cleo")], "bar": [get_dependency("tomlkit")], } def test_search_for_file_sdist_with_extras(provider):
64
64
162
12
52
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_file_sdist_with_extras
test_search_for_file_sdist_with_extras
306
327
306
306
e87d019f04b3b6a6729b04e5c216a50d7e82bc7a
bigcode/the-stack
train
32171e767f71893ccadc0a24
train
function
def test_search_for_file_wheel(provider): dependency = FileDependency( "demo", Path(__file__).parent.parent / "fixtures" / "distributions" / "demo-0.1.0-py2.py3-none-any.whl", ) package = provider.search_for_file(dependency)[0] assert package.name == "demo" ...
def test_search_for_file_wheel(provider):
dependency = FileDependency( "demo", Path(__file__).parent.parent / "fixtures" / "distributions" / "demo-0.1.0-py2.py3-none-any.whl", ) package = provider.search_for_file(dependency)[0] assert package.name == "demo" assert package.version.text == "0.1.0" ...
pendulum", ">=1.4.4"), get_dependency("cleo", optional=True), ] assert package.extras == { "foo": [get_dependency("cleo")], "bar": [get_dependency("tomlkit")], } def test_search_for_file_wheel(provider):
64
64
146
9
55
mgasner/poetry
tests/puzzle/test_provider.py
Python
test_search_for_file_wheel
test_search_for_file_wheel
330
347
330
330
4e27b4a05a54fdf6e2686c981099fb9a3a5cd819
bigcode/the-stack
train
9324800af06629fc80ea35cc
train
class
class MockEnv(BaseMockEnv): def run(self, bin, *args): raise EnvCommandError(CalledProcessError(1, "python", output=""))
class MockEnv(BaseMockEnv):
def run(self, bin, *args): raise EnvCommandError(CalledProcessError(1, "python", output=""))
.repositories.repository import Repository from poetry.utils._compat import PY35 from poetry.utils._compat import Path from poetry.utils.env import EnvCommandError from poetry.utils.env import MockEnv as BaseMockEnv from tests.helpers import get_dependency from subprocess import CalledProcessError class MockEnv(BaseM...
64
64
35
7
56
mgasner/poetry
tests/puzzle/test_provider.py
Python
MockEnv
MockEnv
22
24
22
22
1e8cf77ce3ec26cc5d78bb37b6983df5261c2ddd
bigcode/the-stack
train