id_within_dataset
int64
1
55.5k
snippet
stringlengths
19
14.2k
tokens
listlengths
6
1.63k
nl
stringlengths
6
352
split_within_dataset
stringclasses
1 value
is_duplicated
bool
2 classes
40,536
def parallel_beta_diversity_process_run_results_f(f): for line in f: fields = line.strip().split(' DCTB ') dm_components = fields[:(-1)] output_fp = fields[(-1)] dm = assemble_distance_matrix(map(open, dm_components)) output_f = open(output_fp, 'w') output_f.write(dm) output_f.close() return True
[ "def", "parallel_beta_diversity_process_run_results_f", "(", "f", ")", ":", "for", "line", "in", "f", ":", "fields", "=", "line", ".", "strip", "(", ")", ".", "split", "(", "' DCTB '", ")", "dm_components", "=", "fields", "[", ":", "(", "-", "1", ")", ...
handles re-assembling of a distance matrix from component vectors .
train
false
40,537
def get_chost(): return get_var('CHOST')
[ "def", "get_chost", "(", ")", ":", "return", "get_var", "(", "'CHOST'", ")" ]
get the value of chost variable in the make .
train
false
40,538
def member(): return s3_rest_controller()
[ "def", "member", "(", ")", ":", "return", "s3_rest_controller", "(", ")" ]
restful crud controller .
train
false
40,539
def objectify_predicate(selector_func): return type(selector_func.__name__, (Predicate,), {'__doc__': selector_func.__doc__, '__call__': (lambda self, *a, **kw: selector_func(*a, **kw))})
[ "def", "objectify_predicate", "(", "selector_func", ")", ":", "return", "type", "(", "selector_func", ".", "__name__", ",", "(", "Predicate", ",", ")", ",", "{", "'__doc__'", ":", "selector_func", ".", "__doc__", ",", "'__call__'", ":", "(", "lambda", "self"...
most of the time .
train
false
40,540
def ftp_put_command(connection, local_path, remote_dir): try: ftp = ftplib.FTP(host=connection.host, user=connection.username, passwd=connection.password) ftp.cwd(remote_dir) name = os.path.split(local_path)[1] f = open(local_path, 'rb') ftp.storbinary(('STOR ' + name), f) f.close() ftp.close() except E...
[ "def", "ftp_put_command", "(", "connection", ",", "local_path", ",", "remote_dir", ")", ":", "try", ":", "ftp", "=", "ftplib", ".", "FTP", "(", "host", "=", "connection", ".", "host", ",", "user", "=", "connection", ".", "username", ",", "passwd", "=", ...
method to transfer a file via ftp .
train
false
40,541
def _make_stim_channel(trigger_chs, slope, threshold, stim_code, trigger_values): if (slope == '+'): trig_chs_bin = (trigger_chs > threshold) elif (slope == '-'): trig_chs_bin = (trigger_chs < threshold) else: raise ValueError("slope needs to be '+' or '-'") if (stim_code == 'binary'): trigger_values = (2 *...
[ "def", "_make_stim_channel", "(", "trigger_chs", ",", "slope", ",", "threshold", ",", "stim_code", ",", "trigger_values", ")", ":", "if", "(", "slope", "==", "'+'", ")", ":", "trig_chs_bin", "=", "(", "trigger_chs", ">", "threshold", ")", "elif", "(", "slo...
create synthetic stim channel from multiple trigger channels .
train
false
40,542
@_np.deprecate(message='scipy.constants.F2K is deprecated in scipy 0.18.0. Use scipy.constants.convert_temperature instead. Note that the new function has a different signature.') def F2K(F): return C2K(F2C(_np.asanyarray(F)))
[ "@", "_np", ".", "deprecate", "(", "message", "=", "'scipy.constants.F2K is deprecated in scipy 0.18.0. Use scipy.constants.convert_temperature instead. Note that the new function has a different signature.'", ")", "def", "F2K", "(", "F", ")", ":", "return", "C2K", "(", "F2C", ...
convert fahrenheit to kelvin parameters f : array_like fahrenheit temperature(s) to be converted .
train
false
40,543
def get_repository(client, repository=''): try: return client.snapshot.get_repository(repository=repository) except (elasticsearch.TransportError, elasticsearch.NotFoundError): logger.error('Repository {0} not found.'.format(repository)) return False
[ "def", "get_repository", "(", "client", ",", "repository", "=", "''", ")", ":", "try", ":", "return", "client", ".", "snapshot", ".", "get_repository", "(", "repository", "=", "repository", ")", "except", "(", "elasticsearch", ".", "TransportError", ",", "el...
return configuration information for the indicated repository .
train
false
40,544
def test_validate_faulty_wcs(): h = fits.Header() h[u'RADESYSA'] = u'ICRS' h[u'PV2_1'] = 1.0 hdu = fits.PrimaryHDU([[0]], header=h) hdulist = fits.HDUList([hdu]) wcs.validate(hdulist)
[ "def", "test_validate_faulty_wcs", "(", ")", ":", "h", "=", "fits", ".", "Header", "(", ")", "h", "[", "u'RADESYSA'", "]", "=", "u'ICRS'", "h", "[", "u'PV2_1'", "]", "=", "1.0", "hdu", "=", "fits", ".", "PrimaryHDU", "(", "[", "[", "0", "]", "]", ...
from github issue #2053 .
train
false
40,545
def register_as(name, formatter_class): if (not isinstance(name, six.string_types)): warnings.warn(('Use parameter ordering: name, formatter_class (for: %s)' % formatter_class)) _formatter_class = name name = formatter_class formatter_class = _formatter_class if isinstance(formatter_class, six.string_types): ...
[ "def", "register_as", "(", "name", ",", "formatter_class", ")", ":", "if", "(", "not", "isinstance", "(", "name", ",", "six", ".", "string_types", ")", ")", ":", "warnings", ".", "warn", "(", "(", "'Use parameter ordering: name, formatter_class (for: %s)'", "%",...
register formatter class with given name .
train
false
40,546
def bytes2str(bs): if (isinstance(bs, type('')) and (PY_MAJOR_VERSION > 2)): return bs.decode('latin1') else: return bs
[ "def", "bytes2str", "(", "bs", ")", ":", "if", "(", "isinstance", "(", "bs", ",", "type", "(", "''", ")", ")", "and", "(", "PY_MAJOR_VERSION", ">", "2", ")", ")", ":", "return", "bs", ".", "decode", "(", "'latin1'", ")", "else", ":", "return", "b...
for cross compatibility between python 2 and python 3 strings .
train
true
40,547
def review_request_published_cb(sender, user, review_request, trivial, changedesc, **kwargs): siteconfig = SiteConfiguration.objects.get_current() if (siteconfig.get(u'mail_send_review_mail') and (not trivial)): mail_review_request(review_request, user, changedesc)
[ "def", "review_request_published_cb", "(", "sender", ",", "user", ",", "review_request", ",", "trivial", ",", "changedesc", ",", "**", "kwargs", ")", ":", "siteconfig", "=", "SiteConfiguration", ".", "objects", ".", "get_current", "(", ")", "if", "(", "sitecon...
send e-mail when a review request is published .
train
false
40,548
def drain(file_like, read_size, timeout): while True: with ChunkReadTimeout(timeout): chunk = file_like.read(read_size) if (not chunk): break
[ "def", "drain", "(", "file_like", ",", "read_size", ",", "timeout", ")", ":", "while", "True", ":", "with", "ChunkReadTimeout", "(", "timeout", ")", ":", "chunk", "=", "file_like", ".", "read", "(", "read_size", ")", "if", "(", "not", "chunk", ")", ":"...
read and discard any bytes from file_like .
train
false
40,549
def CountWordErrors(ocr_text, truth_text): return CountErrors(ocr_text.split(), truth_text.split())
[ "def", "CountWordErrors", "(", "ocr_text", ",", "truth_text", ")", ":", "return", "CountErrors", "(", "ocr_text", ".", "split", "(", ")", ",", "truth_text", ".", "split", "(", ")", ")" ]
counts the word drop and add errors as a bag of words .
train
false
40,550
def key2param(key): result = [] key = list(key) if (not key[0].isalpha()): result.append('x') for c in key: if c.isalnum(): result.append(c) else: result.append('_') return ''.join(result)
[ "def", "key2param", "(", "key", ")", ":", "result", "=", "[", "]", "key", "=", "list", "(", "key", ")", "if", "(", "not", "key", "[", "0", "]", ".", "isalpha", "(", ")", ")", ":", "result", ".", "append", "(", "'x'", ")", "for", "c", "in", ...
converts key names into parameter names .
train
false
40,551
def hexii(s, width=16, skip=True): return hexdump(s, width, skip, True)
[ "def", "hexii", "(", "s", ",", "width", "=", "16", ",", "skip", "=", "True", ")", ":", "return", "hexdump", "(", "s", ",", "width", ",", "skip", ",", "True", ")" ]
hexii -> str return a hexii-dump of a string .
train
false
40,552
def long_path(path): if (sabnzbd.WIN32 and path and (not path.startswith(u'\\\\?\\'))): if path.startswith('\\\\'): path = path.replace(u'\\\\', u'\\\\?\\UNC\\', 1) else: path = (u'\\\\?\\' + path) return path
[ "def", "long_path", "(", "path", ")", ":", "if", "(", "sabnzbd", ".", "WIN32", "and", "path", "and", "(", "not", "path", ".", "startswith", "(", "u'\\\\\\\\?\\\\'", ")", ")", ")", ":", "if", "path", ".", "startswith", "(", "'\\\\\\\\'", ")", ":", "pa...
for windows .
train
false
40,556
def process_chain_both(callbacks, errbacks, input, *a, **kw): d = defer.Deferred() for (cb, eb) in zip(callbacks, errbacks): d.addCallbacks(cb, eb, callbackArgs=a, callbackKeywords=kw, errbackArgs=a, errbackKeywords=kw) if isinstance(input, failure.Failure): d.errback(input) else: d.callback(input) return d
[ "def", "process_chain_both", "(", "callbacks", ",", "errbacks", ",", "input", ",", "*", "a", ",", "**", "kw", ")", ":", "d", "=", "defer", ".", "Deferred", "(", ")", "for", "(", "cb", ",", "eb", ")", "in", "zip", "(", "callbacks", ",", "errbacks", ...
return a deferred built by chaining the given callbacks and errbacks .
train
false
40,557
def md(): return Mde2mdConverter()
[ "def", "md", "(", ")", ":", "return", "Mde2mdConverter", "(", ")" ]
this makes a converter from markdown-extra to markdown .
train
false
40,558
def getCurrentThreadData(): global ThreadData return ThreadData
[ "def", "getCurrentThreadData", "(", ")", ":", "global", "ThreadData", "return", "ThreadData" ]
returns current threads local data .
train
false
40,559
def get_with_url(url): try: params = {'url': url, 'client_id': api_key} request = requests.get(API_BASE.format('resolve'), params=params) request.raise_for_status() except (requests.exceptions.HTTPError, requests.exceptions.ConnectionError) as e: raise APIError('{}'.format(e)) json = request.json() if (not ...
[ "def", "get_with_url", "(", "url", ")", ":", "try", ":", "params", "=", "{", "'url'", ":", "url", ",", "'client_id'", ":", "api_key", "}", "request", "=", "requests", ".", "get", "(", "API_BASE", ".", "format", "(", "'resolve'", ")", ",", "params", "...
takes a soundcloud url and returns an item .
train
false
40,560
def names2dnsrepr(x): if (type(x) is str): if (x and (x[(-1)] == '\x00')): return x x = [x] res = [] for n in x: termin = '\x00' if (n.count('.') == 0): termin += '\x00' n = (''.join(map((lambda y: (chr(len(y)) + y)), n.split('.'))) + termin) res.append(n) return ''.join(res)
[ "def", "names2dnsrepr", "(", "x", ")", ":", "if", "(", "type", "(", "x", ")", "is", "str", ")", ":", "if", "(", "x", "and", "(", "x", "[", "(", "-", "1", ")", "]", "==", "'\\x00'", ")", ")", ":", "return", "x", "x", "=", "[", "x", "]", ...
take as input a list of dns names or a single dns name and encode it in dns format if a string that is already a dns name in dns format is passed .
train
false
40,563
def print_data_keys(data, item=None): path = (displayable_path(item.path) if item else None) formatted = [] for (key, value) in data.items(): formatted.append(key) if (len(formatted) == 0): return line_format = u'{0}{{0}}'.format((u' ' * 4)) if path: ui.print_(displayable_path(path)) for field in sorted(fo...
[ "def", "print_data_keys", "(", "data", ",", "item", "=", "None", ")", ":", "path", "=", "(", "displayable_path", "(", "item", ".", "path", ")", "if", "item", "else", "None", ")", "formatted", "=", "[", "]", "for", "(", "key", ",", "value", ")", "in...
print only the keys for an item .
train
false
40,566
def from_url(url, db=None, **kwargs): from redis.client import Redis return Redis.from_url(url, db, **kwargs)
[ "def", "from_url", "(", "url", ",", "db", "=", "None", ",", "**", "kwargs", ")", ":", "from", "redis", ".", "client", "import", "Redis", "return", "Redis", ".", "from_url", "(", "url", ",", "db", ",", "**", "kwargs", ")" ]
returns an active redis client generated from the given database url .
train
true
40,567
@docstring.dedent_interpd def angle_spectrum(x, Fs=None, window=None, pad_to=None, sides=None): return _single_spectrum_helper(x=x, Fs=Fs, window=window, pad_to=pad_to, sides=sides, mode=u'angle')
[ "@", "docstring", ".", "dedent_interpd", "def", "angle_spectrum", "(", "x", ",", "Fs", "=", "None", ",", "window", "=", "None", ",", "pad_to", "=", "None", ",", "sides", "=", "None", ")", ":", "return", "_single_spectrum_helper", "(", "x", "=", "x", ",...
compute the angle of the frequency spectrum of *x* .
train
false
40,568
def partition_list(): return ceph_cfg.partition_list()
[ "def", "partition_list", "(", ")", ":", "return", "ceph_cfg", ".", "partition_list", "(", ")" ]
list partitions by disk cli example: .
train
false
40,570
def _add_attribute(cls, key, value): if ('__mapper__' in cls.__dict__): if isinstance(value, Column): _undefer_column_name(key, value) cls.__table__.append_column(value) cls.__mapper__.add_property(key, value) elif isinstance(value, ColumnProperty): for col in value.columns: if (isinstance(col, Col...
[ "def", "_add_attribute", "(", "cls", ",", "key", ",", "value", ")", ":", "if", "(", "'__mapper__'", "in", "cls", ".", "__dict__", ")", ":", "if", "isinstance", "(", "value", ",", "Column", ")", ":", "_undefer_column_name", "(", "key", ",", "value", ")"...
add an attribute to an existing declarative class .
train
false
40,572
def describe_file_handle(fthing): if is_block(fthing): return u'block device' else: return fthing.name
[ "def", "describe_file_handle", "(", "fthing", ")", ":", "if", "is_block", "(", "fthing", ")", ":", "return", "u'block device'", "else", ":", "return", "fthing", ".", "name" ]
return the name of file or a description .
train
false
40,573
def is_neutron(): return CONF.use_neutron
[ "def", "is_neutron", "(", ")", ":", "return", "CONF", ".", "use_neutron" ]
does this configuration mean were neutron .
train
false
40,574
def is_naive(value): return (value.utcoffset() is None)
[ "def", "is_naive", "(", "value", ")", ":", "return", "(", "value", ".", "utcoffset", "(", ")", "is", "None", ")" ]
determines if a given datetime .
train
false
40,575
def _validate_numa_nodes(nodes): if ((nodes is not None) and ((not strutils.is_int_like(nodes)) or (int(nodes) < 1))): raise exception.InvalidNUMANodesNumber(nodes=nodes)
[ "def", "_validate_numa_nodes", "(", "nodes", ")", ":", "if", "(", "(", "nodes", "is", "not", "None", ")", "and", "(", "(", "not", "strutils", ".", "is_int_like", "(", "nodes", ")", ")", "or", "(", "int", "(", "nodes", ")", "<", "1", ")", ")", ")"...
validate numa nodes number .
train
false
40,577
def on_parent_exit(signame): def noop(): pass try: libc = cdll['libc.so.6'] except OSError: return noop try: prctl = libc.prctl except AttributeError: return noop signum = getattr(signal, signame) def set_parent_exit_signal(): result = prctl(PR_SET_PDEATHSIG, signum) if (result != 0): raise Exce...
[ "def", "on_parent_exit", "(", "signame", ")", ":", "def", "noop", "(", ")", ":", "pass", "try", ":", "libc", "=", "cdll", "[", "'libc.so.6'", "]", "except", "OSError", ":", "return", "noop", "try", ":", "prctl", "=", "libc", ".", "prctl", "except", "...
return a function to be run in a child process which will trigger signame to be sent when the parent process dies .
train
false
40,578
def fixSetGroupID(childPath): if ((os.name == u'nt') or (os.name == u'ce')): return parentPath = os.path.dirname(childPath) parentStat = os.stat(parentPath) parentMode = stat.S_IMODE(parentStat[stat.ST_MODE]) childPath = os.path.join(parentPath, os.path.basename(childPath)) if (parentMode & stat.S_ISGID): par...
[ "def", "fixSetGroupID", "(", "childPath", ")", ":", "if", "(", "(", "os", ".", "name", "==", "u'nt'", ")", "or", "(", "os", ".", "name", "==", "u'ce'", ")", ")", ":", "return", "parentPath", "=", "os", ".", "path", ".", "dirname", "(", "childPath",...
inherid sgid from parent .
train
false
40,579
def _try_get_string(dev, index, langid=None, default_str_i0='', default_access_error='Error Accessing String'): if (index == 0): string = default_str_i0 else: try: if (langid is None): string = util.get_string(dev, index) else: string = util.get_string(dev, index, langid) except: string = defau...
[ "def", "_try_get_string", "(", "dev", ",", "index", ",", "langid", "=", "None", ",", "default_str_i0", "=", "''", ",", "default_access_error", "=", "'Error Accessing String'", ")", ":", "if", "(", "index", "==", "0", ")", ":", "string", "=", "default_str_i0"...
try to get a string .
train
true
40,580
@contextlib.contextmanager def task_logging(task): old_task = getattr(local_context, u'task', u'') local_context.task = task try: (yield) finally: local_context.task = old_task
[ "@", "contextlib", ".", "contextmanager", "def", "task_logging", "(", "task", ")", ":", "old_task", "=", "getattr", "(", "local_context", ",", "u'task'", ",", "u''", ")", "local_context", ".", "task", "=", "task", "try", ":", "(", "yield", ")", "finally", ...
context manager which adds task information to log messages .
train
false
40,582
def init_compare(): print 'Initializing comparison feature' subprocess.Popen(['hg', 'clone', '..', 'a']).wait() subprocess.Popen(['hg', 'clone', '..', 'b']).wait()
[ "def", "init_compare", "(", ")", ":", "print", "'Initializing comparison feature'", "subprocess", ".", "Popen", "(", "[", "'hg'", ",", "'clone'", ",", "'..'", ",", "'a'", "]", ")", ".", "wait", "(", ")", "subprocess", ".", "Popen", "(", "[", "'hg'", ",",...
initializes the comparison feature .
train
false
40,583
@public def roots(f, *gens, **flags): from sympy.polys.polytools import to_rational_coeffs flags = dict(flags) auto = flags.pop('auto', True) cubics = flags.pop('cubics', True) trig = flags.pop('trig', False) quartics = flags.pop('quartics', True) quintics = flags.pop('quintics', False) multiple = flags.pop('mu...
[ "@", "public", "def", "roots", "(", "f", ",", "*", "gens", ",", "**", "flags", ")", ":", "from", "sympy", ".", "polys", ".", "polytools", "import", "to_rational_coeffs", "flags", "=", "dict", "(", "flags", ")", "auto", "=", "flags", ".", "pop", "(", ...
get nodes from graph g with indegree 0 .
train
false
40,584
def addXMLFromLoopComplexZ(attributes, depth, loop, output, z): addBeginXMLTag(attributes, depth, 'path', output) for pointComplexIndex in xrange(len(loop)): pointComplex = loop[pointComplexIndex] addXMLFromXYZ((depth + 1), pointComplexIndex, output, pointComplex.real, pointComplex.imag, z) addEndXMLTag(depth, '...
[ "def", "addXMLFromLoopComplexZ", "(", "attributes", ",", "depth", ",", "loop", ",", "output", ",", "z", ")", ":", "addBeginXMLTag", "(", "attributes", ",", "depth", ",", "'path'", ",", "output", ")", "for", "pointComplexIndex", "in", "xrange", "(", "len", ...
add xml from loop .
train
false
40,585
def _unpack_epochs(epochs): if (len(epochs.event_id) > 1): epochs = [epochs[k] for k in epochs.event_id] else: epochs = [epochs] return epochs
[ "def", "_unpack_epochs", "(", "epochs", ")", ":", "if", "(", "len", "(", "epochs", ".", "event_id", ")", ">", "1", ")", ":", "epochs", "=", "[", "epochs", "[", "k", "]", "for", "k", "in", "epochs", ".", "event_id", "]", "else", ":", "epochs", "="...
aux function .
train
false
40,587
def parse_iso8601_timestamp(timestamp): return datetime.datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
[ "def", "parse_iso8601_timestamp", "(", "timestamp", ")", ":", "return", "datetime", ".", "datetime", ".", "strptime", "(", "timestamp", ",", "'%Y-%m-%dT%H:%M:%S.%fZ'", ")" ]
parse a particular type of iso8601 formatted timestamp .
train
false
40,588
def remove_tenant_user(request, tenant_id, user_id): client = keystoneclient(request, admin=True) roles = client.roles.roles_for_user(user_id, tenant_id) for role in roles: client.roles.remove_user_role(user_id, role.id, tenant_id)
[ "def", "remove_tenant_user", "(", "request", ",", "tenant_id", ",", "user_id", ")", ":", "client", "=", "keystoneclient", "(", "request", ",", "admin", "=", "True", ")", "roles", "=", "client", ".", "roles", ".", "roles_for_user", "(", "user_id", ",", "ten...
removes all roles from a user on a tenant .
train
false
40,589
def send_all_stats(): deployment_id = helper.get_deployment_id() if (not deployment_id): return logging.debug('Getting all stats from every deployment node.') all_stats = helper.get_all_stats() portal_path = hermes_constants.PORTAL_STATS_PATH.format(deployment_id) url = '{0}{1}'.format(hermes_constants.PORTAL_U...
[ "def", "send_all_stats", "(", ")", ":", "deployment_id", "=", "helper", ".", "get_deployment_id", "(", ")", "if", "(", "not", "deployment_id", ")", ":", "return", "logging", ".", "debug", "(", "'Getting all stats from every deployment node.'", ")", "all_stats", "=...
calls get_all_stats and sends the deployment monitoring stats to the appscale portal .
train
false
40,590
def temporary_mount(filesystem, options=None): mountpoint = temporary_directory() try: mounted_fs = mount(filesystem, mountpoint, options=options) except: mountpoint.remove() raise return TemporaryMountedFilesystem(fs=mounted_fs)
[ "def", "temporary_mount", "(", "filesystem", ",", "options", "=", "None", ")", ":", "mountpoint", "=", "temporary_directory", "(", ")", "try", ":", "mounted_fs", "=", "mount", "(", "filesystem", ",", "mountpoint", ",", "options", "=", "options", ")", "except...
mount filesystem at a temporary mountpoint with options .
train
false
40,592
def indefinite_article(word): return 'a'
[ "def", "indefinite_article", "(", "word", ")", ":", "return", "'a'" ]
returns the indefinite article for a given word .
train
false
40,593
def get_permalink_ids(self): return list(self.get_permalink_ids_iter())
[ "def", "get_permalink_ids", "(", "self", ")", ":", "return", "list", "(", "self", ".", "get_permalink_ids_iter", "(", ")", ")" ]
method to get permalink ids from content .
train
false
40,595
def _get_blocks(rows, coords, idx): for idx_name in ('query', 'hit', 'midline', 'qannot', 'hannot'): assert (idx_name in idx) blocks = [] for (start, end) in coords: block = {} block['query'] = rows[idx['query']][start:end] block['hit'] = rows[idx['hit']][start:end] block['similarity'] = rows[idx['midline'...
[ "def", "_get_blocks", "(", "rows", ",", "coords", ",", "idx", ")", ":", "for", "idx_name", "in", "(", "'query'", ",", "'hit'", ",", "'midline'", ",", "'qannot'", ",", "'hannot'", ")", ":", "assert", "(", "idx_name", "in", "idx", ")", "blocks", "=", "...
returns a list of dictionaries of sequences split by the coordinates .
train
false
40,596
def to_language(locale): if ('_' in locale): return to_language(translation.trans_real.to_language(locale)) elif ('-' in locale): (lang, region) = locale.lower().split('-') if (region == 'latn'): region = region.capitalize() else: region = region.upper() return ('%s-%s' % (lang, region)) else: retu...
[ "def", "to_language", "(", "locale", ")", ":", "if", "(", "'_'", "in", "locale", ")", ":", "return", "to_language", "(", "translation", ".", "trans_real", ".", "to_language", "(", "locale", ")", ")", "elif", "(", "'-'", "in", "locale", ")", ":", "(", ...
turns a locale name into a language name .
train
false
40,597
def mirror_from(source, attributes, only_getters=True): def decorator(cls): for attribute in attributes: def make_gs_etter(source, attribute): def getter(self): return getattr(getattr(self, source), attribute) def setter(self, value): setattr(getattr(self, source), attribute, value) return (...
[ "def", "mirror_from", "(", "source", ",", "attributes", ",", "only_getters", "=", "True", ")", ":", "def", "decorator", "(", "cls", ")", ":", "for", "attribute", "in", "attributes", ":", "def", "make_gs_etter", "(", "source", ",", "attribute", ")", ":", ...
decorator for classes that mirror some attributes from an instance variable .
train
false
40,598
def check_call(*popenargs, **kwargs): retcode = call(*popenargs, **kwargs) cmd = kwargs.get('args') if (cmd is None): cmd = popenargs[0] if retcode: raise CalledProcessError(retcode, cmd) return retcode
[ "def", "check_call", "(", "*", "popenargs", ",", "**", "kwargs", ")", ":", "retcode", "=", "call", "(", "*", "popenargs", ",", "**", "kwargs", ")", "cmd", "=", "kwargs", ".", "get", "(", "'args'", ")", "if", "(", "cmd", "is", "None", ")", ":", "c...
run command with arguments .
train
true
40,600
def getTransformedPathByKey(key, xmlElement): if (key not in xmlElement.attributeDictionary): return [] word = str(xmlElement.attributeDictionary[key]).strip() evaluatedLinkValue = getEvaluatedLinkValue(word, xmlElement) if (evaluatedLinkValue.__class__ == list): return getPathByList(evaluatedLinkValue) xmlEle...
[ "def", "getTransformedPathByKey", "(", "key", ",", "xmlElement", ")", ":", "if", "(", "key", "not", "in", "xmlElement", ".", "attributeDictionary", ")", ":", "return", "[", "]", "word", "=", "str", "(", "xmlElement", ".", "attributeDictionary", "[", "key", ...
get transformed path from prefix and xml element .
train
false
40,601
def _from_ordinalf(x, tz=None): if (tz is None): tz = _get_rc_timezone() ix = int(x) dt = datetime.datetime.fromordinal(ix) remainder = (float(x) - ix) (hour, remainder) = divmod((24 * remainder), 1) (minute, remainder) = divmod((60 * remainder), 1) (second, remainder) = divmod((60 * remainder), 1) microsecon...
[ "def", "_from_ordinalf", "(", "x", ",", "tz", "=", "None", ")", ":", "if", "(", "tz", "is", "None", ")", ":", "tz", "=", "_get_rc_timezone", "(", ")", "ix", "=", "int", "(", "x", ")", "dt", "=", "datetime", ".", "datetime", ".", "fromordinal", "(...
convert gregorian float of the date .
train
true
40,602
def list_cache_nodes_full(opts=None, provider=None, base=None): if (opts is None): opts = __opts__ if (opts.get('update_cachedir', False) is False): return if (base is None): base = os.path.join(opts['cachedir'], 'active') minions = {} for driver in os.listdir(base): minions[driver] = {} prov_dir = os.pa...
[ "def", "list_cache_nodes_full", "(", "opts", "=", "None", ",", "provider", "=", "None", ",", "base", "=", "None", ")", ":", "if", "(", "opts", "is", "None", ")", ":", "opts", "=", "__opts__", "if", "(", "opts", ".", "get", "(", "'update_cachedir'", "...
return a list of minion data from the cloud cache .
train
false
40,604
def add_vendor_dir(path, index=1): venv_path = os.path.join(path, 'lib', _PYTHON_VERSION, 'site-packages') if os.path.isdir(venv_path): site_dir = venv_path elif os.path.isdir(path): site_dir = path else: raise ValueError(('virtualenv: cannot access %s: No such virtualenv or site directory' % path)) sys_path...
[ "def", "add_vendor_dir", "(", "path", ",", "index", "=", "1", ")", ":", "venv_path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "'lib'", ",", "_PYTHON_VERSION", ",", "'site-packages'", ")", "if", "os", ".", "path", ".", "isdir", "(", "ven...
insert site dir or virtualenv at a given index in sys .
train
false
40,605
def _xx_time_effects(x, y): xx = np.dot(x.values.T, x.values) xt = x.sum(level=0).values count = y.unstack().count(1).values selector = (count > 0) xt = xt[selector] count = count[selector] return (xx - np.dot((xt.T / count), xt))
[ "def", "_xx_time_effects", "(", "x", ",", "y", ")", ":", "xx", "=", "np", ".", "dot", "(", "x", ".", "values", ".", "T", ",", "x", ".", "values", ")", "xt", "=", "x", ".", "sum", "(", "level", "=", "0", ")", ".", "values", "count", "=", "y"...
returns xx - ^-1 .
train
false
40,606
def _root(name='', all_roots=False): if (_sd_version() >= 219): if all_roots: return [os.path.join(x, name) for x in ('/var/lib/machines', '/var/lib/container')] else: return os.path.join('/var/lib/machines', name) else: ret = os.path.join('/var/lib/container', name) if all_roots: return [ret] else...
[ "def", "_root", "(", "name", "=", "''", ",", "all_roots", "=", "False", ")", ":", "if", "(", "_sd_version", "(", ")", ">=", "219", ")", ":", "if", "all_roots", ":", "return", "[", "os", ".", "path", ".", "join", "(", "x", ",", "name", ")", "for...
return the container root directory .
train
true
40,607
def PhdIterator(handle): phd_records = Phd.parse(handle) for phd_record in phd_records: name = phd_record.file_name.split(None, 1)[0] seq_record = SeqRecord(phd_record.seq, id=name, name=name, description=phd_record.file_name) seq_record.annotations = phd_record.comments seq_record.letter_annotations['phred_q...
[ "def", "PhdIterator", "(", "handle", ")", ":", "phd_records", "=", "Phd", ".", "parse", "(", "handle", ")", "for", "phd_record", "in", "phd_records", ":", "name", "=", "phd_record", ".", "file_name", ".", "split", "(", "None", ",", "1", ")", "[", "0", ...
returns seqrecord objects from a phd file .
train
false
40,608
@task def test_api2(ctx): test_module(ctx, module=API_TESTS2)
[ "@", "task", "def", "test_api2", "(", "ctx", ")", ":", "test_module", "(", "ctx", ",", "module", "=", "API_TESTS2", ")" ]
run the api test suite .
train
false
40,609
def sg_label(sg_id, sg_name): return (((PREFIX + str(sg_id)) + '_') + sg_name)
[ "def", "sg_label", "(", "sg_id", ",", "sg_name", ")", ":", "return", "(", "(", "(", "PREFIX", "+", "str", "(", "sg_id", ")", ")", "+", "'_'", ")", "+", "sg_name", ")" ]
construct the security group id used as chain identifier in midonet .
train
false
40,611
def windows_friendly_colon_split(config_string): if Platform.is_win32(): return COLON_NON_WIN_PATH.split(config_string) else: return config_string.split(':')
[ "def", "windows_friendly_colon_split", "(", "config_string", ")", ":", "if", "Platform", ".", "is_win32", "(", ")", ":", "return", "COLON_NON_WIN_PATH", ".", "split", "(", "config_string", ")", "else", ":", "return", "config_string", ".", "split", "(", "':'", ...
perform a split by : on the config_string without splitting on the start of windows path .
train
false
40,612
def chirp(t, f0, t1, f1, method='linear', phi=0, vertex_zero=True): phase = _chirp_phase(t, f0, t1, f1, method, vertex_zero) phi *= (pi / 180) return cos((phase + phi))
[ "def", "chirp", "(", "t", ",", "f0", ",", "t1", ",", "f1", ",", "method", "=", "'linear'", ",", "phi", "=", "0", ",", "vertex_zero", "=", "True", ")", ":", "phase", "=", "_chirp_phase", "(", "t", ",", "f0", ",", "t1", ",", "f1", ",", "method", ...
frequency-swept cosine generator .
train
false
40,613
def record_utm_registration_attribution(request, user): utm_cookie_name = RegistrationCookieConfiguration.current().utm_cookie_name utm_cookie = request.COOKIES.get(utm_cookie_name) if (user and utm_cookie): utm = json.loads(utm_cookie) for utm_parameter_name in REGISTRATION_UTM_PARAMETERS: utm_parameter = ut...
[ "def", "record_utm_registration_attribution", "(", "request", ",", "user", ")", ":", "utm_cookie_name", "=", "RegistrationCookieConfiguration", ".", "current", "(", ")", ".", "utm_cookie_name", "utm_cookie", "=", "request", ".", "COOKIES", ".", "get", "(", "utm_cook...
attribute this users registration to the latest utm referrer .
train
false
40,614
def put_pipeline_definition(pipeline_id, pipeline_objects, parameter_objects=None, parameter_values=None, region=None, key=None, keyid=None, profile=None): parameter_objects = (parameter_objects or []) parameter_values = (parameter_values or []) client = _get_client(region, key, keyid, profile) r = {} try: respo...
[ "def", "put_pipeline_definition", "(", "pipeline_id", ",", "pipeline_objects", ",", "parameter_objects", "=", "None", ",", "parameter_values", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "...
add tasks .
train
true
40,615
def build_UNIX_integration_tests(mixin_class, name, fixture): class RealTests(mixin_class, AsyncTestCase, ): '\n Tests that endpoints are available over the network interfaces that\n real API users will be connecting from.\n ' def setUp(self): path = os.path.relpath(self.mktemp()) self.a...
[ "def", "build_UNIX_integration_tests", "(", "mixin_class", ",", "name", ",", "fixture", ")", ":", "class", "RealTests", "(", "mixin_class", ",", "AsyncTestCase", ",", ")", ":", "def", "setUp", "(", "self", ")", ":", "path", "=", "os", ".", "path", ".", "...
build asynctestcase class that runs the tests in the mixin class with real queries over a unix socket .
train
false
40,616
def draw_rimmed_box(screen, box_rect, box_color, rim_width=0, rim_color=Color('black')): if rim_width: rim_rect = Rect((box_rect.left - rim_width), (box_rect.top - rim_width), (box_rect.width + (rim_width * 2)), (box_rect.height + (rim_width * 2))) pygame.draw.rect(screen, rim_color, rim_rect) pygame.draw.rect(sc...
[ "def", "draw_rimmed_box", "(", "screen", ",", "box_rect", ",", "box_color", ",", "rim_width", "=", "0", ",", "rim_color", "=", "Color", "(", "'black'", ")", ")", ":", "if", "rim_width", ":", "rim_rect", "=", "Rect", "(", "(", "box_rect", ".", "left", "...
draw a rimmed box on the given surface .
train
false
40,617
def _sid_subdir_path(sid): padded_sid = format(sid, '06') return os.path.join(padded_sid[0:2], padded_sid[2:4], '{0}.bcolz'.format(str(padded_sid)))
[ "def", "_sid_subdir_path", "(", "sid", ")", ":", "padded_sid", "=", "format", "(", "sid", ",", "'06'", ")", "return", "os", ".", "path", ".", "join", "(", "padded_sid", "[", "0", ":", "2", "]", ",", "padded_sid", "[", "2", ":", "4", "]", ",", "'{...
format subdir path to limit the number directories in any given subdirectory to 100 .
train
true
40,620
def ownership(registry, xml_parent, data): ownership_plugin = XML.SubElement(xml_parent, 'com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerJobProperty') ownership = XML.SubElement(ownership_plugin, 'ownership') owner = str(data.get('enabled', True)).lower() XML.SubElement(ownership, 'ownershipEnabled').text ...
[ "def", "ownership", "(", "registry", ",", "xml_parent", ",", "data", ")", ":", "ownership_plugin", "=", "XML", ".", "SubElement", "(", "xml_parent", ",", "'com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerJobProperty'", ")", "ownership", "=", "XML", ".", "SubEl...
yaml: ownership plugin provides explicit ownership for jobs and slave nodes .
train
false
40,621
def dpll_satisfiable(expr, all_models=False): clauses = conjuncts(to_cnf(expr)) if (False in clauses): if all_models: return (f for f in [False]) return False symbols = sorted(_find_predicates(expr), key=default_sort_key) symbols_int_repr = range(1, (len(symbols) + 1)) clauses_int_repr = to_int_repr(clauses...
[ "def", "dpll_satisfiable", "(", "expr", ",", "all_models", "=", "False", ")", ":", "clauses", "=", "conjuncts", "(", "to_cnf", "(", "expr", ")", ")", "if", "(", "False", "in", "clauses", ")", ":", "if", "all_models", ":", "return", "(", "f", "for", "...
check satisfiability of a propositional sentence .
train
false
40,622
def eggs(x, y): global fr, st fr = inspect.currentframe() st = inspect.stack() p = x q = (y / 0)
[ "def", "eggs", "(", "x", ",", "y", ")", ":", "global", "fr", ",", "st", "fr", "=", "inspect", ".", "currentframe", "(", ")", "st", "=", "inspect", ".", "stack", "(", ")", "p", "=", "x", "q", "=", "(", "y", "/", "0", ")" ]
a docstring .
train
false
40,625
def register_ui(review_ui): if (not issubclass(review_ui, FileAttachmentReviewUI)): raise TypeError(u'Only FileAttachmentReviewUI subclasses can be registered') _file_attachment_review_uis.append(review_ui)
[ "def", "register_ui", "(", "review_ui", ")", ":", "if", "(", "not", "issubclass", "(", "review_ui", ",", "FileAttachmentReviewUI", ")", ")", ":", "raise", "TypeError", "(", "u'Only FileAttachmentReviewUI subclasses can be registered'", ")", "_file_attachment_review_uis", ...
registers a review ui class .
train
false
40,626
def ConfigureRemoteApi(app_id, path, auth_func, servername=None, rpc_server_factory=appengine_rpc.HttpRpcServer, rtok=None, secure=False, services=None, default_auth_domain=None, save_cookies=False, use_remote_datastore=True): if ((not servername) and (not app_id)): raise ConfigurationError('app_id or servername req...
[ "def", "ConfigureRemoteApi", "(", "app_id", ",", "path", ",", "auth_func", ",", "servername", "=", "None", ",", "rpc_server_factory", "=", "appengine_rpc", ".", "HttpRpcServer", ",", "rtok", "=", "None", ",", "secure", "=", "False", ",", "services", "=", "No...
does necessary setup to allow easy remote access to app engine apis .
train
false
40,627
def test_data_name_third_party_package(): data_dir = os.path.join(os.path.dirname(__file__), u'data') sys.path.insert(0, data_dir) try: import test_package filename = test_package.get_data_filename() assert (filename == os.path.join(data_dir, u'test_package', u'data', u'foo.txt')) finally: sys.path.pop(0)
[ "def", "test_data_name_third_party_package", "(", ")", ":", "data_dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "u'data'", ")", "sys", ".", "path", ".", "insert", "(", "0", ",", "data_dir"...
regression test for issue #1256 tests that get_pkg_data_filename works in a third-party package that doesnt make any relative imports from the module its used from .
train
false
40,628
def test_sample_wrong_X(): ada = ADASYN(random_state=RND_SEED) ada.fit(X, Y) assert_raises(RuntimeError, ada.sample, np.random.random((100, 40)), np.array((([0] * 50) + ([1] * 50))))
[ "def", "test_sample_wrong_X", "(", ")", ":", "ada", "=", "ADASYN", "(", "random_state", "=", "RND_SEED", ")", "ada", ".", "fit", "(", "X", ",", "Y", ")", "assert_raises", "(", "RuntimeError", ",", "ada", ".", "sample", ",", "np", ".", "random", ".", ...
test either if an error is raised when x is different at fitting and sampling .
train
false
40,629
def patch_os(): patch_module('os')
[ "def", "patch_os", "(", ")", ":", "patch_module", "(", "'os'", ")" ]
replace :func:os .
train
false
40,630
def _simple_blockify(tuples, dtype): (values, placement) = _stack_arrays(tuples, dtype) if ((dtype is not None) and (values.dtype != dtype)): values = values.astype(dtype) block = make_block(values, placement=placement) return [block]
[ "def", "_simple_blockify", "(", "tuples", ",", "dtype", ")", ":", "(", "values", ",", "placement", ")", "=", "_stack_arrays", "(", "tuples", ",", "dtype", ")", "if", "(", "(", "dtype", "is", "not", "None", ")", "and", "(", "values", ".", "dtype", "!=...
return a single array of a block that has a single dtype; if dtype is not none .
train
true
40,631
def is_valid_route_dist(route_dist): return is_valid_ext_comm_attr(route_dist)
[ "def", "is_valid_route_dist", "(", "route_dist", ")", ":", "return", "is_valid_ext_comm_attr", "(", "route_dist", ")" ]
validates *route_dist* as string representation of route distinguisher .
train
false
40,632
def command_copytree(args): for srcdir in args.srcdirs: basename = os.path.basename(srcdir) destdir2 = os.path.normpath(os.path.join(args.destdir, basename)) if os.path.exists(destdir2): shutil.rmtree(destdir2) sys.stdout.write(('copytree: %s => %s\n' % (srcdir, destdir2))) shutil.copytree(srcdir, destdir...
[ "def", "command_copytree", "(", "args", ")", ":", "for", "srcdir", "in", "args", ".", "srcdirs", ":", "basename", "=", "os", ".", "path", ".", "basename", "(", "srcdir", ")", "destdir2", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path"...
copy one or more source directory(s) below a destination directory .
train
true
40,634
def refresh(): if _TRAFFICCTL: cmd = _traffic_ctl('config', 'reload') else: cmd = _traffic_line('-x') log.debug('Running: %s', cmd) return _subprocess(cmd)
[ "def", "refresh", "(", ")", ":", "if", "_TRAFFICCTL", ":", "cmd", "=", "_traffic_ctl", "(", "'config'", ",", "'reload'", ")", "else", ":", "cmd", "=", "_traffic_line", "(", "'-x'", ")", "log", ".", "debug", "(", "'Running: %s'", ",", "cmd", ")", "retur...
this waits for the timeout on each host .
train
false
40,635
def _get_pip_bin(bin_env): if (not bin_env): which_result = __salt__['cmd.which_bin'](['pip', 'pip2', 'pip3', 'pip-python']) if (which_result is None): raise CommandNotFoundError('Could not find a `pip` binary') if salt.utils.is_windows(): return which_result.encode('string-escape') return which_result ...
[ "def", "_get_pip_bin", "(", "bin_env", ")", ":", "if", "(", "not", "bin_env", ")", ":", "which_result", "=", "__salt__", "[", "'cmd.which_bin'", "]", "(", "[", "'pip'", ",", "'pip2'", ",", "'pip3'", ",", "'pip-python'", "]", ")", "if", "(", "which_result...
locate the pip binary .
train
false
40,636
def load_certificate(type, buffer): if isinstance(buffer, _text_type): buffer = buffer.encode('ascii') bio = _new_mem_buf(buffer) if (type == FILETYPE_PEM): x509 = _lib.PEM_read_bio_X509(bio, _ffi.NULL, _ffi.NULL, _ffi.NULL) elif (type == FILETYPE_ASN1): x509 = _lib.d2i_X509_bio(bio, _ffi.NULL) else: raise...
[ "def", "load_certificate", "(", "type", ",", "buffer", ")", ":", "if", "isinstance", "(", "buffer", ",", "_text_type", ")", ":", "buffer", "=", "buffer", ".", "encode", "(", "'ascii'", ")", "bio", "=", "_new_mem_buf", "(", "buffer", ")", "if", "(", "ty...
load public and secret key from a zmq certificate .
train
false
40,637
def getArchivableObjectAddToParent(archivableClass, xmlElement): archivableObject = archivableClass() archivableObject.xmlElement = xmlElement xmlElement.object = archivableObject archivableObject.setToObjectAttributeDictionary() xmlElement.parent.object.archivableObjects.append(archivableObject) return archivabl...
[ "def", "getArchivableObjectAddToParent", "(", "archivableClass", ",", "xmlElement", ")", ":", "archivableObject", "=", "archivableClass", "(", ")", "archivableObject", ".", "xmlElement", "=", "xmlElement", "xmlElement", ".", "object", "=", "archivableObject", "archivabl...
get the archivable object and add it to the parent object .
train
false
40,639
def sgml_extract(text_data): return {'docid': _get_one(docid_re, text_data, required=True), 'doctype': _get_one(doctype_re, text_data, required=True), 'datetime': _get_one(datetime_re, text_data, required=True), 'headline': _get_one(headline_re, text_data, required=True), 'poster': _get_one(poster_re, _get_one(post_re...
[ "def", "sgml_extract", "(", "text_data", ")", ":", "return", "{", "'docid'", ":", "_get_one", "(", "docid_re", ",", "text_data", ",", "required", "=", "True", ")", ",", "'doctype'", ":", "_get_one", "(", "doctype_re", ",", "text_data", ",", "required", "="...
extract text from the ontonotes web documents .
train
false
40,642
def dictionary_merge(a, b): for (key, value) in b.items(): if ((key in a) and isinstance(a[key], dict) and isinstance(value, dict)): dictionary_merge(a[key], b[key]) continue a[key] = b[key] return a
[ "def", "dictionary_merge", "(", "a", ",", "b", ")", ":", "for", "(", "key", ",", "value", ")", "in", "b", ".", "items", "(", ")", ":", "if", "(", "(", "key", "in", "a", ")", "and", "isinstance", "(", "a", "[", "key", "]", ",", "dict", ")", ...
merges dictionary b into a like dict .
train
true
40,643
def bulk_update_private(context, data_dict): _check_access('bulk_update_private', context, data_dict) _bulk_update_dataset(context, data_dict, {'private': True})
[ "def", "bulk_update_private", "(", "context", ",", "data_dict", ")", ":", "_check_access", "(", "'bulk_update_private'", ",", "context", ",", "data_dict", ")", "_bulk_update_dataset", "(", "context", ",", "data_dict", ",", "{", "'private'", ":", "True", "}", ")"...
make a list of datasets private .
train
false
40,644
def update_preferred_site_language_code(user_id, preferred_site_language_code): user_settings = get_user_settings(user_id, strict=True) user_settings.preferred_site_language_code = preferred_site_language_code _save_user_settings(user_settings)
[ "def", "update_preferred_site_language_code", "(", "user_id", ",", "preferred_site_language_code", ")", ":", "user_settings", "=", "get_user_settings", "(", "user_id", ",", "strict", "=", "True", ")", "user_settings", ".", "preferred_site_language_code", "=", "preferred_s...
updates preferred_site_language_code of user with given user_id .
train
false
40,645
def _get_md5(name, path, run_func): output = run_func(name, 'md5sum {0}'.format(pipes.quote(path)), ignore_retcode=True)['stdout'] try: return output.split()[0] except IndexError: return None
[ "def", "_get_md5", "(", "name", ",", "path", ",", "run_func", ")", ":", "output", "=", "run_func", "(", "name", ",", "'md5sum {0}'", ".", "format", "(", "pipes", ".", "quote", "(", "path", ")", ")", ",", "ignore_retcode", "=", "True", ")", "[", "'std...
get the md5 checksum of a file from a container .
train
true
40,647
def find_dependent_tables(tables, graph=None): if (graph is None): graph = _pokedex_graph tables = list(tables) dependents = set() def add_dependents_of(table): for dependent_table in graph.get(table, []): if (dependent_table not in dependents): dependents.add(dependent_table) add_dependents_of(depen...
[ "def", "find_dependent_tables", "(", "tables", ",", "graph", "=", "None", ")", ":", "if", "(", "graph", "is", "None", ")", ":", "graph", "=", "_pokedex_graph", "tables", "=", "list", "(", "tables", ")", "dependents", "=", "set", "(", ")", "def", "add_d...
recursively find all tables which depend on the given tables .
train
false
40,648
def _read_exactly(sock, amt): data = '' while (amt > 0): chunk = sock.recv(amt) data += chunk amt -= len(chunk) return data
[ "def", "_read_exactly", "(", "sock", ",", "amt", ")", ":", "data", "=", "''", "while", "(", "amt", ">", "0", ")", ":", "chunk", "=", "sock", ".", "recv", "(", "amt", ")", "data", "+=", "chunk", "amt", "-=", "len", "(", "chunk", ")", "return", "...
read *exactly* amt bytes from the socket sock .
train
false
40,649
@no_auto_transaction def meeting_hook(): message = ConferenceMessage() try: message.verify() except ConferenceError as error: logger.error(error) raise HTTPError(httplib.NOT_ACCEPTABLE) try: conference = Conference.get_by_endpoint(message.conference_name, active=False) except ConferenceError as error: lo...
[ "@", "no_auto_transaction", "def", "meeting_hook", "(", ")", ":", "message", "=", "ConferenceMessage", "(", ")", "try", ":", "message", ".", "verify", "(", ")", "except", "ConferenceError", "as", "error", ":", "logger", ".", "error", "(", "error", ")", "ra...
view function for email conference submission .
train
false
40,650
def is_device(device_name, allow_virtual): device_name = re.sub('/', '!', device_name) if allow_virtual: devicename = (('/sys/block/' + device_name) + '/device') else: devicename = ('/sys/block/' + device_name) return os.access(devicename, os.F_OK)
[ "def", "is_device", "(", "device_name", ",", "allow_virtual", ")", ":", "device_name", "=", "re", ".", "sub", "(", "'/'", ",", "'!'", ",", "device_name", ")", "if", "allow_virtual", ":", "devicename", "=", "(", "(", "'/sys/block/'", "+", "device_name", ")"...
test whether given name is a device or a partition .
train
false
40,651
def _incremental_mean_and_var(X, last_mean=0.0, last_variance=None, last_sample_count=0): last_sum = (last_mean * last_sample_count) new_sum = X.sum(axis=0) new_sample_count = X.shape[0] updated_sample_count = (last_sample_count + new_sample_count) updated_mean = ((last_sum + new_sum) / updated_sample_count) if (...
[ "def", "_incremental_mean_and_var", "(", "X", ",", "last_mean", "=", "0.0", ",", "last_variance", "=", "None", ",", "last_sample_count", "=", "0", ")", ":", "last_sum", "=", "(", "last_mean", "*", "last_sample_count", ")", "new_sum", "=", "X", ".", "sum", ...
calculate mean update and a youngs and cramer variance update .
train
false
40,652
def hdfs_uri_to_real_path(hdfs_uri, environ): components = urlparse(hdfs_uri) scheme = components.scheme path = components.path if ((not scheme) and (not path.startswith('/'))): path = ('/user/%s/%s' % (environ['USER'], path)) return os.path.join(get_mock_hdfs_root(environ=environ), path.lstrip('/'))
[ "def", "hdfs_uri_to_real_path", "(", "hdfs_uri", ",", "environ", ")", ":", "components", "=", "urlparse", "(", "hdfs_uri", ")", "scheme", "=", "components", ".", "scheme", "path", "=", "components", ".", "path", "if", "(", "(", "not", "scheme", ")", "and",...
map an hdfs uri to a path on the filesystem .
train
false
40,653
def check_callbacks(bot, trigger, url, run=True): matched = any((regex.search(url) for regex in bot.memory[u'url_exclude'])) for (regex, function) in tools.iteritems(bot.memory[u'url_callbacks']): match = regex.search(url) if match: if (run or hasattr(function, u'url_regex')): function(bot, trigger, match)...
[ "def", "check_callbacks", "(", "bot", ",", "trigger", ",", "url", ",", "run", "=", "True", ")", ":", "matched", "=", "any", "(", "(", "regex", ".", "search", "(", "url", ")", "for", "regex", "in", "bot", ".", "memory", "[", "u'url_exclude'", "]", "...
check the given url against the callbacks list .
train
false
40,654
@pytest.fixture(scope='session') def user_dir(tmpdir_factory): return tmpdir_factory.mktemp('user_dir')
[ "@", "pytest", ".", "fixture", "(", "scope", "=", "'session'", ")", "def", "user_dir", "(", "tmpdir_factory", ")", ":", "return", "tmpdir_factory", ".", "mktemp", "(", "'user_dir'", ")" ]
fixture that simulates the users home directory .
train
false
40,656
def get_selected_inferior(): return gdb.inferiors()[0] selected_thread = gdb.selected_thread() for inferior in gdb.inferiors(): for thread in inferior.threads(): if (thread == selected_thread): return inferior
[ "def", "get_selected_inferior", "(", ")", ":", "return", "gdb", ".", "inferiors", "(", ")", "[", "0", "]", "selected_thread", "=", "gdb", ".", "selected_thread", "(", ")", "for", "inferior", "in", "gdb", ".", "inferiors", "(", ")", ":", "for", "thread", ...
return the selected inferior in gdb .
train
false
40,659
def save_hdf5(filename, obj, compression=4): _check_available() with h5py.File(filename, 'w') as f: s = HDF5Serializer(f, compression=compression) s.save(obj)
[ "def", "save_hdf5", "(", "filename", ",", "obj", ",", "compression", "=", "4", ")", ":", "_check_available", "(", ")", "with", "h5py", ".", "File", "(", "filename", ",", "'w'", ")", "as", "f", ":", "s", "=", "HDF5Serializer", "(", "f", ",", "compress...
saves an object to the file in hdf5 format .
train
false
40,660
def connectToRootNS(network, switch, ip, routes): root = Node('root', inNamespace=False) intf = network.addLink(root, switch).intf1 root.setIP(ip, intf=intf) network.start() for route in routes: root.cmd(((('route add -net ' + route) + ' dev ') + str(intf)))
[ "def", "connectToRootNS", "(", "network", ",", "switch", ",", "ip", ",", "routes", ")", ":", "root", "=", "Node", "(", "'root'", ",", "inNamespace", "=", "False", ")", "intf", "=", "network", ".", "addLink", "(", "root", ",", "switch", ")", ".", "int...
connect hosts to root namespace via switch .
train
false
40,661
def getOverhangSupportAngle(xmlElement): return math.radians(xmlElement.getCascadeFloat(45.0, 'overhangSupportAngle'))
[ "def", "getOverhangSupportAngle", "(", "xmlElement", ")", ":", "return", "math", ".", "radians", "(", "xmlElement", ".", "getCascadeFloat", "(", "45.0", ",", "'overhangSupportAngle'", ")", ")" ]
get the overhang support angle in radians .
train
false
40,663
def test_xdawn_apply_transform(): (raw, events, picks) = _get_data() raw.pick_types(eeg=True, meg=False) epochs = Epochs(raw, events, event_id, tmin, tmax, proj=False, preload=True, baseline=None, verbose=False) n_components = 2 xd = Xdawn(n_components=n_components, correct_overlap=False) xd.fit(epochs) for inst...
[ "def", "test_xdawn_apply_transform", "(", ")", ":", "(", "raw", ",", "events", ",", "picks", ")", "=", "_get_data", "(", ")", "raw", ".", "pick_types", "(", "eeg", "=", "True", ",", "meg", "=", "False", ")", "epochs", "=", "Epochs", "(", "raw", ",", ...
test xdawn apply and transform .
train
false
40,664
def hdmedian(data, axis=(-1), var=False): result = hdquantiles(data, [0.5], axis=axis, var=var) return result.squeeze()
[ "def", "hdmedian", "(", "data", ",", "axis", "=", "(", "-", "1", ")", ",", "var", "=", "False", ")", ":", "result", "=", "hdquantiles", "(", "data", ",", "[", "0.5", "]", ",", "axis", "=", "axis", ",", "var", "=", "var", ")", "return", "result"...
returns the harrell-davis estimate of the median along the given axis .
train
false
40,666
def time_diff(): now = time_utcnow() diff = (now - timedelta(minutes=flaskbb_config['ONLINE_LAST_MINUTES'])) return diff
[ "def", "time_diff", "(", ")", ":", "now", "=", "time_utcnow", "(", ")", "diff", "=", "(", "now", "-", "timedelta", "(", "minutes", "=", "flaskbb_config", "[", "'ONLINE_LAST_MINUTES'", "]", ")", ")", "return", "diff" ]
calculates the time difference between now and the online_last_minutes variable from the configuration .
train
false