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 |
|---|---|---|---|---|---|---|
Write a decorator that prints UPPER_SLICE and LOWER_SLICE before and after calling the function (func) that is passed in ( is to preserve the original func's docstring) | def sandwich(func):
@functools.wraps(func)
def wrapped_decorator(*args, **kwargs):
print(UPPER_SLICE)
arguments= func(*args, **kwargs)
print(LOWER_SLICE)
return arguments
return wrapped_decorator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_wraps():\n print('func')",
"def trace(func):\n @wraps(func)\n def tracer(*args, **kwargs):\n name = func.__name__\n stack_size = int(len(inspect.stack(0)) / 2) # @wraps(func) is also increasing the size\n indent = stack_size*'\\t'\n print(f'{indent} > Entering \"{nam... | [
"0.59775233",
"0.59042966",
"0.58600795",
"0.58352566",
"0.58184",
"0.5748021",
"0.5739565",
"0.5706729",
"0.56139064",
"0.55796224",
"0.5578859",
"0.5534652",
"0.5532867",
"0.5523652",
"0.55230683",
"0.55105054",
"0.54960775",
"0.5491101",
"0.5476996",
"0.54521424",
"0.54212... | 0.8172087 | 0 |
Generates graph of connected peers Change to make this customisable | def generate_graph(self):
temp_graph = [[] for i in xrange(Parameters.num_peers)]
unconnected = set([i for i in xrange(Parameters.num_peers)])
while len(unconnected) > 1:
node1 = random.sample(unconnected, 1)[0]
unconnected.remove(node1)
node2 = random.sample(unconnected, 1)[0]
temp_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chain_graph(self) -> nx.DiGraph:\n edg_lst = [\n (f\"p{idx}\", f\"p{idx+1}\", self.d[f\"p{idx+1}\"]) for idx in range(self.n)\n ]\n chain_graph = nx.DiGraph()\n chain_graph.add_weighted_edges_from(edg_lst)\n return chain_graph",
"def chain_graph(self) -> nx.DiGra... | [
"0.62271756",
"0.61608636",
"0.5960585",
"0.58688587",
"0.5849908",
"0.5812597",
"0.57896066",
"0.57523227",
"0.5716475",
"0.57021713",
"0.56578314",
"0.56416863",
"0.56310755",
"0.56212884",
"0.56085145",
"0.5589877",
"0.5569081",
"0.5566458",
"0.55554277",
"0.5497438",
"0.5... | 0.6303654 | 0 |
Start thread for each peer | def start_peers(self):
for i in self.nodes:
i.start() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peer_server(self):\n try:\n listener_thread = threading.Thread(target=self.peer_server_listener)\n listener_thread.setDaemon(True)\n\n operations_thread = threading.Thread(target=self.peer_server_host)\n operations_thread.setDaemon(True)\n\n listene... | [
"0.67120516",
"0.65352994",
"0.649779",
"0.64329314",
"0.6382283",
"0.62863195",
"0.6221034",
"0.62145627",
"0.6192615",
"0.6154389",
"0.61105305",
"0.60992175",
"0.6057519",
"0.6056828",
"0.60463715",
"0.60429364",
"0.6019063",
"0.5967418",
"0.59653294",
"0.595958",
"0.59562... | 0.7830526 | 0 |
Get the network delay between pid1 and pid2 | def get_delay(self, pid1, pid2, is_block):
is_slow = self.node_is_slow[pid1] or self.node_is_slow[pid2]
p = random.uniform(Parameters.p_min, Parameters.p_max)
c = Parameters.c_low if is_slow else Parameters.c_high
m = Parameters.m if is_block else 0
d = random.expovariate(c / Parameters.d)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTimeDelay(*args):\n return args[0].TimeState.TimeDelay.time_delay",
"def get_delay(self, src, dst):\n try:\n fwd_delay = self.awareness.graph[src][dst]['lldpdelay']\n re_delay = self.awareness.graph[dst][src]['lldpdelay']\n src_latency = self.echo_latency[src]\n ... | [
"0.60461235",
"0.59016067",
"0.586062",
"0.56952107",
"0.55916893",
"0.55790615",
"0.55780035",
"0.5559182",
"0.554915",
"0.5509043",
"0.5487633",
"0.5454966",
"0.53850937",
"0.53481144",
"0.5299796",
"0.5299796",
"0.52713627",
"0.5267619",
"0.52288824",
"0.52207476",
"0.5209... | 0.75615823 | 0 |
This function defines the inital board of the game | def init_board():
# Generates a table 10*10 of 0s with -1 around and the initial state
# of the board with 2 whites and 2 blacks in the middle
table = [[0 if i != 0 and i != 9 else -1 for i in range(10)] if j != 0 and j != 9 else [-1 for i in range(10)] for j in range(10)] #leaves a -1 line around the whole table of... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initBoard(self):\n pass",
"def initialize_board(self):\n self.board = np.zeros(shape=(BOARD_SIZE, BOARD_SIZE), dtype=np.int) # another way of defining board: [[for x in range(cm.BOARD_SIZE)] for x in range(cm.BOARD_SIZE)]\n center = int(BOARD_SIZE / 2)\n self.board[center-1][cen... | [
"0.84164816",
"0.81662166",
"0.7968856",
"0.77619267",
"0.7733716",
"0.77081436",
"0.7704614",
"0.7676403",
"0.75649804",
"0.75117373",
"0.75034124",
"0.7497264",
"0.7476524",
"0.7459026",
"0.74174595",
"0.7414584",
"0.738848",
"0.73879623",
"0.73621136",
"0.73618233",
"0.734... | 0.83401465 | 1 |
This function finds the flipped pieces and returns them | def flipper(pos, coul, state_board):
tflips = []
for i in range(-1,2): # -1 to 1
for j in range(-1,2): #-1 to 1
for k in range(1,9): # 1 to 8
if state_board[pos[0]+i*k][pos[1]+j*k] == 0 or state_board[pos[0]+i*k][pos[1]+j*k] == -1: # if the case is empty or out of bounds
break;
elif state_board[pos[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_flip_piece():\n board = Board(640, 640, 8)\n board.start_game()\n board.gm.flip_pieces = [(3, 3)]\n current_color = board.game_pieces[3][3].color\n board.flip_pieces()\n assert board.game_pieces[3][3].color != current_color\n \n board.gm.flip_pieces = [(3, 4)]\n current_color = b... | [
"0.6014114",
"0.58825684",
"0.56461775",
"0.556043",
"0.5503755",
"0.54604626",
"0.5395813",
"0.53947204",
"0.5389461",
"0.53884953",
"0.53873485",
"0.5317875",
"0.52953404",
"0.5292987",
"0.52406585",
"0.52359927",
"0.5230201",
"0.5228546",
"0.52233607",
"0.5223231",
"0.5212... | 0.64342684 | 0 |
Context processor to fetch community stats from Django people and Django packages. This caches the resulting dictionary to lower the chance of overwhelming those services. | def community_stats(request):
stats = cache.get(STATS_CACHE_KEY, None)
if not stats:
stats = fetch(PEOPLE_STATS_URL)
packages_data = fetch(PACKAGES_STATS_URL)
if 'meta' in packages_data:
stats.update({'packages': packages_data['meta']['total_count']})
stats = {'comm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_context(self, request):\n script_name = request.META['SCRIPT_NAME']\n site_url = script_name if self.site_url == '/' and script_name else self.site_url\n # 把用户的groupID传给template\n # if Group.objects.filter(id = request.user.id):\n # group_context = Group.objects.get(... | [
"0.55988616",
"0.5566804",
"0.5502004",
"0.54921055",
"0.53882295",
"0.5386748",
"0.53179926",
"0.52953476",
"0.5235253",
"0.52319646",
"0.5156149",
"0.51293546",
"0.5121426",
"0.51195425",
"0.5102308",
"0.50859106",
"0.5080095",
"0.5077161",
"0.5069672",
"0.5065913",
"0.5061... | 0.7520238 | 0 |
Returns True if both submodels have same length | def _validate_submodels(self, type_promax, type_ms):
return type_promax in self._submodels and \
type_ms in self._submodels and \
len(self._submodels[type_promax]) > 0 and \
len(self._submodels[type_promax]) == len(self._submodels[type_ms]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n assert len(self.sent1) == len(self.sent2)\n return len(self.sent1)",
"def __eq__(self, other):\n return isinstance(other, type(self)) and self.size == other.size",
"def equal_size(self, other):\n if not isinstance(other, Matrix):\n raise ValueError(\"... | [
"0.62707317",
"0.62434",
"0.6213933",
"0.6097161",
"0.6058098",
"0.6052282",
"0.6001739",
"0.5992692",
"0.59679824",
"0.5957825",
"0.595145",
"0.59088415",
"0.5906478",
"0.5892642",
"0.58872175",
"0.5876356",
"0.58497226",
"0.58374107",
"0.5794245",
"0.57578903",
"0.575601",
... | 0.71253115 | 0 |
Validates type, returning ("normalized_type", submodel_fields) | def _validate_type(self, tp: str, name: str = None):
if tp is None:
return None, None
fields = None
if tp.startswith('{'):
# Submodel defined in JSON
fields = parse_json_model(tp, modelname=name)
if not fields:
return None, None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_model_field_types(self):\n self.assertTrue(isinstance(self.UserInfo.have_siblings, str))\n self.assertTrue(isinstance(self.UserInfo.known_env_exposures, str))\n self.assertTrue(isinstance(self.UserInfo.known_genetic_mutations, str))\n self.assertTrue(isinstance(self.UserInfo.ag... | [
"0.6012281",
"0.5627871",
"0.56062263",
"0.5541995",
"0.5448626",
"0.5435107",
"0.5423925",
"0.54003364",
"0.5392331",
"0.53780186",
"0.5370685",
"0.52956146",
"0.5276091",
"0.5266467",
"0.5264356",
"0.52599204",
"0.5195668",
"0.51644295",
"0.51417065",
"0.5140979",
"0.513462... | 0.6659755 | 0 |
Yields pairs from an iterable. | def pairs(iterable):
previous = None
for item in iterable:
current = item
if previous is not None:
yield previous, current
previous = current | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_pairs(iterable):\n if isinstance(iterable, Mapping):\n iterable = iterable.items()\n return iter(iterable)",
"def pairs(lst):\r\n\tfor i in range(1, len(lst), 2):\r\n\t\tyield lst[i-1], lst[i]",
"def pairwise(iterable):\r\n a = iter(iterable)\r\n return izip(a, a)",
"def pairs(lst... | [
"0.81223637",
"0.7461575",
"0.7307938",
"0.7271222",
"0.714917",
"0.7142806",
"0.7133279",
"0.7094758",
"0.70062834",
"0.6977689",
"0.6964083",
"0.6942506",
"0.6933127",
"0.6882018",
"0.6859719",
"0.68461996",
"0.6843346",
"0.6843346",
"0.6843346",
"0.6824935",
"0.6753879",
... | 0.77604663 | 1 |
lemmatize words in noun_phrases, exclude phrases with `STOPWORDS` | def lemmatized_phrases(self):
phrases = [set(lower_words(TextBlob(p).words.lemmatize()))
for p in self.blob.noun_phrases]
return [' '.join(p) for p in phrases if not STOPWORDS.intersection(p)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lemmatize_verbs(self):\n lemmas = []\n # lemmas = \"\"\n for word in self.words:\n lemma = wn.lemmatize(word, pos='v')\n lemmas.append(lemma)\n # lemmas += f\"{lemma} \"\n self.words = lemmas\n return self",
"def lemmatize_nouns(self, words):\n\t\tlemmatizer = WordNetLemma... | [
"0.73897773",
"0.73393244",
"0.72585356",
"0.7244815",
"0.71327686",
"0.69146174",
"0.68672264",
"0.68209785",
"0.6816726",
"0.6812039",
"0.6789802",
"0.6779173",
"0.67476636",
"0.6746864",
"0.6731405",
"0.6731262",
"0.67183787",
"0.6701651",
"0.66856176",
"0.66856176",
"0.66... | 0.8088282 | 0 |
downloading and renaming columns replace space with '_' | def download_datasets_csv(url):
# dataset = pd.read_csv(url, sep='\t')
dataset = pd.read_csv(url, sep=",")
dataset.columns = dataset.columns.str.replace(" ", "_")
return dataset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tidy_cols(my_csv):\n return [re.sub(\" \", \"_\", col.lower()) for col in my_csv.columns]",
"def _clean_up_table_column_names(loop_dict):\n \n # Make the column names all lowercase\n # and remove any underscores from the beginning\n for key in loop_dict.keys():\n rename_dict = { x:re.su... | [
"0.5891028",
"0.582513",
"0.5810645",
"0.5772185",
"0.5601228",
"0.558993",
"0.55504906",
"0.55083317",
"0.547578",
"0.5473249",
"0.54711485",
"0.54481345",
"0.5434032",
"0.54124486",
"0.53992754",
"0.5395076",
"0.5377607",
"0.532118",
"0.53113216",
"0.52825606",
"0.5271922",... | 0.586284 | 1 |
download and save historical + new dataset in complte dataset | def save_today_up_to_date_local_copy(url_hist, url_new):
df_historical = download_datasets_csv(url_hist)
df_new = download_datasets_csv(url_new)
# creating complete dataset
complete_dataset = df_historical.append(df_new, ignore_index=True)
# saving dataset
today = date.today().strftime("%d_%m_%Y... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_data_and_save():\n url = 'https://github.com/djay/covidthailand/wiki/combined.csv'\n s=requests.get(url).content\n global df\n global last_updated\n df=pd.read_csv(io.StringIO(s.decode('utf-8')), parse_dates= ['Date'])\n df.to_parquet(file_name, compression='UNCOMPRESSED')\n df.to_csv('jaydata.... | [
"0.7490032",
"0.70159507",
"0.6900648",
"0.673739",
"0.6722774",
"0.66758853",
"0.65556735",
"0.6517671",
"0.6412614",
"0.63694435",
"0.633438",
"0.6323673",
"0.63144374",
"0.62915635",
"0.62536067",
"0.6218456",
"0.6188079",
"0.61649686",
"0.61501503",
"0.61264765",
"0.61185... | 0.73869425 | 1 |
replacing data in Google Cloud Table | def replace_data_in_gbq_table(project_id, table_id, complete_dataset):
complete_dataset.to_gbq(
destination_table=table_id,
project_id=project_id,
credentials=credentials,
if_exists="replace",
)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_data(\n table_id: str = typer.Option(..., help=\"The id of the table\"),\n test: bool = typer.Option(False, help=\"Whether is a test or not\")\n) -> None:\n base_path = Path.cwd().parent\n\n tbl = bd.Table(dataset_id=\"br_cgu_servidores_executivo_federal\", table_id=table_id)\n output_pa... | [
"0.6006506",
"0.60053116",
"0.5916676",
"0.58872443",
"0.58701134",
"0.5751219",
"0.5727902",
"0.57181513",
"0.5715651",
"0.56847066",
"0.5664049",
"0.56344426",
"0.5623332",
"0.55554026",
"0.5548725",
"0.54871124",
"0.5472866",
"0.5461745",
"0.54568017",
"0.54271203",
"0.542... | 0.6709368 | 0 |
Parses the FJR produced by job in order to retrieve the WrapperExitCode and ExeExitCode. Updates the BossDB with these values. | def parseFinalReport(self, input):
from ProdCommon.FwkJobRep.ReportParser import readJobReport
codeValue = {}
jreports = readJobReport(input)
if len(jreports) <= 0 :
codeValue["applicationReturnCode"] = str(50115)
codeValue["wrapperReturnCode"] = str(50... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wsParseFJR(self):\n txt = '\\n#Written by cms_cmssw::wsParseFJR\\n'\n txt += 'echo \">>> Parse FrameworkJobReport crab_fjr.xml\"\\n'\n txt += 'if [ -s $RUNTIME_AREA/crab_fjr_$NJob.xml ]; then\\n'\n txt += ' if [ -s $RUNTIME_AREA/parseCrabFjr.py ]; then\\n'\n txt += ' ... | [
"0.64432395",
"0.5260613",
"0.52343196",
"0.52212924",
"0.519622",
"0.5182771",
"0.51703864",
"0.51282525",
"0.5100127",
"0.5092974",
"0.50409675",
"0.503647",
"0.5012631",
"0.50123405",
"0.49673423",
"0.49517173",
"0.49453866",
"0.49341914",
"0.49084947",
"0.49002942",
"0.48... | 0.71490014 | 0 |
Return the score obtained on the test data set | def score(self, test_data):
ins, outs = self._split_inputs_outputs(test_data)
return self.model.score(ins, outs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score(self, test_data):\n\n\t\tpass",
"def score(self, test_data):\n\n\t\tins, outs = self._split_inputs_outputs(test_data)\n\n\t\t# One hot encode the input/labels\n\t\tencoder = LabelEncoder()\n\t\tencoder.fit(outs)\n\t\tenc_labels = encoder.transform(outs)\n\t\tenc_labels = np_utils.to_categorical(enc_lab... | [
"0.86668295",
"0.7818388",
"0.77717274",
"0.77294904",
"0.76660264",
"0.76660264",
"0.76569784",
"0.73830205",
"0.7382572",
"0.7316532",
"0.7287335",
"0.72611284",
"0.7224763",
"0.7224763",
"0.7218049",
"0.7218049",
"0.7199401",
"0.7164144",
"0.71476907",
"0.71476907",
"0.714... | 0.8328699 | 1 |
Return parameter details for dim, nIter, lamb and alph | def paramDetails(cls):
return {
'dim': (10, 20, 2, 20),
'nIter': (1, 10, 2, 5),
'lamb': (.1, 1., .1, .05),
'alph': (30, 50, 5, 40)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setParams(self,dim=20, nIter=5, lamb=0.05, alph=40):\n self._dim = dim\n self._nIter = nIter\n self._lamb = lamb\n self._alph = alph",
"def show_parameters(self):\n with np.printoptions(precision=3, suppress=True):\n print('number of wind phase = {}'.format(self.... | [
"0.66055083",
"0.65783185",
"0.6249512",
"0.60537255",
"0.6009132",
"0.60000795",
"0.599074",
"0.5983164",
"0.59602505",
"0.59599835",
"0.59563273",
"0.5954735",
"0.5952508",
"0.59498894",
"0.59248936",
"0.5918452",
"0.5881164",
"0.58748",
"0.5865431",
"0.5844908",
"0.5821393... | 0.74654466 | 0 |
Java Float Matrix is a 1D array writen column after column. Numpy reads row after row, therefore, we need a conversion. | def _float_matrix2numpy(self, java_float_matrix):
columns_input = java_float_matrix.toArray()
split = lambda lst, sz: [numpy.fromiter(lst[i:i+sz],dtype=numpy.float)
for i in range(0, len(lst), sz)]
cols = split(columns_input, java_float_matrix.rows)
matri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrixToFloatMatrix(matrix):\n\n float_matrix = [matrix(i, j) for i in xrange(4) for j in xrange(4)]\n\n outMatrix = OpenMaya.MFloatMatrix()\n OpenMaya.MScriptUtil.createFloatMatrixFromList(float_matrix , outMatrix)\n\n return outMatrix",
"def itemsToFloat(self):\n returnva... | [
"0.7274915",
"0.66002345",
"0.6478091",
"0.62763405",
"0.59943956",
"0.58819616",
"0.58508307",
"0.58382297",
"0.58107084",
"0.5799",
"0.57688916",
"0.57163143",
"0.5654517",
"0.56448877",
"0.56354064",
"0.5616841",
"0.5608916",
"0.55774224",
"0.5566227",
"0.5564168",
"0.5546... | 0.7982614 | 0 |
Given a ManagedProcess protobuf instance, create the corresponding ProcessNode and insert it into the graph. | def add_node(self, managed_process_pb):
node = ProcessNode(managed_process_pb)
if node.name not in self.nodes:
self.nodes[node.name] = node
self.logger.info('Created node for [{}]'.format(node.name))
else:
self.logger.error(
'Detected request ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_node_process(name, properties):\n process = NodeProcess(name)\n DB.session.add(process)\n DB.session.commit()\n for p in properties:\n prop = NodeProcessProperty(process.id, p[0], p[1], p[2])\n DB.session.add(prop)\n DB.session.commit()\n return process",
"def add_proce... | [
"0.6773554",
"0.64495486",
"0.60057384",
"0.5933061",
"0.5871152",
"0.58102006",
"0.5744983",
"0.57229316",
"0.5719331",
"0.56770027",
"0.5667292",
"0.5577523",
"0.5570289",
"0.55650806",
"0.55393213",
"0.55308384",
"0.5441535",
"0.5393277",
"0.5389408",
"0.5335206",
"0.52840... | 0.7839599 | 0 |
Reset all adjacency information and rebuild it after adding nodes. This implements a collection of sanity checks (making sure every subscribed topic has a publisher, etc.) which, if they all pass, mean we can safely / sanely construct the dependency graph. | def build(self):
self.logger.info('Rebuilding adjacency information')
self.edges = collections.defaultdict(list)
topic_to_publisher = collections.defaultdict(list)
topic_to_subscribers = collections.defaultdict(list)
node_to_missing_deps = collections.defaultdict(list)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reset_state(self):\n # Directed graph, (u, v) => v depends on u. u, v are pairs of (rule_name, rule_dir_abs)\n # Used for generating Topological Sort\n self._rule_to_dependency_graph_adjlist = {}\n self._topologically_sorted_build_rule_names = []\n\n # List of (dependency_na... | [
"0.65324295",
"0.63045096",
"0.6301467",
"0.6183333",
"0.6102479",
"0.6050887",
"0.6023047",
"0.5987564",
"0.5974988",
"0.58748007",
"0.5874257",
"0.58559334",
"0.5806248",
"0.5778933",
"0.5771964",
"0.5762822",
"0.57474977",
"0.57438475",
"0.57006",
"0.5695009",
"0.56947756"... | 0.7615647 | 0 |
Private. Resets the traversal state of all nodes in preparation for a new traversal | def _reset_traversal_state(self):
for n in self.nodes.values():
n.reset_traversal_state() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_tree(self):\n self.root = None\n self.action = None\n self.dist_probability = None",
"def reset_visited(self):\n self.__visited = False",
"def reset_graph(self):\n self.nodes = {}\n self.add_node(self.initial_state)\n self.add_node(self.final_state)",
... | [
"0.74285185",
"0.73662233",
"0.7337941",
"0.73155934",
"0.7201365",
"0.71484256",
"0.7138489",
"0.71265846",
"0.71129096",
"0.71065027",
"0.7018088",
"0.6959817",
"0.6881637",
"0.6879142",
"0.681779",
"0.6811828",
"0.6801169",
"0.67853063",
"0.67844963",
"0.6764829",
"0.67444... | 0.8812322 | 0 |
Perform a depthfirst traversal of the entire graph. The supplied visitor_function callable is called twice per | def depth_first_traversal(self, visitor_function=None):
self._reset_traversal_state()
self.time = 0
result = False
for n in self.nodes.values():
if NodeColor.WHITE == n.color:
stack = collections.deque()
stack.append(n)
while... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traverse_depth_first(self, fn):\n queue = deque([self.root])\n while len(queue) > 0:\n node = queue.popleft()\n fn(node)\n queue.extendleft(reversed(node.children))",
"def _traverse_region_graph(root: Region, fun: Callable[[Region], None]) -> None:\n visited_... | [
"0.69131184",
"0.6532276",
"0.63960713",
"0.6223167",
"0.61571103",
"0.59844995",
"0.59705156",
"0.59194154",
"0.59114933",
"0.5801044",
"0.5797877",
"0.5770219",
"0.5733677",
"0.5723791",
"0.5710354",
"0.5705172",
"0.5666923",
"0.5657166",
"0.5648695",
"0.5614636",
"0.561195... | 0.69286025 | 0 |
This lengthy, irritating piece of code returns the slice idcs for subcube (i,j) in a decomposition of an original map of shape (2HD_res[0],2HD_res[1]) with chunks of 2LD_res per sides, together with buffers[0],[1] buffers pixel on each side, fixed by the periodicity condition of the HD map. Nothing very subtle for the ... | def get_slices_chk_N(N, LD_res, HD_res, buffers, inverse=False):
assert len(LD_res) == 2 and len(HD_res) == 2
if np.all(LD_res == HD_res):
assert N == 0, N
assert buffers == (0, 0), buffers
sl0_LD = slice(0, 2 ** LD_res[0]) # Center of buffered cube
sl1_L... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _segments2slices(array_size, grid_segments, patch_segments):\n patch_slices = [slice(start, stop) for start, stop in patch_segments]\n array_slices = []\n\n for start, stop in grid_segments:\n segment_size = max(abs(start), abs(stop))\n k = int(ceil(float(segment_size) / array_size) + (-... | [
"0.60255563",
"0.5919896",
"0.58811724",
"0.5863269",
"0.585582",
"0.58138037",
"0.57283646",
"0.56544244",
"0.5653726",
"0.56497926",
"0.5631293",
"0.55874455",
"0.5561426",
"0.5546333",
"0.55354935",
"0.55143887",
"0.5499627",
"0.54738224",
"0.5452872",
"0.54172575",
"0.541... | 0.6117562 | 0 |
Function that integer validator to a name and value | def integer_validator(self, name, value):
self.name = name
self.value = value
if type(value) is not int:
raise TypeError("{} must be an integer".format(name))
if value <= 0:
raise ValueError("{} must be greater than 0".format(name))
self.value = value
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def integer_validator(self, name, value):\n if type(value) is not int:\n raise TypeError(name + \" must be an integer\")\n elif value <= 0 and name not in (\"x\", \"y\"):\n raise ValueError(name + \" must be > 0\")\n elif value < 0 and name in (\"x\", \"y\"):\n ... | [
"0.8130921",
"0.788335",
"0.7841091",
"0.7826758",
"0.7700402",
"0.7427867",
"0.7427867",
"0.7261612",
"0.7167946",
"0.70053536",
"0.693558",
"0.6867623",
"0.67775255",
"0.6776555",
"0.67418826",
"0.6563546",
"0.65442383",
"0.6446882",
"0.6382053",
"0.6289101",
"0.626554",
... | 0.8029562 | 1 |
Set pin as high | def set_pin_high(pin):
HIGH_PINS.append(pin) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_high(pin):\n _write_value(HIGH, \"{0}/gpio{1}/value\".format(_path_prefix, pin))",
"def gpio_output_high(self, pin: int) -> None:\n self._pins[pin - 1] = \"OUTPUT_HIGH\"",
"def set_pin_low(pin):\n if pin in HIGH_PINS:\n HIGH_PINS.remove(pin)",
"def set_pin(self):\n GPIO.set... | [
"0.8202024",
"0.7684762",
"0.76168716",
"0.756904",
"0.74249405",
"0.720764",
"0.7134327",
"0.711949",
"0.71125674",
"0.7103002",
"0.70253396",
"0.69540894",
"0.68812466",
"0.6861089",
"0.6766074",
"0.67559886",
"0.6692666",
"0.66920656",
"0.66851836",
"0.6638315",
"0.6575943... | 0.85144776 | 0 |
Return a related filter_name, using the filterset relationship if present. | def related(filterset, filter_name):
if not filterset.relationship:
return filter_name
return LOOKUP_SEP.join([filterset.relationship, filter_name]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filter_name(self):\n pass",
"def get_param_filter_name(cls, param, rel=None):\n # check for empty param\n if not param:\n return param\n\n # strip the rel prefix from the param name.\n prefix = '%s%s' % (rel or '', LOOKUP_SEP)\n if rel and param.starts... | [
"0.6471144",
"0.62778616",
"0.58047044",
"0.56574893",
"0.56555384",
"0.56209326",
"0.5564204",
"0.55566245",
"0.5534012",
"0.5517095",
"0.5462722",
"0.54582113",
"0.5367023",
"0.5363491",
"0.53548676",
"0.53417313",
"0.53322023",
"0.5322664",
"0.526207",
"0.52405727",
"0.522... | 0.8743976 | 0 |
Resolve `AutoFilter`s into their perlookup filters. `AutoFilter`s are a declarative alternative to the `Meta.fields` dictionary syntax, and use the same machinery internally. | def expand_auto_filters(cls, new_class):
# get reference to opts/declared filters
orig_meta, orig_declared = new_class._meta, new_class.declared_filters
# override opts/declared filters w/ copies
new_class._meta = copy.deepcopy(new_class._meta)
new_class.declared_filters = new_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadFilters(ufo):\n preFilters, postFilters = [], []\n for filterDict in ufo.lib.get(FILTERS_KEY, []):\n namespace = filterDict.get(\"namespace\", \"ufo2ft.filters\")\n try:\n filterClass = getFilterClass(filterDict[\"name\"], namespace)\n except (ImportError, AttributeErr... | [
"0.5492552",
"0.5431763",
"0.5252897",
"0.52475154",
"0.5196505",
"0.5192317",
"0.5170377",
"0.5147656",
"0.5139516",
"0.50391585",
"0.4980402",
"0.49512303",
"0.49480322",
"0.49272498",
"0.49130383",
"0.49125457",
"0.489388",
"0.48330957",
"0.48206162",
"0.4809472",
"0.48018... | 0.5948139 | 0 |
Returns the subset of filters that should be initialized by the FilterSet, dependent on the requested `params`. This helps minimize the cost of initialization by reducing the number of deepcopy ops. The `rel` argument is used for related filtersets to strip the param of its relationship prefix. See `.get_param_filter_n... | def get_filter_subset(cls, params, rel=None):
# Determine names of filters from query params and remove empty values.
# param names that traverse relations are translated to just the local
# filter names. eg, `author__username` => `author`. Empty values are
# removed, as they indicate an... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_request_filters(self):\n # build the compiled set of all filters\n requested_filters = OrderedDict()\n for filter_name, f in self.filters.items():\n requested_filters[filter_name] = f\n\n # exclusion params\n exclude_name = '%s!' % filter_name\n ... | [
"0.6619125",
"0.6226987",
"0.6226987",
"0.60220295",
"0.56563276",
"0.557124",
"0.5495559",
"0.5387023",
"0.537955",
"0.5361835",
"0.5359296",
"0.53389424",
"0.53347725",
"0.5314394",
"0.53115654",
"0.52742255",
"0.5228215",
"0.5208534",
"0.51974314",
"0.5195309",
"0.5190603"... | 0.8191257 | 0 |
Disable filter subsetting, allowing the form to render the filterset. Note that this decreases performance and should only be used when rendering a form, such as with DRF's browsable API. | def disable_subset(cls, *, depth=0):
if not issubclass(cls, SubsetDisabledMixin):
cls = type('SubsetDisabled%s' % cls.__name__,
(SubsetDisabledMixin, cls), {})
# recursively disable subset for related filtersets
if depth > 0:
# shallow copy to prev... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_filtering(self):\r\n clone = copy.deepcopy(self)\r\n clone._allow_filtering = True\r\n return clone",
"def non_hidden(self):\n return self.filter(hidden=False)",
"def non_hidden(self):\n return self.filter(hidden=False)",
"def __disableSearchEdit(self):\n s... | [
"0.6328865",
"0.61500955",
"0.61500955",
"0.61072856",
"0.5808935",
"0.57838905",
"0.57728505",
"0.5675368",
"0.56208265",
"0.5614127",
"0.55958295",
"0.55693483",
"0.5554618",
"0.5534325",
"0.5480112",
"0.5472331",
"0.5463367",
"0.5458596",
"0.5456048",
"0.54518133",
"0.5449... | 0.6411095 | 0 |
Build a set of filters based on the request data. This currently includes only filter exclusion/negation. | def get_request_filters(self):
# build the compiled set of all filters
requested_filters = OrderedDict()
for filter_name, f in self.filters.items():
requested_filters[filter_name] = f
# exclusion params
exclude_name = '%s!' % filter_name
if relate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_filters(self, req):\n filters = {}\n properties = {}\n\n for param in req.params:\n if param in SUPPORTED_FILTERS:\n filters[param] = req.params.get(param)\n if param.startswith('property-'):\n _param = param[9:]\n pro... | [
"0.7212947",
"0.70940274",
"0.7063467",
"0.70396554",
"0.70150787",
"0.7010616",
"0.68755764",
"0.67024094",
"0.67008877",
"0.6694236",
"0.6660822",
"0.6646979",
"0.65543395",
"0.65318733",
"0.64761287",
"0.64659613",
"0.6453026",
"0.64314073",
"0.6378158",
"0.63564056",
"0.6... | 0.7715377 | 0 |
Get the related filterset instances for all related filters. | def get_related_filtersets(self):
related_filtersets = OrderedDict()
for related_name in self.related_filters:
if related_name not in self.filters:
continue
f = self.filters[related_name]
related_filtersets[related_name] = f.filterset(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_related_filtersets(self, queryset):\n for related_name, related_filterset in self.related_filtersets.items():\n # Related filtersets should only be applied if they had data.\n prefix = '%s%s' % (related(self, related_name), LOOKUP_SEP)\n if not any(value.startswit... | [
"0.7343028",
"0.67154413",
"0.61035365",
"0.60354567",
"0.5970218",
"0.59653723",
"0.5931315",
"0.58990955",
"0.5755272",
"0.5717431",
"0.5715828",
"0.5692265",
"0.5688741",
"0.5616253",
"0.5609072",
"0.5583161",
"0.55796957",
"0.5577063",
"0.55623674",
"0.55400354",
"0.55383... | 0.82383394 | 0 |
Filter the provided `queryset` by the `related_filtersets`. It is recommended that you override this method to change the filtering behavior across relationships. | def filter_related_filtersets(self, queryset):
for related_name, related_filterset in self.related_filtersets.items():
# Related filtersets should only be applied if they had data.
prefix = '%s%s' % (related(self, related_name), LOOKUP_SEP)
if not any(value.startswith(prefix)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_filters(self, queryset, applicable_filters=None, applicable_exclusions=None):\n if applicable_filters:\n queryset = queryset.filter(applicable_filters)\n if applicable_exclusions:\n queryset = queryset.exclude(applicable_exclusions)\n return queryset",
"def ge... | [
"0.67854434",
"0.6782465",
"0.66839457",
"0.6680913",
"0.646492",
"0.63564074",
"0.63288736",
"0.63143224",
"0.63010234",
"0.6240037",
"0.6125244",
"0.60945296",
"0.608679",
"0.6075394",
"0.6073214",
"0.60558784",
"0.60067743",
"0.60016656",
"0.5998127",
"0.59923685",
"0.5961... | 0.84336936 | 0 |
Callback function for metrics_btn A window will popup to display the user metadata of previous user | def display_metrics(self):
metrics = client.user_metrics(self.user_name.get())
messagebox.showinfo("Metrics", metrics) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_metrics3(self):\n messagebox.showinfo(\"Processed Image Metrics\", self.pro_metrics)",
"def display_metrics2(self):\n messagebox.showinfo(\"Original Image Metrics\", self.raw_metrics)",
"def user_labels_prev(*args):\n return _ida_hexrays.user_labels_prev(*args)",
"def action_sessio... | [
"0.5536531",
"0.5336233",
"0.5274754",
"0.52151805",
"0.5156828",
"0.51532024",
"0.51404095",
"0.509433",
"0.50761753",
"0.50675863",
"0.5057054",
"0.5030155",
"0.49895877",
"0.49638245",
"0.49565363",
"0.4928132",
"0.49049008",
"0.48959267",
"0.48698136",
"0.4867956",
"0.486... | 0.63189566 | 0 |
Callback function for im_metrics_btn1 A window will popup to display the original image metadata | def display_metrics2(self):
messagebox.showinfo("Original Image Metrics", self.raw_metrics) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_metrics3(self):\n messagebox.showinfo(\"Processed Image Metrics\", self.pro_metrics)",
"def win5_ManageData_Caption(event=None):\r\n\r\n clearwin()\r\n global IMAGES_FILE_PATH\r\n global i\r\n i = 0\r\n\r\n Descriptions = load()\r\n imgs = []\r\n if os.path.exists(IMAGES_F... | [
"0.69807404",
"0.62527585",
"0.58932143",
"0.58668804",
"0.58499783",
"0.58255225",
"0.5808261",
"0.57940733",
"0.5692784",
"0.56442815",
"0.5617792",
"0.5611394",
"0.55932826",
"0.5588301",
"0.5586624",
"0.5570289",
"0.555042",
"0.5538848",
"0.55376774",
"0.55155426",
"0.548... | 0.73585606 | 0 |
Callback function for im_metrics_btn2 A window will popup to display the processed image metadata | def display_metrics3(self):
messagebox.showinfo("Processed Image Metrics", self.pro_metrics) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_metrics2(self):\n messagebox.showinfo(\"Original Image Metrics\", self.raw_metrics)",
"def btn_display_hist_callback(self):\n self.show_as_waiting(True)\n ids = self.tbl_images.get_selected_ids()\n names = self.tbl_images.get_selected_names()\n\n for id, name in zip... | [
"0.7458454",
"0.616558",
"0.60215414",
"0.5975251",
"0.584566",
"0.582564",
"0.5801999",
"0.5760714",
"0.5755779",
"0.5739632",
"0.5733116",
"0.56553966",
"0.56404024",
"0.5639404",
"0.5581315",
"0.5552886",
"0.5552128",
"0.55366683",
"0.5528491",
"0.55033773",
"0.5477598",
... | 0.74962056 | 0 |
Check if the output from server is a string of error message Raise error if it is string. It should be a dictionary. | def check_r_type(r):
if type(r) is str:
raise TypeError('Get Error message.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_rpc_value ( user_dict ):\n for key in user_dict:\n if not isinstance ( user_dict[ key ], str ):\n # Error code 422\n raise ValueError ( 'Value of {0} is not a string'.format ( key ) )",
"def is_error(response: str) -> bool:\n return \"ERROR\" in respo... | [
"0.67002916",
"0.6622685",
"0.65426445",
"0.64297044",
"0.6372873",
"0.62947875",
"0.61671525",
"0.604404",
"0.6020194",
"0.59307563",
"0.590339",
"0.5883814",
"0.5872144",
"0.58716655",
"0.58712596",
"0.5850643",
"0.5848179",
"0.5827672",
"0.58271694",
"0.58263636",
"0.58262... | 0.68892103 | 0 |
Extract filename and extension from filepath | def get_file_name(filepath): # need pytest
filename, extension = os.path.splitext(filepath.split('/')[-1])
return filename, extension | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_ext(path):\n result = os.path.splitext(path)[1]\n return result",
"def get_file_ext(path: str) -> str:\n return os.path.splitext(os.path.basename(path))[1]",
"def get_file_name_with_ext(path: str) -> str:\n return os.path.basename(path)",
"def _get_ext(self, path):\n return os.pat... | [
"0.80850315",
"0.7980222",
"0.7961075",
"0.79087883",
"0.7875789",
"0.7851262",
"0.7824376",
"0.7815243",
"0.7754425",
"0.7731678",
"0.7668338",
"0.7649159",
"0.76470023",
"0.7626894",
"0.7625784",
"0.76075673",
"0.7575197",
"0.7550891",
"0.75276417",
"0.7518576",
"0.74935955... | 0.79995126 | 1 |
Check if multiple or single file is chosen. | def check_multi_single(filenames):
num = len(filenames)
if num == 1:
single = bool(1)
else:
single = bool(0)
return single | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_multi_file(self):\n return 'files' in self.torrent['info']",
"def select_files():\n\n if not Settings.is_prompt(): return [File.get_random_file()]\n category = Settings.select_category()\n if not category: return File.select_file_upload_method()\n # if not Settings.confi... | [
"0.6862918",
"0.6714143",
"0.64036655",
"0.6360947",
"0.62420434",
"0.6179852",
"0.6168158",
"0.606886",
"0.6025578",
"0.5963181",
"0.59183747",
"0.5914388",
"0.59100074",
"0.59086585",
"0.5877628",
"0.5876562",
"0.5874005",
"0.58681023",
"0.5844574",
"0.5818032",
"0.5810063"... | 0.6930178 | 0 |
Run image analysis for zip archive | def run_zip_analysis(filepath, ID, method):
with zipfile.ZipFile(filepath[0]) as zf:
for entry in zf.namelist():
if not entry.startswith("__"): # Get rid hidden files in zip
with zf.open(entry) as file:
data = file.read()
fh = io.BytesIO(d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n\n today = datetime.now().strftime(\"%Y-%m-%d\")\n log_file = os.path.abspath(\"logs/{}.log\".format(today))\n logger = RsmasLogger(\"pipeline\", log_file)\n\n images = get_list_of_images()\n # LOG: list of images to process\n logger.log(loglevel.INFO, [img.key for img in images])\n\n... | [
"0.64381856",
"0.63635296",
"0.6358149",
"0.6324381",
"0.62869585",
"0.6232183",
"0.6155203",
"0.6140258",
"0.6044015",
"0.6022487",
"0.5966659",
"0.5904075",
"0.5880147",
"0.58736247",
"0.5790913",
"0.5768327",
"0.57619715",
"0.5741277",
"0.57412493",
"0.5739594",
"0.5689725... | 0.693419 | 0 |
Check if message contains Error or Warning for run_analysis functions. | def check_msg(msg):
err = bool(0)
if 'Error' in msg:
err = bool(1)
elif "Warning" in msg:
msg = 'Success! Warning: Image already exists. ' \
'Processing ran on existing image'
else:
msg = 'Image saved successfully'
return err, msg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_check(self, message):\n matches = ERROR_SYNTAX.match(message)\n if matches:\n error_code = int(matches.group(1))\n error_message = matches.group(2)\n return error_code, error_message\n return None",
"def collect_errors_and_warnings(self) -> str:\n ... | [
"0.6047532",
"0.59931284",
"0.59822315",
"0.5976988",
"0.5970713",
"0.59450835",
"0.59394825",
"0.5925255",
"0.5906123",
"0.59012663",
"0.5873115",
"0.58316827",
"0.57754755",
"0.57746696",
"0.57093453",
"0.5681229",
"0.56606114",
"0.5603111",
"0.558577",
"0.5583142",
"0.5579... | 0.6277207 | 0 |
Check if message contains Error for get new_user_id function. Raise a ValueError if message contains "Error" | def check_user(msg):
if "Error" in msg:
raise ValueError('User already exists.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_message_id(self, user, item_id, message_id):\n try:\n\n err_options = message_id.split(':', 2)\n msg_error_count = int(err_options[1])\n\n # check for token update\n if len(err_options) > 1 and err_options[2] != str(self.get_token(user)):\n ... | [
"0.67848724",
"0.61461526",
"0.6122",
"0.6017559",
"0.5941634",
"0.5908885",
"0.59077275",
"0.5874253",
"0.5843121",
"0.5823432",
"0.5823432",
"0.5823432",
"0.57579714",
"0.57539093",
"0.5725768",
"0.57183814",
"0.57163316",
"0.57006186",
"0.56851375",
"0.5680018",
"0.5669614... | 0.701784 | 0 |
Upload image(s) and run the required analysis for multiple or single image file(s) | def run_images_analysis(filepath, ID, method):
for path in filepath:
try:
Image.open(path)
except IOError:
msg = 'Please import images files, or just a single zip archive'
else:
filename, extension = get_file_name(path)
# Save raw image to dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n \n # for inserting other images, add tem to /input folder and list them here\n images = (\n 'image-0',\n 'image-1',\n 'image-2'\n )\n\n for image_name in images:\n print(image_name, \"image:\")\n\n image = open_image(image_name)\n display_image(im... | [
"0.6907992",
"0.6606996",
"0.65919435",
"0.6470824",
"0.6414355",
"0.6368806",
"0.6355245",
"0.63245857",
"0.6265804",
"0.62025523",
"0.62011194",
"0.6152564",
"0.6149888",
"0.61378866",
"0.61241436",
"0.608345",
"0.60723394",
"0.606071",
"0.606038",
"0.6033568",
"0.6033372",... | 0.76435435 | 0 |
Download multiple processed images in a zip archive. | def download_multiple(select_files, savepath, id, ext):
with zipfile.ZipFile(savepath + '/processed_images.zip', mode='w') as zf:
for file in select_files:
pro_img, _, _, _, _ = get_image_pair(file, id)
output = io.BytesIO()
pro_img.save(output, format=ext)
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downloadImages(self):\n\t\ti = 0\n\t\tfor im in self.images:\n\t\t\t# Let's get the file extension and file name and make the final file path. \n\t\t\t# We need to do this to slugify the file name and avoid errors when loading images\n\t\t\tfile_name, file_extension = os.path.splitext(im['url'])\n\t\t\tfile_na... | [
"0.76530296",
"0.72565246",
"0.68648124",
"0.673801",
"0.6725581",
"0.67049855",
"0.67010486",
"0.6687771",
"0.6672859",
"0.6647223",
"0.6634884",
"0.66337126",
"0.66298825",
"0.66295946",
"0.65946233",
"0.65826285",
"0.6576",
"0.65477145",
"0.6529526",
"0.6509803",
"0.650044... | 0.7829335 | 0 |
This method will store a MistAssociation object into mongodb after creating a MistAssociation with the same values as the Association provided. Secret will be encoded because it constantly produced errors with encoding. | def storeAssociation(self, server_url, association):
mist_association = MistAssociation()
mist_association.assoc_type = association.assoc_type
mist_association.handle = association.handle.hex()
mist_association.secret = association.secret.hex()
mist_association.lifetime = associ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def storeAssociation(self, server_url, assoc):\n assoc = models.Association(url=server_url,\n handle=assoc.handle,\n association=assoc.serialize())\n assoc.put()",
"def storeAssociation(self, server_url, association):\r\n entity = datastore.Entity('Associati... | [
"0.702098",
"0.6713939",
"0.56481075",
"0.53882486",
"0.5067821",
"0.50430053",
"0.5034432",
"0.493951",
"0.49269888",
"0.4900855",
"0.48810253",
"0.48749557",
"0.4837358",
"0.48064864",
"0.48010197",
"0.4800175",
"0.47752208",
"0.4773829",
"0.47659233",
"0.47503135",
"0.4745... | 0.705629 | 0 |
Called when using a nonce. This method should return C{True} if the nonce has not been used before, and store it for a while to make sure nobody tries to use the same value again. If the nonce has already been used or the timestamp is not current, return C{False}. You may use L{openid.store.nonce.SKEW} for your timesta... | def useNonce(self, server_url, timestamp, salt):
if is_nonce_old(timestamp):
return False
try:
mist_nonces = MistNonce.objects(server_url=server_url, salt=salt,
timestamp=timestamp)
except me.DoesNotExist:
mist_non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def useNonce(self, nonce):\r\n query = datastore.Query('Nonce')\r\n query['nonce ='] = nonce\r\n query['created >='] = (datetime.datetime.now() -\r\n datetime.timedelta(hours=6))\r\n\r\n results = query.Get(1)\r\n if results:\r\n datastore.Delete(results[0].key())\r\n ... | [
"0.73136973",
"0.6600226",
"0.6195637",
"0.61672926",
"0.61513644",
"0.6094848",
"0.6070164",
"0.6020712",
"0.6004455",
"0.5996191",
"0.5996191",
"0.59095937",
"0.5881976",
"0.5801852",
"0.5756545",
"0.569583",
"0.5590977",
"0.5563972",
"0.55559796",
"0.5550194",
"0.5542444",... | 0.76029676 | 0 |
Shortcut for C{L{cleanupNonces}()}, C{L{cleanupAssociations}()}. This method is not called in the normal operation of the library. It provides a way for store admins to keep their storage from filling up with expired data. | def cleanup(self):
return self.cleanupNonces(), self.cleanupAssociations() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(self, *args, **kwargs):",
"def _cleanup(self):\n pass",
"def cleanup():",
"def cleanup(*args, **kwargs): # real signature unknown\n pass",
"def cleanup(self):\n\n pass",
"def cleanup(self):\n raise NotImplementedError",
"def cleanup(self):\n pass",
"def cleanup(... | [
"0.7016629",
"0.69023955",
"0.66813576",
"0.6666886",
"0.66557264",
"0.65890634",
"0.6582056",
"0.6582056",
"0.6582056",
"0.6582056",
"0.6582056",
"0.6582056",
"0.6582056",
"0.6582056",
"0.6582056",
"0.6582056",
"0.6582056",
"0.6575037",
"0.65191555",
"0.6517952",
"0.649991",... | 0.73417866 | 0 |
View application's service logs. | def logs(app_or_svc, host, uniq, service):
try:
app, uniq, logtype, logname = app_or_svc.split('/', 3)
except ValueError:
app, uniq, logtype, logname = app_or_svc, uniq, 'service', service
if any(param is None for param in [app, uniq, logtype, logname]):
cli.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLogs():",
"def getLogs():",
"def logs(self):\n return self.logger.logs()",
"def log(self):\n resp = requests.get(\"%s/api/log\"%self.urlbase, verify=False)\n return resp.json[\"log\"]",
"def logs(self, shell=False):\n if self.app_id:\n return self.yarn_api.logs... | [
"0.68098724",
"0.68098724",
"0.64053893",
"0.6395825",
"0.630246",
"0.6281809",
"0.6209214",
"0.62079066",
"0.611495",
"0.61128664",
"0.6103324",
"0.60686356",
"0.6053491",
"0.6024822",
"0.60207194",
"0.5982966",
"0.5934909",
"0.5930149",
"0.59281075",
"0.59259474",
"0.592594... | 0.6984841 | 0 |
Find nodeinfo endpoint on host | def _nodeinfo_endpoint(host):
zkclient = context.GLOBAL.zk.conn
nodeinfo_zk_path = '{}/{}'.format(z.ENDPOINTS, 'root')
for node in zkclient.get_children(nodeinfo_zk_path):
if 'nodeinfo' in node and host in node:
data, _metadata = zkclient.get(
'{}/{}'.format(nodeinfo_zk_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getHostInfo():",
"def get_node_details(self, node):\n node_details = self.parser.find_server_by_ip(node.get('ip')) or \\\n self.parser.find_server_by_hostname(node.get('host'))\n\n return node_details",
"def getHost():",
"def getHost():",
"def test_get_node_internal_... | [
"0.7210888",
"0.66543496",
"0.6595249",
"0.6595249",
"0.6384198",
"0.62400854",
"0.6236083",
"0.6164553",
"0.6050032",
"0.6024226",
"0.5987261",
"0.5953469",
"0.593182",
"0.5915911",
"0.59002453",
"0.5839691",
"0.58132106",
"0.57908964",
"0.5767918",
"0.5744465",
"0.57380223"... | 0.7731481 | 0 |
dropout + batch norm + l1_l2 | def architecture_CONV_FC_batch_norm_dropout_L1_l2(
X, nbclasses, nb_conv=1, nb_fc=1, kernel_initializer="random_normal"
):
# input size
width, height, depth = X.shape
input_shape = (height, depth)
# parameters of the architecture
l1_l2_rate = 1.0e-3
dropout_rate = 0.5
conv_kernel = 3
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def architecture_CONV_FC_batch_norm_dropout_L1_l2_LEAKY_ReLU(\n X, nbclasses, nb_conv=1, nb_fc=1\n):\n # input size\n width, height, depth = X.shape\n input_shape = (height, depth)\n\n # parameters of the architecture\n l1_l2_rate = 1.0e-3\n dropout_rate = 0.5\n conv_kernel = 3\n conv_fi... | [
"0.6057391",
"0.6015575",
"0.59682286",
"0.59510905",
"0.5895679",
"0.5895679",
"0.5812982",
"0.57391614",
"0.5654636",
"0.5644836",
"0.56329393",
"0.56230843",
"0.5617473",
"0.56083846",
"0.5606605",
"0.55982274",
"0.55822885",
"0.5554348",
"0.5552772",
"0.554574",
"0.554353... | 0.6199096 | 0 |
dropout + batch norm + l1_l2 | def architecture_CONV_FC_batch_norm_dropout_L1_l2_LEAKY_ReLU(
X, nbclasses, nb_conv=1, nb_fc=1
):
# input size
width, height, depth = X.shape
input_shape = (height, depth)
# parameters of the architecture
l1_l2_rate = 1.0e-3
dropout_rate = 0.5
conv_kernel = 3
conv_filters = 64
n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def architecture_CONV_FC_batch_norm_dropout_L1_l2(\n X, nbclasses, nb_conv=1, nb_fc=1, kernel_initializer=\"random_normal\"\n):\n # input size\n width, height, depth = X.shape\n input_shape = (height, depth)\n\n # parameters of the architecture\n l1_l2_rate = 1.0e-3\n dropout_rate = 0.5\n c... | [
"0.6198059",
"0.6015281",
"0.596931",
"0.5949474",
"0.58950055",
"0.58950055",
"0.5811575",
"0.5737953",
"0.56548023",
"0.5646338",
"0.563125",
"0.5623065",
"0.56162375",
"0.5609015",
"0.5605381",
"0.5597299",
"0.5579035",
"0.55545306",
"0.5553643",
"0.5545299",
"0.5540341",
... | 0.60564125 | 1 |
r""" Find named groups in `pattern` and replace them with the group name. E.g., 1. ^(?P\w+)/b/(\w+)$ ==> ^/b/(\w+)$ 2. ^(?P\w+)/b/(?P\w+)/$ ==> ^/b//$ | def replace_named_groups(pattern):
named_group_indices = [
(m.start(0), m.end(0), m.group(1))
for m in named_group_matcher.finditer(pattern)
]
# Tuples of (named capture group pattern, group name).
group_pattern_and_name = []
# Loop over the groups and their start and end indices.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename_regex_groups(pattern):\n\n grp_rewritten = ''\n mapping = dict()\n rmapping = dict()\n cnt = 1\n for item in _NAMED_GRP_PATTERN.split(pattern):\n if _NAMED_GRP_PATTERN.fullmatch(item):\n old_name = item[len(_NAMED_GRP_PREFIX):-len(_NAMED_GRP_S... | [
"0.7320233",
"0.67950296",
"0.605959",
"0.6014507",
"0.5789089",
"0.5741866",
"0.55717754",
"0.5548644",
"0.55015105",
"0.5437232",
"0.54301506",
"0.53881884",
"0.5342404",
"0.53323615",
"0.52918",
"0.5223952",
"0.520838",
"0.51812756",
"0.5165162",
"0.5128126",
"0.510275",
... | 0.7663291 | 0 |
r""" Find unnamed groups in `pattern` and replace them with ''. E.g., 1. ^(?P\w+)/b/(\w+)$ ==> ^(?P\w+)/b/$ 2. ^(?P\w+)/b/((x|y)\w+)$ ==> ^(?P\w+)/b/$ | def replace_unnamed_groups(pattern):
unnamed_group_indices = [m.start(0) for m in unnamed_group_matcher.finditer(pattern)]
# Indices of the start of unnamed capture groups.
group_indices = []
# Loop over the start indices of the groups.
for start in unnamed_group_indices:
# Handle nested par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_named_groups(pattern: str, noncapturing: bool = True) -> str:\n if noncapturing:\n new_parens = \"(?:\"\n else:\n new_parens = \"(\"\n\n return re.sub(r\"\\(\\?P<\\w+>\", new_parens, pattern)",
"def replace_named_groups(pattern):\n named_group_indices = [\n (m.start(0)... | [
"0.680426",
"0.6300317",
"0.60647875",
"0.58528376",
"0.5731375",
"0.56507546",
"0.56190664",
"0.5457598",
"0.5445742",
"0.5427602",
"0.5402431",
"0.5378804",
"0.531599",
"0.52673435",
"0.5245449",
"0.5193543",
"0.5173778",
"0.51385576",
"0.50884974",
"0.50674146",
"0.5060320... | 0.73646694 | 0 |
if keys from dict occur in kw, pop them | def _kw_extract(kw,dict):
for key,value in dict.items():
dict[key]=kw.pop(key,value)
return kw,dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mRemove(self, **kw):\n kw = copy_non_reserved_keywords(kw)\n for key, val in kw.items():\n # It would be easier on the eyes to write this using\n # \"continue\" statements whenever we finish processing an item,\n # but Python 1.5.2 apparently doesn't let you use \... | [
"0.659709",
"0.658242",
"0.64829236",
"0.6343324",
"0.62005615",
"0.602767",
"0.59886026",
"0.5980594",
"0.5973243",
"0.59430367",
"0.5851196",
"0.5803663",
"0.578763",
"0.5769544",
"0.5725139",
"0.5696665",
"0.564784",
"0.56437635",
"0.5620172",
"0.56135494",
"0.5593906",
... | 0.73164487 | 0 |
plot(f) allows f to be (x,y) tuple | def plot(f,**kw):
if type(f)==tuple:
x,y=f
pl.plot(x,y,**kw)
else:
pl.plot(f,**kw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_plot(x,y):",
"def plot():\n pass",
"def plot_f(self, *args, **kwargs):\r\n kwargs['plot_raw'] = True\r\n self.plot(*args, **kwargs)",
"def __plot(self, x: list, y:list):\r\n # clear the figure\r\n self.figure.clear()\r\n # create an axis\r\n self.canvas.a... | [
"0.7233913",
"0.67269236",
"0.6719971",
"0.643809",
"0.63938314",
"0.63545954",
"0.62653416",
"0.61198306",
"0.6113964",
"0.6108317",
"0.60705554",
"0.6022874",
"0.5939718",
"0.59299445",
"0.59191865",
"0.5891549",
"0.58682585",
"0.58335316",
"0.5833347",
"0.5831018",
"0.5812... | 0.8709098 | 0 |
Plot values along direction dir={0,1,2}, through point pt=[x,y,z] | def plot_values_along(pp,pt=[0.5,0.5,0.5],**kw):
kv = {'dir':0, 'verbose':0, 'all':False, 'iv':0, 'i4':0, 'var':None}
kw,kv = _kw_extract(kw,kv)
plot(ds.values_along(pp,pt,iv=kv['iv'],dir=kv['dir'],all=kv['all']),**kw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_point(axis, pnt3d, color):\n xy = bc2xy(pnt3d)\n axis.scatter(xy[0], xy[1], c=color, marker='o')",
"def plot_direction(ax, phi_deg, psi_deg, \n color='black', marker='d', markersize=3,\n label=None, label_position='right', weight='normal'):\n phi_rad = phi_de... | [
"0.6262929",
"0.6006915",
"0.57216173",
"0.5702731",
"0.56610227",
"0.5660082",
"0.5647964",
"0.5641175",
"0.56411433",
"0.5629691",
"0.56232494",
"0.5620824",
"0.5591335",
"0.5566767",
"0.5546428",
"0.5539211",
"0.553336",
"0.553327",
"0.552634",
"0.5522603",
"0.55138886",
... | 0.605601 | 1 |
Delete matches category and all its channels. | async def delete_matches_category(self):
existing_categories = self.get_channels(
'matches', ChannelType.category)
for c in existing_categories:
try:
await asyncio.gather(*(chan.delete() for chan in c.channels))
await c.delete()
# We ca... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(self, channel=None):\n # falls `channel` angegeben wurden, werden nur diese bereinigt,\n # ansonsten wird alles bereinigt\n if channel:\n # ueberpruefe, ob `channel` eine Zahl ist und erstelle eventuell eine Liste nur mit dieser Zahl\n # dies ist wichtig, weil... | [
"0.64337945",
"0.6401022",
"0.6107181",
"0.6081878",
"0.5946473",
"0.5895014",
"0.587733",
"0.5871811",
"0.5821551",
"0.5815859",
"0.57719624",
"0.5770912",
"0.5759033",
"0.57166386",
"0.5705552",
"0.5697941",
"0.5684132",
"0.56386846",
"0.55753577",
"0.5554672",
"0.55487365"... | 0.8869049 | 0 |
Gets the user mention string. If the user isn't found, just return the username. | def mention_user(self, username: str) -> str:
member = self.get_user(username)
if member:
return member.mention
return username | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_user_mention(self, name: str) -> str:\n try:\n return self.known_user_ids[name]\n except KeyError:\n pass\n\n mention = name\n users = get_value_from_redis('slack-members') or []\n user = self._get_user(name, users)\n if user:\n me... | [
"0.78680474",
"0.75037277",
"0.698189",
"0.698189",
"0.68996614",
"0.6867837",
"0.67106825",
"0.6666238",
"0.66000545",
"0.6591795",
"0.6591795",
"0.65639687",
"0.65635896",
"0.65554214",
"0.65437853",
"0.64928955",
"0.64731586",
"0.6467594",
"0.6467354",
"0.6457515",
"0.6457... | 0.8424426 | 0 |
Get member by username. | def get_user(self, username: str) -> Optional[discord.Member]:
for m in self.guild.members:
if utils.istrcmp(m.display_name, username):
return m
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(self, username):\n\t\treturn self.users.get(username, None)",
"def get_member(self, user):\n for player in self.members:\n if player.uuid == user.id:\n return player\n return None",
"def Get(self, username):\n if self._users:\n return self._users.get... | [
"0.75246143",
"0.7495561",
"0.74683446",
"0.74049187",
"0.73253155",
"0.7299027",
"0.72175676",
"0.71334416",
"0.7068116",
"0.7049825",
"0.7039728",
"0.6946112",
"0.69360876",
"0.69183743",
"0.69003195",
"0.689256",
"0.68825346",
"0.6881717",
"0.68705404",
"0.68620247",
"0.68... | 0.8309965 | 0 |
Calculate Time To Prepare All Layers. This funtion takes the lasagna number of layers as a parameter and mutiplies that value with the designated preparation time. | def preparation_time_in_minutes(number_of_layers):
layers_preparation_time = number_of_layers * PREPARATION_TIME
return layers_preparation_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preparation_time_in_minutes(number_of_layers: int) -> int:\n return PREPARATION_TIME_PER_LAYER_IN_MINUTES * number_of_layers",
"def preparation_time_in_minutes(number_of_layers):\n return number_of_layers * 2",
"def preparation_time_in_minutes(number_of_layers):\n return PREPARATION_TIME * number_... | [
"0.74356353",
"0.7422801",
"0.73030597",
"0.7143981",
"0.5985816",
"0.5975828",
"0.5915438",
"0.5865488",
"0.57980657",
"0.5677244",
"0.5349525",
"0.5309606",
"0.5289832",
"0.52619296",
"0.5260173",
"0.5198084",
"0.51720953",
"0.5171042",
"0.5160975",
"0.5144867",
"0.51287425... | 0.7569402 | 0 |
Calculate Total Elapsed Time. This funtion takes the lasagna number of layers as a parameter and also the elapsed bake time and adds both values to aquire an accurate result hoe much time we have spent baking the lasagna. | def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
preparation_time = preparation_time_in_minutes(number_of_layers)
total_bake_time = preparation_time + elapsed_bake_time
return total_bake_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elapsed_time_in_minutes(no_of_layers, elapsed_bake_time):\n return preparation_time_in_minutes(no_of_layers) + elapsed_bake_time",
"def elapsed_time_in_minutes(number_of_layers: int, elapsed_bake_time: int) -> int:\n return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time",
"def elap... | [
"0.75032663",
"0.7467269",
"0.74404085",
"0.73925406",
"0.64541507",
"0.6305446",
"0.6257169",
"0.6257169",
"0.6257169",
"0.6000466",
"0.5808721",
"0.5773526",
"0.5667682",
"0.5637501",
"0.5635833",
"0.55388767",
"0.552437",
"0.5441152",
"0.5426811",
"0.53834176",
"0.53707606... | 0.7721855 | 0 |
get address by id | def get_address_by_id(address_id: int):
try:
address = address_service.get_address_by_id(address_id)
current_app.logger.info("Return data for address_id: {}".format(address_id))
return jsonify({
"data": {
"address": address
}}), 200
except SQLCusto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bank_address_by_id(bank_id: int) -> str:\n # Open a new connection\n db, cursor = db_connector.cursor()\n\n query = \"select address from bank where name = '{}';\".format(bank_id)\n cursor.execute(query)\n data = cursor.fetchall()\n db.disconnect()\n return data[0][0]",
"def get_supp... | [
"0.7158677",
"0.70268",
"0.6940104",
"0.6777704",
"0.67587537",
"0.6659815",
"0.6643687",
"0.65674657",
"0.6503904",
"0.6471765",
"0.64163893",
"0.6403165",
"0.63863844",
"0.6383097",
"0.6337203",
"0.6270841",
"0.6270169",
"0.6261926",
"0.62596136",
"0.62596136",
"0.6199845",... | 0.75688535 | 0 |
delete address by id | def delete_address(address_id: int):
try:
current_app.logger.info("delete address : address_id: %s", address_id)
return jsonify({
"status": address_service.delete_address_by_id(address_id)
}), 200
except SQLCustomError as error:
current_app.logger.error("fail to delet... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, request, *args, **kwargs):\n # validate address id and get object\n instance = self.get_object()\n\n # get last transaction save point id\n sid = transaction.savepoint()\n\n try:\n # soft delete address\n instance.delete_address(request.user... | [
"0.75762683",
"0.72528064",
"0.70932806",
"0.7015976",
"0.7014734",
"0.6979125",
"0.68229157",
"0.6805178",
"0.67385775",
"0.67281526",
"0.6688489",
"0.66123915",
"0.6570931",
"0.6570451",
"0.65646535",
"0.6552276",
"0.654469",
"0.6536282",
"0.6487301",
"0.6466477",
"0.645843... | 0.7932358 | 0 |
This will create persuasions in bulk and will push it to ES API /persuasion/bulk/create [ { | def bulk_create():
logger.info("Creating persuasions in bulk")
try:
request_data = json.loads(request.data)
with concurrent.futures.ThreadPoolExecutor(max_workers=settings.MAX_WORKERS) as executor:
{executor.submit(PersuasionServices.create, data): data for data i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle(self, *args, **options):\n self.create_indices()\n self.bulk()",
"def insert_to_elastic(elastic, paper_authors, papers, authors, index_name):\n helpers.bulk(elastic, merge_to_elastic(paper_authors, papers, authors, index_name))",
"def bulk_refresh():\n logger.info(\"Refreshin... | [
"0.60707426",
"0.6044942",
"0.6015414",
"0.5868079",
"0.58612776",
"0.58422595",
"0.57517433",
"0.5748778",
"0.5713514",
"0.56829447",
"0.56696784",
"0.5647391",
"0.5640021",
"0.56258446",
"0.5564406",
"0.5555156",
"0.5547321",
"0.5522877",
"0.5503289",
"0.5487169",
"0.544674... | 0.79547685 | 0 |
This will update the persuasion and will return it API /persuasion/refresh?push_to_es=true&push_to_inflow=false { | def refresh_persuasion():
try:
request_data = json.loads(request.data)
meta = request.args
persuasion = PersuasionServices.refresh(request_data, meta)
except Exception as e:
error_msg = "Getting persuasion details - " + repr(e)
logger.error(err... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_refresh():\n logger.info(\"Refreshing/Updating persuasions in bulk\")\n try:\n args = request.args\n if not args.get(\"type\") or not args.get(\"sub_type\"):\n return jsonify(\n dict(status=\"failure\", message=\"Invalid type/sub_ty... | [
"0.68004",
"0.65762883",
"0.6169109",
"0.6017237",
"0.58676904",
"0.58676904",
"0.5842514",
"0.58078766",
"0.571597",
"0.5683472",
"0.5669192",
"0.56609315",
"0.56607497",
"0.56477195",
"0.56477195",
"0.5646708",
"0.5581315",
"0.5581315",
"0.55265003",
"0.5518151",
"0.5514036... | 0.8352617 | 0 |
This will update persuasions in bulk and will push it to ES API /persuasion/bulk/refresh?push_to_es=true&push_to_inflow=false [ { | def bulk_refresh():
logger.info("Refreshing/Updating persuasions in bulk")
try:
request_data = json.loads(request.data)
args = request.args
with concurrent.futures.ThreadPoolExecutor(max_workers=settings.MAX_WORKERS) as executor:
{executor.submit(Persu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_refresh():\n logger.info(\"Refreshing/Updating persuasions in bulk\")\n try:\n args = request.args\n if not args.get(\"type\") or not args.get(\"sub_type\"):\n return jsonify(\n dict(status=\"failure\", message=\"Invalid type/sub_ty... | [
"0.76656324",
"0.6743843",
"0.6214206",
"0.59055984",
"0.58515877",
"0.57441527",
"0.5547801",
"0.54766494",
"0.54745275",
"0.54507333",
"0.5444725",
"0.542627",
"0.53595006",
"0.5348997",
"0.5331371",
"0.52764916",
"0.527101",
"0.52681786",
"0.5237418",
"0.5237225",
"0.52309... | 0.8021315 | 0 |
This will also update persuasions in bulk based on type subtype and will push it to ES API /persuasion/schedule/refresh?push_to_es=true&push_to_inflow=false&type=quality_score&sub_type=inventory_depth | def schedule_refresh():
logger.info("Refreshing/Updating persuasions in bulk")
try:
args = request.args
if not args.get("type") or not args.get("sub_type"):
return jsonify(
dict(status="failure", message="Invalid type/sub_type"))
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bulk_refresh():\n logger.info(\"Refreshing/Updating persuasions in bulk\")\n try:\n request_data = json.loads(request.data)\n args = request.args\n with concurrent.futures.ThreadPoolExecutor(max_workers=settings.MAX_WORKERS) as executor:\n {executor... | [
"0.5894394",
"0.552447",
"0.5422689",
"0.51684684",
"0.51551306",
"0.50729585",
"0.50314814",
"0.495626",
"0.49350718",
"0.48938638",
"0.48739257",
"0.48735148",
"0.48624405",
"0.48345262",
"0.48125353",
"0.47565222",
"0.47560182",
"0.47403848",
"0.47322214",
"0.46917525",
"0... | 0.6947471 | 0 |
Convert any text to a fernet key for encryption. | def any_text_to_fernet_key(self, text):
md5 = fingerprint.fingerprint.of_text(text)
fernet_key = base64.b64encode(md5.encode("utf-8"))
return fernet_key | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text2PublicKey(text:str):\n return RSA.importKey(b58decode(text))",
"def encrypt(text):\r\n\r\n cipher = fuzz(text)\r\n return hexify(cipher)",
"def fernet_encript(key,message):\n\tf = Fernet(key)\n\treturn f.encrypt(message)",
"def caesar_encryption(text):\n result = ''\n for char in text:\n ... | [
"0.6408409",
"0.6371177",
"0.63681877",
"0.6212298",
"0.61476415",
"0.60205185",
"0.60133415",
"0.60062563",
"0.6004446",
"0.5816517",
"0.5788318",
"0.5727161",
"0.56803447",
"0.56624347",
"0.5623659",
"0.56033343",
"0.560295",
"0.55829906",
"0.5578667",
"0.5558498",
"0.55552... | 0.85045666 | 0 |
Manually enter a password for encryption on keyboard. | def input_password(self): # pragma: no cover
password = input("Please enter your secret key (case sensitive): ")
self.set_password(password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enter_password(self):",
"def enter_password(self):\n self.password.clear()\n self.password.click()\n self.password.send_keys(TestData.PASSWORD)\n sleep(TestData.DELAY)\n return self.password",
"async def password(self, ctx):\n pass",
"def prompt_pass():\n msg ... | [
"0.81982946",
"0.7473501",
"0.7234966",
"0.7115085",
"0.70761955",
"0.7038702",
"0.693298",
"0.68611926",
"0.68122035",
"0.67915016",
"0.67278564",
"0.67168885",
"0.6711128",
"0.67014295",
"0.66786796",
"0.66681784",
"0.66681784",
"0.66681784",
"0.66681784",
"0.66681784",
"0.... | 0.78404224 | 1 |
Open the deletion modal for an address row. | def delete_address(self) -> object:
self.delete_button.click()
return DeletionModal(self).wait_for_component_to_be_present() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_address(self, address: dict) -> None:\n row = self.addresses_list.surface_address_row(address)\n\n row.open_kebab_menu()\n row.kebab_menu.delete_address()\n\n self.deletion_modal.confirm_address_deletion()",
"def DeleteRow(self, entry):\n for a_link in entry.link:\n ... | [
"0.70819616",
"0.61636835",
"0.6088303",
"0.5755534",
"0.5709963",
"0.55882573",
"0.55848145",
"0.5560167",
"0.55589795",
"0.55150014",
"0.5407896",
"0.5399962",
"0.5394524",
"0.53886646",
"0.5371516",
"0.5349296",
"0.5309787",
"0.53002477",
"0.529465",
"0.52785975",
"0.52676... | 0.77717626 | 0 |
Open the edit address form for an address row. A conditional check for whether the URL contains 'admin' allows this method to be used in both OnDemand Web and OnDemand Admin. | def edit_address(self) -> object:
self.edit_button.click()
if 'admin' not in self.driver.current_url:
return WebAddressForm(self).wait_for_component_to_be_present()
return AdminAddressForm(self).wait_for_component_to_be_present() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_edit_address(self, address: dict) -> None:\n row = self.addresses_list.surface_address_row(address)\n\n row.open_kebab_menu()\n row.kebab_menu.edit_address()",
"def __editAddress(self):\n idx = self.bookmarksTree.currentIndex()\n idx = idx.sibling(idx.row(), 1)\n ... | [
"0.7748994",
"0.6355615",
"0.5770656",
"0.5743798",
"0.5656257",
"0.55580795",
"0.55527085",
"0.55411637",
"0.5522946",
"0.5501704",
"0.5454978",
"0.5401237",
"0.5389246",
"0.5380006",
"0.53368807",
"0.53319603",
"0.5306126",
"0.52961576",
"0.52745545",
"0.52547807",
"0.52438... | 0.81699383 | 0 |
Run the algorithm for the scores in the axis layer (0 for x, 1 for y). This score and the associated ranking are reliable, the ranking of the opposite score is not. | def run(self, axis, gamma):
# Trajectories of the main score to compute and the opposite one
traj_s, traj_o = [_np.ones(self.d[axis])], [_np.ones(self.d[1-axis])]
# Ranked indices of the scores
rank_s, rank_o = _np.array([], dtype=int), _np.array([], dtype=int)
# List of nod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_run(self, axis):\n if (self.x_traj, self.y_traj)[axis] is None:\n if (self.inverse_x_traj, self.inverse_y_traj)[axis] is None:\n raise Exception('The algorithm has not been run.')\n else:\n if self.params['print_info']:\n prin... | [
"0.6627804",
"0.6555331",
"0.6459971",
"0.5922805",
"0.5655154",
"0.5596297",
"0.5581356",
"0.5572477",
"0.55473816",
"0.5538019",
"0.5492573",
"0.5474258",
"0.5454743",
"0.54495645",
"0.54365635",
"0.5428014",
"0.54214275",
"0.54198104",
"0.5418108",
"0.5414656",
"0.5410967"... | 0.66810125 | 0 |
Given the scores s, the list of nodes that already reached the low boundary and the ranking computed so far, check if new nodes have reached the low boundary, and, if so, updated the ranking with those | def _update_zero_rank(self, s, zero_ind, rank):
lb = self.params['low_bound']
new_zeros_ind = _np.setdiff1d(_np.nonzero(s <= lb), zero_ind)
if len(new_zeros_ind) > 0:
sorted_zeros_ind = new_zeros_ind[_np.argsort(s[new_zeros_ind])]
rank = _np.append(rank, sorted_zeros_ind)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rerank_candidates(s, pred2sub_rank, all_predictions, rerank_top=20):\n predicted_smiles = []\n model_input = []\n for (predict_smi, label), _ in Counter(all_predictions).most_common(rerank_top):\n if predict_smi == s:\n continue\n features = get_all_features(\n get_... | [
"0.5954974",
"0.59247744",
"0.5833818",
"0.56625795",
"0.56450963",
"0.5566416",
"0.55646116",
"0.5558839",
"0.5552098",
"0.5540993",
"0.55369794",
"0.5497016",
"0.546615",
"0.54586864",
"0.5453142",
"0.54514194",
"0.54451036",
"0.5403085",
"0.53968745",
"0.53879005",
"0.5386... | 0.6555181 | 0 |
Get two lists (for rows and columns) where the row/col index gives the list of col/row indexes of the nonzero elements. | def _get_index_lists(self, mat):
n_row, n_col = mat.shape
col_ind_at_row, row_ind_at_col = [],[]
for i in range(n_row):
aux_ind = _np.where(mat[i]>0)[0]
if len(aux_ind) == 0:
raise Exception('Row {} is composed of zeros'.format(i))
col... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_empty_cells(state):\n cells = []\n for row_index, row in enumerate(state.board):\n for col_index, cell in enumerate(row):\n if cell == 0:\n cells.append([row_index, col_index])\n return cells",
"def empty_cells(state):\n cells = []\n\n for i, row in enumera... | [
"0.70034736",
"0.6999915",
"0.6924702",
"0.6525192",
"0.6505699",
"0.6490474",
"0.64878106",
"0.6456846",
"0.6356905",
"0.63506573",
"0.6348926",
"0.62902606",
"0.6273074",
"0.62722355",
"0.6267735",
"0.62005794",
"0.6167228",
"0.61156595",
"0.6083813",
"0.6070011",
"0.606649... | 0.72458094 | 0 |
Check if the algorithm has been run. It also return the trajectories and the ranking of the associated axis | def _check_run(self, axis):
if (self.x_traj, self.y_traj)[axis] is None:
if (self.inverse_x_traj, self.inverse_y_traj)[axis] is None:
raise Exception('The algorithm has not been run.')
else:
if self.params['print_info']:
print('Warning:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, axis, gamma):\n \n # Trajectories of the main score to compute and the opposite one\n traj_s, traj_o = [_np.ones(self.d[axis])], [_np.ones(self.d[1-axis])]\n # Ranked indices of the scores\n rank_s, rank_o = _np.array([], dtype=int), _np.array([], dtype=int)\n # ... | [
"0.57092583",
"0.5609589",
"0.5562583",
"0.5543754",
"0.54045916",
"0.5378096",
"0.5376567",
"0.5344754",
"0.53006",
"0.52756476",
"0.5219423",
"0.51986915",
"0.51444024",
"0.51367295",
"0.51324886",
"0.50954634",
"0.50765365",
"0.506339",
"0.50485265",
"0.50454706",
"0.50318... | 0.7411444 | 0 |
Compute the extinction area of a binary matrix formatted as a "indexes_lists" (see "_get_index_lists"), given a ranking of the nodes and the axis (0 for row removing, 1 for column removing). | def _ext_area(axis, ranking, row_ind_at_col, col_ind_at_row):
if axis == 0:
indexes_lists = _np.array([col_ind_at_row[:], row_ind_at_col[:]])
else:
indexes_lists = _np.array([row_ind_at_col[:], col_ind_at_row[:]])
if len(ranking) != len(indexes_lists[0]):
print ('Dimensions do not ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def independendentColumns(matrix, rank, threshold):\n\n index = [None]*rank\n norms = [None]*rank\n\n if rank == 0:\n return index\n\n # select the first column\n index[0] = 0\n norms[0] = np.linalg.norm(matrix[:, 0])\n idx = 1\n\n if rank == 1:\n return index\n\n for i in rang... | [
"0.5215772",
"0.4802194",
"0.47601265",
"0.47544992",
"0.47510993",
"0.4719506",
"0.46831623",
"0.46391895",
"0.46330476",
"0.46060845",
"0.4589925",
"0.4584294",
"0.45521936",
"0.45242146",
"0.45011955",
"0.4497215",
"0.44914553",
"0.44876465",
"0.44790936",
"0.44733527",
"0... | 0.75243336 | 0 |
This algorithm returns a cutlist which performs a vertical core operation. The laser cuts off one side of poly at a time, rotating the block such that the edge of the laser "cone" is parallel to the SCD core. After one side of the block has been removed, the block is rotated 90 degrees and the algorithm repeats until a... | def vertical_core(block,cut,laser):
layers = int(block["thickness"]/laser["z_spacing"])
angle = math.radians(laser["kerf_angle"]/2)
taper = math.tan(angle) * laser["z_spacing"]
u = math.tan(2 * angle) * (block["thickness"] + laser["z_final_overshoot"])
z_0 = block["thickness"]*math.cos(angle) + math.sin(a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetContourValuesLengthsAndSubContoursAndOrderOfSubContoursByFrame(\n watershed, allValsByFrame\n):\n scListByFrame, orderOfSCsByValueByFrame = GetSubContoursAndOrderingByFrame(\n watershed, allValsByFrame\n )\n cVLSByFrame = [[sc.cVLS() for sc in scList] for scList in scListByFrame]\n ret... | [
"0.5736482",
"0.54933506",
"0.5457592",
"0.5425763",
"0.5424649",
"0.54244435",
"0.5406228",
"0.5358565",
"0.53265375",
"0.5317147",
"0.5295013",
"0.5287533",
"0.5257076",
"0.524541",
"0.51966155",
"0.51694214",
"0.5141546",
"0.51079696",
"0.51050085",
"0.5099054",
"0.5085029... | 0.6428014 | 0 |
This algorithm returns a cutlist which performs a cut which is a quarter of the total slicing required to create a pyramid top, while ensuring a flat bottom above it, both of which is required for an OG seed. | def pyramid_slice(x1,y1,x2,y2,z,delta,deltaz,taper_x,taper_y,taper_straight,layers):
cutlist = []
y_max = abs(y1-y2)
for a in range(layers):
i = 0
new_x1, new_y1, new_x2, new_y2 = x1 - a*taper_x, y1-a*taper_straight, x2+a*taper_x, y2+a*taper_y
while abs(new_y1 - (y1 - a*taper_straight)) < y_max and x1 > ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cuts(l, step, size):\n ncuts= (len(l)-size)/step + 1\n cuts= [None]*ncuts\n for i in xrange(ncuts): \n cuts[i]= l[i*step:i*step+size]\n if ncuts*step < len(l):\n cuts.append(l[ncuts*step:])\n return cuts",
"def generate_possible_slices(L, H):\n n_min = 2 * L\n n_max = H... | [
"0.6510405",
"0.6228084",
"0.60608464",
"0.60395974",
"0.5939082",
"0.59373015",
"0.5816045",
"0.5764991",
"0.5731781",
"0.5705467",
"0.57034826",
"0.57019746",
"0.5698488",
"0.56911135",
"0.56729025",
"0.5668522",
"0.56589216",
"0.5610545",
"0.56084186",
"0.5563644",
"0.5558... | 0.67580295 | 0 |
This algorithm returns a cutlist which performs OG slicing. It begins with an optional core, then cuts out slices until as many OG seeds as specified are removed from the block. | def oss_stacked(block, cut, laser):
x0_1, x1_1, z0_1, taper_x_1, taper_y_1, layers_1, pyramid_angle_1 = oss_helper(block, cut, laser, cut["final_dimension_x"]/2)
x0_2, x1_2, z0_2, taper_x_2, taper_y_2, layers_2, pyramid_angle_2 = oss_helper(block, cut, laser, cut["final_dimension_y"]/2)
angle = math.radians(laser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _iterative_cutting(g, p):\n\n to_be_processed = [g]\n K = math.ceil(len(g.nodes()) / p)\n\n res = []\n while len(to_be_processed) > 0:\n\n g = to_be_processed.pop()\n g_l, g_r = kernighan_lin_bisection(g, weight=\"rate\")\n\n ... | [
"0.55150145",
"0.5500191",
"0.5455198",
"0.5378894",
"0.53707415",
"0.5246031",
"0.5238846",
"0.5228055",
"0.51568055",
"0.51228464",
"0.51081675",
"0.51019835",
"0.5090313",
"0.5088919",
"0.50825244",
"0.5066888",
"0.50596964",
"0.5026915",
"0.5015684",
"0.5010477",
"0.50010... | 0.5538502 | 0 |
This algorithm takes a cutlist and returns an estimate for the time | def time_taken(json_cutlist, laser):
cutlist = json.loads(json_cutlist)
time = 0
coordinate_array = [0, 0]
for a in cutlist:
if a[0] == "jump" or a[0] == "mark":
coordinate_array = [float(a[1]) - coordinate_array[0], float(a[2]) - coordinate_array[1]]
mag = math.sqrt(coordinate_array[0]**2 + coordina... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hit_time(tmat,start_list,targ_list,ntraj = 1000, cutoff=1000):\n \n # get state names\n nstates = tmat.shape[0]\n states = array([ii for ii in range(nstates)])\n \n times = list()\n \n for ii in range(ntraj):\n curr = choice(start_list)\n tm = 0\n while curr not in ... | [
"0.627223",
"0.5568012",
"0.55149806",
"0.542661",
"0.54003626",
"0.5371899",
"0.5357149",
"0.5351884",
"0.5332691",
"0.53161633",
"0.52837616",
"0.52747995",
"0.5273911",
"0.52718514",
"0.52711356",
"0.5226085",
"0.5219191",
"0.51971257",
"0.51944643",
"0.5190102",
"0.518243... | 0.6458329 | 0 |
This function takes a cut_configuration json object and calls the function corresponding to the desired cut, thereby returning the cutlist. | def generateCutList(cut_configuration):
#Check that this line reads json.loads(cut_configuration)
input_json = json.load(cut_configuration)
#Currently only desired_cut and laser_cut_config are required
try:
block = input_json["block"]
except:
pass
try:
cut = input_json["desired_cut"]
laser = i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadCutFolder(config):\n cutfolder = QFramework.TQFolder(\"__baseCut__\") #not a name any user should use but still sort of readable\n cutfolder.setTagString(\".cutExpression\",\"1.\") #pass all events, this is only a common handle for all actual (sub)cuts\n cutfolder.setTagBool(\".skipJobs\",True) #d... | [
"0.6149866",
"0.5558365",
"0.55202043",
"0.52206475",
"0.5109341",
"0.49454144",
"0.4927624",
"0.49099135",
"0.49094042",
"0.48717844",
"0.4865596",
"0.4846522",
"0.47562224",
"0.471486",
"0.47056",
"0.46879908",
"0.4677999",
"0.46680018",
"0.46643007",
"0.4607456",
"0.454606... | 0.71448123 | 0 |
check it has a solution | def has_solution(self) -> bool:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def did_solve(self) -> bool:\n pass",
"def is_solved(self):\n if not self._find_empty():\n return True\n else:\n return False",
"def did_solve(self):\n return self._solution[\"status\"] == \"optimal\"",
"def has_solution(self) -> bool:\n if self in [se... | [
"0.7137686",
"0.7136563",
"0.7095094",
"0.70714545",
"0.7049462",
"0.7029765",
"0.6964778",
"0.6960238",
"0.6939422",
"0.68836486",
"0.6876838",
"0.6864891",
"0.68153703",
"0.6815134",
"0.6724094",
"0.6690701",
"0.66641307",
"0.6656697",
"0.6656075",
"0.65969825",
"0.65919304... | 0.8243674 | 0 |
obtain a time duration between the recent events of the same bizLocation | def obtain_time_duration(collection, new_document):
# Obtain the previously existing two document for the incoming bizLocation
# Sort them in descending order
# The first in the list is the newly inserted document detected by Change Streams
# the second document is of interest
prev_documents ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duration(self):\r\n return self.t2 - self.t1",
"def duration(self):\r\n return (self.end_time or time.time()) - self.start_time",
"def duration(self):\n return self._end - self._begin",
"def GetDuration(self):\n return _gmat_py.LocatedEvent_GetDuration(self)",
"def compute_go_duration(s... | [
"0.6247451",
"0.6066179",
"0.59149534",
"0.587591",
"0.58055454",
"0.57777333",
"0.57665247",
"0.5748646",
"0.5732722",
"0.572424",
"0.571313",
"0.5707432",
"0.56868815",
"0.5675801",
"0.565217",
"0.5647044",
"0.56372106",
"0.56028074",
"0.5601279",
"0.5599238",
"0.5544639",
... | 0.6420903 | 0 |
Load the best num parameters from the given file. | def load_params(player_class, filename, num):
parser = player_class.deserialize_parameters
all_params = []
with open(filename) as datafile:
reader = csv.reader(datafile)
for line in reader:
score, rep = float(line[-2]), line[-1]
all_params.append((score, rep))
al... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadBestFit(self):\n bestFit, err = [], []\n row = 0\n with open(self.filename) as f:\n for lines in f.readlines():\n line = lines.strip(\"\\n\")\n data = line.split(\" \")\n if row == self.Npar:\n for kk in range(s... | [
"0.6628179",
"0.6617545",
"0.6580962",
"0.64695466",
"0.64075434",
"0.62310404",
"0.6230305",
"0.62199324",
"0.61862564",
"0.61166227",
"0.6109736",
"0.6079469",
"0.5998742",
"0.5996682",
"0.5978318",
"0.59457254",
"0.5927295",
"0.5894868",
"0.5883919",
"0.58676887",
"0.58008... | 0.73936313 | 0 |
Update UserCreate instance firstname | def update_firstname(state: UserCreate, firstname: str) -> None:
state.name.first = firstname
state.slug = slugify(f"super-user: {state.name.first} {state.name.last}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signup(self, request, user):\n user.first_name = self.cleaned_data['first_name']\n user.last_name = self.cleaned_data['last_name']\n user.save()\n\n return user",
"def first_name(self, instance):\r\n return instance.user.first_name",
"def register_user_first_name(self, me... | [
"0.7218886",
"0.72107047",
"0.7091783",
"0.70805126",
"0.68391097",
"0.6802234",
"0.6792022",
"0.6786857",
"0.668164",
"0.66436106",
"0.6567716",
"0.65634876",
"0.65209407",
"0.64976525",
"0.64976525",
"0.6494254",
"0.6456594",
"0.6450713",
"0.642974",
"0.6408176",
"0.6386372... | 0.81902975 | 0 |
Build User response instance | def build_user(data: Dict[Any, Any]) -> User:
return User(**data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get():\n return prepare_response(get_user_info())",
"def get_user_details(self, response):\n fullname, first_name, last_name = self.get_user_names(\n response.get(\"fullName\"),\n response.get(\"firstName\"),\n response.get(\"lastName\"),\n )\n ret... | [
"0.6529011",
"0.6426592",
"0.6373598",
"0.63219744",
"0.61717933",
"0.6141898",
"0.61418366",
"0.6088162",
"0.6084343",
"0.6070999",
"0.60210335",
"0.6011697",
"0.60002035",
"0.5984306",
"0.5978686",
"0.59628445",
"0.59532416",
"0.5891522",
"0.5889954",
"0.58876634",
"0.58819... | 0.6766939 | 0 |
This methods runs one episode for a gym environment. deterministic == True => agent executes only greedy actions according the Q function approximator (no random actions). do_training == True => train agent | def run_episode(env, agent, deterministic, skip_frames=0, do_training=True, rendering=True, max_timesteps=10000,
history_length=0, manual=False):
stats = utils.EpisodeStats()
# Save history
image_hist = []
step = 0
state = env.reset()
env.viewer.window.on_key_press = utils.k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _train_simulate(self, env, train_episode=None):\n # The initial observation\n o_r_d_i = [env.reset()] + [None]*3 # o_r_d_i means \"Observation_Reward_Done_Info\"\n # Reset all the manager parameters\n self.reset(o_r_d_i[0][\"manager\"])\n done = False\n current_option... | [
"0.75989807",
"0.7317887",
"0.731042",
"0.72842157",
"0.72729677",
"0.7271064",
"0.71605587",
"0.70899516",
"0.70623356",
"0.70282584",
"0.70133144",
"0.69955355",
"0.6992601",
"0.69857806",
"0.6981672",
"0.69651085",
"0.69529545",
"0.6945286",
"0.6932808",
"0.69287926",
"0.6... | 0.7439519 | 1 |
Split the course string in to a course number and a course postfix Expects all strings to be in the format numpostfix. For instance, | def _split_course_string(course_string):
course_num = ''
course_postfix = ''
count = 0
for indx, char in enumerate(course_string):
if not char.isdigit():
break
course_num += char
count += 1
try:
course_num = int(course_num)
except ValueError:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def space_coursecodes(input_string):\n\n coursecode_pattern = re.compile(r\"[A-Z]{2,6}\\s{,1}-{,1}/{,1}[0-9]{2,6}-{,1}/{,1}([0-9]{2,6}){,1}\")\n\n # for any coursecodes in string, find beginning and end index of each\n ind_pairs = [(m.start(0), m.end(0)) for m in re.finditer(coursecode_pattern, input_stri... | [
"0.59728956",
"0.5590606",
"0.5450177",
"0.533765",
"0.5325984",
"0.51580155",
"0.5109719",
"0.5105101",
"0.5051153",
"0.5044799",
"0.49115965",
"0.48173293",
"0.48144338",
"0.48039567",
"0.47931984",
"0.47742018",
"0.4764439",
"0.47197244",
"0.47027755",
"0.46838984",
"0.462... | 0.7670243 | 0 |
Add a new column named placeholder fill with the arg_1 value | def main(dataframe: pd.DataFrame, arg_1: str='nothing') -> pd.DataFrame:
dataframe["placeholder"] = arg_1
return dataframe | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_column(df, colTitle, colIndex, fillValue):\n if colTitle not in df.columns:\n df.insert(colIndex, colTitle, fillValue, True)\n return df",
"def add_column_parameter(params, name, dataset, args, key):\n column_id = args.get_value(key, raise_error=False)\n if column_id is None:\n ... | [
"0.61651623",
"0.60531425",
"0.5932682",
"0.55233854",
"0.53711224",
"0.5348192",
"0.5308065",
"0.52713895",
"0.5266658",
"0.51256454",
"0.5117017",
"0.51092947",
"0.510111",
"0.5097036",
"0.5096841",
"0.50488573",
"0.50472313",
"0.50351626",
"0.50323486",
"0.5029519",
"0.502... | 0.6702973 | 0 |
Endpoint qui permet d'envoyer la convention de partenariat par mail pour une perm d'id {id}. | def send_convention(request, id):
perm = perm_models.Perm.objects.get(pk=id)
convention_template = get_template('convention_partenariat.html')
convention_context = {
'perm': perm,
'articles': perm.get_convention_information()['perm_articles'],
'montant': round(perm.get_montant_deco_max(), ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def envoi_par_mail(self):\n cr , uid, context = self.env.args\n if not self.pool['res.users'].has_group(cr, uid, 'is_plastigray.is_comptable_group'):\n raise Warning(u\"Accès non autorisé !\")\n ids=[]\n for obj in self:\n ids.append(str(obj.id))\n if len(id... | [
"0.6005149",
"0.5587609",
"0.5556423",
"0.5496287",
"0.52939004",
"0.5288747",
"0.52882147",
"0.52684224",
"0.52666515",
"0.5243778",
"0.5187994",
"0.5171401",
"0.51496404",
"0.5147281",
"0.5110905",
"0.50985926",
"0.5092945",
"0.50828236",
"0.50735444",
"0.5072316",
"0.50681... | 0.6470842 | 0 |
Endpoint qui permet d'envoyer le justificatif de paiement par mail pour une perm d'id {id}. | def send_justificatif(request, id):
perm = perm_models.Perm.objects.get(pk=id)
info = perm.get_justificatif_information()
justificatif_template = get_template('justificatif_paiement.html')
justificatif_context = {
'perm': perm, 'articles': info['perm_articles'], 'total_ht': info['total_ht'],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_convention(request, id):\n perm = perm_models.Perm.objects.get(pk=id)\n convention_template = get_template('convention_partenariat.html')\n convention_context = {\n 'perm': perm,\n 'articles': perm.get_convention_information()['perm_articles'],\n 'montant': round(perm.get_montant_d... | [
"0.57655394",
"0.5716651",
"0.56478196",
"0.56307864",
"0.55586624",
"0.5510274",
"0.54520583",
"0.54152286",
"0.5387207",
"0.5373411",
"0.5325026",
"0.53217953",
"0.529948",
"0.52949625",
"0.52771795",
"0.5257251",
"0.5247731",
"0.5247631",
"0.52378786",
"0.52317333",
"0.522... | 0.63593924 | 0 |
Build the left part of the fireball function. Doing this uses slots 0,1,2,3 and the result will be in slot 0. (S (horace ((S (horace ((S (horace (greg (K S)))) ((S (horace fanny)) (greg I))))) june ((S (horace fanny)) ian) ))) kelly | def build_leftpart():
# build kelly.
build_kelly()
# copy kelly to 3.
copy(0, 3)
# build june in slots 0,1,2
build_june()
# copy kelly to slot 1
copy(3, 1)
# smash together to get (june kelly) in 0
smash()
# copy (june kelly) to 1
copy(0, 1)
# build horace in 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_fireball():\n # build the right part\n build_rightpart()\n\n # copy it to 4.\n copy(0, 4)\n\n # build the left part, now it's in 0\n build_leftpart()\n\n # copy right part from 4 to 1.\n copy(4, 1)\n # smash together for whole fireball.\n smash()",
"def keyLeft(self):\n ... | [
"0.70482737",
"0.58627445",
"0.58096784",
"0.58096784",
"0.5768745",
"0.5619706",
"0.55908644",
"0.55596286",
"0.5548311",
"0.5537584",
"0.55325747",
"0.5531275",
"0.5530027",
"0.55278164",
"0.54952",
"0.5482912",
"0.54783756",
"0.54747903",
"0.5452353",
"0.5442784",
"0.54378... | 0.7919818 | 0 |
Build the fireball function. We'll apply the Y combinator to it. Stomps registers [0,4]. | def build_fireball():
# build the right part
build_rightpart()
# copy it to 4.
copy(0, 4)
# build the left part, now it's in 0
build_leftpart()
# copy right part from 4 to 1.
copy(4, 1)
# smash together for whole fireball.
smash() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fy(self):\n\n def fy(p):\n p0, p1 = p\n e = anp.exp(-(p0 + p1) * self.ts)\n x = (\n 1\n / (-p0 - p1)\n * anp.array(\n [\n [-p1 - p0 * e, -p1 + p1 * e],\n [-p... | [
"0.57334554",
"0.54655373",
"0.53826815",
"0.53662187",
"0.53366727",
"0.5298539",
"0.5281986",
"0.52551913",
"0.52137053",
"0.520962",
"0.5203715",
"0.51821357",
"0.51619667",
"0.5104895",
"0.51000744",
"0.5096226",
"0.5089348",
"0.50706804",
"0.50680226",
"0.5058774",
"0.50... | 0.68100685 | 0 |
Initialize a Route solver object and set properties. | def initialize_rt_solver(self):
# For a local network dataset, we need to checkout the Network Analyst extension license.
if not self.is_service:
arcpy.CheckOutExtension("network")
# Create a new Route object
self.logger.debug("Creating Route object...")
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.RRTFamilySolver = RRTFamilyPathPlanner()\n self.PRMSolver = PRMPathPlanner()",
"def __init__(self):\n\n # Set a node name - something relevant\n rospy.init_node('waypoint_updater')\n\n # Most recent pose\n self.pose = None\n\n # Map wayp... | [
"0.70928293",
"0.6806993",
"0.67323405",
"0.6620287",
"0.65866923",
"0.6567693",
"0.6503277",
"0.6323346",
"0.6312729",
"0.62945217",
"0.6200703",
"0.6181314",
"0.61419207",
"0.6131141",
"0.6076377",
"0.6046717",
"0.6043842",
"0.59901327",
"0.59900606",
"0.5955468",
"0.594591... | 0.75314903 | 0 |
Add fields to input Stops with the origin and destination's original unique IDs. | def _add_unique_id_fields(self):
field_types = {"String": "TEXT", "Single": "FLOAT", "Double": "DOUBLE", "SmallInteger": "SHORT",
"Integer": "LONG", "OID": "LONG"}
origin_field_def = [self.origin_unique_id_field_name, field_types[self.origin_id_field_obj.type]]
if self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _insert_stops_one_to_one(self): # pylint: disable=too-many-locals\r\n # Use an insertCursor to insert Stops into the Route analysis\r\n destinations = {}\r\n destination_rows = []\r\n with self.rt_solver.insertCursor(\r\n arcpy.nax.RouteInputDataType.Stops,\r\n ... | [
"0.6808154",
"0.65527296",
"0.6456082",
"0.5107205",
"0.4909032",
"0.4837304",
"0.48278338",
"0.47855443",
"0.4784247",
"0.47640702",
"0.47625896",
"0.46876457",
"0.4668027",
"0.46508414",
"0.46428096",
"0.46241915",
"0.45510978",
"0.45495996",
"0.45336407",
"0.45158657",
"0.... | 0.7586507 | 0 |
Retrieve a list of OD pairs included in this chunk. | def _get_od_pairs_for_chunk(self, chunk_definition):
# Read the relevant rows from the CSV
chunk_num, chunk_size = chunk_definition
# Explicitly set data types
dtypes = {
0: helpers.PD_FIELD_TYPES[self.origin_id_field_obj.type],
1: helpers.PD_FIELD_TYPES[sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pairs(self):\n return self.pairs",
"def pairs(self):\n return self.items() if self.is_a(dict) else self.chunks(2)",
"def pairs(self):\n return self.__pairs",
"def getOrderList(self):\r\n\t\treturn self.pair.orders",
"async def fetch_trading_pairs() -> List[str]:\n raise NotI... | [
"0.61472523",
"0.58992565",
"0.5761564",
"0.567055",
"0.5611011",
"0.55578417",
"0.5545772",
"0.5545772",
"0.5542505",
"0.55348593",
"0.5519136",
"0.55052334",
"0.5441358",
"0.5352025",
"0.53083766",
"0.52903664",
"0.5279547",
"0.5259124",
"0.5257976",
"0.52337116",
"0.521395... | 0.6435109 | 0 |
Insert the origins and destinations as Stops for the Route analysis for the onetoone case. | def _insert_stops_one_to_one(self): # pylint: disable=too-many-locals
# Use an insertCursor to insert Stops into the Route analysis
destinations = {}
destination_rows = []
with self.rt_solver.insertCursor(
arcpy.nax.RouteInputDataType.Stops,
["RouteName", "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _insert_stops_many_to_many(self):\r\n # Store data of the relevant origins and destinations in dictionaries for quick lookups and reuse\r\n o_data = {} # {Origin ID: [Shape, transferred fields]}\r\n for row in arcpy.da.SearchCursor( # pylint: disable=no-member\r\n self.input_o... | [
"0.65625894",
"0.5583581",
"0.5395718",
"0.5393464",
"0.5392419",
"0.53610194",
"0.5345976",
"0.52621037",
"0.5238447",
"0.521201",
"0.52106446",
"0.52027905",
"0.518865",
"0.5178128",
"0.51780194",
"0.51352537",
"0.51346874",
"0.5124585",
"0.51178783",
"0.51078916",
"0.51078... | 0.7464433 | 0 |
Insert each predefined OD pair into the Route analysis for the manytomany case. | def _insert_stops_many_to_many(self):
# Store data of the relevant origins and destinations in dictionaries for quick lookups and reuse
o_data = {} # {Origin ID: [Shape, transferred fields]}
for row in arcpy.da.SearchCursor( # pylint: disable=no-member
self.input_origins_layer,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_parties(self, *parties) -> None:\n\n for party in parties:\n self._route_table['route_table'][party.get_id()] = party.to_entry_point(\n )",
"def assign_aovs(self, aovs: List[AOV]):\n\t\tfor aov in aovs:\n\t\t\tself.assign_aov(aov)",
"def route(self, ori, dest, pois):\n ... | [
"0.55640215",
"0.50584227",
"0.50430346",
"0.502575",
"0.5020248",
"0.50056565",
"0.49825788",
"0.4962253",
"0.49563637",
"0.4931308",
"0.4920993",
"0.49143758",
"0.4910077",
"0.48764232",
"0.48703808",
"0.48517448",
"0.48504838",
"0.4847047",
"0.48325107",
"0.4819616",
"0.48... | 0.612654 | 0 |
Export the Route result to a feature class. | def _export_to_feature_class(self, chunk_definition):
# Make output gdb
rt_workspace = self._create_output_gdb()
# Export routes
output_routes = os.path.join(rt_workspace, f"Routes_{chunk_definition[0]}_{chunk_definition[1]}")
self.logger.debug(f"Exporting Route Routes out... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _post_process_route_fcs(self):\r\n # Create the final output feature class\r\n desc = arcpy.Describe(self.route_fcs[0])\r\n helpers.run_gp_tool(\r\n LOGGER,\r\n arcpy.management.CreateFeatureclass, [\r\n os.path.dirname(self.out_routes),\r\n ... | [
"0.6221787",
"0.5916604",
"0.53928643",
"0.5349487",
"0.5265204",
"0.52557456",
"0.51746285",
"0.51711124",
"0.51549613",
"0.5122801",
"0.51089555",
"0.50449544",
"0.5029637",
"0.50276506",
"0.5018805",
"0.4998023",
"0.49829662",
"0.49803904",
"0.49756134",
"0.49702242",
"0.4... | 0.72400814 | 0 |
Solve a Route analysis for the given inputs for the given chunk of preassigned OD pairs. | def solve_route(inputs, chunk):
rt = Route(**inputs)
if inputs["pair_type"] is helpers.PreassignedODPairType.one_to_one:
rt.logger.info(f"Processing origins OID {chunk[0]} to {chunk[1]} as job id {rt.job_id}")
elif inputs["pair_type"] is helpers.PreassignedODPairType.many_to_many:
rt.lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve(self, chunk_definition): # pylint: disable=too-many-locals, too-many-statements, too-many-branches\r\n # Select the inputs to process\r\n if self.pair_type is helpers.PreassignedODPairType.one_to_one:\r\n self._select_inputs_one_to_one(chunk_definition)\r\n elif self.pair... | [
"0.7265158",
"0.6186221",
"0.5823401",
"0.56546044",
"0.5640756",
"0.55801356",
"0.54897994",
"0.5467185",
"0.5436492",
"0.537317",
"0.5360428",
"0.5298746",
"0.5258818",
"0.523264",
"0.5204271",
"0.51753855",
"0.5158027",
"0.5145004",
"0.5122745",
"0.5106338",
"0.50887746",
... | 0.73194927 | 0 |
Validate Route settings before spinning up a bunch of parallel processes doomed to failure. Also check which field name in the output OD Lines will store the optimized cost values. This depends on the travel mode being used by the analysis, and we capture it here to use in later steps. | def _validate_route_settings(self):
# Create a dummy Route object and set properties. This allows us to
# detect any errors prior to spinning up a bunch of parallel processes and having them all fail.
LOGGER.debug("Validating Route settings...")
rt = None
try:
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f_check_adr_parameters_correctness(dict):\n\n if int(dict[\"operation_mode_num\"]) not in (0, 1, 2, 3, 4, 5, 6):\n print('\\n Error!!! Operation mode is wrong!\\n')\n sys.exit(' Program stopped!')\n\n if int(dict[\"FFT_size_samples\"]) not in (2048, 4096, 8192, 16384, 32768):\n pri... | [
"0.58897823",
"0.5755311",
"0.5660653",
"0.557182",
"0.5522201",
"0.550903",
"0.54448694",
"0.53637433",
"0.5346746",
"0.5307992",
"0.52819705",
"0.52334815",
"0.52329284",
"0.52285826",
"0.5222194",
"0.52111304",
"0.51922095",
"0.5165339",
"0.51619154",
"0.51523876",
"0.5147... | 0.7251164 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.