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 |
|---|---|---|---|---|---|---|
Calculates embeddings from a given dataframe assume dataframe has title and abstract in the columns | def calculate_embeddings(df, option="lsa", n_papers=MAX_BATCH_SIZE, n_components=30):
assert option in ["lsa", "sent_embed"]
if len(df) < n_components:
print(
"Length of dataframe is less than number of projected components, \
set option to sent_embed instead"
)
o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_embeddings(xdf, cat, emb, w, verbose):\n if verbose:\n print(\"embeddings category: '%s' embeddings shape %s\" % (cat, np.shape(w)))\n if cat not in list(xdf.columns):\n print(\"categorical variable '%s' not found in data-frame\" % cat)\n print(type(xdf), np.shape(xdf), list(xd... | [
"0.60098046",
"0.58753",
"0.5867118",
"0.5841953",
"0.5804004",
"0.57337356",
"0.5729218",
"0.57054985",
"0.5680929",
"0.563684",
"0.5633486",
"0.56218636",
"0.560861",
"0.55656105",
"0.5543683",
"0.55378395",
"0.55248564",
"0.54824895",
"0.5471733",
"0.5426145",
"0.54256785"... | 0.6808147 | 0 |
Uses the unicode of an input kanji to find the corresponding stroke order gif in mistval's collection | def get_gif_uri(kanji):
fileName = kanji.encode("unicode-escape").decode("utf-8").replace("\\u", '') + '.gif'
animationUri = f'https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/{fileName}'
return animationUri | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def singleglyph(x):\n return [glyph(x)]",
"def lcd_string_kana(self, message, line):\n codes = u'線線線線線線線線線線線線線線線線 '\\\n u' !\"#$%&()*+,-./0123456789:;<=>?@ABCDEFG'\\\n u'HIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{'\\\n u'|}→← ... | [
"0.5736218",
"0.55576307",
"0.5534901",
"0.54400593",
"0.53849167",
"0.53792924",
"0.53267854",
"0.53198653",
"0.529424",
"0.526523",
"0.5261577",
"0.52349937",
"0.5214417",
"0.5189843",
"0.5167919",
"0.5137147",
"0.5071565",
"0.5069392",
"0.49859008",
"0.4958913",
"0.4954960... | 0.6089763 | 0 |
Takes a word and returns true if there are hiragana or katakana present within the word | def contains_kana(word):
for k in word:
if k in hiragana or k in katakana or k in small_characters:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_japanese(x):\n pattern = re.compile(r'[\\p{IsHira}\\p{IsKatakana}]', re.UNICODE)\n ret = bool(pattern.search(x))\n return ret",
"def isValid(text):\n\n\n return any(word in text for word in [u\"我好看么\", u\"称赞\"])",
"def is_british_english_term(word: str) -> bool:\n word = process_word(word... | [
"0.6930642",
"0.68723994",
"0.66538167",
"0.6580591",
"0.6552416",
"0.65398663",
"0.64157027",
"0.6405542",
"0.6381708",
"0.6371139",
"0.6359613",
"0.63581526",
"0.6336159",
"0.6310224",
"0.63045526",
"0.6291132",
"0.628089",
"0.6279967",
"0.6273224",
"0.6266891",
"0.625361",... | 0.87406576 | 0 |
Directly use Jisho's official API to get info on a phrase (can be multiple characters) | def search_for_phrase(self, phrase):
uri = uriForPhraseSearch(phrase)
return json.loads(requests.get(uri).content) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def jisho(self, ctx, word: str):\r\n search_args = await self.dict_search_args_parse(ctx, word.lower())\r\n if not search_args:\r\n return\r\n limit, query = search_args\r\n message = urllib.parse.quote(query, encoding='utf-8')\r\n url = \"http://jisho.org/api/v1... | [
"0.6383143",
"0.62670934",
"0.60265064",
"0.5882855",
"0.5850151",
"0.58406603",
"0.5805289",
"0.5768935",
"0.5695436",
"0.5689113",
"0.568847",
"0.5662847",
"0.5660174",
"0.56477916",
"0.5562004",
"0.5547414",
"0.55439466",
"0.55421555",
"0.5507159",
"0.54866064",
"0.5482057... | 0.67336345 | 0 |
With the response, extract the HTML and store it into the object. | def _extract_html(self, url):
self.response = requests.get(url, timeout=5)
self.html = BeautifulSoup(self.response.content, "lxml") if self.response.ok else None
# return self.html | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(self, response: BeautifulSoup):\n raise NotImplementedError",
"def parse(self, response):\n yield{\n 'url': response.url,\n 'title': response.css(\"h1.article-main-title::text\").get(),\n 'sub_title': response.css(\"h2.article-sub-title::text\").get(),\n ... | [
"0.7155325",
"0.6815259",
"0.6661986",
"0.66527045",
"0.65676737",
"0.65462565",
"0.652491",
"0.6482208",
"0.6459295",
"0.64440024",
"0.64043",
"0.6329705",
"0.63162",
"0.63162",
"0.62707376",
"0.6270195",
"0.62326896",
"0.62191874",
"0.62183607",
"0.6180285",
"0.6169138",
... | 0.732518 | 0 |
Take the meanings list from the DOM and clean out noninformative meanings. | def _isolate_meanings(self, meanings_list):
index = self._get_meaning_cutoff_index(meanings_list)
if index:
return [m for i, m in enumerate(meanings_list) if i < index]
else:
return meanings_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_descriptions(descriptions):\n for key, desc_list in descriptions.items():\n for i in range(len(desc_list)):\n desc = desc_list[i]\n # Tokenize.\n desc = desc.split()\n # Convert to lower case.\n desc = [word.lower() for word in desc]\n ... | [
"0.54715055",
"0.5397452",
"0.5360758",
"0.53188324",
"0.5145506",
"0.51151055",
"0.51028174",
"0.5073956",
"0.5072407",
"0.5066381",
"0.5064213",
"0.5051223",
"0.50442636",
"0.5030571",
"0.5029992",
"0.50089633",
"0.5005092",
"0.49978328",
"0.4987968",
"0.4981853",
"0.497821... | 0.5666595 | 0 |
Return the full furigana of a word from the html. | def _get_full_vocabulary_string(self, html):
# The kana represntation of the Jisho entry is contained in this div
text_markup = html.select_one(".concept_light-representation")
upper_furigana = text_markup.select_one(".furigana").find_all('span')
# inset_furigana needs more formatting ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_of_the_day():\n r = requests.get(\"http://www.urbandictionary.com\") # link is always homepage\n soup = BeautifulSoup(r.content, features=\"html.parser\") # sets up soup\n def_header = \"**\" + soup.find(\"div\", attrs={\"class\": \"def-header\"}).text.replace(\"unknown\",\n ... | [
"0.6115667",
"0.5743542",
"0.55236655",
"0.53933805",
"0.5346994",
"0.5319101",
"0.5280804",
"0.5258494",
"0.5191958",
"0.5186769",
"0.5165909",
"0.51648223",
"0.5127701",
"0.5116987",
"0.51016253",
"0.50996876",
"0.50930995",
"0.5036981",
"0.502899",
"0.5027194",
"0.5025558"... | 0.6967511 | 0 |
Prefetch the approvals, so that we don't do a query perprescription on the regional summary page. | def queryset(self, request):
qs = super(PrescriptionAdmin, self).queryset(request)
qs.prefetch_related('approval_set')
return qs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_prefetched_queryset(self, *args, **kwargs):\n return (\n super()\n .get_prefetched_queryset(*args, **kwargs)\n .select_related(\"user\", \"poll\")\n .prefetch_related(\"votes\")\n )",
"def get_prefetched_queryset(self, *args, **kwargs):\n\n ... | [
"0.54367656",
"0.5391246",
"0.5300379",
"0.52060467",
"0.5086948",
"0.50608206",
"0.5014186",
"0.50046194",
"0.4998559",
"0.49390295",
"0.49279544",
"0.49236992",
"0.48870006",
"0.48863047",
"0.48823196",
"0.48582858",
"0.48275545",
"0.4819519",
"0.48050737",
"0.4800241",
"0.... | 0.6178668 | 0 |
Override the redirect url after successful save of an existing burn plan. | def response_post_save_change(self, request, obj):
url = reverse('admin:prescription_prescription_detail',
args=[str(obj.id)])
return HttpResponseRedirect(url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_success_url(self):\n return reverse('warehouse-list')",
"def edit_redirect_url(self):\n return url_for(self.edit_redirect_to_view)",
"def get_success_url(self):\n if self.success_url:\n url = self.success_url % self.object.__dict__\n elif hasattr(self.object,'url'... | [
"0.66047686",
"0.6257987",
"0.6155057",
"0.6155057",
"0.61462444",
"0.61178875",
"0.61144376",
"0.6113364",
"0.60519975",
"0.6047323",
"0.6047323",
"0.6019146",
"0.6019146",
"0.59772176",
"0.5965734",
"0.5944104",
"0.59375286",
"0.591943",
"0.59057283",
"0.58903694",
"0.58812... | 0.6583407 | 1 |
View to manage corporate approval of an ePFP. | def corporate_approve(self, request, object_id, extra_context=None):
obj = self.get_object(request, unquote(object_id))
if request.method == 'POST':
url = reverse('admin:prescription_prescription_detail',
args=[str(obj.id)])
if request.POST.get('_cancel'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def office_edit_process_view(request):\n status = ''\n success = True\n # admin, analytics_admin, partner_organization, political_data_manager, political_data_viewer, verified_volunteer\n authority_required = {'verified_volunteer'}\n if not voter_has_authority(request, authority_required):\n ... | [
"0.60776347",
"0.59112906",
"0.58727604",
"0.57528615",
"0.57168037",
"0.56779003",
"0.5671841",
"0.5618632",
"0.55696684",
"0.55305827",
"0.551526",
"0.55147535",
"0.54409975",
"0.54267627",
"0.5425578",
"0.5413403",
"0.5285814",
"0.5261875",
"0.5244001",
"0.5226627",
"0.521... | 0.66895914 | 0 |
View to manage endorsement of an ePFP. | def endorse(self, request, object_id, extra_context=None):
obj = self.get_object(request, unquote(object_id))
title = "Endorse this ePFP"
if obj.endorsement_status == obj.ENDORSEMENT_DRAFT:
title = "Submit for endorsement"
form = AddEndorsementForm(request.POST or None, req... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enterprise_edit(request):\r\n action = tool.get_param_by_request(request.GET, 'action', \"add\", str)\r\n career_id = tool.get_param_by_request(request.GET, 'careerId', 0, int)\r\n\r\n enterprise = APIResult()\r\n c = None\r\n if action == \"add\":\r\n c = {\"career_id\": career_id, \"act... | [
"0.60825455",
"0.56893605",
"0.5541821",
"0.55269986",
"0.5434012",
"0.54181087",
"0.5341557",
"0.5296141",
"0.52757007",
"0.5231355",
"0.52184767",
"0.5189548",
"0.5168149",
"0.51590496",
"0.5138254",
"0.51100785",
"0.5106903",
"0.5091372",
"0.5052076",
"0.5046529",
"0.50167... | 0.72415787 | 0 |
Find the substring between the first and last chars/strings | def __find_between(self, s, first, last):
try:
start = s.index(first) + len(first)
end = s.index(last, start)
return s[start:end]
except ValueError:
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_string(begin, end, string):\n b = string.find(begin) + len(begin)\n e = string.find(end, b)\n\n return string[b:e]",
"def find_between(s, first, last):\n try:\n start = s.index(first) + len(first)\n end = s.index(last, start)\n return s[start:end]\n except ValueErr... | [
"0.75524485",
"0.7417657",
"0.7238031",
"0.7159151",
"0.7050701",
"0.6868164",
"0.67760736",
"0.66350746",
"0.6626501",
"0.661806",
"0.6558184",
"0.65289724",
"0.6459214",
"0.64507204",
"0.6400073",
"0.63390535",
"0.6337741",
"0.62925154",
"0.6251687",
"0.62035304",
"0.618484... | 0.7477597 | 1 |
Figure out where to redirect after the 'Save' button has been pressed when adding a new object. | def response_post_save_add(self, request, obj):
opts = self.model._meta
if "next" in request.GET:
return HttpResponseRedirect(request.GET['next'])
if self.has_change_permission(request, None):
post_url = reverse('admin:%s_%s_changelist' %
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_add(self, request, obj, post_url_continue='../%s/'):\n opts = obj._meta\n pk_value = obj._get_pk_val()\n\n msg = '\"%s\" was successfully added to the \"%s\" menu.' % (\n force_unicode(obj),\n obj.menu_item.menu\n )\n\n if \"_continue\" in reque... | [
"0.64924026",
"0.6153812",
"0.61309814",
"0.59334826",
"0.591273",
"0.5899871",
"0.56958824",
"0.5689271",
"0.5634287",
"0.55540913",
"0.5533874",
"0.55007654",
"0.55007654",
"0.55007654",
"0.55007654",
"0.55007654",
"0.5483759",
"0.5469536",
"0.5456317",
"0.54537416",
"0.544... | 0.68166924 | 0 |
Save the model and assign delete permissions to particular objects. Also save user to object if an audit object | def save_model(self, request, obj, form, change):
try:
obj.prescription = self.prescription
except AttributeError:
pass
if not obj.pk:
obj.creator = request.user
obj.modifier = request.user
obj.save()
# If can_delete is set, allow the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_model( self, request, obj, form, change ):\n obj.save()",
"def on_model_delete(self, model):\n if not current_user.is_active or not current_user.is_authenticated:\n abort(403)\n if not user_has_permission(current_user, 'can_delete','updates'):\n abort(403)",
... | [
"0.64432746",
"0.6320202",
"0.63064605",
"0.6246145",
"0.62002057",
"0.60748917",
"0.60741484",
"0.6067784",
"0.60301447",
"0.5991352",
"0.5975772",
"0.59583265",
"0.5951502",
"0.5950179",
"0.59379965",
"0.59379965",
"0.59276307",
"0.5916935",
"0.5892021",
"0.58640754",
"0.58... | 0.727388 | 0 |
Fix up the display of the criteria so that it looks a bit nicer. | def criteria_display(self, obj):
return markdownify(obj.criteria) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _print_active_criteria(conv_status, conv_requirements):\n conv_str = f\"\\n\\t {'===> Final Convergence Report <===': ^76}\\n\"\n conv_str += \"\\n\\t\" + \"-\" * 76\n conv_str += f\"\\n\\t|{'Required Criteria': ^24}|{'One or More Criteria': ^24}|{'Alternate Criteria': ^24}|\"\n conv_str += \"\\n\\... | [
"0.6004934",
"0.5642903",
"0.5641137",
"0.56178117",
"0.5541909",
"0.5533003",
"0.55291677",
"0.5502816",
"0.5482058",
"0.54708695",
"0.5310582",
"0.5297918",
"0.52971756",
"0.52587277",
"0.5255082",
"0.5253097",
"0.5229677",
"0.52207726",
"0.5216699",
"0.5201825",
"0.5198934... | 0.730556 | 0 |
At the begining the function reads the layers thickness of a composite material and converts its properties to the property of the isotropic one. Then the properties of the isotropic material are assigned to the tables if necessary. Additionally the function tests the input parameters of the isotropic material on consi... | def updateData( Tables, Graph, LayersInfo, WarningMessage ):
# clean the warning message
LayersInfo.clean()
WarningMessage.clean()
LayerThicknessBuffer = Tables[ "GeometryProperties" ].getValue( 0, 2 )
try:
Layers = getLayersFromString( Tables[ "GeometryProperties" ].getValue( 0, 2 ) )
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_material_info(TABLE_info):\n \"\"\"\n 1 Get info from TABLE_info.\n \"\"\"\n width = TABLE_info[0]\n height = TABLE_info[1]\n t_m = TABLE_info[2]\n\n \"\"\"\n 2 Get material info.\n \"\"\"\n z_m = 3 * t_m\n\n m_width = rs.GetInteger(\"Put the width of material\", z_m, N... | [
"0.6475344",
"0.5682321",
"0.5672466",
"0.5636607",
"0.552437",
"0.5461393",
"0.53857917",
"0.527137",
"0.5246535",
"0.5223118",
"0.5219347",
"0.51697445",
"0.51493186",
"0.5122936",
"0.51042575",
"0.5100329",
"0.50907505",
"0.5060393",
"0.5043993",
"0.504055",
"0.5037686",
... | 0.59535277 | 1 |
The function saves the current state of the tables and calls "cangeMode" function | def updateMode( Tables,
WarningMessage,
Graph,
Properties ):
WarningMessage.clean( )
Graph.setMode( Properties )
#WarningMessage.printMessage( "Click on the Apply button to update grapths..." )
if Properties == 0:
Tables[ "ElasticModulus" ].fillT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alterTableMode(database: str, table: str, mode: str) -> int:\n\n try:\n\n bd = _database(database)\n\n if bd:\n\n tb = _table(database, table)\n\n if tb:\n\n if tb[\"modo\"] == mode or mode not in [\"avl\", \"b\", \"bplus\", \"dict\", \"hash\", \"isam\", \"... | [
"0.60449374",
"0.5693288",
"0.5666721",
"0.563098",
"0.5616466",
"0.5605347",
"0.55648464",
"0.5559937",
"0.5443037",
"0.5381708",
"0.53650904",
"0.5321684",
"0.53107697",
"0.52835166",
"0.52474654",
"0.5224185",
"0.5222314",
"0.51933074",
"0.51613885",
"0.5130906",
"0.512630... | 0.5883549 | 1 |
Returns the metrics from the registry in latest text format as a string. | def generate_latest(registry=Registry):
def sample_line(line, metric_type):
if line.labels:
labelstr = '{{{0}}}'.format(','.join(
['{0}="{1}"'.format(
k, v.replace('\\', r'\\').replace('\n', r'\n').replace('"', r'\"'))
for k, v in sorted(l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def generate_latest_metrics(client):\n resp = await client.get(prometheus.API_ENDPOINT)\n assert resp.status == HTTPStatus.OK\n assert resp.headers[\"content-type\"] == CONTENT_TYPE_TEXT_PLAIN\n body = await resp.text()\n body = body.split(\"\\n\")\n\n assert len(body) > 3\n\n return bod... | [
"0.6561686",
"0.65185255",
"0.64778507",
"0.6407903",
"0.6371694",
"0.6371694",
"0.6159014",
"0.6076035",
"0.59855705",
"0.5963776",
"0.5963161",
"0.58073926",
"0.57971",
"0.57738096",
"0.57541287",
"0.57380533",
"0.57340425",
"0.5730773",
"0.56887656",
"0.5684547",
"0.568445... | 0.65264964 | 1 |
Generates a list of random colours in RGB given a random number generator and the size of this list | def generate_random_colours_list(rng: random.Random, size: int) -> List[TupleInt3]:
return [random_colour(rng) for _ in range(size)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_color_gen():\n r = randint(0, 255)\n g = randint(0, 255)\n b = randint(0, 255)\n return [r, g, b]",
"def _random_color() -> List[float]:\n return [np.random.uniform(), np.random.uniform(), np.random.uniform()]",
"def get_color_list(cluster_count):\n color_list = []\n for i in xr... | [
"0.7871541",
"0.748539",
"0.7485229",
"0.74038225",
"0.72706544",
"0.71166867",
"0.70931363",
"0.7082866",
"0.7052505",
"0.696605",
"0.6933918",
"0.69295365",
"0.6914378",
"0.6914372",
"0.6912016",
"0.6897092",
"0.6876162",
"0.68433",
"0.68433",
"0.68433",
"0.6812373",
"0.6... | 0.8515019 | 0 |
learn novel phrases by looking at cooccurrence of candidate term pairings; docs should be input in tokenized (`tdocs`) and untokenized (`docs`) form | def extract_phrases(tdocs, docs, idf):
# Gather existing keyphrases
keyphrases = set()
for doc in tdocs:
for t in doc:
if len(t.split(' ')) > 1:
keyphrases.add(t)
# Count document co-occurrences
t_counts = defaultdict(int)
pair_docs = defaultdict(list)
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self, documents):\n ###DONE\n\n #entire vocab in document set D\n vocab_sod = set()\n vocab_pop = set()\n \n #Calcuates prior probabilities\n priorSOD = 0 #how many docs are spam\n priorPOP = 0 #how many docs are ham\n \n #Cacluates Tc... | [
"0.6524535",
"0.6303925",
"0.63031244",
"0.6283015",
"0.62118506",
"0.61696297",
"0.6147306",
"0.6121404",
"0.610831",
"0.61022097",
"0.6042071",
"0.6039818",
"0.59821063",
"0.5974946",
"0.5971",
"0.5961817",
"0.58901966",
"0.58670616",
"0.5834076",
"0.58197343",
"0.58094156"... | 0.7074772 | 0 |
returns `top_n` keywords for a list of articles. keywords are returned as (keyword, score) tuples. | def keywords(articles, top_n=25):
# compute term idfs
token_docs = [lemma_tokenize(clean(a.text)) for a in articles]
local_term_idf = IDF(token_docs)
token_docs, phrases = extract_phrases(token_docs, [a.text for a in articles], global_term_idf)
titles = [a.title for a in articles]
title_token... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_keywords(urls, count=10):\n try:\n res = Counter()\n for url in urls:\n res += Counter(get_keyword_dict(url))\n return [w[0] for w in res.most_common(count)]\n except:\n print('Error finding top keywords')",
"def extract_keywords(article_list, n=10):\n vectorizer = TfidfVectorizer()... | [
"0.78360444",
"0.7450141",
"0.6965421",
"0.694177",
"0.6873025",
"0.68340343",
"0.6781121",
"0.6672731",
"0.66101223",
"0.6608954",
"0.659795",
"0.6593758",
"0.6579277",
"0.6569332",
"0.6565945",
"0.65614015",
"0.64829606",
"0.6468362",
"0.64578843",
"0.6425248",
"0.63832724"... | 0.826135 | 0 |
return current thread name. | def get_threadname():
cur_thread = threading.current_thread()
return cur_thread.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_thread_name(self) -> Optional[str]:\n return self.thread_name",
"def get_name(thread_id):\r\n for thread in threading.enumerate():\r\n if thread.ident == thread_id:\r\n return thread.name",
"def get_uname(self):\n return Server.t_usernames.get(threading.ge... | [
"0.80912495",
"0.77005726",
"0.69585633",
"0.6890283",
"0.6844813",
"0.67890924",
"0.674684",
"0.670793",
"0.6689467",
"0.668167",
"0.6630126",
"0.6606617",
"0.6594408",
"0.6587215",
"0.65800315",
"0.65798545",
"0.6551568",
"0.6512428",
"0.6499626",
"0.648431",
"0.6480289",
... | 0.90061885 | 0 |
remove duplicate keys while preserving order. optionally return values. | def find_uniq_preserve_order(orig_keys, orig_values=None):
seen = {}
keys = []
values = []
for i, item in enumerate(orig_keys):
if item in seen:
continue
seen[item] = 1
keys.append(item)
if orig_values:
values.append(orig_values[i])
return keys, values | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_duplicate(x):\n return list(dict.fromkeys(x))",
"def _remove_duplicates(input_list):\n return list(OrderedDict.fromkeys(input_list))",
"def remove_duplicates(input_list):\n return list(dict.fromkeys(input_list))",
"def removeDups(lst):\n\n return list(dict.fromkeys(lst) )",
"... | [
"0.75429296",
"0.72203714",
"0.7036629",
"0.7017405",
"0.6760333",
"0.6731918",
"0.6579014",
"0.65164787",
"0.64843994",
"0.6472747",
"0.6425572",
"0.6410459",
"0.6388204",
"0.6381012",
"0.63454247",
"0.6309064",
"0.62704206",
"0.62684274",
"0.6259605",
"0.61603624",
"0.61588... | 0.775089 | 0 |
resets server figure by deleting lines and clearing legend. | def _handle_reset(self):
stream_data = self.server.stream_data
# remove lines from graph, and reset legends
for name in stream_data:
stream_data[name]['line'].remove()
for name in self.server.axes:
self.server.axes[name].legend([]) # TODO: find a better way.
stream_data = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n\n self.fig.clear()\n self.ax = self.fig.add_subplot(111)\n self.hasLegend.set(False)\n self.title(Graph.default_title)\n # Lines is a list of DataSet objects. The user should take care to make\n # DataSet names unique, as there is no error checking done ... | [
"0.7666481",
"0.72009104",
"0.7048835",
"0.7034993",
"0.6928158",
"0.6892367",
"0.6811622",
"0.6684505",
"0.664847",
"0.6554894",
"0.65438944",
"0.653004",
"0.65285474",
"0.64676446",
"0.6457668",
"0.6457389",
"0.6455251",
"0.6446467",
"0.64300036",
"0.6376522",
"0.63337445",... | 0.7724574 | 0 |
Updates the legend for single_axes, listing duplicate labels once. | def _handle_update_legend(self, single_axes):
# lines are bundled with an axes.
# legends are printed per axes.
# line data is in stream_data without reference to axes sets.
# for each current line, get label, get axes
# for unique axes-labels create a list to pass to legend()
artists, labels = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def legend (self, **kwargs):\n axes = self.twin_axes or self.axes\n self.mpl_legend = axes.legend (self.mpl_lines, self.labels, **kwargs)",
"def legend(self):\n if self.nplots == 1:\n lax = self.ax\n loff = 0.2\n else:\n lax = self.ax1\n lof... | [
"0.663479",
"0.6562808",
"0.6533729",
"0.6064412",
"0.60395277",
"0.60051537",
"0.597655",
"0.597276",
"0.59519356",
"0.5942864",
"0.5882607",
"0.57779515",
"0.57668364",
"0.5744277",
"0.5723438",
"0.5700704",
"0.57001144",
"0.56860155",
"0.5684757",
"0.5676725",
"0.5665561",... | 0.8137135 | 0 |
creates a line on the given axes using style_args. returns line_name | def _handle_create_line(self, axes, style_args):
stream_data = self.server.stream_data
# sample data for initial create
x_data = numpy.arange(0, 2, 1)
y_data = numpy.array([0]*2)
line, = axes.plot(x_data, y_data, '-', **style_args)
# NOTE: client may set 'label'
line_name = style_args['labe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addLineStyle(dist, focus, axis, pupil):\n r = 0 #focus / 2\n g = 0 #np.log10(dist) / (25 / 3)\n b = 0 #axis / 20\n a = 0.4\n rgb = [r, g, b, a]\n line = {'style': '-', 'color': rgb}\n return line",
"def create_line(uniform = True, *args):\n axis = cmds.radioButtonGrp(widgets[\"lineAxi... | [
"0.62994033",
"0.6173251",
"0.61364174",
"0.6051291",
"0.5881077",
"0.58236307",
"0.5810255",
"0.58049214",
"0.5775597",
"0.5750251",
"0.5716448",
"0.57113814",
"0.5684895",
"0.5669201",
"0.5652392",
"0.56158364",
"0.5613863",
"0.55943674",
"0.5562825",
"0.55502826",
"0.55340... | 0.7652667 | 0 |
Add a new axis, if axis_args are not already created. | def _handle_setup_axis(self, axis_args):
axis_name = axis_args['name']
axes_dict = self.server.axes
if axis_name not in [name for name, _ in axes_dict.items()]:
print "Adding a new axis:", axis_name
axis_count = len(axes_dict)
newaxis = self.server.figure.add_subplot(axis_count+1, 1, axis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _appendAxisDefinition(self, axis):\n length = len(axis)\n\n self.na_dict[\"NX\"].append(length)\n self.na_dict[\"XNAME\"].append(xarray_utils.getBestName(axis))\n\n # If only one item in axis values\n if length < 2:\n self.na_dict[\"DX\"].append(0)\n sel... | [
"0.66521394",
"0.6354571",
"0.62128806",
"0.62128806",
"0.62128806",
"0.6071286",
"0.59581596",
"0.58640105",
"0.5820328",
"0.5758695",
"0.56854737",
"0.5659909",
"0.5653431",
"0.56397295",
"0.5619788",
"0.56062645",
"0.5583612",
"0.5512482",
"0.54416555",
"0.54299825",
"0.54... | 0.7232592 | 0 |
create instance data for figure, axes, and stream data. | def setup(self, flags):
self.figure = pylab.figure(1)
self.axes = {}
self.stream_data = {}
self.flags = flags | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_data(self):\n pdf_datasets_all = make_pdf_datasets(self.pdf_list, self.xlims, self.ylims, self.tlims, self.dims, 9)\n self.pdf_dataset = np.concatenate(pdf_datasets_all, axis = 0)\n self.PDE_dataset = make_PDE_dataset(self.num_collocation, self.xlims, self.ylims, self.tlims, self.dim... | [
"0.69154173",
"0.6703749",
"0.6548121",
"0.64630646",
"0.63672024",
"0.63393867",
"0.6333037",
"0.63126576",
"0.63034093",
"0.6290425",
"0.6271378",
"0.626019",
"0.62436026",
"0.6238506",
"0.6222409",
"0.6222409",
"0.6222409",
"0.6222409",
"0.62218726",
"0.6218369",
"0.621429... | 0.67423743 | 1 |
Return the last 5 published polls(Not including those to be published in the future) that have at least 2 choices | def get_queryset(self):
#Old get_queryset() method.
#Return last 5 published polls
#return Poll.objects.order_by('-pub_date')[:5]
#New get_queryset() method.
#return Poll.objects.filter(pub_date__lte=timezone.now()).order_by('-pub_date')[:5]
return Poll.objects.annotate(num_choices=Count('choic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n #return Poll.objects.filter(pub_date__lte=timezone.now())\n return Poll.objects.annotate(num_choices=Count('choice')).filter(pub_date__lte=timezone.now(), num_choices__gte=2)",
"def get_queryset(self):\n #.1 below code was showing future poll/questions\n #.1 return Q... | [
"0.66441554",
"0.6153953",
"0.61504656",
"0.5914476",
"0.59008074",
"0.5822036",
"0.58044267",
"0.56992376",
"0.5674518",
"0.56489867",
"0.56489867",
"0.5606918",
"0.5585309",
"0.55579126",
"0.55579126",
"0.5490999",
"0.5477059",
"0.5477059",
"0.5477059",
"0.5477059",
"0.5477... | 0.64896417 | 1 |
Constructor for decisions having just the low and high value | def __init__(self, low, high):
self.low = low
self.high = high | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, low_score=0, high_score=0):\n self.low_score = low_score\n self.high_score = high_score",
"def __init__(self):\n self.low = []\n self.high = []",
"def __init__(self):\n self.high_low = []",
"def __init__(self, min_val, max_val):\n self.values = (mi... | [
"0.7121283",
"0.6842653",
"0.6765476",
"0.66799957",
"0.66799957",
"0.66799957",
"0.66799957",
"0.64936614",
"0.6454951",
"0.6441182",
"0.635217",
"0.6306492",
"0.6245966",
"0.62103117",
"0.61977905",
"0.61973435",
"0.61709034",
"0.6144477",
"0.61384565",
"0.61371243",
"0.610... | 0.7508133 | 0 |
Constructor for model having objectives, constraints and decisions | def __init__(self, objectives, constraints, decisions):
self.objectives = objectives
self.constraints = constraints
self.decisions = decisions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.name = \"Osyczka\"\n objectives = [ob_os_1, ob_os_2]\n constraints = [con_os_1, con_os_2, con_os_3, con_os_4, con_os_5, con_os_6]\n decisions = [Decision(0, 10), Decision(0, 10), Decision(1, 5), Decision(0, 6), Decision(1, 5), Decision(0, 10)]\n Model._... | [
"0.8211604",
"0.783042",
"0.7588628",
"0.71783847",
"0.711893",
"0.71124303",
"0.7095124",
"0.7054429",
"0.67368513",
"0.6669032",
"0.6669032",
"0.6669032",
"0.6669032",
"0.6669032",
"0.66268575",
"0.65448666",
"0.6534245",
"0.6528547",
"0.6521854",
"0.6510179",
"0.64817524",... | 0.8309128 | 0 |
Evaluates the score for a given solution using all objectives | def evaluate(self, solution, total = 0):
for objective in self.objectives:
total = total + objective(solution)
return total | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_score(self, solution: np.array) -> float:\n pass",
"def score_solution(g, s):\n pass",
"def scoreEvaluationFunction(currentGameState):\n return currentGameState.getScore()",
"def scoreEvaluationFunction(currentGameState):\n return currentGameState.getScore()",
"def scoreEvaluationFuncti... | [
"0.6913881",
"0.67433435",
"0.6517173",
"0.6517173",
"0.6517173",
"0.6517173",
"0.6517173",
"0.6517173",
"0.6514553",
"0.65127504",
"0.64637536",
"0.64637536",
"0.64637536",
"0.64637536",
"0.64637536",
"0.64637536",
"0.64637536",
"0.64637536",
"0.64637536",
"0.64637536",
"0.6... | 0.7744005 | 0 |
Validates if given solutions is as per the constraints | def ok(self, solution):
if self.constraints is not None:
for constraint in self.constraints:
if not constraint(solution):
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_constraints ( A, S, complete ) :\n\t\n\tok = True\n\t\n\tfor i in range(len(complete)) :\n\t\tif complete[i] :\n\t\t\tif not (dot(A[i],S) == 0) :\n\t\t\t\tok = False\n\t\t\t\tprint '\\n'\n\t\t\t\tprint '*** warning *** constraint %d not verified' % (i)\n\t\t\t\tvars_inds = (where(abs(A[i]) == 1))[0]\n\t\... | [
"0.7118976",
"0.7054554",
"0.6993789",
"0.6782743",
"0.66744995",
"0.6646843",
"0.6623786",
"0.66098017",
"0.65714705",
"0.6541072",
"0.6465648",
"0.6465648",
"0.6367656",
"0.6321812",
"0.63074505",
"0.6303715",
"0.62613684",
"0.62440664",
"0.6223591",
"0.62150496",
"0.620849... | 0.7211056 | 0 |
Constructor for Osyczka2 model | def __init__(self):
self.name = "Osyczka"
objectives = [ob_os_1, ob_os_2]
constraints = [con_os_1, con_os_2, con_os_3, con_os_4, con_os_5, con_os_6]
decisions = [Decision(0, 10), Decision(0, 10), Decision(1, 5), Decision(0, 6), Decision(1, 5), Decision(0, 10)]
Model.__init__(self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.name = \"Kursawe\"\n objectives = [o_ku_1, o_ku_2]\n decisions = [Decision(-5, 5), Decision(-5, 5), Decision(-5, 5)]\n Model.__init__(self, objectives, None, decisions)",
"def __init__(self):\n self.name = \"Schaffer\"\n objectives = [o_sh_1, o... | [
"0.73778796",
"0.7025361",
"0.6996897",
"0.6996897",
"0.6996897",
"0.6996897",
"0.6996897",
"0.6893153",
"0.656395",
"0.6520004",
"0.6520004",
"0.6498464",
"0.64387596",
"0.64387596",
"0.64387596",
"0.64387596",
"0.6397256",
"0.6388983",
"0.63875407",
"0.63851994",
"0.6379331... | 0.7899179 | 0 |
Constructor for Schaffer model | def __init__(self):
self.name = "Schaffer"
objectives = [o_sh_1, o_sh_2]
decisions = [Decision(-10 ** 5, 10 ** 5)]
Model.__init__(self, objectives, None, decisions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, model):\n self._model = model",
"def __init__(self, model):\n self.model = model",
"def __init__(self, model):\n self.model = model",
"def __init__(self, model):\n self.model = model",
"def __init__(self, model):\n self.model = model",
"def __init__(s... | [
"0.7268544",
"0.7181175",
"0.7181175",
"0.7181175",
"0.7181175",
"0.7096036",
"0.707674",
"0.70726955",
"0.70252573",
"0.70025045",
"0.6913892",
"0.6901609",
"0.6901609",
"0.68665624",
"0.68252325",
"0.68252325",
"0.68252325",
"0.67947894",
"0.67506754",
"0.67506754",
"0.6750... | 0.74169093 | 0 |
Constructor for Kursawe model | def __init__(self):
self.name = "Kursawe"
objectives = [o_ku_1, o_ku_2]
decisions = [Decision(-5, 5), Decision(-5, 5), Decision(-5, 5)]
Model.__init__(self, objectives, None, decisions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__( self, weights, topics ):\n\n # Number of topics and dictionary size\n self.W, self.K = topics.shape\n assert( self.W > self.K )\n\n self.topics = topics\n MixtureModel.__init__(self, weights, topics)",
"def __init__(self, corpus: Corpus):\n\n # the legomena... | [
"0.6457493",
"0.6087304",
"0.60511214",
"0.5994956",
"0.5893758",
"0.5884114",
"0.5880795",
"0.5876523",
"0.5846621",
"0.58328944",
"0.5819378",
"0.5818917",
"0.5792546",
"0.5777222",
"0.5762234",
"0.57456267",
"0.5744699",
"0.57347846",
"0.5731228",
"0.572777",
"0.5710261",
... | 0.67541903 | 0 |
Add a phone number as a subscriber to the current Topic | def addSubscriber(self, phoneNumber):
if self.topicArn is None:
print 'ERROR: Notification topic not set!'
return
protocol = 'sms'
subscribeResponse = self.snsClient.subscribe(
TopicArn=self.topicArn,
Protocol=protocol,
Endpoint=phoneN... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _registerSubscriber(self, callerId, topic, topicType, callerApi):\n if topic not in self.FilterSubscribedTopics:\n self.__docWriter.addSub(callerId, topic, topicType)",
"def subscribe(self, subscriber):\n self.subscribers.append(subscriber)",
"def subscribe(self, transport, data):\... | [
"0.638156",
"0.6316568",
"0.6203704",
"0.6152549",
"0.61257267",
"0.5983778",
"0.59511983",
"0.59360534",
"0.59137255",
"0.58507955",
"0.5845568",
"0.58303136",
"0.5795692",
"0.5792568",
"0.57643414",
"0.5711302",
"0.57093185",
"0.5682131",
"0.5657824",
"0.5638501",
"0.563821... | 0.76084113 | 0 |
Execute http probe and count metrics | async def exec_probes(self, session: aiohttp.ClientSession,
counter: dict):
self._logger.debug('Start exec probe %s', self.url)
regexp_metrics = [RegexpMetrics(pattern) for pattern in self._patterns]
status_code_metrics = StatusCodeMetrics()
time_metrics = Time... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def poll_health():\n global timesCalled\n\n # Poll /health\n session = requests.Session()\n retry = Retry(connect=3, backoff_factor=0.5)\n adapter = HTTPAdapter(max_retries=retry)\n session.mount('http://', adapter)\n response = session.get(health_url)\n\n # Check HTTP status code\n stat... | [
"0.623642",
"0.5890013",
"0.5889076",
"0.588622",
"0.58364296",
"0.58144206",
"0.5729184",
"0.5712603",
"0.57124424",
"0.56684583",
"0.5641274",
"0.5602359",
"0.5582319",
"0.55592555",
"0.55570114",
"0.55567306",
"0.5549612",
"0.55015385",
"0.54746914",
"0.5471975",
"0.547004... | 0.636973 | 0 |
Method to write the XML file containing the information regarding the stop condition for branching in DET method @ In, filename, string, filename (with absolute path) of the XML file that needs to be printed out @ In, trigger, string, the name of the trigger variable | def writeXmlForDET(filename,trigger,listDict,stopInfo):
# trigger == 'variable trigger'
# Variables == 'variables changed in the branch control logic block'
# associated_pb = 'CDF' in case multibranch needs to be performed
# stopInfo {'end_time': end simulation time (already stopped), 'end_ts': end time s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_gen_xml(self, out_file):\n\n param_list = []\n msg = []\n msg_type = []\n dep_node = []\n for line in self.full_ed_lines:\n param_list.append(line.text())\n dep_pkg = param_list[6].split(', ')\n if dep_pkg[len(dep_pkg) - 1] == '':\n ... | [
"0.5683157",
"0.5659544",
"0.55591834",
"0.55065686",
"0.5498814",
"0.5428093",
"0.54104936",
"0.5392612",
"0.53216076",
"0.5316584",
"0.5289246",
"0.52678",
"0.5199608",
"0.5194961",
"0.51714367",
"0.51580346",
"0.5156104",
"0.5138284",
"0.5084493",
"0.50813687",
"0.5064787"... | 0.79320467 | 0 |
Draw circle for face, sized relative to window size | def drawFace(win, winW, winH):
face = Circle(Point(winW/2, winH/2), min(winW, winH)*11/24)
face.setOutline("black")
face.setFill("burlywood")
face.draw(win) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __drawCircle(self, center, radius, color, drawwidth=1):\n radius *= self.viewZoom\n if radius < 1: radius = 1\n else: radius = int(radius)\n\n pygame.draw.circle(self.screen, color, center, radius, drawwidth)",
"def draw(self, window):\n radius = SQUARE_SIZE // 2 - PADDING\... | [
"0.7119598",
"0.67873436",
"0.67307967",
"0.65992916",
"0.6582572",
"0.65336627",
"0.65306664",
"0.65284276",
"0.6486938",
"0.64669365",
"0.64669365",
"0.6432975",
"0.64328283",
"0.6406504",
"0.6402449",
"0.638859",
"0.63861144",
"0.63558817",
"0.6353007",
"0.63493526",
"0.63... | 0.7234741 | 0 |
Draws eyes for face | def drawEyes(win, winW, winH):
# leftEye = Oval(Point(300-120-40, 300-80-20), Point(300-120+40, 300-80+20))
leftEye = Oval(Point(winW/2-winW/5-winW/15, winH/2-winH/7.5-winH/30),
Point(winW/2-winW/5+winW/15, winH/2-winH/7.5+winH/30))
leftEye.setFill("white")
leftEye.setOutline("black")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_eyes(self):\n GREEN = (0, 255, 0)\n for eye in self.eyes:\n if eye:\n cv2.circle(self.eyes_frame, eye, 8, GREEN, 1)",
"def draw(self, context):\n # TODO: Add this color to Add-on option\n color = (1.0, 1.0, 0.5, 1.0)\n alpha = 2.0 * math.atan(... | [
"0.8009308",
"0.6916443",
"0.63930106",
"0.6312382",
"0.6312382",
"0.6248364",
"0.62259424",
"0.61367136",
"0.61108315",
"0.6107865",
"0.60468125",
"0.60296154",
"0.6011443",
"0.59987676",
"0.59953946",
"0.5938486",
"0.58893174",
"0.5887674",
"0.58734787",
"0.5868707",
"0.585... | 0.7662611 | 1 |
Draws arc for mouth | def drawMouth(win, winW, winH):
drawArc(win, winW/2, winH/2, winH/4, 60, 1.5) # draw mouth | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_arc(self, center_x, center_y, radius, thickness, start_angle, end_angle, edge_shine=False):\n\n if end_angle >= start_angle:\n pass\n else:\n start_angle, end_angle = end_angle, start_angle\n\n rad = radius\n while rad <= radius + thickness:\n a... | [
"0.7010531",
"0.67628413",
"0.6670524",
"0.646824",
"0.644992",
"0.6396002",
"0.63777846",
"0.63353235",
"0.6235798",
"0.6210867",
"0.6182836",
"0.61770433",
"0.6169239",
"0.61444896",
"0.6139231",
"0.61139756",
"0.61103326",
"0.60893536",
"0.60711163",
"0.6058924",
"0.604840... | 0.73307204 | 0 |
Draws arcs for eyebrows | def drawEyebrows(win, winW, winH):
drawArc(win, winW/2-winW/5, winH/2-winH/7.5+winH/10, winH/6, 30, 0.5) # left eyebrow
drawArc(win, winW/2+winW/5, winH/2-winH/7.5+winH/10, winH/6, 30, 0.5) # right eyebrow | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def horizontal_arcs_iglu():\n arc(screen, BLACK, (50, 560, 300, 20), 3.14, 0)\n arc(screen, BLACK, (60, 510, 280, 20), 3.14, 0)\n arc(screen, BLACK, (80, 460, 240, 20), 3.14, 0)\n arc(screen, BLACK, (120, 420, 160, 20), 3.14, 0)",
"def draw_edges():\n\n def bezier(p0, p1, p2, **kwargs):\n ... | [
"0.6601741",
"0.62746024",
"0.5991124",
"0.59876937",
"0.5959159",
"0.591964",
"0.5901125",
"0.58788854",
"0.58297336",
"0.58249354",
"0.58104646",
"0.5792224",
"0.5779965",
"0.5762585",
"0.5755536",
"0.57407904",
"0.5722869",
"0.5716876",
"0.5698326",
"0.5696385",
"0.5671755... | 0.6681989 | 0 |
Draws red nose with reflection spot (polygon) | def drawNose(win, winW, winH):
noseRad = winW/12
nose = Circle(Point(winW/2, winH/2+winH/15), noseRad)
nose.setOutline("red4")
nose.setFill("red")
nose.draw(win)
spot = Polygon(Point(winW/2+noseRad*0.7, winH/2+noseRad*0.6),
Point(winW/2+noseRad*0.7, winH/2+noseRad*0.4),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drawPoles(wn):\n wn.setworldcoordinates(-1, -5, 3, 20)\n t = turtle.Turtle()\n t.speed(0)\n t.pensize(3)\n t.up()\n t.goto(-.5, 0)\n t.down()\n t.goto(2.5, 0)\n t.up()\n for i in range(3):\n t.goto(i, 0)\n t.down()\n t.goto(i, 10)\n t.up()\n t.hidetu... | [
"0.6396361",
"0.63340116",
"0.6125329",
"0.6106198",
"0.60511094",
"0.6015702",
"0.5982887",
"0.5980764",
"0.59279174",
"0.59251344",
"0.5907863",
"0.59069467",
"0.5906906",
"0.58955175",
"0.5889194",
"0.5886915",
"0.58502054",
"0.58475804",
"0.58288246",
"0.58231246",
"0.581... | 0.6485777 | 0 |
Save the saveable objects to a checkpoint with `file_prefix`. | def save(self, file_prefix, options=None):
options = options or checkpoint_options.CheckpointOptions()
tensor_names = []
tensors = []
slice_specs = []
for checkpoint_key, tensor_slices in self._tensor_slice_dict.items():
for slice_spec, tensor in tensor_slices.items():
if isinstance(te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, file_prefix, options=None):\n options = options or checkpoint_options.CheckpointOptions()\n\n # IMPLEMENTATION DETAILS: most clients should skip.\n #\n # Suffix for any well-formed \"checkpoint_prefix\", when sharded.\n # Transformations:\n # * Users pass in \"save_path\" in save()... | [
"0.8050191",
"0.72655725",
"0.70114654",
"0.68767583",
"0.6402732",
"0.63886064",
"0.6338492",
"0.6300955",
"0.6300955",
"0.6300955",
"0.62696517",
"0.6260468",
"0.6259008",
"0.62584656",
"0.6258426",
"0.6252518",
"0.6250101",
"0.62088394",
"0.6168359",
"0.6159923",
"0.613466... | 0.7847717 | 1 |
Restore the saveable objects from a checkpoint with `file_prefix`. | def restore(self, file_prefix, options=None):
options = options or checkpoint_options.CheckpointOptions()
tensor_names = []
tensor_dtypes = []
slice_specs = []
for checkpoint_key, tensor_slices in self._tensor_slice_dict.items():
for slice_spec, tensor in tensor_slices.items():
tensor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore(self, file_prefix, options=None):\n options = options or checkpoint_options.CheckpointOptions()\n\n def restore_fn():\n restore_fn_inputs = {}\n restore_fn_input_count = {\n fn: len(keys) for fn, keys in self._restore_fn_to_keys.items()}\n\n restore_ops = {}\n # Sort ... | [
"0.7489",
"0.7427531",
"0.71940327",
"0.7081849",
"0.7081849",
"0.7081849",
"0.69074863",
"0.6745683",
"0.6576598",
"0.64617085",
"0.6417714",
"0.63264495",
"0.6171721",
"0.61581063",
"0.61405045",
"0.6077467",
"0.6041426",
"0.60319626",
"0.60011774",
"0.59856737",
"0.5977744... | 0.77099335 | 0 |
Append sharding information to a filename. | def sharded_filename(filename_tensor, shard, num_shards):
return gen_io_ops.sharded_filename(filename_tensor, shard, num_shards) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shard_filename(path, tag, shard_num, total_shards):\n return os.path.join(\n path, \"%s-%s-%.5d-of-%.5d\" % (_PREFIX, tag, shard_num, total_shards))",
"def shard_path(self, shard_id, training=True):\n sub_dir = 'train' if training else 'validation'\n fname = 'shard-{}.tfrecord'.format(sha... | [
"0.6643691",
"0.5697363",
"0.56757563",
"0.5666619",
"0.54714036",
"0.5333628",
"0.53004414",
"0.5286781",
"0.5286214",
"0.52476746",
"0.5242944",
"0.5241004",
"0.5194285",
"0.5178036",
"0.5169993",
"0.5164789",
"0.51546425",
"0.51322526",
"0.51283985",
"0.5119813",
"0.509658... | 0.57318276 | 1 |
Save the saveable objects to a checkpoint with `file_prefix`. | def save(self, file_prefix, options=None):
options = options or checkpoint_options.CheckpointOptions()
# IMPLEMENTATION DETAILS: most clients should skip.
#
# Suffix for any well-formed "checkpoint_prefix", when sharded.
# Transformations:
# * Users pass in "save_path" in save() and restore(). ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, file_prefix, options=None):\n options = options or checkpoint_options.CheckpointOptions()\n tensor_names = []\n tensors = []\n slice_specs = []\n for checkpoint_key, tensor_slices in self._tensor_slice_dict.items():\n for slice_spec, tensor in tensor_slices.items():\n if i... | [
"0.78489673",
"0.72668874",
"0.70105153",
"0.6881262",
"0.6406851",
"0.6393002",
"0.6343004",
"0.6299223",
"0.6299223",
"0.6299223",
"0.6275086",
"0.62643564",
"0.6264212",
"0.6264104",
"0.62639993",
"0.6254322",
"0.6253772",
"0.62144583",
"0.61729413",
"0.61586666",
"0.61399... | 0.80512387 | 0 |
Restore the saveable objects from a checkpoint with `file_prefix`. | def restore(self, file_prefix, options=None):
options = options or checkpoint_options.CheckpointOptions()
def restore_fn():
restore_fn_inputs = {}
restore_fn_input_count = {
fn: len(keys) for fn, keys in self._restore_fn_to_keys.items()}
restore_ops = {}
# Sort by device name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore(self, file_prefix, options=None):\n options = options or checkpoint_options.CheckpointOptions()\n tensor_names = []\n tensor_dtypes = []\n slice_specs = []\n\n for checkpoint_key, tensor_slices in self._tensor_slice_dict.items():\n for slice_spec, tensor in tensor_slices.items():\n ... | [
"0.7710502",
"0.7426955",
"0.71934044",
"0.70837396",
"0.70837396",
"0.70837396",
"0.690655",
"0.6745984",
"0.6577562",
"0.646206",
"0.6419114",
"0.63269955",
"0.6172737",
"0.61575806",
"0.6141102",
"0.60786045",
"0.60416305",
"0.60324484",
"0.6001584",
"0.59863573",
"0.59766... | 0.74891186 | 1 |
Main entry point for landing zone command. | def run(config, toml_config, args, parser, subparser):
if not args.landingzone_cmd: # pragma: nocover
return run_nocmd(config, args, parser, subparser)
else:
config = LandingZoneConfig.create(args, config, toml_config)
return args.landingzone_cmd(config, toml_config, args, parser, subpa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main() -> None:\n\n data = Ground(sys.argv[1])\n DeliveryMan.show_route(data.coordinates)",
"def Run(self, args):\n project = properties.VALUES.core.project.Get(required=True)\n zone = {}\n zone['dnsName'] = args.dns_name\n zone['name'] = args.zone\n zone['description'] = args.descriptio... | [
"0.69619477",
"0.6414897",
"0.6252262",
"0.6175504",
"0.59503347",
"0.59487396",
"0.59453166",
"0.5835306",
"0.58340424",
"0.58282",
"0.5816947",
"0.5801014",
"0.5773889",
"0.5770805",
"0.5750875",
"0.5741733",
"0.5728984",
"0.5725193",
"0.5716316",
"0.56993407",
"0.5698184",... | 0.7543086 | 0 |
Override method from djrestauth library to login with username or email | def login(self):
self.user = self.serializer.validated_data['user'] or self.serializer.validated_data['email'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_login(request):\n if \"email\" in request.DATA and \"password\" in request.DATA:\n user = authenticate(\n request,\n username=request.DATA[\"email\"],\n password=request.DATA[\"password\"],\n )\n if user is not None:\n login(request, user... | [
"0.68783975",
"0.66309136",
"0.66066015",
"0.66062045",
"0.6598922",
"0.6579894",
"0.6574915",
"0.6515354",
"0.65140116",
"0.65127194",
"0.65111333",
"0.6499497",
"0.6488138",
"0.646653",
"0.6461104",
"0.64396834",
"0.64242405",
"0.6423767",
"0.6421206",
"0.64155567",
"0.6401... | 0.68613046 | 1 |
Convert numpy array of noisy coefs to dataframe for plotting. | def arr_to_df(coefs_noisy, n_arr, coefs_id):
out = pd.DataFrame(coefs_noisy, columns=n_arr)
out = pd.DataFrame(out.stack()).reset_index()
out.columns = ['component', 'n', 'value']
out = out.assign(id=coefs_id)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_to_df(coefs, n_arr, coefs_id):\n out = pd.DataFrame({'component': 'L2_dist', 'n': n_arr, 'value': coefs,\n 'id': coefs_id})\n return out",
"def as_DF(self):\n\n gs_df = pd.DataFrame(self.P, columns=self.xvec, index=self.yvec)\n gs_df.columns.name = 'x'\n ... | [
"0.5676058",
"0.5650214",
"0.5565525",
"0.55317235",
"0.55146766",
"0.5458486",
"0.5452004",
"0.54493064",
"0.54056114",
"0.539738",
"0.5363231",
"0.5359971",
"0.5354889",
"0.5327784",
"0.5323152",
"0.5283996",
"0.5249769",
"0.52473086",
"0.52459276",
"0.5223076",
"0.52193254... | 0.7141686 | 0 |
Plot risk and fairness gaps. | def plot_metrics(results, epsilon_pos, epsilon_neg):
## Plot risk and fairness gaps as a function of sample size,
## with true minimum risk and true fairness gaps for reference.
metrics_Y0 = pd.concat(results['metrics_Y0_noisy'], keys=n_arr)
metrics_Y0 = metrics_Y0.reset_index().drop(columns='level_1')... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_scenario_distribution(self):\n x = self.arms\n\n y = self.df.groupby('price').mean().Converted[x]\n y_sex_0 = self.df[self.df.Sex == 0].groupby('price').mean().Converted[x]\n y_sex_1 = self.df[self.df.Sex == 1].groupby('price').mean().Converted[x]\n y_age_0 = self.df[sel... | [
"0.62412286",
"0.6003811",
"0.5952074",
"0.59471977",
"0.5879272",
"0.5722639",
"0.55827194",
"0.5509448",
"0.54747474",
"0.54674083",
"0.5467399",
"0.54673696",
"0.54360753",
"0.5435962",
"0.5407168",
"0.540194",
"0.5389398",
"0.53769875",
"0.537178",
"0.53634727",
"0.535109... | 0.6439876 | 0 |
Plot the residuals between measured and predicted values. | def residuals(y_true, y_pred, ax=None):
_check_parameter_validity(y_true, y_pred)
if ax is None:
ax = plt.gca()
# horizontal line for residual=0
ax.axhline(y=0)
ax.scatter(y_pred, y_true - y_pred)
_set_ax_settings(ax, "Predicted Value", "Residuals", "Residuals Plot")
return ax | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _plot_resid_vs_fitted(self, ax):\n\n res = self._model.fit()\n\n ax.plot(res.fittedvalues, res.resid, '.')\n ax.set_xlabel('Fitted ' + self._model.endog_names)\n ax.set_ylabel('Raw residual')\n plt.sca(ax)\n plt.axhline(color='k')",
"def residual_plot(targets, predic... | [
"0.76177293",
"0.74306864",
"0.73046005",
"0.7271648",
"0.71746546",
"0.70974493",
"0.70785415",
"0.7046744",
"0.70070755",
"0.69879323",
"0.68859196",
"0.6638787",
"0.6637704",
"0.65629137",
"0.6533907",
"0.6488404",
"0.64341474",
"0.64010227",
"0.63988537",
"0.63487905",
"0... | 0.7854943 | 0 |
Complete the images table of the database with the relevant values of the directory images. | def complete_images_table(self, table):
# Variable initialization
cmp_double = 0
cmp_img = 0
# Connection to database
conn, cursor = connection_database(self.db_name, self.host, self.user, self.password, self.local, self.ssl_ca)
# Get images paths
image... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_images(image_filename):\n\n # Write code here to loop over image data and populate DB.",
"def show_images(images, db):\n images = [int(image) for image in images]\n files = get_img_files(images, db)\n show_files(files)",
"def add_images(imagefiles, description, tags, users_r, \n ... | [
"0.6612568",
"0.65215194",
"0.6491594",
"0.6421915",
"0.6367421",
"0.62234783",
"0.61760515",
"0.61658376",
"0.6102105",
"0.6085422",
"0.5987134",
"0.59791154",
"0.5875186",
"0.58479464",
"0.5841986",
"0.583527",
"0.5827648",
"0.5797089",
"0.578143",
"0.57734877",
"0.57726663... | 0.77361715 | 0 |
Connects to the SQL server and stores the results of the comparisons in a csv. | def get_duels(self, csv_file, table):
conn, curs = connection_database(self.db_name, self.host, self.user, self.password, self.local, self.ssl_ca)
query = "SELECT * FROM {};".format(table)
curs.execute(query)
result = curs.fetchall()
end_connection(conn, curs)
# W... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sql_to_csv():\n csv_outfile = 'optwrf_database.csv'\n db_conn = conn_to_db('optwrf.db')\n sql_to_csv(csv_outfile, db_conn)\n close_conn_to_db(db_conn)\n assert os.path.exists(csv_outfile) == 1",
"def main():\n #use automationassets to get credentials \n cred = automationassets.get_a... | [
"0.60724294",
"0.5836433",
"0.56998223",
"0.5647265",
"0.55306256",
"0.55271506",
"0.551484",
"0.54908764",
"0.53698635",
"0.5367699",
"0.5367317",
"0.5350177",
"0.53416455",
"0.53352654",
"0.5332152",
"0.53131926",
"0.52831393",
"0.52660966",
"0.52494246",
"0.5238187",
"0.51... | 0.5951407 | 1 |
Commit queries of a connect instance. | def commit_query(conn):
conn.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commitQuery(self):\r\n\t\tself.session.commit()",
"def commit(self):\n self.conn.commit()",
"def commit(self):\n self.__connection.commit()",
"def commit(self):\n self._connection.execute_nonquery(\"sql\", \"COMMIT\", True)",
"def commit(self) -> None:\n self._connector.comm... | [
"0.7059963",
"0.69966274",
"0.6971735",
"0.6961581",
"0.6949486",
"0.6940861",
"0.6940398",
"0.6907652",
"0.6823024",
"0.681941",
"0.67607075",
"0.6757692",
"0.6726335",
"0.6708127",
"0.6663223",
"0.66234124",
"0.6611488",
"0.65827453",
"0.6555924",
"0.65552056",
"0.65522164"... | 0.7103915 | 0 |
nice_name tag returns the username when the full name is not available | def test_nice_name_returns_username(self):
class UserNoName():
username = 'my_username'
def get_full_name(self):
return None
rendered = self.render_nice_name(UserNoName())
self.assertEquals(rendered, 'my_username') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nice_name(self):\n if self.first_name or self.last_name:\n return \"%s %s\" % (self.first_name, self.last_name)\n else:\n key = \"profile.nice_name\"\n cache_key = \"%s.%s.%s\" % (settings.SITE_CACHE_KEY, key, self.pk) \n cached = cache.get(cache_key)\n... | [
"0.75342166",
"0.73341274",
"0.7307055",
"0.7307055",
"0.7300437",
"0.7300437",
"0.72588587",
"0.7255315",
"0.7189447",
"0.7167019",
"0.71295244",
"0.71295244",
"0.71295244",
"0.7097332",
"0.70863456",
"0.70732045",
"0.7000764",
"0.69829106",
"0.69238865",
"0.6918486",
"0.690... | 0.7638717 | 0 |
nice_name tag returns the full name when is available | def test_nice_name_returns_full_namename(self):
class User():
username = 'my_username'
def get_full_name(self):
return 'my_full_name'
rendered = self.render_nice_name(User())
self.assertEquals(rendered, 'my_full_name') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nice_name():\n\n pass",
"def test_nice_name_returns_username(self):\n\n class UserNoName():\n username = 'my_username'\n\n def get_full_name(self):\n return None\n\n rendered = self.render_nice_name(UserNoName())\n\n self.assertEquals(rendered, 'my... | [
"0.7759537",
"0.7210823",
"0.71292967",
"0.7072953",
"0.70387155",
"0.69336873",
"0.688742",
"0.67883503",
"0.6753615",
"0.67322063",
"0.6729379",
"0.67096",
"0.67054737",
"0.6651297",
"0.66264844",
"0.6609411",
"0.6609411",
"0.6609411",
"0.6609411",
"0.6609411",
"0.6609411",... | 0.73069805 | 1 |
Forwards output, extracts Thonny message, replaces normal prompts with raw prompts. This is executed when some code is running or just after requesting raw prompt. After submitting commands to the raw REPL, the output should be like {stdout}\x04\{stderr}\x04\n\> In the end of {stdout} there may be \x02{valueforthonny} ... | def _process_until_raw_prompt(self, capture_output=False):
# TODO: experiment with Ctrl+C, Ctrl+D, reset
eot_count = 0
value = None
done = False
out = b""
err = b""
while not done:
if (self._connection.num_bytes_received == 0
and time.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_prompt(self, timeout=30):\n #self.tc.expect(self.tool_prompt, timeout=timeout)\n #self.tf = self.tc.after.split()\n #return {'status': int(self.tf[self.tool_status_index]), 'output': self.tc.before}\n output = \"\"\n # Loop until we receive the special spt prompt while in... | [
"0.59774065",
"0.59364516",
"0.5923323",
"0.5923323",
"0.5696055",
"0.56759435",
"0.56740737",
"0.562927",
"0.55930865",
"0.5571562",
"0.5549954",
"0.55442077",
"0.55442077",
"0.5541861",
"0.5516136",
"0.55004907",
"0.54771006",
"0.5472862",
"0.54632956",
"0.5442928",
"0.5430... | 0.6925466 | 0 |
given a file of predictions and a file of targets compute evaluation metrics and return dict containing results (including a sum of squared errors so that errors can be added across multiple chromosomes) metrics can be computed on gene/enhancer/promoter subsets by passing lists of bin ids matching these subsets (option... | def evaluate_predictions(unfiltered_preds, unfiltered_targets, gene_bins=None,
enhancer_bins=None, promoter_bins=None, retain_bins=None):
unfiltered_errors = np.square(unfiltered_preds-unfiltered_targets)
if retain_bins is None:
retain_bins = np.arange(unfiltered_errors.shape[0]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eval(\n task1_prediction_filename: str,\n task2_prediction_filename: str,\n target_filename: str,\n output_dir: str,\n case_ids_source: Optional[Union[str, List[str]]] = \"target\",\n) -> Tuple[OrderedDict, str]:\n create_dir(output_dir)\n\n # eval task1, task2 or both\n task1 = task1_p... | [
"0.622663",
"0.6073436",
"0.58134985",
"0.5804928",
"0.5719069",
"0.5711731",
"0.5710975",
"0.568237",
"0.5680572",
"0.5669467",
"0.5663991",
"0.5612322",
"0.5609203",
"0.5606721",
"0.55780536",
"0.5572466",
"0.55717826",
"0.55348396",
"0.54948217",
"0.548214",
"0.5472467",
... | 0.62762123 | 0 |
Assumption is that bins which when sorted lie outside top_bottom_bin_range are outliers and the relevant 'robust' minimum and maximum are percentiles within the top_bottom_bin_range This is a bit lie the scikitlearn robust scaler idea; though not exactly | def find_robust_min_max(x, pct_thresh=0.05, top_bottom_bin_range=2000000):
y = x[x > 0]
idxs = np.argsort(y)
abs_max = y[idxs[-1]]
abs_min = y[idxs[0]]
robust_max = y[idxs[-int(pct_thresh * top_bottom_bin_range)]]
robust_min = y[idxs[int(pct_thresh * top_bottom_bin_range)]]
log.info('Array l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binning(data, low, high):\n if len(data) == 0: return 1\n\n mask1 = (data >= low)\n mask2 = (data < high)\n mask3 = numpy.logical_and(mask1, mask2)\n data = data[mask3]\n\n if len(data) == 0: return 10\n\n data.sort()\n q1 = data[int(math.floor(0.25*len(data)))]\n q3 = data[int(math.... | [
"0.6620887",
"0.6594978",
"0.62357104",
"0.6183821",
"0.61543703",
"0.61226857",
"0.61187845",
"0.6117019",
"0.61008453",
"0.6096406",
"0.6086877",
"0.6066685",
"0.60292286",
"0.6000606",
"0.5948171",
"0.5942545",
"0.59317714",
"0.5907111",
"0.59046483",
"0.58851564",
"0.5880... | 0.7037333 | 0 |
The method used to make sure that the number of starting chips for each player can be set. | def test_set_starting_chips(self):
# Setup new game and attempt to set their valid number of starting chips
valid_chips = [
1,
10,
100,
9999,
]
for chips in valid_chips:
game = Game()
game.setup_new_game()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_partial_deck_has_fewer_cards(self):\n self.assertEqual(len(self.partialDeck.deck), 46)",
"def enough_players():\n return True",
"def set_n_players(self):\n complain = \"\"\n while True:\n clear_output()\n try:\n self.n_players = int(\n ... | [
"0.5986601",
"0.5935184",
"0.591481",
"0.58434373",
"0.57822806",
"0.5757061",
"0.5752133",
"0.5748309",
"0.57169116",
"0.56981397",
"0.56899023",
"0.56770945",
"0.56551063",
"0.56398237",
"0.5611947",
"0.5601338",
"0.55866843",
"0.55602324",
"0.55322117",
"0.5494507",
"0.548... | 0.76785713 | 0 |
The method used to make sure that the names of the players in the game can be set. | def test_set_player_names(self):
# Setup new games and attempt to set their players' names
valid_players = [
["Bob", "Sam", "Cal", "Kris"],
["Player 1", "Player 2", "Player 3", "Player 4", "Player 5"],
["Bot"],
["P1", "P2", "P3"],
]
for pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_names_users(self):\n user_1 = self.view.entry_player_1.get()\n user_2 = self.view.entry_player_2.get()\n if len(user_1) == 0 or len(user_2) == 0:\n\n tk.messagebox.showwarning(\"Warning\", \"Please enter players name\")\n self.logger.warning(\"Please enter players... | [
"0.7112906",
"0.6798745",
"0.67947006",
"0.67672193",
"0.6759732",
"0.66581255",
"0.6556097",
"0.65228826",
"0.64666003",
"0.64418626",
"0.63995534",
"0.63855034",
"0.6371685",
"0.6351709",
"0.63382185",
"0.63223565",
"0.63055414",
"0.62601405",
"0.61606365",
"0.6153325",
"0.... | 0.77651775 | 0 |
Selects two customers that are nearest to each other and their neighbours and removes them from the solution. See ``customers_to_remove`` for the degree of destruction done. Similar to cross route removal in Hornstra et al. (2020). | def cross_route(current: Solution, rnd_state: Generator) -> Solution:
problem = Problem()
destroyed = deepcopy(current)
customers = set(range(problem.num_customers))
removed = SetList()
while len(removed) < customers_to_remove():
candidate = rnd_state.choice(tuple(customers))
rout... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_existing_customers(self):\n # remove the customers which are not active (.is_active )\n self.to_move = False\n #for cust in self.customers:\n # print(cust.state)\n self.customers = [cust for cust in self.customers if cust.state != 'checkout']\n #if cust.t... | [
"0.58851576",
"0.5448354",
"0.5397266",
"0.53144395",
"0.5311116",
"0.5295682",
"0.5100967",
"0.5089005",
"0.50736344",
"0.5059185",
"0.50466216",
"0.5021134",
"0.49826962",
"0.49800837",
"0.49682873",
"0.49234816",
"0.49223632",
"0.49205166",
"0.48926115",
"0.48870838",
"0.4... | 0.653128 | 0 |
Tidies a string `time` into a `date` in `datetime64[D]` format, and records the status of the conversion (`date_status`). | def tidy_time_string(time):
# TODO - :return date_range: Where date_status is "centred", date_range is a tuple (`first_date`, `last_date`) of
# `datetime64[D]` objects. Otherwise will return a tuple of Not a Time objects.
# TODO - warnings/logging
# TODO - change date offsets to rounding using MonthEn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_convert(time):\n try:\n time_data = str(time)\n if time_data:\n try:\n time_data = datetime.strptime(time_data, '%Y%m%d')\n except Exception:\n time_data = datetime.strptime(time_data, '%Y%m%d%H%M%S')\n time_data = time_data.s... | [
"0.67671704",
"0.6561771",
"0.6454839",
"0.6385109",
"0.6359751",
"0.6207002",
"0.61763185",
"0.61540025",
"0.6093099",
"0.6084911",
"0.6053707",
"0.5992525",
"0.5986227",
"0.5974825",
"0.5956986",
"0.59523886",
"0.5942912",
"0.5880063",
"0.58654827",
"0.5819688",
"0.5815174"... | 0.65892553 | 1 |
Test that noun_chunks raises Value Error for 'fr' language if Doc is not parsed. | def test_noun_chunks_is_parsed_fr(fr_tokenizer):
doc = fr_tokenizer("trouver des travaux antérieurs")
with pytest.raises(ValueError):
list(doc.noun_chunks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_noun_chunks_is_parsed(fi_tokenizer):\n doc = fi_tokenizer(\"Tämä on testi\")\n with pytest.raises(ValueError):\n list(doc.noun_chunks)",
"def test_issue401(EN, text, i):\n tokens = EN(text)\n assert tokens[i].lemma_ != \"'\"",
"def test_issue3625():\n nlp = Hindi()\n doc = nlp... | [
"0.81967974",
"0.5773204",
"0.57079947",
"0.55603945",
"0.55467683",
"0.5531417",
"0.5456726",
"0.53696465",
"0.53655165",
"0.53548074",
"0.53134775",
"0.52308595",
"0.5148851",
"0.514678",
"0.5137788",
"0.5127326",
"0.5120156",
"0.51103795",
"0.50573343",
"0.5028861",
"0.502... | 0.846443 | 0 |
Add (multidimensional) samples to buffer. | def push(self, samples):
len_s = len(samples)
if self.idx + len_s < self.len:
self.data[self.idx:self.idx + len_s] = samples
self.idx += len_s
else:
if self.idx == self.len:
self.data[:-len_s] = self.data[len_s:]
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addSamples(self, samples):\n try:\n self.buf = np.append(\n self.buf,\n np.fromstring(\n samples,\n dtype=np.float32))\n self.bufcount += 1\n except:\n pass\n if self.bufcount >= self.numBu... | [
"0.7309586",
"0.68047845",
"0.6730027",
"0.669488",
"0.6684545",
"0.6589268",
"0.64348847",
"0.64089745",
"0.6260624",
"0.62548214",
"0.62530696",
"0.6174509",
"0.6046224",
"0.6001303",
"0.59894323",
"0.5982165",
"0.59481347",
"0.59215266",
"0.5910251",
"0.58930796",
"0.58878... | 0.6881006 | 1 |
Pop a number of samples from buffer. | def pop(self, idx=None):
if not idx:
samples = np.copy(self.data[:self.idx])
self.data[:] = np.empty(self.data.shape)
self.idx = 0
else:
if idx > self.idx:
raise ValueError()
samples = np.copy(self.data[:idx])
data =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _popN(self, n):\n for _ in range(n):\n self._buffer.popleft()",
"def pop(self):\n while self.number > self.maxlength:\n self.buffer.popleft()\n self.number -= 1",
"def pop_memory(self, **kwarg):\n for name, obs in kwarg.items():\n self.buffer... | [
"0.67280066",
"0.6347082",
"0.6287858",
"0.60025215",
"0.59872806",
"0.5924517",
"0.59227526",
"0.58538824",
"0.5841255",
"0.58254236",
"0.58163065",
"0.58092636",
"0.58041793",
"0.5779683",
"0.5754109",
"0.5721759",
"0.568317",
"0.5670812",
"0.5636273",
"0.5605704",
"0.56044... | 0.70006067 | 0 |
Returns the dictionary of genome fasta | def getseq(genomefasta):
genomedict = {}
for i in SeqIO.parse(open(genomefasta), "fasta"):
genomedict[i.id] = str(i.seq)
return genomedict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_fasta_to_dictionary(genome_file):\n filename = genome_file\n dct = {}\n\n id_name = \"\"\n sequence = \"\"\n first_pass = 1\n\n read_fh = open(filename, 'r')\n for i, line in enumerate(read_fh):\n line = line.rstrip()\n if re.search(r'^>(\\S+)(\\s+)(\\S+)(\\s+)(\\S+)(\\s... | [
"0.7508443",
"0.7360985",
"0.71590203",
"0.689614",
"0.6895492",
"0.6875781",
"0.6870282",
"0.6815837",
"0.680902",
"0.67469376",
"0.6740498",
"0.6521526",
"0.64860785",
"0.6435831",
"0.64199185",
"0.64125013",
"0.63991344",
"0.63906515",
"0.6364206",
"0.6346941",
"0.6306387"... | 0.7972919 | 0 |
Program to read a gff and create dictionary of exons from a transcript | def read_gff(gff):
genome = getseq(args.genome)
dictoftranscripts = {}
for k in open(gff):
if not k.startswith("#"):
lines = k.strip().split("\t")
if lines[2] == "exon":
strand = lines[6]
chromosome = lines[0]
start = lines[3]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GFFParse(gff_file):\n genes, utr5, exons=dict(), dict(), dict()\n transcripts, utr3, cds=dict(), dict(), dict()\n # TODO Include growing key words of different non-coding/coding transcripts \n features=['mrna', 'transcript', 'ncrna', 'mirna', 'pseudogenic_transcript', 'rrna', 'snorna', 'snrna', 'tr... | [
"0.75707626",
"0.73930323",
"0.7180306",
"0.6962576",
"0.6809232",
"0.6784794",
"0.67178106",
"0.6689208",
"0.6666986",
"0.6539142",
"0.6533102",
"0.635201",
"0.62793416",
"0.62397146",
"0.6231889",
"0.6221245",
"0.6214062",
"0.61779433",
"0.61518013",
"0.6121378",
"0.6117332... | 0.77669865 | 0 |
Show all or a specific predefined statistic. | def show_predefined_statistics(idx: int = -1) -> None:
if idx < 0:
print(PermutationStatistic._predefined_statistics())
else:
print(PermutationStatistic._STATISTICS[idx][0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showStat(self):\n print \">>[Stat Information]:\"\n if self.gid != DEFALUT_GROUP_ID:\n print \"Gid = %u\" % self.gid\n print \"[Queries] Arp = %u, Original_to_controller= %u, Current_to_controller = %u\" % (self.query_arp, self.query_control_origin, self.query_control_current)\n... | [
"0.6680718",
"0.65894514",
"0.65171486",
"0.65093523",
"0.6490466",
"0.6477537",
"0.64123726",
"0.640252",
"0.6308846",
"0.63020253",
"0.6296237",
"0.62802315",
"0.6250845",
"0.62471896",
"0.6246921",
"0.6233278",
"0.62177813",
"0.6141919",
"0.6141851",
"0.6141851",
"0.610725... | 0.70260644 | 0 |
Check if statistic (self) is preserved in a bijection. | def preserved_in(self, bijection: BijectionType) -> bool:
return all(self.func(k) == self.func(v) for k, v in bijection.items()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invariant(self):\n\t\treturn (self.demand.popId != self.dstPopId)",
"def is_bijective(self):\n return self.is_injective() and self.is_surjective()",
"def check_all_transformed(cls, bijection: BijectionType) -> Dict[str, List[str]]:\n transf = defaultdict(list)\n all_stats = cls._get_al... | [
"0.59036845",
"0.58631575",
"0.5650684",
"0.5457113",
"0.53898907",
"0.5371066",
"0.53598166",
"0.53580296",
"0.52650684",
"0.524763",
"0.52252597",
"0.5104863",
"0.5102853",
"0.5074673",
"0.5071287",
"0.5058628",
"0.5055895",
"0.5042884",
"0.5037415",
"0.5028868",
"0.5026352... | 0.72229594 | 0 |
Return a distribution of statistic for a fixed length of permutations. If a class is not provided, we use the set of all permutations. | def distribution_for_length(
self, n: int, perm_class: Optional[Av] = None
) -> List[int]:
iterator = perm_class.of_length(n) if perm_class else Perm.of_length(n)
cnt = Counter(self.func(p) for p in iterator)
lis = [0] * (max(cnt.keys(), default=0) + 1)
for key, val in cnt.it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sampling_class_portion(data,classes,others=None,class_portion=None,rng=np.random.RandomState(100)):\n u, indices = np.unique(classes,return_inverse=True)\n indices=np.asarray(indices)\n num_u=len(u)\n sample_sizes=dict()\n \n # get sample size of each class\n size_min=float(\"inf\")\n f... | [
"0.61888975",
"0.61321306",
"0.5902894",
"0.5809527",
"0.57847863",
"0.5612866",
"0.55107516",
"0.5496993",
"0.5490976",
"0.54454756",
"0.53975725",
"0.537233",
"0.5363853",
"0.5340827",
"0.5332886",
"0.5306523",
"0.525835",
"0.5203852",
"0.51803553",
"0.51737016",
"0.5172415... | 0.6423975 | 0 |
Return all stats that are equally distributed for two classes up to a max length. | def equally_distributed(cls, class1: Av, class2: Av, n: int = 6) -> Iterator[str]:
return (
stat.name
for stat in cls._get_all()
if all(
stat.distribution_for_length(i, class1)
== stat.distribution_for_length(i, class2)
for i in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jointly_equally_distributed(\n class1: Av, class2: Av, n: int = 6, dim: int = 2\n ) -> Iterator[Tuple[str, ...]]:\n return (\n tuple(stat[0] for stat in stats)\n for stats in combinations(PermutationStatistic._STATISTICS, dim)\n if all(\n Counter... | [
"0.6598037",
"0.6402674",
"0.5585297",
"0.5560338",
"0.55585843",
"0.5543845",
"0.54998505",
"0.5416551",
"0.5411819",
"0.5411735",
"0.5398721",
"0.53787124",
"0.53559506",
"0.53210706",
"0.5216282",
"0.51838976",
"0.5151496",
"0.5138267",
"0.51368135",
"0.5108671",
"0.510867... | 0.7223419 | 0 |
Check if a combination of statistics is equally distributed between two classes up to a max length. | def jointly_equally_distributed(
class1: Av, class2: Av, n: int = 6, dim: int = 2
) -> Iterator[Tuple[str, ...]]:
return (
tuple(stat[0] for stat in stats)
for stats in combinations(PermutationStatistic._STATISTICS, dim)
if all(
Counter(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equally_distributed(cls, class1: Av, class2: Av, n: int = 6) -> Iterator[str]:\n return (\n stat.name\n for stat in cls._get_all()\n if all(\n stat.distribution_for_length(i, class1)\n == stat.distribution_for_length(i, class2)\n ... | [
"0.66576874",
"0.6199647",
"0.59378564",
"0.5789172",
"0.5702513",
"0.56209457",
"0.5614542",
"0.5610369",
"0.56012976",
"0.5587149",
"0.5558948",
"0.5496086",
"0.5490565",
"0.54831845",
"0.54587644",
"0.5453182",
"0.5418705",
"0.5415977",
"0.5410122",
"0.53655595",
"0.535024... | 0.66751057 | 0 |
Get all predefined statistics as an instance of PermutationStatistic. | def _get_all(cls) -> Iterator["PermutationStatistic"]:
yield from (cls(name, func) for name, func in PermutationStatistic._STATISTICS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _predefined_statistics() -> str:\n return \"\\n\".join(\n f\"[{i}] {name}\"\n for i, (name, _) in enumerate(PermutationStatistic._STATISTICS)\n )",
"def mutation_probabilities(self):\n return list(self.mutation_pool.values())",
"def show_predefined_statistics(idx: int... | [
"0.70551056",
"0.6512036",
"0.6451701",
"0.6330738",
"0.62371397",
"0.6094051",
"0.60733724",
"0.59972787",
"0.59330034",
"0.587885",
"0.5836238",
"0.57374936",
"0.56783426",
"0.5667591",
"0.5646153",
"0.55885726",
"0.5553806",
"0.5530332",
"0.55006117",
"0.54704416",
"0.5459... | 0.7527292 | 0 |
Given a bijection, check what statistics transform into others. | def check_all_transformed(cls, bijection: BijectionType) -> Dict[str, List[str]]:
transf = defaultdict(list)
all_stats = cls._get_all()
for stat1, stat2 in product(all_stats, all_stats):
if all(stat1.func(k) == stat2.func(v) for k, v in bijection.items()):
transf[stat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preserved_in(self, bijection: BijectionType) -> bool:\n return all(self.func(k) == self.func(v) for k, v in bijection.items())",
"def analyse(self):\n self.__try_fitting()\n self.second.rotate()\n self.__try_fitting()",
"def test_sufficient_statistics(self):\n assert (\n ... | [
"0.5534995",
"0.4957287",
"0.4899984",
"0.4860593",
"0.4808464",
"0.47695872",
"0.47544986",
"0.47357872",
"0.47212732",
"0.4716885",
"0.46912074",
"0.4689866",
"0.468611",
"0.4674001",
"0.46639493",
"0.46639493",
"0.46639493",
"0.46483684",
"0.46417412",
"0.46233192",
"0.459... | 0.7150287 | 0 |
Yield all symmetric versions of a bijection. | def symmetry_duplication(
bijection: BijectionType,
) -> Iterator[BijectionType]:
return (
bij
for rotated in (
{k.rotate(angle): v.rotate(angle) for k, v in bijection.items()}
for angle in range(4)
)
for bij in (rotated... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symmetric(self):\n result = self.directed()\n result.extend([(down, up) for up, down in result])\n return Pairs(result)",
"def yield_symmetric_images(image):\n for h in (True, False): # horizontal\n for v in (True, False): # vertical\n for d in (True, False): # di... | [
"0.65729105",
"0.59622586",
"0.59610325",
"0.58295286",
"0.56446946",
"0.5581517",
"0.5525889",
"0.5328512",
"0.5313593",
"0.5273254",
"0.526318",
"0.5234545",
"0.5233796",
"0.52252924",
"0.52191466",
"0.51288265",
"0.5095979",
"0.5066039",
"0.50310177",
"0.50216424",
"0.4998... | 0.7548317 | 0 |
Creates a binary model using the configuration above. | def create_model(
input_length, input_depth, num_conv_layers, conv_filter_sizes, conv_stride,
conv_depths, max_pool_size, max_pool_stride, num_fc_layers, fc_sizes,
num_tasks, batch_norm, conv_drop_rate, fc_drop_rate
):
bin_model = binary_models.BinaryPredictor(
input_length=input_length,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_model():\n m = model_class(*argv[2:-1])\n modelobj[\"model\"] = m",
"def create_model():\r\n parser = argparse.ArgumentParser()\r\n parser.add_argument('--DISC_LR', type=float, default=1e-4)\r\n parser.add_argument('--GEN_LR', type=float, default=1e-3)\r\n parser.add_argument('--GEN_BE... | [
"0.6976374",
"0.6738157",
"0.67200863",
"0.67200863",
"0.6598115",
"0.65837914",
"0.65531623",
"0.6531232",
"0.65258634",
"0.65250564",
"0.65024483",
"0.64977425",
"0.6426681",
"0.6377093",
"0.6304412",
"0.6303984",
"0.62989664",
"0.6277534",
"0.62273085",
"0.62052596",
"0.62... | 0.7062543 | 0 |
Gets environment variable as string. | def getenv_string(setting, default=''):
return os.environ.get(setting, default) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_env(key: str) -> str:\n value = os.getenv(key)\n assert isinstance(value, str), (\n f\"the {key} environment variable must be set and a string, \" f\"{value=}\"\n )\n return value",
"def env(var):\n return os.environ[var]",
"def windows_get_env_value(var_name:... | [
"0.81528544",
"0.7418339",
"0.7405049",
"0.72382337",
"0.72329384",
"0.72261554",
"0.7057835",
"0.69984245",
"0.69965094",
"0.69708145",
"0.6922805",
"0.68801343",
"0.68776995",
"0.685753",
"0.68367887",
"0.68226147",
"0.6817827",
"0.6792033",
"0.6738943",
"0.67099005",
"0.66... | 0.7531773 | 1 |
Gets environment variable as boolean value. | def getenv_bool(setting, default=None):
result = os.environ.get(setting, None)
if result is None:
return default
return str2bool(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eval_env_as_boolean(varname, standard_value) -> bool:\n return str(os.getenv(varname, standard_value)).lower() in (\"true\", \"1\", \"t\", \"y\")",
"def env_var_bool(key: str) -> bool:\n return env_var_line(key).upper() in (\"TRUE\", \"ON\", \"YES\")",
"def environ_bool(var, default=False):\n if v... | [
"0.82893",
"0.80127674",
"0.7843964",
"0.783441",
"0.7601062",
"0.75889426",
"0.75562733",
"0.73252225",
"0.7213979",
"0.6979548",
"0.6971869",
"0.68721783",
"0.6818791",
"0.6491351",
"0.6471654",
"0.64534855",
"0.6428621",
"0.6404237",
"0.6373961",
"0.6329838",
"0.6319821",
... | 0.81049186 | 1 |
Handle a change of the target object. This handler will remove the old observer and attach a new observer to the target attribute. If the target object is not an Atom object, an exception will be raised. | def __call__(self, change: ChangeDict) -> None:
old = None
new = None
ctype = change["type"]
if ctype == "create":
new = change["value"]
elif ctype == "update":
old = change["oldvalue"]
new = change["value"]
elif ctype == "delete":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle(self, object, name, old, new):\n raise NotImplementedError",
"def update(self, target):\n self.target = target.detach()",
"def handle_dst(self, object, name, old, new):\n self.next.unregister(old)\n object, name = self.next.register(new)\n if old is not Uninitializ... | [
"0.5505239",
"0.5447666",
"0.5287387",
"0.5242358",
"0.5202192",
"0.5201194",
"0.51845044",
"0.5054616",
"0.5054616",
"0.5051807",
"0.5024639",
"0.5023258",
"0.50199413",
"0.50199413",
"0.50012773",
"0.4991372",
"0.4981381",
"0.4964892",
"0.4939625",
"0.49377948",
"0.4923551"... | 0.5871039 | 0 |
Add or override a member after the class creation. | def add_member(cls: AtomMeta, name: str, member: Member) -> None:
existing = cls.__atom_members__.get(name)
if existing is not None:
member.set_index(member.index)
member.copy_static_observers(member)
else:
member.set_index(len(cls.__atom_members__))
member.set_name(name)
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_member_function(cls, methodName, newMethod):\n cls.add_registration_code('def(\"%s\",%s)'%(methodName, newMethod), True)",
"def add_to_class(cls, name, value):\n if hasattr(value, 'contribute_to_class'):\n value.contribute_to_class(cls, name)\n if not name.startswith('_'):\... | [
"0.60400194",
"0.603651",
"0.5997592",
"0.5895129",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.58183837",
"0.57411194",
"0.56308806",
"0.56049895",
"0.5564861",
"... | 0.6289327 | 0 |
Get the members dictionary for the type. Returns | def members(cls) -> Mapping[str, Member]:
return cls.__atom_members__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_members():",
"def members(self) -> object:\n return self._members",
"def _types(cls):\n return {}",
"def get_members(self):\n return self._members",
"def getMembers(self):\n outProperties = ctypes.c_void_p()\n _res = self.mAPIContext.SDTypeStruct_getMembers(self.m... | [
"0.63952565",
"0.6141157",
"0.61048436",
"0.6043802",
"0.59790736",
"0.59537697",
"0.59458727",
"0.59143937",
"0.59143937",
"0.59143937",
"0.59143937",
"0.588506",
"0.586556",
"0.58518934",
"0.582172",
"0.58169",
"0.5795562",
"0.579131",
"0.579131",
"0.5717494",
"0.5717494",
... | 0.6644524 | 0 |
Set the program details in the GUI. {Boolean} Always returns True. | def __setDetails(self):
self.MainWindow.setWindowTitle("{0} {1}".format(
const.APP_NAME, const.VERSION))
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setProgram(self, program):\n self.program = program",
"def set_program(self, prog):\n self.prog = prog",
"def pr_info(self):\n process = self.backend.get_process(str(self.processBox.currentText()))\n\n if not process:\n return\n\n self.infoWindow2 = QDialog(par... | [
"0.60660547",
"0.59619004",
"0.59247255",
"0.58688223",
"0.5844067",
"0.5796609",
"0.57606316",
"0.57349515",
"0.56842154",
"0.5634517",
"0.5594872",
"0.55846405",
"0.5563236",
"0.55436593",
"0.554133",
"0.55260307",
"0.5519292",
"0.55175734",
"0.5494302",
"0.54732877",
"0.54... | 0.7473526 | 0 |
Delegate len() to the list | def __len__(self):
return len(self.list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return len(self.lst)",
"def __len__(self) -> int:\n return len(self._list)",
"def __len__(self):\n return self._list_size",
"def __len__(self):\n return len(self._list)",
"def __len__(self, *args, **kwargs):\n return len(self._list(*args, **kwargs))",... | [
"0.82745445",
"0.82071984",
"0.803236",
"0.80218816",
"0.7948731",
"0.7840801",
"0.7820482",
"0.7789977",
"0.77131003",
"0.76979923",
"0.7642971",
"0.7616903",
"0.7570917",
"0.75674087",
"0.7518233",
"0.7518233",
"0.7495621",
"0.7467969",
"0.7455057",
"0.7443009",
"0.7443009"... | 0.82164276 | 1 |
Delegate pop() to the list | def pop(self):
self.list.pop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop(self):",
"def pop(self):",
"def pop(self):\r\n return self.list.pop()",
"def pop(self): ##################### <-\n value = self.lst[-1]\n self.lst = self.lst[:-1]\n return value",
"def pop():",
"def pop(self):\n pass",
"def pop(self):\n pass",
"def pop(se... | [
"0.8104019",
"0.8104019",
"0.79311556",
"0.7867167",
"0.7832172",
"0.77851623",
"0.77503335",
"0.77503335",
"0.77467185",
"0.7742908",
"0.77351236",
"0.77227414",
"0.767835",
"0.76257366",
"0.7521559",
"0.74597466",
"0.74431336",
"0.7318125",
"0.7282987",
"0.7224658",
"0.7176... | 0.8389024 | 0 |
If avoid_repeats is False, delegates extend() to the list. Otherwise, appends all items that don't create a repeat of 2 items to the list. | def extend(self, other_list:list, avoid_repeats:bool=False):
if not avoid_repeats:
self.list.extend(other_list)
else:
for item in other_list:
if not self.list or not self.list[-1] == item:
self.list.append(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extend(self, items):\n\t\tfor item in items:\n\t\t\tself.append(item)",
"def extend(self, item: Any) -> BaseList:\n super().extend(item)\n return self",
"def _maybe_repeat(self, x):\n if isinstance(x, list):\n assert len(x) == self.n\n return x\n else:\n ... | [
"0.62498456",
"0.58820844",
"0.57340544",
"0.5694424",
"0.56086457",
"0.5561484",
"0.5498792",
"0.5492445",
"0.54523814",
"0.5431818",
"0.5429031",
"0.5411647",
"0.540451",
"0.5382095",
"0.53687876",
"0.5337805",
"0.53252906",
"0.53235775",
"0.5305681",
"0.52904165",
"0.52875... | 0.7816751 | 0 |
Reverses the portion of the list between start and end indexes, inclusive. | def reverse(self, start:int=0, end:int=None):
if end == None:
if start == 0:
self.list.reverse()
return
end = len(self) - 1
left = start
right = end
while left < right:
self.swap(left, right)
left += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rev_list_in_place(lst):\n\n for i in range(len(lst)//2):\n start = lst[i] #0, 1\n end = lst[-i-1] #-1, -2\n\n lst[i] = end\n lst[-i-1] = start\n return lst",
"def reverse_(data, start, stop):\n if start >= stop:\n return\n else:\n tmp = data[start]\n ... | [
"0.75801146",
"0.7426304",
"0.73637533",
"0.72495973",
"0.69379836",
"0.6891903",
"0.6763126",
"0.6715727",
"0.66684985",
"0.6529971",
"0.65189874",
"0.651104",
"0.6492778",
"0.6492647",
"0.6479766",
"0.6479766",
"0.6469574",
"0.6395415",
"0.6336724",
"0.6288921",
"0.62816465... | 0.8482028 | 0 |
A generator that filters through the tuples under specific conditions that can be specified. | def filter(self, filters:list)->list:
for item in self.list:
use_item = True
for filter in filters:
filter_key, filter_value, filter_type = filter
if filter_type == "<" and item[filter_key] >= filter_value:
use_item = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combination2_with_pruning(items: Sequence[U], condition: Callable[[U, U], bool]) -> Iterator[Tuple[U, U]]:\n for i in range(len(items) - 1):\n item1 = items[i]\n if not condition(item1, item1):\n break\n for j in range(i + 1, len(items)):\n item2 = items[j]\n ... | [
"0.6575245",
"0.6373978",
"0.6246004",
"0.62212527",
"0.6165847",
"0.6111315",
"0.6110025",
"0.60950655",
"0.6079471",
"0.6078307",
"0.6066584",
"0.60238826",
"0.6008566",
"0.59748495",
"0.5969665",
"0.57931423",
"0.5792632",
"0.57537127",
"0.57456875",
"0.57093096",
"0.57049... | 0.64063805 | 1 |
Quicksorts the list by outside_key, then divides the list by stable blocks of outside_key and quicksorts those blocks by inner_key. Essentially equivalent to SQL statement of SORT BY outside_key, inner_key. | def double_sort(self, outside_key:int, inner_key:int, start:int=0, end:int=None, reverse_outside:bool=False, reverse_inside:bool=False):
self.quicksort(outside_key, start, end)
if reverse_outside:
self.reverse(start, end)
self.sub_quicksort(outside_key, inner_key, start, end, reverse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quick_sort(partition_list, low, high):\n if low >= high:\n return\n part_point = get_partition(partition_list, low, high)\n quick_sort(partition_list, low, part_point - 1)\n quick_sort(partition_list, part_point + 1, high)",
"def sub_quicksort(self, stable_key:int, sort_key:int, start:int=... | [
"0.64460015",
"0.6355268",
"0.63343626",
"0.61252177",
"0.61231464",
"0.60208863",
"0.59688854",
"0.59314775",
"0.59294957",
"0.5915863",
"0.58827007",
"0.58791566",
"0.5866802",
"0.58583575",
"0.58298904",
"0.58237565",
"0.5819016",
"0.57973635",
"0.579664",
"0.57711905",
"0... | 0.70455134 | 0 |
Quicksorts subsets of the list grouped by a stable key. Inplace, nonrecursive. This function maintains the order of blocks of tuples having the same stable_key. Within that block, items are resorted by sort_key using quicksort(). Since quicksort() is ascending, specifying reverse = True will reverse the order within th... | def sub_quicksort(self, stable_key:int, sort_key:int, start:int=0, end:bool=None, reverse:bool=False):
if end == None:
end = len(self) - 1
if start >= end:
return
first = start
for index in range(start + 1, end + 1):
if not self[index][stable_key] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quicksort(self, key:int, start:int=0, end:int=None):\n if end == None:\n end = len(self) - 1\n if start >= end:\n return\n if start == end - 1:\n if self[start][key] > self[end][key]:\n self.swap(start, end)\n return\n work ... | [
"0.6481071",
"0.6124734",
"0.61035883",
"0.5960609",
"0.5938006",
"0.59239113",
"0.5895712",
"0.58804065",
"0.58605987",
"0.5831882",
"0.578833",
"0.5766656",
"0.5744841",
"0.5650269",
"0.5648659",
"0.56472456",
"0.56437397",
"0.56407726",
"0.56317866",
"0.56163543",
"0.56089... | 0.7287639 | 0 |
A nonrecursive, inplace version of quicksort. Note that Python has notgreat tailrecursion properties, so a recursive approach is not generally recommended. This is inplace to save on memory. Otherwise, it is a straightforward ascending quicksort of all the items between start and end indexes comparing the values in the... | def quicksort(self, key:int, start:int=0, end:int=None):
if end == None:
end = len(self) - 1
if start >= end:
return
if start == end - 1:
if self[start][key] > self[end][key]:
self.swap(start, end)
return
work = [(start, end... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _quick_sort(l, start, end):\n if start < end:\n split_point = partition(l, start, end)\n\n _quick_sort(l, start, split_point - 1)\n _quick_sort(l, split_point + 1, end)\n\n return l",
"def quick_sort(items, low=None, high=None):\r\n # TODO: Check if high and low range bounds hav... | [
"0.8193505",
"0.77273595",
"0.76876134",
"0.76642364",
"0.76446205",
"0.76436085",
"0.7545366",
"0.7532147",
"0.748278",
"0.7454062",
"0.74537796",
"0.7445257",
"0.7441872",
"0.73965734",
"0.73959565",
"0.7365618",
"0.7348234",
"0.7309217",
"0.72909856",
"0.72894216",
"0.7279... | 0.83892685 | 0 |
Determines if the slope of a line is positive. | def positive_slope(line:tuple)->bool:
return line[0][1] < line[1][1] == line[0][0] < line[1][0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_slope(self):\n\t\tif self.high_elevation != self.low_elevation:\n\t\t\treturn True\n\t\treturn False",
"def slope(self):\n if self.b == 0:\n return None\n else:\n return (-1) * self.a/self.b",
"def filter_slope(self,slope):\n if self.slope_interval[0] <= abs(sl... | [
"0.736785",
"0.67845374",
"0.66309035",
"0.6547908",
"0.64874506",
"0.6483003",
"0.6478444",
"0.63426495",
"0.63259435",
"0.6320206",
"0.62273353",
"0.6205177",
"0.6158633",
"0.613933",
"0.61122525",
"0.6104726",
"0.6096476",
"0.6087337",
"0.6063536",
"0.6063536",
"0.59833056... | 0.83179325 | 0 |
Determines if a line moves up from left to right. | def is_upwards(line:tuple)->bool:
return line[1][1] > line[0][1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _move_up(self) -> bool:\n current_agent_node = self._maze.get_player_node()\n\n if current_agent_node.y == 0:\n # Can't go up. Already on the top row\n return False\n else:\n next_node = self._maze.get_node_up(current_agent_node)\n return self._h... | [
"0.70861965",
"0.6750818",
"0.6675489",
"0.6598131",
"0.65929246",
"0.6382831",
"0.6267976",
"0.6258866",
"0.618461",
"0.6151891",
"0.61254895",
"0.61195827",
"0.60737306",
"0.6071918",
"0.6045149",
"0.60422784",
"0.6026788",
"0.60164386",
"0.60142016",
"0.59950626",
"0.59940... | 0.7699524 | 0 |
Determines if a line is horizontal. | def is_horizontal(line:tuple)->bool:
return line[0][1] == line[1][1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_horizontal(self):\n return self.start.x == self.end.x",
"def _isLine(self):\n return (self.width == 0 and self.height > 1) or (self.height == 0 and self.width > 1)",
"def _isLine(self):\n return (self.width == 0 and self.height > 1) or (self.height == 0 and self.width > 1)",
"def ... | [
"0.7609686",
"0.72768867",
"0.72768867",
"0.6881701",
"0.68597597",
"0.6499938",
"0.6489282",
"0.64614856",
"0.63482904",
"0.63324815",
"0.6304397",
"0.6304397",
"0.61203885",
"0.61043155",
"0.6032632",
"0.6023981",
"0.6008056",
"0.59356326",
"0.5913236",
"0.59085",
"0.590548... | 0.80236757 | 0 |
Determines the length and the cosine of the angle from a positive horizontal ray of a line segment. | def line_length_angle(line:tuple)->tuple:
squared_dist = point_sqr_distance(line[0], line[1])
if squared_dist == 0:
return 0,1
distance = math.sqrt(squared_dist)
angle_cosine = (line[1][0] - line[0][0]) / distance
return squared_dist, angle_cosine | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_angle_slope(line, ax):\n x, y = line.get_data()\n\n sp1 = ax.transData.transform_point((x[0],y[0]))\n sp2 = ax.transData.transform_point((x[-1],y[-1]))\n\n rise = (sp2[1] - sp1[1])\n run = (sp2[0] - sp1[0])\n\n return degrees(atan(rise/run))",
"def get_angle(vert1, vert2):\n ... | [
"0.6568259",
"0.6058625",
"0.6033344",
"0.6004007",
"0.59449476",
"0.5929289",
"0.5880977",
"0.5880165",
"0.5810554",
"0.5711322",
"0.5710918",
"0.57101655",
"0.5706915",
"0.57055837",
"0.5633181",
"0.56073636",
"0.5591553",
"0.55895156",
"0.5588889",
"0.5581489",
"0.557368",... | 0.7148612 | 0 |
Takes a sequential list of vertices and turns it into a list of edges. | def edgify(vertices:list)->list:
edges = []
for k in range(0, len(vertices) - 1):
edges.append([vertices[k], vertices[k + 1]])
return edges | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_edges(graph):\n return list(zip(graph[:-1], graph[1:]))",
"def incoming_edges(self, vertices, labels=True):\n return list(self.incoming_edge_iterator(vertices, labels=labels))",
"def getEdges(self):\n edgeList = []\n for v in self.adjList:\n for i in range(len(self.adj... | [
"0.74463135",
"0.6988424",
"0.6973376",
"0.69115984",
"0.69084823",
"0.6798895",
"0.6756665",
"0.67535317",
"0.67494607",
"0.6699782",
"0.66954184",
"0.66598827",
"0.6621105",
"0.6606147",
"0.65837735",
"0.6566445",
"0.650843",
"0.64819276",
"0.64663",
"0.6394724",
"0.6387192... | 0.83298373 | 0 |
Determines the closest point on the infinite line associated with the edge to the given point. The closest point on an infinite line to a point is determined by the intersection of that line (y=mx+b) and a perpendicular line through the | def closest_line_point(point:tuple, edge:tuple)->tuple:
d_y, d_x, b = line_equation((edge[0], edge[1]))
if b == None:
# The line is vertical, need different intercept formula.
return (edge[0][0], point[1])
if d_y == 0:
# The line is horizontal, we can use a faster formula:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nearest_point_on_line(begin, end, point):\n b2e = _vec_sub(end, begin)\n b2p = _vec_sub(point, begin)\n nom = _vec_dot(b2p, b2e)\n denom = _vec_dot(b2e, b2e)\n if denom == 0.0:\n return begin\n u = nom / denom\n if u <= 0.0:\n return begin\n elif u >= 1.0:\n return... | [
"0.7810633",
"0.7691588",
"0.7173058",
"0.71486485",
"0.7119254",
"0.7044393",
"0.69271195",
"0.69156563",
"0.6865664",
"0.68619066",
"0.6846239",
"0.68359554",
"0.67854995",
"0.67513555",
"0.67275",
"0.6722305",
"0.66625106",
"0.66622204",
"0.6593246",
"0.6526185",
"0.651947... | 0.7811466 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.