query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Check if string is DOI. | def _is_doi(s: str) -> bool:
# Thanks to Andrew Gilmartin
# https://www.crossref.org/blog/dois-and-matching-regular-expressions/
match = re.match(r"^10.\d{4,9}/[-._;()/:A-Z0-9]+$", s, re.IGNORECASE)
return match is not None and match.group() is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_doi(val):\n return doi_regexp.match(val)",
"def check_doi(self, doi, whitespace=False):\n\n result_doi = find_doi_in_string(doi, whitespace=False)\n if result_doi is None:\n raise BadDOI('Supplied DOI \"%s\" fails doi check' % doi)\n return doi",
"def citationContainsD... | [
"0.7488969",
"0.7440188",
"0.714925",
"0.68245476",
"0.64832324",
"0.6425882",
"0.5959589",
"0.59391916",
"0.5873299",
"0.5872265",
"0.5761456",
"0.56798387",
"0.5615351",
"0.5450845",
"0.538753",
"0.53825986",
"0.53386146",
"0.53320277",
"0.53132814",
"0.5291846",
"0.5286768... | 0.7775753 | 0 |
Record a a list of values with a message This would ordinarily be a simple logging call but we want to keep the length below the 1024byte syslog() limitation and we'll format things nicely by repeating our message with as many of the values as will fit. Individual items longer than the maximum length will be truncated. | def log_list(msg, items, level=logging.INFO):
max_len = 1024 - len(msg % "")
cur_len = 0
cur_items = list()
while [ i[:max_len] for i in items]:
i = items.pop()
if cur_len + len(i) + 2 > max_len:
logging.info(msg % ", ".join(cur_items))
cur_len = 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_list(self,list_,level='INFO'):\r\n logger.write('\\n'.join(self._log_list(list_)),level)",
"def log_items(items):\n\tif len(items) < max_print:\n\t\tlogging.info(\"ITEMS : %s\", json.dumps(items))",
"def log(data):\n items = []\n for key, value in data.items():\n if valu... | [
"0.5696648",
"0.5608155",
"0.5443723",
"0.5420646",
"0.54089314",
"0.5396192",
"0.5330755",
"0.5272275",
"0.5223701",
"0.5200594",
"0.51988477",
"0.51007485",
"0.50938785",
"0.50880694",
"0.50863326",
"0.50767",
"0.50661916",
"0.50618315",
"0.50441384",
"0.50441384",
"0.50109... | 0.68468493 | 0 |
Takes a string containing a function name (optionally module qualified) and returns a callable object | def get_callable_from_string(f_name):
try:
mod_name, func_name = get_mod_func(f_name)
if mod_name == "" and func_name == "":
raise AttributeError("%s couldn't be converted to a module or function name" % f_name)
module = __import__(mod_name)
if func_name == "":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_function(\n name: Optional[str]\n) -> Optional[Callable]:\n\n if name is None:\n return None\n\n module_name, function_name = name.rsplit('.', maxsplit=1)\n function_module = import_module(module_name)\n function = getattr(function_module, function_name)\n\n return function"... | [
"0.8083442",
"0.7580737",
"0.7434406",
"0.729488",
"0.7125641",
"0.71237427",
"0.7068043",
"0.70373636",
"0.70373636",
"0.70373636",
"0.69661146",
"0.6811584",
"0.6766658",
"0.6722122",
"0.6643902",
"0.6609364",
"0.6583432",
"0.6550623",
"0.65326846",
"0.652172",
"0.64300007"... | 0.842504 | 0 |
Process commandline options Load our preference file Configure the module path to add Application Support directories | def process_commandline():
parser = OptionParser(__doc__.strip())
support_path = '/Library/' if os.getuid() == 0 else os.path.expanduser('~/Library/')
preference_file = os.path.join(support_path, 'Preferences', 'com.googlecode.pymacadmin.crankd.plist')
module_path = os.path.join(support_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_default_options(options):\n if options.settings:\n os.environ['DJANGO_SETTINGS_MODULE'] = options.settings\n if options.pythonpath:\n sys.path.insert(0, options.pythonpath)",
"def handle_default_options(options):\r\n if options.pythonpath:\r\n sys.path.insert(0, options.p... | [
"0.58928007",
"0.58728385",
"0.58278835",
"0.5781644",
"0.56616193",
"0.5657881",
"0.56356794",
"0.5591852",
"0.55839634",
"0.549272",
"0.5440681",
"0.5421743",
"0.53495336",
"0.53313106",
"0.5330712",
"0.533052",
"0.5324511",
"0.5309815",
"0.530172",
"0.5273749",
"0.52636814... | 0.64287686 | 0 |
Returns an SCDynamicStore instance | def get_sc_store():
return SCDynamicStoreCreate(None, "crankd", handle_sc_event, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_store(self):\n return self._store",
"def get_store(cls):\n store_path = cls.get_store_path()\n store = JsonStore(store_path)\n return store",
"def store(self) -> AbstractStore:\n if self._store is None:\n self._store = SquirrelStore(url=self.url, serialize... | [
"0.6690807",
"0.6508678",
"0.6349258",
"0.6334613",
"0.6252112",
"0.6189263",
"0.61643934",
"0.6145207",
"0.61362004",
"0.6114552",
"0.6102535",
"0.60670835",
"0.5862045",
"0.58321494",
"0.576417",
"0.57110476",
"0.56993306",
"0.5699004",
"0.56539637",
"0.5620685",
"0.5608460... | 0.7644329 | 0 |
This uses the SystemConfiguration framework to get a SCDynamicStore session and register for certain events. See the Apple SystemConfiguration | def add_sc_notifications(sc_config):
keys = sc_config.keys()
try:
for key in keys:
SC_HANDLERS[key] = get_callable_for_event(key, sc_config[key], context="SystemConfiguration: %s" % key)
except AttributeError, exc:
print >> sys.stderr, "Error configuring SystemConfiguration ev... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_events(option, opt_str, value, parser):\n\n print 'On this system SystemConfiguration supports these events:'\n for event in sorted(SCDynamicStoreCopyKeyList(get_sc_store(), '.*')):\n print \"\\t\", event\n\n print\n print \"Standard NSWorkspace Notification messages:\\n\\t\",\n prin... | [
"0.62552756",
"0.59944534",
"0.5809146",
"0.57329583",
"0.56357914",
"0.5449959",
"0.5288311",
"0.51998436",
"0.5171661",
"0.5167567",
"0.5151316",
"0.51286256",
"0.5119769",
"0.5114742",
"0.5100622",
"0.50979435",
"0.5090769",
"0.50819397",
"0.50807416",
"0.50807416",
"0.507... | 0.67034554 | 0 |
Adds an FSEvent notification for the specified path | def add_fs_notification(f_path, callback):
path = os.path.realpath(os.path.expanduser(f_path))
if not os.path.exists(path):
raise AttributeError("Cannot add an FSEvent notification: %s does not exist!" % path)
if not os.path.isdir(path):
path = os.path.dirname(path)
try:
FS_WAT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_path_for_monitoring(self, path, prefix):\n pass",
"def notify(self, path, state):\n pass",
"def do_touch ( self, fspath ):\n return",
"def addFile(self, path):\n\n log.msg(\"Gadget.addFile() is deprecated.\")\n self.paths[path] = path",
"def watch(self, path):\n... | [
"0.59082776",
"0.58192897",
"0.560665",
"0.54811627",
"0.5469362",
"0.5432755",
"0.5429937",
"0.539989",
"0.5324973",
"0.52802205",
"0.52584153",
"0.5191449",
"0.51587826",
"0.5105778",
"0.5098983",
"0.5091211",
"0.50629324",
"0.50444824",
"0.5042128",
"0.49974626",
"0.498798... | 0.8187547 | 0 |
Process an FSEvent (consult the Cocoa docs) and call each of our handlers which monitors that path or a parent | def fsevent_callback(stream_ref, full_path, event_count, paths, masks, ids):
for i in range(event_count):
path = os.path.dirname(paths[i])
if masks[i] & kFSEventStreamEventFlagMustScanSubDirs:
recursive = True
if masks[i] & kFSEventStreamEventFlagUserDropped:
loggin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handleEvent(self, event):\n for child in self.children:\n child.handleEvent(event)",
"def process_event(self, event):\r\n pass",
"def processEvent(self, fsm, event, **kwargs):\n handler = self._handlers.get(event, None)\n if handler is not None:\n handler(f... | [
"0.615239",
"0.58786225",
"0.5810463",
"0.5772705",
"0.5769898",
"0.57198673",
"0.56841123",
"0.5683191",
"0.5662394",
"0.5620228",
"0.55959237",
"0.557011",
"0.55215937",
"0.5478375",
"0.545992",
"0.54554105",
"0.5434938",
"0.5430058",
"0.54277456",
"0.53567606",
"0.5332957"... | 0.6339301 | 0 |
Handles the timer events which we use simply to have the runloop run regularly. Currently this logs a timestamp for debugging purposes | def timer_callback(*args):
logging.debug("timer callback at %s" % datetime.now()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timer_handler():\r\n \r\n global elapsed_time\r\n elapsed_time += 1",
"def internal_event (self):\n self.clock_time += 1\n self.log()",
"def timer_tick(self):\n self.timing.timer_tick() # notifies the timing module\n self.events.post('timer_tick') # sends the timer_ti... | [
"0.7081448",
"0.6917902",
"0.6715248",
"0.66538036",
"0.662191",
"0.6619842",
"0.6422403",
"0.639819",
"0.63568836",
"0.6333983",
"0.62987924",
"0.62896055",
"0.6283738",
"0.62059104",
"0.61504054",
"0.61394906",
"0.61167866",
"0.6114388",
"0.61057884",
"0.6050407",
"0.604698... | 0.73614246 | 0 |
Converts input names into more traditional shell environment name style >>> create_env_name("NSApplicationBundleIdentifier") 'NSAPPLICATION_BUNDLE_IDENTIFIER' >>> create_env_name("NSApplicationBundleIdentifier1234$foobar!") 'NSAPPLICATION_BUNDLE_IDENTIFIER_1234_FOOBAR' | def create_env_name(name):
new_name = re.sub(r'''(?<=[a-z])([A-Z])''', '_\\1', name)
new_name = re.sub(r'\W+', '_', new_name)
new_name = re.sub(r'_{2,}', '_', new_name)
return new_name.upper().strip("_") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def env_name(pre_chars='(', post_chars=')'):\n env_path = builtins.__xonsh_env__.get('VIRTUAL_ENV', '')\n if len(env_path) == 0 and xp.ON_ANACONDA:\n env_path = builtins.__xonsh_env__.get('CONDA_DEFAULT_ENV', '')\n env_name = os.path.basename(env_path)\n if env_name:\n return pre_chars + ... | [
"0.7072028",
"0.6389258",
"0.6378341",
"0.6241667",
"0.62210023",
"0.5853845",
"0.58092445",
"0.5706079",
"0.56974334",
"0.5500392",
"0.547317",
"0.5465204",
"0.5386859",
"0.5356315",
"0.5353442",
"0.53214264",
"0.52886957",
"0.52669406",
"0.5264074",
"0.52589834",
"0.5254875... | 0.78384596 | 0 |
Filters YOLO boxes by thresholding on object and class confidence. | def yolo_filter_boxes(box_confidence, boxes, box_class_probs, threshold=.6):
# Step 1: Compute box scores
### START CODE HERE ### (≈ 1 line)
box_scores = box_confidence * box_class_probs
### END CODE HERE ###
# Step 2: Find the box_classes thanks to the max box_scores, keep track of the cor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yolo_filter_boxes(box_confidence, boxes, box_class_probs, threshold=.6):\n\n\t# Step 1: Compute box scores\n\tbox_scores = box_confidence * box_class_probs # [19, 19, 5, 1] * [19, 19, 5, 80] = [19, 19, 5, 80]\n\n\t# Step 2: Find the box_classes thanks to the max box_scores, keep track of the corresponding sco... | [
"0.77095634",
"0.76622283",
"0.760117",
"0.75531733",
"0.69478774",
"0.66959006",
"0.6605738",
"0.65357363",
"0.645577",
"0.633615",
"0.6297718",
"0.6288198",
"0.62573624",
"0.6171029",
"0.61596495",
"0.6126422",
"0.61042315",
"0.6100293",
"0.6069411",
"0.60390794",
"0.603800... | 0.76662046 | 1 |
Reload module (ensuring that CWD is in sys.path). | def reload_from_cwd(module, reloader=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reload(mod,larch=None,**kw):\n\n if isinstance(mod, str):\n return larch.import_module(mod, do_reload=True)\n\n for k,v in chain(larch.symtable._sys.modules.iteritems(), sys.modules.iteritems()):\n if v == mod:\n modname = k\n break\n try:\n return larch.imp... | [
"0.71725005",
"0.69299346",
"0.6911568",
"0.6890375",
"0.6583724",
"0.65417105",
"0.65077513",
"0.6406726",
"0.6327492",
"0.6177538",
"0.61489695",
"0.6141696",
"0.6104401",
"0.6062142",
"0.59237117",
"0.58862835",
"0.58854496",
"0.5871024",
"0.5857107",
"0.58344615",
"0.5831... | 0.8013817 | 0 |
Generate task name from name/module pair. | def gen_task_name(app, name, module_name):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_task_name(cls, addons=None):\n base_name = \".\".join([cls.__module__, cls.__name__])\n extra = ''\n if addons:\n extra = ';%s' % (\", \".join([str(a) for a in addons]))\n return base_name + extra",
"def task_name(self):\n pass",
"def task_name(self) -> str:\n return ... | [
"0.7682546",
"0.72451687",
"0.67556554",
"0.6683679",
"0.66802144",
"0.66363585",
"0.6617958",
"0.64506155",
"0.6445865",
"0.6428004",
"0.63404906",
"0.63163084",
"0.63128716",
"0.6299976",
"0.6273569",
"0.62694097",
"0.61976",
"0.61819285",
"0.6179221",
"0.6120741",
"0.61192... | 0.8859986 | 0 |
Helper function to write DataFrame df to a file at out_path | def write_df_to_disk(df, out_path):
out_dir = os.path.dirname(out_path)
Path(out_dir).mkdir(parents=True, exist_ok=True)
df.to_csv(out_path, index=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_output(df, filename):\n\n logging.info('Writing output')\n\n feather.write_dataframe(df, filename)",
"def save(df, out_file):\n print('------------< save >------------')\n out_path = './data'\n makedirs(out_path, exist_ok=True)\n print(f'path: {out_path}/{out_file}')\n print(f'shap... | [
"0.7982728",
"0.79616106",
"0.79234934",
"0.7657924",
"0.75193864",
"0.7514702",
"0.75081193",
"0.75073874",
"0.7501689",
"0.7464418",
"0.74330616",
"0.7306755",
"0.7269444",
"0.72464305",
"0.70568126",
"0.70323914",
"0.70320594",
"0.69748604",
"0.69482887",
"0.69398254",
"0.... | 0.80903184 | 0 |
Returns the folder where Enso commands are found. This function | def get_script_folder_name():
enso_command_path = os.path.expanduser('~/Library/Application Support/enso/commands')
if (not os.path.isdir(enso_command_path)):
os.makedirs(enso_command_path)
return enso_command_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPath(self):\n path = os.path.dirname(os.path.realpath(__file__)) #Finds the path of the application\n path =(os.path.dirname(os.path.realpath(__file__))+ '\\\\Enigma Settings') #Adds to the directory to create a folder\n \n return path #Returns the folders directory",
"def get_install... | [
"0.7014668",
"0.66876864",
"0.6588057",
"0.65771216",
"0.6507522",
"0.6497156",
"0.6469309",
"0.64583284",
"0.6440784",
"0.6391329",
"0.6358689",
"0.63556904",
"0.6337101",
"0.6325013",
"0.630863",
"0.6307424",
"0.62798166",
"0.62766576",
"0.6272579",
"0.6243662",
"0.6238398"... | 0.7379703 | 0 |
Annotates each opening bracket with the nested level index. | def _annotate_brackets(
self,
tokens: List[tokenize.TokenInfo],
) -> Mapping[int, int]:
brackets = {bracket: 0 for bracket in MATCHING}
for token in tokens:
if token.exact_type in MATCHING.keys():
brackets[token.exact_type] += 1
if token.exact_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addIndents(self, prevLevel=0):\n for num in range(len(self)):\n nextLevel = 0\n if num + 1 < len(self):\n nextLevel = self[num + 1].level\n prevLevel = self[num].addIndents(prevLevel, nextLevel)",
"def _match_brackets(text: str, index_of_open_bracket: in... | [
"0.57791585",
"0.5574875",
"0.54897815",
"0.53925717",
"0.53811973",
"0.52129495",
"0.51941025",
"0.5184101",
"0.5110502",
"0.5095102",
"0.508503",
"0.507386",
"0.5033337",
"0.5019159",
"0.49956527",
"0.49711582",
"0.49661708",
"0.4958856",
"0.49469647",
"0.49339017",
"0.4929... | 0.62899894 | 0 |
Handles logical newline character depending on context. Sets appropriate flags to True if nl encountered inside brackets after some clause, so that a single line comprehension with brackets on multiple lines is still accepted. | def check_nl(self, token: tokenize.TokenInfo) -> None:
self._seen_nl = self.seen_clause_in_line
self.seen_clause_in_line = False
self._seen_for_in_line = False
self._seen_if_in_line = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def try_print_newline(self):\n if self.lasttoken is None:\n return\n\n # Anywhere we writecode does not need the new line character\n no_new_line = {lex.Token.CODE, lex.Token.MULTILINE, lex.Token.ONELINE}\n up_scope = {lex.Token.EXPRESSION, lex.Token.PARENEXPRESSION}\n ... | [
"0.6533808",
"0.60905504",
"0.6086931",
"0.5901122",
"0.5820681",
"0.57478315",
"0.5702475",
"0.5663357",
"0.5645693",
"0.5631956",
"0.5585332",
"0.5582321",
"0.55425584",
"0.5453738",
"0.542495",
"0.5423689",
"0.5420855",
"0.5417257",
"0.53903484",
"0.5335282",
"0.52698195",... | 0.6517785 | 1 |
Adds a violation when a for...in statement is split across lines. Because of the overloaded nature of 'in', we have to rule | def check_in(self, token: tokenize.TokenInfo) -> bool:
if self._seen_for:
if not self._seen_for_in_line:
if not self._seen_if_in_line:
self._reported = True
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testHasForLoop(self):\n no_foreach = build_code(['x=1'], [], ['x=3'], concise=False)\n foreach = build_code(['x=1'], ['x=2'], ['x=3'], concise=False)\n self.assertNotIn('for', no_foreach)\n self.assertIn('for', foreach)",
"def test_37_for(self):\n\t\tinput = \"\"\"function foo():i... | [
"0.54534715",
"0.5340087",
"0.5296133",
"0.5214516",
"0.52088195",
"0.5138647",
"0.5060924",
"0.50440085",
"0.5024554",
"0.49918655",
"0.49755406",
"0.4969769",
"0.49641305",
"0.49313208",
"0.49241373",
"0.48991346",
"0.48187357",
"0.47862616",
"0.47849882",
"0.47669378",
"0.... | 0.5414559 | 1 |
Initializes stack of bracket contexts. Creates an empty stack for bracket contexts to accommodate for nested comprehensions. | def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self._bracket_stack: List[InconsistentComprehensionContext] = []
self._current_ctx: Optional[InconsistentComprehensionContext] = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_empty_stack():\n return Stack(0, None)",
"def __init__(self):\n self._stack = Stack()",
"def __init__(self):\n self.stack = []",
"def __init__(self):\n self.stack = []",
"def __init__(self):\n self.stack = []",
"def __init__(self):\n self.stack = []",
"def... | [
"0.59992033",
"0.5874407",
"0.57490623",
"0.57490623",
"0.57490623",
"0.57490623",
"0.57490623",
"0.57490623",
"0.57490623",
"0.57490623",
"0.57490623",
"0.57490623",
"0.57490623",
"0.5748158",
"0.56922835",
"0.56023157",
"0.5585413",
"0.5585219",
"0.55287755",
"0.5501404",
"... | 0.6778588 | 0 |
Sets self._inside_brackets to True if left bracket found. | def visit_any_left_bracket(self, token: tokenize.TokenInfo) -> None:
self._bracket_stack.append(InconsistentComprehensionContext())
self._current_ctx = self._bracket_stack[-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def whitespace_or_bracket_before():\n d = get_app().current_buffer.document\n return bool(\n d.cursor_position == 0\n or d.char_before_cursor.isspace()\n or d.char_before_cursor in \"([{\"\n )",
"def isLeft(self):\n return self.left",
"def check_for_left(self) -> bool:\n\t\... | [
"0.60813683",
"0.58550274",
"0.5800551",
"0.5731238",
"0.57227486",
"0.5668241",
"0.55835974",
"0.5552061",
"0.5541748",
"0.55388975",
"0.55388975",
"0.5519901",
"0.55025023",
"0.5473584",
"0.54630464",
"0.5410604",
"0.5410123",
"0.5381645",
"0.53460515",
"0.5308878",
"0.5277... | 0.6285612 | 0 |
Interrogate corpus, corpora, subcorpus and file objects. See corpkit.interrogation.interrogate() for docstring | def interrogator(corpus,
search,
query='any',
show='w',
exclude=False,
excludemode='any',
searchmode='all',
dep_type='collapsed-ccprocessed-dependencies',
case_sensitive=False,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interrogator(path,\n search,\n query = 'any', \n show = 'words',\n exclude = False,\n case_sensitive = False,\n lemmatise = False, \n titlefilter = False, \n lemmatag = False, \n ... | [
"0.5888483",
"0.5715347",
"0.56903183",
"0.5548823",
"0.5540298",
"0.5439809",
"0.5359814",
"0.5328422",
"0.52569664",
"0.52407795",
"0.52311546",
"0.5228772",
"0.52283055",
"0.52276486",
"0.5202157",
"0.5201607",
"0.5198235",
"0.51587975",
"0.51382095",
"0.51158184",
"0.5115... | 0.64723754 | 0 |
do the speakerspecific version of tregex queries | def slow_tregex(sents, **dummy_args):
speakr = dummy_args.get('speaker', '')
import os
from corpkit.process import tregex_engine
# first, put the relevant trees into temp file
to_open = '\n'.join(sent.parse_string.strip() for sent in sents \
if sent.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tregex_values():\n\n translated_option = 't'\n if isinstance(search['t'], Wordlist):\n search['t'] = list(search['t'])\n q = tregex_engine(corpus=False,\n query=search.get('t'),\n options=['-t'],\n ch... | [
"0.6598334",
"0.6123778",
"0.60733926",
"0.60444087",
"0.6020305",
"0.59631944",
"0.593435",
"0.5927797",
"0.5781113",
"0.5758964",
"0.57260764",
"0.56976897",
"0.5690832",
"0.5686897",
"0.5676651",
"0.56488115",
"0.5636749",
"0.55857563",
"0.5546409",
"0.55452186",
"0.553844... | 0.67657626 | 0 |
get unique concordance lines | def uniquify(conc_lines):
from collections import OrderedDict
unique_lines = []
checking = []
for index, (_, speakr, start, middle, end) in enumerate(conc_lines):
joined = ' '.join([speakr, start, 'MIDDLEHERE:', middle, ':MIDDLEHERE', end])
if joined not in checki... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_no_repeat_lines_as_string(lines):\n unique_lines = []\n\n for line in lines:\n if len(line[1]) > 0 and not (line[1] in unique_lines):\n unique_lines.append(line[1])\n\n return \"\".join(unique_lines)",
"def countUniqueConsequents(rule_df):\n unique_consequents = []\n for ... | [
"0.6549248",
"0.6015924",
"0.5549715",
"0.5541193",
"0.55044526",
"0.54310316",
"0.5416395",
"0.54156935",
"0.5411469",
"0.5393359",
"0.5389301",
"0.5385189",
"0.5351681",
"0.5347745",
"0.53424466",
"0.53264123",
"0.53142166",
"0.5287698",
"0.5282559",
"0.52744603",
"0.527229... | 0.6829037 | 0 |
Take a list of unicode words and a tag and return a lemmatised list | def lemmatiser(list_of_words, tag):
output = []
for word in list_of_words:
if translated_option.startswith('u'):
word = taglemma.get(word.lower(), 'Other')
else:
word = wordlist.get(word, lmtzr.lemmatize(word, tag))
if not preserve_case... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lemmatiser(list_of_words, tag):\n \n output = []\n for entry in list_of_words:\n if phrases:\n # just get the rightmost word\n word = entry[-1]\n entry.pop()\n else:\n word = entry\n if translated_... | [
"0.78327125",
"0.7143178",
"0.7105679",
"0.69546497",
"0.6923975",
"0.67934495",
"0.6778846",
"0.66946876",
"0.66057914",
"0.6536663",
"0.6528191",
"0.6492946",
"0.64831644",
"0.6475977",
"0.6463908",
"0.64608556",
"0.6451611",
"0.64241594",
"0.6398548",
"0.6393846",
"0.63642... | 0.8035525 | 0 |
Figure out what search function we're using | def determine_search_func(show):
simple_tregex_mode = False
statsmode = False
tree_to_text = False
if search.get('t') and not just_speakers and not kwargs.get('tgrep'):
if have_java:
simple_tregex_mode = True
searcher = None
else:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search():\n pass",
"def search(self, *args, **kwargs): # real signature unknown\n pass",
"def test_determine_search_method(): # ***Incomplete test\n ##########################\n # Arrange.\n query_exten = \"query_exten\"\n db_exten = \"db_exten\"\n\n ##########################\n ... | [
"0.69840384",
"0.6540398",
"0.63770175",
"0.6353729",
"0.62751824",
"0.6189916",
"0.6089244",
"0.6069872",
"0.6022069",
"0.59585744",
"0.5905701",
"0.5905701",
"0.58948123",
"0.57959217",
"0.5786828",
"0.57554525",
"0.5742916",
"0.5719688",
"0.56715596",
"0.55848545",
"0.5543... | 0.6920928 | 1 |
If using Tregex, set appropriate values Check for valid query Make 'any' query Make list query | def get_tregex_values():
translated_option = 't'
if isinstance(search['t'], Wordlist):
search['t'] = list(search['t'])
q = tregex_engine(corpus=False,
query=search.get('t'),
options=['-t'],
check_query=Tru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(self, *qlist):\n\n for i in qlist:\n self.patterns.append('^.*?%s.*?\\s' % i)\n return self",
"def test_multiple_match_any_wildcard_in_literal(self):\n qs = '\"Fo*o t*\"'\n qs_escaped, wildcard = wildcard_escape(qs)\n\n self.assertEqual(\n qs_... | [
"0.5958988",
"0.5939883",
"0.58247966",
"0.5761926",
"0.5738563",
"0.5706575",
"0.57048625",
"0.5687653",
"0.5663917",
"0.56342334",
"0.56223077",
"0.5614278",
"0.5586403",
"0.5540019",
"0.553011",
"0.5473255",
"0.54437816",
"0.5390191",
"0.53859484",
"0.53833526",
"0.5381896... | 0.6348621 | 0 |
search for regex in plaintext corpora it searches over lines, so the user needs to be careful. | def plaintext_regex_search(pattern, plaintext_data, concordancing=False, **kwargs):
import re
if concordancing:
pattern = r'(.{,140})\b(' + pattern + r')\b(.{,140})'
compiled_pattern = compiler(pattern)
if compiled_pattern == 'Bad query':
return 'Bad query'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plaintext_regex_search(pattern, plaintext_data):\n result = []\n #if not pattern.startswith(r'\\b') and not pattern.endswith(r'\\b'):\n #pattern = r'\\b' + pattern + '\\b'\n try:\n compiled_pattern = re.compile(pattern)\n except:\n import traceback\n... | [
"0.6266254",
"0.60613465",
"0.60350335",
"0.5900924",
"0.5739118",
"0.5719736",
"0.5707269",
"0.56813115",
"0.5671053",
"0.5669781",
"0.564275",
"0.56181127",
"0.5590082",
"0.55738795",
"0.5567099",
"0.55560476",
"0.5530935",
"0.5519552",
"0.5513961",
"0.5467003",
"0.54666924... | 0.617954 | 1 |
correct spelling within a string | def correct_spelling(a_string):
if not spelling:
return a_string
from corpkit.dictionaries.word_transforms import usa_convert
if spelling.lower() == 'uk':
usa_convert = {v: k for k, v in list(usa_convert.items())}
bits = a_string.split('/')
for index, i in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_spelling(sample):\n words = nltk.word_tokenize(sample[\"full_text\"])\n for word in words:\n for char, duplicate_char in duplicate_chars.items():\n word = re.sub(duplicate_char, char, word)\n #sample[\"full_text\"] = ' '.join([spell(w)] for w in tweet.split()])\n sample[\"... | [
"0.71682435",
"0.70267934",
"0.70242125",
"0.7003745",
"0.6945178",
"0.68303365",
"0.67460626",
"0.6715815",
"0.66615164",
"0.6615084",
"0.65988404",
"0.654824",
"0.6419127",
"0.63283676",
"0.626048",
"0.6257211",
"0.6255015",
"0.6252652",
"0.6246984",
"0.6243011",
"0.6226713... | 0.74184597 | 0 |
generate a progress bar | def make_progress_bar():
if simple_tregex_mode:
total_files = len(list(to_iterate_over.keys()))
else:
total_files = sum(len(x) for x in list(to_iterate_over.values()))
par_args = {'printstatus': kwargs.get('printstatus', True),
'root': root,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bar(self, progress):\n if not hasattr(self, \"_limit\") or not self._limit:\n self._limit = self.terminal_size()\n graph_progress = int(progress * self._limit)\n self.stdout.write(\"\\r\", ending=\"\")\n progress_format = \"[%-{}s] %d%%\".format(self._limit)\n self... | [
"0.7724847",
"0.7670393",
"0.7637964",
"0.7589866",
"0.7578511",
"0.7515666",
"0.74281526",
"0.7422061",
"0.7408268",
"0.73893464",
"0.7370354",
"0.73700887",
"0.73492914",
"0.7345713",
"0.7331708",
"0.7313536",
"0.7308517",
"0.7232496",
"0.7224645",
"0.7219234",
"0.71974766"... | 0.79598635 | 0 |
Read a public key file from the the state keys directory and return it in a key string format. | def _state_key_file_to_publickey_string(key_file_name):
fullpath = os.path.join(settings.SEATTLECLEARINGHOUSE_STATE_KEYS_DIR, key_file_name)
return rsa.rsa_publickey_to_string(rsa.rsa_file_to_publickey(fullpath)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_key(self):\n\t return open(\"key.key\", \"rb\").read()",
"def public_key(self):\n keyfile = self._get_field('System', 'keyfile')\n return join(self.key_path, keyfile)",
"def rsa_file_to_publickey(filename):\r\n fileobject = file(filename,'r')\r\n publickeystring = fileobject.read()\... | [
"0.7194583",
"0.6979635",
"0.6976253",
"0.6870528",
"0.6829761",
"0.68259186",
"0.68072116",
"0.6757434",
"0.6692691",
"0.6599704",
"0.6480411",
"0.64754915",
"0.64627016",
"0.6445783",
"0.6407686",
"0.6389054",
"0.63005495",
"0.62873834",
"0.6284084",
"0.62804055",
"0.620088... | 0.8570147 | 0 |
Allows the user to download a Android distribution of Seattle that will donate resources to user with 'username'. | def build_android_installer(request, username):
success, return_value = _build_installer(username, "android")
if not success:
error_response = return_value
return error_response
installer_url = return_value
return installer_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_antivirus():\n query = {\n \"type\": \"op\",\n \"cmd\": (\n \"<request><anti-virus><upgrade><download>\"\n \"<latest></latest></download></upgrade></anti-virus></request>\"\n ),\n }\n\n return _get_job_results(query)",
"def package(request, name):\... | [
"0.54345506",
"0.51807845",
"0.51807845",
"0.5172523",
"0.5085657",
"0.50855786",
"0.50675076",
"0.5029689",
"0.50207436",
"0.5004418",
"0.4958991",
"0.4929606",
"0.49105838",
"0.4882021",
"0.4877581",
"0.4856049",
"0.48409528",
"0.4834391",
"0.48332444",
"0.48246512",
"0.481... | 0.62724113 | 0 |
Allows the user to download a Windows distribution of Seattle that will donate resources to user with 'username'. | def build_win_installer(request, username):
success, return_value = _build_installer(username, "windows")
if not success:
error_response = return_value
return error_response
installer_url = return_value
return HttpResponseRedirect(installer_url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_installer(username, platform):\r\n try:\r\n user = interface.get_user_for_installers(username)\r\n username = user.username\r\n except DoesNotExistError:\r\n error_response = HttpResponse(\"Couldn't get user.\")\r\n return False, error_response\r\n\r\n try:\r\n xmlrpc_proxy = xmlrpclib... | [
"0.521585",
"0.517368",
"0.5131205",
"0.5091997",
"0.5064447",
"0.50573826",
"0.49789464",
"0.4934131",
"0.49195322",
"0.49147695",
"0.48605567",
"0.48585278",
"0.48497504",
"0.48097712",
"0.48073697",
"0.48073697",
"0.47945243",
"0.4786354",
"0.4777647",
"0.4776721",
"0.4751... | 0.59728086 | 0 |
Allows the user to download a Linux distribution of Seattle that will donate resources to user with 'username'. | def build_linux_installer(request, username):
success, return_value = _build_installer(username, "linux")
if not success:
error_response = return_value
return error_response
installer_url = return_value
return HttpResponseRedirect(installer_url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_rpm_download(target_userspace_info,\n used_repos,\n tasks,\n xfs_info,\n storage_info,\n plugin_info,\n target_iso=None,\n on_aws=False... | [
"0.54664725",
"0.54026747",
"0.5190029",
"0.51729584",
"0.5134802",
"0.51346374",
"0.51189893",
"0.5117342",
"0.5115091",
"0.51065683",
"0.51021206",
"0.5067577",
"0.5059587",
"0.505202",
"0.5040296",
"0.4981426",
"0.49723926",
"0.49631566",
"0.49269062",
"0.49131846",
"0.490... | 0.6340272 | 0 |
Allows the user to download a Mac distribution of Seattle that will donate resources to user with 'username'. | def build_mac_installer(request, username):
success, return_value = _build_installer(username, "mac")
if not success:
error_response = return_value
return error_response
installer_url = return_value
return HttpResponseRedirect(installer_url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli(date, path, mission):\n download.main(path, mission, date)",
"def download_software_file(filename=None, synch=False):\n if not filename:\n raise CommandExecutionError(\"Filename option must not be none.\")\n\n if not isinstance(synch, bool):\n raise CommandExecutionError(\"Synch op... | [
"0.5531831",
"0.5152475",
"0.50983155",
"0.5010588",
"0.49849537",
"0.49225307",
"0.49126375",
"0.4903317",
"0.48783594",
"0.48682052",
"0.48617488",
"0.4852569",
"0.48408064",
"0.4833493",
"0.4830125",
"0.48116732",
"0.4788062",
"0.47445676",
"0.4735073",
"0.47272393",
"0.46... | 0.6405196 | 0 |
Show the Experiments Registrated Experimenr objects | def viewexperiments(request):
# Obtain the context from the HTTP request.
context_instance = RequestContext(request)
try:
user = _validate_and_get_geniuser(request)
except LoggedInButFailedGetGeniUserError:
return _show_failed_get_geniuser_page(request)
page_top_errors = []
username ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_experiments(self):\n subfolders = self.um.list_subfolders(\"data/*/\")\n experiment_folders = self.um.list_experiments(subfolders)\n experiments = list()\n for exp in experiment_folders:\n try:\n date = self.um.timestamp_to_date(int(exp) / 1000)\n ... | [
"0.6509049",
"0.61315984",
"0.60971254",
"0.60286677",
"0.59629506",
"0.58862746",
"0.58391064",
"0.58109564",
"0.5791251",
"0.5767223",
"0.57372713",
"0.57238495",
"0.5710783",
"0.5648991",
"0.56432927",
"0.5626918",
"0.5608171",
"0.5554109",
"0.5507898",
"0.5480526",
"0.547... | 0.6565462 | 0 |
Builds an installer for the given platform that will donate resources to the user with the given username. | def _build_installer(username, platform):
try:
user = interface.get_user_for_installers(username)
username = user.username
except DoesNotExistError:
error_response = HttpResponse("Couldn't get user.")
return False, error_response
try:
xmlrpc_proxy = xmlrpclib.ServerProxy(settings.SEA... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_win_installer(request, username):\r\n\r\n success, return_value = _build_installer(username, \"windows\")\r\n\r\n if not success:\r\n error_response = return_value\r\n return error_response\r\n\r\n installer_url = return_value\r\n return HttpResponseRedirect(installer_url)",
"def build_androi... | [
"0.6215324",
"0.611576",
"0.5987811",
"0.5949774",
"0.54501987",
"0.54276556",
"0.50957483",
"0.50527024",
"0.5051622",
"0.5019631",
"0.500962",
"0.49261734",
"0.49165192",
"0.49153313",
"0.4894791",
"0.48741162",
"0.48477203",
"0.48438242",
"0.481999",
"0.48024786",
"0.47956... | 0.7527762 | 0 |
Randomly gets winning numbers | def get_winners():
numbers = []
# Randomly get 5 winning numbers
for i in range(0, 5):
if not numbers:
number = random.randrange(1, 71)
while number > 25:
number = random.randrange(1, 71)
else:
numbers.append(number)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_lottery():\n\treturn 0",
"def get_numbers(winning_numbers):\r\n\r\n numbers = []\r\n jackpot = []\r\n count = 1\r\n\r\n # Keep loop going while list is empty (not a winner)\r\n while not jackpot:\r\n # Randomly get 5 numbers. Use enumeration to index numbers list, create conditio... | [
"0.71497434",
"0.6841685",
"0.6770513",
"0.6742104",
"0.66926897",
"0.6657669",
"0.6598102",
"0.6592469",
"0.655984",
"0.65350354",
"0.6530595",
"0.64742345",
"0.64705276",
"0.64642483",
"0.64460814",
"0.6441959",
"0.63983107",
"0.63931024",
"0.6384295",
"0.6370722",
"0.63660... | 0.7870221 | 0 |
Find a possible subsentence according to the given keyword, e.g. NP and PP, and return the result. | def findSubSentence(self, toTree, keyword): #FIXME: under the default grammar weight, this could exceed the maximal depth
words = []
subGrammar = self.grammar.get(keyword, None)
if not subGrammar: # cannot find sub grammar, and this means the keyword must be a terminal
if toTree:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsentence(sentence, start, end):\r\n \r\n sentence_list=re.split(' ', sentence)\r\n return sentence_list[start:end]",
"def extract_phrases_with_keywords(text, keyword):\n sentences = split_text(text)\n phrases = []\n keyword = word_process(keyword)\n for sentence in sentences:\n ... | [
"0.58495724",
"0.5753908",
"0.56309414",
"0.5537737",
"0.5464156",
"0.54408056",
"0.5306136",
"0.5235552",
"0.5201846",
"0.5171426",
"0.5159928",
"0.5120783",
"0.5103705",
"0.51011217",
"0.50527877",
"0.5042506",
"0.5035757",
"0.50015116",
"0.49929184",
"0.4937678",
"0.490139... | 0.7113914 | 0 |
Randomly choose the grammar by the weighted probability. | def weightedRandomChoice(self, keyword):
rules = self.grammar[keyword]
total = sum([pair[0] for pair in rules])
randomNum = random.uniform(0, total)
cumulate = 0
for rule in rules:
cumulate += rule[0]
if cumulate >= randomNum:
return rule[1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_phrase():\n return random.choices(PHRASES, WEIGHTS, k=1)[0]",
"def weighted_choice(items):\n weight_total = sum((item[1] for item in items))\n n = random.uniform(0, weight_total)\n for item, weight in items:\n if n < weight:\n return item\n n = n - weight\n return item",
"def w... | [
"0.71577805",
"0.6517644",
"0.6497557",
"0.6455184",
"0.64502686",
"0.6390017",
"0.63536996",
"0.63029253",
"0.6262877",
"0.6257459",
"0.625137",
"0.62475294",
"0.62170905",
"0.6211756",
"0.62024844",
"0.61946785",
"0.6170615",
"0.61574286",
"0.61357105",
"0.6113679",
"0.6111... | 0.70804936 | 1 |
Print the sentence as a tree structure. | def printTree(cls, sentence, indent, peren):
if not sentence:
return
if sentence[1] is None: # this is a single string, not a grammar
print sentence[0],
return
else:
print "(" + sentence[0],
if type(sentence[1]) is str: # it is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_tree(self):\n\t\tprint(self.__print_tree('', True, ''))",
"def print_tree(node):\n print tree(node)",
"def printTree(self):\r\n print(self.letter)\r\n if self.left:\r\n self.left.printTree()\r\n if self.right:\r\n self.right.printTree()",
"def print_tre... | [
"0.7729245",
"0.74081826",
"0.7387683",
"0.7284739",
"0.72247636",
"0.71699893",
"0.7140745",
"0.71264905",
"0.7107225",
"0.7093896",
"0.7092172",
"0.7024306",
"0.7017479",
"0.6935994",
"0.6921657",
"0.6919154",
"0.6886865",
"0.6877926",
"0.6870467",
"0.68584967",
"0.6851951"... | 0.82239455 | 0 |
Test timeout by mocking a CSV that is slow to open | def test_slow_to_open(self):
from natcap.invest import validation
# make an actual file so that `check_file` will pass
path = os.path.join(self.workspace_dir, 'slow.csv')
with open(path, 'w') as file:
file.write('1,2,3')
spec = {
"mock_csv_path": {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_csvfile_close_not_modified(fs: FakeFilesystem) -> None:\n with freeze_time(\"2022-01-01T00:00:00Z\"):\n fs.create_file(\"test.csv\", contents=CONTENTS)\n\n connection = apsw.Connection(\":memory:\")\n cursor = connection.cursor()\n connection.createmodule(\"csvfile\", VTModule(CSVFile))... | [
"0.6315982",
"0.60688096",
"0.59093183",
"0.57779384",
"0.57387227",
"0.57322454",
"0.5701909",
"0.5700331",
"0.56997144",
"0.5694825",
"0.56218725",
"0.5599623",
"0.5586595",
"0.5584273",
"0.556742",
"0.55632657",
"0.55260414",
"0.55110973",
"0.55033433",
"0.5498571",
"0.546... | 0.7932736 | 0 |
Including extra keys in args that aren't in MODEL_SPEC should work | def test_allow_extra_keys(self):
from natcap.invest import validation
args = {'a': 'a', 'b': 'b'}
spec = {
'a': {
'type': 'freestyle_string',
'name': 'a',
'about': 'a freestyle string',
'required': True
}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extra_target_arguments(self):\n return {}",
"def model_args(self) -> Optional[Dict]:\n return self.config.get('model_args')",
"def get_model_args(args):\r\n global MODEL_ARCHITECTURE, MODEL_OPTIMIZER, ADVANCED_OPTIONS, \\\r\n DATA_OPTIONS, BERT_CONFIG\r\n\r\n required_args = MODEL_AR... | [
"0.62070525",
"0.60104847",
"0.59844923",
"0.5959968",
"0.59498566",
"0.58738023",
"0.58045703",
"0.5759339",
"0.5703959",
"0.56942946",
"0.5677247",
"0.56636554",
"0.5641944",
"0.5599956",
"0.55948186",
"0.5539832",
"0.55177945",
"0.5516183",
"0.55147403",
"0.5508561",
"0.54... | 0.6653259 | 0 |
translates list of tokens into trainable index format. also does padding. | def _tokens_to_index(self,tokens):
wids = []
for tk in tokens:
if tk in self.wtoi.keys():
wids.append(self.wtoi[tk])
else:
wids.append(1) # <UNK>
for _ in range(self.sentence_max_length - len(wids)):
wids.append(0)
if l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collate_tokens(\n values,\n pad_idx,\n eos_idx=None,\n left_pad=False,\n move_eos_to_beginning=False,\n pad_to_length=None,\n pad_to_multiple=1,\n):\n size = max(v.size(0) for v in values)\n size = size if pad_to_length is None else max(size, pad_to_length)\n if pad_to_multiple !=... | [
"0.63890016",
"0.6283487",
"0.6275719",
"0.62290215",
"0.61698973",
"0.61473715",
"0.61390907",
"0.59552914",
"0.59253067",
"0.5893634",
"0.5877626",
"0.5853019",
"0.58448595",
"0.58401644",
"0.58367306",
"0.58242196",
"0.58195466",
"0.58091754",
"0.5806259",
"0.57950723",
"0... | 0.65276206 | 0 |
Test generate_random_sphere_vector to verify that the object normalized_vector is a 3D array with nonzero components and a norm of one. | def test_random_sphere_vector():
test_vector = o_gen_instance.generate_random_sphere_vector()
assert isinstance(test_vector, np.ndarray)
assert test_vector.shape == (3,)
for component in test_vector:
assert component != 0.
assert np.isclose(np.linalg.norm(test_vector), 1.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_sphere():\n vec = np.random.standard_normal(3)\n return vec / np.linalg.norm(vec)",
"def test_norm_vector():\n random_state = np.random.RandomState(0)\n for n in range(1, 6):\n v = pr.random_vector(random_state, n)\n u = pr.norm_vector(v)\n assert_almost_equal(np.linalg.no... | [
"0.79352826",
"0.7224374",
"0.6926471",
"0.6906835",
"0.6901551",
"0.684564",
"0.67936563",
"0.6673033",
"0.6651192",
"0.6604039",
"0.6603412",
"0.6575389",
"0.6544342",
"0.6538467",
"0.6474279",
"0.64473206",
"0.6388019",
"0.6329042",
"0.63280094",
"0.6316557",
"0.63050807",... | 0.90886253 | 0 |
Test generate_solid_angle to verify that the x and y components of the object orientation_vector are within the opening angle size. | def test_orientation_vector():
opening_angle = geom_instance.source_opening_angle
test_orientation = o_gen_instance.generate_orientation_vector()
assert test_orientation[0] < np.cos(opening_angle)
assert test_orientation[1] < np.sin(opening_angle) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_comp_angle_opening(self, test_dict):\n test_obj = test_dict[\"test_obj\"]\n a = test_obj.slot.comp_angle_opening()\n self.assertEqual(a, 2 * pi / test_obj.slot.Zs)\n\n b = comp_angle_opening(test_obj.slot)\n msg = \"Return \" + str(a) + \" expected \" + str(b)\n s... | [
"0.66178",
"0.6446917",
"0.63402283",
"0.6287287",
"0.62780046",
"0.6274058",
"0.6122034",
"0.61118615",
"0.6025408",
"0.60158217",
"0.59966654",
"0.5988399",
"0.595147",
"0.59062386",
"0.58521837",
"0.58085287",
"0.5785771",
"0.5761868",
"0.5744579",
"0.57412726",
"0.5701567... | 0.73199785 | 0 |
Test generate_random_path to make sure that a nonempty array is returned and that the generated particle passes close enough to the panes to be detectable | def test_path_coordinates():
# check that coordinates array is not empty
test_coordinates, _ = path_instance.generate_random_path(trial_samples)
assert test_coordinates.any() != 0.
# check that generated particle has enough samples to go close to panes
# assert
# max(map(lambda p: np.linalg.norm(p.center - geom_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _simulate_random_trajectory(self):\n\n pct_corrupt = np.random.uniform(*[x / 100 for x in self.corrupt_pct_range])\n\n corrupt_matrix_shape = [int(x * math.sqrt(pct_corrupt)) for x in self.phase_encoding_shape]\n # TODO keep this as a vector\n\n if np.prod(corrupt_matrix_shape) == 0... | [
"0.58994585",
"0.5896848",
"0.5839362",
"0.5761",
"0.5715537",
"0.5701637",
"0.5642895",
"0.5611357",
"0.5593065",
"0.5592472",
"0.5591886",
"0.55731374",
"0.55300707",
"0.5529611",
"0.5520355",
"0.5453421",
"0.5438992",
"0.5432719",
"0.54316103",
"0.5418433",
"0.5396537",
... | 0.7637575 | 0 |
Find the last word in a sentence. >>> last_word('abc') 'abc' >>> last_word(' abc') 'abc' >>> last_word('') '' >>> last_word(' ') '' >>> last_word('abc ') '' >>> last_word('abc def') 'def' >>> last_word('abc def ') '' >>> last_word('abc def;') '' >>> last_word('bac $def') 'def' >>> last_word('bac $def', include='most_pu... | def last_word(text, include='alphanum_underscore'):
if not text: # Empty string
return ''
if text[-1].isspace():
return ''
else:
regex = cleanup_regex[include]
matches = regex.search(text)
if matches:
return matches.group(0)
else:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findAlphabeticallyLastWord(text):\n return max(text.split(' '))",
"def last(word):\n return word[-1]",
"def last(word):\n\treturn word[-1]",
"def lengthof_lastword(s):\n a = s.split()\n if a:\n return len(a[len(a)-1])\n return 0",
"def findAlphabeticallyLastWord(text):\n # BEGI... | [
"0.7246695",
"0.70854867",
"0.7032074",
"0.7018031",
"0.69845116",
"0.6942113",
"0.67384136",
"0.66718066",
"0.66049314",
"0.6516773",
"0.64474416",
"0.64474416",
"0.64474416",
"0.6423869",
"0.6391081",
"0.63745224",
"0.63745224",
"0.6356158",
"0.63439316",
"0.6332507",
"0.63... | 0.77969813 | 0 |
Find completion matches for the given text. Given the user's input text and a collection of available completions, find completions matching the last word of the text. If `start_only` is True, the text will match an available completion only at the beginning. Otherwise, a completion is considered a match if the text ap... | def find_matches(text, collection, start_only=False, fuzzy=True, casing=None):
last = last_word(text, include='most_punctuations')
text = last.lower()
completions = []
if fuzzy:
regex = '.*?'.join(map(re.escape, text))
pat = re.compile('(%s)' % regex)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_completion(self, original_text, remaining_text, options):\n if self.should_hide_completions(original_text=original_text,\n remaining_text=remaining_text,\n allowed_suffixes=(\" \", \".\")):\n return []\n\n ... | [
"0.5681952",
"0.5329823",
"0.527169",
"0.52684486",
"0.5164248",
"0.5139905",
"0.5139905",
"0.5129241",
"0.51232123",
"0.5080964",
"0.5075695",
"0.50329864",
"0.50222737",
"0.49978027",
"0.49869835",
"0.4973639",
"0.49638003",
"0.49585158",
"0.49314818",
"0.49203762",
"0.4902... | 0.659969 | 0 |
method to unbind Invoice Order button in sale order tree view | def hide_invoice_order_button(self):
invoice_order_action = self.env.ref('sale.action_view_sale_advance_payment_inv')
if invoice_order_action and invoice_order_action.binding_model_id:
invoice_order_action.binding_model_id = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clicked_no_button(self):\n self.yes = False",
"def do_cancel(order):\r\n self.gox.cancel(order.oid)",
"def cancelOrder(self, order_number):\n pass",
"def deactivate(self):\n pass",
"def close_orders(self):",
"def on_ResetNode_clicked(self):\n # TODO: not implemente... | [
"0.5542315",
"0.52975225",
"0.5288304",
"0.5265517",
"0.52560776",
"0.5250886",
"0.5233528",
"0.52241683",
"0.5201242",
"0.5200846",
"0.51826864",
"0.51785576",
"0.5140167",
"0.5122764",
"0.5122764",
"0.5091585",
"0.5089606",
"0.5089606",
"0.5089606",
"0.50870603",
"0.5079905... | 0.7226724 | 0 |
This function returns the ISO code of the given state. | def get_iso(state):
return len_states[np.where(len_states == state)[0][0], 2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_state_code(self, data) -> int:\n return int(self.state)",
"def USCode(self, short):\n states = {\n 'AK': 'Alaska',\n 'AL': 'Alabama',\n 'AR': 'Arkansas',\n 'AS': 'American Samoa',\n 'AZ': 'Arizona',\n 'CA': 'California',\n ... | [
"0.6684515",
"0.6432416",
"0.64258087",
"0.6385586",
"0.63366586",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
"0.6151007",
... | 0.73081714 | 0 |
This function returns the number of counties in the given state. | def get_len(state):
return int(len_states[np.where(len_states == state)[0][0], 1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_by_state(tweets):\n \n \n s_d=dict()\n name_state=us_states\n for state in name_state:\n s_d[state]=0\n for each in tweets:\n if is_in_state(tweet_location(each), us_states[state])==True:\n s_d[state]=s_d[state]+1\n return s_d",
"def get_num_us_s... | [
"0.72020936",
"0.68704325",
"0.6869267",
"0.68514353",
"0.68275386",
"0.6737331",
"0.664857",
"0.6646284",
"0.65354186",
"0.65067595",
"0.6463262",
"0.64268917",
"0.64082",
"0.6259778",
"0.6248315",
"0.62121034",
"0.6191806",
"0.61886036",
"0.6184314",
"0.61780035",
"0.613613... | 0.71312994 | 1 |
This function iterates over the states and methods and weight functions to create 4 dendrograms to each state. | def loop_plot_dendrogram_by_state():
for state in states:
if state != 'District of Columbia':
plot_dendrogram_by_state(state) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_dendrogram_national():\n print 'Creating the national migration dendrogram'\n for method in ['NR']:\n for weight_fc in ['col', 'row']:\n mat = np.loadtxt('ultra_metric/%s_u%s.csv' % (weight_fc, method),\n dtype=float, delimiter=',')\n plot_den... | [
"0.6001535",
"0.56457",
"0.55670285",
"0.55670285",
"0.55265206",
"0.550452",
"0.54861224",
"0.5476622",
"0.5380023",
"0.5321008",
"0.5278257",
"0.5264836",
"0.5252763",
"0.5246792",
"0.52422607",
"0.5237678",
"0.5232249",
"0.5226519",
"0.5218285",
"0.51863045",
"0.5171666",
... | 0.65117216 | 0 |
This function creates the national migration flow dendrogram. | def plot_dendrogram_national():
print 'Creating the national migration dendrogram'
for method in ['NR']:
for weight_fc in ['col', 'row']:
mat = np.loadtxt('ultra_metric/%s_u%s.csv' % (weight_fc, method),
dtype=float, delimiter=',')
plot_dendrogram_by_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dendogram(self):\r\n \r\n plt.figure(figsize=(20, 7))\r\n dendrogram = sch.dendrogram(sch.linkage(self.X, method='ward'))\r\n plt.title(\"Dendograms\")\r\n plt.axhline(linestyle='--', y=5) \r\n plt.show()",
"def hierarchical(encoder,tsne,true_data,true_labels,save_name... | [
"0.5904094",
"0.5818645",
"0.5731629",
"0.5525495",
"0.5480993",
"0.5404957",
"0.5350937",
"0.5278702",
"0.5245473",
"0.5239785",
"0.5224124",
"0.52206326",
"0.5218269",
"0.52055633",
"0.5174252",
"0.5162258",
"0.5143925",
"0.51324517",
"0.5120389",
"0.5109262",
"0.50999135",... | 0.6931154 | 0 |
Fetch first value of sql query from first row | def fetch_one(self, sql):
curs = self.q(sql, True)
row = curs.fetchone()
if curs._have_unread_result():
curs.fetchall()
curs.close()
if row:
return row[0]
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_first(self, tablename):\n\n query = 'select * from ' + tablename + \" ASC LIMIT 1\"\n try:\n self.__cur.execute(query)\n except Exception as e:\n self.__conn.rollback()\n raise e\n fetcheddata = self.__cur.fetchall()\n if fetcheddata:\n ... | [
"0.73570263",
"0.7294172",
"0.7290552",
"0.72203004",
"0.7203115",
"0.71490043",
"0.70922154",
"0.7053296",
"0.68610364",
"0.6857045",
"0.68527526",
"0.68388796",
"0.6817815",
"0.6792654",
"0.6790783",
"0.67729634",
"0.6772239",
"0.67677546",
"0.6765663",
"0.67581904",
"0.670... | 0.7338183 | 1 |
Fetch first col in result of sql query as list | def fetch_col(self, sql):
result = []
curs = self.q(sql, True)
for row in curs:
result.append(row[0])
curs.close()
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _exec1(self, sql):\n result = self._exec(sql)\n return [row[0] for row in result]",
"def get_data(cur, table, col):\n cur.execute('SELECT {} FROM {}'.format(col, table))\n d = cur.fetchall()\n\n data = []\n for dat in d:\n data.append(dat[0])\n\n return data",
"def dbGet... | [
"0.72786283",
"0.7249234",
"0.7169901",
"0.6911371",
"0.67051584",
"0.6325013",
"0.63209444",
"0.63185567",
"0.627186",
"0.6250654",
"0.6199792",
"0.61864144",
"0.6182418",
"0.6124425",
"0.6091806",
"0.60842735",
"0.6073463",
"0.6024743",
"0.58968884",
"0.5837379",
"0.5835033... | 0.83877146 | 0 |
Update data in table | def update(self, table_name, data, where):
fields = []
for fname in data:
fields.append("`{0}` = '{1}'".format(fname, self.escape(data[fname])))
self.q("UPDATE `{0}` SET {1} WHERE {2}".format(table_name, ", ".join(fields), where)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, table_name, data, id_column_name='id'):\n table = self._create_table(table_name)\n for row in data:\n try:\n statement = table.update() \\\n .where(table.c[id_column_name] == row[id_column_name]) \\\n .values(**r... | [
"0.7792093",
"0.7401779",
"0.7355358",
"0.7144647",
"0.7059116",
"0.697701",
"0.6915207",
"0.69074243",
"0.68955433",
"0.68955433",
"0.6849487",
"0.6813082",
"0.67853963",
"0.67651856",
"0.6749895",
"0.67465323",
"0.6716771",
"0.6698236",
"0.6637194",
"0.6637194",
"0.6637194"... | 0.74780506 | 1 |
Mass update data in table (UPDATE ... CASE) | def update_mass(self, table_name, field, data):
sql_tpl_start = "UPDATE `{0}` SET `{1}` = CASE \n".format(table_name, field)
sql_tpl_end = "ELSE `{0}` \n END".format(field)
sqls = []
for case in data:
sqls.append("WHEN {0} THEN {1} \n".format(case, self.quote(data[case])))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_bulk(self, iterable):\n self.cursor.executemany(self.UPDATE, iterable)",
"def update(self, updates, predicate):\n for row in self.rows:\n if predicate(row):\n for column, new_value in updates.items():\n row[column] = new_value",
"def _updat... | [
"0.65688735",
"0.6558023",
"0.63512254",
"0.63328576",
"0.62864274",
"0.6253742",
"0.61806196",
"0.6035597",
"0.6022993",
"0.5945211",
"0.59413564",
"0.5929763",
"0.5897619",
"0.589339",
"0.5880107",
"0.5854726",
"0.5825947",
"0.581689",
"0.58001184",
"0.578312",
"0.57775307"... | 0.8019296 | 0 |
json_dat is the data returned from the fb graph api query target_urls is the list of urls returned from our nytimes api query The function checks the link for each facebook post if the link is in the NYT data, it writes the metadata into a csv file | def process_items(json_dat, target_urls):
print('********Writing file for posts at %s' % json_dat['data'][0]['created_time'])
with open('output/fb_dat/%s_facebook_dat.csv' % datetime.datetime.now(), 'wb') as outfile:
w = csv.writer(outfile)
w.writerow(['id', 'link', 'reactions', 'shares', 'can_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_urls(json_dict):\n url_list = []\n count = 0\n for i in json_dict[\"items\"]:\n if i[\"is_answered\"]:\n url_list.append(i[\"link\"])\n count += 1\n if count == 3 or count == len(i):\n break\n \n for i in url_list:\n wb.open(i)",
"def p... | [
"0.6187193",
"0.5854688",
"0.5479477",
"0.53063583",
"0.52862805",
"0.5264628",
"0.5170005",
"0.5136996",
"0.5095873",
"0.5070931",
"0.5035758",
"0.50294256",
"0.5020284",
"0.50175667",
"0.5011588",
"0.50007504",
"0.49701276",
"0.49683812",
"0.49673364",
"0.49572316",
"0.4943... | 0.7994558 | 0 |
Update scroll position using policy. | def _scroll (self):
if self.policy is not None:
self._scroll_fn(self, *self._policy_args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_scroll_position(self, new_scroll_position):\n if not self._items:\n raise ValueError(\"Empty navigation history\")\n self._items[self._pointer].scroll_position = new_scroll_position",
"def shell_vertical_scrollbar_policy_changed(self, policy):\n self.set_vertical_policy(policy)",
"... | [
"0.6320449",
"0.6282196",
"0.6256124",
"0.59605294",
"0.58138216",
"0.5772516",
"0.5749272",
"0.5734672",
"0.5731065",
"0.5723491",
"0.56902146",
"0.5677249",
"0.56587213",
"0.5629051",
"0.56015885",
"0.55960417",
"0.5582316",
"0.5572218",
"0.5572024",
"0.5541328",
"0.5515658... | 0.7362202 | 0 |
Set the scroll policy. Takes policy, args and policy_cleanup arguments as required by the constructor. Call with no arguments to disable scrolling. | def set_policy (self, policy = None, args = (), policy_cleanup = None):
if policy == self.policy:
# same policy; might want to change args/cleanup function, though
self._policy_args = args
if policy is not None and not isinstance(policy, basestring):
self._pol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _scroll (self):\n if self.policy is not None:\n self._scroll_fn(self, *self._policy_args)",
"def set_vertical_policy(self, policy):\n self.widget.setVerticalScrollBarPolicy(SCROLLBAR_POLICY_MAP[policy])",
"def shell_horizontal_scrollbar_policy_changed(self, policy):\n self.s... | [
"0.6515044",
"0.6338022",
"0.61150986",
"0.6036306",
"0.60038",
"0.59087986",
"0.5849525",
"0.5325362",
"0.53151673",
"0.525753",
"0.51344055",
"0.50478685",
"0.5021623",
"0.50133526",
"0.4952172",
"0.49184093",
"0.49173033",
"0.48805395",
"0.48208562",
"0.47930115",
"0.47470... | 0.78481305 | 0 |
Create a new display. open_display(display_args, cls = Display) > display | def open_display (self, *display_args, **kw):
# first display argument is always rect; crop it to fit on the screen
rect = pygame.Rect(display_args[0]).clip(self.screen.get_rect())
if any(rect.colliderect(d.rect) for d in self.displays):
raise ValueError('rect overlaps other displays... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_display (self, *display_args, **kw):\n new_disp = kw.get('cls', Display)((0, 0, 0, 0), *display_args)\n self.displays.append(new_disp)\n return (new_disp, self._arrange_displays())",
"def open_display (self, z, *display_args, **kw):\n if z in self.layers:\n layer =... | [
"0.8655459",
"0.6942733",
"0.668072",
"0.6445743",
"0.6404137",
"0.6179312",
"0.61589354",
"0.6149691",
"0.6144649",
"0.6078821",
"0.60752904",
"0.6024354",
"0.5982608",
"0.5864896",
"0.58618313",
"0.5775404",
"0.57638806",
"0.57612926",
"0.5759617",
"0.57234",
"0.56942415",
... | 0.8055005 | 1 |
Destroy the given display and remove it from the screen. Doesn't draw over the display. | def close_display (self, display):
display.destroy()
self.displays.remove(display) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detach_display(self, display):\n self.extra_displays.remove(display)\n self.removeDockWidget(display)\n #self.display_detached.emit(display)",
"def close_display (self, display):\n z = display.z\n self.layers[z].remove(display)\n # remove layer if empty now\n ... | [
"0.7643067",
"0.7496916",
"0.67938095",
"0.66797936",
"0.6676643",
"0.6356042",
"0.6336054",
"0.6325548",
"0.62858474",
"0.6036146",
"0.6015563",
"0.59697443",
"0.59378445",
"0.5921077",
"0.5910971",
"0.5850607",
"0.5803729",
"0.57967037",
"0.5759184",
"0.57557875",
"0.573517... | 0.77797014 | 0 |
Notify the display manager that the surface size has changed. resize(error_on_crop = False) > changed | def resize (self, error_on_crop = False):
screen_rect = self.screen.get_rect()
changed = []
rects = []
for display in self.displays:
# find display rect cropped to fit in new screen rect
rect = display.rect.clip(screen_rect)
if rect != display.rect:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ev_resize(self, event):\n\n new_size = event.dict['size']\n surface_size = self.__screen.get_size()\n old_center = self.__screen.get_rect().center\n if new_size != surface_size:\n self.__screen = pygame.display.set_mode(new_size,\n ... | [
"0.74104506",
"0.7260305",
"0.7077151",
"0.70613784",
"0.70390093",
"0.69498473",
"0.690074",
"0.6857405",
"0.6840272",
"0.6838284",
"0.6817415",
"0.6779252",
"0.67349446",
"0.67349446",
"0.6734184",
"0.6711578",
"0.671106",
"0.66608036",
"0.6611807",
"0.65510494",
"0.6541242... | 0.7380334 | 1 |
Tell every display to draw Returns whether any changes were made to any screens. | def draw (self):
screen = self.screen
dirty = False
for display in self.displays:
dirty |= display.draw(screen)
return dirty | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw (self):\n screen = self.screen\n dirty = False\n for z, displays in self.layers.iteritems():\n for display in displays:\n drew = display.draw(screen)\n # if made changes to the surface\n if drew:\n # set any di... | [
"0.7477884",
"0.69648814",
"0.6924238",
"0.68973786",
"0.685729",
"0.6773457",
"0.66716707",
"0.66647047",
"0.6650934",
"0.65936613",
"0.6584267",
"0.6579884",
"0.65666425",
"0.6562043",
"0.65549684",
"0.65526974",
"0.6552018",
"0.6538944",
"0.6527829",
"0.64884293",
"0.64633... | 0.80497336 | 0 |
Create a new display. Displays are automatically cropped to fit in the screen; if the rect given is outside the screen entirely, ValueError is raised. ValueError is also raised if the display would overlap any existing ones in the same layer (same zindex). open_display(z, display_args, cls = Display) > display | def open_display (self, z, *display_args, **kw):
if z in self.layers:
layer = self.layers[z]
else:
# new layer
self.layers[z] = layer = []
l = self.layers
# resort layers
self.layers = OrderedDict((z, l[z]) for z in sorted(l))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_display (self, *display_args, **kw):\n # first display argument is always rect; crop it to fit on the screen\n rect = pygame.Rect(display_args[0]).clip(self.screen.get_rect())\n if any(rect.colliderect(d.rect) for d in self.displays):\n raise ValueError('rect overlaps other... | [
"0.8903438",
"0.780356",
"0.59852153",
"0.59743905",
"0.5909006",
"0.57527894",
"0.56761914",
"0.5674825",
"0.56592643",
"0.56333023",
"0.55787563",
"0.5524729",
"0.5490934",
"0.54128605",
"0.5394451",
"0.53843486",
"0.53806233",
"0.5377407",
"0.5363306",
"0.5333117",
"0.5251... | 0.8138567 | 1 |
Compute and apply optimal display rects. Returns displays whose rects were changed. | def _arrange_displays (self):
if self.locked:
self._changed = True
return []
n = len(self.displays)
if n == 0:
return []
# find the optimal number of initial splits (rows/columns)
data = []
# if not given, check splitting into both rows... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDisplayRects():\n\tHANDLE_MONITOR, HDC_MONITOR, SCREEN_RECT = list(range(3))\n\n\t# My experiments show this needs to be no more than 3 (for 4 iterations\n\t# through the loop), but use 150 in case there are pathological systems.\n\t# Note that one iteration of the loop takes about 90us on a Q6600.\n\ttries... | [
"0.6759154",
"0.57493937",
"0.57136697",
"0.5621131",
"0.56206185",
"0.5567517",
"0.55445343",
"0.5433071",
"0.54236996",
"0.54150385",
"0.5414731",
"0.5380424",
"0.53761023",
"0.5359294",
"0.53354543",
"0.52643675",
"0.52560115",
"0.5225002",
"0.5218094",
"0.5212483",
"0.518... | 0.74590236 | 0 |
Create a new display. open_display(display_args, cls = Display) > (display, changed) | def open_display (self, *display_args, **kw):
new_disp = kw.get('cls', Display)((0, 0, 0, 0), *display_args)
self.displays.append(new_disp)
return (new_disp, self._arrange_displays()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_display (self, *display_args, **kw):\n # first display argument is always rect; crop it to fit on the screen\n rect = pygame.Rect(display_args[0]).clip(self.screen.get_rect())\n if any(rect.colliderect(d.rect) for d in self.displays):\n raise ValueError('rect overlaps other... | [
"0.7814816",
"0.69402194",
"0.6432336",
"0.6274682",
"0.61335194",
"0.6053817",
"0.6051026",
"0.5886878",
"0.5863076",
"0.5806153",
"0.5770868",
"0.5765462",
"0.5753063",
"0.5749419",
"0.5697002",
"0.5676657",
"0.5676449",
"0.556471",
"0.55429137",
"0.55393386",
"0.55163515",... | 0.8458466 | 0 |
Lock this display manager. When locked, the arrangement of displays is not calculated when one is added or removed, and drawing is disabled. This is used before adding multiple displays, to save doing extra processing between additions. | def lock (self):
self.locked = True
self._changed = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_lock(self):\n self.state = 'locked'",
"def f_lock(self):\n self._locked = True",
"def processLock(self):\r\n self.controller.executionLock()",
"def set_locked(self, *args):\n return _ida_hexrays.vdui_t_set_locked(self, *args)",
"def lockSliderPanel(self, flag): \n... | [
"0.587006",
"0.58462864",
"0.58046246",
"0.57927364",
"0.5705625",
"0.569869",
"0.56452096",
"0.5628417",
"0.5587659",
"0.5557064",
"0.5511961",
"0.54756993",
"0.5415348",
"0.5403101",
"0.53967434",
"0.5393725",
"0.5393725",
"0.5362772",
"0.5325371",
"0.5301108",
"0.52964",
... | 0.6063361 | 0 |
Unlock this display manager. Returns a list of displays whose rects changed as a result of rearranging them. | def unlock (self):
if self.locked:
self.locked = False
if self._changed:
return self._arrange_displays()
return [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release_displays():\n for _disp in displays:\n _disp._release() # pylint: disable=protected-access\n displays.clear()",
"def getDisplayRects():\n\tHANDLE_MONITOR, HDC_MONITOR, SCREEN_RECT = list(range(3))\n\n\t# My experiments show this needs to be no more than 3 (for 4 iterations\n\t# through ... | [
"0.6458859",
"0.6274399",
"0.62245476",
"0.58006555",
"0.57455",
"0.5619013",
"0.5578753",
"0.5430197",
"0.5351928",
"0.5240674",
"0.5166137",
"0.51478165",
"0.5134911",
"0.5023649",
"0.49588466",
"0.49474305",
"0.49188876",
"0.4893868",
"0.48894307",
"0.48807615",
"0.486837"... | 0.8525207 | 0 |
Aggregate proportions df for members. | def _agg_proportions(df, members=None):
p = df.copy()
if members is not None:
p = p.iloc[members]
p = p.T.assign(
group=pd.factorize(p.columns)[0],
label=pd.factorize(p.columns)[-1],
value=p.sum(), #/ p.sum().sum() * p.shape[0],
row_count=p.shape[0]
)
p = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leitner_proportions(df):\n denom = df.shape[0]\n prop_dict = {}\n\n for i in range(1,6):\n df_i = df[df['comfort_level'] == i]\n numer = df_i.shape[0]\n prop_dict[i] = numer / denom\n\n prop_df = pd.DataFrame.from_dict([prop_dict], orient='columns') \n\n prop_df = prop_df.T.... | [
"0.6504868",
"0.61489815",
"0.58079594",
"0.5698404",
"0.5637847",
"0.5619409",
"0.5591558",
"0.5494832",
"0.5460366",
"0.545533",
"0.5442584",
"0.5441737",
"0.5441388",
"0.53967786",
"0.5386168",
"0.53798825",
"0.53480345",
"0.533656",
"0.533095",
"0.5316881",
"0.5313589",
... | 0.813785 | 0 |
Patch the socket module | def patch():
config("127.0.0.1", 9050)
socket.socket = socks.socksocket
socket.create_connection = create_connection | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restoreSocket():\n global ORIG_SOCK\n socket.socket = ORIG_SOCK",
"def wrapmodule(module):\r\n if _defaultproxy != None:\r\n module.socket.socket = socksocket\r\n else:\r\n raise GeneralProxyError((4, \"no proxy specified\"))",
"def wrapmodule(module):\r\n if _defaultproxy != N... | [
"0.6885636",
"0.67882574",
"0.67882574",
"0.6756587",
"0.66317785",
"0.64612216",
"0.6434609",
"0.63301986",
"0.63058424",
"0.6305826",
"0.62696165",
"0.6221603",
"0.61780304",
"0.6163504",
"0.6151241",
"0.613936",
"0.6113585",
"0.6113585",
"0.60936207",
"0.6068484",
"0.60561... | 0.7267799 | 0 |
Calculate the angles of an eye relative to the heading First, the angles are converted into unit vectors. For each frame the cross product is calculated between the eye vector and the heading vector. The signed angle between the heading vector and eye vector is the arcsin of their | def calculate_eye_angles(eye_angles, heading_angles):
eye_vectors = np.array([np.cos(eye_angles), np.sin(eye_angles)])
heading_vectors = np.array([np.cos(heading_angles), np.sin(heading_angles)])
corrected_eye_angles = np.arcsin(np.cross(eye_vectors.T, heading_vectors.T))
return corrected_eye_angles | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angle_hkls(self, h1, h2):\n h1v = norm_vec((vec(*h1).T * self.Bmat)).T\n h2v = norm_vec((vec(*h2).T * self.Bmat)).T\n return np.around(np.arccos(h1v.T*h2v)[0, 0] * degrees, 3)",
"def calc_incidence_angle():\n \n Delta_r, lat_r, Omega_r, Zenith_r, Azimuth_r, Elev_angle = solar_model... | [
"0.6481705",
"0.63144535",
"0.62879187",
"0.6232609",
"0.6228701",
"0.6228701",
"0.62233734",
"0.62011874",
"0.61686873",
"0.6148799",
"0.60972935",
"0.60953176",
"0.6093981",
"0.6093981",
"0.6079193",
"0.60790664",
"0.60631454",
"0.6019296",
"0.6016947",
"0.6011878",
"0.5987... | 0.77265364 | 0 |
Smooths the position of points along the tail | def smooth_tail_points(points, size=7, kind='boxcar'):
if kind == 'boxcar':
kernel = np.ones((size,))
elif kind == 'gaussian':
kernel = gaussian(size, 1)
else:
raise ValueError()
kernel /= np.sum(kernel)
n = (size - 1) / 2
padded_points = np.pad(points, ((0, 0), ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _smooth(self):\n self.te = self._spline(self.rho_in, self.te_in, self.rho)\n self.ne = self._spline(self.rho_in, self.ne_in, self.rho)\n self.ti = self._spline(self.rho_in, self.ti_in, self.rho)\n self.vt = self._spline(self.rho_in, self.vt_in, self.rho)\n for i in range(self... | [
"0.63423336",
"0.63197577",
"0.6231786",
"0.6202506",
"0.61760116",
"0.6120898",
"0.6103585",
"0.6010128",
"0.5941174",
"0.5941174",
"0.5892968",
"0.57734346",
"0.56874615",
"0.5683912",
"0.5669718",
"0.56359553",
"0.56129277",
"0.55778706",
"0.55548126",
"0.5553576",
"0.5540... | 0.63556755 | 0 |
Convert all the storage sizes into kbs for easy computation | def storage_size_to_kb(self,storage_size):
multiplier = 1
val = float(storage_size[0:-2])
meter = storage_size[-2:]
if "kb" == meter:
multiplier = 1
elif "mb" == meter:
multiplier = 1024
elif "gb" == meter:
multiplier = 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disk(self):\n disk_size_list = []\n precision = 2\n size = self.random.randint(1, 1099511627776)\n suffixes=['B','KB','MB','GB','TB']\n suffixIndex = 0\n while size > 1024 and suffixIndex < 4:\n suffixIndex += 1 #increment the index of the suffix\n ... | [
"0.6741091",
"0.6688744",
"0.6595712",
"0.6552293",
"0.6405261",
"0.6338948",
"0.614964",
"0.612405",
"0.6064489",
"0.60633856",
"0.60567683",
"0.601831",
"0.6000964",
"0.59691226",
"0.592122",
"0.59162295",
"0.5899232",
"0.58982587",
"0.58982587",
"0.588114",
"0.5869973",
... | 0.71607184 | 0 |
Reads input and populates log_elements array | def read():
for line in sys.stdin:
if line == "\n":
return
log_elements.append(log_element(line)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_linelog():",
"def _read_log(self):\n\n line_regex = compile(r\"\\[I\\]\\s*\\(\\d+ms\\)[^\\d]+(?P<counter>\\d+)\"\n r\"[^\\d]+(?P<timestamp>\\d+(\\.\\d+)?)[^\\d]+\"\n r\"(?P<acceleration>\\d+);\")\n values = []\n with open(self.... | [
"0.63699794",
"0.63436985",
"0.60513854",
"0.5909126",
"0.5748926",
"0.5674182",
"0.56653786",
"0.563449",
"0.5558002",
"0.5531976",
"0.54010886",
"0.5357035",
"0.535464",
"0.5341019",
"0.52941054",
"0.5272136",
"0.52229947",
"0.51763344",
"0.5167177",
"0.51667005",
"0.516640... | 0.70665985 | 0 |
Returns an instance normalization layer | def get_norm_layer():
norm_layer = functools.partial(nn.InstanceNorm2d, affine=False, track_running_stats=False)
return norm_layer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_norm_model():\n inputs = tf.keras.Input(shape=(16, 16, 3,))\n x = tf.keras.layers.Conv2D(16, (3, 3))(inputs)\n x = tf.contrib.layers.instance_norm(x)\n return x",
"def convert_instance_norm(g, op, block):\n\n x = g.get_node(op.input(\"X\")[0])\n gamma = g.get_node(op.input(\"Scale\... | [
"0.737187",
"0.71423167",
"0.6849389",
"0.6702335",
"0.66798216",
"0.66449195",
"0.6553574",
"0.6545179",
"0.65408355",
"0.6527662",
"0.64864683",
"0.6394771",
"0.6263296",
"0.62447166",
"0.62365717",
"0.622176",
"0.61820877",
"0.61517155",
"0.6101231",
"0.60920525",
"0.60915... | 0.76729393 | 0 |
Initialize the GANLoss class. | def __init__(self, gan_mode, target_real_label=1.0, target_fake_label=0.0):
super(GANLoss, self).__init__()
self.register_buffer('real_label', torch.tensor(target_real_label))
self.register_buffer('fake_label', torch.tensor(target_fake_label))
self.gan_mode = gan_mode
self.loss =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initLoss(self):\n\n pass",
"def __init__(self, gan_mode, target_real_label=1.0, target_fake_label=0.0):\n super(GANLoss, self).__init__()\n self.register_buffer('real_label', torch.tensor(target_real_label))\n self.register_buffer('fake_label', torch.tensor(target_fake_label))\n ... | [
"0.74347126",
"0.70735884",
"0.7062723",
"0.7047087",
"0.6902463",
"0.6902463",
"0.68790823",
"0.6747148",
"0.67172647",
"0.67015034",
"0.6578403",
"0.65131474",
"0.6448463",
"0.64445186",
"0.6394152",
"0.63732684",
"0.63490087",
"0.6348674",
"0.6334805",
"0.6333888",
"0.6294... | 0.7221826 | 1 |
get the directory from where the script is launched and add the db to this path | def get_db_path():
return os.path.join(sys.path[0], "my_db.db") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_db_path():\n \n return(db_run.db_abs_path)",
"def getDBPath():\n return os.path.join(CONFIG_DIR, CONFIG_DICT['common']['local_db'])",
"def get_database_directory(self):\n pass",
"def set_db_file():\n\n return os.path.join(db_path, db_file)",
"def db_path(self, host: str) -> str:\... | [
"0.74853",
"0.74065465",
"0.7374021",
"0.72842073",
"0.6945112",
"0.67996144",
"0.6580396",
"0.65772825",
"0.65709597",
"0.64634407",
"0.6426292",
"0.6384194",
"0.6312689",
"0.6306406",
"0.6175045",
"0.61704856",
"0.61657816",
"0.6133531",
"0.6127076",
"0.6108589",
"0.6099406... | 0.749475 | 0 |
Taken from vgg_rq. Computes RQ decomposition (like qr but other way around) If [R,Q] = rq(X), then R is uppertriangular, Q is orthogonal and X=RQ Moreover, if S is a real matrix, then det(Q) > 0 >>> K = np.array([[50, 0, 20], ... [0, 50, 30], ... [0, 0, 1]]) >>> R = np.array([[np.cos(np.pi/7), np.sin(np.pi/7), 0], ... ... | def positive_rq(S):
Q, R = positive_qr(np.flipud(S).T)
R = np.flipud(R.T)
Q = np.flipud(Q.T)
return R[:,::-1], Q | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qr_decomposition(self):\n if self.m != self.n:\n raise NotImplementedError('QR decomposition not yet available ' +\n 'for non-square matrices')\n orig_basis = [vec.Vector.fromMatrixColumn(self, j)\n for j in range(self.m)]\n ... | [
"0.65592957",
"0.6530989",
"0.647267",
"0.6349665",
"0.62020355",
"0.6180996",
"0.59999245",
"0.59662414",
"0.5740858",
"0.56240654",
"0.55478364",
"0.5515776",
"0.5511022",
"0.549594",
"0.54924625",
"0.54907006",
"0.54727995",
"0.54503036",
"0.5427424",
"0.54005617",
"0.5400... | 0.78627896 | 0 |
change a person in the phonebook | def change(name, phone, db):
database = load(db)
if name in database:
database[name] = phone
pickle.dump(database, open(db, 'wb'))
print("%s number changed to %r" % (name, phone ))
else:
print("no such person %r in %r" % (name, db))
sys.exit(-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_person(self):\n # TODO:\n # if render_person is none: throw error message to click first\n\n info = self.current_person()\n info[\"dob\"] = str(info[\"dob\"])\n # launch module\n self.EditPeople.edit_person(info)\n self.EditPeople.show()",
"def __ui_upd... | [
"0.7097954",
"0.6804154",
"0.6771048",
"0.6752388",
"0.6611106",
"0.6609151",
"0.65740913",
"0.6560294",
"0.65319985",
"0.6499986",
"0.6447221",
"0.62791574",
"0.6244178",
"0.6194998",
"0.61908895",
"0.61908895",
"0.61908895",
"0.61908895",
"0.61908895",
"0.61567295",
"0.6134... | 0.72494525 | 0 |
contracts a random edge | def contract_random_edge(self):
edge_length = len(self.edges)
edge_index = randint(0, edge_length-1)
removed_edge = self.edges[edge_index]
self.vertices.remove(removed_edge.destination_vertex)
to_be_removed_edges = []
for index, item in enumerate(self.edges):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pick_edge(self, edges):\n total_weight = sum([e.weight for e in edges])\n r = rand.random() * total_weight\n running_total = 0\n for e in edges:\n running_total += e.weight\n if running_total >= r:\n return e",
"def random(self):\n adj ... | [
"0.68342674",
"0.66236424",
"0.65874714",
"0.6450685",
"0.6434406",
"0.6353011",
"0.6274038",
"0.6101228",
"0.60512894",
"0.60504234",
"0.6043849",
"0.59824425",
"0.5964198",
"0.5959298",
"0.5923501",
"0.5903826",
"0.5894098",
"0.58764315",
"0.5860331",
"0.58542067",
"0.58232... | 0.79250526 | 0 |
Initialize dlib's face detetctor (HOGbased) and then create the facial landmark predictor | def initialize_dlib(facial_landmark_predictor:str):
print('Loading facial landmark predictor...')
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(FACIAL_LANDMARK_PREDICTOR)
return detector, predictor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, facePredictor = None):\n self.detector = dlib.get_frontal_face_detector()\n if facePredictor != None:\n self.predictor = dlib.shape_predictor(facePredictor)\n else:\n self.predictor = None",
"def __init__(self):\n if not os.path.isfile(PREDICTO... | [
"0.6831879",
"0.6661409",
"0.646069",
"0.63063526",
"0.6283278",
"0.6270865",
"0.6245186",
"0.6168358",
"0.60426056",
"0.5935295",
"0.5924143",
"0.59093416",
"0.58511114",
"0.5850788",
"0.5789124",
"0.5627219",
"0.55687624",
"0.5524729",
"0.5514897",
"0.5503704",
"0.54955685"... | 0.76966816 | 0 |
load the pretrained Caffe model for age estimation | def load_caffe_models(age_model:str,age_proto:str):
#ageModel , ageProto
age_net = cv2.dnn.readNetFromCaffe(age_model , age_proto)
#use CPU
age_net.setPreferableBackend(cv2.dnn.DNN_TARGET_CPU)
return age_net | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_caffe_model(self):\n print(\"Loading caffe model used for detecting a human_blob.\")\n\n # Use cv2.dnn function to read the caffe model used for detecting faces and set preferable target.\n # self.detector = cv2.dnn.readNetFromCaffe(os.path.join(\n # os.path.dirname(os.path... | [
"0.694415",
"0.6865981",
"0.68346673",
"0.6727487",
"0.66873056",
"0.6550186",
"0.65494734",
"0.6520341",
"0.6446358",
"0.6349035",
"0.6331279",
"0.63243085",
"0.6319959",
"0.6292117",
"0.62749726",
"0.62726504",
"0.6265645",
"0.62616515",
"0.6254586",
"0.62516886",
"0.624830... | 0.7752657 | 0 |
Determine the optimal font scale based on the hosting frame width | def get_optimal_font_scale(text, width):
for scale in reversed(range(0, 60, 1)):
textSize = cv2.getTextSize(text, fontFace=cv2.FONT_HERSHEY_DUPLEX, fontScale=scale/10, thickness=1)
new_width = textSize[0][0]
#print(new_width)
if (new_width <= width):
return scale/10... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Scale(*args, **kwargs):\n return _gdi_.Font_Scale(*args, **kwargs)",
"def get_font_at_size(fonts_path, font_name, initial_font_size, text_to_print, target_width):\n font_size = initial_font_size\n while True:\n font = ImageFont.truetype(path.join(fonts_path, font_name), font_size)\n ... | [
"0.673154",
"0.63879925",
"0.6374378",
"0.6338837",
"0.62847567",
"0.6278708",
"0.61513835",
"0.60837716",
"0.6079036",
"0.60436743",
"0.6037729",
"0.60253006",
"0.59711736",
"0.5948849",
"0.59138095",
"0.5880673",
"0.58474314",
"0.583969",
"0.583679",
"0.58010024",
"0.577368... | 0.80169535 | 0 |
Predict the age of the faces showing in the image | def predict_age(input_path:str):
#Initialize dlib face detector using the facial landmark recognition
detector, predictor = initialize_dlib(facial_landmark_predictor=FACIAL_LANDMARK_PREDICTOR)
#Load age prediction model
age_net = load_caffe_models(age_model=AGE_MODEL, age_proto = AGE_PROTO)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_function(frame, faceNet, ageNet, minConf=0.5):\n # Define the list of age range \n AGE_RAN = [\"(0-2)\", \"(4-6)\", \"(8-12)\", \"(15-20)\", \"(25-32)\", \"(38-43)\", \"(48-53)\", \"(60-100)\"]\n \n # Initialize the results list\n results = []\n (h, w) = frame.shape[:2] # extacting the... | [
"0.6636992",
"0.6421009",
"0.63035285",
"0.6284037",
"0.6225446",
"0.6168458",
"0.61557746",
"0.6114197",
"0.61070985",
"0.6063537",
"0.6059852",
"0.604574",
"0.60406256",
"0.60368234",
"0.60300744",
"0.6026352",
"0.6015461",
"0.5999065",
"0.59780234",
"0.59604883",
"0.594221... | 0.7683133 | 0 |
Validates the path inputted and validates that it is a file of type image | def is_valid_path(path):
if not path:
raise ValueError(f"Invalid Path")
if os.path.isfile(path) and 'image' in filetype.guess(path).mime:
return path
else:
raise ValueError(f"Invalid Path {path}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_format_check(img_path):\n \n suffix = img_path.split('.')[-1]\n if suffix in ImgConf._VALID_IMAGE_SUFFIXES:\n return True\n \n return False",
"def check_image(self, filename):\n error = None\n file_type = None\n\n abs_path = os.path.expanduser(os.path.expandva... | [
"0.6682235",
"0.66190654",
"0.6609811",
"0.6504365",
"0.6500428",
"0.64783067",
"0.64720976",
"0.6462452",
"0.641564",
"0.63572514",
"0.63324535",
"0.6302851",
"0.6268838",
"0.6234848",
"0.6222475",
"0.62170124",
"0.61945707",
"0.61741763",
"0.61602306",
"0.6151967",
"0.60950... | 0.7972 | 0 |
Check if a file exists for this environment, then load the rejected pillow types from that file | def get_rejected_pillow_types(code_root, environment):
fpath = os.path.join(code_root, "scripts", "%s_pillows.yaml" % environment)
if os.path.isfile(fpath):
with open(fpath, 'r') as f:
yml = yaml.load(f)
return yml
return {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_type(filename):\n try:\n im = Image.read(filename)\n except SanperaError:\n return False\n else:\n return im.original_format in [b'JPEG', b'PNG', b'GIF']",
"def pil_available():\n out = False\n try:\n from PIL import Image # noqa\n out = True\n exce... | [
"0.5751026",
"0.55280083",
"0.5468043",
"0.5463397",
"0.541402",
"0.5396621",
"0.5384756",
"0.53677744",
"0.53630936",
"0.534056",
"0.53275937",
"0.5326267",
"0.52912676",
"0.52896786",
"0.5279429",
"0.5274889",
"0.5217183",
"0.5199619",
"0.5191081",
"0.51857305",
"0.518448",... | 0.6862207 | 0 |
Hacky override to make pillowtop config. Multiple configs within the conf file | def render_configuration_file(self, conf_template_string):
environment = self.params['environment']
code_root = self.params['code_root']
reject = self.get_rejected_pillow_types(code_root, environment)
configs = []
all_pillows = self.get_pillows_from_settings(settings.PILLOWTOPS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pibooth_setup_picture_factory(cfg, opt_index, factory):",
"def pibooth_configure(cfg):",
"def config():",
"def config():",
"def config(ctx):\n return",
"def config( **kwargs ):",
"def __set_special_config_values(cfg: __Config, config: dict) -> \"__Config\":\n cfg.file_name_plane_masks = l... | [
"0.6384537",
"0.59300953",
"0.58811885",
"0.58811885",
"0.5779177",
"0.5719944",
"0.5643492",
"0.5634617",
"0.56321776",
"0.561842",
"0.5582526",
"0.55407083",
"0.5516638",
"0.5497772",
"0.5489011",
"0.5451195",
"0.54335576",
"0.543045",
"0.5406416",
"0.5394115",
"0.5374888",... | 0.59710276 | 1 |
Callback function to shuffle indexes each epoch | def on_epoch_end(self):
if self.shuffle:
self.indexes = np.random.permutation(self.indexes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_epoch_end(self):\n if self.shuffle:\n np.random.shuffle(self.indexes)",
"def on_epoch_end(self):\n if self.shuffle == True:\n numpy.random.shuffle(self.indexes)",
"def on_epoch_end(self):\n if self.shuffle:\n np.random.shuffle(self.indices)",
"def ... | [
"0.7674896",
"0.76198816",
"0.7496145",
"0.743398",
"0.72897106",
"0.72835857",
"0.726584",
"0.7260552",
"0.7260552",
"0.7158545",
"0.71248597",
"0.70521694",
"0.70521694",
"0.70521694",
"0.7035872",
"0.69764745",
"0.69764745",
"0.69321036",
"0.68971384",
"0.6838018",
"0.6777... | 0.77959675 | 1 |
Load the evaluation policy into the estimator | def load_eval_policy(self, eval_policy: PolicyBase) -> None:
assert isinstance(eval_policy, PolicyBase)
self.eval_policy = eval_policy
if isinstance(self.eval_policy, TabularPolicy):
self.eval_policy_pi = self.eval_policy.pi_all()
elif isinstance(self.eval_policy, FAPolicy):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _eval_checkpoint(\n self,\n checkpoint_path: str,\n writer: TensorboardWriter,\n checkpoint_index: int = 0,\n ) -> None:\n # Map location CPU is almost always better than mapping to a CUDA device.\n ckpt_dict = self.load_checkpoint(checkpoint_path, map_location=\"cp... | [
"0.6181846",
"0.60755885",
"0.6064371",
"0.59805995",
"0.5960121",
"0.5907963",
"0.5894653",
"0.5858587",
"0.5741821",
"0.5728746",
"0.5718018",
"0.5697267",
"0.56760323",
"0.56347805",
"0.56214637",
"0.5608565",
"0.5595055",
"0.55781984",
"0.55779356",
"0.55364317",
"0.55348... | 0.7513779 | 0 |
Computes the importance weights pi_e / pi_b | def get_importance_weights(self, t_s_a_pi_b: Tuple[int, Tuple[int, int, float]]) -> float:
t, s_a_pi_b = t_s_a_pi_b
s, a, pi_b = s_a_pi_b
return self.eval_policy.pi(s, a) / pi_b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_f_p(genes, gene_abundance_file, gene_molecular_weight_file):\n gene_abundance = pd.read_csv(gene_abundance_file, index_col=0)\n gene_molecular_weight = json_load(gene_molecular_weight_file)\n enzy_abundance = 0\n pro_abundance = 0\n for gene_i in gene_abundance.index:\n if gene_... | [
"0.6366732",
"0.6289902",
"0.61191255",
"0.6045736",
"0.6018425",
"0.5997691",
"0.5996093",
"0.59595233",
"0.5903108",
"0.5895175",
"0.5886873",
"0.58775",
"0.58613896",
"0.5858423",
"0.5836599",
"0.58149254",
"0.5805276",
"0.5800174",
"0.5724506",
"0.57170796",
"0.56941944",... | 0.77299684 | 0 |
Updating Action.notification_text for all Actions. | def set_action_notification_text(apps, schema_editor):
Action = apps.get_model("goals", "Action")
for action in Action.objects.all():
text = action.notification_text
if text and text[0].isupper() and not text[1].isupper():
text = "{}{}".format(text[0:1].lower(), text[1:])
act... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acutalizeActionlabel (self, data):\n if data.has_key(StatusMsg.label_action):\n self.actionlabel.setText(self.actionDecoder.get(data.get(StatusMsg.label_action)))",
"def cmd_notification_all(client, args):\n notifications_all = client.get_notifications(args.new)\n notifications_all['m... | [
"0.5739027",
"0.5407203",
"0.5316224",
"0.526637",
"0.52332604",
"0.5208834",
"0.5204673",
"0.5167668",
"0.51554036",
"0.5132883",
"0.512424",
"0.5109301",
"0.5054879",
"0.50501794",
"0.50393176",
"0.5033135",
"0.50324005",
"0.5023964",
"0.5023964",
"0.50160575",
"0.49825758"... | 0.7949134 | 0 |
returns true if the cmyk values are between 0 and 255 | def checkValue(c, m, y, k):
MINVAL=0
MAXVAL=255
valueOk=True
for val in c, m, y, k:
if val >=MINVAL and val <=255:
pass
else:
valueOk=False
return valueOk | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_0to255(value):\n return 0 <= value <= 255",
"def inside_gamut(rgb: ndarray) -> bool:\n return all(rgb >= 0)",
"def has_valid_channel_values(rgb_coll):\n return all([is_0to255(c) and is_int(c) for c in rgb_coll])",
"def validate(c_name, val):\n n = 80\n threshold = 4\n while (threshol... | [
"0.7696764",
"0.6565392",
"0.64692634",
"0.63556695",
"0.63285995",
"0.6285347",
"0.6242104",
"0.6236757",
"0.6173846",
"0.6173846",
"0.61536485",
"0.6117954",
"0.60981804",
"0.6077521",
"0.6021677",
"0.60151637",
"0.60123754",
"0.5974014",
"0.5965677",
"0.5964167",
"0.595889... | 0.7365734 | 1 |
get colors from csv file and return a list with name and cmyk 255 values | def getColorsFromCsv(filename):
csvreader=csv.reader(file(filename))
csvcolors=[]
i=0
for row in csvreader:
name=row[0]
name=name.strip()
c=int(row[1] )* 2.55
c=int(c)
m=int(row[2] )* 2.55
m=int(m)
y=int(row[3] )* 2.55
y=int(y)
k=i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def materials_list_from_file(filename):\n color_data = []\n with open(filename, 'r', newline='') as csvfile:\n reader = csv.reader(csvfile)\n for row in reader:\n image_info = (row[POS_NAME], int(row[POS_RED]),\n int(row[POS_GREEN]), int(row[POS_BLUE]))\n ... | [
"0.7006616",
"0.67844456",
"0.66995895",
"0.66653216",
"0.6451843",
"0.63817394",
"0.63734466",
"0.6324284",
"0.6324284",
"0.63083255",
"0.63006926",
"0.6299784",
"0.62975603",
"0.62866545",
"0.62854576",
"0.6276468",
"0.6271328",
"0.6246794",
"0.6222519",
"0.6218181",
"0.621... | 0.81648016 | 0 |
get the colors that already exist from the opened Document and return a dictionary | def getColorDict():
scribus.statusMessage("Reading existing colors...")
colornames = scribus.getColorNames()
scribus.progressTotal(len(colornames))
i=0
colordict={}
for name in colornames:
colordict[name]=None
i=i+1
scribus.progressSet(i)
return colordict #we can ask ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def colors(self) -> dict:\n raise NotImplementedError",
"def get_colors():\n colors = {}\n for h in wn.synset('chromatic_color.n.01').hyponyms():\n colors[h.lemmas()[0].name()] = [l.name() for l in h.lemmas()]\n colors[h.lemmas()[0].name()].extend(all_hyponyms(h)) \n for h in wn.syn... | [
"0.66811585",
"0.65616244",
"0.6313016",
"0.6313016",
"0.6290793",
"0.61005086",
"0.6089954",
"0.60429496",
"0.5975761",
"0.5883383",
"0.58637387",
"0.5859404",
"0.5786138",
"0.5778272",
"0.5763017",
"0.57571137",
"0.5754907",
"0.5680089",
"0.56760705",
"0.5626018",
"0.557508... | 0.79724157 | 0 |
Main method for importing colors. | def main(argv):
if not scribus.haveDoc(): #do we have a doc?
scribus.messageBox("csv2color", "No document to import colors \n Please open one, first.")
sys.exit()
else:
filename=scribus.fileDialog("csv2color", "CSV files(*.csv *.CSV *.txt *.TXT)")
while os.path.isdir(filename):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_gen_colors(self):\n result = magic.gen_colors(\"tests/test_files/test.jpg\")\n self.assertEqual(result[0], \"#0F191A\")",
"def importColors(colorlist):\n colordict=getColorDict()\n scribus.statusMessage(\"Defining new colors...\")\n scribus.progressTotal(len(colorlist)... | [
"0.6588256",
"0.65384364",
"0.62621117",
"0.6250665",
"0.6212625",
"0.611518",
"0.61103815",
"0.6095837",
"0.60434896",
"0.603946",
"0.59752774",
"0.5839723",
"0.58278394",
"0.5811394",
"0.5789526",
"0.5778762",
"0.575562",
"0.57390374",
"0.5717796",
"0.5715793",
"0.5709064",... | 0.69421935 | 0 |
The main_wrapper() function disables redrawing, sets a sensible generic status bar message, and optionally sets up the progress bar. It then runs the main() function. Once everything finishes it cleans up after the main() function, making sure everything is sane before the script terminates. | def main_wrapper(argv):
try:
#scribus.statusMessage("Running script...")
scribus.progressReset()
main(argv)
finally:
# Exit neatly even if the script terminated with an exception,
# so we leave the progress bar and status bar blank and make sure
# drawing is enabl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n #print( \"main() entered...\" )\n initialize()\n getCmdOptions()\n printVersionInfo()\n\n rc = doWork()\n\n cleanUp()\n sys.exit(rc)",
"def main():\n current_exit_code = 0\n # Launch NBA Stat Tracker main window\n app = QApplication(sys.argv)\n mw = MAIN_WINDOW.Trac... | [
"0.60658103",
"0.5858577",
"0.5656062",
"0.5638914",
"0.5635806",
"0.5588527",
"0.5584347",
"0.5548595",
"0.55001277",
"0.5480039",
"0.5461919",
"0.54452246",
"0.5442541",
"0.5432575",
"0.54216623",
"0.5389165",
"0.537975",
"0.5370261",
"0.5360387",
"0.5357461",
"0.5323044",
... | 0.7586774 | 0 |
Pytest fixture to create ResourceGraphDriver for other tests. | def rgd(mock_res_client, mock_creds, mock_sub_client):
AzCredentials = namedtuple("AzCredentials", ["legacy", "modern"])
mock_sub_client.return_value = _MockSubClient()
mock_creds.return_value = AzCredentials("cred", "cred")
mock_res_client.return_value = _MockResourceGraphClient()
rgd = ResourceGra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUpClass(cls):\n cur_dir = os.path.dirname(os.path.realpath(__file__))\n meta_file = os.path.join(cur_dir, 'testdata/meta.json')\n graph_file = os.path.join(cur_dir, 'testdata/graph.json')\n output_file = os.path.join(cur_dir, 'testdata/graph.dat')\n builder = os.path.join(cur_dir, '../../../t... | [
"0.58357966",
"0.58353907",
"0.5657772",
"0.5644507",
"0.56262153",
"0.5560915",
"0.55090374",
"0.54355985",
"0.5411806",
"0.54053926",
"0.53995866",
"0.53975886",
"0.53845555",
"0.5374215",
"0.5374215",
"0.5361416",
"0.5342002",
"0.53339076",
"0.5309978",
"0.530472",
"0.5295... | 0.58923876 | 0 |
Test query calling returns data in expected format. | def test_query(rgd):
data = rgd.query("test")
assert isinstance(data, pd.DataFrame)
assert data.iloc[0]["name"] == "vm1" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_records(self):\n pass",
"def test_execute(self):\n rset = self.connection.execute(self.rql, export_type=\"json\")\n self.assertTrue(len(rset) > 0)",
"def test_get_results(self):\n pass",
"def test_query_string(self):\n doc_count = 10\n ids = [get_rand_st... | [
"0.7061206",
"0.69826996",
"0.69156545",
"0.6877164",
"0.68105423",
"0.6789535",
"0.6788709",
"0.67580533",
"0.6708457",
"0.6707852",
"0.67008907",
"0.6680119",
"0.6637743",
"0.6604696",
"0.6571454",
"0.65621495",
"0.65586317",
"0.6558445",
"0.6553104",
"0.65360916",
"0.65308... | 0.7281129 | 0 |
Check if received parameters are ok to perform operations in the neuron | def _is_parameters_ok(self):
if self.maxresult is None:
raise MissingParameterException("Arithmetics neuron needs maxresult parameter.")
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_parameters_ok(self):\n if self.api_key is None:\n raise MissingParameterException(\"OpenWeatherMap neuron needs an api_key\")\n if self.location is None:\n raise MissingParameterException(\"OpenWeatherMap neuron needs a location\")\n\n return True",
"def _is_par... | [
"0.71913904",
"0.71913904",
"0.7116435",
"0.7084627",
"0.6999524",
"0.69967127",
"0.68786013",
"0.6820909",
"0.6721664",
"0.67124987",
"0.6706253",
"0.6655764",
"0.6595406",
"0.65659934",
"0.65381014",
"0.6511134",
"0.6498122",
"0.6485848",
"0.6419021",
"0.64133185",
"0.63878... | 0.74413085 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.