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 |
|---|---|---|---|---|---|---|
Draw the network to a file. Only label the candidate nodes; the friend nodes should have no labels (to reduce clutter). | def draw_network(graph, users, filename):
###TODO-- Completed
candidate_names = [user['screen_name'] for user in users]
plt.figure(figsize=(12,12))
candidate_labels = {node: node if node in candidate_names else '' for node in graph.nodes_iter()}
#print(candidate_labels)
nx.draw_networkx(graph, l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_network(graph, filename):\n plt.figure(figsize=(12,12))\n nx.draw_networkx(graph, with_labels=False, alpha=.5, width=.1, node_size=100)\n plt.axis(\"off\")\n plt.savefig(filename, format=\"PNG\")",
"def draw_graph(self, out_path):\n # Define layout for network, with increased distance... | [
"0.675565",
"0.6560529",
"0.6427169",
"0.6395321",
"0.63243383",
"0.62498444",
"0.6215251",
"0.619651",
"0.6190271",
"0.6129893",
"0.6124176",
"0.60744816",
"0.6064628",
"0.603491",
"0.5996798",
"0.59650636",
"0.5946393",
"0.5939295",
"0.59302545",
"0.592903",
"0.5917938",
... | 0.7188244 | 0 |
log() if (level <= loglevel), text is appended to logfile with date/time prepended (nothing is ever logged when loglevel is 0). If (level <= adminlevel) then store log in adminlog list (never store anything if adminlevel is 0). | def log(text='', level=1):
if loglevel == 0 and adminlevel == 0:
return 0 # not logged
datetime = time.asctime(time.localtime(time.time()))
threadname = threading.currentThread().getName()
logtext = "%s (%s)[%d]:%s\n" % (datetime,threadname,level,text)
logged = 0 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __log(level, message):\n if level == 1:\n logging.info(\" \" + str(datetime.datetime.now()) + \" \" + message)\n if level == 2:\n logging.error(\" \" + str(datetime.datetime.now()) + \" \" + message)\n if level == 3:\n logging.critical(\" \" + str(datetime.datetime.now()) + \" \" ... | [
"0.7120623",
"0.6867098",
"0.68032545",
"0.67844707",
"0.6657922",
"0.659959",
"0.6585036",
"0.6573275",
"0.6534616",
"0.6531102",
"0.6517555",
"0.64893204",
"0.63999486",
"0.63679504",
"0.6358388",
"0.6331364",
"0.62842757",
"0.62459934",
"0.6222694",
"0.6216095",
"0.6211309... | 0.82989186 | 0 |
sendadminlog() send adminlog list to adminemail only if there is something in this list. If override==1 then admin_notify times are ignored. | def sendadminlog( override=0 ):
global admin_notify_time
global adminlog
if override == 0:
# if no admin_notify_time set, set one and return
if admin_notify_time == 0:
admin_notify_time = time.time() + admin_notify
return
# if time hasn't reached admin_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emailAdmin(ip, nrLoggedEmails, lastLog):\n \n msg = lastLog[1]\n toEmail = lastLog[2]\n\n msg = \"VARNING! En dator med IP-nummer %s har skickat fler än max-antal e-postmeddelanden under angivet tidsintervall.\\n\\n\" % (ip)\n msg += \"Utdrag från senaste loggade mejlet:\\n\\nIP: %s\\nMottagare:... | [
"0.6240995",
"0.55472285",
"0.55336624",
"0.5529787",
"0.5498411",
"0.5475561",
"0.5449685",
"0.53409684",
"0.5289263",
"0.52011275",
"0.5185836",
"0.5131691",
"0.5124156",
"0.510098",
"0.510057",
"0.50931907",
"0.5059404",
"0.50396657",
"0.50167394",
"0.49878448",
"0.4984303... | 0.842474 | 0 |
returns the percentage of false classification for the given resultsets produced by different models. Only images useable in all set are being considered | def get_percentage_false_class(arr_of_results):
count_success = np.zeros_like(arr_of_results[:,0], dtype=float)
count_correct_prediction = 0
for i in range(len(arr_of_results[0])):
use = True
for result in arr_of_results[:,i]:
if result["image_target"] != result["prediction_ima... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_percentage_false_class_for_resultset(results):\n count_success = 0\n count_correct_prediction = 0\n for result in results:\n if result[\"image_target\"] == result[\"prediction_image\"] and result[\"std_noise\"] != 0:\n count_correct_prediction += 1\n if result[\"success\"]... | [
"0.7694963",
"0.672696",
"0.65284353",
"0.63181716",
"0.6223898",
"0.6206021",
"0.6175322",
"0.61252534",
"0.60787153",
"0.6074429",
"0.6055192",
"0.60469633",
"0.6035008",
"0.6032113",
"0.6022166",
"0.6010247",
"0.60080314",
"0.60068935",
"0.59958446",
"0.59958446",
"0.59928... | 0.7144237 | 1 |
Map a value v in range [0,1] to discrete ordinal classes | def to_ordinal(v, classes):
k = len(classes)
# Map position to discrete space
n1 = k/(1+exp(-v))
# Add Gaussian noise and round
n2 = round(random.gauss(n1, sigma*(k-1)))
n3 = min(k-1, max(n2, 0))
return classes[n3] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_class(numlist,classlist=string.ascii_lowercase):\n\n return np.vectorize(lambda t: classlist[t])(numlist)",
"def to_class(numlist,classlist=string.ascii_lowercase):\n\n return np.vectorize(lambda t: classlist[t])(numlist)",
"def convertclasstoemotion(pred):\n \n label_conversion = {'... | [
"0.5957351",
"0.5957351",
"0.59515435",
"0.57738507",
"0.57738507",
"0.5687176",
"0.5631008",
"0.5593928",
"0.5533812",
"0.5503168",
"0.5502713",
"0.5470743",
"0.54443735",
"0.5438498",
"0.54172623",
"0.5414011",
"0.53954643",
"0.53954643",
"0.53868306",
"0.5372418",
"0.53724... | 0.7464597 | 0 |
Returns True if parameter is one of the continuous parameters defined in continuous_params | def is_continuous(parameter):
return sum([isinstance(parameter, p) for p in continuous_params])>0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isActiveFitParam(param):\n return isFitParam(param) and param.isActive()",
"def is_bounded_continuous_variable(self):\n for rv in self.unique_variables:\n if not is_bounded_continuous_variable(rv):\n return False\n return True",
"def check(self, parameters):\n ... | [
"0.65586585",
"0.6500868",
"0.63482386",
"0.61473125",
"0.6105592",
"0.60367113",
"0.6024447",
"0.60074943",
"0.5997103",
"0.5964175",
"0.5911737",
"0.5889686",
"0.5884454",
"0.5884159",
"0.57671905",
"0.5730443",
"0.5730346",
"0.57129663",
"0.5712339",
"0.56427324",
"0.56163... | 0.8774252 | 0 |
return all envs and groups from all env groups | def all(self):
for group in self.groups():
yield group
for env in self.envs():
yield env | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def envs(self):\n for member in self.members:\n if not isinstance(member, EnvGroup):\n yield member\n continue\n for member in member.envs():\n yield member",
"def get_all_environments():\n return ENVIRONMENTS",
"def get_environments(... | [
"0.7548125",
"0.73480403",
"0.7321437",
"0.7285775",
"0.7087299",
"0.68996537",
"0.6339232",
"0.6245589",
"0.6203714",
"0.6185317",
"0.6175391",
"0.61400133",
"0.6139779",
"0.61358243",
"0.6125854",
"0.6088253",
"0.60369086",
"0.5976081",
"0.5975712",
"0.59464973",
"0.5931734... | 0.7772515 | 0 |
Validate config plugins directories. Check for existence. And build plugins_idx | def _inspect_plugins_dirs(self):
plugins_dirs = getattr(self, 'plugins_dirs')
wrong_dirs = []
for _dir in plugins_dirs:
if not op.isdir(_dir):
wrong_dirs.append(_dir)
else:
# NOTE: if there will be plugins with the same name,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_plugins(self, system, partial_root):\n for root, dirs, files in os.walk(self.directory.path):\n relroot = os.path.relpath(root, self.directory.path)\n splitrelroot = relroot.split(os.sep)\n\n # Skips hidden directories\n hiddendir = False\n fo... | [
"0.6157365",
"0.59965396",
"0.58586574",
"0.576763",
"0.5736396",
"0.5676494",
"0.55941546",
"0.55827403",
"0.55580056",
"0.55318683",
"0.5510506",
"0.5484215",
"0.5465382",
"0.54620993",
"0.54562",
"0.54523844",
"0.5444869",
"0.5432267",
"0.5404659",
"0.53671473",
"0.5358415... | 0.6379896 | 0 |
Get monitoring checks objects | def get_monitoring_checks(self):
logger.debug('Getting monitoring checks')
plugins_dirs = getattr(self, 'plugins_dirs')
monitoring_checks = []
for service_desc, cmd in getattr(self, 'commands').items():
try:
plugin_name = cmd.split()[0]
except Inde... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checks(self):\r\n return checks.Checks(self)",
"def health_checks(self):\n return [self.check_device_connected, self.check_clear_flags]",
"def get_result(self):\n check_result_list = []\n for check in self.monitoring_checks:\n try:\n result = check.execute(... | [
"0.65733325",
"0.6363684",
"0.62054473",
"0.60702723",
"0.6051944",
"0.59617114",
"0.5931713",
"0.5846798",
"0.57369745",
"0.5709225",
"0.5654841",
"0.5577679",
"0.55522555",
"0.5534278",
"0.5504183",
"0.5498289",
"0.54719675",
"0.53983575",
"0.5397788",
"0.5354331",
"0.53518... | 0.7412881 | 0 |
Get monitoring check result for monitoring checks list | def get_result(self):
check_result_list = []
for check in self.monitoring_checks:
try:
result = check.execute()
except ForbiddenCheckError as err:
logger.error(err)
else:
check_result_list.append(result)
if check... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_ResultCheck(self):\n try:\n cmd = self.ExecutionTask.get_param().split(',')\n logging.debug(\"%s-%s-%s-%s-%s\" % ( TestScriptSymbolTable.get_value_from_sym_tab(cmd[0], TestScriptSymbolTable.test_script_sym_tab),cmd[0], cmd[1], cmd[2], cmd[3]))\n\n checkval = cmd[... | [
"0.63706166",
"0.62025386",
"0.6151091",
"0.6064086",
"0.6039532",
"0.5976944",
"0.5972677",
"0.58945674",
"0.58764076",
"0.58144605",
"0.5788281",
"0.57788694",
"0.5717188",
"0.57067704",
"0.56888074",
"0.56824183",
"0.5677777",
"0.5654893",
"0.56247807",
"0.5588808",
"0.557... | 0.80645454 | 0 |
This URL is a test to be sure that the DaemonServer can handle a request | def index(request):
return requests.get(DaemonServer._mock_url + '/') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_http_request(self):\n\n response = requests.get(self.live_server_url)\n assert response.status_code == 200",
"def test_url():\r\n global provided_url\r\n global verbose_flag\r\n # extracting url\r\n provided_url = urlparse(provided_url).scheme+\"://\"+urlparse(provided_url).net... | [
"0.70002085",
"0.66061354",
"0.65519416",
"0.6421083",
"0.63537407",
"0.6349542",
"0.6303565",
"0.62201357",
"0.62109095",
"0.62078255",
"0.6168145",
"0.6095292",
"0.60952",
"0.60858065",
"0.6082953",
"0.60637474",
"0.6036982",
"0.6025642",
"0.6015954",
"0.5986596",
"0.598133... | 0.67284894 | 1 |
Get a specific plugin | def get_plugin(request):
res = requests.get(DaemonServer._mock_url + '/plugins/' + request.url_vars['id'])
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_plugin(self, name):",
"def get_plugin(group, name):\n return _get_plugins(group, name)[name]",
"def get_plugin(name):\n for plugin in IPluginRegistry.plugins:\n if name in plugin.__name__:\n return plugin\n raise ValueError(\"The plugin %s cannot be found.\" % name)",
"def ... | [
"0.81705546",
"0.764261",
"0.7561231",
"0.75498444",
"0.7343164",
"0.73150814",
"0.7270925",
"0.7243109",
"0.7181925",
"0.6945842",
"0.69209474",
"0.6799585",
"0.6742429",
"0.6742429",
"0.6724079",
"0.6690348",
"0.6649153",
"0.66339684",
"0.66067374",
"0.65749896",
"0.6569533... | 0.7715446 | 1 |
Start the DaemonServer by listening on the specified adress | def run(self, adress='127.0.0.1', port=8001):
self._httpd = HTTPServer((adress, port), HTTPRequestHandler)
self._is_running = True
self._th = Thread(None, self._httpd.serve_forever)
self._th.start()
print('DaemonServer is listening on %s:%d' % (adress, port)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_server():\n server.bind(constants.ADDRESS)\n server.listen()\n print(\"Server listening on: \" + constants.HOST + \" on port \" + str(constants.PORT) + \"...\")",
"def start(args):\n # Create the controller\n factory = ServerFactory(args)\n \n protocol = dns.DNSDatagramProtocol(con... | [
"0.7455192",
"0.7074131",
"0.69037455",
"0.6892851",
"0.6880499",
"0.68164194",
"0.68122846",
"0.6771114",
"0.6757552",
"0.67320347",
"0.67300195",
"0.66931385",
"0.66920185",
"0.6678358",
"0.6541331",
"0.653898",
"0.6517115",
"0.6511139",
"0.6464294",
"0.64501506",
"0.641022... | 0.73815656 | 1 |
Check a packetin message. Build and output a packetout. | def packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
port = msg.match['in_port']
gateway = self.gateway_get(datapath.id)
if gateway is None:# or gateway.idc_id != CONF.idc_id:
return
pkt = packet.Packet(msg.data)
pkt_ethernet = pkt.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _packet_in(self, ev):\n\n dp = ev.msg.datapath\n ofp = dp.ofproto\n parser = dp.ofproto_parser\n match = ev.msg.match\n\n ##SNDCP packet with multiple fragments recieved - print warning, send ICMP fragmentation needed\n ##TODO: Not WOrking correctly\n ## File \"... | [
"0.6235294",
"0.61506945",
"0.6109243",
"0.601377",
"0.59785503",
"0.5961816",
"0.5922923",
"0.5854635",
"0.5806374",
"0.55882084",
"0.55190057",
"0.5492686",
"0.54621166",
"0.54290426",
"0.5427576",
"0.541186",
"0.5380287",
"0.53389305",
"0.53269714",
"0.5293727",
"0.5293053... | 0.6294702 | 0 |
Start all remote servers and one local server. | def _start_servers(self):
for user, host, port in self.server_addresses:
remoteHost = "%s@%s" % (user, host)
logger.info("starting remote server %s:%s", host, port)
command = ("cd ~/goaway;" +
"find . -name '*.pyc' -delete ;" +
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(self):\r\n for srv in self._servers:\r\n srv.start()",
"def start_servers(self, **kwargs):\n self.cleanup()\n\n # Start up the API and default conductor server\n\n # We start the conductor server first, as the API server config\n # depends on the conductor ... | [
"0.7768984",
"0.7032133",
"0.6721577",
"0.6698385",
"0.65687376",
"0.6535655",
"0.6447551",
"0.6397013",
"0.63623345",
"0.6346815",
"0.6252066",
"0.6190625",
"0.6175915",
"0.61642206",
"0.6139815",
"0.6139815",
"0.6128373",
"0.6106354",
"0.60582894",
"0.60406834",
"0.60241026... | 0.8314969 | 0 |
Wait for all servers to become alive. | def wait_for_servers(self, timeout):
for user, host, port in self.server_addresses:
if not self.wait_for_server(user, host, port, timeout):
logging.warn("could not start server %s:%s:%s", user, host, port)
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_all():\n global alive\n\n try:\n while alive > 0:\n gevent.sleep(1)\n finally: \n signal.setitimer(signal.ITIMER_REAL, 0)",
"def __wait_for_master_ssh( self ):\n for _ in itertools.count( ):\n s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )\n ... | [
"0.74015445",
"0.718989",
"0.68756485",
"0.67319417",
"0.6638677",
"0.66021174",
"0.6596358",
"0.6572008",
"0.6525765",
"0.64510643",
"0.64422387",
"0.64345455",
"0.64319974",
"0.64055943",
"0.6364728",
"0.6302922",
"0.6285464",
"0.6269691",
"0.62687176",
"0.62614435",
"0.623... | 0.76050067 | 0 |
Wait until this many bytes available in the serial buffer. | def waitforAndRead(self, size):
while self.device.inWaiting() < size:
pass
else:
return self.device.read(size) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _serial_bytes_available(self):\n return self.serial.in_waiting",
"async def _wait_for_data(self, current_command, number_of_bytes):\n while number_of_bytes:\n next_command_byte = await self.read()\n current_command.append(next_command_byte)\n number_of_bytes -= ... | [
"0.7088853",
"0.6867825",
"0.6855532",
"0.67480516",
"0.67391396",
"0.6630244",
"0.66225225",
"0.6618195",
"0.6595421",
"0.6574406",
"0.6466141",
"0.6452985",
"0.644309",
"0.6389591",
"0.6388041",
"0.6383351",
"0.63777477",
"0.6309587",
"0.6277611",
"0.6259124",
"0.6258118",
... | 0.69288653 | 1 |
si le nombre de reponse fausse est superieur a 1, le mot fautes'accorde au pluriel | def singPlur(repFausses):
if repFausses <= 1:
return "faute"
else:
return "fautes" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nom(self, i):\n pass",
"def editar_repet(self, repet: int):\n comprep(repet)\n self.repet = repet",
"def fim_da_rodada(self, recompensa, m, numero_de_cacadores):\n #print('Jogador 4 {}'.format(self.historico[-1]))\n pass",
"def enchere(self):\n\n i = 0\n ... | [
"0.62046045",
"0.60625553",
"0.60084254",
"0.5907415",
"0.5833081",
"0.5792889",
"0.57927155",
"0.5534922",
"0.55008006",
"0.54808915",
"0.54408365",
"0.54359406",
"0.5429279",
"0.5413033",
"0.5403856",
"0.53419846",
"0.5325032",
"0.53236884",
"0.53136164",
"0.5293597",
"0.52... | 0.63280576 | 0 |
Calculate fee based in the transaction size and the price per KiB. | def estimate_fee(estimated_size: int, fee_kb: int) -> int:
return int(estimated_size * fee_kb / 1024.0 + 0.5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fee(self, prices, fee):\n return self.volume(prices) * fee.value / Config.FEE_TOKEN_PRICE",
"def get_fee(self):\n fee = round(self.order_payment.amount * Decimal(0.015), 2)\n return fee",
"def calc_fee(fee_rate, memo=''):\n compiled_memo = compile_memo(memo) if memo else None\n f... | [
"0.65787834",
"0.6210678",
"0.6102024",
"0.6040983",
"0.60349977",
"0.60058254",
"0.59498155",
"0.59323287",
"0.58386",
"0.5809553",
"0.5750729",
"0.5715536",
"0.5650437",
"0.56102574",
"0.5606875",
"0.5598308",
"0.5562563",
"0.5497193",
"0.5484398",
"0.5471336",
"0.54295206"... | 0.69844055 | 0 |
Guess the transaction size based in the number of inputs and outputs. | def guess_transaction_size(inputs: list, outputs: dict) -> (str, int):
return 11 + 180 * len(inputs) + 34 * len(outputs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimateInputSize(scriptSize):\n return (\n 32 + 4 + 1 + 8 + 4 + 4 + wire.varIntSerializeSize(scriptSize) + scriptSize + 4\n )",
"def estimateSerializeSize(scriptSizes, txOuts, changeScriptSize):\n # Generate and sum up the estimated sizes of the inputs.\n txInsSize = 0\n for size in sc... | [
"0.7029825",
"0.7007875",
"0.6962185",
"0.67556745",
"0.65276957",
"0.64963466",
"0.6445923",
"0.6393347",
"0.6393045",
"0.6308914",
"0.63059366",
"0.63059366",
"0.6296995",
"0.62882775",
"0.6285022",
"0.6279971",
"0.62792987",
"0.62775767",
"0.6254468",
"0.62371427",
"0.6222... | 0.842755 | 0 |
This method handles the GET requests to retrieve status on agents from the Registrar Server. Currently, only agents resources are available for GETing, i.e. /agents. All other GET uri's will return errors. agents requests require a single agent_id parameter which identifies the agent to be returned. If the agent_id is ... | def do_GET(self):
rest_params = common.get_restful_params(self.path)
if rest_params is None:
common.echo_json_response(self, 405, "Not Implemented: Use /agents/ interface")
return
if "agents" not in rest_params:
common.echo_json_response(self, 400, "uri not s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n rest_params = common.get_restful_params(self.request.uri)\n if rest_params is None:\n common.echo_json_response(self, 405, \"Not Implemented: Use /agents/ interface\")\n return\n\n if \"agents\" not in rest_params:\n common.echo_json_response(s... | [
"0.81517375",
"0.65542585",
"0.6447016",
"0.6362145",
"0.6153569",
"0.6149206",
"0.60159767",
"0.59956706",
"0.5976985",
"0.59005296",
"0.58650035",
"0.5843438",
"0.5789323",
"0.5787094",
"0.57232255",
"0.56539154",
"0.5580563",
"0.5537036",
"0.551887",
"0.54844165",
"0.54745... | 0.83628625 | 0 |
This method handles the DELETE requests to remove agents from the Registrar Server. Currently, only agents resources are available for DELETEing, i.e. /agents. All other DELETE uri's will return errors. agents requests require a single agent_id parameter which identifies the agent to be deleted. | def do_DELETE(self):
rest_params = common.get_restful_params(self.path)
if rest_params is None:
common.echo_json_response(self, 405, "Not Implemented: Use /agents/ interface")
return
if "agents" not in rest_params:
common.echo_json_response(self, 400, "uri no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self):\n rest_params = common.get_restful_params(self.request.uri)\n if rest_params is None:\n common.echo_json_response(self, 405, \"Not Implemented: Use /agents/ interface\")\n return\n\n if \"agents\" not in rest_params:\n common.echo_json_respons... | [
"0.83328235",
"0.717082",
"0.70636654",
"0.6921048",
"0.69137836",
"0.670038",
"0.66952145",
"0.6065606",
"0.5701796",
"0.56838745",
"0.5650526",
"0.5548786",
"0.54742306",
"0.5472352",
"0.54185456",
"0.54131997",
"0.54131997",
"0.54131997",
"0.54131997",
"0.54131997",
"0.541... | 0.8437115 | 0 |
This method handles the POST requests to add agents to the Registrar Server. Currently, only agents resources are available for POSTing, i.e. /agents. All other POST uri's will return errors. POST requests require an an agent_id identifying the agent to add, and json | def do_POST(self):
rest_params = common.get_restful_params(self.path)
if rest_params is None:
common.echo_json_response(self, 405, "Not Implemented: Use /agents/ interface")
return
if "agents" not in rest_params:
common.echo_json_response(self, 400, "uri not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self):\n try:\n rest_params = common.get_restful_params(self.request.uri)\n if rest_params is None:\n common.echo_json_response(self, 405, \"Not Implemented: Use /agents/ interface\")\n return\n\n if \"agents\" not in rest_params:\n ... | [
"0.7403621",
"0.65014863",
"0.63130796",
"0.616501",
"0.57305866",
"0.56719697",
"0.5531976",
"0.55056393",
"0.5445917",
"0.5390362",
"0.5374244",
"0.5350049",
"0.5341212",
"0.53108996",
"0.5275562",
"0.52541816",
"0.5252334",
"0.52314633",
"0.519691",
"0.51821196",
"0.515735... | 0.7357061 | 1 |
This method handles the PUT requests to add agents to the Registrar Server. Currently, only agents resources are available for PUTing, i.e. /agents. All other PUT uri's will return errors. | def do_PUT(self):
rest_params = common.get_restful_params(self.path)
if rest_params is None:
common.echo_json_response(self, 405, "Not Implemented: Use /agents/ interface")
return
if "agents" not in rest_params:
common.echo_json_response(self, 400, "uri not s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self):\n try:\n rest_params = common.get_restful_params(self.request.uri)\n if rest_params is None:\n common.echo_json_response(self, 405, \"Not Implemented: Use /agents/ interface\")\n return\n\n if \"agents\" not in rest_params:\n ... | [
"0.7346292",
"0.66388345",
"0.63099504",
"0.5964193",
"0.59574366",
"0.58821076",
"0.56671065",
"0.56290895",
"0.56259966",
"0.5612662",
"0.5565945",
"0.55049163",
"0.5471636",
"0.5446584",
"0.5415216",
"0.5295331",
"0.51881486",
"0.5173341",
"0.5171275",
"0.5155832",
"0.5134... | 0.77525806 | 0 |
Build a task representation like `MyTask(param1=1.5, param2='5')` | def __repr__(self):
params = self.get_params()
param_values = self.get_param_values(params, [], self.param_kwargs)
# Build up task id
repr_parts = []
param_objs = dict(params)
for param_name, param_value in param_values:
if param_objs[param_name].significant ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_task(module_name, args=[], kwargs={}, module_attrs={}):\n kwargs = copy.deepcopy(kwargs) # Copy to avoid argument passed by reference issue\n if args:\n kwargs[\"_raw_params\"] = \" \".join(args)\n\n task_data = {\n \"action\": {\n \"module\": mo... | [
"0.64628965",
"0.6422724",
"0.6353564",
"0.63443846",
"0.625492",
"0.62483037",
"0.61929274",
"0.61775887",
"0.6086991",
"0.6076463",
"0.60502404",
"0.59647053",
"0.5902241",
"0.58599955",
"0.5852859",
"0.5821661",
"0.5809856",
"0.57718843",
"0.57576394",
"0.5703558",
"0.5692... | 0.70445263 | 0 |
Find the source candidates (the ones who have not been found infected) Checks the final configurations (from data_["test"]) | def get_source_candidates(all_data_epigen):
candids = {s:
[np.where(np.array(c[1])!=0)[0] for c in mdata["test"] ]
for s, mdata in all_data_epigen.items()}
return candids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_candidates_list(self):\n pass",
"def test_check_source_2(self):\n self.eval_flags[\"check_id_typo\"] = False\n import_genome.check_source(self.src1, self.eval_flags,\n host_genus=\"Mycobacterium\")\n self.assertEqual(len(self.src1.evaluations... | [
"0.5934083",
"0.5801863",
"0.57194805",
"0.57038945",
"0.5695275",
"0.5662381",
"0.5629502",
"0.5607914",
"0.55140257",
"0.5501297",
"0.54986674",
"0.5470249",
"0.5362881",
"0.53098935",
"0.52713174",
"0.5263354",
"0.52497125",
"0.52446026",
"0.52430683",
"0.52268773",
"0.520... | 0.7038606 | 0 |
Get the source position (fraction of the number of candidates) Uses marginal distribution in shape N x T x q | def get_src_posit_obs_margs(margs, msources, candids):
psources = margs[:,0,1][candids]
idx=candids[psources.argsort()[::-1]]
#print(idx)
pos = np.mean([np.argmax(idx == s) for s in msources])
return pos/len(candids) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loc(self):\n return self.distribution.loc",
"def getPositionDistribution(self, position):\n dist = util.Counter()\n (x, y) = position\n total = 1.0\n dist[position] = 1.0\n\n if not self.walls[x + 1][y]:\n dist[(x + 1, y)] = 1.0\n total += 1.0\n if not self.walls[x - 1][y]:\n ... | [
"0.59985954",
"0.5844991",
"0.57710886",
"0.57066786",
"0.56944394",
"0.5637397",
"0.56237406",
"0.55892",
"0.5523165",
"0.5514936",
"0.54958504",
"0.5458601",
"0.5358698",
"0.53497237",
"0.5329066",
"0.53273976",
"0.5306407",
"0.53056574",
"0.52929187",
"0.5288644",
"0.52820... | 0.631222 | 0 |
Constructs the SAM topic weights file from the rest of the config. | def get_topic_weight_filename(config):
base = os.path.splitext(config['corpus'])[0]
return '%s--%dT.arff' % (base, config['T']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_from_file(self,params,weights_dict):\n\n self.name = params[keys._name]\n self.topology = params[keys._topology]\n self.learningRate = params[keys._learning_rate]\n self.momentum = params[keys._momentum]\n #self._outActiv_fun_key = params[keys._output_activation]\n ... | [
"0.5445772",
"0.52090114",
"0.5197359",
"0.51935154",
"0.51659477",
"0.51528746",
"0.5152159",
"0.50725466",
"0.50518197",
"0.5050541",
"0.5045867",
"0.5042122",
"0.50095546",
"0.500033",
"0.4996364",
"0.49739787",
"0.49723807",
"0.49618277",
"0.49463946",
"0.49391994",
"0.49... | 0.6615563 | 0 |
Constructs the SAM model filename from the rest of the config. | def get_model_filename(config):
base = os.path.splitext(config['corpus'])[0]
return '%s--%dT.model' % (base, config['T']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setupFilename(self):\n try:\n os.mkdir('./.netModel')\n except:\n pass # hope it's already there...\n filenames = os.listdir('./.netModel')\n configNum = 1\n i = 0\n configNumString = '%(c)04d' % {'c':configNum}\n while i < len(filenames):... | [
"0.7139478",
"0.6578594",
"0.65595764",
"0.65387714",
"0.6311835",
"0.62951124",
"0.6235641",
"0.6173565",
"0.61575484",
"0.61424035",
"0.6047662",
"0.6041903",
"0.602598",
"0.60108405",
"0.6004139",
"0.5995963",
"0.5995963",
"0.5995963",
"0.5995401",
"0.5993016",
"0.5983836"... | 0.7508373 | 0 |
walk over files in provided directory and return a list of files | def walk_directory(self, path):
files = []
for dirpath, dirnames, filenames in os.walk(path):
for filename in filenames:
files.append(os.path.join(dirpath, filename))
return files | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_all_files(in_dir):\n\n for dirname, dirs, files in os.walk(in_dir):\n for filename in files:\n yield op.join(dirname, filename)",
"def get_all_files(directory):\r\n for dirpath, _dirnames, filenames in os.walk(directory):\r\n for fil... | [
"0.7925665",
"0.78335404",
"0.7786359",
"0.7776031",
"0.7694388",
"0.76942396",
"0.7658098",
"0.7648747",
"0.75843465",
"0.757489",
"0.75511634",
"0.7523276",
"0.75155026",
"0.75122464",
"0.7501486",
"0.74656945",
"0.74481636",
"0.74200726",
"0.7414121",
"0.74086905",
"0.7391... | 0.7963085 | 0 |
Check whether or not a string is a valid Roman numeral. | def is_roman_numeral(s: str) -> bool:
if not isinstance(s, str):
raise TypeError("Only strings may be tested ")
return bool(_romanNumeralPattern.match(s)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fromRoman(s):\n pass",
"def fromRoman(s):\n if not s:\n raise InvalidRomanNumeralError, 'Input can not be blank'\n if not romanNumeralPattern.search(s):\n raise InvalidRomanNumeralError, 'Invalid Roman numeral: %s' % s\n\n result = 0\n index = 0\n for numeral, integer in roman... | [
"0.6835023",
"0.64675707",
"0.61907345",
"0.6095126",
"0.607554",
"0.59310186",
"0.58298",
"0.5818829",
"0.58053446",
"0.5773457",
"0.5767107",
"0.5709555",
"0.56931996",
"0.56590647",
"0.56424683",
"0.5632415",
"0.5631892",
"0.56194246",
"0.5570805",
"0.5566121",
"0.55595434... | 0.8254919 | 0 |
search for user in the ban list | async def banlist(self, ctx, *, username=None):
bans = await ctx.guild.bans()
list_of_matched_users = []
for ban in bans:
if username is None or username.lower() in ban.user.name.lower():
list_of_matched_users.append(ban)
entries = []
for ban in list_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_user_name(cls,user_name):\n for user in cls.user_list:\n if user.user_name == user_name:\n return user",
"def search_user(message, search):\n found = []\n search = search.lower()\n users = hf.get_users()\n for user in users:\n if search in user['nam... | [
"0.6635181",
"0.65845996",
"0.64267707",
"0.6291678",
"0.6161224",
"0.6127906",
"0.6092408",
"0.60619473",
"0.6052187",
"0.60402244",
"0.6016852",
"0.6006078",
"0.5991084",
"0.5965134",
"0.5931113",
"0.59273094",
"0.5911802",
"0.59044695",
"0.58706963",
"0.5839877",
"0.582942... | 0.72738934 | 0 |
removes the last x messages from the channel it was called in (defaults to 10) | async def channel_(self, ctx, number=10):
number = number if number <= 100 else 100
question = await ctx.send(f"this will delete the last {number} messages from ALL users. Continue?")
await question.add_reaction(self.reactions[0])
await question.add_reaction(self.reactions[1])
d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def clear(ctx, number):\n \"\"\":param: ctx\"\"\"\n \"\"\":param: number\"\"\"\n \"\"\"return \"\"\"\n number = int(number) \n counter = 0\n async for x in bot.logs_from(ctx.message.channel, limit = number):\n if counter < number:\n await bot.delete_message(x)\n ... | [
"0.67335105",
"0.6715486",
"0.66315895",
"0.66250706",
"0.6528937",
"0.6269455",
"0.62468845",
"0.6244145",
"0.62168974",
"0.620329",
"0.6188422",
"0.6178319",
"0.6148279",
"0.6100332",
"0.6079787",
"0.6058955",
"0.59551233",
"0.5944647",
"0.59410363",
"0.5928811",
"0.5881828... | 0.682575 | 0 |
use '[.,!]report setup' in the channel that should become the report channel | async def setup(self, ctx):
self.report_channel = ctx.message.channel
with open('data/report_channel.json', 'w') as f:
json.dump({"channel": self.report_channel.id}, f)
await ctx.send('This channel is now the report channel') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def report(self, ctx: commands.Context, report: typing.Optional[str], args: commands.Greedy[typing.Union[discord.User, discord.TextChannel]]):\n author = ctx.message.author\n if report == 'setup':\n if checks.is_owner_or_moderator_check(ctx.message):\n await ctx.invoke... | [
"0.683029",
"0.6375262",
"0.613417",
"0.59820586",
"0.59680825",
"0.5906083",
"0.57938373",
"0.57611376",
"0.57535285",
"0.57166386",
"0.5662714",
"0.56567514",
"0.56311053",
"0.5629033",
"0.56285334",
"0.5610708",
"0.5606113",
"0.5603995",
"0.5593045",
"0.55677265",
"0.55550... | 0.72447664 | 0 |
selfmute yourself for certain amount of time | async def selfmute(self, ctx, amount:int, time_unit:str):
length, error_msg = self.convert_mute_length(amount, time_unit)
if not length:
await ctx.send(error_msg)
return
if length > 7 * self.units["days"]:
question = await ctx.send(f"Are you sure you want to ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def selfmute(ctx, *args):\n user = ctx.message.author\n if await is_staff(ctx):\n return await ctx.send(\"Staff members can't self mute.\")\n time = \" \".join(args)\n await _mute(ctx, user, time, self=True)",
"async def _mute(ctx, user:discord.Member, time: str, self: bool):\n if use... | [
"0.75939256",
"0.68576396",
"0.6521713",
"0.6515285",
"0.64817613",
"0.64531577",
"0.64433974",
"0.63983494",
"0.6394465",
"0.6356057",
"0.6314334",
"0.6289779",
"0.6265375",
"0.6244864",
"0.6233572",
"0.6076269",
"0.6051343",
"0.5984072",
"0.59546584",
"0.59510046",
"0.59105... | 0.7218142 | 1 |
mutes a user from voice for the whole server | async def voice_mute(self, ctx, member: discord.Member, *,reason: typing.Optional[str]):
await member.edit(mute=True, reason=reason[:512])
await ctx.send(f"User {member.mention} successfully muted from voice")
if reason:
await self.check_channel.send(f"user {member.mention} muted fro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def mute(self, ctx):\n author = ctx.message.author\n channel = author.voice.channel\n members = channel.members\n for member in members:\n user = ctx.guild.get_member(member.id)\n await user.edit(mute=True)\n\n embed = await embeds.generate_embed(ctx, ... | [
"0.70429116",
"0.6485882",
"0.64345485",
"0.6267976",
"0.6264996",
"0.6263961",
"0.62500525",
"0.61775255",
"0.61728716",
"0.61710095",
"0.61693317",
"0.61162615",
"0.6115093",
"0.6084224",
"0.60821134",
"0.60459745",
"0.60407513",
"0.60330546",
"0.60249496",
"0.6010342",
"0.... | 0.68234724 | 1 |
Delete an award. This is used on the person edit page. | def award_delete(request, award_id, person_id=None):
award = get_object_or_404(Award, pk=award_id)
badge_name = award.badge.name
award.delete()
messages.success(request, 'Award was deleted successfully.',
extra_tags='awards')
if person_id:
# if a second form of URL, th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def award_delete(request, slug,id):\n \n company =get_object_or_404(Company,slug=slug)\n edit = validate_user_company_access_or_redirect(request,company)\n\n if request.method == 'POST':\n return HttpResponseRedirect('/company/'+str(slug))\n else: \n #verifies if the company exists if ... | [
"0.7830026",
"0.7739207",
"0.68277454",
"0.65321404",
"0.64024395",
"0.6380566",
"0.6345336",
"0.63208514",
"0.62701005",
"0.62636906",
"0.62052655",
"0.62052655",
"0.6161522",
"0.6154171",
"0.6137985",
"0.6120464",
"0.61112374",
"0.6087378",
"0.60695326",
"0.6067862",
"0.606... | 0.85680723 | 0 |
Discard EventRequest, ie. set it to inactive. | def eventrequest_discard(request, request_id):
eventrequest = get_object_or_404(EventRequest, active=True, pk=request_id)
eventrequest.active = False
eventrequest.save()
messages.success(request,
'Workshop request was discarded successfully.')
return redirect(reverse('all_event... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Discard(self, request, global_params=None):\n config = self.GetMethodConfig('Discard')\n return self._RunMethod(\n config, request, global_params=global_params)",
"def Discard(self, request, global_params=None):\n config = self.GetMethodConfig('Discard')\n return self._RunMethod(... | [
"0.6764851",
"0.6764851",
"0.62319267",
"0.62042",
"0.6156134",
"0.61215484",
"0.6118604",
"0.60858923",
"0.60858923",
"0.599714",
"0.59970295",
"0.59970295",
"0.59970295",
"0.596022",
"0.5953863",
"0.59002227",
"0.58789396",
"0.58766323",
"0.5814083",
"0.56593174",
"0.562837... | 0.76252353 | 0 |
Discard ProfileUpdateRequest, ie. set it to inactive. | def profileupdaterequest_discard(request, request_id):
profileupdate = get_object_or_404(ProfileUpdateRequest, active=True,
pk=request_id)
profileupdate.active = False
profileupdate.save()
messages.success(request,
'Profile update request was d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unblock_profile(self, request, *args, **kwargs):\n context = {\n 'conversation': self.get_object(),\n 'request': request\n }\n serializer = UnblockProfileSerializer(data=request.data, context=context)\n serializer.is_valid(raise_exception=True)\n seriali... | [
"0.7594404",
"0.58762586",
"0.57745874",
"0.5689538",
"0.56809133",
"0.5572069",
"0.5572069",
"0.54156774",
"0.5396515",
"0.53649014",
"0.53649014",
"0.53649014",
"0.5338151",
"0.533734",
"0.53143615",
"0.5303479",
"0.5261646",
"0.5238159",
"0.5198251",
"0.5191427",
"0.514967... | 0.8068111 | 0 |
Delete a TodoItem. This is used on the event details page. | def todo_delete(request, todo_id):
todo = get_object_or_404(TodoItem, pk=todo_id)
event_ident = todo.event.get_ident()
todo.delete()
messages.success(request, 'TODO was deleted successfully.',
extra_tags='todos')
return redirect(event_details, event_ident) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, item):\n self._createAction(item, \"delete\")",
"def delete(self, todo_id):\n todo = self.get_todo_by_user_id(todo_id)\n todo.delete()\n return '', 204",
"def delete_item(self, list_name: str, item_name: str) -> None:\n todo_list = self.get_list(list_name)\n ... | [
"0.75566703",
"0.7229479",
"0.7206156",
"0.71743983",
"0.7149615",
"0.71283984",
"0.71145236",
"0.7077117",
"0.700297",
"0.69892603",
"0.6944391",
"0.69187385",
"0.69040143",
"0.6893845",
"0.68695515",
"0.68588835",
"0.683616",
"0.6788384",
"0.6778612",
"0.6743664",
"0.670207... | 0.7717475 | 0 |
Set obj.assigned_to. This view helper works with both POST and GET | def _assign(request, obj, person_id):
try:
if request.method == "POST":
person_id = request.POST.get('person_1', None)
if person_id is None:
obj.assigned_to = None
else:
person = Person.objects.get(pk=person_id)
obj.assigned_to = person
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assigned_to(self) -> Optional[str]:\n return pulumi.get(self, \"assigned_to\")",
"def assigned_to(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"assigned_to\")",
"def assigned_to_changed(self, ar):\n # self.add_change_watcher(self.assigned_to)\n\n if (self.ass... | [
"0.7043154",
"0.68540734",
"0.6465051",
"0.6450169",
"0.6339605",
"0.6332004",
"0.622697",
"0.59485155",
"0.58828086",
"0.5880116",
"0.5737545",
"0.5694664",
"0.5694664",
"0.5586917",
"0.5578563",
"0.55712336",
"0.5555433",
"0.54242676",
"0.53915334",
"0.5375355",
"0.5294603"... | 0.75293905 | 0 |
Use the TCIA client to retrieve a zip of DICOMS associated with a uid | def download_dicom_series(uid, output_folder):
filename_zipped = os.path.join(output_folder, uid + ".zip")
filename = re.sub(".zip", "", filename_zipped)
if not (os.path.exists(filename_zipped) or os.path.isdir(filename)):
client.get_image(
seriesInstanceUid=uid, downloadPath=output_fold... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sample_zip(self, sha256):\n return self.__make_api_call('get/sample/{}/zip'.format(sha256))",
"def unzip_citibike_data(zip_dir):\n# zip_dir = \"data/citibike-tripdata-nyc/\"\n# csv_dir = \"data/citibike-tripdata-nyc/csv\"\n extension = \".zip\"\n\n # for each zip file in zip_dir extr... | [
"0.55942416",
"0.5435304",
"0.51368004",
"0.5116804",
"0.50765246",
"0.5062138",
"0.5018735",
"0.5002108",
"0.4990074",
"0.49663532",
"0.49403724",
"0.49035048",
"0.4894721",
"0.48720554",
"0.48528156",
"0.48371184",
"0.47926164",
"0.4776363",
"0.47761512",
"0.47272655",
"0.4... | 0.56900346 | 0 |
Downloads a zip file from a link in the download_dir folder | def download_zip_from_url(url, download_dir="."):
filename = url.split("/")[-1].split("?")[0].strip("\\")
os.makedirs(download_dir, exist_ok=True)
filename_zipped = os.path.join(download_dir, filename)
filename = re.sub(".zip", "", filename_zipped)
if not (os.path.exists(filename_zipped) or os.path... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _download(url, outpath=None, dirname=None, branch='master', release=None):\n six.print_('downloading...')\n outfolder = outpath or os.getcwd()\n file, archive_url = get_archive_url(url, branch, release)\n six.print_(archive_url)\n if dirname:\n outfolder = \"{}/{}.zip\".format(outfolder, ... | [
"0.7673379",
"0.7671466",
"0.7451294",
"0.74270606",
"0.73973536",
"0.73620456",
"0.73142874",
"0.7294725",
"0.7197982",
"0.7170576",
"0.70669204",
"0.7042603",
"0.7016436",
"0.7009908",
"0.7009856",
"0.6993355",
"0.69703954",
"0.6968875",
"0.6919285",
"0.6912825",
"0.6911805... | 0.7997585 | 0 |
Retrieves SeriesUID from the xml under scrutiny. | def get_SeriesUID_from_xml(path):
try:
return [
e.text
for e in ET.parse(path).getroot().iter()
if e.tag == "{http://www.nih.gov}SeriesInstanceUid"
][0]
except Exception:
return "notfound" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id(self):\n return self._fetch_element('uid')",
"def uid(self):\n return safeInt(self.tag(\"uid\"))",
"def series_instance_uid(self) -> Optional[str]:\n return self._series_instance_uid",
"def identifier(self):\n return self.element.xpath('./@Id')",
"def uid(self) -> str:\n ... | [
"0.6043538",
"0.579238",
"0.57903546",
"0.5624048",
"0.5610217",
"0.56094086",
"0.55660325",
"0.5546598",
"0.5546598",
"0.5546598",
"0.55310714",
"0.5504808",
"0.54589754",
"0.54261786",
"0.5418715",
"0.5418603",
"0.53924775",
"0.53796464",
"0.5324746",
"0.5287385",
"0.520318... | 0.74645054 | 0 |
Download the LIDC dataset in the output_folder folder and link downloaded DICOMs with annotation files. | def download_LIDC(output_folder, debug=False):
# Creating config file with path to dataset
_, config_file = create_config(output_folder, debug, "fed_lidc_idri")
# Get patient X study
patientXstudy = pd.read_json(
client.get_patient_study(collection="LIDC-IDRI").read().decode("utf-8")
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch(data_dir, dest=\"aida\"):\n\n # Get CoNLL03\n conll_dir = conll03.fetch(data_dir)\n\n # Create folder\n aida_dir = os.path.join(data_dir, dest)\n utils.create_folder(aida_dir)\n\n # Download AIDA\n aida_file = os.path.join(aida_dir, AIDA_FILE)\n if not os.path.exists(aida_file):\n... | [
"0.6643622",
"0.64993733",
"0.64365935",
"0.6259419",
"0.61793226",
"0.60971385",
"0.60954",
"0.6052573",
"0.5992943",
"0.5989011",
"0.59568894",
"0.59420604",
"0.58430636",
"0.58426553",
"0.58276373",
"0.5802974",
"0.57967013",
"0.57699454",
"0.5739426",
"0.5739216",
"0.5730... | 0.79258645 | 0 |
Save DataFrame to PostgreSQL via JDBC postgresql driver | def psql_saver(spark, df, tbname, savemode='error'):
df.createOrReplaceTempView("view")
spark.sql('''SELECT * FROM view''').write \
.format('jdbc') \
.option('url', 'jdbc:postgresql://%s' % __credential__.jdbc_accessible_host_psql) \
.option('dbtable', tbname) \
.option('user', _... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeToJDBC(df,tableName,spark):\n #df.table(tableName).write.jdbc(config.jdbcUrl,tableName,config.connectionProperties)\n #df = df.na.fill(0)\n mode= \"overwrite\"\n #print(\"jdbcURL: \",config.jdbcUrl,\"\\ntable Name :\",tableName,\"\\nmode:\",mode,\"\\nconnection property\",config.connectionProp... | [
"0.7538958",
"0.7315046",
"0.7035893",
"0.69290936",
"0.6893589",
"0.67505896",
"0.6718586",
"0.6711653",
"0.6706281",
"0.6678071",
"0.66444737",
"0.66421574",
"0.6595042",
"0.65944266",
"0.650788",
"0.6489796",
"0.64839333",
"0.6483777",
"0.6443881",
"0.6425489",
"0.64215523... | 0.73793316 | 1 |
Load the file list from PostgreSQL and return the readable filepath. | def psql_file_loader(spark, tbname):
filelist_rdd = psql_loader(spark, tbname) \
.rdd.map(lambda x: Row(caseid=x.case_id, filepath=x.path + '/' + x.filename))
return filelist_rdd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def psql_loader(spark, tbname):\n print(\"Loading files from PostgreSQL table: %s\" % tbname)\n filelist = spark.read \\\n .format('jdbc') \\\n .option('url', 'jdbc:postgresql://%s' % __credential__.jdbc_accessible_host_psql) \\\n .option('dbtable', tbname) \\\n .option('user', __... | [
"0.69596756",
"0.5759256",
"0.5735681",
"0.5731232",
"0.5665434",
"0.56590945",
"0.56081575",
"0.54501665",
"0.54350275",
"0.5431418",
"0.53963053",
"0.53911364",
"0.53735834",
"0.5373231",
"0.53518295",
"0.53414434",
"0.53365165",
"0.53235567",
"0.53212494",
"0.5320971",
"0.... | 0.66681415 | 1 |
Save DataFrame to Redshift via JDBC redshift driver | def redshift_saver(spark, df, tbname, tmpdir, savemode='error'):
df.createOrReplaceTempView("view")
spark.sql('''SELECT * FROM view''') \
.write.format("com.databricks.spark.redshift") \
.option("url", __credential__.jdbc_accessible_host_redshift) \
.option("dbtable", tbname) \
.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeToJDBC(df,tableName,spark):\n #df.table(tableName).write.jdbc(config.jdbcUrl,tableName,config.connectionProperties)\n #df = df.na.fill(0)\n mode= \"overwrite\"\n #print(\"jdbcURL: \",config.jdbcUrl,\"\\ntable Name :\",tableName,\"\\nmode:\",mode,\"\\nconnection property\",config.connectionProp... | [
"0.7210167",
"0.6551748",
"0.6547626",
"0.6318852",
"0.6138051",
"0.60281956",
"0.599131",
"0.59745264",
"0.5963789",
"0.59333736",
"0.593165",
"0.583602",
"0.5832216",
"0.57807076",
"0.57741284",
"0.57587796",
"0.5732389",
"0.57164097",
"0.5714424",
"0.5713656",
"0.57106453"... | 0.6924096 | 1 |
Load the file list from Redshift and return the readable filepath. | def redshift_file_loader(spark, tbname, tmpdir):
filelist_rdd = redshift_loader(spark, tbname, tmpdir) \
.rdd.map(lambda x: Row(caseid=x.case_id, filepath=x.path + '/' + x.filename))
return filelist_rdd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redshift_loader(spark, tbname, tmpdir):\n print(\"Loading files from Redshift table: %s\" % tbname)\n filelist = spark.read \\\n .format(\"com.databricks.spark.redshift\") \\\n .option(\"url\", __credential__.jdbc_accessible_host_redshift) \\\n .option(\"forward_spark_s3_credentials\... | [
"0.6710121",
"0.59790194",
"0.56483924",
"0.5509965",
"0.5405186",
"0.5352408",
"0.53398067",
"0.5331406",
"0.5290376",
"0.52780545",
"0.5258845",
"0.5241987",
"0.52318573",
"0.52213573",
"0.5219097",
"0.52087283",
"0.5166526",
"0.51605594",
"0.5156012",
"0.51536196",
"0.5115... | 0.68664795 | 0 |
Finds bootloader properties for the device using offline inspection. | def inspect_boot_loader(g, device) -> inspect_pb2.InspectionResults:
bios_bootable = False
uefi_bootable = False
root_fs = ""
try:
stream = os.popen('gdisk -l {}'.format(device))
output = stream.read()
print(output)
if _inspect_for_hybrid_mbr(output):
bios_bootable = True
part_list ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_device_file_dict():\n cmd = 'lshw -class disk'\n desc = \"description\"\n log_name = \"logical name\"\n serial = \"serial\"\n\n dev = []\n dev_list = []\n\n ret, output, err = run_gluster_command(cmd)\n output = output.decode('ASCII')\n dev_info = output.split('\\n')\n for lin... | [
"0.5718715",
"0.55690753",
"0.5462103",
"0.54236096",
"0.53736985",
"0.5368723",
"0.53373444",
"0.53061146",
"0.5274291",
"0.52600014",
"0.52261484",
"0.5221996",
"0.51640713",
"0.5162854",
"0.51505417",
"0.5148141",
"0.51273084",
"0.5101032",
"0.50776225",
"0.50754064",
"0.5... | 0.61695313 | 0 |
Finds hybrid MBR, which potentially is BIOS bootableeven without a BIOS boot partition. | def _inspect_for_hybrid_mbr(gdisk_output) -> bool:
is_hybrid_mbr = False
mbr_bios_bootable_re = re.compile(r'(.*)MBR:[\s]*hybrid(.*)', re.DOTALL)
if mbr_bios_bootable_re.match(gdisk_output):
is_hybrid_mbr = True
return is_hybrid_mbr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_bios_boot_mode_by_moid(self):\n pass",
"def test_get_bios_boot_mode_list(self):\n pass",
"def detect_mbr(self, filename, offset, fs_id):\n self.logger.debug('Detecting MBR partition type')\n\n if fs_id not in self.__mbr_plugins:\n return None\n else:\n... | [
"0.6185693",
"0.6110025",
"0.59356195",
"0.56100863",
"0.55986625",
"0.55217767",
"0.5459415",
"0.53488076",
"0.527089",
"0.52338624",
"0.51531035",
"0.5113562",
"0.50975084",
"0.50700265",
"0.5068751",
"0.5063921",
"0.5033384",
"0.50226516",
"0.49860033",
"0.49854615",
"0.49... | 0.7008793 | 0 |
Returns a linux.Inspector that is configured with all detectable Linux distros. | def _linux_inspector(
fs: boot_inspect.system.filesystems.Filesystem) -> linux.Inspector:
return linux.Inspector(fs, _LINUX) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def known_os_type():\n return 'Linux'",
"def platform():\n return ['linux']",
"def linux_os_config(self) -> Optional[pulumi.Input['LinuxOSConfigArgs']]:\n return pulumi.get(self, \"linux_os_config\")",
"def __distro(self):\n\n if hpccm.config.g_linux_distro == linux_distro.UBUNTU:\n ... | [
"0.5891477",
"0.5780679",
"0.5668247",
"0.5573606",
"0.5561961",
"0.54512626",
"0.5450596",
"0.537677",
"0.5364674",
"0.53325284",
"0.53206855",
"0.53015876",
"0.5254666",
"0.522435",
"0.52176446",
"0.51821816",
"0.51740766",
"0.5099447",
"0.5091836",
"0.5078843",
"0.5066999"... | 0.78530514 | 0 |
| This void function saves all including files and directories with same name with word to the search_list list. return_equals(directory, word[, result=search_list]) | def return_equals(self, directory, word, result=search_list):
try:
directories = listdir(self.directory)
except WindowsError:
directories = []
if "$Recycle.Bin" in directories:
directories.remove("$Recycle.Bin")
if "*\\*" in directories:
di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(word, current_directory, search_result_list=search_list):\n if search_result_list:\n for counter in range(len(search_result_list)):\n search_result_list.pop()\n if current_directory:\n searcher_object = CompleteSearch(current_directory, word)\n searcher_object.start... | [
"0.70012105",
"0.6431989",
"0.607879",
"0.602893",
"0.59404826",
"0.5890252",
"0.582532",
"0.5747598",
"0.5707703",
"0.567852",
"0.56751424",
"0.5637301",
"0.56358767",
"0.5613221",
"0.5607855",
"0.55870503",
"0.5574656",
"0.5474942",
"0.5450693",
"0.54445446",
"0.54160345",
... | 0.8496839 | 0 |
| This function returns search results of files and directories with same name of word. | First current directory searches and if there is any result, will return as a list | If user searches in home page, all drivers searches for results and the result will return as a list; search(word, current_directory[, search_res... | def search(word, current_directory, search_result_list=search_list):
if search_result_list:
for counter in range(len(search_result_list)):
search_result_list.pop()
if current_directory:
searcher_object = CompleteSearch(current_directory, word)
searcher_object.start()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_equals(self, directory, word, result=search_list):\n try:\n directories = listdir(self.directory)\n except WindowsError:\n directories = []\n if \"$Recycle.Bin\" in directories:\n directories.remove(\"$Recycle.Bin\")\n if \"*\\\\*\" in directo... | [
"0.7444881",
"0.70426524",
"0.6684862",
"0.6606855",
"0.6576921",
"0.6373673",
"0.63490796",
"0.6346005",
"0.6337016",
"0.632932",
"0.62723446",
"0.62628967",
"0.6246423",
"0.6217556",
"0.6217556",
"0.6211351",
"0.6206448",
"0.62025374",
"0.61939514",
"0.61712366",
"0.6165668... | 0.8495745 | 0 |
Fn that Initializes the App. Prints some Fancy Stuff to StreamLit page, Display demo Image and train data stats | def _init_app() -> None:
# set title
st.title("Detecting Pet Faces 👁 🐶 🐱",)
st.markdown(
"This application detects the faces of some common Pet Breeds using a **RetinaNet**."
)
st.write("## How does it work?")
st.write(
"Upload an image of a pet (cat or dog) and the app will d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n\tst.title(\"Iris EDA App with streamlit\")\n\tst.subheader(\"Streamlit is Cool\")",
"def load_homepage() -> None:\n st.image(\"iwakka.png\",\n use_column_width=True)\n \n st.header(\"Hello! This dashboard will help you to analize data from iWakka device\")\n st.write(\"Here a... | [
"0.6979405",
"0.66623354",
"0.64542246",
"0.6356499",
"0.6246196",
"0.62062424",
"0.61641407",
"0.6148707",
"0.6089208",
"0.6088656",
"0.60550535",
"0.6050303",
"0.6050303",
"0.60261196",
"0.60190606",
"0.5988488",
"0.5968736",
"0.59630483",
"0.59583074",
"0.5930924",
"0.5908... | 0.7796994 | 0 |
Moroccan Mosaic using Python Turtle | def draw():
myPen = turtle.Turtle()
myPen.shape("arrow")
myPen.speed(1000) # Set the speed of the turtle
# A Procedue to draw a mosaic by repeating and rotating a polygon shape.
def drawMosaic(color, numberOfSides, size, numberOfIterations):
myPen.color(color)
for i in range(0, n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def example_from_m3():\n # ------------------------------------------------------------------\n # Next two lines after this comment set up a TurtleWindow object\n # for animation. The definition of a TurtleWindow is in the\n # rg (shorthand for rosegraphics) module.\n # ---------------------... | [
"0.65632975",
"0.6095558",
"0.6092665",
"0.60891646",
"0.60118824",
"0.5902748",
"0.5898425",
"0.58668756",
"0.5748317",
"0.57450193",
"0.5698768",
"0.5697413",
"0.5694109",
"0.5622034",
"0.5611353",
"0.5568879",
"0.5532535",
"0.55252886",
"0.55061954",
"0.54686457",
"0.54614... | 0.6980053 | 0 |
Load a ElMo embedder | def load_elmo(cuda_device: int) -> ElmoEmbedder:
return ElmoEmbedder(cuda_device=cuda_device) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def embed():",
"def load(app, verbose, replay, exp_config=None):\n if replay:\n exp_config = exp_config or {}\n exp_config[\"replay\"] = True\n log(header, chevrons=False)\n loader = LoaderDeployment(app, Output(), verbose, exp_config)\n loader.run()",
"def pretrained(name=\"elmo\", l... | [
"0.62175786",
"0.590029",
"0.58213216",
"0.5748839",
"0.5716236",
"0.565742",
"0.5587765",
"0.5479743",
"0.5476409",
"0.54455894",
"0.54414856",
"0.53916883",
"0.53201646",
"0.5269377",
"0.5220537",
"0.52032304",
"0.5201442",
"0.51874834",
"0.5172268",
"0.51608175",
"0.515509... | 0.72271544 | 0 |
Preprocess bureau.csv and bureau_balance.csv. | def bureau_and_balance(num_rows=None, nan_as_category=True):
bureau = pd.read_csv('bureau.csv', nrows=num_rows)
bb = pd.read_csv('bureau_balance.csv', nrows=num_rows)
bb, bb_cat = one_hot_encoder(bb, nan_as_category)
bureau, bureau_cat = one_hot_encoder(bureau, nan_as_category)
# Bureau balance: Pe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_bureau_data(in_dir, nan_as_category=True):\n logger = logging.getLogger(__name__)\n logger.debug('Loading bureau data...')\n\n bureau = pd.read_csv(in_dir + '/bureau.csv')\n\n bb = pd.read_csv(in_dir + '/bureau_balance.csv')\n bb, bb_cat = one_hot_encoder(bb, nan_as_category)\n bureau, b... | [
"0.64036053",
"0.62629867",
"0.58125216",
"0.5807141",
"0.57303107",
"0.57129735",
"0.57014513",
"0.567897",
"0.56665885",
"0.5632176",
"0.5606566",
"0.5606245",
"0.55926096",
"0.55781627",
"0.55719185",
"0.5529289",
"0.55151397",
"0.54760665",
"0.5462434",
"0.543665",
"0.542... | 0.65498394 | 0 |
Lightgbm GBDT with KFold or Stratified KFold. | def kfold_lightgbm(df, num_rows, num_folds, stratified=False, debug=False):
train_df = df[df['TARGET'].notnull()]
test_df = df[df['TARGET'].isnull()]
text = "Starting LightGBM. Train shape: {}, test shape: {}"
print(text.format(train_df.shape, test_df.shape))
del df
gc.collect()
# Cross vali... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_cv(X_train, Y_train, nfold = 5, early_stopping_rounds = 20):\n # model params\n params = { \"objective\" : \"multiclass\",\n \"num_class\" : 6,\n \"verbosity\" : -1 }\n\n # create dataset for lightgbm\n lgb_train = lgb.Dataset(X_train, Y_train)\n \n # cross valida... | [
"0.73550516",
"0.6758229",
"0.6660438",
"0.6614328",
"0.6598201",
"0.621922",
"0.6148235",
"0.6131735",
"0.612636",
"0.6091015",
"0.60582244",
"0.60028034",
"0.59997773",
"0.5892357",
"0.58801293",
"0.58663964",
"0.5835386",
"0.58261806",
"0.5813785",
"0.5792207",
"0.5786084"... | 0.79730666 | 0 |
Convert variable to integer or string depending on the case. | def to_int(variable):
try:
return int(variable)
except ValueError:
return variable | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_str(variable):\n try:\n int(variable)\n return str(variable)\n except ValueError:\n return variable",
"def convertInt(s):\n try:\n int(s)\n return \"INT\"\n except:\n return s",
"def _as_int(self, name):\n org_type = self._get_type(name)\n ... | [
"0.7063601",
"0.6914241",
"0.6573752",
"0.641254",
"0.6336709",
"0.6336709",
"0.6336709",
"0.6336709",
"0.6336709",
"0.6302409",
"0.6298774",
"0.62717533",
"0.6248804",
"0.6206999",
"0.6136418",
"0.6114751",
"0.61015326",
"0.6098964",
"0.6075144",
"0.6054744",
"0.60094166",
... | 0.71815616 | 0 |
Convert variable to integer or string depending on the case. | def to_str(variable):
try:
int(variable)
return str(variable)
except ValueError:
return variable | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_int(variable):\n try:\n return int(variable)\n except ValueError:\n return variable",
"def convertInt(s):\n try:\n int(s)\n return \"INT\"\n except:\n return s",
"def _as_int(self, name):\n org_type = self._get_type(name)\n if org_type == 'int... | [
"0.7184124",
"0.6915447",
"0.6576159",
"0.6408534",
"0.6338109",
"0.6338109",
"0.6338109",
"0.6338109",
"0.6338109",
"0.6305314",
"0.6301793",
"0.6274125",
"0.62451327",
"0.62085027",
"0.6137398",
"0.6113615",
"0.61019415",
"0.61016726",
"0.60746306",
"0.6056998",
"0.60118085... | 0.7059871 | 1 |
Checks if jsonstat version attribute exists and is equal or greater \ than 2.0 for a given dataset. | def check_version_2(dataset):
if float(dataset.get('version')) >= 2.0 \
if dataset.get('version') else False:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_schema_version(context, version):\n data = context.response.json()\n check_and_get_attribute(data, version)",
"def check_version(self, node):\n assert \"version\" in node, \"Version node does not contain attribute 'version'\"\n assert len(node[\"version\"]) >= 1, \"Expecting at leas... | [
"0.6801831",
"0.59882814",
"0.58080256",
"0.56571555",
"0.56525904",
"0.56482166",
"0.5614213",
"0.5611383",
"0.5608659",
"0.55231154",
"0.55203396",
"0.55158633",
"0.5412891",
"0.54117423",
"0.5407262",
"0.5394365",
"0.5364731",
"0.53334713",
"0.5327647",
"0.5326494",
"0.531... | 0.7722066 | 0 |
Unnest collection structure extracting all its datasets and converting \ them to Pandas Dataframes. | def unnest_collection(collection, df_list):
for item in collection['link']['item']:
if item['class'] == 'dataset':
df_list.append(Dataset.read(item['href']).write('dataframe'))
elif item['class'] == 'collection':
nested_collection = request(item['href'])
unnest_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_data(self):\n structure_data = self.parse_root(self.root)\n\n dict_data = {}\n for d in structure_data:\n dict_data = {**dict_data, **d}\n df = pd.DataFrame(data=list(dict_data.values()), index=dict_data.keys()).T\n\n return df",
"def __object_demapper(se... | [
"0.6218987",
"0.577961",
"0.56963843",
"0.5687765",
"0.55922854",
"0.5588951",
"0.55812603",
"0.55670446",
"0.5566674",
"0.5553015",
"0.54693437",
"0.546879",
"0.5448559",
"0.5372168",
"0.53552485",
"0.5334211",
"0.53155845",
"0.53145075",
"0.5292812",
"0.5292152",
"0.5270108... | 0.7781752 | 0 |
Get label from a given dimension. | def get_dim_label(js_dict, dim, input="dataset"):
if input == 'dataset':
input = js_dict['dimension'][dim]
label_col = 'label'
elif input == 'dimension':
label_col = js_dict['label']
input = js_dict
else:
raise ValueError
try:
dim_label = input['category... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAxisLabel(self, dim=0):\n return self.__axis_labels__[dim]",
"def test_get_dim_label_with_label(self):\n\n dim = self.oecd_datasets['oecd']['dimension']['id'][0]\n dims_df = pyjstat.get_dim_label(self.oecd_datasets['oecd'], dim)\n self.assertTrue(dims_df.iloc[0]['id'] == 'UNR')... | [
"0.7131004",
"0.7038563",
"0.6737117",
"0.6715745",
"0.6470384",
"0.6414515",
"0.6387479",
"0.6375916",
"0.6359965",
"0.63417023",
"0.6326266",
"0.6309062",
"0.6306092",
"0.63019234",
"0.6247734",
"0.619815",
"0.6156095",
"0.6134617",
"0.61015564",
"0.609251",
"0.60764146",
... | 0.7249571 | 0 |
Reads data from URL, Dataframe, JSON string, JSON file or OrderedDict. | def read(cls, data):
if isinstance(data, pd.DataFrame):
return cls((json.loads(
to_json_stat(data, output='dict', version='2.0'),
object_pairs_hook=OrderedDict)))
elif isinstance(data, OrderedDict):
return cls(data)
elif (isinstance(data, b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fetch_data(url: str, d: datetime) -> pd.DataFrame:\n return pd.read_json(url)",
"def read_url(full_url = None, \n table_format = 'json'):\n \n if table_format == 'json':\n data = requests.get(full_url)\n df = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict... | [
"0.6491046",
"0.64579487",
"0.6190409",
"0.6136968",
"0.6119346",
"0.61163783",
"0.606284",
"0.6042426",
"0.5994613",
"0.5884721",
"0.58762944",
"0.58694124",
"0.58575994",
"0.5831916",
"0.58314955",
"0.58214885",
"0.5820414",
"0.57760435",
"0.57522964",
"0.5729711",
"0.56720... | 0.6827572 | 0 |
Reads data from URL or OrderedDict. | def read(cls, data):
if isinstance(data, OrderedDict):
return cls(data)
elif isinstance(data, basestring) and data.startswith(("http://",
"https://",
"ftp://",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _request_data(self, url):\n connection = httplib.HTTPConnection(self.url)\n connection.request(\"GET\", url)\n response = connection.getresponse()\n\n if response.status != 200:\n raise Exception(response.reason)\n\n data = response.read()\n response.close()... | [
"0.61915475",
"0.595929",
"0.581939",
"0.57758147",
"0.5734308",
"0.5706303",
"0.5693144",
"0.56683004",
"0.56371516",
"0.56260544",
"0.5621542",
"0.5556245",
"0.55431974",
"0.55298895",
"0.5499914",
"0.54831415",
"0.54318327",
"0.54240686",
"0.5399689",
"0.5399689",
"0.53996... | 0.62716776 | 0 |
Extract the action from a command (get, insert, update, delete) | def get_action(command):
return command.split(" ")[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_command(self,command):\n\t\treturn self.command_handlers[command]",
"def get_value(command):\n if is_get(command) or is_delete(command):\n return None\n elif is_insert(command) or is_update(command):\n return command.split(\" \")[2]",
"def _get_action(self):\n return self.__actio... | [
"0.6848488",
"0.6668799",
"0.66313916",
"0.6625008",
"0.65247416",
"0.6460432",
"0.64350355",
"0.63146126",
"0.6298981",
"0.6275523",
"0.6194686",
"0.6180713",
"0.61756164",
"0.614495",
"0.614495",
"0.6138919",
"0.6136538",
"0.6116887",
"0.60967165",
"0.60889083",
"0.60766923... | 0.77882355 | 0 |
Extract the key from a command | def get_key(command):
return command.split(" ")[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_bin_key(self, command):\n\t\treturn self.remote.encode_button(command)",
"def get_cmd(self, command):\n return self.commands[command][\"cmd\"]",
"def get_command(self):\n return self.c_dict['COMMAND']",
"def _get_command_lookup(self, command_dict):",
"def key(key):\n return ke... | [
"0.7064575",
"0.69919556",
"0.6910567",
"0.6785822",
"0.674809",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.67085004",
"0.6574106",
"0... | 0.90267634 | 0 |
Extract the 'value' from a command | def get_value(command):
if is_get(command) or is_delete(command):
return None
elif is_insert(command) or is_update(command):
return command.split(" ")[2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _query_state_value(command):\n _LOGGER.info('Running state command: %s', command)\n\n try:\n return_value = subprocess.check_output(command, shell=True)\n return return_value.strip().decode('utf-8')\n except subprocess.CalledProcessError:\n _LOGGER.error('C... | [
"0.666239",
"0.66055787",
"0.659243",
"0.6578315",
"0.65387666",
"0.64170784",
"0.63077176",
"0.6285835",
"0.62800246",
"0.62364197",
"0.6215651",
"0.6152268",
"0.6127448",
"0.609683",
"0.60843295",
"0.60843295",
"0.60530883",
"0.60434",
"0.6038694",
"0.6008705",
"0.59813315"... | 0.75534874 | 0 |
Spawns tasks for each GSoCProject in the given Program. | def spawnRemindersForProjectSurvey(self, request, *args, **kwargs):
post_dict = request.POST
# retrieve the program_key and survey_key from POST data
program_key = post_dict.get('program_key')
survey_key = post_dict.get('survey_key')
survey_type = post_dict.get('survey_type')
if not (program_k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_all_projects(args):\n man = load_manifest()\n\n if args[0] == '-p':\n parallel = True\n del args[0]\n else:\n parallel = False\n\n towait = []\n\n for (name, project) in man.projects.iteritems():\n repo = GitRepo(workdir_for_project(project))\n print >>sys.stderr, \"In project: \", name,... | [
"0.6236974",
"0.5777459",
"0.5777358",
"0.56144845",
"0.5541909",
"0.5535827",
"0.5474582",
"0.5409724",
"0.5370587",
"0.53408545",
"0.533208",
"0.53173953",
"0.53173953",
"0.53173953",
"0.5280981",
"0.5270837",
"0.52411216",
"0.5234688",
"0.5231515",
"0.5197715",
"0.51743555... | 0.57984895 | 1 |
Sends a reminder mail for a given GSoCProject and Survey. A reminder is only send if no record is on file for the given Survey and GSoCProject. | def sendSurveyReminderForProject(self, request, *args, **kwargs):
post_dict = request.POST
project_key = post_dict.get('project_key')
survey_key = post_dict.get('survey_key')
survey_type = post_dict.get('survey_type')
if not (project_key and survey_key and survey_type):
# invalid task data, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spawnRemindersForProjectSurvey(self, request, *args, **kwargs):\n post_dict = request.POST\n\n # retrieve the program_key and survey_key from POST data\n program_key = post_dict.get('program_key')\n survey_key = post_dict.get('survey_key')\n survey_type = post_dict.get('survey_type')\n\n if n... | [
"0.6965906",
"0.65784955",
"0.6296216",
"0.62702554",
"0.6187918",
"0.6152014",
"0.61322725",
"0.61321557",
"0.6081931",
"0.6029177",
"0.59823436",
"0.5896652",
"0.58888614",
"0.58611333",
"0.5771516",
"0.5752663",
"0.5662646",
"0.56331736",
"0.56252635",
"0.5573855",
"0.5568... | 0.77263916 | 0 |
This method is called when the viewer is initialized. Optionally implement this method, if you need to tinker with camera position and so forth. | def viewer_setup(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize(self):\n if not self._is_initialized:\n self.connect(retries=Camera.CONNECTION_RETRIES)\n self.cam.resolution = (self.resolution['x'], self.resolution['y'])\n self.cam.start_preview()\n time.sleep(2)\n self._is_initialized = True",
"de... | [
"0.7294715",
"0.707441",
"0.7071216",
"0.7047371",
"0.7039038",
"0.697051",
"0.6797928",
"0.67072433",
"0.66976625",
"0.6676851",
"0.6588336",
"0.6588336",
"0.6588336",
"0.6553483",
"0.6510361",
"0.65016794",
"0.65016794",
"0.65016794",
"0.6449363",
"0.64364845",
"0.63936776"... | 0.804509 | 0 |
Count number of paths by constructing Pascal's triangle, which is dynamic programming. | def npaths_dp(x,y):
## We'll fill in each position in the grid with the number of ways
## to get from the start to that position.
grid = [[None for j in range(y+1)] for i in range(x+1)]
## The grid will look something like this:
## 1-1-1-1- ...
## | | | |
## 1-2-3-4- ...
## | | | |
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_triangle_count_08(self):\n body = {\"direction\": \"IN\", \"degree\": 1}\n code, res = Algorithm().post_triangle_count(body, auth=auth)\n id = res[\"task_id\"]\n if id > 0:\n result = get_task_res(id, 120, auth=auth)\n print(result)\n assert res... | [
"0.6798037",
"0.670736",
"0.66936386",
"0.6689137",
"0.6681198",
"0.6662002",
"0.6618841",
"0.65798163",
"0.64765126",
"0.6342883",
"0.630705",
"0.6297395",
"0.6195524",
"0.61252505",
"0.6113715",
"0.6110095",
"0.60757464",
"0.60736287",
"0.60501665",
"0.6022417",
"0.6019725"... | 0.70024705 | 0 |
return the product of a sequence of factors | def prod(factors):
return reduce(operator.mul, factors, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product(factors):\n product = 1\n for i in factors:\n product *= i\n return product",
"def rf_prod(prime_factors: [int, ]):\n return 1 if not prime_factors else reduce(mul, prime_factors, 1)",
"def mul_factor(factors: List[Tuple[int, int]]) -> int:\n n = 1\n for f in factors:\n... | [
"0.82882315",
"0.7311317",
"0.72265387",
"0.71801776",
"0.7172264",
"0.6903313",
"0.6506647",
"0.6431132",
"0.636319",
"0.63479465",
"0.63479465",
"0.6306992",
"0.63020563",
"0.62482494",
"0.6170946",
"0.6158294",
"0.6128926",
"0.61053824",
"0.60901135",
"0.6059942",
"0.60575... | 0.80307823 | 1 |
Yields (_id, text_body) for all docs with a concatenated text body field. | def fetch_doc_text_body(self, document_level, find_query_mixin={}):
find_query = {'subreddit': self.subreddit, 'postwise.text':{'$exists':True}}
find_query.update(find_query_mixin)
if document_level != 'postwise':
raise NotImplementedError('document_level:%s' % document_level)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_texts():\n dirs = 'comm_use_subset noncomm_use_subset pmc_custom_license biorxiv_medrxiv'.split()\n for dir in dirs:\n fnames = (DATA_PATH / dir / dir).glob('*')\n for fname in fnames:\n with fname.open() as f:\n content = json.load(f)\n \n ... | [
"0.6241602",
"0.5947075",
"0.584004",
"0.55060875",
"0.5495156",
"0.5454279",
"0.5435753",
"0.5326532",
"0.5322977",
"0.53185534",
"0.52696717",
"0.5266342",
"0.52630454",
"0.52428854",
"0.52328455",
"0.522977",
"0.52256966",
"0.5223575",
"0.5191079",
"0.5173535",
"0.5165849"... | 0.6546281 | 0 |
Merges 2 or more topics into a single new topic. Just reassigns all the docs in those topics to new topic. Eg merging the topics ["1","2","3"] will go into a new topic named "(1+2+3)". You don't need to classify anything! | def merge_topics(self, topic_ids):
new_topic_id = '(' + '+'.join(topic_ids) + ')'
arbitrary_prob = 1
result = self.posts_write.update(
{'subreddit':self.subreddit, 'postwise.topic_assignment.topic':{'$in':topic_ids}},
{'$set':{'postwise.topic_assignment.topic':new_topic_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(ss: List[Stream[Any]], topics: List[Any] = None) -> Stream[Any]:\n\n def g(deps, this, src, value):\n if topics is not None:\n return (topics[ss.index(src)], value)\n return value\n\n return combine(g, ss)",
"def add_subscription_topics(self, topics: List[str]) -> None:\n... | [
"0.6516039",
"0.6307437",
"0.62713104",
"0.60813874",
"0.6040409",
"0.59586054",
"0.59270495",
"0.581572",
"0.58087695",
"0.56809825",
"0.56502634",
"0.56499624",
"0.56362545",
"0.55953455",
"0.55468065",
"0.5537097",
"0.5506792",
"0.5490293",
"0.5485791",
"0.54724145",
"0.54... | 0.74834514 | 0 |
Uses the trained TopicModeler to assign all docs in the find query to their "strongest" single topic. | def save_doc_topics(self, topic_modeler, find_query_mixin={}, topic_id_namer=str):
nmf = topic_modeler.nmf
vectorizer = topic_modeler.vectorizer
# only update docs that are the current subreddit,
# and have tokens (via process_text.py)
find_query = {'subreddit': self.subreddit, '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def semanticSearch(model, topics, index, idx_to_docid, k=1000):\r\n run = {}\r\n topic_nums = [topic for topic in topics]\r\n queries = [topics[topic]['title'] for topic in topics]\r\n encoded_queries = model.encode(queries)\r\n labels, distances = index.knn_query(encoded_queries, k=k)\r\n for i,... | [
"0.6346439",
"0.6285733",
"0.6115459",
"0.59040916",
"0.5758389",
"0.5743669",
"0.5686132",
"0.56583214",
"0.56441104",
"0.5585149",
"0.55538833",
"0.5521366",
"0.55110216",
"0.55009013",
"0.54710156",
"0.5399704",
"0.5399425",
"0.5389501",
"0.5375041",
"0.53640926",
"0.53452... | 0.6996216 | 0 |
Remove the postwise.topic_distro and postwise.topic_distro fields from all documents in the subreddit | def wipe_all_topics(self):
# doc_count = self.posts_read.find({'subreddit':self.subreddit, 'postwise.topic_assignment':{'$exists':True}}).count()
doc_count = self.posts_write.update({'subreddit':self.subreddit, 'postwise.topic_assignment':{'$exists':True}},
{'$unset':{'postwise.topic_dis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clear_document(self, docid):\n doc = self.get_document(docid)\n for term, count in doc.get_terms():\n term_entry = self.sql_session.query(Term).get(term)\n term_entry.count -= abs(count)\n term_entry.distinct_docs -= 1\n any_term = self.sql_session.query(T... | [
"0.64760447",
"0.5975757",
"0.58964",
"0.5851747",
"0.5772015",
"0.56319493",
"0.55570906",
"0.5484582",
"0.5437361",
"0.54371744",
"0.5370441",
"0.5353809",
"0.53488874",
"0.5298896",
"0.5295336",
"0.5265782",
"0.5254592",
"0.52453",
"0.52275765",
"0.5221391",
"0.5215771",
... | 0.6893495 | 0 |
Yields each individual comment in a post. | def each_comment_from_post(post):
# first yield the post text body, if any
if post['text']:
yield post['text']
# then yield each comment
for comment in post['comments']:
yield comment['text'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterateComments(db, post_id):\n c=db.cursor()\n c.execute(\"\"\"SELECT * FROM comments WHERE post_id=%d\"\"\" % post_id)\n for comment in c.fetchall():\n yield Comment(answer)\n c.close()",
"def comments(\n self, **stream_options: Any\n ) -> Generator[praw.models.Comment, None, N... | [
"0.8102602",
"0.71330816",
"0.71256965",
"0.70209515",
"0.6956547",
"0.6635815",
"0.6539074",
"0.64607584",
"0.6452519",
"0.64320844",
"0.6412035",
"0.6329041",
"0.6324704",
"0.63164395",
"0.6309868",
"0.6283187",
"0.62656665",
"0.62221324",
"0.62046283",
"0.6180858",
"0.6156... | 0.8596781 | 0 |
Concatenates all a posts's comments together and returns the result | def all_comments_from_post(post, prepend_title=True):
if 'comments' in post:
comments = [comment['text'] for comment in post['comments']]
post_text = post['text']
title_text = post['title']
if post_text:
# preprend post text body if it exists
comments = [post_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commentList(post):\n comments = Comment.objects.all().filter(post=post).order_by('-published')\n remote_comments = RemoteComment.objects.all().filter(post=post).order_by('published')\n comment_list = list()\n\n if comments:\n for comment in comments:\n comment_dict = dict()\n ... | [
"0.6669341",
"0.6629759",
"0.6567346",
"0.65568393",
"0.645952",
"0.6353189",
"0.6242865",
"0.62129784",
"0.6153404",
"0.6153404",
"0.60899085",
"0.60534865",
"0.6011431",
"0.59397805",
"0.5903908",
"0.58740234",
"0.5855156",
"0.58104396",
"0.5805067",
"0.5801013",
"0.5763444... | 0.7301012 | 0 |
Lowercase word and remove junk characters using self.filter_pattern | def clean_word(self, word):
return self.filter_pattern.sub(u'', word.lower()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_ignoring_case(self, pattern):\n return self.filter(re.compile(pattern, re.I))",
"def clean_cases(text):\n return text.lower()",
"def preprocess(self, s):\n stripped = re.sub(\"[^\\w\\s]\", \"\", s)\n stripped = re.sub(\"_\", \"\", stripped)\n\n stripped = re.sub(\"\\s+... | [
"0.73268974",
"0.731889",
"0.7099577",
"0.7067469",
"0.7044841",
"0.7043152",
"0.6991179",
"0.67993104",
"0.67970735",
"0.6778562",
"0.6728453",
"0.6704564",
"0.66781956",
"0.6671974",
"0.66304576",
"0.66165805",
"0.66165805",
"0.66165805",
"0.66165805",
"0.66165805",
"0.6616... | 0.82216036 | 0 |
Delete existing corpus (set of unique words) and make a new one. | def persist_corpus(self):
subreddit = self.postman.subreddit
corpus_coll = self.postman.corpus_write
subreddit_query = {'subreddit':subreddit}
preexisting_corpora = corpus_coll.find(subreddit_query).count()
print 'deleting %i existing corpora for subreddit' % preexisting_corpora... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_delete_corpus():\n corpus = set() # set<list<action, status, sentence>>\n with open(os.path.join(BASE, \"data/corpus.csv\")) as fp:\n for line in fp:\n corpus.add(line.split(\",\"))\n return corpus",
"def clean(corpus):\n # Initiate clean_corpus\n clean_corpus = [] \n ... | [
"0.6868972",
"0.62707067",
"0.6066833",
"0.6028967",
"0.59399575",
"0.5909655",
"0.5907406",
"0.5866781",
"0.5856297",
"0.58376837",
"0.58010125",
"0.57789904",
"0.5776771",
"0.5760552",
"0.5755673",
"0.57234013",
"0.5722739",
"0.57213384",
"0.5716799",
"0.5640827",
"0.563087... | 0.65945077 | 1 |
Master function for preprocessing documents. Reads from postman.posts_read and outputs to postman.posts_write | def process(self):
# tokenize, then filter & otherwise process words in each document
# using steps in preprocess_doc()
all_posts_count = self.postman.posts_read.find({'subreddit': self.postman.subreddit}).count()
for post_idx, post in enumerate(self.postman.posts_read.find({'subreddit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_process(self, documents):\n\n return documents",
"def _preprocess(self):\n self.data['sentences'] = self.data['text'].apply(self._tokenize_sent)\n self.data['nouns'] = self.data['sentences'].apply(self._get_nouns)\n # self._get_frequent_features()\n # self._compactness_... | [
"0.6777922",
"0.63840467",
"0.63757926",
"0.6265362",
"0.624771",
"0.61495733",
"0.61032873",
"0.6045339",
"0.6045339",
"0.6045339",
"0.60180175",
"0.6013464",
"0.6000915",
"0.59672505",
"0.5880899",
"0.5841607",
"0.580233",
"0.5737133",
"0.5736675",
"0.573466",
"0.573466",
... | 0.67262375 | 1 |
Add TimeBased Trimming Input Stream | def create(self, encoding_id, time_based_trimming_input_stream, **kwargs):
# type: (string_types, TimeBasedTrimmingInputStream, dict) -> TimeBasedTrimmingInputStream
return self.api_client.post(
'/encoding/encodings/{encoding_id}/input-streams/trimming/time-based',
time_based_tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _trimTime(time,data,tStart,tStop):\t\n\tif tStart is None:\n\t\tiStart=0;\n\t\tiStop=len(time);\n\telse:\n\t\t# determine indices of cutoff regions\n\t\tiStart=_process.findNearest(time,tStart); # index of lower cutoff\n\t\tiStop=_process.findNearest(time,tStop);\t # index of higher cutoff\n\t\t\n\t# trim ti... | [
"0.596018",
"0.5785316",
"0.57113206",
"0.56665367",
"0.5622098",
"0.55184543",
"0.5498387",
"0.54264224",
"0.5351055",
"0.5325785",
"0.52934694",
"0.5283096",
"0.5221919",
"0.5202626",
"0.5173048",
"0.5157478",
"0.5127592",
"0.51219743",
"0.5113893",
"0.50642955",
"0.5056635... | 0.58582246 | 1 |
Delete TimeBased Trimming Input Stream | def delete(self, encoding_id, input_stream_id, **kwargs):
# type: (string_types, string_types, dict) -> BitmovinResponse
return self.api_client.delete(
'/encoding/encodings/{encoding_id}/input-streams/trimming/time-based/{input_stream_id}',
path_params={'encoding_id': encoding_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _drop_old_data(self, current_time):\n for k in self._buf.keys():\n timelimit = current_time - self._lifetime\n if (k < timelimit):\n del self._buf[k]",
"def filterTimeCorr(corrPath, keepTimes, linesPerTime):\n\n # The file has stanzas beginning with \n # ---\... | [
"0.60808086",
"0.6057969",
"0.6052673",
"0.59732354",
"0.5900076",
"0.5839115",
"0.57906055",
"0.5750173",
"0.5706388",
"0.55499846",
"0.5537241",
"0.5536599",
"0.55201197",
"0.5512166",
"0.5504158",
"0.54612994",
"0.5454063",
"0.5421012",
"0.53685355",
"0.5366544",
"0.535066... | 0.60823244 | 0 |
List TimeBased Trimming Input Streams | def list(self, encoding_id, query_params=None, **kwargs):
# type: (string_types, TimeBasedTrimmingInputStreamListQueryParams, dict) -> TimeBasedTrimmingInputStream
return self.api_client.get(
'/encoding/encodings/{encoding_id}/input-streams/trimming/time-based',
path_params={'en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def win_slide(stream, start_time, win_size, step_size, max_windows):\n stream_list=[]\n for i in range(max_windows):\n ts = start_time + (i*step_size)\n st = stream.slice(ts, ts+win_size)\n # skip missing data\n if len(st)!=3: continue\n if not st[0].stats.starttime == st[1... | [
"0.5895306",
"0.57021743",
"0.5695429",
"0.5674139",
"0.55933565",
"0.5469195",
"0.5462523",
"0.5439689",
"0.5400392",
"0.53992",
"0.5375235",
"0.53676647",
"0.53236187",
"0.53185964",
"0.5308876",
"0.53067726",
"0.5305648",
"0.5305554",
"0.529495",
"0.5290115",
"0.52687687",... | 0.5919266 | 0 |
Given the parsed Version of Pants, return its release notes file path. | def notes_file_for_version(self, version: Version) -> str:
branch_name = self._branch_name(version)
notes_file = self._release_notes.get(branch_name)
if notes_file is None:
raise ValueError(
f"Version {version} lives in branch {branch_name}, which is not configured in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_release_notes(self):\n\n notes = self.output.get_header('RELEASE NOTES')\n notes += 'https://{}/{}/{}/releases'.format(HOST_GITHUB, \\\n self.repo, self.product) + '\\n'\n\n notes += self.output.get_sub_header('COMPARISONS')\n n... | [
"0.64292353",
"0.6268032",
"0.6163238",
"0.61492467",
"0.60980326",
"0.6056897",
"0.59942985",
"0.5937546",
"0.56882155",
"0.5619412",
"0.5613099",
"0.55908245",
"0.55586183",
"0.5537965",
"0.54783875",
"0.5476067",
"0.5475499",
"0.544245",
"0.5414592",
"0.53955483",
"0.53685... | 0.74077183 | 0 |
Tries to find the client with the specified mac address. Returns None if it hasn't been active yet | def get_client(self, mac_address: str) -> Union[Any, None]:
if mac_address in self._clients:
return self._clients[mac_address] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup_client(self, ip_addr: str):\n try:\n conn_obj = self.client_list[ip_addr]\n except KeyError:\n raise Networking.Host.ClientNotFoundException\n\n if conn_obj is not None:\n return conn_obj\n else:\n ra... | [
"0.6797491",
"0.6305357",
"0.62252337",
"0.618177",
"0.59434694",
"0.5883319",
"0.5820577",
"0.58077675",
"0.580335",
"0.57866395",
"0.57657874",
"0.5587245",
"0.5584584",
"0.55807036",
"0.55640537",
"0.5543741",
"0.5538617",
"0.55057526",
"0.55036765",
"0.54920053",
"0.54889... | 0.796704 | 0 |
Returns true if the model is built for training mode. | def is_training(self):
return self.mode == "train" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_training(self):\n return (\n self.detector.training\n # and self.recognizer.training\n and self.shared_conv.training\n )",
"def trainable(self):\n return True",
"def is_trainable(self):\n return False",
"def has_training_docs(self):\n ... | [
"0.77450645",
"0.75195754",
"0.7401473",
"0.6901232",
"0.68979996",
"0.6851016",
"0.6818478",
"0.6815334",
"0.67600894",
"0.67210084",
"0.66106576",
"0.6578971",
"0.65409017",
"0.64601964",
"0.6446735",
"0.6420486",
"0.64169925",
"0.63686174",
"0.6364961",
"0.6309912",
"0.630... | 0.8236415 | 0 |
Distort a batch of images. (Processing a batch allows us to easily switch between TPU and CPU execution). | def distort_images(self, images, seed):
if self.mode == "train":
images = image_processing.distort_image(images, seed)
# Rescale to [-1,1] instead of [0, 1]
images = tf.subtract(images, 0.5)
images = tf.multiply(images, 2.0)
return images | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_undistort():\n # read test images\n all_test_images = os.listdir('test_images')\n test_images = []\n for name in all_test_images:\n if name.endswith(\".jpg\"):\n test_images.append(name)\n # apply distortion correction on test images\n undistort_images(test_images, './... | [
"0.61262804",
"0.60912216",
"0.598788",
"0.59358394",
"0.5922533",
"0.5875004",
"0.5843194",
"0.57700866",
"0.57675856",
"0.57097095",
"0.5691411",
"0.5681225",
"0.5649462",
"0.5595402",
"0.55895615",
"0.5576115",
"0.55393803",
"0.54922485",
"0.54661673",
"0.54537296",
"0.545... | 0.7145252 | 0 |
Builds the input sequence embeddings. | def build_seq_embeddings(self, input_seqs):
with tf.variable_scope("seq_embedding"), tf.device("/cpu:0"):
embedding_map = tf.get_variable(
name="map",
shape=[self.config.vocab_size, self.config.embedding_size],
initializer=self.initializer)
seq_embeddings = tf.nn.embedding_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_seq_embeddings(self):\n with tf.variable_scope(\"seq_embedding\"), tf.device(\"/cpu:0\"):\n embedding_map = tf.get_variable(\n name=\"map\",\n shape=[self.config.vocab_size, self.config.word_embedding_size],\n initializer=self.initializer)\n \n # We need t... | [
"0.77851015",
"0.7130673",
"0.6865367",
"0.67336845",
"0.67199683",
"0.66785735",
"0.6605034",
"0.6559223",
"0.6552313",
"0.65228623",
"0.65226203",
"0.65208817",
"0.6496347",
"0.64477164",
"0.6435911",
"0.6419806",
"0.6393158",
"0.63673705",
"0.63666874",
"0.63221425",
"0.63... | 0.71874005 | 1 |
Sets up the function to restore inception variables from checkpoint. | def setup_inception_initializer(self):
if self.mode != "inference":
# Restore inception variables only.
saver = tf.train.Saver(self.inception_variables)
def restore_fn(sess):
tf.logging.info("Restoring Inception variables from checkpoint file %s",
self.config.incep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_init_fn():\n checkpoint_exclude_scopes = [\"InceptionV1/Logits\", \"InceptionV1/AuxLogits\"]\n\n exclusions = [scope.strip() for scope in checkpoint_exclude_scopes]\n\n variables_to_restore = []\n for var in slim.get_model_variables():\n excluded = False\n for exclusion in exclusi... | [
"0.71575403",
"0.7000785",
"0.68606037",
"0.67431253",
"0.66421974",
"0.65625894",
"0.6548759",
"0.654029",
"0.63851607",
"0.63566697",
"0.6351481",
"0.63231075",
"0.63209087",
"0.63020325",
"0.6232951",
"0.6192776",
"0.6189582",
"0.6169525",
"0.61546874",
"0.61290634",
"0.61... | 0.7782891 | 0 |
3D plot of shell elements coloured by material property. | def shell_properties_3d(
shells: List[Shell],
prop_f: Callable[[Material], float],
prop_units: str,
cmap: matplotlib.colors.Colormap = default_cmap,
colorbar: bool = False,
label: bool = False,
outline: bool = True,
new_fig: bool = True,
):
# Coordinates for rotating the plot perspec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot3d(self):\n plot_rupture_wire3d(self)",
"def get_3d_plot(three_d_matrix, ax, title, length):\r\n x, y, z = np.where(three_d_matrix != 0)\r\n ax.scatter(x, y, z, c='blue')\r\n ax.set_xlabel('x')\r\n ax.set_ylabel('y')\r\n ax.set_xlim(0, length)\r\n ax.set_ylim(0, length)\r\n ax... | [
"0.65396684",
"0.64592177",
"0.6369605",
"0.6002458",
"0.59309155",
"0.5929109",
"0.59126806",
"0.58908397",
"0.5875076",
"0.5787602",
"0.57868934",
"0.57833034",
"0.57310754",
"0.5703645",
"0.5703076",
"0.5677506",
"0.5642147",
"0.5626659",
"0.55626005",
"0.5488953",
"0.5450... | 0.71667206 | 0 |
Top view of shell elements optionally coloured by material property. | def shell_properties_top_view(
shells: List[Shell],
prop_f: Optional[Callable[[Material], float]] = None,
prop_units: Optional[str] = None,
cmap: matplotlib.colors.Colormap = default_cmap,
colorbar: bool = False,
label: bool = False,
outline: bool = True,
):
# Vertices of nodes for each ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_top(self):\n return group()",
"def __init__(self, controller, parent=None):\n super(EraseTool, self).__init__(controller, parent)\n self.hide()\n self.setZValue(styles.ZPATHTOOL)",
"def top_option():\n active = get_active_window()\n Width=get_middle_Width(active)\n ... | [
"0.56002295",
"0.53599805",
"0.53412706",
"0.5248069",
"0.5060203",
"0.5033952",
"0.49754825",
"0.49591467",
"0.48879454",
"0.48508808",
"0.48502374",
"0.48479536",
"0.4833125",
"0.48296246",
"0.4826038",
"0.48259652",
"0.48203567",
"0.4814789",
"0.48111784",
"0.47930458",
"0... | 0.6281429 | 0 |
Ensure `value` is of type T and return it. | def _check_type(cls, value: Any) -> T:
if not isinstance(value, cls.type):
raise ValueError(
f"{cls!r} accepts only values of type {cls.type!r}, "
f"got {type(value)!r}"
)
return cast(T, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert(cls, value: Any) -> Optional[T]:\n pass",
"def _check_value_type(cls, value: Any) -> V:\n if not isinstance(value, cls.valuetype):\n raise ValueError(\n f\"{cls!r} accepts only values of type \"\n \"{cls.valuetype!r}, got {type(value)!r}\"\n ... | [
"0.7167879",
"0.7088845",
"0.6617856",
"0.65999",
"0.65962976",
"0.633142",
"0.63054323",
"0.6303286",
"0.6302568",
"0.6286788",
"0.6285597",
"0.6257876",
"0.62238514",
"0.6135721",
"0.6133391",
"0.613098",
"0.6101893",
"0.599462",
"0.59832716",
"0.5910546",
"0.5896536",
"0... | 0.7335373 | 1 |
Ensure `value` is of type T and return it. | def _check_type(cls, value: Any) -> T:
if not isinstance(value, cls.type):
raise ValueError(
f"{cls!r} accepts only values of type {cls.type!r}, "
f"got {type(value)!r}"
)
return cast(T, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert(cls, value: Any) -> Optional[T]:\n pass",
"def _check_value_type(cls, value: Any) -> V:\n if not isinstance(value, cls.valuetype):\n raise ValueError(\n f\"{cls!r} accepts only values of type \"\n \"{cls.valuetype!r}, got {type(value)!r}\"\n ... | [
"0.7168732",
"0.70905447",
"0.6620016",
"0.6601747",
"0.65981066",
"0.6333085",
"0.63064355",
"0.6306179",
"0.6302738",
"0.6287991",
"0.62865114",
"0.6258626",
"0.6225704",
"0.61366874",
"0.6134749",
"0.6134575",
"0.6103191",
"0.59965014",
"0.5985597",
"0.5912719",
"0.5897219... | 0.73346376 | 0 |
Ensure `key` is of type K and return it. | def _check_key_type(cls, key: Any) -> K:
if not isinstance(key, cls.keytype):
raise KeyError(
f"{cls!r} accepts only keys of type {cls.keytype!r}, "
f"got {type(key)!r}"
)
return cast(K, key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, key, key_type=None):\n pass",
"def get_key(self, key):\n ret = None\n qkey = key.__qualname__\n ret = self.get(qkey)\n if not ret:\n # check all entries if qualname match\n for k in self:\n if k.__qualname__ == qkey:\n ... | [
"0.68074906",
"0.66398764",
"0.6606521",
"0.6545303",
"0.6482864",
"0.645621",
"0.6378684",
"0.63389575",
"0.62857664",
"0.62763745",
"0.6253712",
"0.6230783",
"0.6164547",
"0.61435175",
"0.6126763",
"0.6098707",
"0.60892385",
"0.59927523",
"0.59880143",
"0.59860724",
"0.5982... | 0.7774557 | 0 |
Ensure `value` is of type V and return it. | def _check_value_type(cls, value: Any) -> V:
if not isinstance(value, cls.valuetype):
raise ValueError(
f"{cls!r} accepts only values of type "
"{cls.valuetype!r}, got {type(value)!r}"
)
return cast(V, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_value(self, v, t):\n if (isinstance(t, (abstract.AbstractError, abstract.AbstractType))\n or v is abstract.DEAD):\n return None\n elif isinstance(t, abstract.AbstractScalar):\n if issubclass(t.values[abstract.TYPE],\n (dtype.Nu... | [
"0.707001",
"0.6538014",
"0.6471687",
"0.6431161",
"0.63861257",
"0.6296982",
"0.6222986",
"0.6171691",
"0.6100444",
"0.6065048",
"0.60494566",
"0.6046325",
"0.59974855",
"0.59508926",
"0.59442955",
"0.5941331",
"0.5929134",
"0.5929134",
"0.5926267",
"0.59260654",
"0.59233695... | 0.8052303 | 0 |
Create an attribute at each size. | def testsize(self):
for size in range(5):
AttributeAbility(size=size + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createAttribute(nid, label, primary, list, x, y):\n attribute = Attribute(nid, label, primary, x, y)\n list.append(attribute)",
"def _assign_sizes(self):",
"def _build_attributes(self):\n\n # We might rebuild the program because of snippets but we must\n # keep already bound attributes\... | [
"0.6165269",
"0.6130667",
"0.5805776",
"0.5680951",
"0.5595299",
"0.55945766",
"0.5581527",
"0.5567885",
"0.55510604",
"0.5543194",
"0.55387217",
"0.5535529",
"0.5517087",
"0.5517087",
"0.54875994",
"0.5471983",
"0.54380286",
"0.54255795",
"0.5416302",
"0.5413304",
"0.5410862... | 0.70325506 | 0 |
Create each attribute ability and verify the Ability Cost. | def testAC(self):
for size in range(5):
for attr in ('ST', 'DX'):
a = AttributeAbility([attr,], size + 1)
self.assertEqual(a.AC, (2000, 4000, 7000, 15000, 25000)[size])
for attr in ('IQ', 'Dam'):
a = AttributeAbility([attr,], size + 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testattributes(self):\n for attr in ('ST', 'DX', 'IQ', 'MA', 'Dam', 'Hit'):\n AttributeAbility([attr,])",
"def testsize(self):\n for size in range(5):\n AttributeAbility(size=size + 1)",
"def testattributes(self):\n for attr in AmuletAbility.attributes:\n ... | [
"0.73843056",
"0.66870636",
"0.6642298",
"0.66236144",
"0.6408896",
"0.6198641",
"0.5768418",
"0.5674704",
"0.5548058",
"0.55243206",
"0.54773396",
"0.541924",
"0.5391959",
"0.53720325",
"0.5355543",
"0.5314864",
"0.5313",
"0.5310781",
"0.5279219",
"0.5240787",
"0.5218387",
... | 0.6941932 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.