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
a2a9b17647ea69a86d8a119e
train
function
def _na_for_min_count(values, axis): """Return the missing value for `values` Parameters ---------- values : ndarray axis : int or None axis for the reduction Returns ------- result : scalar or ndarray For 1-D values, returns a scalar of the correct missing type. ...
def _na_for_min_count(values, axis):
"""Return the missing value for `values` Parameters ---------- values : ndarray axis : int or None axis for the reduction Returns ------- result : scalar or ndarray For 1-D values, returns a scalar of the correct missing type. For 2-D values, returns a 1-D array...
if np.fabs(result) > _int64_max: raise ValueError("overflow in timedelta operation") result = tslibs.Timedelta(result, unit='ns') else: result = result.astype('i8').view(dtype) return result def _na_for_min_count(values, axis):
64
64
191
10
53
jmcclenon/pandas
pandas/core/nanops.py
Python
_na_for_min_count
_na_for_min_count
288
315
288
288
8e4eb62c37bffda3496aa2347d09deea2674cc75
bigcode/the-stack
train
2ab6daae684beeb80381834d
train
function
def make_nancomp(op): def f(x, y): xmask = isna(x) ymask = isna(y) mask = xmask | ymask with np.errstate(all='ignore'): result = op(x, y) if mask.any(): if is_bool_dtype(result): result = result.astype('O') np.putmask(resu...
def make_nancomp(op):
def f(x, y): xmask = isna(x) ymask = isna(y) mask = xmask | ymask with np.errstate(all='ignore'): result = op(x, y) if mask.any(): if is_bool_dtype(result): result = result.astype('O') np.putmask(result, mask, np.nan) ...
try: x = float(x) except Exception: try: x = complex(x) except Exception: raise TypeError('Could not convert {value!s} to numeric' .format(value=x)) return x # NA-friendly array comparisons def make_...
64
64
94
6
57
jmcclenon/pandas
pandas/core/nanops.py
Python
make_nancomp
make_nancomp
834
850
834
834
0e938b28f5fb6a112dcd0ab3a73759155c0be26e
bigcode/the-stack
train
cded6b94c6a495a081d662c8
train
function
@disallow('M8', 'm8') def nankurt(values, axis=None, skipna=True): """ Compute the sample excess kurtosis. The statistic computed here is the adjusted Fisher-Pearson standardized moment coefficient G2, computed directly from the second and fourth central moment. """ values = com._values_from_o...
@disallow('M8', 'm8') def nankurt(values, axis=None, skipna=True):
""" Compute the sample excess kurtosis. The statistic computed here is the adjusted Fisher-Pearson standardized moment coefficient G2, computed directly from the second and fourth central moment. """ values = com._values_from_object(values) mask = isna(values) if not is_float_dtype(val...
) with np.errstate(invalid='ignore', divide='ignore'): result = (count * (count - 1) ** 0.5 / (count - 2)) * (m3 / m2 ** 1.5) dtype = values.dtype if is_float_dtype(dtype): result = result.astype(dtype) if isinstance(result, np.ndarray): result = np.where(m2 == 0, 0, result) ...
168
168
563
24
143
jmcclenon/pandas
pandas/core/nanops.py
Python
nankurt
nankurt
601
666
601
602
2425d27470715d77a7cc99b48fa5e6e87864e15d
bigcode/the-stack
train
04343eaf6402e82a14cc9cd9
train
function
def set_use_bottleneck(v=True): # set/unset to use bottleneck global _USE_BOTTLENECK if _BOTTLENECK_INSTALLED: _USE_BOTTLENECK = v
def set_use_bottleneck(v=True): # set/unset to use bottleneck
global _USE_BOTTLENECK if _BOTTLENECK_INSTALLED: _USE_BOTTLENECK = v
".format( ver=ver, min_ver=_MIN_BOTTLENECK_VERSION), UserWarning) except ImportError: # pragma: no cover pass _USE_BOTTLENECK = False def set_use_bottleneck(v=True): # set/unset to use bottleneck
64
64
50
19
44
jmcclenon/pandas
pandas/core/nanops.py
Python
set_use_bottleneck
set_use_bottleneck
48
52
48
49
ff725788892d6e2e3f071c27f6994b1aec3f656f
bigcode/the-stack
train
dd82216d67526c32415ec206
train
function
@disallow('M8') @bottleneck_switch() def nanmedian(values, axis=None, skipna=True): def get_median(x): mask = notna(x) if not skipna and not mask.all(): return np.nan return np.nanmedian(x[mask]) values, mask, dtype, dtype_max = _get_values(values, skipna) if not is_flo...
@disallow('M8') @bottleneck_switch() def nanmedian(values, axis=None, skipna=True):
def get_median(x): mask = notna(x) if not skipna and not mask.all(): return np.nan return np.nanmedian(x[mask]) values, mask, dtype, dtype_max = _get_values(values, skipna) if not is_float_dtype(values): values = values.astype('f8') values[mask] = np.nan ...
None and getattr(the_sum, 'ndim', False): the_mean = the_sum / count ct_mask = count == 0 if ct_mask.any(): the_mean[ct_mask] = np.nan else: the_mean = the_sum / count if count > 0 else np.nan return _wrap_results(the_mean, dtype) @disallow('M8') @bottleneck_switch(...
102
102
342
25
77
jmcclenon/pandas
pandas/core/nanops.py
Python
nanmedian
nanmedian
368
411
368
371
64d52e33963d8207b8a672e6660debca886fda34
bigcode/the-stack
train
6f803f9227b981e03e456010
train
function
@disallow('M8') def nansum(values, axis=None, skipna=True, min_count=0): values, mask, dtype, dtype_max = _get_values(values, skipna, 0) dtype_sum = dtype_max if is_float_dtype(dtype): dtype_sum = dtype elif is_timedelta64_dtype(dtype): dtype_sum = np.float64 the_sum = values.sum(axi...
@disallow('M8') def nansum(values, axis=None, skipna=True, min_count=0):
values, mask, dtype, dtype_max = _get_values(values, skipna, 0) dtype_sum = dtype_max if is_float_dtype(dtype): dtype_sum = dtype elif is_timedelta64_dtype(dtype): dtype_sum = np.float64 the_sum = values.sum(axis, dtype=dtype_sum) the_sum = _maybe_null_out(the_sum, axis, mask, mi...
(values, axis=None, skipna=True): values, mask, dtype, _ = _get_values(values, skipna, True, copy=skipna) return values.all(axis) @disallow('M8') def nansum(values, axis=None, skipna=True, min_count=0):
64
64
126
25
39
jmcclenon/pandas
pandas/core/nanops.py
Python
nansum
nansum
328
339
328
329
449296f01ebc276467f63c053e933dd32a49c0eb
bigcode/the-stack
train
79f46c2474c765cebf15853d
train
function
def _get_counts_nanvar(mask, axis, ddof, dtype=float): dtype = _get_dtype(dtype) count = _get_counts(mask, axis, dtype=dtype) d = count - dtype.type(ddof) # always return NaN, never inf if is_scalar(count): if count <= ddof: count = np.nan d = np.nan else: ...
def _get_counts_nanvar(mask, axis, ddof, dtype=float):
dtype = _get_dtype(dtype) count = _get_counts(mask, axis, dtype=dtype) d = count - dtype.type(ddof) # always return NaN, never inf if is_scalar(count): if count <= ddof: count = np.nan d = np.nan else: mask2 = count <= ddof if mask2.any(): ...
p[dims != axis]) ret.fill(np.nan) return _wrap_results(ret, dtype) # otherwise return a scalar value return _wrap_results(get_median(values) if notempty else np.nan, dtype) def _get_counts_nanvar(mask, axis, ddof, dtype=float):
64
64
131
16
48
jmcclenon/pandas
pandas/core/nanops.py
Python
_get_counts_nanvar
_get_counts_nanvar
414
429
414
414
f3e67b3ce548e41209dcda3ad1750369e9575506
bigcode/the-stack
train
3e508669a8ec65e27c9a34b3
train
function
def _wrap_results(result, dtype): """ wrap our results if needed """ if is_datetime64_dtype(dtype): if not isinstance(result, np.ndarray): result = tslibs.Timestamp(result) else: result = result.view(dtype) elif is_timedelta64_dtype(dtype): if not isinstance(...
def _wrap_results(result, dtype):
""" wrap our results if needed """ if is_datetime64_dtype(dtype): if not isinstance(result, np.ndarray): result = tslibs.Timestamp(result) else: result = result.view(dtype) elif is_timedelta64_dtype(dtype): if not isinstance(result, np.ndarray): ...
np.isfinite(values.astype('float64')) def _na_ok_dtype(dtype): return not is_int_or_datetime_dtype(dtype) def _view_if_needed(values): if is_datetime_or_timedelta_dtype(values): return values.view(np.int64) return values def _wrap_results(result, dtype):
64
64
141
8
55
jmcclenon/pandas
pandas/core/nanops.py
Python
_wrap_results
_wrap_results
266
285
266
266
8c865b4f7cc1b28d597782e1387c5cc6d96b57f3
bigcode/the-stack
train
a22b2cccad7e89db4afdf4f5
train
function
@disallow('M8') @bottleneck_switch() def nanmean(values, axis=None, skipna=True): values, mask, dtype, dtype_max = _get_values(values, skipna, 0) dtype_sum = dtype_max dtype_count = np.float64 if is_integer_dtype(dtype) or is_timedelta64_dtype(dtype): dtype_sum = np.float64 elif is_float_dt...
@disallow('M8') @bottleneck_switch() def nanmean(values, axis=None, skipna=True):
values, mask, dtype, dtype_max = _get_values(values, skipna, 0) dtype_sum = dtype_max dtype_count = np.float64 if is_integer_dtype(dtype) or is_timedelta64_dtype(dtype): dtype_sum = np.float64 elif is_float_dtype(dtype): dtype_sum = dtype dtype_count = dtype count = _get...
values.sum(axis, dtype=dtype_sum) the_sum = _maybe_null_out(the_sum, axis, mask, min_count=min_count) return _wrap_results(the_sum, dtype) @disallow('M8') @bottleneck_switch() def nanmean(values, axis=None, skipna=True):
64
64
216
25
39
jmcclenon/pandas
pandas/core/nanops.py
Python
nanmean
nanmean
342
365
342
344
1e85f99f8c17bd6e37c1bf342a041780f8c01b82
bigcode/the-stack
train
879301bd950febedd969eb3e
train
function
@disallow('M8', 'm8') def nancov(a, b, min_periods=None): if len(a) != len(b): raise AssertionError('Operands to nancov must have same size') if min_periods is None: min_periods = 1 valid = notna(a) & notna(b) if not valid.all(): a = a[valid] b = b[valid] if len(a)...
@disallow('M8', 'm8') def nancov(a, b, min_periods=None):
if len(a) != len(b): raise AssertionError('Operands to nancov must have same size') if min_periods is None: min_periods = 1 valid = notna(a) & notna(b) if not valid.all(): a = a[valid] b = b[valid] if len(a) < min_periods: return np.nan return np.cov(a...
_methods = { 'pearson': _pearson, 'kendall': _kendall, 'spearman': _spearman } return _cor_methods[method] @disallow('M8', 'm8') def nancov(a, b, min_periods=None):
64
64
125
24
40
jmcclenon/pandas
pandas/core/nanops.py
Python
nancov
nancov
789
805
789
790
e3ac5a42a907af1ede4d50b3ec74190c4fbee4e1
bigcode/the-stack
train
96cea32dc92bce09b8d73697
train
function
def get_corr_func(method): if method in ['kendall', 'spearman']: from scipy.stats import kendalltau, spearmanr def _pearson(a, b): return np.corrcoef(a, b)[0, 1] def _kendall(a, b): rs = kendalltau(a, b) if isinstance(rs, tuple): return rs[0] return rs ...
def get_corr_func(method):
if method in ['kendall', 'spearman']: from scipy.stats import kendalltau, spearmanr def _pearson(a, b): return np.corrcoef(a, b)[0, 1] def _kendall(a, b): rs = kendalltau(a, b) if isinstance(rs, tuple): return rs[0] return rs def _spearman(a, b): ...
na(a) & notna(b) if not valid.all(): a = a[valid] b = b[valid] if len(a) < min_periods: return np.nan f = get_corr_func(method) return f(a, b) def get_corr_func(method):
64
64
154
6
58
jmcclenon/pandas
pandas/core/nanops.py
Python
get_corr_func
get_corr_func
765
786
765
765
eec56787468a8d92eb186868bb2b8d42a6ef5ef9
bigcode/the-stack
train
1115f902dd1eaa7ca13a9160
train
function
def nanall(values, axis=None, skipna=True): values, mask, dtype, _ = _get_values(values, skipna, True, copy=skipna) return values.all(axis)
def nanall(values, axis=None, skipna=True):
values, mask, dtype, _ = _get_values(values, skipna, True, copy=skipna) return values.all(axis)
result.fill(fill_value) return result def nanany(values, axis=None, skipna=True): values, mask, dtype, _ = _get_values(values, skipna, False, copy=skipna) return values.any(axis) def nanall(values, axis=None, skipna=True):
64
64
42
12
52
jmcclenon/pandas
pandas/core/nanops.py
Python
nanall
nanall
323
325
323
323
36628fc9c093eb229312c0c7ba908f3be5d0acd0
bigcode/the-stack
train
68998200879f1ff13f0687fd
train
function
def _get_fill_value(dtype, fill_value=None, fill_value_typ=None): """ return the correct fill value for the dtype of the values """ if fill_value is not None: return fill_value if _na_ok_dtype(dtype): if fill_value_typ is None: return np.nan else: if fill_valu...
def _get_fill_value(dtype, fill_value=None, fill_value_typ=None):
""" return the correct fill value for the dtype of the values """ if fill_value is not None: return fill_value if _na_ok_dtype(dtype): if fill_value_typ is None: return np.nan else: if fill_value_typ == '+inf': return np.inf else: ...
_f4(result.ravel()) try: return np.isinf(result).any() except (TypeError, NotImplementedError): # if it doesn't support infs, then it can't have infs return False def _get_fill_value(dtype, fill_value=None, fill_value_typ=None):
64
64
147
16
47
jmcclenon/pandas
pandas/core/nanops.py
Python
_get_fill_value
_get_fill_value
179
199
179
179
c30bc89a771fa04b7076f11a6fbd314f95ebd7e9
bigcode/the-stack
train
75bf42ba33e63581ffa1f735
train
function
def _get_values(values, skipna, fill_value=None, fill_value_typ=None, isfinite=False, copy=True): """ utility to get the values view, mask, dtype if necessary copy and mask using the specified fill_value copy = True will force the copy """ values = com._values_from_object(values) ...
def _get_values(values, skipna, fill_value=None, fill_value_typ=None, isfinite=False, copy=True):
""" utility to get the values view, mask, dtype if necessary copy and mask using the specified fill_value copy = True will force the copy """ values = com._values_from_object(values) if isfinite: mask = _isfinite(values) else: mask = isna(values) dtype = values.dtype ...
return -np.inf else: if fill_value_typ is None: return tslibs.iNaT else: if fill_value_typ == '+inf': # need the max int here return _int64_max else: return tslibs.iNaT def _get_values(values, skipna, fill_value=Non...
88
88
296
26
61
jmcclenon/pandas
pandas/core/nanops.py
Python
_get_values
_get_values
202
244
202
203
e18e1d6c714a5410f94557eea505ec65c281e6a8
bigcode/the-stack
train
34215a8dcd5fba0ab925991d
train
function
@disallow('O') def nanargmin(values, axis=None, skipna=True): """ Returns -1 in the NA case """ values, mask, dtype, _ = _get_values(values, skipna, fill_value_typ='+inf') result = values.argmin(axis) result = _maybe_arg_null_out(result, axis, mask, skipna) return result
@disallow('O') def nanargmin(values, axis=None, skipna=True):
""" Returns -1 in the NA case """ values, mask, dtype, _ = _get_values(values, skipna, fill_value_typ='+inf') result = values.argmin(axis) result = _maybe_arg_null_out(result, axis, mask, skipna) return result
_ = _get_values(values, skipna, fill_value_typ='-inf') result = values.argmax(axis) result = _maybe_arg_null_out(result, axis, mask, skipna) return result @disallow('O') def nanargmin(values, axis=None, skipna=True):
64
64
84
19
44
jmcclenon/pandas
pandas/core/nanops.py
Python
nanargmin
nanargmin
531
539
531
532
68bc3bc9bbaa2c20294e720e4f55ac7019eef91e
bigcode/the-stack
train
a51a732676a12548ebe34c2d
train
function
@disallow('M8', 'm8') def nancorr(a, b, method='pearson', min_periods=None): """ a, b: ndarrays """ if len(a) != len(b): raise AssertionError('Operands to nancorr must have same size') if min_periods is None: min_periods = 1 valid = notna(a) & notna(b) if not valid.all(): ...
@disallow('M8', 'm8') def nancorr(a, b, method='pearson', min_periods=None):
""" a, b: ndarrays """ if len(a) != len(b): raise AssertionError('Operands to nancorr must have same size') if min_periods is None: min_periods = 1 valid = notna(a) & notna(b) if not valid.all(): a = a[valid] b = b[valid] if len(a) < min_periods: ...
1e-14, 0, arg) else: return arg.dtype.type(0) if np.abs(arg) < 1e-14 else arg @disallow('M8', 'm8') def nancorr(a, b, method='pearson', min_periods=None):
64
64
143
29
34
jmcclenon/pandas
pandas/core/nanops.py
Python
nancorr
nancorr
742
762
742
743
1d8cb1bddce0f5e1aa63f1883c1893f7e875a3c3
bigcode/the-stack
train
0093edb9beb2191490d9a483
train
function
def _maybe_arg_null_out(result, axis, mask, skipna): # helper function for nanargmin/nanargmax if axis is None or not getattr(result, 'ndim', False): if skipna: if mask.all(): result = -1 else: if mask.any(): result = -1 else: i...
def _maybe_arg_null_out(result, axis, mask, skipna): # helper function for nanargmin/nanargmax
if axis is None or not getattr(result, 'ndim', False): if skipna: if mask.all(): result = -1 else: if mask.any(): result = -1 else: if skipna: na_mask = mask.all(axis) else: na_mask = mask.any(axis) ...
values.copy() values[mask] = 1 result = values.prod(axis) return _maybe_null_out(result, axis, mask, min_count=min_count) def _maybe_arg_null_out(result, axis, mask, skipna): # helper function for nanargmin/nanargmax
64
64
121
28
36
jmcclenon/pandas
pandas/core/nanops.py
Python
_maybe_arg_null_out
_maybe_arg_null_out
679
695
679
680
9a25d28bd749ea588ea6efafaeddc1caa4dfba89
bigcode/the-stack
train
533b83e49b1a349526643a9c
train
function
def _view_if_needed(values): if is_datetime_or_timedelta_dtype(values): return values.view(np.int64) return values
def _view_if_needed(values):
if is_datetime_or_timedelta_dtype(values): return values.view(np.int64) return values
is_float_dtype(values) or is_integer_dtype(values) or is_bool_dtype(values)): return ~np.isfinite(values) return ~np.isfinite(values.astype('float64')) def _na_ok_dtype(dtype): return not is_int_or_datetime_dtype(dtype) def _view_if_needed(values):
64
64
29
7
57
jmcclenon/pandas
pandas/core/nanops.py
Python
_view_if_needed
_view_if_needed
260
263
260
260
6470d1183af7f4b3c2b9fae3bf5e8723f6c09852
bigcode/the-stack
train
c4555ff8f60c7555fa5cd443
train
function
@disallow('M8') @bottleneck_switch(ddof=1) def nanstd(values, axis=None, skipna=True, ddof=1): result = np.sqrt(nanvar(values, axis=axis, skipna=skipna, ddof=ddof)) return _wrap_results(result, values.dtype)
@disallow('M8') @bottleneck_switch(ddof=1) def nanstd(values, axis=None, skipna=True, ddof=1):
result = np.sqrt(nanvar(values, axis=axis, skipna=skipna, ddof=ddof)) return _wrap_results(result, values.dtype)
np.putmask(d, mask2, np.nan) np.putmask(count, mask2, np.nan) return count, d @disallow('M8') @bottleneck_switch(ddof=1) def nanstd(values, axis=None, skipna=True, ddof=1):
64
64
70
34
29
jmcclenon/pandas
pandas/core/nanops.py
Python
nanstd
nanstd
432
436
432
434
2222cc738c273ab84723f9996d7cea53874330ca
bigcode/the-stack
train
0e8870a65831d7e5d1e266e2
train
class
class bottleneck_switch(object): def __init__(self, **kwargs): self.kwargs = kwargs def __call__(self, alt): bn_name = alt.__name__ try: bn_func = getattr(bn, bn_name) except (AttributeError, NameError): # pragma: no cover bn_func = None @func...
class bottleneck_switch(object):
def __init__(self, **kwargs): self.kwargs = kwargs def __call__(self, alt): bn_name = alt.__name__ try: bn_func = getattr(bn, bn_name) except (AttributeError, NameError): # pragma: no cover bn_func = None @functools.wraps(alt) def f(val...
_iter): msg = 'reduction operation {name!r} not allowed for this dtype' raise TypeError(msg.format(name=f.__name__.replace('nan', ''))) try: with np.errstate(invalid='ignore'): return f(*args, **kwargs) except ValueError as e: ...
139
139
464
6
132
jmcclenon/pandas
pandas/core/nanops.py
Python
bottleneck_switch
bottleneck_switch
90
144
90
91
68e1d85d081588b4bf3e7693b071f01cd634756e
bigcode/the-stack
train
9bd71b4f8000de7fbd30ec8b
train
function
@disallow('O') def nanargmax(values, axis=None, skipna=True): """ Returns -1 in the NA case """ values, mask, dtype, _ = _get_values(values, skipna, fill_value_typ='-inf') result = values.argmax(axis) result = _maybe_arg_null_out(result, axis, mask, skipna) return result
@disallow('O') def nanargmax(values, axis=None, skipna=True):
""" Returns -1 in the NA case """ values, mask, dtype, _ = _get_values(values, skipna, fill_value_typ='-inf') result = values.argmax(axis) result = _maybe_arg_null_out(result, axis, mask, skipna) return result
__ = 'nan' + meth return reduction nanmin = _nanminmax('min', fill_value_typ='+inf') nanmax = _nanminmax('max', fill_value_typ='-inf') @disallow('O') def nanargmax(values, axis=None, skipna=True):
64
64
84
19
45
jmcclenon/pandas
pandas/core/nanops.py
Python
nanargmax
nanargmax
520
528
520
521
d7300e6e82db40c9c58a8416cd9bee5b5434c369
bigcode/the-stack
train
d5b4a09cb75625aba2f0c321
train
function
@disallow('M8', 'm8') def nansem(values, axis=None, skipna=True, ddof=1): var = nanvar(values, axis, skipna, ddof=ddof) mask = isna(values) if not is_float_dtype(values.dtype): values = values.astype('f8') count, _ = _get_counts_nanvar(mask, axis, ddof, values.dtype) var = nanvar(values, ax...
@disallow('M8', 'm8') def nansem(values, axis=None, skipna=True, ddof=1):
var = nanvar(values, axis, skipna, ddof=ddof) mask = isna(values) if not is_float_dtype(values.dtype): values = values.astype('f8') count, _ = _get_counts_nanvar(mask, axis, ddof, values.dtype) var = nanvar(values, axis, skipna, ddof=ddof) return np.sqrt(var) / np.sqrt(count)
the same # precision as the original values array. if is_float_dtype(dtype): result = result.astype(dtype) return _wrap_results(result, values.dtype) @disallow('M8', 'm8') def nansem(values, axis=None, skipna=True, ddof=1):
64
64
120
28
36
jmcclenon/pandas
pandas/core/nanops.py
Python
nansem
nansem
480
490
480
481
0a5db4e6a6260f3346bb62b2e2f4c925044dbc66
bigcode/the-stack
train
393b9ecac4bb91d319b683bd
train
function
def _zero_out_fperr(arg): # #18044 reference this behavior to fix rolling skew/kurt issue if isinstance(arg, np.ndarray): with np.errstate(invalid='ignore'): return np.where(np.abs(arg) < 1e-14, 0, arg) else: return arg.dtype.type(0) if np.abs(arg) < 1e-14 else arg
def _zero_out_fperr(arg): # #18044 reference this behavior to fix rolling skew/kurt issue
if isinstance(arg, np.ndarray): with np.errstate(invalid='ignore'): return np.where(np.abs(arg) < 1e-14, 0, arg) else: return arg.dtype.type(0) if np.abs(arg) < 1e-14 else arg
elif result is not tslibs.NaT: null_mask = mask.size - mask.sum() if null_mask < min_count: result = np.nan return result def _zero_out_fperr(arg): # #18044 reference this behavior to fix rolling skew/kurt issue
64
64
88
25
38
jmcclenon/pandas
pandas/core/nanops.py
Python
_zero_out_fperr
_zero_out_fperr
733
739
733
734
56ccb413e7a83a396689f54a8b7dac71f02775ed
bigcode/the-stack
train
7ba813b22264101e52ec9175
train
function
def _isfinite(values): if is_datetime_or_timedelta_dtype(values): return isna(values) if (is_complex_dtype(values) or is_float_dtype(values) or is_integer_dtype(values) or is_bool_dtype(values)): return ~np.isfinite(values) return ~np.isfinite(values.astype('float64'))
def _isfinite(values):
if is_datetime_or_timedelta_dtype(values): return isna(values) if (is_complex_dtype(values) or is_float_dtype(values) or is_integer_dtype(values) or is_bool_dtype(values)): return ~np.isfinite(values) return ~np.isfinite(values.astype('float64'))
platform independent precision dtype dtype_max = dtype if is_integer_dtype(dtype) or is_bool_dtype(dtype): dtype_max = np.int64 elif is_float_dtype(dtype): dtype_max = np.float64 return values, mask, dtype, dtype_max def _isfinite(values):
64
64
70
6
57
jmcclenon/pandas
pandas/core/nanops.py
Python
_isfinite
_isfinite
247
253
247
247
e68ca717e3f57f72bf4510acae012a4c31f801e2
bigcode/the-stack
train
321051016e5e79896a712fd9
train
function
@disallow('M8', 'm8') def nanprod(values, axis=None, skipna=True, min_count=0): mask = isna(values) if skipna and not is_any_int_dtype(values): values = values.copy() values[mask] = 1 result = values.prod(axis) return _maybe_null_out(result, axis, mask, min_count=min_count)
@disallow('M8', 'm8') def nanprod(values, axis=None, skipna=True, min_count=0):
mask = isna(values) if skipna and not is_any_int_dtype(values): values = values.copy() values[mask] = 1 result = values.prod(axis) return _maybe_null_out(result, axis, mask, min_count=min_count)
, np.ndarray): result = np.where(denom == 0, 0, result) result[count < 4] = np.nan return result @disallow('M8', 'm8') def nanprod(values, axis=None, skipna=True, min_count=0):
64
64
86
28
35
jmcclenon/pandas
pandas/core/nanops.py
Python
nanprod
nanprod
669
676
669
670
bf4cdda2a9312ad9537506fb233c71594011ab4e
bigcode/the-stack
train
a4bbda72ad0f14469431dd60
train
function
def _get_counts(mask, axis, dtype=float): dtype = _get_dtype(dtype) if axis is None: return dtype.type(mask.size - mask.sum()) count = mask.shape[axis] - mask.sum(axis) if is_scalar(count): return dtype.type(count) try: return count.astype(dtype) except AttributeError: ...
def _get_counts(mask, axis, dtype=float):
dtype = _get_dtype(dtype) if axis is None: return dtype.type(mask.size - mask.sum()) count = mask.shape[axis] - mask.sum(axis) if is_scalar(count): return dtype.type(count) try: return count.astype(dtype) except AttributeError: return np.array(count, dtype=dtype)...
result = -1 else: if skipna: na_mask = mask.all(axis) else: na_mask = mask.any(axis) if na_mask.any(): result[na_mask] = -1 return result def _get_counts(mask, axis, dtype=float):
64
64
84
11
52
jmcclenon/pandas
pandas/core/nanops.py
Python
_get_counts
_get_counts
698
709
698
698
dfdad36716b8fadbc2251bb38c1eac84a23d8d60
bigcode/the-stack
train
8c51c16fcdea69237f7a4c29
train
function
def _na_ok_dtype(dtype): return not is_int_or_datetime_dtype(dtype)
def _na_ok_dtype(dtype):
return not is_int_or_datetime_dtype(dtype)
(values): return isna(values) if (is_complex_dtype(values) or is_float_dtype(values) or is_integer_dtype(values) or is_bool_dtype(values)): return ~np.isfinite(values) return ~np.isfinite(values.astype('float64')) def _na_ok_dtype(dtype):
63
64
17
7
56
jmcclenon/pandas
pandas/core/nanops.py
Python
_na_ok_dtype
_na_ok_dtype
256
257
256
256
fd91b90a029a159b08ce4d9acf2a1bbd57fab315
bigcode/the-stack
train
26366b6d0a5ebb8641f567ea
train
function
def _has_infs(result): if isinstance(result, np.ndarray): if result.dtype == 'f8': return lib.has_infs_f8(result.ravel()) elif result.dtype == 'f4': return lib.has_infs_f4(result.ravel()) try: return np.isinf(result).any() except (TypeError, NotImplementedErro...
def _has_infs(result):
if isinstance(result, np.ndarray): if result.dtype == 'f8': return lib.has_infs_f8(result.ravel()) elif result.dtype == 'f4': return lib.has_infs_f4(result.ravel()) try: return np.isinf(result).any() except (TypeError, NotImplementedError): # if it doe...
want to preserve NaN when all elements # are NaN, unlinke bottleneck/numpy which consider this # to be 0 if name in ['nansum', 'nanprod']: return False return True return False def _has_infs(result):
64
64
99
7
56
jmcclenon/pandas
pandas/core/nanops.py
Python
_has_infs
_has_infs
166
176
166
166
b55aec522476b7cfd8b6bc401d2a3d838d9722a6
bigcode/the-stack
train
e4d327deb8e87ac654639026
train
function
@disallow('M8', 'm8') def nanskew(values, axis=None, skipna=True): """ Compute the sample skewness. The statistic computed here is the adjusted Fisher-Pearson standardized moment coefficient G1. The algorithm computes this coefficient directly from the second and third central moment. """ val...
@disallow('M8', 'm8') def nanskew(values, axis=None, skipna=True):
""" Compute the sample skewness. The statistic computed here is the adjusted Fisher-Pearson standardized moment coefficient G1. The algorithm computes this coefficient directly from the second and third central moment. """ values = com._values_from_object(values) mask = isna(values) i...
_typ='-inf') result = values.argmax(axis) result = _maybe_arg_null_out(result, axis, mask, skipna) return result @disallow('O') def nanargmin(values, axis=None, skipna=True): """ Returns -1 in the NA case """ values, mask, dtype, _ = _get_values(values, skipna, fill_value_typ='+inf') r...
141
141
473
24
116
jmcclenon/pandas
pandas/core/nanops.py
Python
nanskew
nanskew
542
598
542
543
92540e70ece1c868203daf0c1a71cb6d4699f4d4
bigcode/the-stack
train
c5fcd2a6c99438979bf89edc
train
function
def _maybe_null_out(result, axis, mask, min_count=1): if axis is not None and getattr(result, 'ndim', False): null_mask = (mask.shape[axis] - mask.sum(axis) - min_count) < 0 if np.any(null_mask): if is_numeric_dtype(result): if np.iscomplexobj(result): ...
def _maybe_null_out(result, axis, mask, min_count=1):
if axis is not None and getattr(result, 'ndim', False): null_mask = (mask.shape[axis] - mask.sum(axis) - min_count) < 0 if np.any(null_mask): if is_numeric_dtype(result): if np.iscomplexobj(result): result = result.astype('c16') else: ...
count = mask.shape[axis] - mask.sum(axis) if is_scalar(count): return dtype.type(count) try: return count.astype(dtype) except AttributeError: return np.array(count, dtype=dtype) def _maybe_null_out(result, axis, mask, min_count=1):
64
64
171
16
48
jmcclenon/pandas
pandas/core/nanops.py
Python
_maybe_null_out
_maybe_null_out
712
730
712
712
3212d8add11e13130e4a684065dc35f2c1b4bed6
bigcode/the-stack
train
5a90b9ad928649fc0c155ce7
train
function
@disallow('M8') @bottleneck_switch(ddof=1) def nanvar(values, axis=None, skipna=True, ddof=1): values = com._values_from_object(values) dtype = values.dtype mask = isna(values) if is_any_int_dtype(values): values = values.astype('f8') values[mask] = np.nan if is_float_dtype(values)...
@disallow('M8') @bottleneck_switch(ddof=1) def nanvar(values, axis=None, skipna=True, ddof=1):
values = com._values_from_object(values) dtype = values.dtype mask = isna(values) if is_any_int_dtype(values): values = values.astype('f8') values[mask] = np.nan if is_float_dtype(values): count, d = _get_counts_nanvar(mask, axis, ddof, values.dtype) else: count,...
, d @disallow('M8') @bottleneck_switch(ddof=1) def nanstd(values, axis=None, skipna=True, ddof=1): result = np.sqrt(nanvar(values, axis=axis, skipna=skipna, ddof=ddof)) return _wrap_results(result, values.dtype) @disallow('M8') @bottleneck_switch(ddof=1) def nanvar(values, axis=None, skipna=True, ddof=1):
107
107
358
34
73
jmcclenon/pandas
pandas/core/nanops.py
Python
nanvar
nanvar
439
477
439
442
b0f32da503e60a59ba9ce862d741820bef1570c0
bigcode/the-stack
train
f5a9aa0c62a5213011db3efa
train
function
def ACE_channel(img, ratio, radius): """The implementation of ACE through individual channel""" h, w = img.shape[:2] if min(h, w) <= 2: return np.zeros(img.shape) + 0.5 down_ori = cv2.pyrDown(img, ((w + 1) // 2, (h + 1) // 2)) temp = ACE_channel(down_ori, ratio, radius) up_temp = cv2.res...
def ACE_channel(img, ratio, radius):
"""The implementation of ACE through individual channel""" h, w = img.shape[:2] if min(h, w) <= 2: return np.zeros(img.shape) + 0.5 down_ori = cv2.pyrDown(img, ((w + 1) // 2, (h + 1) // 2)) temp = ACE_channel(down_ori, ratio, radius) up_temp = cv2.resize(temp, (w, h)) up_ori = cv2.re...
if para_mat[i][j] == 0: continue res += (para_mat[i][j] * np.clip((img - temp[i:i + h, j:j + w]) * ratio, -1, 1)) return res def ACE_channel(img, ratio, radius):
64
64
153
9
54
Gouzhong1223/Dubhe
dubhe_data_process/common/util/algorithm/ACE.py
Python
ACE_channel
ACE_channel
58
68
58
58
4caa83795b39d089967085bc611e33307af3c4ab
bigcode/the-stack
train
0d82eadc4638e8f7fdb55dc6
train
function
def reprocessImage(img): """Reprocess and map the image to [0,1]""" ht = np.histogram(img, 2000) d = np.cumsum(ht[0]) / float(img.size) try: left = next(x for x in range(len(d)) if d[x] >= 0.005) except: left = 1999 try: right = next(y for y in range(len(d) - 1, 0, -1) if...
def reprocessImage(img):
"""Reprocess and map the image to [0,1]""" ht = np.histogram(img, 2000) d = np.cumsum(ht[0]) / float(img.size) try: left = next(x for x in range(len(d)) if d[x] >= 0.005) except: left = 1999 try: right = next(y for y in range(len(d) - 1, 0, -1) if d[y] <= 0.995) excep...
4, radius=3): """Enhance the image through RGB channels""" re = np.zeros(img.shape) for c in range(3): re[:, :, c] = reprocessImage(ACE_channel(img[:, :, c], ratio, radius)) return re def reprocessImage(img):
64
64
161
6
57
Gouzhong1223/Dubhe
dubhe_data_process/common/util/algorithm/ACE.py
Python
reprocessImage
reprocessImage
79
91
79
79
d42a988ad25390a2d1ec235082d33e2d20fb4199
bigcode/the-stack
train
763d70d021509910090103c0
train
function
def ACE_color(img, ratio=4, radius=3): """Enhance the image through RGB channels""" re = np.zeros(img.shape) for c in range(3): re[:, :, c] = reprocessImage(ACE_channel(img[:, :, c], ratio, radius)) return re
def ACE_color(img, ratio=4, radius=3):
"""Enhance the image through RGB channels""" re = np.zeros(img.shape) for c in range(3): re[:, :, c] = reprocessImage(ACE_channel(img[:, :, c], ratio, radius)) return re
2.resize(temp, (w, h)) up_ori = cv2.resize(down_ori, (w, h)) re = up_temp + ACE(img, ratio, radius) - ACE(up_ori, ratio, radius) return re def ACE_color(img, ratio=4, radius=3):
64
64
65
13
50
Gouzhong1223/Dubhe
dubhe_data_process/common/util/algorithm/ACE.py
Python
ACE_color
ACE_color
71
76
71
71
2312468fd9511369d95199378b6ab1d5b04025a4
bigcode/the-stack
train
cc364de71cfe5077f828a31b
train
function
def ACE(img, ratio=4, radius=300): """The implementation of ACE""" global para para_mat = para.get(radius) if para_mat is not None: pass else: size = radius * 2 + 1 para_mat = np.zeros((size, size)) for h in range(-radius, radius + 1): for w in range(-radi...
def ACE(img, ratio=4, radius=300):
"""The implementation of ACE""" global para para_mat = para.get(radius) if para_mat is not None: pass else: size = radius * 2 + 1 para_mat = np.zeros((size, size)) for h in range(-radius, radius + 1): for w in range(-radius, radius + 1): if...
/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ...
93
94
316
12
81
Gouzhong1223/Dubhe
dubhe_data_process/common/util/algorithm/ACE.py
Python
ACE
ACE
27
55
27
27
db1d6fe3cd8b5a2889c659f8b60a59b256273fbf
bigcode/the-stack
train
5e2aa3a2ba3f3fa84a1f32c6
train
function
def invalid(): messagebox.showinfo("Error","Invalid Option") ask()
def invalid():
messagebox.showinfo("Error","Invalid Option") ask()
program is for automation of common uses on LinkedIn ''' from selenium import webdriver from bs4 import BeautifulSoup from urllib.parse import urlparse import tkinter as tk from tkinter import simpledialog from tkinter import messagebox import os,random,time,sys # Handels invalid input def invalid():
64
64
16
3
60
ManoChitoda/Portfolio
LinkedInBot/web-s.py
Python
invalid
invalid
17
19
17
17
89f0744312458240afd5315fc4886867e7e90eca
bigcode/the-stack
train
859ee7345337ced3f842521c
train
function
def ask(): choice = simpledialog.askinteger("Choice","Choose the following options!\n1: Post something\n2: Find Someone\n") switch_replacement(choice)
def ask():
choice = simpledialog.askinteger("Choice","Choose the following options!\n1: Post something\n2: Find Someone\n") switch_replacement(choice)
Soup from urllib.parse import urlparse import tkinter as tk from tkinter import simpledialog from tkinter import messagebox import os,random,time,sys # Handels invalid input def invalid(): messagebox.showinfo("Error","Invalid Option") ask() # Asks for choices def ask():
64
64
35
3
60
ManoChitoda/Portfolio
LinkedInBot/web-s.py
Python
ask
ask
22
24
22
22
d12b0377846e508c6f7dc4285b2f5fa460d2c1f0
bigcode/the-stack
train
76742652687a85dc79f92892
train
function
def findProfile(): find_this = simpledialog.askstring("Post", "Who are you looking for?\n\nEnter the name in lowercase & without any space!") browser.get("https://www.linkedin.com/in/" + find_this + "/")
def findProfile():
find_this = simpledialog.askstring("Post", "Who are you looking for?\n\nEnter the name in lowercase & without any space!") browser.get("https://www.linkedin.com/in/" + find_this + "/")
findProfile } fun = switcher.get(choice,lambda: invalid()) fun() # Choice of posting something def post(): post_stmt = simpledialog.askstring("Post", "What do you want your post to say?") print(post_stmt) # Choice of finding a profile def findProfile():
64
64
50
4
59
ManoChitoda/Portfolio
LinkedInBot/web-s.py
Python
findProfile
findProfile
41
43
41
41
8f96cbe8d5350c8a47ea90944f3d2e85b2fc431a
bigcode/the-stack
train
f8c2f0a8d04e2bebe3a483c1
train
function
def post(): post_stmt = simpledialog.askstring("Post", "What do you want your post to say?") print(post_stmt)
def post():
post_stmt = simpledialog.askstring("Post", "What do you want your post to say?") print(post_stmt)
Find Someone\n") switch_replacement(choice) # Direct the choices def switch_replacement(choice): switcher = { 1: post, 2: findProfile } fun = switcher.get(choice,lambda: invalid()) fun() # Choice of posting something def post():
64
64
27
3
60
ManoChitoda/Portfolio
LinkedInBot/web-s.py
Python
post
post
36
38
36
36
84048ab422541edbf6fee15ff8fd9221b4bf76d8
bigcode/the-stack
train
5be0fbb5b86ad4586346aff1
train
function
def switch_replacement(choice): switcher = { 1: post, 2: findProfile } fun = switcher.get(choice,lambda: invalid()) fun()
def switch_replacement(choice):
switcher = { 1: post, 2: findProfile } fun = switcher.get(choice,lambda: invalid()) fun()
.showinfo("Error","Invalid Option") ask() # Asks for choices def ask(): choice = simpledialog.askinteger("Choice","Choose the following options!\n1: Post something\n2: Find Someone\n") switch_replacement(choice) # Direct the choices def switch_replacement(choice):
64
64
40
6
57
ManoChitoda/Portfolio
LinkedInBot/web-s.py
Python
switch_replacement
switch_replacement
27
33
27
27
0b33ac9f450b01c8494d3afa5345e6c787dcf300
bigcode/the-stack
train
b1fe5996cbbe82de7ab8a19a
train
class
class ArticlecrawlItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field() pass
class ArticlecrawlItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field()
pass
# Define here the models for your scraped items # # See documentation in: # https://docs.scrapy.org/en/latest/topics/items.html import scrapy class ArticlecrawlItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field()
58
64
29
26
31
awael/Finantial-News-Scraper
ArticleCrawl/ArticleCrawl/items.py
Python
ArticlecrawlItem
ArticlecrawlItem
9
12
9
11
a8a2a7efe389c735f390b3eadfaacf9c0aa52bef
bigcode/the-stack
train
5f8f54e38ba8f1302a314b54
train
function
def get_current_connections(): """ Returns a list of `UncDirectoryConnection` or `UncDirectoryMount` objects. Each object represents a connection or mount currently recognized by the system. """ net_use = get_current_net_use_table() return [_get_connection_or_mount(row['remote'], row['local']) f...
def get_current_connections():
""" Returns a list of `UncDirectoryConnection` or `UncDirectoryMount` objects. Each object represents a connection or mount currently recognized by the system. """ net_use = get_current_net_use_table() return [_get_connection_or_mount(row['remote'], row['local']) for row in net_use.rows]
from win_unc.connecting import UncDirectoryConnection, UncDirectoryMount from win_unc.internal.current_state import get_current_net_use_table __all__ = ['get_current_connections', 'get_connection_for_unc_directory', 'get_connection_for_disk_drive'] def get_current_connections():
57
64
76
5
52
zo-edv/py_win_unc
win_unc/query.py
Python
get_current_connections
get_current_connections
8
14
8
8
c756e4be5f37e55d8ce1c7f9b247ce85bb63857c
bigcode/the-stack
train
6c20f5e8cee1eb23ea8050cf
train
function
def get_connection_for_disk_drive(disk_drive): """ Returns a `UncDirectoryMount` representing a mounted UNC directory that matches a disk drive (`disk_drive`) or `None` if no system mounts match `disk_drive`. `disk_drive` is a `DiskDrive`. """ net_use = get_current_net_use_table() matching =...
def get_connection_for_disk_drive(disk_drive):
""" Returns a `UncDirectoryMount` representing a mounted UNC directory that matches a disk drive (`disk_drive`) or `None` if no system mounts match `disk_drive`. `disk_drive` is a `DiskDrive`. """ net_use = get_current_net_use_table() matching = net_use.get_matching_rows(local=disk_drive) ...
`UncDirectory`. """ net_use = get_current_net_use_table() matching = net_use.get_matching_rows(remote=unc) return _get_connection_or_mount(matching[0]['remote'], matching[0]['local']) if matching else None def get_connection_for_disk_drive(disk_drive):
64
64
110
10
53
zo-edv/py_win_unc
win_unc/query.py
Python
get_connection_for_disk_drive
get_connection_for_disk_drive
29
37
29
29
cd56083fd9c942e083585cb8d6484475680651e9
bigcode/the-stack
train
10f296adb71e9d4d439de26c
train
function
def get_connection_for_unc_directory(unc): """ Returns a `UncDirectoryConnection` or `UncDirectoryMount` representing a connected or mounted UNC directory that matches a given UNC directory (`unc`) or `None` if no system connections or mounts match `unc`. `unc` is a `UncDirectory`. """ net_u...
def get_connection_for_unc_directory(unc):
""" Returns a `UncDirectoryConnection` or `UncDirectoryMount` representing a connected or mounted UNC directory that matches a given UNC directory (`unc`) or `None` if no system connections or mounts match `unc`. `unc` is a `UncDirectory`. """ net_use = get_current_net_use_table() matchi...
cDirectoryMount` objects. Each object represents a connection or mount currently recognized by the system. """ net_use = get_current_net_use_table() return [_get_connection_or_mount(row['remote'], row['local']) for row in net_use.rows] def get_connection_for_unc_directory(unc):
64
64
121
9
55
zo-edv/py_win_unc
win_unc/query.py
Python
get_connection_for_unc_directory
get_connection_for_unc_directory
17
26
17
17
d7c6ac7483b8bb97e845268d041e52f99b902029
bigcode/the-stack
train
0039ee6d338e84114773bd3e
train
function
def _get_connection_or_mount(unc, disk_drive=None): return UncDirectoryMount(unc, disk_drive) if disk_drive else UncDirectoryConnection(unc)
def _get_connection_or_mount(unc, disk_drive=None):
return UncDirectoryMount(unc, disk_drive) if disk_drive else UncDirectoryConnection(unc)
Drive`. """ net_use = get_current_net_use_table() matching = net_use.get_matching_rows(local=disk_drive) return UncDirectoryMount(matching[0]['remote'], matching[0]['local']) if matching else None def _get_connection_or_mount(unc, disk_drive=None):
64
64
36
13
50
zo-edv/py_win_unc
win_unc/query.py
Python
_get_connection_or_mount
_get_connection_or_mount
40
41
40
40
136a176daea2ff84067a30a37236befef4caccb3
bigcode/the-stack
train
86b3fefdf1cc93fdc1ad65c2
train
function
def test_mkdir_file_exists(tmp_path): """mkdir""" dest = tmp_path / "foo" dest.touch() with pytest.raises(Exception) as e: assert PathlibUtil(dest).mkdir() assert e.type == FileExistsError
def test_mkdir_file_exists(tmp_path):
"""mkdir""" dest = tmp_path / "foo" dest.touch() with pytest.raises(Exception) as e: assert PathlibUtil(dest).mkdir() assert e.type == FileExistsError
libUtil(src_path).move_to(dest_path) assert e.type == FileExistsError def test_mkdir(tmp_path): """mkdir""" dest = tmp_path / "foo" result = PathlibUtil(dest).mkdir() assert result.is_dir() def test_mkdir_file_exists(tmp_path):
64
64
53
9
55
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_mkdir_file_exists
test_mkdir_file_exists
188
194
188
188
0a50e7a0da5efbbbfef105220467a41dc3865f48
bigcode/the-stack
train
315680157bebf33ebe7765ec
train
function
def test_mkdir(tmp_path): """mkdir""" dest = tmp_path / "foo" result = PathlibUtil(dest).mkdir() assert result.is_dir()
def test_mkdir(tmp_path):
"""mkdir""" dest = tmp_path / "foo" result = PathlibUtil(dest).mkdir() assert result.is_dir()
_path = dest_path / "test.jpg" dest_path.touch() PathlibUtil(TEST_FILE).copy_to(src_path) with pytest.raises(Exception) as e: assert PathlibUtil(src_path).move_to(dest_path) assert e.type == FileExistsError def test_mkdir(tmp_path):
64
64
36
7
56
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_mkdir
test_mkdir
181
185
181
181
06840fc3079d124d617a8c099a8e8487fbde7b18
bigcode/the-stack
train
50e38f183c030bab557a828d
train
function
def test_hardlink_to_file_invvalid(tmp_path): """hardlink_to file with invalid src, dest""" dest = tmp_path / "test.jpg" dest2 = tmp_path / "test2.jpg" with pytest.raises(Exception) as e: assert PathlibUtil(dest).hardlink_to(dest2) assert e.type == FileNotFoundError
def test_hardlink_to_file_invvalid(tmp_path):
"""hardlink_to file with invalid src, dest""" dest = tmp_path / "test.jpg" dest2 = tmp_path / "test2.jpg" with pytest.raises(Exception) as e: assert PathlibUtil(dest).hardlink_to(dest2) assert e.type == FileNotFoundError
_path): """hardlink_to file with valid src, dest""" dest = tmp_path / "test.jpg" result = PathlibUtil(dest).hardlink_to(TEST_FILE) assert result.is_file() assert result.samefile(TEST_FILE) def test_hardlink_to_file_invvalid(tmp_path):
64
64
78
12
52
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_hardlink_to_file_invvalid
test_hardlink_to_file_invvalid
205
211
205
205
7e94e74a0b635671f3e5b2e30fe1019e8b5c6eb0
bigcode/the-stack
train
344167484372cecd7b8a1bea
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_valid(tmp_path, pyobjc, monkeypatch): """copy file with valid src, dest""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) result = PathlibUtil(TEST_FILE).copy_to(tmp_path) assert result.is_file()
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_valid(tmp_path, pyobjc, monkeypatch):
"""copy file with valid src, dest""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) result = PathlibUtil(TEST_FILE).copy_to(tmp_path) assert result.is_file()
and pyobjc is installed, test the pyobjc methods PYOBJC = False try: import Foundation PYOBJC = True except ImportError: pass @pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_valid(tmp_path, pyobjc, monkeypatch):
64
64
78
26
37
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_copy_file_valid
test_copy_file_valid
27
33
27
28
28138ad68f0ba85a9ffc2f372d1d97466fae5d53
bigcode/the-stack
train
4e11d4c88d477dfae21de8d3
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_source_is_dir(tmp_path, pyobjc, monkeypatch): """copy directory""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) result = PathlibUtil(TEST_DIR).copy_to(tmp_path) assert result.is_dir() assert TEST_FILE_NAME...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_source_is_dir(tmp_path, pyobjc, monkeypatch):
"""copy directory""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) result = PathlibUtil(TEST_DIR).copy_to(tmp_path) assert result.is_dir() assert TEST_FILE_NAME in [f.name for f in result.iterdir()]
dest_dir = tmp_path / "test_dir" dest_dir.mkdir() result = PathlibUtil(TEST_FILE).copy_to(dest_dir) assert result.is_file() @pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_source_is_dir(tmp_path, pyobjc, monkeypatch):
64
64
91
28
36
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_copy_file_source_is_dir
test_copy_file_source_is_dir
70
77
70
71
d007276511b3c9bf54acaebad102827f77ddce23
bigcode/the-stack
train
019e6a9e0e7ad95240a9c378
train
function
def test_hardlink_to_file_valid(tmp_path): """hardlink_to file with valid src, dest""" dest = tmp_path / "test.jpg" result = PathlibUtil(dest).hardlink_to(TEST_FILE) assert result.is_file() assert result.samefile(TEST_FILE)
def test_hardlink_to_file_valid(tmp_path):
"""hardlink_to file with valid src, dest""" dest = tmp_path / "test.jpg" result = PathlibUtil(dest).hardlink_to(TEST_FILE) assert result.is_file() assert result.samefile(TEST_FILE)
def test_mkdir_file_exists(tmp_path): """mkdir""" dest = tmp_path / "foo" dest.touch() with pytest.raises(Exception) as e: assert PathlibUtil(dest).mkdir() assert e.type == FileExistsError def test_hardlink_to_file_valid(tmp_path):
64
64
61
11
52
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_hardlink_to_file_valid
test_hardlink_to_file_valid
197
202
197
197
bf3f698a102754ec658266aa93c59b307d097659
bigcode/the-stack
train
f71c0cfa3a761b2760a3ab78
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_destination_is_dir(tmp_path, pyobjc, monkeypatch): """copy file when destination is a directory""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) dest_dir = tmp_path / "test_dir" dest_dir.mkdir() result = Pa...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_destination_is_dir(tmp_path, pyobjc, monkeypatch):
"""copy file when destination is a directory""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) dest_dir = tmp_path / "test_dir" dest_dir.mkdir() result = PathlibUtil(TEST_FILE).copy_to(dest_dir) assert result.is_file()
tmp_file.touch() with pytest.raises(Exception) as e: assert PathlibUtil(TEST_FILE).copy_to(tmp_file) assert e.type == FileExistsError @pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_destination_is_dir(tmp_path, pyobjc, monkeypatch):
64
64
96
28
35
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_copy_file_destination_is_dir
test_copy_file_destination_is_dir
59
67
59
60
f18ed6e5f190cb67bfae61f15fd92037058a3979
bigcode/the-stack
train
d37ae180f739edd78f93cb46
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_invalid(tmp_path, pyobjc, monkeypatch): """copy file with invalid src""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) with pytest.raises(Exception) as e: src = "tests/test_files/DOES_NOT_EXIST.jpg" ...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_invalid(tmp_path, pyobjc, monkeypatch):
"""copy file with invalid src""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) with pytest.raises(Exception) as e: src = "tests/test_files/DOES_NOT_EXIST.jpg" assert PathlibUtil(src).copy_to(tmp_path) assert e.type == FileNotFoundError
JC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) result = PathlibUtil(TEST_FILE).copy_to(tmp_path) assert result.is_file() @pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_invalid(tmp_path, pyobjc, monkeypatch):
64
64
101
26
38
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_copy_file_invalid
test_copy_file_invalid
36
44
36
37
fc0eddcfc5e95cb66ccf1343f882d129b0009023
bigcode/the-stack
train
280f0bcc07442d730ded82e4
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_destination_file_exists(tmp_path, pyobjc, monkeypatch): """copy file when destination file exists""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) tmp_file = tmp_path / "test.jpg" tmp_file.touch() with pyte...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_destination_file_exists(tmp_path, pyobjc, monkeypatch):
"""copy file when destination file exists""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) tmp_file = tmp_path / "test.jpg" tmp_file.touch() with pytest.raises(Exception) as e: assert PathlibUtil(TEST_FILE).copy_to(tmp_file) assert e.type == FileExistsError
src = "tests/test_files/DOES_NOT_EXIST.jpg" assert PathlibUtil(src).copy_to(tmp_path) assert e.type == FileNotFoundError @pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_destination_file_exists(tmp_path, pyobjc, monkeypatch):
64
64
106
28
35
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_copy_file_destination_file_exists
test_copy_file_destination_file_exists
47
56
47
48
49363048bd873d44305ea27a2d280c34f4b5a9cf
bigcode/the-stack
train
03b468d71995125cfcfaf5a3
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_destination_file_exists(tmp_path, pyobjc, monkeypatch): """move file when destination file exists""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_path = tm...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_destination_file_exists(tmp_path, pyobjc, monkeypatch):
"""move file when destination file exists""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_path = tmp_path / "dest" dest_path.mkdir() dest_path = dest_path / "test.jpg" dest_path.touch() src = PathlibUtil(TEST...
src = "tests/test_files/DOES_NOT_EXIST.jpg" assert PathlibUtil(src).move_to(tmp_path) assert e.type == FileNotFoundError @pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_destination_file_exists(tmp_path, pyobjc, monkeypatch):
64
64
149
28
35
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_move_file_destination_file_exists
test_move_file_destination_file_exists
118
132
118
119
cc0895028ce610c8ff6290cf01cfb09512fa57d6
bigcode/the-stack
train
ba9599f76b3341d0fd406b0e
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_source_is_dir(tmp_path, pyobjc, monkeypatch): """move directory""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_path = tmp_path / "dest" dest_path.mkdi...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_source_is_dir(tmp_path, pyobjc, monkeypatch):
"""move directory""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_path = tmp_path / "dest" dest_path.mkdir() PathlibUtil(TEST_FILE).copy_to(src_path) result = PathlibUtil(src_path).move_to(dest_path) assert r...
_path.mkdir() src = PathlibUtil(TEST_FILE).copy_to(src_path) result = PathlibUtil(src).move_to(dest_path) assert result.is_file() @pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_source_is_dir(tmp_path, pyobjc, monkeypatch):
64
64
133
28
36
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_move_file_source_is_dir
test_move_file_source_is_dir
149
161
149
150
b359bc928a71aba33edb8140176332b18c3f311a
bigcode/the-stack
train
0aef3f517be8624560c0061a
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_source_is_dir_dest_is_file(tmp_path, pyobjc, monkeypatch): """move directory when destination is a file""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_pat...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_source_is_dir_dest_is_file(tmp_path, pyobjc, monkeypatch):
"""move directory when destination is a file""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_path = tmp_path / "dest" dest_path.mkdir() dest_path = dest_path / "test.jpg" dest_path.touch() PathlibUtil(TEST_FI...
libUtil(src_path).move_to(dest_path) assert result.is_dir() assert TEST_FILE_NAME in [f.name for f in result.iterdir()] @pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_source_is_dir_dest_is_file(tmp_path, pyobjc, monkeypatch):
63
64
152
31
32
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_move_file_source_is_dir_dest_is_file
test_move_file_source_is_dir_dest_is_file
164
178
164
165
e1f6a0ac19d960be1a0f15a168b4ce87feca8fd6
bigcode/the-stack
train
f51d737079466066745fb18e
train
function
def test_hardlink_at_file_invvalid(tmp_path): """hardlink_to file with invalid src, dest""" dest = tmp_path / "test.jpg" dest2 = tmp_path / "test2.jpg" with pytest.raises(Exception) as e: assert PathlibUtil(dest).hardlink_at(dest2) assert e.type == FileNotFoundError
def test_hardlink_at_file_invvalid(tmp_path):
"""hardlink_to file with invalid src, dest""" dest = tmp_path / "test.jpg" dest2 = tmp_path / "test2.jpg" with pytest.raises(Exception) as e: assert PathlibUtil(dest).hardlink_at(dest2) assert e.type == FileNotFoundError
(tmp_path): """hardlink_at file with valid src, dest""" dest = tmp_path / "test.jpg" result = PathlibUtil(TEST_FILE).hardlink_at(dest) assert result.is_file() assert result.samefile(dest) def test_hardlink_at_file_invvalid(tmp_path):
64
64
78
12
52
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_hardlink_at_file_invvalid
test_hardlink_at_file_invvalid
222
228
222
222
97b4438bef34900970543974d53e9bb995a69d4d
bigcode/the-stack
train
7f6c58c319653b2d70f93a39
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_valid(tmp_path, pyobjc, monkeypatch): """move file with valid src, dest""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_path = tmp_path / "dest" dest_p...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_valid(tmp_path, pyobjc, monkeypatch):
"""move file with valid src, dest""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_path = tmp_path / "dest" dest_path.mkdir() dest_path = dest_path / "test.jpg" src = PathlibUtil(TEST_FILE).copy_to(src_path) r...
.jpg" tmp_file.touch() with pytest.raises(Exception) as e: assert PathlibUtil(TEST_DIR).copy_to(tmp_file) assert e.type == FileExistsError @pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_valid(tmp_path, pyobjc, monkeypatch):
64
64
132
26
37
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_move_file_valid
test_move_file_valid
92
104
92
93
6f0a9fe18bc6b2e8176f34e5d5fed3087b08585b
bigcode/the-stack
train
d79787557496b5e89d0d8d1c
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_invalid(tmp_path, pyobjc, monkeypatch): """move file with invalid src""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) with pytest.raises(Exception) as e: src = "tests/test_files/DOES_NOT_EXIST.jpg" ...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_invalid(tmp_path, pyobjc, monkeypatch):
"""move file with invalid src""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) with pytest.raises(Exception) as e: src = "tests/test_files/DOES_NOT_EXIST.jpg" assert PathlibUtil(src).move_to(tmp_path) assert e.type == FileNotFoundError
/ "test.jpg" src = PathlibUtil(TEST_FILE).copy_to(src_path) result = PathlibUtil(src).move_to(dest_path) assert result.is_file() @pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_invalid(tmp_path, pyobjc, monkeypatch):
64
64
101
26
38
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_move_file_invalid
test_move_file_invalid
107
115
107
108
3bd7953a81221fe1e4452a7396582e53ca406d40
bigcode/the-stack
train
0a16bc6dffa705ebe6caee2e
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_source_is_dir_dest_is_file(tmp_path, pyobjc, monkeypatch): """copy directory when destination is a file""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) tmp_file = tmp_path / "test.jpg" tmp_file.touch() wit...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_source_is_dir_dest_is_file(tmp_path, pyobjc, monkeypatch):
"""copy directory when destination is a file""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) tmp_file = tmp_path / "test.jpg" tmp_file.touch() with pytest.raises(Exception) as e: assert PathlibUtil(TEST_DIR).copy_to(tmp_file) assert e.type == FileExistsError
libUtil(TEST_DIR).copy_to(tmp_path) assert result.is_dir() assert TEST_FILE_NAME in [f.name for f in result.iterdir()] @pytest.mark.parametrize("pyobjc", [True, False]) def test_copy_file_source_is_dir_dest_is_file(tmp_path, pyobjc, monkeypatch):
63
64
110
31
32
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_copy_file_source_is_dir_dest_is_file
test_copy_file_source_is_dir_dest_is_file
80
89
80
81
e64dc2289942977172d940addcae8e21d01dad3d
bigcode/the-stack
train
61b4f752cafcba822b7750a5
train
function
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_destination_is_dir(tmp_path, pyobjc, monkeypatch): """move file when destination is a directory""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_path = tmp_...
@pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_destination_is_dir(tmp_path, pyobjc, monkeypatch):
"""move file when destination is a directory""" if PYOBJC: monkeypatch.setattr(PathlibUtil, "_pyobjc", pyobjc) src_path = tmp_path / "src" src_path.mkdir() dest_path = tmp_path / "dest" dest_path.mkdir() src = PathlibUtil(TEST_FILE).copy_to(src_path) result = PathlibUtil(src).mov...
).copy_to(src_path) with pytest.raises(Exception) as e: assert PathlibUtil(src).move_to(dest_path) assert e.type == FileExistsError @pytest.mark.parametrize("pyobjc", [True, False]) def test_move_file_destination_is_dir(tmp_path, pyobjc, monkeypatch):
64
64
123
28
35
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_move_file_destination_is_dir
test_move_file_destination_is_dir
135
146
135
136
67347ee5be069308864f9a8f07623fe8d4c26069
bigcode/the-stack
train
dd819a1f1260045e64d097a9
train
function
def test_hardlink_at_file_valid(tmp_path): """hardlink_at file with valid src, dest""" dest = tmp_path / "test.jpg" result = PathlibUtil(TEST_FILE).hardlink_at(dest) assert result.is_file() assert result.samefile(dest)
def test_hardlink_at_file_valid(tmp_path):
"""hardlink_at file with valid src, dest""" dest = tmp_path / "test.jpg" result = PathlibUtil(TEST_FILE).hardlink_at(dest) assert result.is_file() assert result.samefile(dest)
dest = tmp_path / "test.jpg" dest2 = tmp_path / "test2.jpg" with pytest.raises(Exception) as e: assert PathlibUtil(dest).hardlink_to(dest2) assert e.type == FileNotFoundError def test_hardlink_at_file_valid(tmp_path):
64
64
60
11
52
RhetTbull/autofile
tests/test_pathlibutil.py
Python
test_hardlink_at_file_valid
test_hardlink_at_file_valid
214
219
214
214
d816075910037bdb16b0da83d03a7f4c02e336cc
bigcode/the-stack
train
1e991bbae6f36526615fdc30
train
class
@day(8) class Day8(AOCDay): print_debug = "c12" test_input = """be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg ...
@day(8) class Day8(AOCDay):
print_debug = "c12" test_input = """be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg fbegcd cbd adcefb dageb afcb...
from collections import defaultdict from days import AOCDay, day @day(8) class Day8(AOCDay):
27
256
993
13
13
Kurocon/AdventOfCode2021
days/day8.py
Python
Day8
Day8
6
66
6
7
75251f9d292347ccc90e90817588607d3c06d068
bigcode/the-stack
train
d4f82ff8c3b78d49714f4442
train
class
class TestRandomVariable(unittest.TestCase): """ Test functions for the statspy.core.RV class """ def test_param_value_initialization(self): """Test that two different ways of setting parameter values give the same answer. """ a = np.linspace(2., 18., 9) X1 = sp.RV("...
class TestRandomVariable(unittest.TestCase):
""" Test functions for the statspy.core.RV class """ def test_param_value_initialization(self): """Test that two different ways of setting parameter values give the same answer. """ a = np.linspace(2., 18., 9) X1 = sp.RV("norm(x1;mu_x1=10,sigma_x1=2)") Y1 = s...
+- 1.") y = sp.Param("y = 4. +- 1.") z = np.zeros(5) z[0] = (x + y).unc z[1] = (x - y).unc z[2] = (x * y).unc z[3] = (x / y).unc z[4] = (x**2).unc result = np.asarray([math.sqrt(2.), # x+y math.sqrt(2.), # x-y ...
190
190
634
8
182
bruneli/statspy
statspy/tests/test_statspy.py
Python
TestRandomVariable
TestRandomVariable
56
105
56
56
f1a9ece74bdcefcc144913b2c73d617b3b5f4baa
bigcode/the-stack
train
7c4429ba85bde2bf4f04df06
train
class
class TestParameter(unittest.TestCase): """ Test functions for the statspy.core.Param class """ def test_operations(self): """Test that parameter operations are fine.""" x = sp.Param("x = 2. +- 1.") y = sp.Param("y = 4. +- 1.") z = np.zeros(8) z[0] = (x + y).value ...
class TestParameter(unittest.TestCase):
""" Test functions for the statspy.core.Param class """ def test_operations(self): """Test that parameter operations are fine.""" x = sp.Param("x = 2. +- 1.") y = sp.Param("y = 4. +- 1.") z = np.zeros(8) z[0] = (x + y).value z[1] = (x - y).value z[2] =...
""" Test functions for the statspy package """ import math import numpy as np from numpy.testing import assert_array_equal from numpy.testing import assert_array_almost_equal import statspy as sp import unittest class TestParameter(unittest.TestCase):
52
149
498
7
44
bruneli/statspy
statspy/tests/test_statspy.py
Python
TestParameter
TestParameter
12
54
12
12
b02811f3b924822d20edc868dc1a32e1ad90f61e
bigcode/the-stack
train
ade0292c0f795b7e0dc18f41
train
class
class Migration(migrations.Migration): dependencies = [ ('examsys', '0001_initial'), ] operations = [ migrations.RenameField( model_name='question', old_name='question_text', new_name='correctans', ), migrations.RemoveField( m...
class Migration(migrations.Migration):
dependencies = [ ('examsys', '0001_initial'), ] operations = [ migrations.RenameField( model_name='question', old_name='question_text', new_name='correctans', ), migrations.RemoveField( model_name='question', name='...
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration):
31
64
116
7
23
icyflame/test-taking-platform
examsys/migrations/0002_auto_20150315_1640.py
Python
Migration
Migration
7
29
7
8
bbd8c3cac971f2b4a53c3100a21097c9c4dfa101
bigcode/the-stack
train
92315dc89321ec5536f76bac
train
class
class RNSB(BaseMetric): """Relative Relative Negative Sentiment Bias (RNSB). References ---------- | [1]: Chris Sweeney and Maryam Najafian. A transparent framework for evaluating | unintended demographic bias in word embeddings. | In Proceedings of the 57th Annual Meeting of t...
class RNSB(BaseMetric):
"""Relative Relative Negative Sentiment Bias (RNSB). References ---------- | [1]: Chris Sweeney and Maryam Najafian. A transparent framework for evaluating | unintended demographic bias in word embeddings. | In Proceedings of the 57th Annual Meeting of the Association for |...
"""Relative Negative Sentiment Bias (RNSB) metric implementation.""" import logging from typing import Any, Callable, Dict, List, Tuple, Union import numpy as np import pandas as pd from scipy.stats import entropy from sklearn.base import BaseEstimator from sklearn.linear_model import LogisticRegression from ...
125
256
3,867
7
117
dccuchile/wefe
wefe/metrics/RNSB.py
Python
RNSB
RNSB
18
467
18
18
59669a1d994a4552a5162aac455d05e8ef8cda55
bigcode/the-stack
train
8081a687b5bcb7c7c28cbe1e
train
function
def _ellip_normal_vec(h2, k2, n, p): return _ellipsoid_norm(h2, k2, n, p)
def _ellip_normal_vec(h2, k2, n, p):
return _ellipsoid_norm(h2, k2, n, p)
0.00108056853382 """ with _ellip_lock: with np.errstate(all='ignore'): return _ellip_harm_2_vec(h2, k2, n, p, s) def _ellip_normal_vec(h2, k2, n, p):
64
64
32
16
48
GiggleLiu/scipy
scipy/special/_ellip_harm.py
Python
_ellip_normal_vec
_ellip_normal_vec
166
167
166
166
323d2b78a2f79f06ce7e3524033945343dfb2652
bigcode/the-stack
train
acfc4b73b0cf4125b9a6bdca
train
function
def ellip_normal(h2, k2, n, p): r""" Ellipsoidal harmonic normalization constants gamma^p_n The normalization constant is defined as .. math:: \gamma^p_n=8\int_{0}^{h}dx\int_{h}^{k}dy\frac{(y^2-x^2)(E^p_n(y)E^p_n(x))^2}{\sqrt((k^2-y^2)(y^2-h^2)(h^2-x^2)(k^2-x^2)} Parameters ----------...
def ellip_normal(h2, k2, n, p):
r""" Ellipsoidal harmonic normalization constants gamma^p_n The normalization constant is defined as .. math:: \gamma^p_n=8\int_{0}^{h}dx\int_{h}^{k}dy\frac{(y^2-x^2)(E^p_n(y)E^p_n(x))^2}{\sqrt((k^2-y^2)(y^2-h^2)(h^2-x^2)(k^2-x^2)} Parameters ---------- h2 : float ``h**2``...
_lock: with np.errstate(all='ignore'): return _ellip_harm_2_vec(h2, k2, n, p, s) def _ellip_normal_vec(h2, k2, n, p): return _ellipsoid_norm(h2, k2, n, p) _ellip_normal_vec = np.vectorize(_ellip_normal_vec, otypes='d') def ellip_normal(h2, k2, n, p):
99
99
331
14
85
GiggleLiu/scipy
scipy/special/_ellip_harm.py
Python
ellip_normal
ellip_normal
172
216
172
172
125d6f1eb6064bcee6c1668e020cd27fe93ba627
bigcode/the-stack
train
5560bdfddb34a227b2de2d53
train
function
def ellip_harm(h2, k2, n, p, s, signm=1, signn=1): r""" Ellipsoidal harmonic functions E^p_n(l) These are also known as Lame functions of the first kind, and are solutions to the Lame equation: .. math:: (s^2 - h^2)(s^2 - k^2)E''(s) + s(2s^2 - h^2 - k^2)E'(s) + (a - q s^2)E(s) = 0 where :math...
def ellip_harm(h2, k2, n, p, s, signm=1, signn=1):
r""" Ellipsoidal harmonic functions E^p_n(l) These are also known as Lame functions of the first kind, and are solutions to the Lame equation: .. math:: (s^2 - h^2)(s^2 - k^2)E''(s) + s(2s^2 - h^2 - k^2)E'(s) + (a - q s^2)E(s) = 0 where :math:`q = (n+1)n` and :math:`a` is the eigenvalue (not ...
from __future__ import division, print_function, absolute_import import threading import numpy as np from ._ufuncs import _ellip_harm from ._ellip_harm_2 import _ellipsoid, _ellipsoid_norm # the functions _ellipsoid, _ellipsoid_norm use global variables, the lock # protects them if the function is called from multi...
119
256
938
27
92
GiggleLiu/scipy
scipy/special/_ellip_harm.py
Python
ellip_harm
ellip_harm
15
103
15
15
872cf9d7693ed0880c1371f89ab3eb88cbe753f1
bigcode/the-stack
train
52a369ed4f875e275d1460b0
train
function
def ellip_harm_2(h2, k2, n, p, s): r""" Ellipsoidal harmonic functions F^p_n(l) These are also known as Lame functions of the second kind, and are solutions to the Lame equation: .. math:: (s^2 - h^2)(s^2 - k^2)F''(s) + s(2s^2 - h^2 - k^2)F'(s) + (a - q s^2)F(s) = 0 where :math:`q = (n+1)n` a...
def ellip_harm_2(h2, k2, n, p, s):
r""" Ellipsoidal harmonic functions F^p_n(l) These are also known as Lame functions of the second kind, and are solutions to the Lame equation: .. math:: (s^2 - h^2)(s^2 - k^2)F''(s) + s(2s^2 - h^2 - k^2)F'(s) + (a - q s^2)F(s) = 0 where :math:`q = (n+1)n` and :math:`a` is the eigenvalue (not...
s) >>> E_spl = UnivariateSpline(s, E) >>> a, a_err = eigenvalue(E_spl(s), E_spl(s,1), E_spl(s,2)) >>> a, a_err (583.44366156701483, 6.4580890640310646e-11) """ return _ellip_harm(h2, k2, n, p, s, signm, signn) _ellip_harm_2_vec = np.vectorize(_ellipsoid, otypes='d') def ellip_harm_2(h2, k2, ...
140
140
468
19
121
GiggleLiu/scipy
scipy/special/_ellip_harm.py
Python
ellip_harm_2
ellip_harm_2
109
163
109
109
d95474441829b3b4e93d40e9d746c73e053e9506
bigcode/the-stack
train
13b32867e0483a2f3018fd57
train
class
class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('posts', '0002_post_likes'), ] operations = [ migrations.AddField( model_name='post', name='dislikes', field=models.ManyToManyFiel...
class Migration(migrations.Migration):
dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('posts', '0002_post_likes'), ] operations = [ migrations.AddField( model_name='post', name='dislikes', field=models.ManyToManyField(related_name='post_dislikes', to=setti...
# Generated by Django 3.1.1 on 2020-09-25 11:37 from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration):
44
64
80
7
36
ShrayankM/Django-MicroBlog
microblog/posts/migrations/0003_post_dislikes.py
Python
Migration
Migration
7
20
7
8
3b1a9c35a9cbd4b9ef3d32ccdbdd7d0d1d3f5391
bigcode/the-stack
train
76e4d07b47fafb38134d270b
train
class
class ssh_server(ShutItModule): def is_installed(self, shutit): shutit.file_exists('/root/start_ssh_server.sh') def build(self, shutit): shutit.install('openssh-server') shutit.set_password(shutit.cfg[self.module_id]['password']) shutit.send('mkdir -p /var/run/sshd') shutit.send('chmod 700 /var/run/sshd')...
class ssh_server(ShutItModule):
def is_installed(self, shutit): shutit.file_exists('/root/start_ssh_server.sh') def build(self, shutit): shutit.install('openssh-server') shutit.set_password(shutit.cfg[self.module_id]['password']) shutit.send('mkdir -p /var/run/sshd') shutit.send('chmod 700 /var/run/sshd') # Set up root bashrcs once #...
from shutit_module import ShutItModule class ssh_server(ShutItModule):
18
237
790
9
8
aidanhs/shutit
library/ssh_server/ssh_server.py
Python
ssh_server
ssh_server
3
55
3
4
9b77789389d10cf7ebe4667ac5a0370f2a29a91d
bigcode/the-stack
train
35e3be88739ca98558c9e656
train
function
def module(): return ssh_server( 'shutit.tk.ssh_server.ssh_server', 0.121, description='ssh server', depends=['shutit.tk.setup'] )
def module():
return ssh_server( 'shutit.tk.ssh_server.ssh_server', 0.121, description='ssh server', depends=['shutit.tk.setup'] )
(self, shutit): shutit.send('rm -f /root/start_ssh_server.sh') return True def get_config(self, shutit): shutit.get_config(self.module_id, 'password', 'changeme', hint='root password for the image') return True def module():
64
64
43
3
60
aidanhs/shutit
library/ssh_server/ssh_server.py
Python
module
module
58
63
58
58
6ca546b2cd9475882dcdf3db706a12e43bc335eb
bigcode/the-stack
train
ba4843526e85a2f073d19e23
train
class
class ExecuteOperator(BaseOperator): template_fields = ('table', 'parameters', 'path') @apply_defaults def __init__(self, sql, parameters=None, table=None, mode=None, data_source=None, path=None, format=None, csv_options=None, schema=None, max_bad_records=None, *args, **kwargs): super(Execute...
class ExecuteOperator(BaseOperator):
template_fields = ('table', 'parameters', 'path') @apply_defaults def __init__(self, sql, parameters=None, table=None, mode=None, data_source=None, path=None, format=None, csv_options=None, schema=None, max_bad_records=None, *args, **kwargs): super(ExecuteOperator, self).__init__(*args, **kwar...
7 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except # in compliance with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
159
159
533
6
152
freyrsae/pydatalab
google/datalab/contrib/bigquery/operators/_bq_execute_operator.py
Python
ExecuteOperator
ExecuteOperator
18
74
18
19
7660d60b36823b2541295ae38c312c509b36475d
bigcode/the-stack
train
35dbba470282b7df36c67be3
train
function
def generate_data(dimension = 2, classes = 2, max_cluster_size = 100, centroid_dispersion = 5, no_deformation = False, same_deformation = False, plot = False): # Setting the number of elements in each cluster... cardinals = np.random.randint(max_cluster_size - 1, size = classes) + 1 # (classes, ) N = np....
def generate_data(dimension = 2, classes = 2, max_cluster_size = 100, centroid_dispersion = 5, no_deformation = False, same_deformation = False, plot = False): # Setting the number of elements in each cluster...
cardinals = np.random.randint(max_cluster_size - 1, size = classes) + 1 # (classes, ) N = np.sum(cardinals) # Generating the dispersions of the clusters... dispersions = np.random.randn(classes) # (classes, ) # Generating the centroids... centroids = np.random.randn(classes, dimension).T ...
cos, sin)) * distorsions[0] # (2, 1, classes) msincos = np.vstack((sin * (-1), cos)) * distorsions[1] # (2, 1, classes) return np.hstack((cossin, msincos)) # (2, 2, classes) def generate_data(dimension = 2, classes = 2, max_cluster_size = 100, centroid_dispersion = 5, no_deformation = False, same_deformation ...
129
130
435
55
74
bserranoanton/Machine-learning
Fisher/fisher.py
Python
generate_data
generate_data
19
55
19
20
b8bc6cfddcd14edb95492110c44565a41474114b
bigcode/the-stack
train
e0b26595f6836487fc7919fe
train
function
def compute_cut(data, cardinals, w, m1, m2): N = np.sum(cardinals) p1 = cardinals[0] / N p2 = cardinals[1] / N data_proj = w.T.dot(data) m1_proj = w.T.dot(m1) m2_proj = w.T.dot(m2) sigma1_cuad = np.var(data_proj[:cardinals[0]]) sigma2_cuad = np.var(data_proj[cardinals[0]:]) ...
def compute_cut(data, cardinals, w, m1, m2):
N = np.sum(cardinals) p1 = cardinals[0] / N p2 = cardinals[1] / N data_proj = w.T.dot(data) m1_proj = w.T.dot(m1) m2_proj = w.T.dot(m2) sigma1_cuad = np.var(data_proj[:cardinals[0]]) sigma2_cuad = np.var(data_proj[cardinals[0]:]) sigma1 = np.sqrt(sigma1_cuad) sigma2 = np...
:cardinals[0]].mean(axis = 1) m2 = data[:, cardinals[0]:].mean(axis = 1) s1 = np.cov(data[:, :cardinals[0]]) s2 = np.cov(data[:, cardinals[0]:]) sw = s1 + s2 return np.linalg.solve(sw, m2 - m1) def compute_cut(data, cardinals, w, m1, m2):
99
99
332
16
83
bserranoanton/Machine-learning
Fisher/fisher.py
Python
compute_cut
compute_cut
65
83
65
65
89a433c58477844c90fcc6b00c8ac53c4e62dd1c
bigcode/the-stack
train
6644ec3a85d0c9da6ba2a208
train
function
def evaluate_line(a, b, c, x): return (-a * x - c) / b
def evaluate_line(a, b, c, x):
return (-a * x - c) / b
: return np.real(roots[1]) def derivative_evaluation(x, a, b, c): return 2 * a * x + b # ax + by + c=0 <=> y = (-ax - c) / b def evaluate_line(a, b, c, x):
64
64
23
11
52
bserranoanton/Machine-learning
Fisher/fisher.py
Python
evaluate_line
evaluate_line
89
90
89
89
a54fd4014a700bb145709a965c4b5702c8ec1a97
bigcode/the-stack
train
aafeb812ed2a148ae6b31a79
train
function
def derivative_evaluation(x, a, b, c): return 2 * a * x + b
def derivative_evaluation(x, a, b, c):
return 2 * a * x + b
= np.roots(np.array([a,b,c])) if derivative_evaluation(roots[0], a, b, c) >= 0: return np.real(roots[0]) else: return np.real(roots[1]) def derivative_evaluation(x, a, b, c):
64
64
23
12
52
bserranoanton/Machine-learning
Fisher/fisher.py
Python
derivative_evaluation
derivative_evaluation
85
86
85
85
c2301276e542e50d1cf3fe40c07fadf886027217
bigcode/the-stack
train
e2204063226b1694229d693e
train
function
def plot_cut(w, c, data, linestyle = None): a = np.min(data[0]) b = np.max(data[0]) plt.plot([a, b], [evaluate_line(w[0], w[1], c, a), evaluate_line(w[0], w[1], c, b)], linestyle = linestyle)
def plot_cut(w, c, data, linestyle = None):
a = np.min(data[0]) b = np.max(data[0]) plt.plot([a, b], [evaluate_line(w[0], w[1], c, a), evaluate_line(w[0], w[1], c, b)], linestyle = linestyle)
2 * a * x + b # ax + by + c=0 <=> y = (-ax - c) / b def evaluate_line(a, b, c, x): return (-a * x - c) / b def plot_cut(w, c, data, linestyle = None):
64
64
72
13
50
bserranoanton/Machine-learning
Fisher/fisher.py
Python
plot_cut
plot_cut
92
95
92
92
ed0f8dfa8886fed38f6818a5782d9acc45defe23
bigcode/the-stack
train
19c562a696a5df8184e55310
train
function
def generate_deformations(classes = 2, deformation_range = 1): distorsions = np.random.randn(2, classes) * deformation_range + 1 # (2, classes) angles = np.random.rand(classes) * np.pi # (classes, ) cos = np.cos(angles)[np.newaxis, np.newaxis, :] # (1, 1, classes) sin = np.sin(angles)[np.newaxis, np...
def generate_deformations(classes = 2, deformation_range = 1):
distorsions = np.random.randn(2, classes) * deformation_range + 1 # (2, classes) angles = np.random.rand(classes) * np.pi # (classes, ) cos = np.cos(angles)[np.newaxis, np.newaxis, :] # (1, 1, classes) sin = np.sin(angles)[np.newaxis, np.newaxis, :] # (1, 1, classes) cossin = np.vstack((cos, sin...
# Fisher linear discriminant # Álvaro García Tenorio, Belén Serrano Antón import numpy as np import matplotlib.pyplot as plt # Generates rotation + stretching matrixes (2, 2, classes) def generate_deformations(classes = 2, deformation_range = 1):
61
64
190
15
46
bserranoanton/Machine-learning
Fisher/fisher.py
Python
generate_deformations
generate_deformations
8
15
8
8
b34d4c8ad6754e65355932f73dd3b40a2c27d2c0
bigcode/the-stack
train
20b27992b609a9f1e41ed68f
train
function
def compute_projection(data, cardinals): m1 = data[:, :cardinals[0]].mean(axis = 1) m2 = data[:, cardinals[0]:].mean(axis = 1) s1 = np.cov(data[:, :cardinals[0]]) s2 = np.cov(data[:, cardinals[0]:]) sw = s1 + s2 return np.linalg.solve(sw, m2 - m1)
def compute_projection(data, cardinals):
m1 = data[:, :cardinals[0]].mean(axis = 1) m2 = data[:, cardinals[0]:].mean(axis = 1) s1 = np.cov(data[:, :cardinals[0]]) s2 = np.cov(data[:, cardinals[0]:]) sw = s1 + s2 return np.linalg.solve(sw, m2 - m1)
: previous + cardinals[k]] = distorsions[:,:,s].dot(data[:, previous : previous + cardinals[k]]) * dispersions[k] + centroids[:, k, np.newaxis] previous = previous + cardinals[k] return data, cardinals def compute_projection(data, cardinals):
64
64
97
8
55
bserranoanton/Machine-learning
Fisher/fisher.py
Python
compute_projection
compute_projection
57
63
57
57
39a9b0eab9cb12eda6322a6fce6e803f546864dd
bigcode/the-stack
train
f520c6bcf0fd268da836fdf2
train
class
class DistributedToonHallInteriorAI(DistributedToonInteriorAI): def __init__(self, block, air, zoneId, building): DistributedToonInteriorAI.__init__(self, block, air, zoneId, building) self.accept('ToonEnteredZone', self.logToonEntered) self.accept('ToonLeftZone', self.logToonLeft) def...
class DistributedToonHallInteriorAI(DistributedToonInteriorAI):
def __init__(self, block, air, zoneId, building): DistributedToonInteriorAI.__init__(self, block, air, zoneId, building) self.accept('ToonEnteredZone', self.logToonEntered) self.accept('ToonLeftZone', self.logToonLeft) def logToonEntered(self, avId, zoneId): result = self.getCur...
from DistributedToonInteriorAI import * from toontown.toonbase import ToontownGlobals class DistributedToonHallInteriorAI(DistributedToonInteriorAI):
34
132
443
14
19
AnonymousDeveloper65535/open-toontown
toontown/building/DistributedToonHallInteriorAI.py
Python
DistributedToonHallInteriorAI
DistributedToonHallInteriorAI
4
44
4
5
26935baac71b59d30e0e0bfc59dceddf994a8d29
bigcode/the-stack
train
d075189766ff424af55552e3
train
class
class UtilitiesTest(unittest.TestCase): def test_print_args(self): """Datastacks: verify that we format args correctly.""" from natcap.invest.datastack import format_args_dict, __version__ args_dict = { 'some_arg': [1, 2, 3, 4], 'foo': 'bar', } args_...
class UtilitiesTest(unittest.TestCase):
def test_print_args(self): """Datastacks: verify that we format args correctly.""" from natcap.invest.datastack import format_args_dict, __version__ args_dict = { 'some_arg': [1, 2, 3, 4], 'foo': 'bar', } args_string = format_args_dict(args_dict=args...
'data', 'filepath1.txt'), 'linux_path': os.path.join(extraction_path, 'data', 'filepath2.txt'), } self.maxDiff = None # show whole exception on failure self.assertEqual(extracted_args, expected_args) ...
64
64
153
7
57
tomsaleeba/invest
tests/test_datastack.py
Python
UtilitiesTest
UtilitiesTest
665
681
665
665
3b9064852fad7daef2ad901a7d2087295e95050d
bigcode/the-stack
train
6d3ba4802da055e11a96e0bf
train
class
class DatastacksTest(unittest.TestCase): def setUp(self): self.workspace = tempfile.mkdtemp() def tearDown(self): shutil.rmtree(self.workspace) def test_collect_simple_parameters(self): from natcap.invest import datastack params = { 'a': 1, 'b': 'hel...
class DatastacksTest(unittest.TestCase):
def setUp(self): self.workspace = tempfile.mkdtemp() def tearDown(self): shutil.rmtree(self.workspace) def test_collect_simple_parameters(self): from natcap.invest import datastack params = { 'a': 1, 'b': 'hello there', 'c': 'plain bytest...
import os import unittest import tempfile import shutil import json import tarfile import textwrap import pygeoprocessing.testing from osgeo import ogr DATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'data', 'invest-test-data', 'data_stack') class DatastacksTest(unitte...
77
256
5,575
9
68
tomsaleeba/invest
tests/test_datastack.py
Python
DatastacksTest
DatastacksTest
15
662
15
15
dbfaa4dfdd01c0bcea7dfcffc192f6ac81c9ca62
bigcode/the-stack
train
3896d11983ab582ad6082c86
train
function
def bundle_dependencies(): with open('package.json') as f: package = json.load(f) package['bundledDependencies'] = list(package['dependencies'].keys()) with open('package.json', 'w') as f: json.dump(package, f)
def bundle_dependencies():
with open('package.json') as f: package = json.load(f) package['bundledDependencies'] = list(package['dependencies'].keys()) with open('package.json', 'w') as f: json.dump(package, f)
import sys import tarfile import tempfile def is_bundled(tar): # No entries for directories, so scan for a matching prefix. for entry in tar.getmembers(): if entry.name.startswith('package/node_modules/'): return True return False def bundle_dependencies():
64
64
56
4
59
19317362/gerrit
tools/js/npm_pack.py
Python
bundle_dependencies
bundle_dependencies
42
47
42
42
ff51ab24247ba53c8928e7350b0a888157beb542
bigcode/the-stack
train
6d558f0fa32e32da5db359fe
train
function
def is_bundled(tar): # No entries for directories, so scan for a matching prefix. for entry in tar.getmembers(): if entry.name.startswith('package/node_modules/'): return True return False
def is_bundled(tar): # No entries for directories, so scan for a matching prefix.
for entry in tar.getmembers(): if entry.name.startswith('package/node_modules/'): return True return False
IT" in WORKSPACE). """ from __future__ import print_function import atexit import json import os import shutil import subprocess import sys import tarfile import tempfile def is_bundled(tar): # No entries for directories, so scan for a matching prefix.
64
64
49
22
41
19317362/gerrit
tools/js/npm_pack.py
Python
is_bundled
is_bundled
34
39
34
35
219cd9b5eed8632144487c994fd4bbe796ba6ffa
bigcode/the-stack
train
35e82569367f34d26dfce3f8
train
function
def main(args): if len(args) != 2: print('Usage: %s <package> <version>' % sys.argv[0], file=sys.stderr) return 1 name, version = args filename = '%s-%s.tgz' % (name, version) url = 'http://registry.npmjs.org/%s/-/%s' % (name, filename) tmpdir = tempfile.mkdtemp(); tgz = os.path.join(tmpdir, filen...
def main(args):
if len(args) != 2: print('Usage: %s <package> <version>' % sys.argv[0], file=sys.stderr) return 1 name, version = args filename = '%s-%s.tgz' % (name, version) url = 'http://registry.npmjs.org/%s/-/%s' % (name, filename) tmpdir = tempfile.mkdtemp(); tgz = os.path.join(tmpdir, filename) atexit.re...
.name.startswith('package/node_modules/'): return True return False def bundle_dependencies(): with open('package.json') as f: package = json.load(f) package['bundledDependencies'] = list(package['dependencies'].keys()) with open('package.json', 'w') as f: json.dump(package, f) def main(args):
76
76
255
4
72
19317362/gerrit
tools/js/npm_pack.py
Python
main
main
50
76
50
50
e41ee5f55b5b9d5a5442d07a437ed29975fc28d6
bigcode/the-stack
train
594a6dc88112d14c71ea6785
train
function
def main(cozmo : Robot.Robot): cozmo.say("Hello World")
def main(cozmo : Robot.Robot):
cozmo.say("Hello World")
import CozmOSU as Robot robot = Robot.Robot() def main(cozmo : Robot.Robot):
24
64
18
10
14
OSU-cozmo/OSU-Cozmo-Library
tests/structure-testing.py
Python
main
main
5
7
5
6
1fad406b45aa7a1b750c527dadba0067bf37894e
bigcode/the-stack
train
7ab2b7990fc2af365f3aaeb9
train
function
async def test_heartbeat_do_not_unload(hass): """Test that the heartbeat is not deactivated until the last config entry is removed.""" device_a = get_device("Office") device_b = get_device("Bedroom") mock_setup = await device_a.setup_entry(hass) await device_b.setup_entry(hass) await hass.async...
async def test_heartbeat_do_not_unload(hass):
"""Test that the heartbeat is not deactivated until the last config entry is removed.""" device_a = get_device("Office") device_b = get_device("Bedroom") mock_setup = await device_a.setup_entry(hass) await device_b.setup_entry(hass) await hass.async_block_till_done() await hass.config_entr...
_block_till_done() with patch(DEVICE_PING) as mock_ping: async_fire_time_changed( hass, dt.utcnow() + BroadlinkHeartbeat.HEARTBEAT_INTERVAL ) assert mock_ping.call_count == 0 async def test_heartbeat_do_not_unload(hass):
64
64
168
12
51
MrDelik/core
tests/components/broadlink/test_heartbeat.py
Python
test_heartbeat_do_not_unload
test_heartbeat_do_not_unload
89
108
89
89
1fed5d1170e9d754fb008d670a04b022cca888c6
bigcode/the-stack
train
7669de56aa512fde9a2d2472
train
function
async def test_heartbeat_do_not_trigger_before_time(hass): """Test that the heartbeat is not triggered before the time.""" device = get_device("Office") await device.setup_entry(hass) await hass.async_block_till_done() with patch(DEVICE_PING) as mock_ping: async_fire_time_changed( ...
async def test_heartbeat_do_not_trigger_before_time(hass):
"""Test that the heartbeat is not triggered before the time.""" device = get_device("Office") await device.setup_entry(hass) await hass.async_block_till_done() with patch(DEVICE_PING) as mock_ping: async_fire_time_changed( hass, dt.utcnow() + BroadlinkHeartbeat.HEAR...
_changed( hass, dt.utcnow() + BroadlinkHeartbeat.HEARTBEAT_INTERVAL ) await hass.async_block_till_done() assert mock_ping.call_count == 1 assert mock_ping.call_args == call(device.host) async def test_heartbeat_do_not_trigger_before_time(hass):
64
64
111
13
51
MrDelik/core
tests/components/broadlink/test_heartbeat.py
Python
test_heartbeat_do_not_trigger_before_time
test_heartbeat_do_not_trigger_before_time
54
68
54
54
3d45f84f8f57b865f71d47709149b29072843500
bigcode/the-stack
train
d9becd98e9f4090ea5eb2da9
train
function
async def test_heartbeat_ignore_oserror(hass, caplog): """Test that an OSError is ignored.""" device = get_device("Office") with patch(DEVICE_PING, side_effect=OSError()): await device.setup_entry(hass) await hass.async_block_till_done() assert "Failed to send heartbeat to" in caplog.t...
async def test_heartbeat_ignore_oserror(hass, caplog):
"""Test that an OSError is ignored.""" device = get_device("Office") with patch(DEVICE_PING, side_effect=OSError()): await device.setup_entry(hass) await hass.async_block_till_done() assert "Failed to send heartbeat to" in caplog.text
with patch(DEVICE_PING) as mock_ping: await device.setup_entry(hass) await hass.async_block_till_done() assert mock_ping.call_count == 1 assert mock_ping.call_args == call(device.host) async def test_heartbeat_ignore_oserror(hass, caplog):
64
64
77
14
50
MrDelik/core
tests/components/broadlink/test_heartbeat.py
Python
test_heartbeat_ignore_oserror
test_heartbeat_ignore_oserror
26
34
26
26
2a7dce9228ce23551257f681b467fcce53118c4e
bigcode/the-stack
train
7eae4b31aba7cb987a98701d
train
function
async def test_heartbeat_trigger_startup(hass): """Test that the heartbeat is initialized with the first config entry.""" device = get_device("Office") with patch(DEVICE_PING) as mock_ping: await device.setup_entry(hass) await hass.async_block_till_done() assert mock_ping.call_count ==...
async def test_heartbeat_trigger_startup(hass):
"""Test that the heartbeat is initialized with the first config entry.""" device = get_device("Office") with patch(DEVICE_PING) as mock_ping: await device.setup_entry(hass) await hass.async_block_till_done() assert mock_ping.call_count == 1 assert mock_ping.call_args == call(device...
homeassistant.components.broadlink.heartbeat import BroadlinkHeartbeat from homeassistant.util import dt from . import get_device from tests.common import async_fire_time_changed DEVICE_PING = "homeassistant.components.broadlink.heartbeat.blk.ping" async def test_heartbeat_trigger_startup(hass):
64
64
83
11
53
MrDelik/core
tests/components/broadlink/test_heartbeat.py
Python
test_heartbeat_trigger_startup
test_heartbeat_trigger_startup
14
23
14
14
345da46e5d9bb705afc1a4d70deba96e27bbf694
bigcode/the-stack
train
ee6faa4f467aa00dc6bbf913
train
function
async def test_heartbeat_trigger_right_time(hass): """Test that the heartbeat is triggered at the right time.""" device = get_device("Office") await device.setup_entry(hass) await hass.async_block_till_done() with patch(DEVICE_PING) as mock_ping: async_fire_time_changed( hass, ...
async def test_heartbeat_trigger_right_time(hass):
"""Test that the heartbeat is triggered at the right time.""" device = get_device("Office") await device.setup_entry(hass) await hass.async_block_till_done() with patch(DEVICE_PING) as mock_ping: async_fire_time_changed( hass, dt.utcnow() + BroadlinkHeartbeat.HEARTBEAT_INTERVAL...
device = get_device("Office") with patch(DEVICE_PING, side_effect=OSError()): await device.setup_entry(hass) await hass.async_block_till_done() assert "Failed to send heartbeat to" in caplog.text async def test_heartbeat_trigger_right_time(hass):
64
64
116
11
52
MrDelik/core
tests/components/broadlink/test_heartbeat.py
Python
test_heartbeat_trigger_right_time
test_heartbeat_trigger_right_time
37
51
37
37
53ea6b69276b6c9c711dee3427055d6bd2de3f39
bigcode/the-stack
train
c945e197612f3c330a88e3d9
train
function
async def test_heartbeat_unload(hass): """Test that the heartbeat is deactivated when the last config entry is removed.""" device = get_device("Office") mock_setup = await device.setup_entry(hass) await hass.async_block_till_done() await hass.config_entries.async_remove(mock_setup.entry.entry_id) ...
async def test_heartbeat_unload(hass):
"""Test that the heartbeat is deactivated when the last config entry is removed.""" device = get_device("Office") mock_setup = await device.setup_entry(hass) await hass.async_block_till_done() await hass.config_entries.async_remove(mock_setup.entry.entry_id) await hass.async_block_till_done() ...
ING) as mock_ping: async_fire_time_changed( hass, dt.utcnow() + BroadlinkHeartbeat.HEARTBEAT_INTERVAL // 2, ) await hass.async_block_till_done() assert mock_ping.call_count == 0 async def test_heartbeat_unload(hass):
64
64
124
10
53
MrDelik/core
tests/components/broadlink/test_heartbeat.py
Python
test_heartbeat_unload
test_heartbeat_unload
71
86
71
71
5b20ecb0597c8041d61cb5e7108a3a3bfac03d9c
bigcode/the-stack
train
b57d444e58e0078ea6c8d11f
train
class
class V1Pod(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. attr...
class V1Pod(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 The version of the OpenAPI document: release-1.21 Generated by: https://openapi-generator.tech """ import pprint import re # noqa: F401 import si...
96
256
1,569
6
89
henrywu2019/python
kubernetes/client/models/v1_pod.py
Python
V1Pod
V1Pod
21
228
21
21
c2259b6d72abf3b80cdd4de2c188bb170bcbdb25
bigcode/the-stack
train
78ed54e00d53bfdaa4422441
train
function
def get_22(pitch, pitch1): on = midi.NoteOnEvent(tick=0, velocity=85, pitch=pitch) off = midi.NoteOffEvent(tick=200, pitch=pitch) track.extend([on, off]) on = midi.NoteOnEvent(tick=0, velocity=80, pitch=pitch1) off = midi.NoteOffEvent(tick=200, pitch=pitch1) track.extend([on, off])
def get_22(pitch, pitch1):
on = midi.NoteOnEvent(tick=0, velocity=85, pitch=pitch) off = midi.NoteOffEvent(tick=200, pitch=pitch) track.extend([on, off]) on = midi.NoteOnEvent(tick=0, velocity=80, pitch=pitch1) off = midi.NoteOffEvent(tick=200, pitch=pitch1) track.extend([on, off])
.append(track) def get_1(pitch): on = midi.NoteOnEvent(tick=0, velocity=100, pitch=pitch) off = midi.NoteOffEvent(tick=400, pitch=pitch) track.extend([on, off]) def get_22(pitch, pitch1):
64
64
100
10
54
shiyeli/jupyter_notebook
library_learn/midi_gen.py
Python
get_22
get_22
20
26
20
20
4f0f54fb454d577965b72b2d1d38349c58192a94
bigcode/the-stack
train
4a961f50231ae8a62aea67a7
train
function
def get_13(pitch, pitch1): on = midi.NoteOnEvent(tick=0, velocity=85, pitch=pitch) off = midi.NoteOffEvent(tick=100, pitch=pitch1) track.extend([on, off]) on = midi.NoteOnEvent(tick=0, velocity=90, pitch=pitch1) off = midi.NoteOffEvent(tick=300, pitch=pitch) track.extend([on, off])
def get_13(pitch, pitch1):
on = midi.NoteOnEvent(tick=0, velocity=85, pitch=pitch) off = midi.NoteOffEvent(tick=100, pitch=pitch1) track.extend([on, off]) on = midi.NoteOnEvent(tick=0, velocity=90, pitch=pitch1) off = midi.NoteOffEvent(tick=300, pitch=pitch) track.extend([on, off])
track.extend([on, off]) on = midi.NoteOnEvent(tick=0, velocity=85, pitch=pitch1) off = midi.NoteOffEvent(tick=100, pitch=pitch1) track.extend([on, off]) def get_13(pitch, pitch1):
64
64
100
10
54
shiyeli/jupyter_notebook
library_learn/midi_gen.py
Python
get_13
get_13
60
66
60
60
c4ba12c9599619bc1de375e3d9b1cd5f9768e46d
bigcode/the-stack
train
a07d3c71499cd50d001c623e
train
function
def get_31(pitch, pitch1): on = midi.NoteOnEvent(tick=0, velocity=90, pitch=pitch) off = midi.NoteOffEvent(tick=300, pitch=pitch) track.extend([on, off]) on = midi.NoteOnEvent(tick=0, velocity=85, pitch=pitch1) off = midi.NoteOffEvent(tick=100, pitch=pitch1) track.extend([on, off])
def get_31(pitch, pitch1):
on = midi.NoteOnEvent(tick=0, velocity=90, pitch=pitch) off = midi.NoteOffEvent(tick=300, pitch=pitch) track.extend([on, off]) on = midi.NoteOnEvent(tick=0, velocity=85, pitch=pitch1) off = midi.NoteOffEvent(tick=100, pitch=pitch1) track.extend([on, off])
track.extend([on, off]) on = midi.NoteOnEvent(tick=0, velocity=80, pitch=pitch2) off = midi.NoteOffEvent(tick=200, pitch=pitch2) track.extend([on, off]) def get_31(pitch, pitch1):
64
64
100
10
54
shiyeli/jupyter_notebook
library_learn/midi_gen.py
Python
get_31
get_31
52
58
52
52
c435709035cc4141e8d30442893da4d7739fd05d
bigcode/the-stack
train