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 |
|---|---|---|---|---|---|---|
Map profiling information to that we consider relevant. | def map_profile_info(profile):
result = map(
lambda p: {
'callcount': p.callcount,
'time': p.totaltime,
'name': p.code if isinstance(p.code, str) else p.code.co_name,
'file': None if isinstance(p.code, str) else p.code.co_filename},
profile.getstats())... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_profile_fields(data, fields):\n profile = {}\n for dst, src in fields.items():\n if callable(src):\n value = src(data)\n else:\n value = data.get(src)\n\n if value is not None and value != '':\n profile[dst] = value\n\n return profile",
"def ... | [
"0.5740802",
"0.56392205",
"0.56055224",
"0.55328506",
"0.54870385",
"0.54597306",
"0.54565483",
"0.5436571",
"0.54253584",
"0.5375065",
"0.5319913",
"0.52781445",
"0.5247227",
"0.5228473",
"0.5214851",
"0.5212649",
"0.51746607",
"0.511492",
"0.5113408",
"0.5090468",
"0.50846... | 0.7137595 | 0 |
NK table mapping binary sequence to value. | def nk_table(self):
return self.map("keys", "values") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeValMap(self,value = 'readcount'):\n self.valMap = np.zeros(len(self))\n self.valMap = self.valMap-1\n myTmp = []\n for x in range(0,len(self)):\n myTmp.append([])\n for i in self.children:\n for j in range(i.start,i.end+1):\n myTmp[j-s... | [
"0.5793329",
"0.5744892",
"0.56919354",
"0.5584746",
"0.5507807",
"0.5425487",
"0.53992283",
"0.5373337",
"0.53448844",
"0.5336639",
"0.52844787",
"0.527202",
"0.5269434",
"0.5232513",
"0.5224803",
"0.5220393",
"0.5209991",
"0.51919585",
"0.51794624",
"0.51602954",
"0.5154623... | 0.6788704 | 0 |
Set the order (K) of the NK model. | def set_order(self, K):
self.K = K
# point to order
self.order = self.K
self._keys = np.array(["".join(r) for r in
it.product('01', repeat=self.K)])
# Reset phenotypes
self.data['phenotypes'] = np.empty(self.n, dtype=float) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_order(self, order):\n self.order = order",
"def set_order(self, order):\n self.order = order",
"def setOrder(self, order):\n\t\tself.orderInData = order",
"def _setordering_customer_50K(self, val):\n self.swift_obj.OrderingCustomer_K = val\n self.swift_obj.OrderingCustomer... | [
"0.67037237",
"0.67037237",
"0.65358293",
"0.6362102",
"0.62988967",
"0.62647235",
"0.6218576",
"0.62119216",
"0.62119216",
"0.62119216",
"0.6013113",
"0.593146",
"0.5919525",
"0.5821439",
"0.572999",
"0.56128156",
"0.5604605",
"0.5604605",
"0.56034064",
"0.5601273",
"0.55803... | 0.80582696 | 0 |
Set the values of the NK table by drawing from a uniform distribution between the given k_range. | def set_random_values(self, k_range=(0, 1)):
if hasattr(self, "keys") is False:
raise Exception("Need to set K first. Try `set_order` method.")
self._values = np.random.uniform(k_range[0], k_range[1],
size=len(self.keys))
self.build() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_k(dataset, range_k, n_seed=30):\r\n range_Ks = np.arange(0,range_k,1,dtype=int) #range of delays to study\r\n h_K=np.zeros((10,range_k))\r\n \r\n for i in range(10):\r\n for k, K in enumerate(range_Ks):\r\n traj_matrix= embed.trajectory_matrix(dataset, K=K)\r\n ... | [
"0.57710737",
"0.56050676",
"0.5352598",
"0.5342018",
"0.5335359",
"0.5318227",
"0.5310305",
"0.51940215",
"0.51878417",
"0.51309323",
"0.513036",
"0.5095839",
"0.5073497",
"0.5061649",
"0.5057922",
"0.5051695",
"0.50410706",
"0.5020852",
"0.50112736",
"0.50064665",
"0.499611... | 0.7136088 | 0 |
Set the values of the NK table from a list/array of values. | def set_table_values(self, values):
if len(values) != len(self.keys):
raise Exception("Length of the values do not equal the length of "
"NK keys. "
"Length of keys is : %d" % (len(self.keys),))
self._values = values
self.build(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_values(self, values=None, *args, **kwargs):\n valueList = []\n valueDict = {}\n if values is not None:\n # check type of {\\sf values} to get correctly the values\n if isinstance(values, list) or isinstance(values, tuple):\n valueList.extend(values)... | [
"0.69007885",
"0.679975",
"0.6547312",
"0.64566696",
"0.6412549",
"0.6412346",
"0.63792694",
"0.630354",
"0.6177051",
"0.60555947",
"0.60262287",
"0.6000296",
"0.5967956",
"0.5946116",
"0.5946116",
"0.5946116",
"0.5946116",
"0.5946116",
"0.5946116",
"0.59048855",
"0.59048855"... | 0.7321782 | 0 |
Build phenotypes from NK table. | def build(self):
nk_table = self.nk_table
# Check for even interaction
neighbor = int(self.order / 2)
if self.order % 2 == 0:
pre_neighbor = neighbor - 1
else:
pre_neighbor = neighbor
# Use NK table to build phenotypes
phenotypes = np.zeros... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_phenotype(phenotype_id, adapter):\n phenotype_obj = {}\n phenotype = adapter.hpo_term(phenotype_id)\n if phenotype:\n phenotype_obj[\"phenotype_id\"] = phenotype[\"hpo_id\"]\n phenotype_obj[\"feature\"] = phenotype[\"description\"]\n return phenotype",
"def create_model():\n ... | [
"0.59477466",
"0.571061",
"0.56416917",
"0.545999",
"0.5419914",
"0.5342602",
"0.52819085",
"0.52390313",
"0.51898134",
"0.5189629",
"0.5152559",
"0.5144572",
"0.51429605",
"0.5127938",
"0.51271623",
"0.50853604",
"0.5077953",
"0.5057735",
"0.5053897",
"0.50402",
"0.5030632",... | 0.7407428 | 0 |
Achieves "def get_caseX_indices_matching_symbol" but on a list of symbols. | def get_caseX_indices_matching_symbol_list(result,match_symbols = ["NA"]):
#
# Sub-function
#
def get_caseX_indices_matching_symbol(result,match_symbol = "NA"):
""" get a list of indices of case4 (see: @caseX) elements from @result
Args:
result: @@result: an @uncolla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _index_symbols(symbols):\n symbol_start_indices = []\n next_start_index = 0\n for symbol in symbols:\n entry_count = count_entries(symbol)\n if entry_count > EXAMPLE_SIZE:\n symbol_start_indices.append(next_start_index)\n next_start_index += entry_count - EXAMPLE_SI... | [
"0.65377474",
"0.6477875",
"0.6457072",
"0.6457072",
"0.64341956",
"0.61545986",
"0.6037521",
"0.6014018",
"0.58861655",
"0.5723973",
"0.5679167",
"0.5665417",
"0.5510377",
"0.54939115",
"0.54873234",
"0.5473831",
"0.546451",
"0.54531556",
"0.5384212",
"0.53800964",
"0.537828... | 0.74190253 | 0 |
Maps the locations of symbols in caseX to the corresponding symbols in | def map_case_to_punnet_indices(caseX, caseX_sym_to_coord):
caseCoord_to_punnetCoord = {}
for y,j in enumerate(caseX):
for x,i in enumerate(j):
case_coord = (y,x)
punnet_coord = caseX_sym_to_coord[i]
caseCoord_to_punnetCoord[case_coord] = punnet_coord
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_symbol_mapping():\n normal_items = [\"+\", \"-\"]\n unicode_items = [chr(0x2070 + i) for i in range(10, 12)]\n\n # Create a dict mapping the two.\n return DefaultDictionary(zip(normal_items, unicode_items))",
"def __set_symbol_dict(self):\r\n return {0: list(alph) if self.is_case_snstv... | [
"0.6319196",
"0.6069674",
"0.5674592",
"0.5491752",
"0.54740614",
"0.5442556",
"0.5403927",
"0.53647107",
"0.53445184",
"0.5340918",
"0.5296028",
"0.5274964",
"0.5239597",
"0.5212809",
"0.51993406",
"0.5174405",
"0.5146997",
"0.51462525",
"0.5117898",
"0.5112995",
"0.5112307"... | 0.67383003 | 0 |
Replaces elements of the using elemts of caseX_collapsed via a map_caseX_to_punnet | def replace_punnet_with_collapsed_cases(punnet,map_caseX_to_punnet,caseX_collapsed):
for case_coord in map_caseX_to_punnet.keys():
punnet_coords = map_caseX_to_punnet[case_coord]
for punnet_coord in punnet_coords:
punnet[punnet_coord] = caseX_collapsed[case_coord]
return punnet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _map_elements_vectorized(self, unused_nid_map, model, unused_j, unused_dim_max,\n unused_nid_cp_cd, plot=True, xref_loads=True):\n self.gui.isubcase_name_map = {1: ['Nastran', '']}\n grid = self.gui.grid\n\n nelements = self.nelements\n if nelements =... | [
"0.5443269",
"0.54277223",
"0.53019744",
"0.52509886",
"0.52509886",
"0.52509886",
"0.52509886",
"0.52509886",
"0.52509886",
"0.52509886",
"0.51589334",
"0.51589334",
"0.51589334",
"0.51411754",
"0.5120727",
"0.5113141",
"0.5113141",
"0.503857",
"0.5027112",
"0.49946713",
"0.... | 0.8381181 | 0 |
Takes a sentence as an input, and returns a dictionary of emotions and number of occurences for them. | def get_emotions_in_sentence(sentence):
tknzr = TweetTokenizer()
tokens = tknzr.tokenize(sentence)
emotions = {}
for word in tokens:
# Replace hashtags with pure words (i.e. "#positive" becomes "positive")
if re.match("^#\S+", word):
word = re.sub("^#", "", wor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_word_in_each_sentence(sentence):\n\tsentence = sentence.lower()\n\twords = sentence.split()\n\tcount_dict = dict()\n\tfor _ in words:\n\t\tif count_dict.get(_):\n\t\t\tcount_dict[_] += 1\n\t\telse:\n\t\t\tcount_dict[_] = 1\n\treturn count_dict",
"def basic_count(sentence):\n letter_count = {}\n f... | [
"0.68797433",
"0.6825759",
"0.65769255",
"0.6535194",
"0.65148383",
"0.65113354",
"0.6354589",
"0.63443613",
"0.6339356",
"0.63273925",
"0.6326009",
"0.62736243",
"0.6194626",
"0.6182634",
"0.6145766",
"0.61381006",
"0.6122692",
"0.6083806",
"0.6078651",
"0.6076343",
"0.60078... | 0.7836813 | 0 |
Adds the end bracket to finish list of lists Reads the finished product as string Converts String to List Sends final copy of list to generate_template | def compile_data(self):
with open(self.store_path, 'a') as file:
file.write(']')
with open(self.store_path) as file:
list_of_lists = file.read()
card_list = json.loads(list_of_lists)
return self.generate_template(card_list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(entities_to_proceed):\n yield \"[\"\n for index, entity in enumerate(entities_to_proceed):\n if logging.getLogger().isEnabledFor(logging.DEBUG):\n logging.debug(\"processing entity : %s\", entity)\n else:\n logging.info(\"processing ent... | [
"0.57277954",
"0.56510913",
"0.5608768",
"0.55836725",
"0.54954815",
"0.5477419",
"0.54415685",
"0.5341591",
"0.5339922",
"0.5274645",
"0.52173305",
"0.5185166",
"0.51788926",
"0.51774514",
"0.5177045",
"0.5169892",
"0.516534",
"0.5163845",
"0.51523644",
"0.51406246",
"0.5137... | 0.6110166 | 0 |
Builds the Teams Card Traditional tools for Json formatting do not preserve the template's syntax, So it has to be built manually For card_list, the sensor data is looped to create a table. This adds each sensor to the card and add a comma between them. Once the last run, the comma is skipped and the bracket is closed | def generate_template(self, card_list):
with open(self.generator_output, 'w') as gen_file:
print(Template.Top_prefix1+self.project+Template.Top_prefix2, file=gen_file)
print(Template.sensor_prefix, file=gen_file)
_run = len(card_list)
_loop = 0
for e i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_data(self):\n with open(self.store_path, 'a') as file:\n file.write(']')\n with open(self.store_path) as file:\n list_of_lists = file.read()\n card_list = json.loads(list_of_lists)\n return self.generate_template(card_list)",
"def construct_cards(toke... | [
"0.6514272",
"0.5683417",
"0.561787",
"0.5517833",
"0.54892814",
"0.54420215",
"0.5386302",
"0.5369797",
"0.53519976",
"0.5306699",
"0.529736",
"0.5160479",
"0.5063059",
"0.50323474",
"0.49998054",
"0.49891",
"0.49889284",
"0.49734932",
"0.49520928",
"0.49148855",
"0.4858352"... | 0.62450767 | 1 |
Convert string date in format 'Aug 2020' to '20200801' | def reformat_date(date_str: str) -> str:
if date_str is None or date_str == '':
return None
[month_key, year] = date_str.split()
return f'{year}-{MONTHS[month_key]}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_date_column(datestring):\n return datetime.datetime.strptime(datestring.strip(), \"%b-%Y\").date()",
"def convert_date(dt_str, letter_date):\r\n if letter_date:\r\n rev_date = datetime.datetime.strptime(dt_str, '%b-%y').strftime('%Y-%m') # convert date to yymm string format\r\n r... | [
"0.63704276",
"0.6331814",
"0.63243455",
"0.619683",
"0.61956924",
"0.59415126",
"0.58787394",
"0.5870436",
"0.58346206",
"0.58210987",
"0.57984483",
"0.57928306",
"0.57660526",
"0.5744133",
"0.5704916",
"0.56917703",
"0.56885225",
"0.5663735",
"0.5614924",
"0.5588107",
"0.55... | 0.6506631 | 0 |
add quote to string | def add_quote(item):
if type(item) == str:
return "\'" + item + "\'"
else:
return item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quot(string):\r\n return string.replace('\"', \"'\")",
"def _quote(self, arg):\n arg = arg.replace('\\\\', '\\\\\\\\')\n arg = arg.replace('\"', '\\\\\"')\n return '\"%s\"' % arg",
"def _quote(v):\n return '\"' + v + '\"' if ' ' in v else v",
"def shQuote(text):\n\tretu... | [
"0.82810366",
"0.7859846",
"0.7793372",
"0.77169293",
"0.7604381",
"0.7604381",
"0.7577342",
"0.75539434",
"0.75435525",
"0.7453465",
"0.7444847",
"0.7441447",
"0.7387246",
"0.7360612",
"0.7244319",
"0.72439015",
"0.7235581",
"0.71914256",
"0.7133501",
"0.7128411",
"0.7099550... | 0.7902357 | 1 |
Goes up the indicated number of levels and returns the equivalent of calling locals() in that scope | def parent_vars(level, extra_vars = None):
try: 1/0
except: frame = sys.exc_traceback.tb_frame
# Go up in the frame stack
for i in range(level+1): frame = frame.f_back
loc, glob = frame.f_locals, frame.f_globals
if extra_vars != None:
loc = loc.copy()
for key in extra_var... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stack():\n return currentframe().f_back.f_locals.setdefault(SN, [])",
"def get_local(self, where: Any, depth: int = 0) -> Any:\n return self.scope_stack[depth][where]",
"def _resolve_this(self, levels):\n if hasattr(\n sys, \"_getframe\"\n ): # implementation detail of C... | [
"0.6399998",
"0.6136883",
"0.5983501",
"0.59237546",
"0.5805225",
"0.5802206",
"0.57395476",
"0.5731738",
"0.5708003",
"0.5674699",
"0.5579075",
"0.5545951",
"0.549061",
"0.5461867",
"0.54421484",
"0.54293317",
"0.5416329",
"0.538953",
"0.5357531",
"0.53261524",
"0.52594477",... | 0.72129375 | 0 |
Takes a chunk of HTML, looks for a select, and outputs a list of options of that select. Looks only at value='', not at the pretty display. | def get_select_options(html, select_name):
# a regular expression to match the select block
pattern = re.compile('<select *name="%s"[^>]*>(.*?)</select>' % select_name, re.MULTILINE | re.IGNORECASE | re.DOTALL)
m = pattern.search(html)
if (m == None):
# we have no match, try another pattern
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def htmlSelect(labelText, parName, args, choiceList, hint=None, descriptionSeparator='::',\n labelAttr='', attr=''):\n snippet = htmlLabel(labelText,parName,labelAttr)\n default = args[parName] if parName in args else ''\n if not isinstance(default,list):\n default = [default]\n sn... | [
"0.58957684",
"0.5724786",
"0.5716659",
"0.57085514",
"0.568741",
"0.56390756",
"0.5558695",
"0.5549973",
"0.54741323",
"0.5450411",
"0.5365093",
"0.5349225",
"0.53060424",
"0.5284998",
"0.5204723",
"0.5121547",
"0.51064837",
"0.50677323",
"0.5058194",
"0.5057655",
"0.5047623... | 0.5956624 | 0 |
Make a string safe for a CSV field | def csv_safe(string):
# let's backslash all the quotation marks anyways
string = str(string)
string = string.replace('"','\\"')
if "," not in string and "\n" not in string:
return string
return '"' + string + '"' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_friendly_string(input):\n #Convert to string and strip of whitespace\n s = strip(str(input))\n #Newlines are bad\n s = replace(s, '\\n', \" \")\n s = replace(s, '\\r', \" \")\n #Replace double quotes with double-double\n s = replace(s, '\"', '\"\"')\n\n #Add quotes if needed\n fo... | [
"0.6742102",
"0.6715928",
"0.66002315",
"0.58941966",
"0.57422",
"0.568915",
"0.5677563",
"0.5639043",
"0.55888426",
"0.557945",
"0.5571272",
"0.55682826",
"0.5516632",
"0.5515312",
"0.5504741",
"0.5504615",
"0.54903525",
"0.548838",
"0.5464011",
"0.5452441",
"0.543062",
"0... | 0.7284532 | 0 |
Make a string safe for HTML with double quotes | def html_dq_safe(string):
if not string:
return string
string = string.replace('"','"')
return string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_html_safe(s):\n return s.replace(\"<\", \"<\").replace(\">\", \">\")",
"def html_escape(s):\n s = html.escape(s, False)\n s = s.replace('\"', \""\")\n return s",
"def escape_html(s):\n\treturn s. \\\n\t\treplace(\"<\", \"<\"). \\\n\t\treplace(\">\", \">\"). \\\n\t\treplace... | [
"0.7772578",
"0.7563124",
"0.7387473",
"0.71487874",
"0.7135516",
"0.7122315",
"0.7078092",
"0.70605904",
"0.7015321",
"0.70024043",
"0.6998787",
"0.69906825",
"0.6930037",
"0.6901274",
"0.68498677",
"0.682636",
"0.6826105",
"0.6747699",
"0.67402124",
"0.67118645",
"0.6671309... | 0.784569 | 0 |
Parses a URL and errors out if its not scheme http or https or has no net location | def url_check(url):
url_tuple = urlparse.urlparse(url)
if url_tuple[0] == 'http' or url_tuple[0] == 'https' and url_tuple[1] != "":
return url
else:
raise Exception('bad url') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_url (url):\n # Parse URL provided\n v = urlparse(url)\n\n # Verify if protocol (http, https, ftp) and hostname are present \n # in the URL provided.\n if v.scheme and v.hostname:\n \n # Get URL base and hostname to form the correct URL base\n u = v.scheme + '://' + v.ho... | [
"0.7514687",
"0.74862754",
"0.74089587",
"0.7376512",
"0.73097086",
"0.7287078",
"0.7267685",
"0.72663707",
"0.7234755",
"0.7187554",
"0.7187554",
"0.7164459",
"0.71450585",
"0.71440923",
"0.71121097",
"0.7051559",
"0.70260364",
"0.69987065",
"0.6996799",
"0.69552004",
"0.693... | 0.81642485 | 0 |
Parses a URL and truncates it after the domain part | def url_truncate(url):
url_tuple = urlparse.urlparse(url)
return url_tuple[0] + '://' + url_tuple[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def domain_parse(url):\n url = url.lower()\n if not url.startswith('http://') and not url.startswith('https://'):\n url = '{schema}{host}'.format(schema='http://', host=url)\n url = urlparse(url)\n if not url.hostname:\n raise ValueError('Invalid domain provided')\n\n # Strip www prefi... | [
"0.7620176",
"0.7324768",
"0.7284738",
"0.7240761",
"0.7154701",
"0.70812964",
"0.7073174",
"0.70719314",
"0.706794",
"0.7067837",
"0.7048127",
"0.7047652",
"0.69829565",
"0.6875338",
"0.6874541",
"0.6873694",
"0.6865281",
"0.6862966",
"0.68619376",
"0.68316275",
"0.68275714"... | 0.76441383 | 0 |
Init yarp ports for communication /data_server/in and /data_server/out | def server_yarp():
"""Depending on the command it gets a finger data or all fingers data and send it through the port /data_server/out"""
y.Network.init()
portsrv_in = y.BufferedPortBottle()
portsrv_in.open("/data_server/in")
portsrv_out = y.BufferedPortBottle()
portsrv_out.open("/data_server/ou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_data_port(self):\n err = None\n sock = None\n for res in socket.getaddrinfo(None, 0, socket.AF_INET, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):\n af, socktype, proto, canonname, sa = res\n try:\n sock = socket.socket(af, socktype, proto)\n ... | [
"0.64356095",
"0.60305744",
"0.60272783",
"0.59800035",
"0.59362817",
"0.59055966",
"0.5846435",
"0.5844897",
"0.57740307",
"0.5770993",
"0.5770788",
"0.5761662",
"0.56832856",
"0.5680248",
"0.5649125",
"0.56416017",
"0.5637095",
"0.56346905",
"0.5632841",
"0.5629053",
"0.560... | 0.638576 | 1 |
a ppg/no ppg aware run wrapper | def run():
if ppg2.inside_ppg():
ppg2.run()
else:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(_):\n pass",
"def run():\n main()",
"def run(ctx):\n pass",
"def custom():\n run(\"example\")",
"def run_module_ground_plan(args):\n raise NotImplementedError",
"def _run(self):\n raise NotImplementedError",
"def run():\n main(sys.argv[1:])",
"def run():\n main(sys.arg... | [
"0.64849204",
"0.62375826",
"0.604792",
"0.60420704",
"0.5985371",
"0.59746647",
"0.58955795",
"0.58955795",
"0.58955795",
"0.58955795",
"0.58955795",
"0.58955795",
"0.58955795",
"0.58955795",
"0.57908344",
"0.57514197",
"0.57406765",
"0.57267183",
"0.570456",
"0.5685785",
"0... | 0.74806374 | 0 |
Return a sequence of the names in a directory If the filter is not None, include only those names for which the filter returns a true value. | def names(filter=None): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names(path, filter=None):",
"def get_filtered_dir_list(self) -> typing.List[str]:\n if self._regex is None:\n self.build_regex()\n\n return [\n elem\n for elem in self.super_dir()\n if self._regex.fullmatch(elem)\n ]",
"def scan_directories(d... | [
"0.68968344",
"0.6543039",
"0.6297752",
"0.617669",
"0.6166819",
"0.60795903",
"0.5977339",
"0.59732294",
"0.596002",
"0.5898916",
"0.58962566",
"0.5863355",
"0.5831567",
"0.5811614",
"0.57734287",
"0.5728591",
"0.57237214",
"0.56886095",
"0.5684366",
"0.5653274",
"0.56437254... | 0.65556586 | 1 |
Return a sequence of information objects Return item info objects (see lsinfo) for the files in a directory. If the filter is not None, include only those names for which the filter returns a true value. | def ls(filter=None): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFiles(folderToProcess,filter):\n\n print(f\"Parsing {folderToProcess} for {filter} files\")\n\n if debug:\n for path in Path(folderToProcess).rglob(filter):\n print(f\"Found {path}\")\n\n all_files = [str(x) for x in Path(folderToProcess).rglob(filter)] \n\n return all_files",
... | [
"0.62276477",
"0.61657846",
"0.6048434",
"0.5977725",
"0.59174025",
"0.58965987",
"0.57888776",
"0.56596655",
"0.5631385",
"0.5593354",
"0.5388888",
"0.5364172",
"0.53641665",
"0.5358325",
"0.53024876",
"0.5293489",
"0.52633387",
"0.5261047",
"0.52554226",
"0.5251259",
"0.524... | 0.6325731 | 0 |
Outputs the file at name to a stream. Data are copied starting from start. If end is not None, data are copied up to end. | def readfile(name, outstream, start=0, end=None): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writefile(name, instream, start=None, end=None, append=False):",
"def writefile(path, instream, start=None, end=None, append=False):",
"def readfile(path, outstream, start=0, end=None):",
"def output(self, _in, out, **kwds):\n out.write(_in.read())",
"def stream_to_file(self, path):\n # Using d... | [
"0.73203975",
"0.66282195",
"0.6548188",
"0.52931905",
"0.5192701",
"0.51389235",
"0.50570816",
"0.50302005",
"0.49630135",
"0.4937502",
"0.49246177",
"0.49229074",
"0.49182338",
"0.48734298",
"0.48445198",
"0.4824233",
"0.4819832",
"0.48137543",
"0.47911045",
"0.47882125",
"... | 0.731194 | 1 |
Write data to a file. If start or end is not None, then only part of the file is written. The remainder of the file is unchanged. If start or end are specified, they must ne nonnegative. If end is None, then the file is truncated after the data are written. If end is not None, parts of the file after end, if any, are u... | def writefile(name, instream, start=None, end=None, append=False): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writefile(path, instream, start=None, end=None, append=False):",
"def _save_to_file(filename, data, start=0, header_size=None):\n if header_size is None:\n header_size = 0\n item_dtype = data.dtype\n # Open file as necessary\n opened = False\n if isinstance(filename, str):\n fd =... | [
"0.75953966",
"0.5372479",
"0.5263298",
"0.5215831",
"0.518739",
"0.51277757",
"0.4973634",
"0.49608546",
"0.48990738",
"0.48797482",
"0.48632792",
"0.48159334",
"0.47887868",
"0.4715249",
"0.4707024",
"0.46998763",
"0.4688589",
"0.46282938",
"0.4616939",
"0.46119153",
"0.454... | 0.7525721 | 1 |
Factory which creates and returns a Dog model. If file name or rating not given, then a random one is used. | def create_dog(create_random_file_name):
def dog_factory(rating=None, file_name=None):
file_name = (
create_random_file_name() if file_name is None else file_name
)
rating = random.randint(0, 5000) if rating is None else rating
return models.Dog.create(file_name=file_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, animal_factory=None):\n self.pet_factory = animal_factory",
"def __init__(self, animal_factory=None):\n self.pet_factory = animal_factory",
"def create_model(mode: str, path_to_checkpoint = None) -> LightningModule:\n\n assert mode != None and mode != ''\n\n if mode == 's... | [
"0.5565132",
"0.5565132",
"0.5531412",
"0.52198267",
"0.51935834",
"0.5106767",
"0.50903696",
"0.5042248",
"0.5031069",
"0.5011618",
"0.5001675",
"0.499962",
"0.4996231",
"0.4969871",
"0.4945932",
"0.49347904",
"0.49257568",
"0.49164423",
"0.48965567",
"0.48892954",
"0.485672... | 0.78184766 | 0 |
Factory which returns a random image file name. | def create_random_file_name():
def random_file_name_factory():
length = random.randint(10, 15)
chars = string.ascii_letters + string.digits + "-_"
return f"{''.join(random.choice(chars) for _ in range(length))}.jpg"
return random_file_name_factory | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filename_generate(image_class, size=12, chars=string.ascii_uppercase + string.ascii_lowercase + string.digits):\n\tnew_filename = time.strftime(\"%d-%m-%Y_\")\n\tnew_filename = new_filename + ''.join(random.choice(chars) for _ in range(size))\n\tnew_filename = new_filename + \"_P\" + str(image_class)\n\treturn... | [
"0.7617596",
"0.71837944",
"0.7169918",
"0.7101182",
"0.70534843",
"0.698676",
"0.6965958",
"0.68606925",
"0.68600625",
"0.6857476",
"0.67635787",
"0.6722866",
"0.6721171",
"0.6692241",
"0.66776305",
"0.66626406",
"0.66584057",
"0.66395634",
"0.66275424",
"0.66211987",
"0.662... | 0.8460935 | 0 |
return path of best checkpoint in a model_dir | def best_checkpoint(model_dir, model_name):
filenames = glob.glob(os.path.join(model_dir,model_name+".*"))
best = 0
best_ckpt = ""
for fname in filenames:
tmp = float(fname.replace(os.path.join(model_dir,model_name+"."),""))
if best < tmp:
best = tmp
best_ckpt = f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_model(model_chkp_dir, mode='last'):\n\n if mode == 'last':\n file_name = sorted(os.listdir(model_chkp_dir))[-1]\n model_path = os.path.join(model_chkp_dir, file_name)\n\n elif mode == 'best':\n raise NotImplementedError\n\n return model_path",
"def _find_last_checkpoint(se... | [
"0.77047443",
"0.7275439",
"0.7243931",
"0.7167202",
"0.7096826",
"0.70633096",
"0.70490897",
"0.7047686",
"0.6949422",
"0.69273454",
"0.69082046",
"0.6876256",
"0.6825796",
"0.6814628",
"0.6799923",
"0.67915136",
"0.67452896",
"0.6720997",
"0.6715767",
"0.6666559",
"0.666464... | 0.7602403 | 1 |
return path of latest checkpoint in a model_dir | def latest_checkpoint(model_dir, model_name):
ckpt_info_path = Path(model_dir) / "checkpoints.json"
if not ckpt_info_path.is_file():
return None
with open(ckpt_info_path, 'r') as f:
ckpt_dict = json.loads(f.read())
if model_name not in ckpt_dict['latest_ckpt']:
return None
la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_last_checkpoint(self):\n highest_num, last_checkpoint = -np.inf, None\n for filename in os.listdir(self.logdir):\n # checkpoints look like logdir/model.ckpt-N\n # self._save_path is \"logdir/model.ckpt\"\n if os.path.basename(self._save_path) in filename:\n try:\n N =... | [
"0.77078223",
"0.753826",
"0.7491004",
"0.7485388",
"0.7307086",
"0.7223708",
"0.7215126",
"0.7205785",
"0.7110889",
"0.70348877",
"0.7023044",
"0.7001256",
"0.6954298",
"0.69517803",
"0.69449365",
"0.6940163",
"0.6933478",
"0.6877685",
"0.6873649",
"0.6860138",
"0.6805028",
... | 0.77784103 | 0 |
Get stage folder from stage number | def stage_folder(stage_no):
name = "stage.{}".format(stage_no)
folder = path.join(output_path(), name)
return ensure_path(folder) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_scene_folder():\n\n flg = logging.getLogger(\"lettuce.xgenSetup.get_scene_folder\")\n\n file_name = mc.file(q=True, sceneName=True)\n\n head, tail = os.path.split(file_name)\n\n flg.info(\"Scene fileName: {}\".format(tail))\n flg.info(\"Scene directory: {}\".format(head))\n\n return head"... | [
"0.6684712",
"0.654478",
"0.64453286",
"0.61957896",
"0.6165433",
"0.6139131",
"0.6111561",
"0.59132767",
"0.59132767",
"0.5840295",
"0.5827037",
"0.579603",
"0.57570565",
"0.57570565",
"0.57570565",
"0.5732925",
"0.5711266",
"0.5544683",
"0.5538145",
"0.5508859",
"0.54853666... | 0.80924505 | 0 |
Rounds to nearest integer and clears outofboundary values. Intensity boundary is [0, 255]. | def normalize(img):
tol = 355
maxi = np.max(img)
if maxi > tol:
img = 255 * (img - (tol - 255)) / maxi
# end if
norm = np.round(img)
norm[norm < 0] = 0
norm[norm > 255] = 255
return norm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip_round(value):\n return max(0, min(np.round(value/64), 1023))",
"def round_and_clip_image(image):\n \n for idx, pixel in enumerate(image[\"pixels\"]):\n if round(pixel) < 0 :\n image[\"pixels\"][idx] = 0\n elif round(pixel) > 255 :\n image[\"pixels\"][idx] = 2... | [
"0.659085",
"0.6122267",
"0.5983545",
"0.5962671",
"0.59548813",
"0.5940595",
"0.59342605",
"0.5893791",
"0.58673143",
"0.5842229",
"0.5834837",
"0.5816023",
"0.58125573",
"0.5807283",
"0.5797075",
"0.5789674",
"0.5788379",
"0.5784362",
"0.5770589",
"0.57692945",
"0.57363313"... | 0.6147466 | 1 |
Deletes a stage folder | def delete_stage(stage):
folder = stage_folder(stage)
shutil.rmtree(folder) # delete old
ensure_path(folder) # create new | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_folder(path):\n command = ['rm', '-rf', TEST_DIR]\n file_operation(path, command)",
"def _unstage_folder(dir_path):\n for dir_item in os.listdir(dir_path):\n full_path = os.path.join(dir_path, dir_item)\n if os.path.isfile(full_path) and dir_item != 'load.go':\n ... | [
"0.6754427",
"0.6659505",
"0.6353486",
"0.6346276",
"0.63430285",
"0.6243483",
"0.6221596",
"0.62102133",
"0.62036866",
"0.61407954",
"0.6134758",
"0.6134758",
"0.6118617",
"0.6117536",
"0.6064411",
"0.60489357",
"0.6011915",
"0.5986747",
"0.5982103",
"0.59773934",
"0.59722",... | 0.8571731 | 0 |
Rescale molecule coords to a given factor | def rescale_molecule(path, factor):
mol = Chem.MolFromMolFile(path, sanitize=True)
matrix = numpy.zeros((4, 4), float)
for i in range(3):
matrix[i, i] = factor
matrix[3, 3] = 1
AllChem.TransformMol(mol, matrix)
Chem.MolToMolFile(mol, path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale(self,factor):\n for x in range(len(self.coord)):\n self.coord[x] = np.array([y*factor for y in self.coord[x]])\n return self",
"def _force_rescale(self, setpoint_x, setpoint_y):",
"def scale_coords(self, mol, target=1.5):\n\t#Compute Median Bond Length\n\tbondlengths = []\n\t... | [
"0.7354363",
"0.6686502",
"0.66113037",
"0.6565813",
"0.6292672",
"0.62915665",
"0.6285049",
"0.62842643",
"0.62798035",
"0.6210972",
"0.6203826",
"0.6155714",
"0.61438906",
"0.6143718",
"0.6099302",
"0.6092187",
"0.6081201",
"0.6037964",
"0.60108364",
"0.59721416",
"0.595790... | 0.6958495 | 1 |
Update 2d images of pdbechem components which are available in the pubchem database from CCD files. | def update_ccd_file(self, ccd: str) -> None:
components = ccd_reader.read_pdb_components_file(ccd)
for i in components.values():
self.process_template(i.component) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_image(self):\n if self.filenames:\n pos = self.slider.value()\n proj, flat, dark, theta = dx.read_aps_32id(self.filenames, proj=(pos, pos+1))\n if self.ffc_correction:\n image = proj[0,:,:].astype(np.float)/flat[0,:,:].astype(np.float)\n ... | [
"0.59459436",
"0.5931459",
"0.5890593",
"0.56384003",
"0.542464",
"0.5374642",
"0.5374642",
"0.53658164",
"0.5333321",
"0.5295699",
"0.52952296",
"0.5214089",
"0.5175713",
"0.5169607",
"0.5164791",
"0.5131144",
"0.51290625",
"0.5110845",
"0.50653243",
"0.50643325",
"0.5064164... | 0.62722003 | 0 |
Process template for a given component. First the component is attempted to be downloaded and rescaled. Since the RDKit default depiction has 1.5A single bond size whereas templates from pubchem are 1.0A. | def process_template(self, component):
destination = os.path.join(self.pubchem_templates, f"{component.id}.sdf")
downloaded = download_template(destination, component.id, component.inchikey)
if downloaded:
rescale_molecule(destination, 1.5)
return downloaded | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def processTemplates(self, tk, templateFile = '', id = '', shotNum = '', inprogressBar = ''):\r\n ## Now fetch all the template paths from shotgun\r\n getTemplatePaths = tk.paths_from_template(templateFile, {'Step' : 'Light', 'id' : id, 'Shot' : shotNum})\r\n debug(app = self, method = 'proces... | [
"0.5333179",
"0.5140254",
"0.51039773",
"0.509984",
"0.5071793",
"0.5044713",
"0.4932854",
"0.4887987",
"0.4865483",
"0.47699484",
"0.4758888",
"0.47446755",
"0.47439492",
"0.47232375",
"0.46697277",
"0.46674794",
"0.46576747",
"0.46525013",
"0.46251747",
"0.46167573",
"0.459... | 0.83371866 | 0 |
Given the waterlevel time history, this function computes a least squares fit polynomial of degree p to the water level data. | def polyfit(dates, levels, p):
assert isinstance(p, int) and p > 0, f"{p} is not a positive integer"
x = matplotlib.dates.date2num(dates)
y = levels
try:
# Find coefficients of best-fit polynomial f(x) of degree p
p_coeff = np.polyfit(x - x[0], y, p)
# Convert coefficient into a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def polyfit(dates, levels, p):\n x = matplotlib.dates.date2num(dates)\n\n y = levels\n\n # Using shifted x values, find coefficient of best-fit\n # polynomial f(x) of degree p\n shifted_times = [t-x[0] for t in x]\n p_coeff = np.polyfit(shifted_times, y, p)\n\n # Convert coefficient into a pol... | [
"0.68798745",
"0.6365099",
"0.61925536",
"0.6161876",
"0.61507106",
"0.6070283",
"0.5868757",
"0.58644587",
"0.5821649",
"0.5798074",
"0.5762538",
"0.5758994",
"0.5749708",
"0.5739675",
"0.5738362",
"0.57277375",
"0.5726155",
"0.57221943",
"0.5698397",
"0.5694881",
"0.5680145... | 0.70911086 | 0 |
Convert a trace codes text to dictionary. | def from_trace_codes_text(codes_text: str) -> Mapping[int, str]:
return {int(s[0], 16): s[1] for s in map(lambda l: l.split(), codes_text.splitlines())} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_trace_codes_file(path: str) -> Mapping[int, str]:\n with open(path, 'r') as fd:\n return from_trace_codes_text(fd.read())",
"def default_trace_codes() -> Mapping[int, str]:\n with open(Path(__file__).resolve().parent.joinpath('trace.codes'), 'r') as fd:\n return from_trace_codes_text... | [
"0.6811558",
"0.61674523",
"0.6107895",
"0.59936696",
"0.592808",
"0.54712546",
"0.5466992",
"0.54269063",
"0.5381498",
"0.53706264",
"0.53520334",
"0.5219542",
"0.520817",
"0.51722044",
"0.5172045",
"0.51429605",
"0.51282406",
"0.51202375",
"0.5092845",
"0.5079664",
"0.50580... | 0.8251909 | 0 |
Read trace codes from a file. | def from_trace_codes_file(path: str) -> Mapping[int, str]:
with open(path, 'r') as fd:
return from_trace_codes_text(fd.read()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_trace(path):\n suffix = path[-3:]\n if suffix == 'txt':\n return read_csv(path)\n elif suffix == 'trc':\n return read_trc(path)\n else:\n raise ValueError(\"Invalid file extension: %s\" % suffix)",
"def read_codes(self, filename=\"static/codes.txt\"):\n with open(... | [
"0.69202065",
"0.65100384",
"0.6413361",
"0.6296157",
"0.61902547",
"0.6171397",
"0.6058499",
"0.59744567",
"0.594655",
"0.5926533",
"0.591121",
"0.58754104",
"0.58621883",
"0.57683814",
"0.5767075",
"0.5757081",
"0.5746866",
"0.57361424",
"0.5710775",
"0.56944233",
"0.565523... | 0.7683125 | 0 |
Get the default trace codes mapping. | def default_trace_codes() -> Mapping[int, str]:
with open(Path(__file__).resolve().parent.joinpath('trace.codes'), 'r') as fd:
return from_trace_codes_text(fd.read()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_trace_codes_file(path: str) -> Mapping[int, str]:\n with open(path, 'r') as fd:\n return from_trace_codes_text(fd.read())",
"def forward_code_map(self):\n\n return { c.key:c.value for c in self.codes}",
"def codes(self, name):\n return self._get_valuemap(name, non_mapped='codes... | [
"0.6177796",
"0.6068879",
"0.60158306",
"0.58416814",
"0.5706858",
"0.5705263",
"0.563382",
"0.5626298",
"0.5607481",
"0.558467",
"0.549548",
"0.5402228",
"0.5259976",
"0.52537525",
"0.52353066",
"0.5230671",
"0.51013124",
"0.5097843",
"0.5085019",
"0.50778747",
"0.5073233",
... | 0.86958295 | 0 |
Install the cloc package for autograding source code comment counting. | def up(config):
os.system("sudo apt-get install cloc --yes") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def InstallPrereqs():\n #Collect the source for Cython and put in _deps/cython-master\n import urllib,zipfile\n print('getting cython sources')\n urllib.urlretrieve('https://github.com/cython/cython/archive/master.zip', filename = 'master.zip')\n with zipfile.ZipFile('master.zip', 'r') as myzip:\n ... | [
"0.57753175",
"0.50839555",
"0.5048947",
"0.4999652",
"0.4999292",
"0.49329606",
"0.48832586",
"0.48532987",
"0.4812118",
"0.48035082",
"0.4798042",
"0.4769488",
"0.4746221",
"0.47187597",
"0.47153038",
"0.4701966",
"0.4700621",
"0.46982154",
"0.46897608",
"0.46163833",
"0.46... | 0.5521329 | 1 |
Test when the yaml stream is a valid xban format | def test_valid_xban():
# first is a valid dict but the second one is not
stream = [
{"xban_config": {"title": "testfile", "description": "", "board_color": [],}},
{},
]
assert xban_content("test/testfile.yaml", stream) == stream | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_yaml_xban(caplog):\n\n # the color generation is random so need to check individual values\n\n stream = [{\"new\": [\"a\", \"b\"], \"old\": [\"c\", \"d\"]}]\n\n parsed = xban_content(\"test/testfile.yaml\", stream)\n assert parsed[1] == stream[0]\n assert parsed[0][\"xban_config\"][\"... | [
"0.77437544",
"0.75530493",
"0.75530493",
"0.6958264",
"0.6825725",
"0.6687764",
"0.66465294",
"0.65671825",
"0.6549907",
"0.6477815",
"0.63983715",
"0.6390067",
"0.62619424",
"0.6199314",
"0.6169752",
"0.6092808",
"0.6079635",
"0.60743856",
"0.60647416",
"0.60126257",
"0.599... | 0.76649076 | 1 |
Test given process yaml given a mocked io and invalid input | def test_process_yaml_invalid(caplog):
data = """
text_key: incorrect format
- listitem
- listitem
"""
with patch("builtins.open", mock_open(read_data=data)):
result = process_yaml("test/file.yaml")
for record in caplog.records:
assert (
"Incorrect test/file.yam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_process_yaml_valid(caplog):\n\n with patch(\"builtins.open\", mock_open(read_data=DATA)):\n result = process_yaml(\"test/testfile.yaml\")\n assert result == [\n {\n \"xban_config\": {\n \"title\": \"testfile\",\n \"description\": \"test io\",\n ... | [
"0.72985035",
"0.61559045",
"0.6025226",
"0.5997324",
"0.59448725",
"0.5877921",
"0.5869697",
"0.5867817",
"0.5832697",
"0.5803574",
"0.57814",
"0.5766075",
"0.5719221",
"0.5697595",
"0.5692346",
"0.568342",
"0.5672739",
"0.56462955",
"0.5644205",
"0.5641872",
"0.562619",
"... | 0.671951 | 1 |
Test given process yaml given a mocked io | def test_process_yaml_valid(caplog):
with patch("builtins.open", mock_open(read_data=DATA)):
result = process_yaml("test/testfile.yaml")
assert result == [
{
"xban_config": {
"title": "testfile",
"description": "test io",
"board_color"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_yaml_include(mo):\n\n mo.return_value.name = \"./foobar.yml\"\n mo2 = mock.mock_open(read_data=test)\n mo2.return_value.name = \"test\"\n handlers = (mo.return_value, mo2.return_value)\n mo.side_effect = handlers\n\n with mock.patch(\"builtins.open\", mo, create=True):\n cfg = con... | [
"0.5976523",
"0.59347874",
"0.57523376",
"0.5659607",
"0.5630501",
"0.55258167",
"0.55115277",
"0.54421395",
"0.5437241",
"0.5436717",
"0.5402416",
"0.5360342",
"0.53089064",
"0.5305208",
"0.5304585",
"0.52773273",
"0.5237477",
"0.52093935",
"0.5208303",
"0.5205367",
"0.52052... | 0.7105798 | 0 |
Verify that cloud endpoint service names match the regex | def test_match_endpoints():
service_names = [
"iap-ingress-kfctl-8c9b.endpoints.kubeflow-ci-deployment.cloud.goog",
]
for s in service_names:
assert cleanup_ci.is_match(s, patterns=cleanup_ci.E2E_PATTERNS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_service_endpoint(path):\n return re.match(r'^[a-zA-Z0-9.-]+:\\d+$', path)",
"def check_name(name, allow_services=False):",
"def is_service_name_correct(self, service):\r\n return service in self.services",
"def _is_format_endpoint(pattern):\n return '?P<format>' in pattern._regex",
"def e... | [
"0.6847793",
"0.65917355",
"0.6273963",
"0.58474916",
"0.57660294",
"0.5582451",
"0.5489312",
"0.5447833",
"0.5414882",
"0.53854394",
"0.5358709",
"0.5328395",
"0.53097093",
"0.5299616",
"0.525812",
"0.52561545",
"0.52393234",
"0.5234684",
"0.5198802",
"0.51901925",
"0.518286... | 0.76800895 | 0 |
Process an LTPage layout and return a list of elements. | def _process_layout(self, layout):
# Here we just group text into paragraphs
elements = []
for lt_obj in layout:
if isinstance(lt_obj, LTTextBox) or isinstance(lt_obj, LTTextLine):
elements.append(Paragraph(lt_obj.get_text().strip()))
elif isinstance(lt_ob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _process_layout(self, layout):\r\n # Here we just group text into paragraphs\r\n elements = []\r\n for lt_obj in layout:\r\n if isinstance(lt_obj, LTTextBox) or isinstance(lt_obj, LTTextLine):\r\n elements.append(Paragraph(lt_obj.get_text().strip()))\r\n ... | [
"0.7649959",
"0.6409742",
"0.602266",
"0.5737034",
"0.5713485",
"0.5590701",
"0.54194415",
"0.5303942",
"0.52360404",
"0.5199061",
"0.51894474",
"0.51213837",
"0.5121312",
"0.5115619",
"0.50663406",
"0.5054951",
"0.50322646",
"0.4996954",
"0.49940476",
"0.4983458",
"0.4974945... | 0.7622432 | 1 |
Computes where the first tensor is greater than the second tensor. This is an elementwise operation (with NumPystyle broadcasting support). See also | def greater(input: Tensor, other: Tensor) -> Tensor:
ctx = get_current_context()
g = ctx.graph
pb_g = g._pb_graph
check_in_graph(g, input=input, other=other)
check_tensor_ipu_and_tile_set(input=input, other=other)
settings = ctx._get_op_settings("greater")
opid = _ir.OperatorIdentifier("ai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_greater_than_bcast(self):\n utils.compare_tracing_methods(\n SimpleCompareOpsModule(\"greaterThan\"),\n torch.randn(3, 4, 5),\n torch.randn(4, 5),\n fusible_ops={\"aten::gt\"},\n )",
"def test_greater_than(self):\n utils.compare_tracing_me... | [
"0.7161988",
"0.69977444",
"0.6803066",
"0.6791493",
"0.6791026",
"0.67566764",
"0.6724056",
"0.6651434",
"0.6625063",
"0.66145337",
"0.657495",
"0.6460056",
"0.64555115",
"0.6449233",
"0.64254844",
"0.63984334",
"0.636584",
"0.63458794",
"0.63412446",
"0.63338196",
"0.632626... | 0.7294057 | 0 |
Get this project folder's name or None if it is the root project folder | def get_name(self):
return self.client._perform_json("GET", "/project-folders/%s" % self.project_folder_id).get("name", None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_project_root_name():\n return get_project_root_name_from_settings(settings.PROJECT_ROOT)",
"def base_name(self):\n return self._project.path",
"def get_project_name(working_dir):\n return path.path(working_dir).name",
"def get_name(self) -> str:\n return os.path.split(os.getcwd())... | [
"0.7680206",
"0.7352743",
"0.7339847",
"0.73121136",
"0.72225565",
"0.70877147",
"0.70877147",
"0.70877147",
"0.70877147",
"0.70877147",
"0.70877147",
"0.7020423",
"0.6999252",
"0.6999252",
"0.69466954",
"0.6943411",
"0.6913359",
"0.6867396",
"0.6861792",
"0.6852675",
"0.6782... | 0.7708228 | 0 |
Get this project folder's parent or None if it is the root project folder | def get_parent(self):
parent_id = self.client._perform_json("GET", "/project-folders/%s" % self.project_folder_id).get("parentId", None)
if parent_id is None:
return None
else:
return DSSProjectFolder(self.client, parent_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_folder(self):\n return self.properties.get(\"ParentFolder\",\n Folder(self.context, ResourcePath(\"ParentFolder\", self.resource_path)))",
"def parent_dir(self):\n parent = os.path.dirname(self.dirn)\n if self.is_subdir:\n parent = os.p... | [
"0.75956905",
"0.7526333",
"0.7380301",
"0.7366877",
"0.73337495",
"0.7214397",
"0.7214397",
"0.7214397",
"0.7214397",
"0.72093064",
"0.71505404",
"0.7147413",
"0.7147413",
"0.7107515",
"0.70951563",
"0.7071745",
"0.7060472",
"0.70595",
"0.70325863",
"0.7026057",
"0.70073944"... | 0.8148282 | 0 |
List the child project folders inside this project folder | def list_child_folders(self):
children = self.client._perform_json("GET", "/project-folders/%s" % self.project_folder_id).get("childrenIds", [])
return [DSSProjectFolder(self.client, child) for child in children] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_projects():\n if '.wcscanner' not in os.listdir(context.__BASE_PATH__):\n return []\n return os.listdir(context.__PROJECTS_PATH__)",
"def list_dir(self, path):",
"def list_projects(self) -> List['RadsProject']:\n ret = []\n base = self.fspath(\"projects\")\n for name ... | [
"0.671556",
"0.65671426",
"0.649489",
"0.6452801",
"0.6385048",
"0.6361596",
"0.6360185",
"0.6353166",
"0.6309465",
"0.6256494",
"0.62158364",
"0.6205499",
"0.61954165",
"0.6167936",
"0.61630815",
"0.6134903",
"0.61286485",
"0.61226493",
"0.60995126",
"0.6084035",
"0.6050062"... | 0.7146115 | 0 |
List the project keys of the projects that are stored in this project folder | def list_project_keys(self):
return self.client._perform_json("GET", "/project-folders/%s" % self.project_folder_id).get("projectKeys", []) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_keys_from_projects():\r\n\r\n returnkeys = set()\r\n for project in (self.project*self.suspend_default_keys) + self.temp_projects:\r\n if project in self.default_dict['projects'].get_all_projects():\r\n returnkeys = returnkeys.union(set(self.default_d... | [
"0.7168071",
"0.7027032",
"0.68906045",
"0.6847208",
"0.67857355",
"0.6781415",
"0.6719056",
"0.66914505",
"0.6626524",
"0.66041535",
"0.65820473",
"0.6570286",
"0.6526935",
"0.65014863",
"0.6491836",
"0.64669544",
"0.64484143",
"0.6429212",
"0.6370583",
"0.6344642",
"0.63150... | 0.8718406 | 0 |
Move this project folder into another project folder (aka. destination) | def move_to(self, destination):
params = {
"destination": destination.project_folder_id
}
self.client._perform_empty("POST", "/project-folders/%s/move" % self.project_folder_id, params=params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_project_to(self, project_key, destination):\n params = {\n \"destination\": destination.project_folder_id\n }\n self.client._perform_empty(\"POST\", \"/project-folders/%s/projects/%s/move\" % (self.project_folder_id, project_key), params=params)",
"def move(self,src,dst):... | [
"0.71520203",
"0.68892497",
"0.68195164",
"0.669439",
"0.65629345",
"0.64931214",
"0.6460968",
"0.63149184",
"0.6205377",
"0.61995924",
"0.6159439",
"0.6138532",
"0.6100024",
"0.6050833",
"0.6043683",
"0.60310405",
"0.60202485",
"0.60058755",
"0.59887636",
"0.5975746",
"0.596... | 0.7494612 | 0 |
Move a project within this project folder into another project folder (aka. destination) | def move_project_to(self, project_key, destination):
params = {
"destination": destination.project_folder_id
}
self.client._perform_empty("POST", "/project-folders/%s/projects/%s/move" % (self.project_folder_id, project_key), params=params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_to(self, destination):\n params = {\n \"destination\": destination.project_folder_id\n }\n self.client._perform_empty(\"POST\", \"/project-folders/%s/move\" % self.project_folder_id, params=params)",
"def move(self,src,dst):\n src = os.path.join(self.testpath,src)\... | [
"0.7171021",
"0.63889736",
"0.6316078",
"0.621614",
"0.6122555",
"0.5999708",
"0.5974252",
"0.5811231",
"0.5784794",
"0.57436264",
"0.5729",
"0.5725763",
"0.5717845",
"0.5717237",
"0.57152677",
"0.57001674",
"0.56600225",
"0.5658027",
"0.5654615",
"0.5640274",
"0.5616604",
... | 0.7311976 | 0 |
Gets all settings as a raw dictionary. This returns a reference to the raw retrieved settings, not a copy, so changes made to the returned object will be reflected when saving. | def get_raw(self):
return self.settings | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_values(self):\n rv = {}\n for setting in self.manager.all():\n rv[setting.name] = setting.to_dict()\n return rv",
"def get_settings(self):\n\n\t\t# TODO: Consider YAML. Human writable, machine readable.\n\t\twith open(self.filename) as fp:\n\t\t\ttry:\n\t\t\t\treturn json... | [
"0.72432184",
"0.6985964",
"0.6944899",
"0.6929001",
"0.69271636",
"0.6859243",
"0.6859243",
"0.68463105",
"0.6821209",
"0.6821209",
"0.6763247",
"0.67585516",
"0.6684184",
"0.6684184",
"0.6682379",
"0.668028",
"0.66603684",
"0.66174513",
"0.6500105",
"0.6481581",
"0.6417557"... | 0.78474265 | 1 |
Set the owner of the project folder | def set_owner(self, owner):
self.settings["owner"] = owner | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_owner(self, owner):\n self.__owner = owner",
"def set_ownership(self):\n\n os.chmod(os.path.join(\"%s\" % NetworkManager_conf_dir, self.connection._id), 0600)",
"def set_file_owner(host, fqpath, user):\n command = \"chown %s %s\" % (user, fqpath)\n rcode, _, rerr = g.run(host, comma... | [
"0.70010644",
"0.67605895",
"0.6558529",
"0.65345246",
"0.64300406",
"0.6328601",
"0.6328463",
"0.6319",
"0.6319",
"0.6319",
"0.6319",
"0.62747085",
"0.6262846",
"0.616684",
"0.616684",
"0.616684",
"0.616684",
"0.6150944",
"0.61200434",
"0.6045264",
"0.60192376",
"0.5943294... | 0.7705122 | 0 |
Test case for list_supported_assets | def test_list_supported_assets(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_system_assets(self):\n pass",
"def test_get_test_assets(self):\n pass",
"def test_list_dependent_assets(self):\n pass",
"def test_list_dependent_assets3(self):\n pass",
"def test_list_dependent_assets2(self):\n pass",
"def test_list_dependent_assets1(self)... | [
"0.7656596",
"0.6691637",
"0.65236694",
"0.6175305",
"0.6162377",
"0.5957903",
"0.5940173",
"0.5921987",
"0.5883309",
"0.5817313",
"0.5779641",
"0.5772436",
"0.5749467",
"0.5739388",
"0.57346356",
"0.57313186",
"0.55638844",
"0.55423427",
"0.5535344",
"0.55265224",
"0.5520921... | 0.9424378 | 0 |
Determine if a value is a sequence type. | def is_sequence(value):
return (hasattr(value, "__iter__") and not
isinstance(value, (six.string_types, six.binary_type))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_sequence_type(self):\n raise exceptions.NotImplementedError()",
"def is_sequence(self) -> bool:\n return isinstance(self.yaml_node, yaml.SequenceNode)",
"def isSequence(obj):\n # type: (Any) -> bool\n return isinstance(obj, Sequence)",
"def _is_proper_sequence(seq):\n return (is... | [
"0.7498325",
"0.72475845",
"0.7201947",
"0.7077905",
"0.68908113",
"0.6705126",
"0.6571976",
"0.6474664",
"0.64672744",
"0.6388015",
"0.6350229",
"0.63393205",
"0.6258271",
"0.6190354",
"0.6108412",
"0.60880846",
"0.6007587",
"0.59494674",
"0.5857607",
"0.5830456",
"0.5734059... | 0.7734437 | 0 |
Import the class referred to by the fully qualified class path. | def import_class(classpath):
modname, classname = classpath.rsplit(".", 1)
module = importlib.import_module(modname)
klass = getattr(module, classname)
return klass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_class(path):\n components = path.split(\".\")\n module = components[:-1]\n module = \".\".join(module)\n # __import__ needs a native str() on py2\n mod = __import__(module, fromlist=[str(components[-1])])\n return getattr(mod, str(components[-1]))",
"def import_class(self, class_name... | [
"0.7455476",
"0.69682497",
"0.68978304",
"0.68467927",
"0.6829854",
"0.68212545",
"0.6801098",
"0.6758792",
"0.67015433",
"0.66877824",
"0.66808754",
"0.66743",
"0.66590977",
"0.64971083",
"0.6385219",
"0.63572675",
"0.63111407",
"0.6289722",
"0.6236301",
"0.6071559",
"0.6060... | 0.70014346 | 1 |
Attempt to return a Python class for the input class reference. If `classref` is a class or None, return it. If `classref` is a python classpath (e.g., "foo.bar.MyClass") import the class and return it. | def resolve_class(classref):
if classref is None:
return None
elif isinstance(classref, six.class_types):
return classref
elif isinstance(classref, six.string_types):
return import_class(classref)
else:
raise ValueError("Unable to resolve class for '%s'" % classref) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_from_class_path(class_path):\n if class_path not in _CLASS_PATH_TO_CLASS_CACHE:\n module_name, class_name = class_path.rsplit('.', 1)\n m = importlib.import_module(module_name)\n c = getattr(m, class_name)\n _CLASS_PATH_TO_CLASS_CACHE[class_path] = c\n\n return _CLASS_PATH_TO_CLASS_CACHE[cl... | [
"0.6821553",
"0.6546032",
"0.6535509",
"0.64897174",
"0.6375194",
"0.62873596",
"0.6285258",
"0.62793916",
"0.62676936",
"0.6228637",
"0.61416215",
"0.61140877",
"0.6087256",
"0.6058573",
"0.6048758",
"0.5986935",
"0.59225583",
"0.58762515",
"0.5859201",
"0.5783632",
"0.57542... | 0.883918 | 0 |
Function decorator which checks that the decorated function is called with a set of required kwargs. | def needkwargs(*argnames):
required = set(argnames)
def decorator(func):
def inner(*args, **kwargs):
missing = required - set(kwargs)
if missing:
err = "%s kwargs are missing." % list(missing)
raise ValueError(err)
return func(*args, *... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_arguments(required):\n\n def decorator(func):\n def wrapper(request):\n request_params = get_dict_from_request(request)\n for param in required:\n if param not in request_params:\n return APIMissingArgumentResponse(error_msg=param)\n ... | [
"0.72308356",
"0.7081471",
"0.7008813",
"0.6984335",
"0.69742376",
"0.69423914",
"0.69055426",
"0.6887728",
"0.6887091",
"0.6854476",
"0.6846821",
"0.67375857",
"0.6730363",
"0.6717054",
"0.6682574",
"0.6669929",
"0.66130555",
"0.6594434",
"0.65906775",
"0.6549689",
"0.649757... | 0.7618426 | 0 |
Test the ArmiCLI.showVersion method. | def test_showVersion(self):
origout = sys.stdout
try:
out = io.StringIO()
sys.stdout = out
ArmiCLI.showVersion()
finally:
sys.stdout = origout
self.assertIn("armi", out.getvalue())
self.assertIn(meta.__version__, out.getvalue()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_show_version():\n result = runner.invoke(app, [\"--version\"])\n assert result.exit_code == 0\n assert \"Confluence poster version\" in result.stdout",
"def test_cli_version_info(config, capsys):\n CLI.version_info()\n captured = capsys.readouterr()\n assert captured.out == \"yessssms ... | [
"0.7923721",
"0.771824",
"0.7611274",
"0.75258106",
"0.749578",
"0.74099976",
"0.7334167",
"0.7327753",
"0.723506",
"0.7200838",
"0.71340364",
"0.7133125",
"0.7112922",
"0.70674443",
"0.7005836",
"0.69929063",
"0.6932062",
"0.6920988",
"0.6911848",
"0.6906924",
"0.68915796",
... | 0.81843084 | 0 |
Wrapper around ProtobufReceiver.send_obj for logging | def send_obj(self, obj):
ProtobufReceiver.send_obj(self, obj)
self.factory.sent_message_log[obj.__class__.__name__] += obj.ByteSize() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send(self, obj):\n try:\n obj = dic_pickle_dumps_and_b64(obj)\n self.bufout += json.dumps(obj) + \"\\n\\n\"\n except:\n # It should never happen! And not be reported to the client!\n logging.exception(\"Client.send(%s)\", self)",
"def send(self, kwarg... | [
"0.6729722",
"0.65537256",
"0.62075424",
"0.6126205",
"0.6092147",
"0.6076926",
"0.60404396",
"0.6032093",
"0.59861624",
"0.59832275",
"0.59643966",
"0.59317803",
"0.5841705",
"0.5838265",
"0.5838265",
"0.5838265",
"0.57502455",
"0.57261884",
"0.5718602",
"0.56995785",
"0.565... | 0.7474465 | 0 |
Broadcast a message to all nodes in self.peers, the list should include myself | def bcast(self, msg):
for k, v in self.peers.iteritems():
proto = v[2]
proto.send_obj(msg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def broadcast(msg):\r\n for user in clients:\r\n msg_client(msg, user)",
"def broadcast(self, message):\n for s in self.connections:\n s.send(bytes(message, encoding='utf-8'))",
"def broadcast(self, msg):\n for client in self.clients.values():\n send_data(client.socket, msg)... | [
"0.7086546",
"0.69735074",
"0.69041973",
"0.67947894",
"0.67869544",
"0.6753279",
"0.64555633",
"0.64517486",
"0.6389841",
"0.6380765",
"0.6365368",
"0.634614",
"0.6294606",
"0.6270231",
"0.62304324",
"0.62302434",
"0.62242216",
"0.62085104",
"0.6192714",
"0.6187464",
"0.6165... | 0.699885 | 1 |
sets all peers to promoters, only use this method for testing | def overwrite_promoters(self):
logging.debug("NODE: overwriting promoters {}".format(len(self.peers)))
self.promoters = self.peers.keys() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_peers(self):\n for i in self.nodes:\n i.start()",
"def honeypot_peer(self,honeypotids,ip,port):\n req = {\"type\":\"set_peer\",\n \"from\":self.network.mc_id,\n \"to\":honeypotids,\n \"ip\":ip,\n \"port\":port}\n expect_d... | [
"0.65473676",
"0.5898622",
"0.58977187",
"0.58709633",
"0.5758995",
"0.5739834",
"0.55967075",
"0.5580255",
"0.5573473",
"0.55024105",
"0.54508686",
"0.5439354",
"0.54012555",
"0.5398449",
"0.5394799",
"0.53926075",
"0.53751516",
"0.5373392",
"0.53349924",
"0.5330222",
"0.531... | 0.80836135 | 0 |
Release the play_lock, allowing this player to take action. | def release_play_lock(self) :
self.play_lock = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_play_lock(self) : \n self.play_lock = True",
"def release_lock(self):\n if self.lock:\n self.lock.release()",
"def _unload_player(self):\n if self.player is not None:\n Logger.info(\"VLCPlayer: Unloading player\")\n self.player.event_manager().eve... | [
"0.80757964",
"0.681601",
"0.6544812",
"0.6506472",
"0.6494424",
"0.64629257",
"0.6462893",
"0.64540225",
"0.6352633",
"0.6288496",
"0.62782377",
"0.62748384",
"0.62733674",
"0.6267041",
"0.62507015",
"0.6235214",
"0.6166721",
"0.6162678",
"0.6134564",
"0.6134564",
"0.611125"... | 0.89283556 | 0 |
Prevent the player from doing anything by closing his play_lock. | def close_play_lock(self) :
self.play_lock = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release_play_lock(self) :\n self.play_lock = False",
"def stop(self):\n self.set_state_null()\n self.player = None",
"def stop(self):\n if self.player and self.player.is_playing():\n self.player.pause()\n super().stop()",
"def _control_stop(self):\n se... | [
"0.80847925",
"0.74121135",
"0.704765",
"0.6801468",
"0.67960155",
"0.6727953",
"0.67137367",
"0.6661506",
"0.66500396",
"0.662484",
"0.6569142",
"0.6555061",
"0.651804",
"0.6496678",
"0.64666593",
"0.6449531",
"0.6446811",
"0.6435666",
"0.640964",
"0.64022917",
"0.6401895",
... | 0.86099297 | 0 |
Play the combination of cards defined by the given indices. ======= =============================================================== indices list of int; the indices of the cards to play as they appear in self.cards ======= =============================================================== | def play(self, indices) :
cards = [self.cards[i] for i in indices]
combination = Combination(cards)
return combination | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_card_by_index(self, index, **kwargs):\n target = kwargs.get('target', None)\n self.hand[index].play(target=target)",
"def play_minion(num_cards_in_hand, card_idx):\n click_on_card(num_cards_in_hand, card_idx)\n mouseclick(510, 472)",
"def play_card(self, index):\n if index <... | [
"0.69412464",
"0.6330761",
"0.6193321",
"0.5735996",
"0.57159185",
"0.57118446",
"0.5599808",
"0.55448586",
"0.553087",
"0.55256015",
"0.5468829",
"0.5448354",
"0.54388344",
"0.54294634",
"0.540727",
"0.54032826",
"0.5387532",
"0.5382046",
"0.53635436",
"0.53505224",
"0.53424... | 0.87667453 | 0 |
Initializes DINT model with the specified feature configuration and resampling strategy. The model gets created at schema_matcher server. | def __init__(self, schema_matcher, feature_config, resampling_strategy, description):
logging.info("Initializing DINT model.")
if not(type(schema_matcher) is SchemaMatcher):
logging.error("DINTModel init: SchemaMatcher instance required.")
raise InternalError("DINTModel init", "S... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **kwargs):\n\n # Identify the mode to start the model in\n if \"x\" in kwargs and \"y\" in kwargs:\n x = kwargs.get(\"x\")\n y = kwargs.get(\"y\")\n if \"model_name\" not in kwargs:\n self.__mode = \"train\"\n else:\n ... | [
"0.6067533",
"0.59074247",
"0.5883574",
"0.57862705",
"0.5761598",
"0.57383394",
"0.5631568",
"0.5629441",
"0.55597234",
"0.5543431",
"0.5540538",
"0.5529641",
"0.5491851",
"0.5476369",
"0.54582095",
"0.54497975",
"0.54382914",
"0.5434254",
"0.5421252",
"0.54178",
"0.5411861"... | 0.8336873 | 0 |
Train DINTModel and return True. | def train(self):
logging.info("Training DINTModel.")
start = time.time()
tr = self.classifier.train()
return time.time() - start | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train():\n pass",
"def train():\n # YOUR TRAINING CODE GOES HERE",
"def train(self, dataset):\n \"*** YOUR CODE HERE ***\"\n converged = False\n while not converged:\n failures = 0\n for item, classification in dataset.iterate_once(1):\n p... | [
"0.6943487",
"0.69396836",
"0.6853591",
"0.6760111",
"0.6710526",
"0.6703681",
"0.669696",
"0.6665524",
"0.6639153",
"0.6626513",
"0.66127175",
"0.658711",
"0.6572034",
"0.6572034",
"0.6572034",
"0.6572034",
"0.6572034",
"0.6546802",
"0.65428543",
"0.65414816",
"0.6514876",
... | 0.7758692 | 0 |
Prediction with DINTModel for the source. | def predict(self, source):
# TODO: track run time
logging.info("Predicting with DINTModel for source {}".format(source))
if source not in self.allowed_sources:
logging.warning("Source '{}' not in allowed_sources. Skipping it.".format(source))
return None
# upload ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, model, x_test):\n pass",
"def predict(self, src): # real signature unknown; restored from __doc__\n pass",
"def predict_step(self, x):\n\n input_x = self.session.graph.get_operation_by_name(\"input_x\").outputs[0]\n predictions_op = self.session.graph.get_operation... | [
"0.6938811",
"0.69291127",
"0.68213713",
"0.6790836",
"0.6790836",
"0.6790836",
"0.67622983",
"0.67259806",
"0.67074686",
"0.6683066",
"0.66768557",
"0.6623888",
"0.6623888",
"0.6618554",
"0.6615593",
"0.65755063",
"0.6575005",
"0.65682495",
"0.65682495",
"0.65682495",
"0.656... | 0.73403883 | 0 |
Read columns from source, and return them as a list of Column objects (as defined in neural_nets.museum_data_reader) | def _read(self, source, label_source=None):
filename = os.path.join("data", "sources", source+".csv")
if label_source is None:
label_filename = os.path.join("data", "labels", source + ".columnmap.txt")
else:
label_filename = os.path.join("data", "labels", label_source)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_columns(source):\n return _get_tuple(source)",
"def _get_column_parts(source):\n return _get_tuple(source, delimiter=' ')",
"def load_columns(self):\n pass",
"def columns(self) -> java.util.Collection:\n ...",
"def list_column(self,\n column_name: str,\n ... | [
"0.7480413",
"0.659853",
"0.6436579",
"0.6131555",
"0.60717994",
"0.6018328",
"0.59529024",
"0.5887448",
"0.5881336",
"0.5843457",
"0.58333224",
"0.582966",
"0.58264387",
"0.580666",
"0.5799173",
"0.57792217",
"0.57775426",
"0.57338744",
"0.57074404",
"0.57035786",
"0.5700294... | 0.7367568 | 1 |
Extract training columns from train_sources, and assign semantic labels to them The result should be self.train_cols a list of Column objects (defined in museum_data_reader) to pass to labeler in self.train() | def define_training_data(self, train_sources, train_labels=None):
logging.info("Defining training data for NNetModel...")
self.train_cols = []
if train_labels is None:
for source in train_sources:
self.train_cols += self._read(source)
else:
for sou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read(self, source, label_source=None):\n filename = os.path.join(\"data\", \"sources\", source+\".csv\")\n if label_source is None:\n label_filename = os.path.join(\"data\", \"labels\", source + \".columnmap.txt\")\n else:\n label_filename = os.path.join(\"data\", \"... | [
"0.6559914",
"0.6052187",
"0.57164496",
"0.5696534",
"0.56487805",
"0.5536536",
"0.55146205",
"0.5490378",
"0.5440697",
"0.5417198",
"0.5373422",
"0.53056693",
"0.5295664",
"0.52940863",
"0.5287289",
"0.52654225",
"0.52557045",
"0.52543795",
"0.5223914",
"0.52191883",
"0.5207... | 0.6832204 | 0 |
Create an instance of NN_Column_Labeler, perform bagging, feature preparation, and training of the underlying classifier(s) | def train(self):
start = time.time()
self.labeler = NN_Column_Labeler([self.classifier_type], self.train_cols, split_by=hp['split_by'], test_frac=0, add_headers=self.add_headers, p_header=self.p_header) # test_frac = 0 means no further splitting into train and test sets, i.e., use train_cols as all_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def naive_bayes(self,X_columns, y_column, cv_kfold=10, class_bins=0, bin_strat='uniform', feature_selection=True):\n \n try:\n\n valid_strategy = ('uniform', 'quantile', 'kmeans')\n if bin_strat not in valid_strategy:\n raise ValueError(\"Valid options for 'bin_st... | [
"0.61327016",
"0.60631764",
"0.5974141",
"0.5968611",
"0.5860819",
"0.5854023",
"0.58511835",
"0.5840595",
"0.58283985",
"0.5798087",
"0.5785424",
"0.57740974",
"0.5768317",
"0.57531476",
"0.5741446",
"0.5738302",
"0.5718393",
"0.5714158",
"0.5706167",
"0.5693297",
"0.5693103... | 0.7302397 | 0 |
Predict labels for all columns in source | def predict(self, source):
# First, we need to extract query Column objects from source:
query_cols = []
for s in source:
query_cols += self._read(s)
logging.info("NNetModel: Predicting for {} columns from {} sources".format(len(query_cols), len(source)))
true_label... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_label(self, src): # real signature unknown; restored from __doc__\n pass",
"def predict_labels(model, x_test):\n \n pred = model.predict(x_test)\n #pred_labels = model.predict_classes(x_test) # depricated\n pred_labels = np.argmax(model.predict(x_test), axis=-1)\n \n retur... | [
"0.75673765",
"0.69536525",
"0.6880678",
"0.6880678",
"0.6878754",
"0.6861358",
"0.6859072",
"0.68183094",
"0.6798352",
"0.6798352",
"0.6798352",
"0.6794257",
"0.67640674",
"0.67569023",
"0.6752388",
"0.67336595",
"0.6707299",
"0.6691524",
"0.666908",
"0.6666647",
"0.66116095... | 0.79116446 | 0 |
Worker init func for dataloader. The seed of each worker equals to num_worker rank + worker_id + user_seed | def worker_init_fn(worker_id, num_workers, rank, seed):
worker_seed = num_workers * rank + worker_id + seed
np.random.seed(worker_seed)
random.seed(worker_seed) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def worker_init_fn(worker_id):\r\n base_seed = torch.IntTensor(1).random_().item()\r\n #print(worker_id, base_seed)\r\n np.random.seed(base_seed + worker_id)",
"def worker_init_fn(worker_id: int) -> None:\n worker_info = torch.utils.data.get_worker_info()\n set_rnd(worker_info.dataset, seed=worker... | [
"0.83711416",
"0.82632536",
"0.79382265",
"0.79382265",
"0.7899612",
"0.78742003",
"0.7825774",
"0.7457807",
"0.7354716",
"0.7296145",
"0.7219687",
"0.6539588",
"0.65001684",
"0.63125265",
"0.6237946",
"0.6194707",
"0.60962236",
"0.6094651",
"0.60454345",
"0.6043736",
"0.6035... | 0.86481786 | 1 |
If file "database2.sqlite" or "database3.sqlite" is damaged, music are reset and new ones are created | def error_correction():
if not path.exists("Databases"):
mkdir("Databases")
def check_db(db_name):
conn = sqlite3.connect(f"Databases/{db_name}")
cursor = conn.cursor()
try:
cursor.execute("SELECT * FROM user_music WHERE name=?", (encode_text("test_name")... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_db(self):\n songs = self.db.get_all_songs()\n for song in songs:\n if choose_song(song) == ERROR:\n self.db.delete_song(song)\n files = []\n for song in glob.glob(\"songs\\*.wav\"):\n to_append = song.split('\\\\')[ONE][:-4]\n f... | [
"0.69164497",
"0.6316394",
"0.59935206",
"0.5793738",
"0.57836765",
"0.5769535",
"0.5754988",
"0.5712814",
"0.5695106",
"0.5601377",
"0.55163604",
"0.55131423",
"0.54717577",
"0.54681504",
"0.54675",
"0.5466998",
"0.5455232",
"0.5451918",
"0.54459465",
"0.54375535",
"0.543573... | 0.6690796 | 1 |
Return paramater score given its current value, max value and parameter weight. | def get_param_score(param, max_value, weight=1):
return (math.log(1 + param) / math.log(1 + max(param, max_value))) * weight | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score(self, params):\n\n if self.use_sqrt:\n return self.score_sqrt(params)\n else:\n return self.score_full(params)",
"def greedy_policy(self):\n # print(self.weights)\n policy = defaultdict(lambda: 0)\n\n for entry, values in self.weights.items():\n ... | [
"0.6292394",
"0.6178509",
"0.6064886",
"0.6044544",
"0.6035095",
"0.60076636",
"0.5989297",
"0.5986231",
"0.5984959",
"0.5937223",
"0.59368867",
"0.591551",
"0.5853794",
"0.5844487",
"0.5820323",
"0.58165556",
"0.58165556",
"0.5810112",
"0.5798618",
"0.5790173",
"0.5771708",
... | 0.85167205 | 0 |
Return repository stats, including criticality score. | def get_repository_stats(repo, additional_params=[]):
# Validate and compute additional params first.
additional_params_total_weight = 0
additional_params_score = 0
for additional_param in additional_params:
try:
value, weight, max_threshold = [
int(i) for i in additi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __gitStatistics(self):\n self.vcs.gitStatistics(self.project.getProjectPath())",
"def get_commit_stats(self):\n return self.commit_stats",
"def get_stats():\r\n stats = {\r\n \"progress_precent\": 100.0*finished_work_units_amount/work_units_amount,\r\n \"results\": None if wo... | [
"0.6341863",
"0.60292643",
"0.6003116",
"0.5998877",
"0.58837956",
"0.5879955",
"0.58450276",
"0.57766205",
"0.57766205",
"0.57766205",
"0.5751038",
"0.57093024",
"0.5699269",
"0.56872267",
"0.5619458",
"0.561718",
"0.560706",
"0.55628246",
"0.54854643",
"0.5432927",
"0.54281... | 0.71026087 | 0 |
Return expiry information given a github token. | def get_github_token_info(g):
rate_limit = g.get_rate_limit()
near_expiry = rate_limit.core.remaining < 50
wait_time = (rate_limit.core.reset - datetime.datetime.utcnow()).seconds
return near_expiry, wait_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_github_auth_token():\n global _cached_github_token\n if _cached_github_token:\n near_expiry, _ = get_github_token_info(_cached_github_token)\n if not near_expiry:\n return _cached_github_token\n\n github_auth_token = os.getenv('GITHUB_AUTH_TOKEN')\n assert github_auth_t... | [
"0.6769654",
"0.6433507",
"0.6418123",
"0.6418123",
"0.57661664",
"0.57641804",
"0.5683738",
"0.5673133",
"0.5673133",
"0.5588578",
"0.5476521",
"0.54721695",
"0.54422075",
"0.5384525",
"0.53797305",
"0.5364178",
"0.5355047",
"0.53395385",
"0.53342307",
"0.52983904",
"0.52898... | 0.705975 | 0 |
Return an unexpired github token if possible from a list of tokens. | def get_github_auth_token():
global _cached_github_token
if _cached_github_token:
near_expiry, _ = get_github_token_info(_cached_github_token)
if not near_expiry:
return _cached_github_token
github_auth_token = os.getenv('GITHUB_AUTH_TOKEN')
assert github_auth_token, 'GITHUB... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokens():\n return ['access token', 'refresh token']",
"def token(cls, token):\n user_db = User.get_by('token', token)\n if not user_db:\n raise ValueError('Sorry, your token is either invalid or expired.')\n return token",
"def check_token(token: str, secret: str | List[... | [
"0.57277447",
"0.56966573",
"0.5588019",
"0.55098516",
"0.54732585",
"0.545649",
"0.54281145",
"0.54081726",
"0.5367577",
"0.5320743",
"0.5294111",
"0.5282494",
"0.5272418",
"0.5269372",
"0.5261628",
"0.52006954",
"0.5181814",
"0.51739687",
"0.5167998",
"0.51490164",
"0.51465... | 0.67476416 | 0 |
Return repository object, given a url. | def get_repository(url):
if not '://' in url:
url = 'https://' + url
parsed_url = urllib.parse.urlparse(url)
if parsed_url.netloc.endswith('github.com'):
g = get_github_auth_token()
repo_url = parsed_url.path.strip('/')
repo = GitHubRepository(g.get_repo(repo_url))
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRepo(session, name=None, url=None):\r\n\r\n try:\r\n # Look up repository by name\r\n if name is not None:\r\n return session.get_repo(name)\r\n\r\n # Look up repository by clone URL\r\n if url is not None:\r\n # Parse URL\r\n url = urlparse(url)\r\n\r\n # Check that this is... | [
"0.7281594",
"0.6778706",
"0.6539018",
"0.6533035",
"0.6382873",
"0.63770306",
"0.63320506",
"0.6298444",
"0.62905043",
"0.6267841",
"0.6234613",
"0.6186023",
"0.6170094",
"0.610516",
"0.6103195",
"0.6099141",
"0.60270405",
"0.6025164",
"0.6019437",
"0.59717953",
"0.59647065"... | 0.76957023 | 0 |
Build an oauth client with which callers can query Allura. | def make_oauth_client(base_url) -> requests.Session:
config_file = os.path.join(os.environ['HOME'], '.allurarc')
cp = ConfigParser()
cp.read(config_file)
REQUEST_TOKEN_URL = base_url + '/rest/oauth/request_token'
AUTHORIZE_URL = base_url + '/rest/oauth/authorize'
ACCESS_TOKEN_URL = base_url + '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, oauth=None, client_id=None):\n\t\tself.oauth = oauth\n\t\tself.client_id = client_id or self.default_client_id",
"def oauth_config(url_base):\n return {\n \"credentials\": {\n \"auth_type\": \"oauth2_confidential_application\",\n \"client_secret\": \"test_client... | [
"0.6535492",
"0.6519864",
"0.6420498",
"0.6407966",
"0.6387362",
"0.6379229",
"0.62640995",
"0.62335783",
"0.6118638",
"0.60628766",
"0.6022355",
"0.6002151",
"0.59875053",
"0.5984816",
"0.5984286",
"0.5928542",
"0.59119326",
"0.59105897",
"0.5902255",
"0.58838856",
"0.584856... | 0.6976381 | 0 |
Count how many times the phrase appears in the text | def count_phrase_in_text(phrase: str, text: str):
count = 0
# Remove leading and trailing white spaces
phrase = phrase.strip()
# Substitute multiple whitespace with single whitespace
phrase = ' '.join(phrase.split())
if text.startswith(phrase + " "):
count += 1
if text.endswith(" " +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(text):\n return len(text)",
"def word_count(phrase):\n return collections.Counter(phrase.split())",
"def text_count(self, text):\n res = 0\n for intv in self:\n if intv._text == text:\n res += 1\n return res",
"def total_phrases(target_text):\n\n... | [
"0.7900522",
"0.7784761",
"0.7549326",
"0.7538776",
"0.75155354",
"0.7307728",
"0.7293747",
"0.7270723",
"0.7217096",
"0.72156507",
"0.7180605",
"0.71126467",
"0.71083605",
"0.7090928",
"0.7031768",
"0.70294064",
"0.7003735",
"0.69982064",
"0.69665307",
"0.69554585",
"0.69320... | 0.8243048 | 0 |
Downloads and unzips an online csv file. | def download_and_unzip(url, zip_path, csv_path, data_folder):
download_from_url(url, zip_path)
unzip(zip_path, csv_path, data_folder)
print('Done.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downloadData(url):\r\n\r\n data = urllib2.urlopen(url)\r\n csvdata = data.read()",
"def download_and_unzip_dataset(url, path):\n dl = urllib.urlretrieve(url)\n zf = zipfile.ZipFile(dl[0])\n zf.extractall(path)\n return zf",
"def download_and_unzip_data(\n url=\"https://storage.googleap... | [
"0.70533955",
"0.7049977",
"0.6632082",
"0.6481793",
"0.64712685",
"0.63593525",
"0.62945485",
"0.6238677",
"0.61125064",
"0.61080784",
"0.6092125",
"0.60683024",
"0.6016457",
"0.6001136",
"0.60005647",
"0.59859836",
"0.5955988",
"0.59508663",
"0.5920118",
"0.59149975",
"0.58... | 0.8117438 | 0 |
Get the new suggested trials with random search. | def get_new_suggestions(self, study_id, trials=[], number=1):
search_space = hyperopt.hp.uniform('x', -10, 10)
search_space_instance = search_space
rstate = np.random.RandomState()
trials = hyperopt.Trials()
domain = hyperopt.Domain(None, search_space_instance,
pass_expr_mem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_suggestions(self, space, old_trials, num_suggestions=10, budget=50):\n new_trials = []\n\n # Use 3 times the dimensionality of the space for training the GP.\n if len(old_trials) < len(space) * 3:\n opt = RandomSearch()\n return opt.get_suggestions(space, old_tria... | [
"0.673707",
"0.66433907",
"0.62491417",
"0.62107706",
"0.6049886",
"0.5957509",
"0.5921522",
"0.5920681",
"0.5868315",
"0.58326787",
"0.5820831",
"0.57852846",
"0.57586384",
"0.5753827",
"0.5749022",
"0.57412815",
"0.56640464",
"0.56435263",
"0.56167614",
"0.56019133",
"0.559... | 0.6908943 | 0 |
This method removes the message received from the list of messages, then routes \n the message to the appropriate function | def process(self, message):
try:
self.messages.remove(message)
except ValueError:
pass # nothing to see here, just a message that was already processed and is not on the list any more
except Exception as e:
print('error removing message from self.message:', e)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_new_line(self, message):\n if message.endswith('\\n'):\n return message[:-1]\n return message",
"def del_old_msg(self, line):\n if not isinstance(line, list):\n raise ValueError\n lines_occupied = sum(line)\n while lines_occupied >= self.h - 2:... | [
"0.6690043",
"0.64363915",
"0.6417138",
"0.6370209",
"0.63638574",
"0.6278583",
"0.614606",
"0.6113393",
"0.61117715",
"0.60682833",
"0.60108536",
"0.60044193",
"0.59817094",
"0.5978349",
"0.59654874",
"0.5923463",
"0.5904784",
"0.58949006",
"0.5865086",
"0.5831896",
"0.58156... | 0.6683044 | 1 |
Opens a new connection to the websocket | def open(self):
try:
self.error_count = 0
self.conn_thread = Thread(target=self.connect, name='Websocket Connection')
self.conn_thread.start()
except Exception as e:
self.conn_thread.join()
self.on_error(self.ws, "Error from openning connection... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def connect(self, url: str):\n logger.info(\"Opening connection to {}\".format(url))\n self.websocket = await WSClient.connect(url)\n logger.info(\"Connected to gateway!\")\n self._open = True\n return self.websocket",
"async def _open_market_data_websocket(self):\n ... | [
"0.7578339",
"0.7381387",
"0.73584044",
"0.727567",
"0.7079712",
"0.6967358",
"0.69503075",
"0.6941937",
"0.69125676",
"0.6901161",
"0.68965214",
"0.6851598",
"0.68342113",
"0.68273735",
"0.6776803",
"0.6750949",
"0.6748201",
"0.6728414",
"0.67280823",
"0.6713812",
"0.6681543... | 0.764353 | 0 |
Receives the level 2 snapshot and the subsequent updates and updates the orderbook | def update(self, message):
try:
if message['type'] == 'l2update':
if self.snapshot_received:
self.l2update(message)
else:
self.backlog += message['changes']
elif message['type'] == 'snapshot':
self.sn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _snapshot(self, msg) -> None:\n\n product_id = msg[\"product_id\"]\n logging.debug(\"Received snapshot for {}\".format(product_id))\n price_precision = \"%.{}f\".format(self.products[product_id])\n\n self.book[product_id] = {}\n\n for book_side in [BOOK_BIDS, BOOK_ASKS]:\n ... | [
"0.6120915",
"0.60521984",
"0.60405105",
"0.5957573",
"0.5957573",
"0.5955088",
"0.59534407",
"0.57923406",
"0.5773802",
"0.574019",
"0.56705797",
"0.56300354",
"0.5538148",
"0.55151826",
"0.5482091",
"0.5431966",
"0.5430278",
"0.54130715",
"0.5404102",
"0.5397799",
"0.538057... | 0.69247013 | 0 |
This is the function to send the robot the new target We publish the information of the the target position of the robot to topic /move_base/goal. Message type is MoveBaseActionGoal | def send_destination(self):
print('send the target to the robot')
move_base_action_goal=MoveBaseActionGoal()
move_base_action_goal.goal.target_pose.header.frame_id="map"
move_base_action_goal.goal.target_pose.pose.orientation.w=1
move_base_action_goal.goal.target_pose.pose.posit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _go_to_goal(self, new_goal):\n\n # Waits until the action server has started up and started\n # listening for goals.\n rospy.loginfo(\"Waiting for move_base to come up . . . \")\n self._MoveBaseClient.wait_for_server()\n rospy.loginfo(\"move_base is UP!\")\n\n # Wait f... | [
"0.7590081",
"0.7262525",
"0.69072",
"0.68744373",
"0.6722525",
"0.66449314",
"0.65029967",
"0.64658207",
"0.6431669",
"0.62456536",
"0.6217606",
"0.61394477",
"0.6081033",
"0.6040425",
"0.601179",
"0.5964906",
"0.5939005",
"0.5862318",
"0.5845824",
"0.5809169",
"0.57735795",... | 0.77526456 | 0 |
Perform maximum a posteriori fit | def fit(args):
config_file = args.setupfn
conf_base = os.path.basename(config_file).split('.')[0]
print("Performing maximum a posteriori fitting for {}".format(conf_base))
P, post = radvel.utils.initialize_posterior(config_file, decorr=args.decorr)
post = radvel.fitting.maxlike_fitting(post, verb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maxfit(self, *args, **kwargs):\n return _image.image_maxfit(self, *args, **kwargs)",
"def predict_max(self, x):\n y_ = self.predict(x)\n amax = torch.argmax(y_, dim=1).detach()\n t = torch.zeros_like(y_)\n t[torch.arange(y_.shape[0]),amax] = 1\n return t",
"def pos... | [
"0.6777389",
"0.62072074",
"0.6111423",
"0.5956245",
"0.592218",
"0.5921827",
"0.59028506",
"0.58424306",
"0.5815447",
"0.5815447",
"0.5815447",
"0.57727796",
"0.57099736",
"0.56954104",
"0.5691916",
"0.56553304",
"0.5617285",
"0.559461",
"0.55689347",
"0.5566601",
"0.5557688... | 0.71464545 | 0 |
De manier van levering en aanplanting van het wortelgestel van de boom of plant. | def wortelAanplant(self):
return self._wortelAanplant.get_waarde() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mezclar_bolsa(self):",
"def standings():\n pass",
"def plant(self):\n\t\ttic=time.clock()\n\t\tcommands=[]\n\t\tt=self.m.times\n\t\tauto=self.m.automatic\n\t\tpHeads=self.plantHeads\n\t\t#gather information about the soil at site\n\t\tdeepest=0\n\t\tdeepestPos=None\n\t\tfor h in pHeads:\n\t\t\tdepth=sel... | [
"0.6290834",
"0.6014581",
"0.59381443",
"0.5893181",
"0.5864082",
"0.5799145",
"0.5793714",
"0.5658449",
"0.5597196",
"0.55904484",
"0.5589598",
"0.5574663",
"0.556646",
"0.55553424",
"0.5544154",
"0.5526583",
"0.5516136",
"0.5506473",
"0.5501297",
"0.5497164",
"0.54813373",
... | 0.6271675 | 1 |
parsing the html node for template definitions | def parse_html_template_node(htmlNode):
from BeautifulSoup import NavigableString
node = HtmlTemplateDefinition()
node.tag = htmlNode.name
for name, value in htmlNode.attrs:
if name != "define":
node.attrs[name] = value
else:
node.defines = value
for subnode... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_starting_template(checker):\n contents = labeled.contents(label=\"template\")\n _ = tomllib.loads(contents)",
"def parse_template(self):\n for line in self.raw_template.split(\"\\n\"):\n line = line.strip()\n if line.startswith('#m3'):\n key, val = line[... | [
"0.6144188",
"0.59667295",
"0.5910988",
"0.58417255",
"0.5832843",
"0.57946736",
"0.5791633",
"0.5513455",
"0.5368274",
"0.5321239",
"0.5256728",
"0.5246223",
"0.52121377",
"0.5194012",
"0.51886094",
"0.51714516",
"0.5155424",
"0.5155424",
"0.5152998",
"0.51181227",
"0.511790... | 0.72280455 | 0 |
Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace. | def compact(number):
return clean(number, ' -').strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compact(number):\n return clean(number, ' -./,').strip()",
"def clean(number):\n digits = [c for c in number if c.isdigit()]\n if len(digits) == 11 and digits[0] == \"1\":\n return ''.join(digits[1:])\n elif len(digits) != 10:\n return \"0000000000\"\n els... | [
"0.7245501",
"0.656221",
"0.64973676",
"0.64160055",
"0.6292922",
"0.6228728",
"0.6026842",
"0.6006934",
"0.5927505",
"0.5873222",
"0.5849065",
"0.5830982",
"0.5821903",
"0.58107376",
"0.58034885",
"0.5800797",
"0.5761181",
"0.5749941",
"0.5686296",
"0.56762457",
"0.5647582",... | 0.70902634 | 1 |
Calculate the checksum. The checksum is only used for the 9 digits of the number and the result can either be 0 or 42. | def checksum(number):
return sum(i * int(n) for i, n in enumerate(reversed(number), 1)) % 11 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __calculate_checksum(cls, number) -> str:\n # TODO in future stages, this function will use the Luhn algorithm to create checksum\n return str(sum(int(num) for num in str(number)) % 10)",
"def calculate_checksum(code):\n\n sum_odd = reduce(sum_chars, code[::2])\n sum_even = reduce... | [
"0.78587705",
"0.7552482",
"0.7338071",
"0.7285181",
"0.72572434",
"0.7091845",
"0.6993215",
"0.6969281",
"0.68769675",
"0.6869387",
"0.686647",
"0.686087",
"0.6852495",
"0.68352187",
"0.6782381",
"0.6770472",
"0.67436624",
"0.67336917",
"0.6673327",
"0.66170275",
"0.66162884... | 0.76590395 | 1 |
Check if the number is valid. This checks the length and check digit. | def validate(number):
number = compact(number)
if not isdigits(number):
raise InvalidFormat()
if len(number) != 10:
raise InvalidLength()
if checksum(number) != 0:
raise InvalidChecksum()
return number | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_number(self):\n digits = self.number\n _sum = 0\n alt = False\n ix = []\n for x in str(digits):\n ix.append(int(x))\n for d in reversed(ix):\n assert 0 <= d <= 9\n if alt:\n d *= 2\n if d > 9:\n ... | [
"0.7818345",
"0.7770616",
"0.76976967",
"0.75029325",
"0.73723716",
"0.73674816",
"0.7297837",
"0.72790253",
"0.7276956",
"0.71201795",
"0.7106368",
"0.7062896",
"0.7016437",
"0.70082414",
"0.69429743",
"0.6932591",
"0.69264835",
"0.68842614",
"0.687007",
"0.6866722",
"0.6857... | 0.78588283 | 0 |
Sample an ordering given scores | def sample(
self,
scores: torch.Tensor
):
perturbed = torch.log(scores) + self.gumbel_noise.sample((len(scores),))
return torch.argsort(-perturbed.detach()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_score_ordered(scores, idx):\t\n\treturn [x[1][idx] for x in sorted(scores.items())]",
"def test_scoring(self):\n scores = score_words(['foo', 'far', 'has', 'car'])\n expected = [(7, 'far'), (6, 'car'), (5, 'has'), (4 , 'foo')]\n self.assertEqual(scores, expected)",
"def eval_ord... | [
"0.61846995",
"0.5977011",
"0.59168404",
"0.5782286",
"0.5709815",
"0.5659634",
"0.56449974",
"0.56339675",
"0.5622803",
"0.55706906",
"0.55613416",
"0.5512437",
"0.5457819",
"0.5451847",
"0.5430736",
"0.542836",
"0.5408105",
"0.54074764",
"0.540372",
"0.5390767",
"0.53904086... | 0.63623494 | 0 |
Compute log probability given scores and an action (a permutation). The formula uses the equivalence of sorting with Gumbel noise and PlackettLuce model (See Yellot 1977) | def log_prob(self, scores : torch.Tensor, permutations):
s = torch.log(select_indices(scores, permutations))
n = len(scores)
p = self.upto if self.upto is not None else n - 1
return -sum(
torch.log(torch.exp((s[k:] - s[k]) * self.shape).sum(dim=0))
for k in range(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_log_probs(self, state):\n dist = self.action_distribution(state)\n raw_action = dist.rsample() # reparametrization trick\n\n # enforcing action bounds\n tanh_action = torch.tanh(raw_action) # prevent recomputation later.\n action = tanh_action * self.action_scale + s... | [
"0.724304",
"0.694372",
"0.68872494",
"0.67296517",
"0.6673799",
"0.6590309",
"0.64809585",
"0.64702743",
"0.645265",
"0.6351982",
"0.6325196",
"0.63182306",
"0.6232857",
"0.6152958",
"0.6137351",
"0.61292297",
"0.6126552",
"0.6091621",
"0.6089503",
"0.6088007",
"0.60647804",... | 0.7008553 | 1 |
Add a view to the collection. | def add_view(self, view):
# Add to views
self._views.append(view)
# If app was provided in constructor, register view with Flask app
if self.app is not None:
self.app.register_blueprint(view.create_blueprint(self))
if view.is_menu:
self._add_view_to_menu(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_view(self, *args, **kwargs):\n return self._resources_manager.add_view(*args, **kwargs)",
"def addView(self, dataView):\n hooks = self.getHooks()\n if hooks is not None:\n dataView.setHooks(hooks)\n self.__views.append(dataView)",
"def _add_view(self, window, view... | [
"0.75795144",
"0.74328953",
"0.716204",
"0.69258523",
"0.6875929",
"0.6744332",
"0.65339804",
"0.6369164",
"0.6368626",
"0.6259857",
"0.6074848",
"0.5948421",
"0.5892814",
"0.5855832",
"0.5814092",
"0.5697377",
"0.56804794",
"0.5673495",
"0.56560206",
"0.5632909",
"0.56310827... | 0.7520189 | 1 |
Add one or more views to the collection. | def add_views(self, *args):
for view in args:
self.add_view(view) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def views(self, views):\n\n self._views = views",
"def add_view(self, *args, **kwargs):\n return self._resources_manager.add_view(*args, **kwargs)",
"def addView(self, dataView):\n hooks = self.getHooks()\n if hooks is not None:\n dataView.setHooks(hooks)\n self.__... | [
"0.7105995",
"0.6818911",
"0.6739592",
"0.65900046",
"0.6586987",
"0.6408147",
"0.6131624",
"0.60490364",
"0.59855074",
"0.5868126",
"0.58605367",
"0.5818668",
"0.57982373",
"0.5793522",
"0.5711679",
"0.5710666",
"0.5690995",
"0.5679969",
"0.5618374",
"0.5610827",
"0.5562094"... | 0.78226066 | 0 |
Add link to menu links collection. | def add_link(self, link):
if link.category:
self._add_menu_item(link, link.category)
else:
self._menu_links.append(link) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_link(self, **kwgs):\n self.links.append(kwgs)",
"def add_link(self, link):\n raise NotImplementedError",
"def add_links(self, *args):\n for link in args:\n self.add_link(link)",
"def links(self, links):\n\n self.container['links'] = links",
"def update_links(s... | [
"0.7691359",
"0.72404385",
"0.70956004",
"0.7082974",
"0.6781136",
"0.67305875",
"0.66682863",
"0.6609667",
"0.6557421",
"0.6507363",
"0.64803123",
"0.6463921",
"0.64266014",
"0.63898194",
"0.63898194",
"0.63898194",
"0.63898194",
"0.63898194",
"0.63898194",
"0.63898194",
"0.... | 0.7950336 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.