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 |
|---|---|---|---|---|---|---|
Given an offset, plaintext, and oracle, forges a block with the proper padding. | def forge_block(offset, plaintext, oracle):
b_size, _, _ = challenge_12.determine_block_stats(oracle)
new_padding = b"A" * (b_size - offset)
payload = new_padding + challenge_09.pkcs7(plaintext, b_size)
ciphertext = oracle(payload)
return challenge_07.as_blocks(ciphertext, b_size)[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forge_padding_block(oracle):\n b_size, pt_size, padding = challenge_12.determine_block_stats(oracle)\n new_padding = b\"A\" * padding\n\n return challenge_07.as_blocks(oracle(new_padding), b_size)[-1]",
"def encrypt(text, offset):\r\n\r\n return format_text(text, offset)",
"def pkcs7_pad(blockl... | [
"0.7168934",
"0.5863658",
"0.5846171",
"0.5747094",
"0.574332",
"0.5658577",
"0.5591082",
"0.5590468",
"0.54089946",
"0.53620017",
"0.53189814",
"0.5233698",
"0.52017486",
"0.517661",
"0.51744473",
"0.512005",
"0.50064063",
"0.49992564",
"0.49891132",
"0.4943387",
"0.489504",... | 0.7434226 | 0 |
Given an oracle, forges a block with all PKCS7 padding (which occurs when the length of a plaintext is an integer multiple of the block size) | def forge_padding_block(oracle):
b_size, pt_size, padding = challenge_12.determine_block_stats(oracle)
new_padding = b"A" * padding
return challenge_07.as_blocks(oracle(new_padding), b_size)[-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forge_block(offset, plaintext, oracle):\n b_size, _, _ = challenge_12.determine_block_stats(oracle)\n new_padding = b\"A\" * (b_size - offset)\n payload = new_padding + challenge_09.pkcs7(plaintext, b_size)\n ciphertext = oracle(payload)\n\n return challenge_07.as_blocks(ciphertext, b_size)[1]",... | [
"0.718337",
"0.7012611",
"0.6525299",
"0.63634807",
"0.6312443",
"0.62574965",
"0.6204864",
"0.61596626",
"0.6152799",
"0.6040315",
"0.5880037",
"0.58678126",
"0.581205",
"0.5769569",
"0.57621455",
"0.57519305",
"0.572222",
"0.5710781",
"0.5623784",
"0.56190366",
"0.5612416",... | 0.7988467 | 0 |
Reads the file from fin and saves the file in wav format in fout | def convert_to_wav(fin, fout):
temp = subprocess.run(["ffmpeg",
"-i",
fin,
fout],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _to_wav(self):\n self._status = 0\n fname = fm.file2wav(self.get_filename()) \n if fname != self.get_filename(): # can change the name\n self._set_filename(fname) # in case of wave transcoding\n self._status = 1",
"def convert_wav(src_wav, dst_wav, subtype='PCM_16'... | [
"0.6910893",
"0.65897757",
"0.6502043",
"0.64688486",
"0.6411844",
"0.63927984",
"0.62594163",
"0.6213807",
"0.61818516",
"0.61807996",
"0.6094217",
"0.6085368",
"0.6054992",
"0.60524696",
"0.603306",
"0.602905",
"0.6027152",
"0.6003981",
"0.59826803",
"0.5968395",
"0.5954145... | 0.73223794 | 0 |
set the message data business_id to a specific value | def step_impl_the_ru_is_set_to(context, business_id):
context.bdd_helper.message_data["business_id"] = business_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def business_id(self, business_id):\n\n self._business_id = business_id",
"def business_phone(self, business_phone):\n\n self._business_phone = business_phone",
"def business_phone_number(self, business_phone_number):\n\n self._business_phone_number = business_phone_number",
"def bus_ob_... | [
"0.7509327",
"0.6467309",
"0.63252246",
"0.6016918",
"0.6016918",
"0.59384924",
"0.58963674",
"0.5866777",
"0.5703364",
"0.5699451",
"0.5621401",
"0.56115365",
"0.55243134",
"0.54495156",
"0.5436615",
"0.5346349",
"0.53436536",
"0.53373826",
"0.5327274",
"0.5308453",
"0.52264... | 0.7794713 | 0 |
Import a submission from deviantArt. Ignores flash content. Uses a combination of the DA backend and HTML scraping. | def import_submission(self, submission: praw.objects.Submission) -> dict:
try:
if self.regex_direct.match(urlsplit(submission.url).netloc):
r = requests.head(submission.url, headers=self.headers)
mime_text = r.headers.get('Content-Type')
mime = mimepar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrape_submission(submission_url):\n\n\t'''\n\tScrape Data\n\t'''\n\n\t# Get submission dict\n\tsubmission_dict = reddit.extract_post_data(submission_url=submission_url)\n\n\t# Get list of comments_dicts\n\tsubmission_object = submission_dict.get('submission_object')\n\tcomments_dict = reddit.extract_post_comm... | [
"0.616191",
"0.610111",
"0.58288443",
"0.5678453",
"0.5619826",
"0.5566439",
"0.53977937",
"0.5396064",
"0.5394963",
"0.53024304",
"0.52641046",
"0.5256734",
"0.52327317",
"0.5211399",
"0.52003515",
"0.5163786",
"0.5095641",
"0.50951064",
"0.5082744",
"0.50585926",
"0.5019451... | 0.6888236 | 0 |
Parse the url of each book from the book list page. The book's title and url will be stored in database. | def parse_books_from_html(html):
root = lxml.html.fromstring(html)
for a in root.cssselect("a"):
if not 'href' in a.attrib:
continue
href = a.attrib['href']
if href.startswith("javascript"):
continue
if not href.startswith("http"):
href = urljo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_books_url(url):\n url_array = []\n nbr_pages = get_nbr_of_pages(url) \n if(nbr_pages == None):\n nbr_pages = 1\n formatted_url = split_url(url)\n formatted_url = formatted_url.split('page')\n for i in range(1, int(nbr_pages) + 1):\n if nbr_pages != 1:\n join_url =... | [
"0.6903227",
"0.64504856",
"0.63376325",
"0.6297125",
"0.6132663",
"0.6110711",
"0.6098223",
"0.607932",
"0.605915",
"0.6037943",
"0.60282815",
"0.5987423",
"0.5987423",
"0.59660596",
"0.5940519",
"0.59073544",
"0.5829715",
"0.58157396",
"0.57694906",
"0.57678217",
"0.571373"... | 0.6719539 | 1 |
Post event to all rulesets | def all_events_request():
result = []
message = json.loads(request.stream.read().decode('utf-8'))
for ruleset_name in host.list_rulesets():
result.append(host.post(ruleset_name, message))
return jsonify(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_events(ruleset_name):\n message = json.loads(request.stream.read().decode('utf-8'))\n result = host.post(ruleset_name, message)\n return jsonify(result)",
"def __call__(self, event):\n post_event(event, self.baseUrl, self.filterName)",
"def _do_rule_processing(self, line, events):\n\n ... | [
"0.5963852",
"0.58948195",
"0.5618622",
"0.55938214",
"0.5427861",
"0.5391614",
"0.53427666",
"0.5329339",
"0.53197384",
"0.531575",
"0.53121924",
"0.530597",
"0.5285532",
"0.52750355",
"0.52552474",
"0.5246069",
"0.5223859",
"0.52142763",
"0.51979613",
"0.51774013",
"0.51750... | 0.59976584 | 0 |
Set ruleset state sid | def set_state_sid_request(ruleset_name, sid):
message = json.loads(request.stream.read().decode('utf-8'))
message['sid'] = sid
result = host.patch_state(ruleset_name, message)
return jsonify(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sid(self, sid):\n self._sid = sid",
"def set_state(self,s):\n self.state = s",
"def set_state(self, state: int):",
"def __setstate__(self, state):\n\n self.set(DER = state)",
"def set_rule(self, rule):\n self.rule.load_state_dict(rule, strict=True)",
"def _set_state(self, ... | [
"0.6317392",
"0.6268615",
"0.62445796",
"0.60649145",
"0.58590347",
"0.5837428",
"0.580806",
"0.58021194",
"0.57980675",
"0.5752198",
"0.5752198",
"0.5744414",
"0.57234263",
"0.5718662",
"0.5679742",
"0.5645187",
"0.5636659",
"0.5628161",
"0.5618529",
"0.5560293",
"0.5513871"... | 0.74748975 | 0 |
Get ruleset state sid | def get_state_sid_request(ruleset_name, sid):
result = host.get_state(ruleset_name, sid)
return jsonify(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_id(self):\n return self._state_id",
"def get_rule_id(self):\n from .osid_errors import IllegalState\n # Someday I'll have a real implementation, but for now I just:\n raise IllegalState()",
"def sid(self):\n return self._sid",
"def sid(self):\n return self.... | [
"0.6522904",
"0.6476181",
"0.6398606",
"0.6354551",
"0.60375524",
"0.60295653",
"0.60295653",
"0.59568083",
"0.5888084",
"0.58808523",
"0.58517295",
"0.58414584",
"0.58183634",
"0.5815065",
"0.57778585",
"0.5670262",
"0.5668822",
"0.56557137",
"0.56524223",
"0.56524223",
"0.5... | 0.6936951 | 0 |
Post events to the ruleset | def post_events(ruleset_name):
message = json.loads(request.stream.read().decode('utf-8'))
result = host.post(ruleset_name, message)
return jsonify(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, event):\n post_event(event, self.baseUrl, self.filterName)",
"def _do_rule_processing(self, line, events):\n\n for rule in self.rules:\n match = rule.regexp.search(line)\n if match:\n events.append(Event(self, rule.handler, LogMatch(line, matc... | [
"0.63994485",
"0.6042524",
"0.6003626",
"0.5981115",
"0.5941807",
"0.5918527",
"0.5845204",
"0.5819378",
"0.58176184",
"0.58072335",
"0.57101154",
"0.5693851",
"0.5638689",
"0.56246656",
"0.55693597",
"0.5526446",
"0.55139947",
"0.54291743",
"0.54178923",
"0.5412167",
"0.5411... | 0.6678471 | 0 |
Post sid events to the ruleset | def post_sid_events(ruleset_name, sid):
message = json.loads(request.stream.read().decode('utf-8'))
message['sid'] = sid
result = host.post(ruleset_name, message)
return jsonify(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_events(ruleset_name):\n message = json.loads(request.stream.read().decode('utf-8'))\n result = host.post(ruleset_name, message)\n return jsonify(result)",
"def set_state_sid_request(ruleset_name, sid):\n message = json.loads(request.stream.read().decode('utf-8'))\n message['sid'] = sid\n ... | [
"0.560759",
"0.5351545",
"0.5286287",
"0.5215918",
"0.50854534",
"0.50759035",
"0.5052492",
"0.5019985",
"0.49917015",
"0.4915208",
"0.4852344",
"0.48465505",
"0.48308286",
"0.47611645",
"0.47459525",
"0.47393727",
"0.47084105",
"0.46966222",
"0.46946904",
"0.46800652",
"0.46... | 0.7941506 | 0 |
This function populates an instance of DeadlineTab with the UI controls that make up the submission dialog. This tab is instantiated by Katana every time the user selects "Tabs > Thinkbox > Submit to Deadline" from the menu bar in Katana. Essentially, this function serves as a deferred __init__ implementation for the t... | def PopulateSubmitter( gui ):
global submissionInfo
print( "Grabbing submitter info..." )
try:
stringSubInfo = CallDeadlineCommand( [ "-prettyJSON", "-GetSubmissionInfo", "Pools", "Groups", "MaxPriority", "UserHomeDir", "RepoDir:submission/Katana/Main", "RepoDir:submission/Integration/Main", ], useD... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populateUI():\n \n # Main form layout\n form = cmds.formLayout()\n\n # Tab Layout\n tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)\n # Form attachment config\n cmds.formLayout( form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'ri... | [
"0.6382394",
"0.5868262",
"0.5825627",
"0.5785208",
"0.5766149",
"0.57174546",
"0.568647",
"0.56794524",
"0.5625228",
"0.5619884",
"0.55831283",
"0.5565874",
"0.5505238",
"0.5494764",
"0.54784214",
"0.5467494",
"0.54137725",
"0.5401807",
"0.5315046",
"0.5295689",
"0.52889675"... | 0.65244144 | 0 |
Augments a staged job info submission file with the appropriate properties for the Pipeline Tool settings. | def ConcatenatePipelineSettingsToJob( jobInfoPath, batchName ):
global submissionInfo
jobWriterPath = os.path.join( submissionInfo["RepoDirs"]["submission/Integration/Main"], "JobWriter.py" )
scenePath = NodegraphAPI.GetSourceFile()
argArray = ["-ExecuteScript", jobWriterPath, "Katana", "--write", "--sc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_job_info(run, seqno, slices):\n inset = {\"job_info\": [\"workscript.stdout\", \"workscript.stderr\"],\n }\n outset = {\"job_info\": [\"std_{0:06d}_{1:03d}.out\", \"std_{0:06d}_{1:03d}.err\"],\n }\n tarset = {\"job_info\": \"job_info_{0:06d}_{1:03d}.tgz\",\n }\n ba... | [
"0.54600435",
"0.5365229",
"0.49939448",
"0.4906341",
"0.48872775",
"0.48601264",
"0.48544395",
"0.48313162",
"0.48072532",
"0.47882256",
"0.4777496",
"0.47465393",
"0.47256604",
"0.46529025",
"0.4646404",
"0.46430737",
"0.46245492",
"0.4616829",
"0.45886663",
"0.4572362",
"0... | 0.61063117 | 0 |
Grabs a status message from the JobWriter that indicates which pipeline tools have settings enabled for the current scene. | def RetrievePipelineToolStatus( raiseOnExitCode=False ):
global submissionInfo
scenePath = NodegraphAPI.GetSourceFile()
jobWriterPath = os.path.join(submissionInfo["RepoDirs"]["submission/Integration/Main"], "JobWriter.py")
argArray = ["-ExecuteScript", jobWriterPath, "Katana", "--status", "--scene-pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tools_state(self):\n\t\treturn Job(SDK.PrlVm_GetToolsState(self.handle)[0])",
"def status(self):\n return STATUSES.get(self._mower_status, {}).get('message', self._mower_status)",
"def get_status(self):\n url = \"data_request?id=jobstatus&job=%d&plugin=zwave\" % self.id\n return se... | [
"0.5826462",
"0.5679577",
"0.56522906",
"0.5546779",
"0.55216604",
"0.5513174",
"0.54827136",
"0.5467698",
"0.5463971",
"0.5463971",
"0.5463971",
"0.5425974",
"0.5425974",
"0.5425974",
"0.5425974",
"0.5425974",
"0.5425974",
"0.5425974",
"0.5425974",
"0.5425974",
"0.5425974",
... | 0.7234952 | 0 |
Modifies the Pipeline Tool status label UI element with the supplied message | def UpdatePipelineToolStatusLabel( gui, statusMessage ):
gui.pipelineToolStatusLabel.setText( statusMessage ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_status(self, msg):\n self.status_lbl.config(text=msg)",
"def status_display(self, message, level=0, field=0):\n #print(message)\n self.statusbar_txt.set(message)",
"def updateStatus(self, message):\r\n self.statusBar().showMessage(message, 5000)\r\n if self.kinfile... | [
"0.79712987",
"0.7420736",
"0.7228758",
"0.7161831",
"0.70710754",
"0.69951653",
"0.6985524",
"0.6982464",
"0.6789776",
"0.6676902",
"0.6615886",
"0.6576708",
"0.6549624",
"0.653623",
"0.6525615",
"0.648638",
"0.6450446",
"0.64447117",
"0.6439653",
"0.6434152",
"0.6397675",
... | 0.8840854 | 0 |
Generic error handling when the a pipeline tools script run via deadline command returns a nonzero exit code. Generates a technical error message for a given subprocess.CalledProcessError instance and displays it in the Katana console. Similarly, a humanreadable error message is presented to the user in a modal dialog.... | def HandlePipelineToolsCalledProcessError( exc ):
errorMsg = StringIO()
errorMsg.write( "Pipeline Tools encountered an error - the command:" )
errorMsg.write( os.linesep * 2 )
errorMsg.write( exc.cmd )
errorMsg.write( os.linesep * 2 )
errorMsg.write( "return a non-zero (%d) exit code" % exc.retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_build_error(error):\n sys.stderr.write('Error running command `%s`. Returned %s.\\n' % (\n ' '.join(error.argv), str(error.error_code)))",
"def print_unable_to_run(exc: \"CalledProcessError\"):\n _print(str(exc), level=MessageLevel.QUIET)",
"def error(text, exitcode=1):\n\n # If we g... | [
"0.5881938",
"0.5847716",
"0.5779613",
"0.5747992",
"0.5723428",
"0.5697356",
"0.56824833",
"0.5620372",
"0.55943125",
"0.5581835",
"0.5550394",
"0.55393744",
"0.5523604",
"0.55169374",
"0.551156",
"0.54878414",
"0.54639775",
"0.54484504",
"0.54443103",
"0.5437845",
"0.542948... | 0.75752896 | 0 |
Opens the a dialog for viewing and modifying the job's pipeline tool settings. The dialog is launched in a deadline command subprocess. All settings are maintained by the JobWriter using a combination of the application name and the scene path. | def OpenIntegrationWindow( raiseOnExitCode=False ):
global submissionInfo
integrationPath = os.path.join( submissionInfo["RepoDirs"]["submission/Integration/Main"], "IntegrationUIStandAlone.py" )
scenePath = NodegraphAPI.GetSourceFile()
if not scenePath:
raise SceneNotSavedError()
argArray ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shotWinUI(*args):\n### ---------- should check for current project\n if cmds.window(\"shotWin\", exists = True):\n cmds.deleteUI(\"shotWin\")\n\n widgets[\"win\"] = cmds.window(\"shotWin\", t= \"Charlex Shot Manager\", w=1000, h=560, s=False)\n widgets[\"mainCLO\"] = cmds.columnLayout(w=1000, h... | [
"0.5803222",
"0.5764439",
"0.5632621",
"0.5579987",
"0.55609196",
"0.5531322",
"0.5498198",
"0.5456681",
"0.5440068",
"0.54032004",
"0.54000485",
"0.5395688",
"0.5395272",
"0.53947246",
"0.5367619",
"0.5364008",
"0.53474754",
"0.5346228",
"0.53405243",
"0.5282741",
"0.5273741... | 0.6004767 | 0 |
Returns the path to DeadlineCommand. | def GetDeadlineCommand( useDeadlineBg=False ):
deadlineBin = ""
try:
deadlineBin = os.environ[ 'DEADLINE_PATH' ]
except KeyError:
# if the error is a key error it means that DEADLINE_PATH is not set. however Deadline command may be in the PATH or on OSX it could be in the file /Users/Shared/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_deadline_command_path():\n\n deadline_bin = os.environ.get('DEADLINE_PATH', '')\n\n # On Linux, the Deadline Client installer creates a system-wide script to set the DEADLINE_PATH environment\n # variable. Cloud-init does not load system environment variables. Cherry-pick the\n ... | [
"0.753901",
"0.6118858",
"0.6027574",
"0.58908194",
"0.5830067",
"0.5762068",
"0.570046",
"0.5663638",
"0.56532186",
"0.56523234",
"0.5645256",
"0.5634848",
"0.56305516",
"0.5628725",
"0.5616503",
"0.5605415",
"0.5578746",
"0.55568534",
"0.55538136",
"0.5526211",
"0.5518902",... | 0.73081684 | 1 |
Creates a utf8 encoded file with each argument in arguments on a separate line. | def CreateArgFile( arguments, tmpDir ):
tmpFile = os.path.join( tmpDir, "args.txt" )
with io.open( tmpFile, 'w', encoding="utf-8-sig" ) as fileHandle:
fileHandle.write( "\n".join( arguments ) )
return tmpFile | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_i18n_data_file(cls, filename, encoding):\n cls.cluster.fs.setuser(cls.cluster.superuser)\n f = cls.cluster.fs.open(filename, \"w\")\n for x in range(256):\n f.write(\"%d\\t%s\\n\" % (x, chr(x).encode(encoding)))\n f.close()",
"def output_file(data, filename):\n with open(filename + ... | [
"0.6052145",
"0.57538974",
"0.567268",
"0.55836433",
"0.55042565",
"0.5475151",
"0.54015994",
"0.5380762",
"0.5356525",
"0.5350646",
"0.5287505",
"0.5250849",
"0.52459705",
"0.5193831",
"0.51840913",
"0.51814663",
"0.5180244",
"0.5170334",
"0.51647687",
"0.5129749",
"0.506740... | 0.7158849 | 0 |
Run DeadlineCommand with the specified arguments returning the standard out | def CallDeadlineCommand(arguments, hideWindow=True, useArgFile=False, useDeadlineBg=False, raiseOnExitCode=False):
deadlineCommand = GetDeadlineCommand( useDeadlineBg )
tmpdir = None
if useArgFile or useDeadlineBg:
tmpdir = tempfile.mkdtemp()
if useDeadlineBg:
arguments = [ "-outputfil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _call_deadline_command_raw(self, arguments):\n # make a copy so we don't mutate the caller's reference\n arguments = list(arguments)\n arguments.insert(0, self._deadline_command_path)\n try:\n proc = subprocess.Popen(\n arguments,\n stdin=sub... | [
"0.6623097",
"0.6296079",
"0.6084702",
"0.5997185",
"0.59120613",
"0.5874816",
"0.57683825",
"0.5742775",
"0.57391727",
"0.5712437",
"0.56482756",
"0.5596094",
"0.558642",
"0.553605",
"0.553605",
"0.5521694",
"0.55093294",
"0.54556483",
"0.5436485",
"0.54264593",
"0.54078025"... | 0.65875596 | 1 |
Get the path to the file where we will store sticky settings | def GetStickySettingsFilePath():
global submissionInfo
deadlineHome = submissionInfo[ "UserHomeDir" ].strip()
return os.path.join( deadlineHome, "settings", "katana_sticky.json" ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def settingsFilePath(self):\n return self._settingsFilePath",
"def get_preference_file():\n\n return \"{}/{}\".format(_MANAGER_PREFERENCE_PATH, _MANAGER_PREFERENCE_FILE)",
"def get_preference_file_cache_destination_path():\n\n return read_preference_key(search_key=\"cache_manager_cache_path\")",
... | [
"0.72601885",
"0.7198174",
"0.69512",
"0.6910759",
"0.69085604",
"0.68241256",
"0.67362624",
"0.6648517",
"0.66195136",
"0.6618425",
"0.6611885",
"0.65249866",
"0.6479099",
"0.64735585",
"0.64711976",
"0.6452971",
"0.638629",
"0.6381435",
"0.63718975",
"0.63349026",
"0.631905... | 0.8301903 | 0 |
Writes the current settings from Submitter UI to the sticky settings file. | def WriteStickySettings( gui ):
global stickySettingWidgets, stickyWidgetSaveFunctions
print( "Writing sticky settings..." )
configFile = GetStickySettingsFilePath()
stickySettings = {}
for setting, widgetName in stickySettingWidgets.iteritems():
try:
widget = getattr( gui, wi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_settings(self):\n logger.info(f'Saving settings: {self.settings_dict}')\n for k, section in self.settings_dict.items():\n for setting_name in section.keys():\n value = self.get_control_value(setting_name)\n if value is not None:\n s... | [
"0.71699524",
"0.7144108",
"0.6855974",
"0.68193734",
"0.66913515",
"0.66821957",
"0.64933175",
"0.64606106",
"0.6453299",
"0.63580054",
"0.63520503",
"0.63510686",
"0.6333627",
"0.6321657",
"0.6306876",
"0.62875223",
"0.6263997",
"0.62562144",
"0.62060374",
"0.61840034",
"0.... | 0.7189759 | 0 |
Reads in settings from the sticky settings file, then update the UI with the new settings | def LoadStickySettings( gui ):
global stickySettingWidgets, stickyWidgetLoadFunctions
configFile = GetStickySettingsFilePath()
print( "Reading sticky settings from: %s" % configFile )
stickySettings = None
try:
with io.open( configFile, "r", encoding="utf-8" ) as fileHandle:
sti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateSettings(self):\n self.parser.read(self.file)\n self.showTicker = self.parser.getboolean('Settings', 'showTicker')\n self.verbose = self.parser.getboolean('Settings', 'verbose')\n self.sleepTime = self.parser.getint('Settings', 'sleeptime')\n self.saveGraph = self.parse... | [
"0.686287",
"0.67737114",
"0.6748555",
"0.6717438",
"0.6571519",
"0.6435366",
"0.63965124",
"0.6376148",
"0.6361373",
"0.62330866",
"0.621005",
"0.62071073",
"0.61983466",
"0.61828625",
"0.61292857",
"0.6116447",
"0.59903854",
"0.5935539",
"0.5932085",
"0.58979905",
"0.584024... | 0.69833964 | 0 |
Converts a url patternesque string into a path, given a context dict, and splits the result. | def pathify(urlpattern, **context):
repl = lambda match: context[match.group(1)]
path = re.sub(r':([a-z]+)', repl, urlpattern)
return tuple(path[1:].split('/')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_string_path(base, path):\n for i in range(len(path)):\n if isinstance(base, string_types):\n return path[:i], path[i:]\n base = base[path[i]]\n return path, ()",
"def resolveContext(self, context):\n if context is None:\n return context\n elif isinstance(contex... | [
"0.59003174",
"0.5704174",
"0.5683664",
"0.5584328",
"0.55201805",
"0.546162",
"0.5402494",
"0.535743",
"0.53368884",
"0.5284471",
"0.5279856",
"0.52473545",
"0.5235247",
"0.52138245",
"0.51656365",
"0.5129309",
"0.5124352",
"0.5093053",
"0.5055723",
"0.5051632",
"0.5041933",... | 0.7681451 | 0 |
init cluster_temp for all the center point | def __initCluster(self):
data_size, cluster_center = self.data_size, self.cluster_center
self.cluster_temp = np.zeros(data_size, dtype=int)
self.cluster_upper_bound = np.full(len(cluster_center), float('inf'), dtype=float)
for center in cluster_center:
self.cluster_temp[cente... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initClusters(self):\n if len(self.labelList) != len(self.pointList):\n \traise ValueError(\"Label List and Point List not the same length!\")\n for i in range(len(self.labelList)):\n self.centroids[self.labelList[i]] = self.pointList[i]\n self.pointcounts[self.labelLi... | [
"0.69504863",
"0.6859036",
"0.67012495",
"0.6668851",
"0.6667392",
"0.6468853",
"0.6415132",
"0.64095896",
"0.63832414",
"0.6361127",
"0.63474107",
"0.6336359",
"0.62062657",
"0.62016225",
"0.61754805",
"0.61420494",
"0.6140045",
"0.6138546",
"0.6138051",
"0.6124449",
"0.6099... | 0.825215 | 0 |
calculate the delta of each vector save the delta point as master | def calculate_delta(self):
rho_des_index, distance, data_size = self.rho_des_index, self.distance, self.data_size
self.result[rho_des_index[0]][1] = -1
for i in range(1, data_size):
for j in range(0, i):
old_i, old_j = rho_des_index[i], rho_des_index[j]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_velocities(self):\n Ddemo_trajs = []\n\n for demo_traj in self._demo_trajs:\n d_traj = np.diff(demo_traj, axis=0)/self._dt\n #append last element to adjust the length\n d_traj = np.hstack([d_traj, d_traj[-1]])\n #add it to the list\n ... | [
"0.65990263",
"0.6551683",
"0.6391416",
"0.6347046",
"0.6311589",
"0.6305406",
"0.6271971",
"0.62243825",
"0.61688155",
"0.6113892",
"0.6110934",
"0.6104737",
"0.6018288",
"0.5975151",
"0.5968072",
"0.592978",
"0.59040904",
"0.584247",
"0.57922715",
"0.57737917",
"0.5765913",... | 0.673058 | 0 |
use the multiplication of normalized rho and delta as gamma to determine cluster center | def calculate_gamma(self):
result = self.result
# scaler = preprocessing.StandardScaler()
# train_minmax = scaler.fit_transform(result)
# st_rho, st_delta = train_minmax[:, 0], train_minmax[:, 1]
# self.gamma = (st_delta + st_rho) / 2
self.gamma = result[:, 0] * result[:,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_cluster_center(self, threshold):\n gamma = self.gamma\n self.cluster_center = np.where(gamma >= threshold)[0]",
"def M_step(X, gamma):\n N = X.shape[0] # number of objects\n C = gamma.shape[1] # number of clusters\n d = X.shape[1] # dimension of each object\n\n ### YOUR CO... | [
"0.6678306",
"0.6379675",
"0.6162399",
"0.59755903",
"0.5975015",
"0.59482974",
"0.59137064",
"0.58591443",
"0.5844926",
"0.5769318",
"0.5760845",
"0.5734815",
"0.5687573",
"0.56765157",
"0.56329596",
"0.56303257",
"0.5629205",
"0.558961",
"0.55850154",
"0.5579336",
"0.557140... | 0.64044535 | 1 |
Intercept a point with gamma greater than 0.2 as the cluster center | def calculate_cluster_center(self, threshold):
gamma = self.gamma
self.cluster_center = np.where(gamma >= threshold)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian(centre, k, intensity, xpos):\r\n\treturn intensity * np.exp(- np.power(k * (xpos - centre), 2))",
"def predict_center(point):\n point_cluster_num = predict_cluster(point)\n center = centers[point_cluster_num]\n return center",
"def center(x):\n return x - x.mean()",
"def gauss_spot(s... | [
"0.6103443",
"0.5330922",
"0.529988",
"0.52296835",
"0.52157253",
"0.5153788",
"0.51438296",
"0.51432735",
"0.5122229",
"0.5116896",
"0.51106155",
"0.509807",
"0.50852835",
"0.50819665",
"0.5080408",
"0.50785637",
"0.50589377",
"0.50488997",
"0.504817",
"0.50294673",
"0.50135... | 0.57451344 | 1 |
Initial configuration. Used to specify your username, password and domain. Configuration is stored in ~/.accountable/config.yaml. | def configure(username, password, domain):
art = r'''
Welcome! __ ___. .__
_____ ____ ____ ____ __ __ _____/ |______ \_ |__ | | ____
\__ \ _/ ___\/ ___\/ _ \| | \/ \ __\__ \ | __ \| | _/ __ \
/ __ \\ \__\ \__( <_> ) | / | \ | / __ \| \_\ \ |_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure(self):\n configurations = config.Configurations()\n self.credentials = configurations.credentials\n self.config = configurations.config",
"def configure(self, conf):\n self.openam_base_url = conf.get('url')\n self.username = conf.get('user')\n self.__passwo... | [
"0.6725636",
"0.65860176",
"0.6572466",
"0.6524407",
"0.6381888",
"0.625799",
"0.62230504",
"0.6196215",
"0.6191912",
"0.61845404",
"0.6112712",
"0.60647243",
"0.6038883",
"0.6033728",
"0.60200953",
"0.60005546",
"0.5989566",
"0.598916",
"0.59883714",
"0.5980305",
"0.5948604"... | 0.6898006 | 0 |
List all issue types. Optional parameter to list issue types by a given project. | def issuetypes(accountable, project_key):
projects = accountable.issue_types(project_key)
headers = sorted(['id', 'name', 'description'])
rows = []
for key, issue_types in sorted(projects.items()):
for issue_type in issue_types:
rows.append(
[key] + [v for k, v in sor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(self, request):\n bug_types = BugType.objects.all()\n\n # Note the additional `many=True` argument to the\n # serializer. It's needed when you are serializing\n # a list of objects instead of a single object.\n serializer = BugTypeSerializer(\n bug_types, many... | [
"0.580682",
"0.57997316",
"0.55276394",
"0.53734636",
"0.53584605",
"0.53383344",
"0.5332019",
"0.5323111",
"0.53199",
"0.52730525",
"0.5229358",
"0.5195646",
"0.51418656",
"0.51354766",
"0.50994647",
"0.5088411",
"0.50732434",
"0.5071402",
"0.50672746",
"0.5037107",
"0.50092... | 0.715429 | 0 |
Lists all comments for a given issue key. | def comments(accountable):
comments = accountable.issue_comments()
headers = sorted(['author_name', 'body', 'updated'])
if comments:
rows = [[v for k, v in sorted(c.items()) if k in headers]
for c in comments]
rows.insert(0, headers)
print_table(SingleTable(rows))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_comments(self, issue_id):\n data = self._get(\"/issues/{}/comments\".format(issue_id))\n comments = []\n for item in data:\n comments.append(\n Comment(item['user']['login'], item['body'])\n )\n return comments",
"def problem_comments(self... | [
"0.6735813",
"0.63723326",
"0.6294947",
"0.62622994",
"0.61518073",
"0.6067908",
"0.5866216",
"0.5846625",
"0.5813753",
"0.58126175",
"0.5763556",
"0.5763556",
"0.56536496",
"0.5609131",
"0.55674785",
"0.55547565",
"0.55169636",
"0.54941475",
"0.547762",
"0.5461454",
"0.54559... | 0.68489426 | 0 |
Add a comment to the given issue key. Accepts a body argument to be used as the comment's body. | def addcomment(accountable, body):
r = accountable.issue_add_comment(body)
headers = sorted(['author_name', 'body', 'updated'])
rows = [[v for k, v in sorted(r.items()) if k in headers]]
rows.insert(0, headers)
print_table(SingleTable(rows)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_comment_to_issue(repo, issue_number, body, allow_duplicates):\n found = False\n issue = repo.issue(issue_number)\n\n if not allow_duplicates:\n for comment in issue.iter_comments():\n if comment.body == body:\n found = True\n break\n\n if allow_du... | [
"0.682299",
"0.6740081",
"0.6561953",
"0.6297364",
"0.6274821",
"0.6229835",
"0.61394274",
"0.5977267",
"0.5953699",
"0.5946078",
"0.58701116",
"0.5741862",
"0.57191175",
"0.56251615",
"0.56233865",
"0.5619574",
"0.5502269",
"0.5478731",
"0.54059154",
"0.5405601",
"0.5395265"... | 0.7143064 | 0 |
List all worklogs for a given issue key. | def worklog(accountable):
worklog = accountable.issue_worklog()
headers = ['author_name', 'comment', 'time_spent']
if worklog:
rows = [[v for k, v in sorted(w.items()) if k in headers]
for w in worklog]
rows.insert(0, headers)
print_table(SingleTable(rows))
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_worklog(self, emp_id=None):\n\n query = \"select * from worklog\"\n\n try:\n self.dbCursor.execute(query)\n return self.dbCursor.fetchall()\n except mysql.connector.Error as err:\n ErrorMessageWindow(err)",
"def get_logs(job_key):\n job = Job.fet... | [
"0.6104521",
"0.5450961",
"0.5429597",
"0.54215986",
"0.53740776",
"0.53375506",
"0.5177321",
"0.51320475",
"0.509252",
"0.50396067",
"0.50299364",
"0.50039464",
"0.49709633",
"0.49424547",
"0.49327973",
"0.49153993",
"0.4895989",
"0.4895989",
"0.48916838",
"0.48571062",
"0.4... | 0.68508613 | 0 |
List all possible transitions for a given issue. | def transitions(accountable):
transitions = accountable.issue_transitions().get('transitions')
headers = ['id', 'name']
if transitions:
rows = [[v for k, v in sorted(t.items()) if k in headers]
for t in transitions]
rows.insert(0, headers)
print_table(SingleTable(rows... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transitions(self) -> List[Dict]:\n return []",
"def transitions(self, from_state=None):\n return list(self.iter_transitions(from_state))",
"def setup_transition_list():\n xn_list = []\n\n xn_list.append( Transition(3, 4, 2., 'left ejection') )\n xn_list.append( Transition(12, 2, 2., ... | [
"0.6658203",
"0.64597243",
"0.609803",
"0.5973659",
"0.59435755",
"0.5658975",
"0.56407136",
"0.5377166",
"0.5376197",
"0.5366969",
"0.53484374",
"0.5304934",
"0.52682185",
"0.5264709",
"0.5251384",
"0.5251384",
"0.5246294",
"0.52343994",
"0.5204525",
"0.5165543",
"0.5150279"... | 0.7419396 | 0 |
Debug breakpoint while in curses mode | def _D(stdscr):
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()
import pdb; pdb.set_trace() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __exit__(self, exc_type, exc_val, exc_tb):\n self.stdscr.keypad(False)\n self.stdscr.nodelay(False)\n curses.echo()\n curses.nocbreak()\n curses.endwin()",
"def gdb_breakpoint():\n _gdb_python_call_gen('gdb_breakpoint')()",
"def _debug_trace():\n from PyQt4.QtCore i... | [
"0.6429854",
"0.64178854",
"0.6243146",
"0.62248564",
"0.6194091",
"0.610298",
"0.6085449",
"0.5991171",
"0.5902381",
"0.58755255",
"0.5865251",
"0.5808573",
"0.5802128",
"0.57814217",
"0.57667226",
"0.5760795",
"0.5739943",
"0.572808",
"0.5721066",
"0.5709992",
"0.5702061",
... | 0.75144726 | 0 |
Retrieve yaml data from a given path if file not exist, return False | def get_yaml_data(path):
yaml_path = "%s%s.yml" % (CONTENT_FILE_DIR, path[:-5])
if os.path.isfile(yaml_path):
f = open(yaml_path, 'r')
template_data = yaml.load(f)
return template_data
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_yaml(path):\n if os.path.exists(path):\n f = open(path)\n data = yaml.load(f)\n f.close()\n return data\n else:\n # This should maybe throw an exception or something\n return {}",
"def load_yaml(path):\n if os.path.exists(path):\n f = open(path)\... | [
"0.7641903",
"0.7460384",
"0.69069195",
"0.6766211",
"0.6622035",
"0.6619555",
"0.6472961",
"0.6431809",
"0.630646",
"0.6232994",
"0.620704",
"0.620435",
"0.617769",
"0.6173353",
"0.6155012",
"0.6154364",
"0.6134782",
"0.6125133",
"0.6101209",
"0.6087636",
"0.6067218",
"0.6... | 0.80198294 | 0 |
Try and determine the correct _ (underscore) template matching the files directory structure | def determine_template_by_path(path):
path = path.lstrip('/')
path_chunks = re.split('\/', path)
if len(path_chunks) <= 1:
return path
else:
"""
For now be ignorant and just return the
first entry of the list as the possible template
name, so in fact ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _FindTemplateFile(self, topdir):\n if topdir.endswith('..'):\n topdir = '/'.join(topdir.split('/')[:-2])\n fnames = os.listdir(topdir)\n for fname in fnames:\n filename = '%s/%s' % (topdir, fname)\n if filename.endswith('.yaml') and not os.path.isdir(filena... | [
"0.68880016",
"0.65661573",
"0.6463607",
"0.6450778",
"0.6291978",
"0.6183937",
"0.6181306",
"0.6174625",
"0.61639",
"0.60519874",
"0.6047972",
"0.6023817",
"0.60039794",
"0.5952855",
"0.5941049",
"0.5935887",
"0.5918789",
"0.5912781",
"0.5902953",
"0.5882798",
"0.5849363",
... | 0.6831351 | 1 |
constructor instantiate a Document with a term_list to be converted into dict | def __init__(self, term_list, links=[]):
# do type check
if not isinstance(term_list, list):
raise TypeError('term_list must be of type list')
if not isinstance(links, list):
raise TypeError('links must be of type list')
self.term_dict = {x: term_list.count(x) for x in term_list}
self.links = copy.deepc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, docs, n):\n self.n = n\n self.dict = {}\n self.vocab = set()\n self.sum_index = \"*sum*\"\n regex = re.compile(\"\\s+\")\n count = 0\n for doc in docs:\n terms = re.split(regex, doc)\n for term in terms:\n if t... | [
"0.66287744",
"0.65560615",
"0.64975613",
"0.63856316",
"0.63014597",
"0.6102487",
"0.6062859",
"0.60123897",
"0.59738135",
"0.597112",
"0.5929631",
"0.58660865",
"0.5838759",
"0.5802222",
"0.5794235",
"0.5776823",
"0.57711035",
"0.5759174",
"0.57271045",
"0.5723895",
"0.5695... | 0.6789457 | 0 |
init Construct a DocumentSet with main document | def __init__(self, main_doc):
if not isinstance(main_doc, Document):
raise TypeError('term must be of type Document')
self.main_doc = main_doc
self.env_docs = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(init_document: 'Document') -> 'DocumentArray':",
"def build_document(self):\n pass",
"def new_document(self) -> nodes.document:\n document = super().new_document()\n document.__class__ = addnodes.document # replace the class with patched version\n\n # substitute transfor... | [
"0.6253416",
"0.60488045",
"0.5982539",
"0.59698325",
"0.5956928",
"0.59276694",
"0.58543664",
"0.5842508",
"0.5783739",
"0.5778808",
"0.57767564",
"0.5767244",
"0.57607514",
"0.57084924",
"0.5701809",
"0.5619672",
"0.56058586",
"0.56026864",
"0.55988246",
"0.5564519",
"0.556... | 0.6229792 | 1 |
Add Env Page append a new env_page to env_docs | def add_env_page(self, env_page):
if not isinstance(env_page, Document):
raise TypeError('env_page must be of type Document')
self.env_docs.append(env_page) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_env(self, env):\n pass",
"def addPage(self, name, page, **attrs):\n page.globalConfig = self.globalConfig\n page.pageConfig['pageName'] = name\n self.globalConfig.pageList.append(name)\n self.globalConfig.pageAttributes[name] = dict(attrs)\n setattr(self,name,pag... | [
"0.5903957",
"0.5708109",
"0.5389904",
"0.5385481",
"0.52170116",
"0.5199296",
"0.51268643",
"0.51034814",
"0.5072406",
"0.50699824",
"0.49988046",
"0.49757445",
"0.4973589",
"0.49586692",
"0.49433592",
"0.4912121",
"0.4901298",
"0.48945105",
"0.4888683",
"0.48753846",
"0.487... | 0.83140147 | 0 |
Count term in environment calculate idf of a term in main doc | def __count_term_in_env(self, term):
# type check
if not isinstance(term, str):
raise TypeError('term must be of type str')
total_cnt = float(len(self.env_docs)) + 1.0
if total_cnt == 1.0:
return 1.0
cnt = 1.0
for doc in self.env_docs:
if term in doc.term_dict:
cnt += 1.0
return math.log(to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_tf(doc):\r\n tf = {}\r\n for term in doc:\r\n if term not in tf:\r\n tf[term] = doc.count(term)\r\n return tf",
"def term_idf(self, term):\n idf = math.log(2 + self.count_term_distinct_documents(ANY))\\\n - math.log(1 + self.count_term_distinct_documents(term... | [
"0.729734",
"0.71593374",
"0.7090254",
"0.6939883",
"0.6922164",
"0.66782546",
"0.6643847",
"0.65991753",
"0.6548294",
"0.6533882",
"0.6521299",
"0.6515126",
"0.6509364",
"0.65010506",
"0.64998555",
"0.6493106",
"0.64863795",
"0.6480846",
"0.6379101",
"0.6369765",
"0.63460505... | 0.7381723 | 0 |
Statistic TF calculate and sort terms in main doc by tf | def statistic_tf(self):
return sorted(self.main_doc.term_dict.items(), key=operator.itemgetter(1), reverse=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_tf(doc):\r\n tf = {}\r\n for term in doc:\r\n if term not in tf:\r\n tf[term] = doc.count(term)\r\n return tf",
"def compute_TF(doc_info):\n tf_scores = []\n\n for idx, doc in enumerate(doc_info):\n tf_score_table = {}\n for word in doc['freq_dict'].keys():... | [
"0.7448172",
"0.7352905",
"0.7274512",
"0.719932",
"0.70984966",
"0.70313746",
"0.69458485",
"0.68545496",
"0.66986537",
"0.6692026",
"0.6671128",
"0.662987",
"0.6564009",
"0.65638477",
"0.65546054",
"0.6543071",
"0.6411876",
"0.6403338",
"0.6386789",
"0.631672",
"0.62851524"... | 0.805907 | 0 |
Statistic TFIDF calculate and sort terms in main doc by tfidf | def statistic_tfidf(self):
# calculate df-idf for all words
count_dict = {x: self.main_doc.term_dict[x] * self.__count_term_in_env(x) for x in self.main_doc.term_dict}
# sort them by df and idf
return sorted(count_dict.items(), key=operator.itemgetter(1), reverse=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tf_idf_score():\n\n global final_doc_set\n global final_dictionary\n final_score = []\n\n for doc_id in final_doc_set:\n score = 0\n for query_term in final_dictionary.keys():\n if final_dictionary[query_term][1].get(doc_id):\n tf = final_dictionary[query_ter... | [
"0.7582223",
"0.7435247",
"0.73491657",
"0.73197037",
"0.7230406",
"0.7206604",
"0.71902233",
"0.71717143",
"0.71699125",
"0.7125617",
"0.702574",
"0.7018102",
"0.700898",
"0.69296885",
"0.6926581",
"0.6906138",
"0.68636584",
"0.68492436",
"0.68379414",
"0.6832129",
"0.682651... | 0.8353365 | 0 |
Show the menu and return either None (if an exit key was pressed) or FindTweetMenu.BACK_INDEX | def showAndGet(self):
keywords = TerminalInterface.getSearchKeywords()
# If user did not enter any keywords, return FindUserMenu.BACK_INDEX
if keywords is None: return FindTweetMenu.BACK_INDEX
tweetGeneratorMethod = lambda: TweetsTableTools.findTweets(
self._connection, keywords)
menu = TweetsMenu(self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_menu(self):\n while True:\n number = pyip.inputNum(\"0. Back to the main menu: \")\n if number == 0:\n # Clean up the console\n self.clear_console()\n # back to the main menu\n self.run()\n else:\n ... | [
"0.6956989",
"0.63773394",
"0.6250696",
"0.6249938",
"0.6121402",
"0.6083828",
"0.6070606",
"0.6057965",
"0.6057965",
"0.6047459",
"0.60398436",
"0.60209143",
"0.5979282",
"0.59761137",
"0.59599715",
"0.59599715",
"0.59599715",
"0.5945133",
"0.59189636",
"0.5891626",
"0.58872... | 0.75444674 | 0 |
Uses an index array to obtain indices using an index array along an axis. | def select_indices(arr,index_arr,axis=-1):
shape_list=(lambda x,y: [ 1 if dim!=x else y for dim in range(len(arr.shape))] )
indices_list=[np.reshape(np.arange(length),shape_list(length_id,length))
for length_id,length in enumerate(arr.shape)]
indices_list[axis]=index_arr
return arr.rav... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pndindex(*args):\r\n return np.ndindex(*args)",
"def pndindex(*args):\n return np.ndindex(*args)",
"def _index(tensor_3d, tensor_2d):\n x, y, z = tensor_3d.size()\n t = tensor_3d.reshape(x * y, z)\n tt = tensor_2d.reshape(x * y)\n v = t[torch.arange(x * y), tt]\n v = v.reshape(x, y)\n ... | [
"0.7302368",
"0.7263272",
"0.69995314",
"0.6984675",
"0.68649966",
"0.68557614",
"0.6626734",
"0.6612736",
"0.64494765",
"0.63717943",
"0.6355618",
"0.6344733",
"0.6259788",
"0.62565714",
"0.62565714",
"0.6241369",
"0.62404037",
"0.62190133",
"0.62045544",
"0.61014456",
"0.60... | 0.7482163 | 0 |
Continous loop of inputs and answers | def evaluateCycle(self):
print("Enter q or quit to exit")
input_sentence = ''
while(1):
# Get input sentence
input_sentence = input('> ')
# Check if it is quit case
if input_sentence == 'q' or input_sentence == 'quit': break
ans = self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eval_loop():\n while(True):\n decision = raw_input(\"enter some mathematical operations\")\n if(decision == \"done\"):\n break\n print eval(decision)",
"def main():\n min_random = 10 #keeping constant for the min random number range\n max_random = 99 #keeping constant... | [
"0.6230928",
"0.6096894",
"0.6076145",
"0.5999656",
"0.5885386",
"0.5863726",
"0.5846322",
"0.5829764",
"0.5800593",
"0.57979757",
"0.5749408",
"0.57334924",
"0.5704362",
"0.5703528",
"0.56611365",
"0.5657158",
"0.56488985",
"0.564698",
"0.5644468",
"0.5608744",
"0.5578464",
... | 0.6725195 | 0 |
Execute html_reporter if html flag is exist in sys.argv. | def __execute_reporter(self):
if not self.__args.report:
return
reporter.HTMLReporter().generate_report_from_file(
self.__lst_json_files) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(args):\n p = OptionParser()\n p.add_option('-d', '--debug',\n action='store_true', default=False, dest='debug',\n help='debug')\n p.add_option('-w', '--w3c',\n action='store_true', default=False, dest='w3c',\n help='send file to vali... | [
"0.61923707",
"0.6103338",
"0.57461756",
"0.5729902",
"0.5687042",
"0.5661867",
"0.5577024",
"0.5549909",
"0.5545881",
"0.5544282",
"0.5523945",
"0.5516386",
"0.5506726",
"0.5482997",
"0.545956",
"0.541977",
"0.5402856",
"0.5398641",
"0.5351573",
"0.53477114",
"0.5338802",
... | 0.65210193 | 0 |
Get all scenario in folder. Recursive to sub folder if "rd" argument appear in sys.argv. | def __get_list_scenarios_in_folder(self):
# If both directory and recur_directory are exist
# then show "Invalid command" and exit.
if self.__args.directory is not "" \
and self.__args.recur_directory is not "":
utils.print_error("\n{}\n".format(constant.ERR_COMMAND_E... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getImmediateSubdirectories(dir):",
"def open_run_list(base_path, filter=None):\n dir_list = listdir(base_path)\n if not dir_list:\n return []\n if filter is not None:\n filter_list = glob(path.join(base_path, filter))\n filter_list = [path.basename(x) for x in filter_list]\n ... | [
"0.63146096",
"0.5627409",
"0.558369",
"0.55248845",
"0.5507381",
"0.54794055",
"0.54717195",
"0.541972",
"0.5409548",
"0.5396662",
"0.53879046",
"0.5381494",
"0.53524697",
"0.534816",
"0.53151697",
"0.5314741",
"0.5300426",
"0.5292671",
"0.5287332",
"0.52773887",
"0.5202164"... | 0.6236096 | 1 |
Takes a tuple representing a circle as (x,y,radius) and returns a tuple with the x,y coordinates and width,size (x,y,w,h) | def circle_2_tuple(circle):
assign_coord = lambda x,y: x - y if x > y else 0
x = assign_coord(circle[0],circle[2])
y = assign_coord(circle[1],circle[2])
assign_size = lambda x,y : y*2 if x > y else y*2 - (y-x)
w = assign_size(circle[0],circle[2])
h = assign_size(circle[1],circle[2])
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def circle_2_bbox(circle):\n x,y,w,h = circle_2_tuple(circle)\n return ((x,y),(x+w,y+h))",
"def circleInfo(r):\n c = 2 * 3.14159 * r\n a = 3.14159 * r * r\n return (c, a)",
"def _resolve_size(self, width, height, center_x, center_y):\n if self.size_type == 'explicit':\n size_x,... | [
"0.6815439",
"0.67740446",
"0.6597744",
"0.64084023",
"0.63581634",
"0.6175593",
"0.6125594",
"0.6088099",
"0.6076769",
"0.60566986",
"0.6024376",
"0.5960171",
"0.5957911",
"0.5952948",
"0.59458065",
"0.5938926",
"0.5935301",
"0.59228104",
"0.59222513",
"0.5917145",
"0.588294... | 0.82615507 | 0 |
Takes a tuple representing a circle as (x,y,radius) and returns a tuple represeting a bbox ((x,y),(x',y')) | def circle_2_bbox(circle):
x,y,w,h = circle_2_tuple(circle)
return ((x,y),(x+w,y+h)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def circle_2_tuple(circle):\n assign_coord = lambda x,y: x - y if x > y else 0\n x = assign_coord(circle[0],circle[2])\n y = assign_coord(circle[1],circle[2])\n\n assign_size = lambda x,y : y*2 if x > y else y*2 - (y-x) \n w = assign_size(circle[0],circle[2])\n h = assign_size(circle[1],circle[2... | [
"0.7212098",
"0.6748863",
"0.6743238",
"0.6730478",
"0.67082477",
"0.66678756",
"0.66592455",
"0.66318727",
"0.6586817",
"0.65842336",
"0.6532223",
"0.6481017",
"0.6468795",
"0.6422326",
"0.6373362",
"0.63589585",
"0.635091",
"0.6347281",
"0.6332991",
"0.63162756",
"0.6307187... | 0.87923753 | 0 |
Takes a tuple of tuples represeting a bbox ((x,y),(x',y')) and returns | def fix_bbox(bbox,img_shape):
x = min(bbox[1][0],img_shape[1])
y = min(bbox[1][1],img_shape[0])
return ((bbox[0]),(x,y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def circle_2_bbox(circle):\n x,y,w,h = circle_2_tuple(circle)\n return ((x,y),(x+w,y+h))",
"def bbox(self):\n lower = (self.x.min(), self.y.min())\n upper = (self.x.max(), self.y.max())\n return (lower, upper)",
"def bbox2points(bbox):\r\n l, x, y, w, h = bbox\r\n xmin = int(ro... | [
"0.74169517",
"0.7330232",
"0.73051816",
"0.7260692",
"0.72117823",
"0.71556735",
"0.711998",
"0.70630515",
"0.6968945",
"0.6965542",
"0.6959953",
"0.68821084",
"0.68737143",
"0.68725014",
"0.6858501",
"0.68244123",
"0.67616284",
"0.67497444",
"0.67070234",
"0.66811466",
"0.6... | 0.75615424 | 0 |
Draws bboxes in a image given an array of circles [(x,y,radius)] | def bbox_from_circle(img, circles):
seg_imgs = []
bboxes = []
aux = img.copy()
for i,el in enumerate(circles):
bbox = circle_2_bbox(el['coord'])
bbox = fix_bbox(bbox,aux.shape)
cv.rectangle(aux,bbox[0],bbox[1],(0,255,0))
bboxes.append(bbox)
return bboxes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_bboxes(img, bboxes, color=(0, 0, 255), thick=6):\n draw_img = np.copy(img)\n # Draw rectangles given bbox coordinates as opposing coordinates\n # bboxes = opposing coordinates: (x1,y1), (x2,y2)\n [cv2.rectangle(draw_img, bbox[0], bbox[1], color, thick) for bbox in bboxes]\n return draw_img"... | [
"0.68533266",
"0.68072176",
"0.6805508",
"0.6788925",
"0.676972",
"0.6738393",
"0.67133397",
"0.664385",
"0.66165227",
"0.6587222",
"0.6578446",
"0.65585065",
"0.6551722",
"0.65482426",
"0.6528621",
"0.65220505",
"0.64468735",
"0.64413995",
"0.6400262",
"0.6379862",
"0.637677... | 0.73344976 | 0 |
Calculate heterozygosity samples = list of sample names vcf = VCF file | def calHet( inFile, varType ):
names = []
print("Sample\tfracHet\thetCt\thomCt") # print header
with open( inFile, 'r') as files: # open sample name file
for i in files:
i = i.rstrip()
vcf = i + "." + varType + ".vcf" ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vcf_samples(vcffile):\n try:\n vcf_reader = vcf.Reader(open(vcffile, 'r'))\n return vcf_reader.samples\n except Exception as error:\n print(f\"Could not read vcffile {vcffile}: continuing without vcf data: {str(error)}\")\n\n return []",
"def calculate_mixture_features(args):\n ... | [
"0.59488827",
"0.5802758",
"0.58007336",
"0.57328737",
"0.56093895",
"0.55808663",
"0.5559472",
"0.5527993",
"0.55187845",
"0.5462843",
"0.54014647",
"0.5394218",
"0.53905374",
"0.53511345",
"0.53466797",
"0.5334894",
"0.5314936",
"0.5283237",
"0.5243797",
"0.5231647",
"0.523... | 0.6672723 | 0 |
A convenience function for getting a single suggestion. | def get_suggestion():
global _suggestions_iterator
while True:
try:
return next(_suggestions_iterator)
except StopIteration:
_suggestions_iterator = iter(suggestions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suggestion(self, suggestion_id):\r\n return suggestions.Suggestion(self, suggestion_id)",
"def pull_suggestion(self, callback, who, arg):\n\t\t\n random_sug = self.dong.db.get_random_row('suggest')\n res = self.google_suggest(callback, who, random_sug[2], False)\n\t\t\n w = res.sp... | [
"0.70957506",
"0.7064316",
"0.6983561",
"0.6963836",
"0.6963836",
"0.6800833",
"0.6749406",
"0.6550867",
"0.6436159",
"0.6428319",
"0.6357224",
"0.62608695",
"0.62456524",
"0.6239825",
"0.6186077",
"0.60764414",
"0.6011701",
"0.5944827",
"0.5927803",
"0.582557",
"0.5824507",
... | 0.7540617 | 0 |
Builds game board by retrieving a sudoku puzzle preset from a sudoku dataset and then sets up the game board. Also calls a backtracking algorithm to derive a solution for the sudoku puzzle. | def build_game_board(self):
# retrieves new sudoku puzzle from dataset
sudoku_set = self.data.get_sudoku_set()
sudoku_problem, sudoku_solution = sudoku_set[0], sudoku_set[1]
# removes old game boards
self.board = []
self.puzzle = []
self.alg_solution = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solveSudoku(board):\n # represents all numbers in a specific row, col, box\n # format: if (5,9) is in rows, that means row 5 contains digit 9\n\t\t# format: if (3, 2) is in cols, that means col 3 contains digit 2\n\t\t# format: if (0,2,8) is in boxes, that means box (0,2) contains 8\n\t\t# cellsT... | [
"0.70219713",
"0.6696299",
"0.6669564",
"0.665291",
"0.6652331",
"0.6648256",
"0.6491506",
"0.6417593",
"0.64122254",
"0.6406946",
"0.64067495",
"0.6398763",
"0.6398049",
"0.6371711",
"0.63527167",
"0.6332174",
"0.63301975",
"0.6281087",
"0.6276849",
"0.62565374",
"0.62547344... | 0.8129647 | 0 |
Requests user input for the row column and number input they would like to enter as the next entry to the Sudoku puzzle. Has some lightweight data validation through a try / except format and asks for another input attempt if invalid inputs were provided. | def request_number_input(self):
try:
self.print_board(self.board)
row = int(input("Please enter row to add number to (0-8): "))
col = int(input("Please enter column to add number to (0-8): "))
num = int(input("Please enter number you wish to add (1-9): "))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input(self):\n while True:\n try:\n self.rows = int(input(\"Number of rows: \"))\n while self.rows < 2 or self.rows > 30:\n self.rows = int(input(\"Please enter a number between 2 and 30: \"))\n break\n except Valu... | [
"0.7249653",
"0.7011725",
"0.68896455",
"0.65655696",
"0.64116174",
"0.63925433",
"0.62278056",
"0.6168719",
"0.6091157",
"0.6074832",
"0.604573",
"0.6043378",
"0.5990928",
"0.5926154",
"0.5902846",
"0.58928376",
"0.5879233",
"0.5877413",
"0.5809618",
"0.57965463",
"0.5755129... | 0.71602094 | 1 |
Checks if the requested square to change is an original input for the puzzle, which cannot be changed. | def new_input_does_not_overlap_original_board(self, col, row):
return self.puzzle[row][col] == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_solved(self):\n # Iterate through each square of the puzzle\n for row in range(self.sl):\n for col in range(self.sl):\n val = self.puzzle[row][col]\n\n # If any square value is blank (0), not solved, return False\n if val == 0:\n ... | [
"0.68145555",
"0.66621006",
"0.65014184",
"0.6457396",
"0.64046955",
"0.6342213",
"0.6310124",
"0.630704",
"0.6286575",
"0.62758124",
"0.62362766",
"0.6218367",
"0.62178296",
"0.61827266",
"0.61717474",
"0.61584324",
"0.61545163",
"0.61536086",
"0.6134026",
"0.6131081",
"0.61... | 0.710153 | 0 |
Method for retrieving game state. | def get_game_state(self):
return self.game_state | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_game_state(self):\r\n return self._game_state",
"def get_game_state(self):\n return self._game_state",
"def get_game_state(self):\n return self._game_state",
"def get_game_state(self):\n return self._game_state",
"def get_game_state(self):\n return self._current_s... | [
"0.8740767",
"0.86155",
"0.86155",
"0.86155",
"0.8482095",
"0.84146124",
"0.84146124",
"0.8371279",
"0.8281865",
"0.82611275",
"0.7860468",
"0.7752739",
"0.7565724",
"0.75503594",
"0.75414294",
"0.75414294",
"0.75414294",
"0.75414294",
"0.75414294",
"0.75414294",
"0.75414294"... | 0.87546504 | 0 |
Nethod for playing a game of sudoku. Prints out rules and instructions and asks for user inputs. If current puzzle is solved, asks player if they would like to play again and provides a new puzzle. | def play_sudoku(puzzle):
print_instructions()
print("For review and grading purposes purposes, here is a sample solution:")
puzzle.print_board(puzzle.alg_solution)
# while puzzle is not solved, continues to ask user for their next input
while puzzle.get_game_state() != "Solved!":
puzzle.re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\r\n print(WELCOME_MESSAGE)\r\n\r\n playing = True\r\n while playing:\r\n\r\n # Valid inputs that the user can use\r\n move_actions = (UP, DOWN, LEFT, RIGHT)\r\n other_actions = (GIVE_UP, HELP)\r\n\r\n grid_size = int(input(BOARD_SIZE_PROMPT))\r\n\r\n # Get th... | [
"0.7092953",
"0.689259",
"0.68871856",
"0.6726647",
"0.6684823",
"0.6676533",
"0.6589806",
"0.6555856",
"0.6482301",
"0.63967913",
"0.6358735",
"0.6353301",
"0.6346815",
"0.63003695",
"0.6269608",
"0.6250014",
"0.6243339",
"0.62017316",
"0.61864555",
"0.6185452",
"0.61633503"... | 0.82174706 | 0 |
Prints to console a set of instructions for how to play a game of Sudoku. | def print_instructions():
print("Welcome to the game of Sudoku!")
print("--------------------------------")
print("The goal of the game is to fill every 'square' here with a number.")
print("The rules of the game are simple:")
print(" Rule No 1: You can only enter numbers 1-9 in each square.")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_instructions(self):\n\t\tprint('\\n\\n==========================================================================')\n\t\tprint('==========================================================================\\n')\n\t\tprint('Welcome to Tic Tac Toe, the came you know and love. \\nThe rules are the same ones you... | [
"0.75848573",
"0.71088547",
"0.703432",
"0.6988165",
"0.69866717",
"0.6634064",
"0.6410708",
"0.6397539",
"0.6355258",
"0.63541543",
"0.6338774",
"0.63357323",
"0.6296808",
"0.6284995",
"0.6267385",
"0.62419635",
"0.6191577",
"0.6185726",
"0.6172115",
"0.61716187",
"0.6133821... | 0.74090517 | 1 |
Creates four plotly visualizations using the New York Times Archive API | def return_figures():
# Add New York Times API Key
nyt = NYTAPI("AsjeHhqDYrePA2GMPpYoY1KAKAdG7P99")
# Select Year and Month of articles
data = nyt.archive_metadata(
date = datetime.datetime(2020, 7, 1)
)
def data_to_df(data):
# Initiate list for restructured information
data_list = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_figures():\n\n graph_one = []\n df = cleanparrisdf('data/Salem-Village-Data-Set.csv')\n sources = [0,0,0,1,1,1]\n targets = [2,3,4,2,3,4]\n values = df[\"petition_count\"].tolist()\n\n data_one = dict(\n type = 'sankey',\n node = dict(\n pad = 10,\n ... | [
"0.64221996",
"0.6253128",
"0.61704546",
"0.61357796",
"0.59865403",
"0.5960612",
"0.5946181",
"0.59333766",
"0.585216",
"0.58064705",
"0.5785414",
"0.576179",
"0.5730726",
"0.57133067",
"0.57080656",
"0.5644872",
"0.56262666",
"0.5618747",
"0.559435",
"0.559427",
"0.5580006"... | 0.715962 | 0 |
Since virtual steppers are virtual, we don't need pins or step sequences. We're still using delay and n_steps to resemble physical steppers. | def __init__(self, name = None, n_steps = 256, delay = 1e-3):
self.fig, self.ax = plt.subplots(figsize=(3, 3))
self.n_steps = n_steps
self.delay = delay
self.step_size = 2 * pi / self.n_steps
if name is None:
self.name = 'Stepper {}'.format(VirtualStepper.count + 1)
self.angle = 0.0
self.check()
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simulation_step(self):\n if not self.np_trajectory.size:\n #No trajectory to go to.....\n return\n closest_ind = self.find_closest_trajectory_pose()\n ref_ind = (closest_ind + 30) # closest_ind + numpy.round(self.v / 4)\n traj_len = len(self.np_trajectory[0])\n... | [
"0.61042655",
"0.58270293",
"0.57595366",
"0.5680195",
"0.566837",
"0.56112635",
"0.5599372",
"0.55904734",
"0.5564814",
"0.55495346",
"0.55369097",
"0.5532785",
"0.552632",
"0.55011874",
"0.5483982",
"0.5469438",
"0.5464263",
"0.54594064",
"0.54537576",
"0.5439023",
"0.54092... | 0.5976446 | 1 |
Rotate the stepper by this angle (radians unless specified) Positive angles rotate clockwise, negative angles rotate counterclockwise | def rotate_by(self, angle, degrees = False):
target = angle * pi / 180 if degrees else angle
if self.inv:
target = -target
if target > 0:
n = int(target // self.step_size) + 1
for _ in range(n):
self.step_c()
else:
n = int(-target // self.step_size) + 1
for _ in range(n):
self.step_cc()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_rad(self, angle):\n self.beam_angle += angle\n self.xy = rotate(self.xy, angle)\n self.angle += angle",
"def rotate(self, direction):\n electro = pygame.mixer.Sound('resources/Electro_Motor.wav')\n electro.set_volume(0.2)\n self.rotation += min(max(direction, ... | [
"0.7070411",
"0.7032392",
"0.6987201",
"0.6970376",
"0.69328016",
"0.6915016",
"0.6913845",
"0.68389475",
"0.68369746",
"0.682694",
"0.6704316",
"0.6675216",
"0.6641125",
"0.66407424",
"0.66319656",
"0.66140467",
"0.65792656",
"0.65759706",
"0.6568908",
"0.6567404",
"0.651743... | 0.730979 | 0 |
convert csv into numpy | def csv_2_numpy(file, path=INPUT_PATH, sep=',', type='int8'):
file_path = path + file
reader = csv.reader(open(file_path, "r"), delimiter=sep)
x = list(reader)
dataset = numpy.array(x).astype(type)
return dataset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(csvfilename):\r\n with open(csvfilename, 'r') as f:\r\n reader = csv.reader(f, delimiter=';')\r\n #reader = csv.reader(f, delimiter=';', quotechar=\"'\")\r\n data = list(reader)\r\n # transform data into numpy array\r\n data = np.array(data).astype(float)\r\n retu... | [
"0.7606892",
"0.7327829",
"0.727883",
"0.7161398",
"0.71550566",
"0.69989276",
"0.69635636",
"0.68933666",
"0.6836764",
"0.6802852",
"0.6801808",
"0.67944103",
"0.6787268",
"0.67241",
"0.6684425",
"0.66639805",
"0.6646328",
"0.6636542",
"0.6630825",
"0.658941",
"0.6581193",
... | 0.81163687 | 0 |
Builds a vocabulary mapping from word to index based on the sentences. Returns vocabulary mapping and inverse vocabulary mapping. | def build_vocab(sentences):
# Build vocabulary
word_counts = Counter(itertools.chain(*sentences)) # 实际没用到
# Mapping from index to word
vocabulary_inv = [x[0] for x in word_counts.most_common()]
vocabulary_inv = list(sorted(vocabulary_inv))
# 加入 <UNK>
vocabulary_inv.insert(0, '</s>')
# M... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_vocab(self, sentences):\n\t\t# Build the vocab\n\t\tword_counts = collections.Counter(sentences)\n\n\t\t# Mapping from index to word (get the indices of most common words)\n\t\tvocab_inv = [x[0] for x in word_counts.most_common()] # Do we need this?\n\t\tvocab_inv = list(sorted(vocab_inv))\n\n\t\t# Mapp... | [
"0.79638803",
"0.7715133",
"0.7715133",
"0.7715133",
"0.76599747",
"0.7653059",
"0.7552094",
"0.74614453",
"0.69518715",
"0.6917704",
"0.68646234",
"0.68494624",
"0.67772037",
"0.6662719",
"0.6608852",
"0.65526927",
"0.65498227",
"0.6457259",
"0.6451463",
"0.6442439",
"0.6440... | 0.7844205 | 1 |
Estimate the true signal mean and interpolate bad channels. This function implements the functionality of the `performReference` function as part of the PREP pipeline on mne raw object. Notes This function calls robust_reference first Currently this function only implements the functionality of default settings, i.e., ... | def perform_reference(self):
# Phase 1: Estimate the true signal mean with robust referencing
self.robust_reference()
if self.noisy_channels["bad_all"]:
self.raw.info["bads"] = self.noisy_channels["bad_all"]
self.raw.interpolate_bads()
self.reference_signal = (
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def robust_reference(self):\n raw = self.raw.copy()\n raw._data = removeTrend(raw.get_data(), sample_rate=self.sfreq)\n\n # Determine unusable channels and remove them from the reference channels\n noisy_detector = NoisyChannels(raw, do_detrend=False)\n noisy_detector.find_all_ba... | [
"0.72033346",
"0.51534164",
"0.51021534",
"0.5064311",
"0.50264406",
"0.50084466",
"0.49690974",
"0.49434143",
"0.4942057",
"0.4890532",
"0.4875339",
"0.4820547",
"0.4813191",
"0.47748223",
"0.47736692",
"0.47729418",
"0.47667706",
"0.4733884",
"0.47221825",
"0.47158694",
"0.... | 0.80031914 | 0 |
Detect bad channels and estimate the robust reference signal. This function implements the functionality of the `robustReference` function as part of the PREP pipeline on mne raw object. | def robust_reference(self):
raw = self.raw.copy()
raw._data = removeTrend(raw.get_data(), sample_rate=self.sfreq)
# Determine unusable channels and remove them from the reference channels
noisy_detector = NoisyChannels(raw, do_detrend=False)
noisy_detector.find_all_bads(ransac=s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_reference(self):\n # Phase 1: Estimate the true signal mean with robust referencing\n self.robust_reference()\n if self.noisy_channels[\"bad_all\"]:\n self.raw.info[\"bads\"] = self.noisy_channels[\"bad_all\"]\n self.raw.interpolate_bads()\n self.refere... | [
"0.7477632",
"0.6277125",
"0.59613264",
"0.58670795",
"0.55491996",
"0.53819615",
"0.5299285",
"0.5188852",
"0.51496625",
"0.5102384",
"0.50921977",
"0.5008404",
"0.49466848",
"0.4929399",
"0.49203682",
"0.49124527",
"0.48961046",
"0.48734668",
"0.48694846",
"0.48172373",
"0.... | 0.79005593 | 0 |
Remove the reference signal from the original EEG signal. This function implements the functionality of the `removeReference` function as part of the PREP pipeline on mne raw object. | def remove_reference(signal, reference, index=None):
if np.ndim(signal) != 2:
raise ValueError(
"RemoveReference: EEG signal must be 2D array (channels * times)"
)
if np.ndim(reference) != 1:
raise ValueError("RemoveReference: Reference signal must be ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeReference(self, reference: ghidra.program.model.symbol.Reference) -> None:\n ...",
"def removeReferenceGlyph(self, *args):\n return _libsbml.GeneralGlyph_removeReferenceGlyph(self, *args)",
"def _remove_reference(self, target):\n assert target in self._referenced_nodes\n ... | [
"0.7395361",
"0.618159",
"0.6136284",
"0.6101331",
"0.59427154",
"0.58940864",
"0.58332074",
"0.57739156",
"0.5770895",
"0.5762816",
"0.5671317",
"0.56659806",
"0.5665375",
"0.5660799",
"0.5658297",
"0.5644026",
"0.5601565",
"0.5555541",
"0.5552319",
"0.5550075",
"0.5489779",... | 0.7985783 | 0 |
Sets the buy list for the board | def setBuyList(self, buyList):
parsedBuyList = []
for bought in buyList:
if hasattr(bought, "unitType"):
parsedBuyList.append(bought)
elif isinstance(bought, dict) and u'unitType' in bought and u'territory' in bought:
parsedBuyList.append(createBou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buys(self, buys):\n\n self._buys = buys",
"def set_buy_sell_deal_account(self, account_list):\n self.multiple_items_selection_from_kendo_dropdown(self.buy_sell_deal_account_dropdown_locator, account_list)\n self.wait_for_ajax_spinner_load()",
"def set_target_buy_list(self, item_name, i... | [
"0.6422962",
"0.6265",
"0.5775737",
"0.5630926",
"0.5596823",
"0.5562822",
"0.55483556",
"0.5545518",
"0.5418781",
"0.53955275",
"0.535245",
"0.5310174",
"0.5309824",
"0.53068644",
"0.5252064",
"0.52498454",
"0.5239531",
"0.5211751",
"0.5184596",
"0.51813936",
"0.5175984",
... | 0.6954832 | 0 |
Converts json string in related object object_to_serialize have to be an instace of the desired to convert object | def DeserializeJson(self, json_string, object_to_serialize):
object_to_serialize.__dict__ = json.loads(str(json_string))
return object_to_serialize | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_serializable(o: Any) -> Any:\n if isinstance(o, UUID):\n return str(o)\n if isinstance(o, datetime):\n return isoformat(o)\n if is_dataclass(o):\n return asdict(o)\n if hasattr(o, \"__json__\"):\n return o.__json__()\n if hasattr(o, \"to_dict\"):\n # api_cli... | [
"0.68756694",
"0.6863126",
"0.68572044",
"0.68323946",
"0.68267304",
"0.6792545",
"0.67513794",
"0.6714095",
"0.6697272",
"0.66942084",
"0.6680018",
"0.6673534",
"0.6665409",
"0.6663698",
"0.6646167",
"0.6644696",
"0.6639211",
"0.6623753",
"0.66212523",
"0.66212523",
"0.66212... | 0.7826462 | 0 |
Constructs a DVR object | def DVR(
domain=None,
divs=None,
classes=None,
potential_function=None,
g=None,
g_deriv=None,
scf=False,
potential_optimize=False,
**base_opts
):
return DVRConstructor.construct(
domain=domain,
divs=divs,
classes=classe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dzdt, v, e, D):\n self.V = dzdt\n self.v = v\n self.e = e\n self.D = D\n self.laminar_label = \"Laminar\"\n self.critical_label = \"Critical\"\n self.turbulent_label = \"Turbulent\"",
"def __init__(self, dr_ds: DatasetReader) -> None:\n s... | [
"0.61528945",
"0.60658884",
"0.599728",
"0.59843045",
"0.59223074",
"0.5918787",
"0.5913648",
"0.5847089",
"0.5769131",
"0.5743365",
"0.57272416",
"0.57149744",
"0.57125163",
"0.5688939",
"0.56877244",
"0.5670665",
"0.56602484",
"0.56357646",
"0.5623393",
"0.5620744",
"0.5612... | 0.7178919 | 0 |
Convert the ``Response`` object into django's ``HttpResponse`` | def _finalize_response(self, response):
res = HttpResponse(content=response.content,
content_type=self._get_content_type())
# status_code is set separately to allow zero
res.status_code = response.code
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_http_response(self) -> HttpResponse:\n response = (\n JsonResponse(self.body)\n if (self.headers or {}).get(\"Content-Type\") == \"application/json\"\n else HttpResponse(self.body)\n )\n response.headers = self.headers\n return response",
"def m... | [
"0.7379816",
"0.7109294",
"0.69839066",
"0.6952941",
"0.6952941",
"0.6925957",
"0.6925957",
"0.69120204",
"0.68229306",
"0.6809943",
"0.6809943",
"0.6740994",
"0.6736841",
"0.6683467",
"0.66039944",
"0.65061057",
"0.64141685",
"0.640344",
"0.6377596",
"0.634833",
"0.6296918",... | 0.759568 | 0 |
Return ContentType header with charset info. | def _get_content_type(self):
return '%s; charset=%s' % (self.content_type, self.charset) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def charset(self) -> Optional[str]:\n raw = self._headers.get(hdrs.CONTENT_TYPE) # type: ignore[attr-defined]\n if self._stored_content_type != raw:\n self._parse_content_type(raw)\n return self._content_dict.get(\"charset\") # type: ignore[union-attr]",
"def content_type_header... | [
"0.7331894",
"0.71138537",
"0.6978401",
"0.6755701",
"0.6664483",
"0.6629774",
"0.6557151",
"0.65387005",
"0.65190446",
"0.64697444",
"0.64657295",
"0.6446364",
"0.642422",
"0.6410978",
"0.63235193",
"0.6279511",
"0.6264188",
"0.623511",
"0.6197167",
"0.61729234",
"0.6166692"... | 0.74809164 | 0 |
Initialize the manager. The ``_datamappers`` dictionary is initialized here to make testing easier. | def __init__(self):
self._datamappers = {
'*/*': DataMapper()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.data_set_loc = conf.config_section_mapper(\"filePath\").get(\"data_set_loc\")\n self.data_extractor = DataExtractor(self.data_set_loc)",
"def do_init(self):\n\n pass",
"def init(self, **kwargs):\n self._d = {}\n self._th = None\n self._run = ... | [
"0.6461124",
"0.6418458",
"0.6413563",
"0.6375085",
"0.6290806",
"0.6228817",
"0.6185347",
"0.6185347",
"0.6185347",
"0.61723155",
"0.61663306",
"0.6159628",
"0.6139021",
"0.6131483",
"0.61117107",
"0.6094118",
"0.6062833",
"0.6062833",
"0.6062833",
"0.6062833",
"0.6062833",
... | 0.7486393 | 0 |
Select appropriate formatter based on the request. | def select_formatter(self, request, resource):
# 1. get from resource
if resource.mapper:
return resource.mapper
# 2. get from url
mapper_name = self._get_name_from_url(request)
if mapper_name:
return self._get_mapper(mapper_name)
# 3. get from ac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _determine_format(self, request):\n return determine_format(request, self._meta.serializer, default_format=self._meta.default_format)",
"def determine_format(request, serializer, default_format='application/json'):\r\n # First, check if they forced the format.\r\n if request.GET.get('format'):\r... | [
"0.70516115",
"0.68860674",
"0.67620766",
"0.6718547",
"0.641668",
"0.62356836",
"0.6230665",
"0.61402184",
"0.61402184",
"0.6086643",
"0.6054365",
"0.59921783",
"0.59283495",
"0.5847288",
"0.58354276",
"0.5824539",
"0.57529914",
"0.5744481",
"0.5692539",
"0.569212",
"0.56478... | 0.7539723 | 0 |
Select appropriate parser based on the request. | def select_parser(self, request, resource):
# 1. get from resource
if resource.mapper:
return resource.mapper
# 2. get from content type
mapper_name = self._get_name_from_content_type(request)
if mapper_name:
return self._get_mapper(mapper_name)
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_parser():\n\n try:\n select_texttools_parser()\n except ImportError:\n select_python_parser()",
"def get_parser(self):\n if self.vendor and self.platform and self.version:\n cls = self.profile.get_profile().get_parser(\n self.vendor.code, self.platform.name, se... | [
"0.67126334",
"0.6521535",
"0.6489922",
"0.640149",
"0.6139885",
"0.61379045",
"0.613299",
"0.61198676",
"0.6049748",
"0.602667",
"0.5946609",
"0.58708733",
"0.58408815",
"0.5837304",
"0.58118755",
"0.5710313",
"0.5667457",
"0.5613246",
"0.5606975",
"0.5493934",
"0.5479771",
... | 0.73894787 | 0 |
Returs mapper based on the content type. | def get_mapper_by_content_type(self, content_type):
content_type = util.strip_charset(content_type)
return self._get_mapper(content_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mapper(self, structure):\n type_ = structure['type']\n mapper = self.mappers[type_]\n return mapper",
"def mapper_for_type(self, type_):\n mapper = self.mappers[type_]\n return mapper",
"def get_mapping_type(cls):\n ...",
"def _get_mapper(obj):\n its_a_model =... | [
"0.6787792",
"0.6768891",
"0.62163997",
"0.5705611",
"0.56396294",
"0.55432177",
"0.5536067",
"0.5350777",
"0.53324276",
"0.53072",
"0.529081",
"0.5220667",
"0.5189422",
"0.5182988",
"0.51817083",
"0.50861496",
"0.50557506",
"0.5036861",
"0.50153947",
"0.49689895",
"0.4966391... | 0.77844703 | 0 |
Set the default mapper to be used, when no format is defined. This is the same as calling ``register_mapper`` with ``/`` with the exception of giving ``None`` as parameter. | def set_default_mapper(self, mapper):
mapper = mapper or DataMapper()
self._datamappers['*/*'] = mapper | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_default_mapper(self):\n\n return self._datamappers['*/*']",
"def set_mapper(obj, mapper):\n setattr(obj, MAPPER, mapper)\n return mapper",
"def _get_mapper(self, mapper_name):\n\n if mapper_name in self._datamappers:\n # mapper found\n return self._datamappers... | [
"0.7185841",
"0.5845222",
"0.5408889",
"0.5322639",
"0.5239758",
"0.5030067",
"0.4899394",
"0.48726788",
"0.4867522",
"0.48561874",
"0.48168156",
"0.4815694",
"0.48097968",
"0.48017895",
"0.47900453",
"0.4782826",
"0.47522974",
"0.47464633",
"0.4713747",
"0.46979213",
"0.4691... | 0.7901851 | 0 |
Return the default mapper. | def _get_default_mapper(self):
return self._datamappers['*/*'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_default_mapper(self, mapper):\n\n mapper = mapper or DataMapper()\n self._datamappers['*/*'] = mapper",
"def mapper(self):\n if not self._fitted:\n raise ValueError(\"Cannot get mapper if object has not been fitted.\")\n return self._mapper.copy()",
"def _get_mapp... | [
"0.6871667",
"0.6705098",
"0.66739136",
"0.65977365",
"0.6307456",
"0.62351674",
"0.6097825",
"0.5983813",
"0.59388465",
"0.57689005",
"0.5738587",
"0.57277805",
"0.57277805",
"0.5723523",
"0.56839365",
"0.562199",
"0.5607039",
"0.5599599",
"0.5549087",
"0.553436",
"0.5475148... | 0.8958518 | 0 |
Return the mapper based on the given name. | def _get_mapper(self, mapper_name):
if mapper_name in self._datamappers:
# mapper found
return self._datamappers[mapper_name]
else:
# unsupported format
return self._unknown_format(mapper_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup(self, name):\n try:\n return self._baseLookup(name)\n except ImportError:\n raise ImportError(\"No module named %r in mapper %r\" % (name, self))",
"def get(cls, name):\n cls.initialize()\n if isinstance(name, cls):\n return name\n el... | [
"0.69885236",
"0.6523901",
"0.64461076",
"0.63601327",
"0.6340254",
"0.6093008",
"0.60604954",
"0.60452425",
"0.59643584",
"0.5960165",
"0.59453994",
"0.589722",
"0.5801919",
"0.567288",
"0.5612674",
"0.5609351",
"0.55997974",
"0.559257",
"0.55712503",
"0.5496303",
"0.5479467... | 0.7992836 | 0 |
Get name from ContentType header | def _get_name_from_content_type(self, request):
content_type = request.META.get('CONTENT_TYPE', None)
if content_type:
# remove the possible charset-encoding info
return util.strip_charset(content_type)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_type_header(request: Request) -> str:\n return request.content_type",
"def gettype(self, failobj=None):\n missing = []\n value = self.get('content-type', missing)\n if value is missing:\n return failobj\n return re.split(r';\\s*', value.strip())[0].lower()",
... | [
"0.6892327",
"0.6575444",
"0.65093666",
"0.6481238",
"0.6447588",
"0.63857204",
"0.6333128",
"0.63329685",
"0.6310448",
"0.6281364",
"0.6262302",
"0.62129503",
"0.6198477",
"0.61856425",
"0.608376",
"0.60403216",
"0.5957448",
"0.5953572",
"0.59456986",
"0.5944716",
"0.5935226... | 0.78704923 | 0 |
Determine short name for the mapper based on the URL. Short name can be either in query string (e.g. ?format=json) or as an extension to the URL (e.g. myresource.json). | def _get_name_from_url(self, request):
format = request.GET.get('format', None)
if not format:
match = self._format_query_pattern.match(request.path)
if match and match.group('format'):
format = match.group('format')
return format | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_name(request):\n url_name = False\n if request.resolver_match:\n url_name = request.resolver_match.url_name\n return {\"url_name\": url_name}",
"def shorten_url():\n return rh.shorten_url(request)",
"def _shortenUrl(self, url):\n posturi = \"https://www.googleapis.com/urlshort... | [
"0.6074111",
"0.6005944",
"0.5902819",
"0.58046716",
"0.5792287",
"0.5767634",
"0.57404774",
"0.57221323",
"0.57147455",
"0.5575753",
"0.5546919",
"0.5540886",
"0.553158",
"0.55257696",
"0.5518946",
"0.5516314",
"0.54784685",
"0.5469388",
"0.544259",
"0.54098177",
"0.5381609"... | 0.66325134 | 0 |
Deal with the situation when we don't support the requested format. | def _unknown_format(self, format):
raise errors.NotAcceptable('unknown data format: ' + format) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_format(self):\n raise NotImplementedError()",
"def _determine_format(self, request):\n return determine_format(request, self._meta.serializer, default_format=self._meta.default_format)",
"def validateWorkFormat(format):\n\n if not(format):\n return \"You must select a work ... | [
"0.7758894",
"0.6573002",
"0.6391546",
"0.6325112",
"0.62708557",
"0.6243621",
"0.6233522",
"0.6175671",
"0.6166886",
"0.61477107",
"0.61403495",
"0.60342926",
"0.60149646",
"0.6010532",
"0.5987411",
"0.5959781",
"0.5955787",
"0.5895473",
"0.58931667",
"0.58854645",
"0.588295... | 0.76091594 | 1 |
Check that the mapper has valid signature. | def _check_mapper(self, mapper):
if not hasattr(mapper, 'parse') or not callable(mapper.parse):
raise ValueError('mapper must implement parse()')
if not hasattr(mapper, 'format') or not callable(mapper.format):
raise ValueError('mapper must implement format()') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_signature(self, inputs, signature):\n pass",
"def verify_signature(self, inputs, signature):\n pass",
"def signature_check(dummy, *args, **kwargs):\n try:\n dummy(*args, **kwargs)\n return True\n\n except TypeError:\n return False",
"def _check_type(self):\... | [
"0.6831698",
"0.6831698",
"0.6462788",
"0.6245771",
"0.62307477",
"0.6047557",
"0.601151",
"0.5921455",
"0.59146875",
"0.5847448",
"0.58155686",
"0.57982296",
"0.577483",
"0.5725613",
"0.57252246",
"0.5719018",
"0.5713518",
"0.57050633",
"0.56824374",
"0.5622677",
"0.561941",... | 0.73222697 | 0 |
Return an airport code input after validating it | def airportCodeInput(self, prompt):
while True:
code = input(prompt).upper()
if code not in self.travel_db.airports:
print("Invalid airport code")
else:
return code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateAirport(self, code):\n print(code)\n if code in self.travel_db.airports:\n return True\n else:\n return False",
"def iata(code):\r\n if len(code) == 3:\r\n return code.upper()\r\n else:\r\n raise argparse.ArgumentTypeError(\"%s is not val... | [
"0.7340205",
"0.6232221",
"0.6139465",
"0.6118442",
"0.6065149",
"0.60150987",
"0.5987312",
"0.58300376",
"0.57871574",
"0.57339126",
"0.5719007",
"0.5665261",
"0.5665261",
"0.5665261",
"0.5651849",
"0.56237924",
"0.5594974",
"0.5574781",
"0.55745834",
"0.556082",
"0.55538803... | 0.81940216 | 0 |
Return a country name input after validating it | def countryInput(self, prompt):
while True:
name = input(prompt)
if name not in self.travel_db.countries:
print("Invalid country name. Please make sure name is capitalized.")
else:
return name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def country() -> str:",
"def valid_country(value: Any) -> str:\n value = cv.string(value)\n all_supported_countries = holidays.list_supported_countries()\n\n try:\n raw_value = value.encode(\"utf-8\")\n except UnicodeError as err:\n raise vol.Invalid(\n \"The country name or ... | [
"0.6980752",
"0.69086546",
"0.6828054",
"0.669586",
"0.66514415",
"0.66304183",
"0.6440515",
"0.64396936",
"0.6435864",
"0.6435098",
"0.6365185",
"0.63565147",
"0.6318801",
"0.6305565",
"0.62800944",
"0.6262626",
"0.6246364",
"0.6230827",
"0.62267274",
"0.62176657",
"0.607218... | 0.79892355 | 0 |
Return a currency code input after validaing it | def currencyInput(self, prompt):
while True:
code = input(prompt).upper()
if code not in self.travel_db.currencies:
print("Invalid currency code")
else:
return code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_currency(currency_code):\n try:\n rate = rates.get_rates(currency_code)\n return 0\n except:\n flash(f'Error: {currency_code} is not a valid currency')\n return 1",
"def get_currency(test_loop_count=None) -> str:\n loop_count = 0\n while True:\n try:\n ... | [
"0.6704559",
"0.6646507",
"0.6486832",
"0.62412405",
"0.6107163",
"0.60303926",
"0.600023",
"0.59911394",
"0.5982588",
"0.59745014",
"0.5958056",
"0.5924218",
"0.587548",
"0.58722013",
"0.5858742",
"0.5832311",
"0.5812267",
"0.5781818",
"0.5777066",
"0.5729549",
"0.5705858",
... | 0.7700206 | 0 |
Return True if airport code valid, False otherwise. | def validateAirport(self, code):
print(code)
if code in self.travel_db.airports:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_valid_code(self, code):\r\n return code in COUNTRY_CODES",
"def is_valid(postal_code):\n return bool(re.match(UK_POST_CODE_REGEX, postal_code, re.VERBOSE)) if postal_code else False",
"def check_code(item_code):\r\n # RA matches\r\n if re.match(r'^MCRNC[0-9]{4}\\.T$', item_code):\r\n ... | [
"0.70381415",
"0.6726082",
"0.64569366",
"0.6375067",
"0.630065",
"0.6263566",
"0.6250235",
"0.62470305",
"0.6238505",
"0.62053096",
"0.6156845",
"0.61343706",
"0.61318254",
"0.6113142",
"0.6089113",
"0.6086316",
"0.6080452",
"0.6008818",
"0.5969722",
"0.59552896",
"0.5907283... | 0.8865747 | 0 |
Return True if country_name valid, False otherwise. | def validateCountry(self, country_name):
if country_name in self.travel_db.countries:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_country():\n assert valid_country(\"Democratic Republic of Lungary\") is True\n assert valid_country(\"Kraznoviklandstan\") is True\n assert valid_country(\"kraznoviklandstan\") is True\n assert valid_country(\"KRAZNOVIKLANDSTAN\") is True\n\n assert valid_country(\"Democratic_Republi... | [
"0.7013575",
"0.700049",
"0.6939837",
"0.68034947",
"0.67918384",
"0.6622717",
"0.6601707",
"0.6583337",
"0.6476302",
"0.64751047",
"0.6429186",
"0.64257467",
"0.64110726",
"0.6369207",
"0.63588893",
"0.62856215",
"0.6275524",
"0.62537944",
"0.62458146",
"0.6229923",
"0.62293... | 0.8314883 | 0 |
Return True if currency_code valid, False otherwise. | def validateCurrency(self, currency_code):
if currency_code in self.travel_db.currencies:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_currency(currency_code):\n try:\n rate = rates.get_rates(currency_code)\n return 0\n except:\n flash(f'Error: {currency_code} is not a valid currency')\n return 1",
"def _is_valid_code(self, code):\r\n return code in COUNTRY_CODES",
"def is_valid(postal_cod... | [
"0.759342",
"0.70800674",
"0.6537341",
"0.62727094",
"0.62223756",
"0.619591",
"0.6130835",
"0.60933155",
"0.6079185",
"0.6059149",
"0.6046414",
"0.60261106",
"0.5977034",
"0.59302557",
"0.5910405",
"0.5875142",
"0.5865183",
"0.5845647",
"0.5834872",
"0.57638985",
"0.57544607... | 0.85613906 | 0 |
Return a dictionary of Currency objects, with key = currency code. Created from info stored in filename | def buildCurrencyDict(filename):
currencies = {}
with open(os.path.join("input", filename), "rt", encoding="utf8") as f:
reader = csv.reader(f)
for line in reader:
currencies[line[1]] = Currency(line[1], line[0], float(line[2]))
return currencies | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildCountryDict(filename, currencies_dict):\n # This function requires the currency dictionary to be built already.\n countries = {}\n with open(os.path.join(\"input\", filename), \"rt\", encoding=\"utf8\") as f:\n reader = csv.reader(f)\n for line in reader:\n ... | [
"0.70550233",
"0.6869403",
"0.6178886",
"0.61106163",
"0.59804064",
"0.59100264",
"0.5908569",
"0.59003896",
"0.58851796",
"0.58286935",
"0.58016914",
"0.57944894",
"0.57516325",
"0.5689539",
"0.5687478",
"0.56543136",
"0.56246847",
"0.56089044",
"0.56031054",
"0.5590987",
"0... | 0.84670454 | 0 |
Return a dictionary of Country objects, with key = country name. Created from info stored in filename | def buildCountryDict(filename, currencies_dict):
# This function requires the currency dictionary to be built already.
countries = {}
with open(os.path.join("input", filename), "rt", encoding="utf8") as f:
reader = csv.reader(f)
for line in reader:
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildAirportDict(filename, countries_dict): \n # This function requires the country dictionary to be built already.\n airports = {}\n with open(os.path.join(\"input\", filename), \"rt\", encoding=\"utf8\") as f:\n reader = csv.reader(f)\n for line in reader:\n ... | [
"0.65897286",
"0.64826685",
"0.6389784",
"0.6383171",
"0.6335359",
"0.62931234",
"0.6252615",
"0.62445325",
"0.6109666",
"0.6080601",
"0.6028311",
"0.60078806",
"0.5918966",
"0.588614",
"0.5876146",
"0.5860082",
"0.5792945",
"0.576631",
"0.57317054",
"0.5713805",
"0.5710851",... | 0.74422234 | 0 |
Return a dictionary of Airport objects, with key = airport code. Created from info stored in filename | def buildAirportDict(filename, countries_dict):
# This function requires the country dictionary to be built already.
airports = {}
with open(os.path.join("input", filename), "rt", encoding="utf8") as f:
reader = csv.reader(f)
for line in reader:
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def triplify(self):\n airports = {}\n with open(self.source_file_path, 'r') as csvfile:\n reader = csv.reader(csvfile, delimiter=\",\")\n for i, row in enumerate(reader):\n if i != 0:\n # even if it says that data is encoded to latin-1, it actua... | [
"0.70951945",
"0.7048426",
"0.68105704",
"0.67958844",
"0.67303306",
"0.660992",
"0.6241538",
"0.6214554",
"0.60528135",
"0.5989924",
"0.59378284",
"0.5857952",
"0.58015823",
"0.55762887",
"0.55647373",
"0.554717",
"0.5545705",
"0.5532614",
"0.551982",
"0.5506063",
"0.5496964... | 0.7226677 | 0 |
Return a list of routes from a file, in the format [name, [airport code list]]. Return None if file not found. | def getRouteInputFile(filename):
if filename[-4:] != ".csv": # Make sure the filename is a .csv
return None
routes = []
try:
with open(os.path.join("input", filename), "rt", encoding="utf8") as f:
reader = csv.reader(f)
for line in read... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_routes_file(route_filename):\n\n list_route_descriptions = []\n tree = ET.parse(route_filename)\n for route in tree.iter(\"route\"):\n route_town = route.attrib['map']\n route_id = route.attrib['id']\n waypoint_list = [] # the list of waypoints that can be found on this rou... | [
"0.6682189",
"0.61099017",
"0.60007584",
"0.59836805",
"0.59614146",
"0.585794",
"0.58239037",
"0.57957166",
"0.5757466",
"0.5705301",
"0.5684137",
"0.5619704",
"0.5542456",
"0.55303",
"0.5512766",
"0.5511307",
"0.5509003",
"0.54854715",
"0.5457731",
"0.54531974",
"0.54459774... | 0.6995897 | 0 |
Create a csv input file, given a list of routes. Routes are lists of names and airport codes. | def writeRoutesCSV(filename, routes):
if filename[-4:] != ".csv": # Make sure the filename is a .csv
filename += ".csv"
try:
with open(os.path.join("input", filename), "w", newline='') as f:
writer = csv.writer(f, delimiter=",")
writer.writerow... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route_data(route):\n os.chdir(\"../Data/test\") #change to whatever directory your data files are stored in\n with open(\"../Sorted Data/\"+str(route)+\"_data.csv\",\"w\",newline=\"\") as result_file: #storing resulting data in csv file in different directory\n wr=csv.writer(result_file, dialect='... | [
"0.6899799",
"0.66672605",
"0.6458159",
"0.63670135",
"0.634914",
"0.63457423",
"0.63208055",
"0.6306807",
"0.6239996",
"0.62074065",
"0.6170774",
"0.60570943",
"0.6028385",
"0.6027313",
"0.60171574",
"0.60073507",
"0.59914494",
"0.59842396",
"0.5965804",
"0.59501034",
"0.591... | 0.7744267 | 0 |
Write output .csv file for list of itineraries. Output file shows cheapest route and its cost. | def writeItineraryOutput(filename, itins):
if filename[-4:] != ".csv": # Make sure the filename is a .csv
filename += ".csv"
try:
with open(os.path.join("output", filename), "w", newline='') as f:
writer = csv.writer(f, delimiter=",")
firstline... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_csv(net, wires, net_id, chip_id, chip):\n with open('output/output.csv', 'w') as file:\n # Write first line\n output = csv.writer(file)\n output.writerow([\"net\", \"wires\"])\n\n # Index and fill the body\n for step in range(len(wires)):\n output.writerow(... | [
"0.654631",
"0.64892834",
"0.6398828",
"0.6333328",
"0.6306452",
"0.62436354",
"0.6238039",
"0.6226846",
"0.6123271",
"0.6066527",
"0.6055366",
"0.6047722",
"0.6046962",
"0.6041532",
"0.6025302",
"0.60197496",
"0.6000928",
"0.5996336",
"0.59933907",
"0.5990987",
"0.5989872",
... | 0.7681153 | 0 |
Create an input file with randomly generated routes for num_people. | def generateRandomInput(filename, num_people, travel_db):
import random
routes = []
for i in range(num_people):
route = travel_db.randomRoute()
route.insert(0,"Person " + str(i)) # Add a name for each route.
routes.append(route)
if FileHandler.writeRo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_input_file(self, filename, numlines, maxvalue):\n with open(filename, 'a') as f:\n for _ in range(numlines):\n f.write(str(randrange(maxvalue)) + '\\n')\n self.filepath = f.name",
"def routes_gen(num) -> Generator[Route, None, None]:\n with open(f'data/route-... | [
"0.587769",
"0.5856231",
"0.56174666",
"0.55805063",
"0.55153143",
"0.5446747",
"0.54272777",
"0.54071355",
"0.5406519",
"0.5362641",
"0.5354671",
"0.53122556",
"0.5305677",
"0.5279175",
"0.5232032",
"0.5200919",
"0.51978534",
"0.518729",
"0.51755005",
"0.5140269",
"0.5115986... | 0.84894335 | 0 |
Tests API call to fetch multiple NS descriptor resources | def test_get_ns_descriptors(get_ns_descriptors_keys):
sonata_nsd = SONATAClient.Nsd(HOST_URL)
sonata_auth = SONATAClient.Auth(HOST_URL)
_token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
_token = json.loads(_token["data"])
response = json.loads(sonata_nsd.get_ns_descr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_many_descriptors(self, uuids):",
"def test_multiple_gets(uris):\n\n for uri in uris:\n print('='*10 + ' Try uri : {uri} '.format(uri=uri) + '='*10)\n resp = get_api_url(uri)\n print(resp)\n try:\n pprint(resp.json())\n except Exception as e:\n p... | [
"0.6480714",
"0.64030355",
"0.63878626",
"0.633152",
"0.61416095",
"0.6027618",
"0.59268606",
"0.5893378",
"0.5883436",
"0.5867936",
"0.5860991",
"0.58218473",
"0.58013874",
"0.5790113",
"0.5780573",
"0.5772255",
"0.57513046",
"0.5746608",
"0.5731543",
"0.5729499",
"0.5722015... | 0.65850234 | 0 |
Tests API call to read information about an NS descriptor resources | def test_get_ns_descriptors_nsdinfoid():
sonata_nsd = SONATAClient.Nsd(HOST_URL)
sonata_auth = SONATAClient.Auth(HOST_URL)
_token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
_token = json.loads(_token["data"])
_nsd_list = json.loads(sonata_nsd.get_ns_descriptors(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_ns_descriptors(get_ns_descriptors_keys):\r\n sonata_nsd = SONATAClient.Nsd(HOST_URL)\r\n sonata_auth = SONATAClient.Auth(HOST_URL)\r\n _token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))\r\n _token = json.loads(_token[\"data\"])\r\n\r\n response = json.loads(sona... | [
"0.64663666",
"0.608117",
"0.5999047",
"0.5969652",
"0.59466934",
"0.59190524",
"0.5892444",
"0.5845748",
"0.5732233",
"0.5668746",
"0.5648303",
"0.5639067",
"0.56217575",
"0.56203",
"0.56144845",
"0.5610858",
"0.5607481",
"0.560151",
"0.5600352",
"0.55998194",
"0.5585602",
... | 0.70114577 | 0 |
Tests API call to delete NS descriptor resources | def test_delete_ns_descriptors_nsdinfoid(delete_ns_descriptors_nsdinfoid_keys):
sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
sonata_nsd = SONATAClient.Nsd(HOST_URL)
sonata_auth = SONATAClient.Auth(HOST_URL)
_token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
_token = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_on_background_response_descriptor_projects_release_release_resource_spaces(self):\n pass",
"def test_delete_on_background_response_descriptor_projects_release_release_resource(self):\n pass",
"def test_delete_on_background_response_descriptor_subscriptions_subscription_subscriptio... | [
"0.70575756",
"0.68376297",
"0.67838246",
"0.66237175",
"0.64669347",
"0.64376366",
"0.64376366",
"0.6399817",
"0.6381159",
"0.63791645",
"0.63716006",
"0.6369237",
"0.6348905",
"0.6325135",
"0.6323571",
"0.62920225",
"0.62577426",
"0.62550163",
"0.6228073",
"0.62071025",
"0.... | 0.70335805 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.