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
23,769
def default_ssl_connection_selector(connection, app_blame, client_hello): return None
[ "def", "default_ssl_connection_selector", "(", "connection", ",", "app_blame", ",", "client_hello", ")", ":", "return", "None" ]
returns a nogotofail .
train
false
23,771
def appproperties(): appprops = makeelement('Properties', nsprefix='ep') appprops = etree.fromstring('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/doc...
[ "def", "appproperties", "(", ")", ":", "appprops", "=", "makeelement", "(", "'Properties'", ",", "nsprefix", "=", "'ep'", ")", "appprops", "=", "etree", ".", "fromstring", "(", "'<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Properties xmlns=\"http://schemas...
create app-specific properties .
train
true
23,772
def request_host(request): url = request.get_full_url() host = _rfc3986.urlsplit(url)[1] if (host is None): host = request.get_header('Host', '') return cut_port_re.sub('', host, 1)
[ "def", "request_host", "(", "request", ")", ":", "url", "=", "request", ".", "get_full_url", "(", ")", "host", "=", "_rfc3986", ".", "urlsplit", "(", "url", ")", "[", "1", "]", "if", "(", "host", "is", "None", ")", ":", "host", "=", "request", ".",...
return request-host .
train
false
23,773
def get_cache_key_counter(bound_method, *args, **kwargs): model = bound_method.im_self ormcache = bound_method.clear_cache.im_self (cache, key0, counter) = ormcache.lru(model) key = (key0 + ormcache.key(model, *args, **kwargs)) return (cache, key, counter)
[ "def", "get_cache_key_counter", "(", "bound_method", ",", "*", "args", ",", "**", "kwargs", ")", ":", "model", "=", "bound_method", ".", "im_self", "ormcache", "=", "bound_method", ".", "clear_cache", ".", "im_self", "(", "cache", ",", "key0", ",", "counter"...
return the cache .
train
false
23,774
def sep2tabs(fname, in_place=True, patt='\\s+'): regexp = re.compile(patt) (fd, temp_name) = tempfile.mkstemp() fp = os.fdopen(fd, 'wt') i = None for (i, line) in enumerate(open(fname)): line = line.rstrip('\r\n') elems = regexp.split(line) fp.write(('%s\n' % ' DCTB '.join(elems))) fp.close() if (i is None...
[ "def", "sep2tabs", "(", "fname", ",", "in_place", "=", "True", ",", "patt", "=", "'\\\\s+'", ")", ":", "regexp", "=", "re", ".", "compile", "(", "patt", ")", "(", "fd", ",", "temp_name", ")", "=", "tempfile", ".", "mkstemp", "(", ")", "fp", "=", ...
transforms in place a sep separated file to a tab separated one .
train
false
23,775
def _get_conv_weights_bc01(layer): assert isinstance(layer, (MaxoutConvC01B, ConvElemwise)) weights = layer.get_params()[0].get_value() if isinstance(layer, MaxoutConvC01B): c01b = Conv2DSpace(shape=weights.shape[1:3], num_channels=weights.shape[0], axes=('c', 0, 1, 'b')) bc01 = Conv2DSpace(shape=c01b.shape, num...
[ "def", "_get_conv_weights_bc01", "(", "layer", ")", ":", "assert", "isinstance", "(", "layer", ",", "(", "MaxoutConvC01B", ",", "ConvElemwise", ")", ")", "weights", "=", "layer", ".", "get_params", "(", ")", "[", "0", "]", ".", "get_value", "(", ")", "if...
returns a conv .
train
false
23,776
def clean_expired_tokens(opts): serializer = salt.payload.Serial(opts) for (dirpath, dirnames, filenames) in os.walk(opts['token_dir']): for token in filenames: token_path = os.path.join(dirpath, token) with salt.utils.fopen(token_path) as token_file: try: token_data = serializer.loads(token_file.rea...
[ "def", "clean_expired_tokens", "(", "opts", ")", ":", "serializer", "=", "salt", ".", "payload", ".", "Serial", "(", "opts", ")", "for", "(", "dirpath", ",", "dirnames", ",", "filenames", ")", "in", "os", ".", "walk", "(", "opts", "[", "'token_dir'", "...
clean expired tokens from the master .
train
false
23,777
def S_ISSOCK(mode): return (S_IFMT(mode) == S_IFSOCK)
[ "def", "S_ISSOCK", "(", "mode", ")", ":", "return", "(", "S_IFMT", "(", "mode", ")", "==", "S_IFSOCK", ")" ]
return true if mode is from a socket .
train
false
23,778
def implicit_application(result, local_dict, global_dict): for step in (_group_parentheses(implicit_application), _apply_functions, _implicit_application): result = step(result, local_dict, global_dict) result = _flatten(result) return result
[ "def", "implicit_application", "(", "result", ",", "local_dict", ",", "global_dict", ")", ":", "for", "step", "in", "(", "_group_parentheses", "(", "implicit_application", ")", ",", "_apply_functions", ",", "_implicit_application", ")", ":", "result", "=", "step",...
makes parentheses optional in some cases for function calls .
train
false
23,780
def image_list(id=None, profile=None, name=None): g_client = _auth(profile) ret = [] for image in g_client.images.list(): if ((id is None) and (name is None)): _add_image(ret, image) else: if ((id is not None) and (id == image.id)): _add_image(ret, image) return ret if (name == image.name): ...
[ "def", "image_list", "(", "id", "=", "None", ",", "profile", "=", "None", ",", "name", "=", "None", ")", ":", "g_client", "=", "_auth", "(", "profile", ")", "ret", "=", "[", "]", "for", "image", "in", "g_client", ".", "images", ".", "list", "(", ...
return a list of available images if a name is provided .
train
true
23,781
def _convert_nnn_fr(val): word = '' (mod, rem) = ((val % 100), (val // 100)) if (rem > 0): word = (to_19_fr[rem] + ' Cent') if (mod > 0): word += ' ' if (mod > 0): word += _convert_nn_fr(mod) return word
[ "def", "_convert_nnn_fr", "(", "val", ")", ":", "word", "=", "''", "(", "mod", ",", "rem", ")", "=", "(", "(", "val", "%", "100", ")", ",", "(", "val", "//", "100", ")", ")", "if", "(", "rem", ">", "0", ")", ":", "word", "=", "(", "to_19_fr...
convert a value < 1000 to french special cased because it is the level that kicks off the < 100 special case .
train
false
23,783
def promoted(name): ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} if (('@' in name) or ('#' in name)): ret['result'] = False ret['comment'] = 'invalid filesystem or volume name: {0}'.format(name) if ret['result']: if (name in __salt__['zfs.list'](name)): origin = '-' if (not __opts__...
[ "def", "promoted", "(", "name", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", "}", "if", "(", "(", "'@'", "in", "name", ")", "or", "(", "'#'", "in",...
ensure a dataset is not a clone name : string name of fileset or volume .
train
false
23,785
def unregister_actions(action_ids): _populate_defaults() for action_id in action_ids: try: action = _all_actions[action_id] except KeyError: raise KeyError((u'%s does not correspond to a registered review request action' % action_id)) action.unregister()
[ "def", "unregister_actions", "(", "action_ids", ")", ":", "_populate_defaults", "(", ")", "for", "action_id", "in", "action_ids", ":", "try", ":", "action", "=", "_all_actions", "[", "action_id", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "(", ...
unregister each of the actions corresponding to the given ids .
train
false
23,788
def get_custom_objects(): return _GLOBAL_CUSTOM_OBJECTS
[ "def", "get_custom_objects", "(", ")", ":", "return", "_GLOBAL_CUSTOM_OBJECTS" ]
retrieves a live reference to the global dictionary of custom objects .
train
false
23,790
@require_admin_context def cluster_destroy(context, id): query = _cluster_query(context, id=id) query = query.filter((models.Cluster.num_hosts == 0)) result = query.update(models.Cluster.delete_values(), synchronize_session=False) if (not result): cluster_get(context, id=id) raise exception.ClusterHasHosts(id=i...
[ "@", "require_admin_context", "def", "cluster_destroy", "(", "context", ",", "id", ")", ":", "query", "=", "_cluster_query", "(", "context", ",", "id", "=", "id", ")", "query", "=", "query", ".", "filter", "(", "(", "models", ".", "Cluster", ".", "num_ho...
destroy the cluster or raise if it does not exist or has hosts .
train
false
23,793
def read_style_table(xml_source): table = {} xmlns = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' root = fromstring(xml_source) custom_num_formats = parse_custom_num_formats(root, xmlns) builtin_formats = NumberFormat._BUILTIN_FORMATS cell_xfs = root.find(QName(xmlns, 'cellXfs').text) cell_xfs_nod...
[ "def", "read_style_table", "(", "xml_source", ")", ":", "table", "=", "{", "}", "xmlns", "=", "'http://schemas.openxmlformats.org/spreadsheetml/2006/main'", "root", "=", "fromstring", "(", "xml_source", ")", "custom_num_formats", "=", "parse_custom_num_formats", "(", "r...
read styles from the shared style table .
train
false
23,794
def set_auth_traps_enabled(status=True): vname = 'EnableAuthenticationTraps' current_status = get_auth_traps_enabled() if (bool(status) == current_status): _LOG.debug('%s already contains the provided value.', vname) return True vdata = int(status) __salt__['reg.set_value'](_HKEY, _SNMP_KEY, vname, vdata, 'REG...
[ "def", "set_auth_traps_enabled", "(", "status", "=", "True", ")", ":", "vname", "=", "'EnableAuthenticationTraps'", "current_status", "=", "get_auth_traps_enabled", "(", ")", "if", "(", "bool", "(", "status", ")", "==", "current_status", ")", ":", "_LOG", ".", ...
manage the sending of authentication traps .
train
true
23,795
def _split_nonparallel_tests(test): ptests = [] stests = [] def is_parallelizable_test_case(test): method_name = test._testMethodName method = getattr(test, method_name) if ((method.__name__ != method_name) and (method.__name__ == 'testFailure')): return False return getattr(test, '_numba_parallel_test_',...
[ "def", "_split_nonparallel_tests", "(", "test", ")", ":", "ptests", "=", "[", "]", "stests", "=", "[", "]", "def", "is_parallelizable_test_case", "(", "test", ")", ":", "method_name", "=", "test", ".", "_testMethodName", "method", "=", "getattr", "(", "test"...
split test suite into parallel and serial tests .
train
false
23,796
def list_meta_fields(): ret = {} (status, result) = _query(action='meta', command='fields') root = ET.fromstring(result) fields = root.getchildren() for field in fields: field_id = None field_ret = {'name': field.text} for item in field.items(): field_ret[item[0]] = item[1] if (item[0] == 'id'): fi...
[ "def", "list_meta_fields", "(", ")", ":", "ret", "=", "{", "}", "(", "status", ",", "result", ")", "=", "_query", "(", "action", "=", "'meta'", ",", "command", "=", "'fields'", ")", "root", "=", "ET", ".", "fromstring", "(", "result", ")", "fields", ...
show all meta data fields for this company .
train
true
23,797
def get_descriptor(dev, desc_size, desc_type, desc_index, wIndex=0): wValue = (desc_index | (desc_type << 8)) bmRequestType = util.build_request_type(util.CTRL_IN, util.CTRL_TYPE_STANDARD, util.CTRL_RECIPIENT_DEVICE) return dev.ctrl_transfer(bmRequestType=bmRequestType, bRequest=6, wValue=wValue, wIndex=wIndex, data...
[ "def", "get_descriptor", "(", "dev", ",", "desc_size", ",", "desc_type", ",", "desc_index", ",", "wIndex", "=", "0", ")", ":", "wValue", "=", "(", "desc_index", "|", "(", "desc_type", "<<", "8", ")", ")", "bmRequestType", "=", "util", ".", "build_request...
return the specified descriptor .
train
true
23,798
def make_errordocument(app, global_conf, **kw): map = {} for (status, redir_loc) in kw.items(): try: status = int(status) except ValueError: raise ValueError(('Bad status code: %r' % status)) map[status] = redir_loc forwarder = forward(app, map) return forwarder
[ "def", "make_errordocument", "(", "app", ",", "global_conf", ",", "**", "kw", ")", ":", "map", "=", "{", "}", "for", "(", "status", ",", "redir_loc", ")", "in", "kw", ".", "items", "(", ")", ":", "try", ":", "status", "=", "int", "(", "status", "...
paste deploy entry point to create a error document wrapper .
train
false
23,799
def init(mpstate): return SerialModule(mpstate)
[ "def", "init", "(", "mpstate", ")", ":", "return", "SerialModule", "(", "mpstate", ")" ]
initialise module .
train
false
23,800
def _on_raw(func_name): def wrapped(self, *args, **kwargs): args = list(args) try: string = args.pop(0) if hasattr(string, '_raw_string'): args.insert(0, string.raw()) else: args.insert(0, string) except IndexError: pass result = getattr(self._raw_string, func_name)(*args, **kwargs) if is...
[ "def", "_on_raw", "(", "func_name", ")", ":", "def", "wrapped", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "args", "=", "list", "(", "args", ")", "try", ":", "string", "=", "args", ".", "pop", "(", "0", ")", "if", "hasattr", ...
like query_super .
train
false
23,802
@cache_permission def can_edit_project(user, project): return check_permission(user, project, 'trans.change_project')
[ "@", "cache_permission", "def", "can_edit_project", "(", "user", ",", "project", ")", ":", "return", "check_permission", "(", "user", ",", "project", ",", "'trans.change_project'", ")" ]
checks whether user can edit given project .
train
false
23,804
@utils.arg('snapshot_id', metavar='<snapshot-id>', help='ID of the snapshot to delete.') @utils.service_type('monitor') def do_snapshot_delete(cs, args): snapshot = _find_monitor_snapshot(cs, args.snapshot_id) snapshot.delete()
[ "@", "utils", ".", "arg", "(", "'snapshot_id'", ",", "metavar", "=", "'<snapshot-id>'", ",", "help", "=", "'ID of the snapshot to delete.'", ")", "@", "utils", ".", "service_type", "(", "'monitor'", ")", "def", "do_snapshot_delete", "(", "cs", ",", "args", ")"...
remove a snapshot .
train
false
23,805
def message_url_path(course_key, access_point): return RestrictedCourse.message_url_path(course_key, access_point)
[ "def", "message_url_path", "(", "course_key", ",", "access_point", ")", ":", "return", "RestrictedCourse", ".", "message_url_path", "(", "course_key", ",", "access_point", ")" ]
determine the url path for the message explaining why the user was blocked .
train
false
23,806
def test_one_image_peak(): image = np.ones((5, 5)) image[(2, 2)] = 2 mask = (np.ones((5, 5)) * 3) assert_close(reconstruction(image, mask), 2)
[ "def", "test_one_image_peak", "(", ")", ":", "image", "=", "np", ".", "ones", "(", "(", "5", ",", "5", ")", ")", "image", "[", "(", "2", ",", "2", ")", "]", "=", "2", "mask", "=", "(", "np", ".", "ones", "(", "(", "5", ",", "5", ")", ")",...
test reconstruction with one peak pixel .
train
false
23,809
def copyFile(srcFile, destFile): try: shutil.copyfile(srcFile, destFile) shutil.copymode(srcFile, destFile) except OSError as e: raise
[ "def", "copyFile", "(", "srcFile", ",", "destFile", ")", ":", "try", ":", "shutil", ".", "copyfile", "(", "srcFile", ",", "destFile", ")", "shutil", ".", "copymode", "(", "srcFile", ",", "destFile", ")", "except", "OSError", "as", "e", ":", "raise" ]
copy a file from source to destination .
train
false
23,811
def _sizeof_fmt(num): for unit in ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']: if (num < 1024.0): return '{0:3.1f} {1}'.format(num, unit) num /= 1024.0
[ "def", "_sizeof_fmt", "(", "num", ")", ":", "for", "unit", "in", "[", "'bytes'", ",", "'KB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", ",", "'PB'", "]", ":", "if", "(", "num", "<", "1024.0", ")", ":", "return", "'{0:3.1f} {1}'", ".", "format", "(", ...
return disk format size data .
train
false
23,812
def _db_documents_for(locale, topics=None, products=None): qs = Document.objects.filter(locale=locale, is_archived=False, current_revision__isnull=False, category__in=settings.IA_DEFAULT_CATEGORIES) for topic in (topics or []): qs = qs.filter(topics=topic) for product in (products or []): qs = qs.filter(products...
[ "def", "_db_documents_for", "(", "locale", ",", "topics", "=", "None", ",", "products", "=", "None", ")", ":", "qs", "=", "Document", ".", "objects", ".", "filter", "(", "locale", "=", "locale", ",", "is_archived", "=", "False", ",", "current_revision__isn...
db implementation of documents_for .
train
false
23,814
def cleanedUpGenericNetwork(original_network): network = caffe_pb2.NetParameter() network.CopyFrom(original_network) for (i, layer) in enumerate(network.layer): if ('Data' in layer.type): assert (layer.type in ['Data']), ('Unsupported data layer type %s' % layer.type) elif (layer.type == 'Input'): del netw...
[ "def", "cleanedUpGenericNetwork", "(", "original_network", ")", ":", "network", "=", "caffe_pb2", ".", "NetParameter", "(", ")", "network", ".", "CopyFrom", "(", "original_network", ")", "for", "(", "i", ",", "layer", ")", "in", "enumerate", "(", "network", ...
perform a few cleanup routines on a generic network returns a new netparameter .
train
false
23,815
def serialize_query_with_map_builtin_function(test, serial, fcn): t = symbol('t', discover(iris)) expr = t.species.map(fcn, 'int') query = {'expr': to_tree(expr)} response = test.post('/compute', data=serial.dumps(query), headers=mimetype(serial)) assert ('OK' in response.status) respdata = serial.loads(response....
[ "def", "serialize_query_with_map_builtin_function", "(", "test", ",", "serial", ",", "fcn", ")", ":", "t", "=", "symbol", "(", "'t'", ",", "discover", "(", "iris", ")", ")", "expr", "=", "t", ".", "species", ".", "map", "(", "fcn", ",", "'int'", ")", ...
serialize a query that invokes the map operation using a builtin function return the result of the post operation along with expected result .
train
false
23,817
def checks_list(): application_url = _get_application_url() log.debug('[uptime] get checks') jcontent = requests.get('{0}/api/checks'.format(application_url)).json() return [x['url'] for x in jcontent]
[ "def", "checks_list", "(", ")", ":", "application_url", "=", "_get_application_url", "(", ")", "log", ".", "debug", "(", "'[uptime] get checks'", ")", "jcontent", "=", "requests", ".", "get", "(", "'{0}/api/checks'", ".", "format", "(", "application_url", ")", ...
list url checked by uptime cli example: .
train
true
23,818
def _categories_level(keys): res = [] for i in zip(*keys): tuplefied = _tuplify(i) res.append(list(OrderedDict([(j, None) for j in tuplefied]))) return res
[ "def", "_categories_level", "(", "keys", ")", ":", "res", "=", "[", "]", "for", "i", "in", "zip", "(", "*", "keys", ")", ":", "tuplefied", "=", "_tuplify", "(", "i", ")", "res", ".", "append", "(", "list", "(", "OrderedDict", "(", "[", "(", "j", ...
use the ordered dict to implement a simple ordered set return each level of each category [[key_1_level_1 .
train
false
23,819
def _get_changed_files(): if (not ci_diff_helper): return None try: config = ci_diff_helper.get_config() except OSError: return None changed_files = ci_diff_helper.get_changed_files('HEAD', config.base) changed_files = set(['./{}'.format(filename) for filename in changed_files]) return changed_files
[ "def", "_get_changed_files", "(", ")", ":", "if", "(", "not", "ci_diff_helper", ")", ":", "return", "None", "try", ":", "config", "=", "ci_diff_helper", ".", "get_config", "(", ")", "except", "OSError", ":", "return", "None", "changed_files", "=", "ci_diff_h...
returns a list of files changed for this pull request / push .
train
false
23,820
def send_file(name, data): nf = NetlogFile(name) nf.sock.sendall(data) nf.close()
[ "def", "send_file", "(", "name", ",", "data", ")", ":", "nf", "=", "NetlogFile", "(", "name", ")", "nf", ".", "sock", ".", "sendall", "(", "data", ")", "nf", ".", "close", "(", ")" ]
send a file-like object to the request output .
train
false
23,821
def MERGE_SQUARES(writer, segments): from whoosh.filedb.filereading import SegmentReader sizedsegs = [(s.doc_count_all(), s) for s in segments] tomerge = [] for size in (10, 100, 1000, 10000, 100000): smaller = [seg for (segsize, seg) in sizedsegs if ((segsize < (size - 1)) and (segsize >= (size // 10)))] if (l...
[ "def", "MERGE_SQUARES", "(", "writer", ",", "segments", ")", ":", "from", "whoosh", ".", "filedb", ".", "filereading", "import", "SegmentReader", "sizedsegs", "=", "[", "(", "s", ".", "doc_count_all", "(", ")", ",", "s", ")", "for", "s", "in", "segments"...
this is an alternative merge policy similar to lucenes .
train
false
23,822
def FITSFactory(image_ext): if (not isinstance(image_ext, tuple)): raise TypeError('Expected a tuple') if (len(image_ext) != 2): raise ValueError('Expected a tuple of length 2') filename = image_ext[0] extnum = image_ext[1] if ((type(filename) is not str) or (type(extnum) is not int)): raise ValueError('Expe...
[ "def", "FITSFactory", "(", "image_ext", ")", ":", "if", "(", "not", "isinstance", "(", "image_ext", ",", "tuple", ")", ")", ":", "raise", "TypeError", "(", "'Expected a tuple'", ")", "if", "(", "len", "(", "image_ext", ")", "!=", "2", ")", ":", "raise"...
load an image extension from a fits file and return a numpy array parameters image_ext : tuple fits extension to load .
train
false
23,823
def relevent_issue(issue, after): return (closed_issue(issue, after) and issue_completed(issue) and issue_section(issue))
[ "def", "relevent_issue", "(", "issue", ",", "after", ")", ":", "return", "(", "closed_issue", "(", "issue", ",", "after", ")", "and", "issue_completed", "(", "issue", ")", "and", "issue_section", "(", "issue", ")", ")" ]
returns true iff this issue is something we should show in the changelog .
train
true
23,824
def parse_blob_info(field_storage): if (field_storage is None): return None field_name = field_storage.name def get_value(dct, name): value = dct.get(name, None) if (value is None): raise BlobInfoParseError(('Field %s has no %s.' % (field_name, name))) return value filename = get_value(field_storage.disp...
[ "def", "parse_blob_info", "(", "field_storage", ")", ":", "if", "(", "field_storage", "is", "None", ")", ":", "return", "None", "field_name", "=", "field_storage", ".", "name", "def", "get_value", "(", "dct", ",", "name", ")", ":", "value", "=", "dct", "...
parse a blobinfo record from file upload field_storage .
train
true
23,825
def _view_on_get(request): return ((request.method == 'GET') and acl.action_allowed(request, 'ReviewerTools', 'View'))
[ "def", "_view_on_get", "(", "request", ")", ":", "return", "(", "(", "request", ".", "method", "==", "'GET'", ")", "and", "acl", ".", "action_allowed", "(", "request", ",", "'ReviewerTools'", ",", "'View'", ")", ")" ]
return true if the user can access this page .
train
false
23,827
def unregister_account_page_class(page_cls): warn(u'unregister_account_page_class is deprecated in Review Board 3.0 and will be removed; use AccountPage.registry.unregister instead.', DeprecationWarning) AccountPage.registry.unregister(page_cls)
[ "def", "unregister_account_page_class", "(", "page_cls", ")", ":", "warn", "(", "u'unregister_account_page_class is deprecated in Review Board 3.0 and will be removed; use AccountPage.registry.unregister instead.'", ",", "DeprecationWarning", ")", "AccountPage", ".", "registry", ".", ...
unregister a previously registered account page class .
train
false
23,828
def get_dpi(raise_error=True): display = quartz.CGMainDisplayID() mm = quartz.CGDisplayScreenSize(display) px = quartz.CGDisplayBounds(display).size return ((((px.width / mm.width) + (px.height / mm.height)) * 0.5) * 25.4)
[ "def", "get_dpi", "(", "raise_error", "=", "True", ")", ":", "display", "=", "quartz", ".", "CGMainDisplayID", "(", ")", "mm", "=", "quartz", ".", "CGDisplayScreenSize", "(", "display", ")", "px", "=", "quartz", ".", "CGDisplayBounds", "(", "display", ")",...
get screen dpi from the os parameters raise_error : bool if true .
train
true
23,829
def get_random_sequence(length, exclude=None): seen = set() def add_seen(kmer): seen.add(kmer) seen.add(revcomp(kmer)) if (exclude is not None): for pos in range(0, (len(exclude) - K)): add_seen(exclude[pos:((pos + K) - 1)]) seq = [random.choice('ACGT') for _ in range((K - 1))] add_seen(''.join(seq)) whi...
[ "def", "get_random_sequence", "(", "length", ",", "exclude", "=", "None", ")", ":", "seen", "=", "set", "(", ")", "def", "add_seen", "(", "kmer", ")", ":", "seen", ".", "add", "(", "kmer", ")", "seen", ".", "add", "(", "revcomp", "(", "kmer", ")", ...
generate a random nucleotide sequence .
train
false
23,830
def get_net(t): return (100 * (0.5 + (0.5 * np.sin(((0.7 * np.pi) * (t - 0.1))))))
[ "def", "get_net", "(", "t", ")", ":", "return", "(", "100", "*", "(", "0.5", "+", "(", "0.5", "*", "np", ".", "sin", "(", "(", "(", "0.7", "*", "np", ".", "pi", ")", "*", "(", "t", "-", "0.1", ")", ")", ")", ")", ")", ")" ]
returns an instance of caffe .
train
false
23,831
def yield_fixture(scope='function', params=None, autouse=False, ids=None, name=None): if (callable(scope) and (params is None) and (not autouse)): return FixtureFunctionMarker('function', params, autouse, ids=ids, name=name)(scope) else: return FixtureFunctionMarker(scope, params, autouse, ids=ids, name=name)
[ "def", "yield_fixture", "(", "scope", "=", "'function'", ",", "params", "=", "None", ",", "autouse", "=", "False", ",", "ids", "=", "None", ",", "name", "=", "None", ")", ":", "if", "(", "callable", "(", "scope", ")", "and", "(", "params", "is", "N...
decorator to mark a yield-fixture factory function .
train
false
23,832
def get_group_info_for_cohort(cohort, use_cached=False): request_cache = RequestCache.get_request_cache() cache_key = u'cohorts.get_group_info_for_cohort.{}'.format(cohort.id) if (use_cached and (cache_key in request_cache.data)): return request_cache.data[cache_key] request_cache.data.pop(cache_key, None) try: ...
[ "def", "get_group_info_for_cohort", "(", "cohort", ",", "use_cached", "=", "False", ")", ":", "request_cache", "=", "RequestCache", ".", "get_request_cache", "(", ")", "cache_key", "=", "u'cohorts.get_group_info_for_cohort.{}'", ".", "format", "(", "cohort", ".", "i...
get the ids of the group and partition to which this cohort has been linked as a tuple of .
train
false
23,835
def new(rsa_key): return PKCS115_SigScheme(rsa_key)
[ "def", "new", "(", "rsa_key", ")", ":", "return", "PKCS115_SigScheme", "(", "rsa_key", ")" ]
returns a form for a new imageclassificationdatasetjob .
train
false
23,836
def writeDataRow(output_file, session_info, session_uservar_names, event_data): session_data = [str(i) for i in session_info[:(-1)]] session_user_data = [session_info.user_variables[sud_name] for sud_name in session_uservar_names] all_data = (((session_data + session_user_data) + [str(e) for e in event_data]) + sess...
[ "def", "writeDataRow", "(", "output_file", ",", "session_info", ",", "session_uservar_names", ",", "event_data", ")", ":", "session_data", "=", "[", "str", "(", "i", ")", "for", "i", "in", "session_info", "[", ":", "(", "-", "1", ")", "]", "]", "session_...
save a row of data to the output file .
train
false
23,837
def data_sharing_consent_requirement_at_login(request): if (not enterprise_enabled()): return None if data_sharing_consent_required_at_login(request): return 'required' if data_sharing_consent_requested(request): return 'optional' return None
[ "def", "data_sharing_consent_requirement_at_login", "(", "request", ")", ":", "if", "(", "not", "enterprise_enabled", "(", ")", ")", ":", "return", "None", "if", "data_sharing_consent_required_at_login", "(", "request", ")", ":", "return", "'required'", "if", "data_...
returns either optional or required based on where we are .
train
false
23,838
def not26(func): @wraps(func) def errfunc(*args, **kwargs): raise NotImplementedError if (hexversion < 34013184): return errfunc else: return func
[ "def", "not26", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "errfunc", "(", "*", "args", ",", "**", "kwargs", ")", ":", "raise", "NotImplementedError", "if", "(", "hexversion", "<", "34013184", ")", ":", "return", "errfunc", "else", ...
function decorator for methods not implemented in python 2 .
train
true
23,840
def _run_checker_for_package(checker, package_name, extra_ignore=None): ignore_strings = IGNORE_ERRORS if extra_ignore: ignore_strings += extra_ignore package_path = path_for_import(package_name) for (root, dirs, files) in os.walk(str(package_path)): for f in files: if ((f == u'local_settings.py') or (not f....
[ "def", "_run_checker_for_package", "(", "checker", ",", "package_name", ",", "extra_ignore", "=", "None", ")", ":", "ignore_strings", "=", "IGNORE_ERRORS", "if", "extra_ignore", ":", "ignore_strings", "+=", "extra_ignore", "package_path", "=", "path_for_import", "(", ...
runs the checker function across every python module in the given package .
train
false
23,841
def _custom_getter(resource, resource_id): if (resource == quotasv2.RESOURCE_NAME): return quota.get_tenant_quotas(resource_id)[quotasv2.RESOURCE_NAME]
[ "def", "_custom_getter", "(", "resource", ",", "resource_id", ")", ":", "if", "(", "resource", "==", "quotasv2", ".", "RESOURCE_NAME", ")", ":", "return", "quota", ".", "get_tenant_quotas", "(", "resource_id", ")", "[", "quotasv2", ".", "RESOURCE_NAME", "]" ]
helper function to retrieve resources not served by any plugin .
train
false
23,842
def _validate_mutable_mappings(a, b): if (not (isinstance(a, MutableMapping) and isinstance(b, MutableMapping))): myvars = [] for x in [a, b]: try: myvars.append(dumps(x)) except: myvars.append(to_native(x)) raise AnsibleError("failed to combine variables, expected dicts but got a '{0}' and a '{1}'...
[ "def", "_validate_mutable_mappings", "(", "a", ",", "b", ")", ":", "if", "(", "not", "(", "isinstance", "(", "a", ",", "MutableMapping", ")", "and", "isinstance", "(", "b", ",", "MutableMapping", ")", ")", ")", ":", "myvars", "=", "[", "]", "for", "x...
internal convenience function to ensure arguments are mutablemappings this checks that all arguments are mutablemappings or raises an error :raises ansibleerror: if one of the arguments is not a mutablemapping .
train
false
23,844
def _format_error(error): try: return _format_error_helper(error) except: return json.dumps(error, indent=2, sort_keys=True)
[ "def", "_format_error", "(", "error", ")", ":", "try", ":", "return", "_format_error_helper", "(", "error", ")", "except", ":", "return", "json", ".", "dumps", "(", "error", ",", "indent", "=", "2", ",", "sort_keys", "=", "True", ")" ]
return string to log/print explaining the given error .
train
false
23,845
def distance_indicators(x, epsilon=None, distance=1.5): x = np.asarray(x) nobs = len(x) if ((epsilon is not None) and (epsilon <= 0)): raise ValueError(('Threshold distance must be positive if specified. Got epsilon of %f' % epsilon)) if (distance <= 0): raise ValueError(('Threshold distance must be positive. G...
[ "def", "distance_indicators", "(", "x", ",", "epsilon", "=", "None", ",", "distance", "=", "1.5", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "nobs", "=", "len", "(", "x", ")", "if", "(", "(", "epsilon", "is", "not", "None", ")", "...
calculate all pairwise threshold distance indicators for a time series parameters x : 1d array observations of time series for which heaviside distance indicators are calculated epsilon : scalar .
train
false
23,848
def lock_exists(name): return os.path.exists(get_lock_path(name))
[ "def", "lock_exists", "(", "name", ")", ":", "return", "os", ".", "path", ".", "exists", "(", "get_lock_path", "(", "name", ")", ")" ]
returns true if lock of the given name exists .
train
false
23,849
def getpath(environ): return ''.join([quote(environ.get('SCRIPT_NAME', '')), quote(environ.get('PATH_INFO', ''))])
[ "def", "getpath", "(", "environ", ")", ":", "return", "''", ".", "join", "(", "[", "quote", "(", "environ", ".", "get", "(", "'SCRIPT_NAME'", ",", "''", ")", ")", ",", "quote", "(", "environ", ".", "get", "(", "'PATH_INFO'", ",", "''", ")", ")", ...
builds a path .
train
false
23,850
def degree_mixing_matrix(G, x='out', y='in', weight=None, nodes=None, normalized=True): d = degree_mixing_dict(G, x=x, y=y, nodes=nodes, weight=weight) s = set(d.keys()) for (k, v) in d.items(): s.update(v.keys()) m = max(s) mapping = dict(zip(range((m + 1)), range((m + 1)))) a = dict_to_numpy_array(d, mapping=...
[ "def", "degree_mixing_matrix", "(", "G", ",", "x", "=", "'out'", ",", "y", "=", "'in'", ",", "weight", "=", "None", ",", "nodes", "=", "None", ",", "normalized", "=", "True", ")", ":", "d", "=", "degree_mixing_dict", "(", "G", ",", "x", "=", "x", ...
return mixing matrix for attribute .
train
false
23,851
def is_in(obj, l): for item in l: if (item is obj): return True return False
[ "def", "is_in", "(", "obj", ",", "l", ")", ":", "for", "item", "in", "l", ":", "if", "(", "item", "is", "obj", ")", ":", "return", "True", "return", "False" ]
checks whether an object is one of the item in the list .
train
false
23,852
def recipr(X): x = np.maximum(np.asarray(X).astype(np.float64), 0) return (np.greater(x, 0.0) / (x + np.less_equal(x, 0.0)))
[ "def", "recipr", "(", "X", ")", ":", "x", "=", "np", ".", "maximum", "(", "np", ".", "asarray", "(", "X", ")", ".", "astype", "(", "np", ".", "float64", ")", ",", "0", ")", "return", "(", "np", ".", "greater", "(", "x", ",", "0.0", ")", "/"...
return the reciprocal of an array .
train
false
23,853
def dup_neg(f, K): return [(- coeff) for coeff in f]
[ "def", "dup_neg", "(", "f", ",", "K", ")", ":", "return", "[", "(", "-", "coeff", ")", "for", "coeff", "in", "f", "]" ]
negate a polynomial in k[x] .
train
false
23,854
def db_encrypt_parameters_and_properties(ctxt, encryption_key, batch_size=50, verbose=False): excs = [] excs.extend(_db_encrypt_or_decrypt_template_params(ctxt, encryption_key, True, batch_size, verbose)) excs.extend(_db_encrypt_or_decrypt_resource_prop_data(ctxt, encryption_key, True, batch_size, verbose)) return ...
[ "def", "db_encrypt_parameters_and_properties", "(", "ctxt", ",", "encryption_key", ",", "batch_size", "=", "50", ",", "verbose", "=", "False", ")", ":", "excs", "=", "[", "]", "excs", ".", "extend", "(", "_db_encrypt_or_decrypt_template_params", "(", "ctxt", ","...
encrypt parameters and properties for all templates in db .
train
false
23,856
def initial_state(layer, dimensions=None): if (dimensions is None): return (layer.initial_hidden_state if has_hidden(layer) else None) else: return (matrixify(layer.initial_hidden_state, dimensions) if has_hidden(layer) else None)
[ "def", "initial_state", "(", "layer", ",", "dimensions", "=", "None", ")", ":", "if", "(", "dimensions", "is", "None", ")", ":", "return", "(", "layer", ".", "initial_hidden_state", "if", "has_hidden", "(", "layer", ")", "else", "None", ")", "else", ":",...
initalizes the recurrence relation with an initial hidden state if needed .
train
false
23,857
def drop_user(name): _run_as_pg(('psql -c "DROP USER %(name)s;"' % locals()))
[ "def", "drop_user", "(", "name", ")", ":", "_run_as_pg", "(", "(", "'psql -c \"DROP USER %(name)s;\"'", "%", "locals", "(", ")", ")", ")" ]
drop a postgresql user .
train
false
23,860
def flush_cache(**kwargs): def class_hierarchy(clslist): 'Recursively yield a class hierarchy' for cls in clslist: subclass_list = cls.__subclasses__() if subclass_list: for subcls in class_hierarchy(subclass_list): (yield subcls) else: (yield cls) for cls in class_hierarchy([SharedMemoryMod...
[ "def", "flush_cache", "(", "**", "kwargs", ")", ":", "def", "class_hierarchy", "(", "clslist", ")", ":", "for", "cls", "in", "clslist", ":", "subclass_list", "=", "cls", ".", "__subclasses__", "(", ")", "if", "subclass_list", ":", "for", "subcls", "in", ...
flush idmapper cache .
train
false
23,861
def ADOPT_module_key_flags(module, flag_values=FLAGS): if isinstance(module, str): raise FlagsError(('Received module name %s; expected a module object.' % module)) _InternalDeclareKeyFlags([f.name for f in flag_values._GetKeyFlagsForModule(module.__name__)], flag_values=flag_values) if (module == _GetThisModuleOb...
[ "def", "ADOPT_module_key_flags", "(", "module", ",", "flag_values", "=", "FLAGS", ")", ":", "if", "isinstance", "(", "module", ",", "str", ")", ":", "raise", "FlagsError", "(", "(", "'Received module name %s; expected a module object.'", "%", "module", ")", ")", ...
declares that all flags key to a module are key to the current module .
train
false
23,862
def get_new_device(event, config, device): device_id = slugify(event.device.id_string.lower()) if (device_id in RFX_DEVICES): return if (not config[ATTR_AUTOMATIC_ADD]): return pkt_id = ''.join(('{0:02x}'.format(x) for x in event.data)) _LOGGER.info('Automatic add %s rfxtrx device (Class: %s Sub: %s Packet_id:...
[ "def", "get_new_device", "(", "event", ",", "config", ",", "device", ")", ":", "device_id", "=", "slugify", "(", "event", ".", "device", ".", "id_string", ".", "lower", "(", ")", ")", "if", "(", "device_id", "in", "RFX_DEVICES", ")", ":", "return", "if...
add entity if not exist and the automatic_add is true .
train
false
23,863
def bytes_to_num(bval): num = 0 num += ord((bval[0] << 24)) num += ord((bval[1] << 16)) num += ord((bval[2] << 8)) num += ord(bval[3]) return num
[ "def", "bytes_to_num", "(", "bval", ")", ":", "num", "=", "0", "num", "+=", "ord", "(", "(", "bval", "[", "0", "]", "<<", "24", ")", ")", "num", "+=", "ord", "(", "(", "bval", "[", "1", "]", "<<", "16", ")", ")", "num", "+=", "ord", "(", ...
convert a four byte sequence to an integer .
train
false
23,864
def recommend_for_brands(brands): return []
[ "def", "recommend_for_brands", "(", "brands", ")", ":", "return", "[", "]" ]
return top five recommended brands when given brands to recommend for .
train
false
23,865
def show_interface(call=None, kwargs=None): global netconn if (not netconn): netconn = get_conn(NetworkManagementClient) if (kwargs is None): kwargs = {} if kwargs.get('group'): kwargs['resource_group'] = kwargs['group'] if (kwargs.get('resource_group') is None): kwargs['resource_group'] = config.get_cloud...
[ "def", "show_interface", "(", "call", "=", "None", ",", "kwargs", "=", "None", ")", ":", "global", "netconn", "if", "(", "not", "netconn", ")", ":", "netconn", "=", "get_conn", "(", "NetworkManagementClient", ")", "if", "(", "kwargs", "is", "None", ")", ...
create a network interface .
train
false
23,866
def make_display_brightness_message(brightness): raise ((0 <= brightness <= 255) or AssertionError) return make_message(8, to_7L1M(brightness))
[ "def", "make_display_brightness_message", "(", "brightness", ")", ":", "raise", "(", "(", "0", "<=", "brightness", "<=", "255", ")", "or", "AssertionError", ")", "return", "make_message", "(", "8", ",", "to_7L1M", "(", "brightness", ")", ")" ]
the display brightness is influenced by various parameters like absolute maximum backlight led current .
train
false
23,868
def PlistValueToPlainValue(plist): if isinstance(plist, dict): ret_value = dict() for (key, value) in plist.items(): ret_value[key] = PlistValueToPlainValue(value) return ret_value elif isinstance(plist, list): return [PlistValueToPlainValue(value) for value in plist] elif isinstance(plist, binplist.RawVa...
[ "def", "PlistValueToPlainValue", "(", "plist", ")", ":", "if", "isinstance", "(", "plist", ",", "dict", ")", ":", "ret_value", "=", "dict", "(", ")", "for", "(", "key", ",", "value", ")", "in", "plist", ".", "items", "(", ")", ":", "ret_value", "[", ...
takes the plist contents generated by binplist and returns a plain dict .
train
false
23,869
def f_oneway(*args): return _f_oneway(*args)[0]
[ "def", "f_oneway", "(", "*", "args", ")", ":", "return", "_f_oneway", "(", "*", "args", ")", "[", "0", "]" ]
performs a 1-way anova .
train
false
23,871
def reindex_questions_answers(sender, instance, **kw): if instance.id: answer_ids = instance.answers.all().values_list('id', flat=True) index_task.delay(AnswerMetricsMappingType, list(answer_ids))
[ "def", "reindex_questions_answers", "(", "sender", ",", "instance", ",", "**", "kw", ")", ":", "if", "instance", ".", "id", ":", "answer_ids", "=", "instance", ".", "answers", ".", "all", "(", ")", ".", "values_list", "(", "'id'", ",", "flat", "=", "Tr...
when a question is saved .
train
false
23,873
def getDocBlockRegion(view, point): start = end = point while ((start > 0) and (view.scope_name((start - 1)).find('comment.block') > (-1))): start = (start - 1) while ((end < view.size()) and (view.scope_name(end).find('comment.block') > (-1))): end = (end + 1) return sublime.Region(start, end)
[ "def", "getDocBlockRegion", "(", "view", ",", "point", ")", ":", "start", "=", "end", "=", "point", "while", "(", "(", "start", ">", "0", ")", "and", "(", "view", ".", "scope_name", "(", "(", "start", "-", "1", ")", ")", ".", "find", "(", "'comme...
given a starting point inside a docblock .
train
false
23,875
def mu_law_decode(output, quantization_channels): with tf.name_scope('decode'): mu = (quantization_channels - 1) casted = tf.cast(output, tf.float32) signal = ((2 * (casted / mu)) - 1) magnitude = ((1 / mu) * (((1 + mu) ** abs(signal)) - 1)) return (tf.sign(signal) * magnitude)
[ "def", "mu_law_decode", "(", "output", ",", "quantization_channels", ")", ":", "with", "tf", ".", "name_scope", "(", "'decode'", ")", ":", "mu", "=", "(", "quantization_channels", "-", "1", ")", "casted", "=", "tf", ".", "cast", "(", "output", ",", "tf",...
recovers waveform from quantized values .
train
false
23,876
def identityResponse(): a = TpPd(pd=3) b = MessageType(mesType=22) c = MobileId() packet = ((a / b) / c) return packet
[ "def", "identityResponse", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "3", ")", "b", "=", "MessageType", "(", "mesType", "=", "22", ")", "c", "=", "MobileId", "(", ")", "packet", "=", "(", "(", "a", "/", "b", ")", "/", "c", ")", "return...
identity response section 9 .
train
true
23,878
def _format_comments(comments): ret = '. '.join(comments) if (len(comments) > 1): ret += '.' return ret
[ "def", "_format_comments", "(", "comments", ")", ":", "ret", "=", "'. '", ".", "join", "(", "comments", ")", "if", "(", "len", "(", "comments", ")", ">", "1", ")", ":", "ret", "+=", "'.'", "return", "ret" ]
return a joined list .
train
false
23,879
def CheckLocation(): for url in (config_lib.CONFIG['Client.server_urls'] + config_lib.CONFIG['Client.control_urls']): if (('staging' in url) or ('localhost' in url)): return logging.error('Poolclient should only be run against test or staging.') exit()
[ "def", "CheckLocation", "(", ")", ":", "for", "url", "in", "(", "config_lib", ".", "CONFIG", "[", "'Client.server_urls'", "]", "+", "config_lib", ".", "CONFIG", "[", "'Client.control_urls'", "]", ")", ":", "if", "(", "(", "'staging'", "in", "url", ")", "...
checks that the poolclient is not accidentally ran against production .
train
false
23,881
def map_int_to_tour(num_nodes, i, start_node): nodes_remaining = (range(0, start_node) + range((start_node + 1), num_nodes)) tour = [] while (len(nodes_remaining) > 0): num_nodes = len(nodes_remaining) next_step = nodes_remaining[(i % num_nodes)] nodes_remaining.remove(next_step) tour.append(next_step) i =...
[ "def", "map_int_to_tour", "(", "num_nodes", ",", "i", ",", "start_node", ")", ":", "nodes_remaining", "=", "(", "range", "(", "0", ",", "start_node", ")", "+", "range", "(", "(", "start_node", "+", "1", ")", ",", "num_nodes", ")", ")", "tour", "=", "...
gets a unique tour through a graph given an integer and starting node .
train
false
23,882
def getNewRepository(): return ExportRepository()
[ "def", "getNewRepository", "(", ")", ":", "return", "ExportRepository", "(", ")" ]
get the repository constructor .
train
false
23,883
def csv_mapping_parser(path, template): mapping_blocks = defaultdict(dict) with open(path, 'r') as handle: reader = csv.reader(handle) reader.next() for row in reader: mapping = dict(zip(template, row)) fid = mapping.pop('function') aid = int(mapping['address']) mapping_blocks[aid] = mapping return...
[ "def", "csv_mapping_parser", "(", "path", ",", "template", ")", ":", "mapping_blocks", "=", "defaultdict", "(", "dict", ")", "with", "open", "(", "path", ",", "'r'", ")", "as", "handle", ":", "reader", "=", "csv", ".", "reader", "(", "handle", ")", "re...
given a csv file of the the mapping data for a modbus device .
train
false
23,884
def get_plugins(phase=None, interface=None, category=None, name=None, min_api=None): def matches(plugin): if ((phase is not None) and (phase not in phase_methods)): raise ValueError((u'Unknown phase %s' % phase)) if (phase and (phase not in plugin.phase_handlers)): return False if (interface and (interface...
[ "def", "get_plugins", "(", "phase", "=", "None", ",", "interface", "=", "None", ",", "category", "=", "None", ",", "name", "=", "None", ",", "min_api", "=", "None", ")", ":", "def", "matches", "(", "plugin", ")", ":", "if", "(", "(", "phase", "is",...
helper to get a direct interface to _plugins .
train
false
23,885
def align_block(raw, multiple=4, pad='\x00'): extra = (len(raw) % multiple) if (extra == 0): return raw return (raw + (pad * (multiple - extra)))
[ "def", "align_block", "(", "raw", ",", "multiple", "=", "4", ",", "pad", "=", "'\\x00'", ")", ":", "extra", "=", "(", "len", "(", "raw", ")", "%", "multiple", ")", "if", "(", "extra", "==", "0", ")", ":", "return", "raw", "return", "(", "raw", ...
return raw with enough pad bytes append to ensure its length is a multiple of 4 .
train
false
23,886
def check_freezing_date(posting_date, adv_adj=False): if (not adv_adj): acc_frozen_upto = frappe.db.get_value(u'Accounts Settings', None, u'acc_frozen_upto') if acc_frozen_upto: frozen_accounts_modifier = frappe.db.get_value(u'Accounts Settings', None, u'frozen_accounts_modifier') if ((getdate(posting_date) ...
[ "def", "check_freezing_date", "(", "posting_date", ",", "adv_adj", "=", "False", ")", ":", "if", "(", "not", "adv_adj", ")", ":", "acc_frozen_upto", "=", "frappe", ".", "db", ".", "get_value", "(", "u'Accounts Settings'", ",", "None", ",", "u'acc_frozen_upto'"...
nobody can do gl entries where posting date is before freezing date except authorized person .
train
false
23,888
def hazard(): return s3_rest_controller()
[ "def", "hazard", "(", ")", ":", "return", "s3_rest_controller", "(", ")" ]
rest controller .
train
false
23,890
def test_random_report_log_xdist(testdir): pytest.importorskip('xdist') testdir.makepyfile("\n import pytest, time\n @pytest.mark.parametrize('i', list(range(30)))\n def test_x(i):\n assert i != 22\n ") (_, dom) = runandparse(testdir, '-n2') suite_node = dom.find_first_by_tag('tes...
[ "def", "test_random_report_log_xdist", "(", "testdir", ")", ":", "pytest", ".", "importorskip", "(", "'xdist'", ")", "testdir", ".", "makepyfile", "(", "\"\\n import pytest, time\\n @pytest.mark.parametrize('i', list(range(30)))\\n def test_x(i):\\n as...
xdist calls pytest_runtest_logreport as they are executed by the slaves .
train
false
23,891
def conforms_partial_ordering(tuples, sorted_elements): deps = defaultdict(set) for (parent, child) in tuples: deps[parent].add(child) for (i, node) in enumerate(sorted_elements): for n in sorted_elements[i:]: if (node in deps[n]): return False else: return True
[ "def", "conforms_partial_ordering", "(", "tuples", ",", "sorted_elements", ")", ":", "deps", "=", "defaultdict", "(", "set", ")", "for", "(", "parent", ",", "child", ")", "in", "tuples", ":", "deps", "[", "parent", "]", ".", "add", "(", "child", ")", "...
true if the given sorting conforms to the given partial ordering .
train
false
23,892
@should_profile_cpu def stop_cpu_profiling(): cancel_thread(SAVE_THREAD_PTR) dump_data()
[ "@", "should_profile_cpu", "def", "stop_cpu_profiling", "(", ")", ":", "cancel_thread", "(", "SAVE_THREAD_PTR", ")", "dump_data", "(", ")" ]
save profiling information .
train
false
23,893
def generate_signing_key(args): if os.path.exists(args.keyfile): raise esptool.FatalError(('ERROR: Key file %s already exists' % args.keyfile)) sk = ecdsa.SigningKey.generate(curve=ecdsa.NIST256p) with open(args.keyfile, 'wb') as f: f.write(sk.to_pem()) print ('ECDSA NIST256p private key in PEM format written t...
[ "def", "generate_signing_key", "(", "args", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "args", ".", "keyfile", ")", ":", "raise", "esptool", ".", "FatalError", "(", "(", "'ERROR: Key file %s already exists'", "%", "args", ".", "keyfile", ")", "...
generate an ecdsa signing key for signing secure boot images .
train
true
23,894
def get_cohorted_discussions(course, course_settings): cohorted_course_wide_discussions = [] cohorted_inline_discussions = [] course_wide_discussions = [topic['id'] for (__, topic) in course.discussion_topics.items()] all_discussions = get_discussion_categories_ids(course, None, include_all=True) for cohorted_disc...
[ "def", "get_cohorted_discussions", "(", "course", ",", "course_settings", ")", ":", "cohorted_course_wide_discussions", "=", "[", "]", "cohorted_inline_discussions", "=", "[", "]", "course_wide_discussions", "=", "[", "topic", "[", "'id'", "]", "for", "(", "__", "...
returns the course-wide and inline cohorted discussion ids separately .
train
false
23,895
def test_biweight_location_axis(): with NumpyRNGContext(12345): ny = 100 nx = 200 data = normal(5, 2, (ny, nx)) bw = funcs.biweight_location(data, axis=0) bwi = [] for i in range(nx): bwi.append(funcs.biweight_location(data[:, i])) bwi = np.array(bwi) assert_allclose(bw, bwi) bw = funcs.biweight_l...
[ "def", "test_biweight_location_axis", "(", ")", ":", "with", "NumpyRNGContext", "(", "12345", ")", ":", "ny", "=", "100", "nx", "=", "200", "data", "=", "normal", "(", "5", ",", "2", ",", "(", "ny", ",", "nx", ")", ")", "bw", "=", "funcs", ".", "...
test a 2d array with the axis keyword .
train
false
23,896
def skew(a, axis=0, bias=True, nan_policy='propagate'): (a, axis) = _chk_asarray(a, axis) n = a.shape[axis] (contains_nan, nan_policy) = _contains_nan(a, nan_policy) if (contains_nan and (nan_policy == 'omit')): a = ma.masked_invalid(a) return mstats_basic.skew(a, axis, bias) m2 = moment(a, 2, axis) m3 = mome...
[ "def", "skew", "(", "a", ",", "axis", "=", "0", ",", "bias", "=", "True", ",", "nan_policy", "=", "'propagate'", ")", ":", "(", "a", ",", "axis", ")", "=", "_chk_asarray", "(", "a", ",", "axis", ")", "n", "=", "a", ".", "shape", "[", "axis", ...
skew matrix a such that a x v = av for any v .
train
false
23,897
def display_colorbar(): (y, x) = np.mgrid[(-4):2:200j, (-4):2:200j] z = (10 * np.cos(((x ** 2) + (y ** 2)))) cmap = plt.cm.copper ls = LightSource(315, 45) rgb = ls.shade(z, cmap) (fig, ax) = plt.subplots() ax.imshow(rgb, interpolation='bilinear') im = ax.imshow(z, cmap=cmap) im.remove() fig.colorbar(im) ax....
[ "def", "display_colorbar", "(", ")", ":", "(", "y", ",", "x", ")", "=", "np", ".", "mgrid", "[", "(", "-", "4", ")", ":", "2", ":", "200j", ",", "(", "-", "4", ")", ":", "2", ":", "200j", "]", "z", "=", "(", "10", "*", "np", ".", "cos",...
display a correct numeric colorbar for a shaded plot .
train
false
23,898
def create_gs_key_async(filename, rpc=None): if (not isinstance(filename, basestring)): raise TypeError(('filename must be str: %s' % filename)) if (not filename.startswith(GS_PREFIX)): raise ValueError(('filename must start with "/gs/": %s' % filename)) if (not ('/' in filename[4:])): raise ValueError(('filen...
[ "def", "create_gs_key_async", "(", "filename", ",", "rpc", "=", "None", ")", ":", "if", "(", "not", "isinstance", "(", "filename", ",", "basestring", ")", ")", ":", "raise", "TypeError", "(", "(", "'filename must be str: %s'", "%", "filename", ")", ")", "i...
create an encoded key for a google storage file - async version .
train
false
23,899
def serve(request, path, document_root=None, insecure=False, **kwargs): if ((not settings.DEBUG) and (not insecure)): raise ImproperlyConfigured("The staticfiles view can only be used in debug mode or if the the --insecure option of 'runserver' is used") normalized_path = posixpath.normpath(urllib.unquote(path)).ls...
[ "def", "serve", "(", "request", ",", "path", ",", "document_root", "=", "None", ",", "insecure", "=", "False", ",", "**", "kwargs", ")", ":", "if", "(", "(", "not", "settings", ".", "DEBUG", ")", "and", "(", "not", "insecure", ")", ")", ":", "raise...
start development web server .
train
false
23,900
def get_default_gid(uid): if isinstance(uid, int): return pwd.getpwuid(uid).pw_gid return pwd.getpwnam(uid).pw_gid
[ "def", "get_default_gid", "(", "uid", ")", ":", "if", "isinstance", "(", "uid", ",", "int", ")", ":", "return", "pwd", ".", "getpwuid", "(", "uid", ")", ".", "pw_gid", "return", "pwd", ".", "getpwnam", "(", "uid", ")", ".", "pw_gid" ]
return the default group of a specific user .
train
false
23,901
def xmliter(obj, nodename): nodename_patt = re.escape(nodename) HEADER_START_RE = re.compile(('^(.*?)<\\s*%s(?:\\s|>)' % nodename_patt), re.S) HEADER_END_RE = re.compile(('<\\s*/%s\\s*>' % nodename_patt), re.S) text = _body_or_str(obj) header_start = re.search(HEADER_START_RE, text) header_start = (header_start.g...
[ "def", "xmliter", "(", "obj", ",", "nodename", ")", ":", "nodename_patt", "=", "re", ".", "escape", "(", "nodename", ")", "HEADER_START_RE", "=", "re", ".", "compile", "(", "(", "'^(.*?)<\\\\s*%s(?:\\\\s|>)'", "%", "nodename_patt", ")", ",", "re", ".", "S"...
return a iterator of selectors over all nodes of a xml document .
train
false
23,902
def move_task_by_id(task_id, dest, **kwargs): return move_by_idmap({task_id: dest}, **kwargs)
[ "def", "move_task_by_id", "(", "task_id", ",", "dest", ",", "**", "kwargs", ")", ":", "return", "move_by_idmap", "(", "{", "task_id", ":", "dest", "}", ",", "**", "kwargs", ")" ]
find a task by id and move it to another queue .
train
false