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 |
|---|---|---|---|---|---|---|
at most, default provided, cmdline args provided, required option | def test_at_most_default_args_required():
class TestCmdLine(CmdLine):
yaml_def = '''
supported_options:
- category:
options:
- name : test_opt
long : test-opt
opt : param
default : [default1, default2]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_commandline(cmdline_arguments: argparse.Namespace) -> Optional[Text]:",
"def test_exactly_implicit_default_args_required():\n class TestCmdLine(CmdLine):\n yaml_def = '''\n supported_options:\n - category:\n options:\n - name : test_opt\n ... | [
"0.7313445",
"0.72712463",
"0.7250068",
"0.7142192",
"0.71418095",
"0.71380323",
"0.71337074",
"0.71311206",
"0.71287304",
"0.7108569",
"0.707965",
"0.7058111",
"0.7051075",
"0.7048938",
"0.70381427",
"0.701937",
"0.70117986",
"0.6976874",
"0.69711566",
"0.6964402",
"0.695256... | 0.7292708 | 1 |
no limit, count, default provided, cmdline args provided, required option | def test_no_limit_default_count_args_required():
class TestCmdLine(CmdLine):
yaml_def = '''
supported_options:
- category:
options:
- name : test_opt
long : test-opt
opt : param
default : [default1, default... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_limit_count_no_default_no_args_optional():\n class TestCmdLine(CmdLine):\n yaml_def = '''\n supported_options:\n - category:\n options:\n - name : test_opt\n long : test-opt\n opt : param\n multi_type... | [
"0.719602",
"0.7167907",
"0.7166996",
"0.7128426",
"0.71095276",
"0.6897583",
"0.686943",
"0.68682885",
"0.68614024",
"0.68535453",
"0.6834506",
"0.67861134",
"0.6784479",
"0.65741295",
"0.6504409",
"0.64971584",
"0.64812136",
"0.64331436",
"0.6405051",
"0.64044034",
"0.63558... | 0.7185219 | 1 |
no limit, count, no default provided, no cmdline args, optional option | def test_no_limit_count_no_default_no_args_optional():
class TestCmdLine(CmdLine):
yaml_def = '''
supported_options:
- category:
options:
- name : test_opt
long : test-opt
opt : param
multi_type: no-limit
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_limit_count_no_default_args_required():\n class TestCmdLine(CmdLine):\n yaml_def = '''\n supported_options:\n - category:\n options:\n - name : test_opt\n long : test-opt\n opt : param\n multi_type: n... | [
"0.7050631",
"0.70452785",
"0.70235735",
"0.69944155",
"0.69669026",
"0.6923237",
"0.68905103",
"0.6890214",
"0.6879554",
"0.6854905",
"0.68200153",
"0.6792353",
"0.6734336",
"0.67135996",
"0.6648302",
"0.66345125",
"0.64197403",
"0.6388591",
"0.6376675",
"0.63543284",
"0.634... | 0.71876866 | 0 |
no limit, count, no default provided, cmdline args provided, required option | def test_no_limit_count_no_default_args_required():
class TestCmdLine(CmdLine):
yaml_def = '''
supported_options:
- category:
options:
- name : test_opt
long : test-opt
opt : param
multi_type: no-limit
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_limit_count_no_default_no_args_optional():\n class TestCmdLine(CmdLine):\n yaml_def = '''\n supported_options:\n - category:\n options:\n - name : test_opt\n long : test-opt\n opt : param\n multi_type... | [
"0.73283625",
"0.72420824",
"0.7235708",
"0.72236294",
"0.71616715",
"0.7101584",
"0.7085448",
"0.7080621",
"0.70441616",
"0.7033358",
"0.7031973",
"0.6981981",
"0.6959908",
"0.6799875",
"0.6760403",
"0.67291933",
"0.65991414",
"0.65847325",
"0.6554253",
"0.65058875",
"0.6470... | 0.7275675 | 1 |
Decorator to write to current log, using the info method. | def info(func):
def decorated(*args, **kwargs):
r"""Decorated method."""
runLog.info(func(*args, **kwargs))
return decorated | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, *args, **kwargs):\n self.logger.info(*args, **kwargs)",
"def log_info(info):\n log = open(log_path, 'a+')\n log.write(info + '\\n')\n log.close()",
"def log_info(self, msg, *args, **kwargs):\n if self.action_logging_enabled and self._log is not None:\n self.... | [
"0.75058866",
"0.7232002",
"0.71800804",
"0.71438056",
"0.70644534",
"0.7003833",
"0.6972972",
"0.6971884",
"0.6946898",
"0.69413275",
"0.69349533",
"0.6920375",
"0.6906088",
"0.6902692",
"0.6858961",
"0.6855104",
"0.685286",
"0.68466866",
"0.68445116",
"0.6832443",
"0.682783... | 0.7406214 | 1 |
Decorates a method to produce a repeatable warning message. | def warn(func):
def decorated(*args, **kwargs):
"""Decorated method."""
runLog.warning(func(*args, **kwargs))
return decorated | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warning(self, *args, **kwargs):",
"def warning(self, *args, **kwargs):\n self.msg(logging.WARNING, *args, **kwargs)",
"def important(func):\n\n def decorated(*args, **kwargs):\n \"\"\"Decorated method.\"\"\"\n runLog.important(func(*args, **kwargs))\n\n return decorated",
"def warn... | [
"0.6305619",
"0.61806756",
"0.61770254",
"0.6174671",
"0.6135365",
"0.6073327",
"0.60699433",
"0.58915794",
"0.5876475",
"0.5847712",
"0.58348745",
"0.58138067",
"0.5776181",
"0.5749293",
"0.57378614",
"0.57370216",
"0.5709198",
"0.57013345",
"0.56715167",
"0.56360596",
"0.56... | 0.733396 | 0 |
r"""Decorates a method to produce a warning message only on the root node. | def warn_when_root(func):
return _message_when_root(warn(func)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warning(self, *args, **kwargs):",
"def warn_undefined(func):\r\n\r\n def wrapped(self, *args, **kwargs):\r\n print(\"Lexicon [{0}] did not define API method: {1}\"\r\n .format(self.__class__.__name__,\r\n func.__name__))\r\n return func(self, *args, **kwargs... | [
"0.62868017",
"0.6003668",
"0.5967138",
"0.59299684",
"0.5882724",
"0.5868549",
"0.5818214",
"0.57812047",
"0.5729901",
"0.57067007",
"0.56958514",
"0.56435037",
"0.5528144",
"0.5526603",
"0.55155736",
"0.54177815",
"0.53631747",
"0.52808774",
"0.52076787",
"0.51754564",
"0.5... | 0.67079234 | 0 |
Drives the process of solving a maze. Takes command line parameters for the maze file and the type of agenda to be used. | def main():
filename = sys.argv[1]
agendaType = sys.argv[2]
maze = Maze(filename)
#Make the right agenda
if agendaType == 's':
agenda = StackAgenda()
elif agendaType == 'q':
agenda = QueueAgenda()
elif agendaType == 'p':
Eval = ManhattanDistanceEvaluator(maze.getGoa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n import argparse\n parser = argparse.ArgumentParser(description=\"Create and solve mazes\")\n parser.add_argument(\"-c\", \"--cli\", help=\"Switch to CLI mode\", action='store_true')\n parser.add_argument(\"-f\", \"--file\", help=\"File to import map from\")\n parser.add_argument(\"-s\",... | [
"0.75238645",
"0.6268863",
"0.6056313",
"0.5929022",
"0.5876019",
"0.58671695",
"0.5861825",
"0.58552366",
"0.58518976",
"0.58424836",
"0.57604975",
"0.57092434",
"0.56660146",
"0.55999553",
"0.55649126",
"0.5557676",
"0.54953426",
"0.54923564",
"0.54886127",
"0.5436678",
"0.... | 0.8546027 | 0 |
Get the list of excluded warnings for the specified filepath | def get_excluded_warnings(filepath):
exclwarns = list(SHELLCHECK_EXCLUDED_WARNS)
for pattern, warn in SHELLCHECK_SPECIFIC_EXCL_WARNS:
if re.match(pattern, filepath):
exclwarns.append(warn)
# Reorder the warnings
joined_exclwarns = ','.join(exclwarns)
return sorted(joined_exclwar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_warnings(self, path: str,\n is_ancillary: bool = False,\n is_system: bool = False,\n is_removed: bool = False) -> List[str]:",
"def get_excluded_videos():\n excluded_list = open('exclude.txt', 'r')\n return set([line.strip() for line in exclud... | [
"0.70083284",
"0.6590777",
"0.6536865",
"0.6536865",
"0.647672",
"0.63914484",
"0.6345218",
"0.6342791",
"0.62889993",
"0.62750965",
"0.61725247",
"0.6171398",
"0.6101468",
"0.60653377",
"0.6024153",
"0.5997995",
"0.59961766",
"0.59841835",
"0.59727174",
"0.5961339",
"0.59539... | 0.85258216 | 0 |
Implement some custom rules as linting shell script | def custom_lint_rules(filepath):
result = True
with open(filepath, 'r') as stream:
for lineno, line in enumerate(stream, start=1):
# Lines must only include ASCII characters, and no tab
stripped_line = line
if stripped_line.endswith('\n'):
stripped_lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commands_lint():\n lint()",
"def lint(ctx):\r\n print('Running linting...')\r\n ctx.run('pylint metrics')",
"def lint_py_check_per_line(_repo, cf):\n with open(cf.name, \"r\", encoding = 'utf-8', errors = 'replace') as f:\n line_cnt = 0\n regex_import = re.compile(r\"\\s*from\... | [
"0.72898704",
"0.7034197",
"0.6694135",
"0.66438174",
"0.6619083",
"0.6544736",
"0.65380174",
"0.65299606",
"0.6506779",
"0.6484315",
"0.64734906",
"0.64626765",
"0.64241415",
"0.6370633",
"0.6369927",
"0.63018984",
"0.6277159",
"0.62606436",
"0.6249945",
"0.62139994",
"0.619... | 0.70412993 | 1 |
Run shellcheck on all shell files | def test():
# subprocess.check_output() has been introduced in Python 2.7
if sys.version_info < (2, 7):
print("Python version too old, skipping test.")
return 2
try:
subprocess.check_output(['shellcheck', '--version'])
except OSError as exc:
if exc.errno == errno.ENOENT:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RunChecks(self):\n results = []\n\n affected_files = self.input_api.AffectedFiles(\n file_filter=self.file_filter, include_deletes=False)\n affected_js_files = filter(\n lambda f: f.LocalPath().endswith('.js'), affected_files)\n\n if affected_js_files:\n self.input_api.logging.in... | [
"0.64426523",
"0.6375341",
"0.6179758",
"0.61652446",
"0.61307645",
"0.6079823",
"0.5914165",
"0.5861633",
"0.5823021",
"0.5809482",
"0.5807577",
"0.5797322",
"0.5777568",
"0.5739403",
"0.57278496",
"0.57190955",
"0.5666298",
"0.56662434",
"0.565907",
"0.5653608",
"0.564138",... | 0.73892987 | 0 |
Get the latest response given a user ID and a unit ID. | def get_latest_response(db_conn, user_id, unit_id):
query = """
SELECT *
FROM responses
WHERE user_id = %(user_id)s AND unit_id = %(unit_id)s
ORDER BY created DESC
LIMIT 1;
"""
params = {
'user_id': convert_slug_to_uuid(user_id),
'unit_id': convert_slug_to_uuid(unit_id),
}
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_user_match(self, user):\n\n user_id = self.get_user_id(user)\n endpoint = f\"users/{user_id}/recent\"\n response = self._api_request(endpoint)\n if response is not None and response != []:\n return response",
"def get(cls, user_id: int):\n\n response_obj... | [
"0.5876116",
"0.56816244",
"0.5667954",
"0.5611992",
"0.5534829",
"0.55154866",
"0.5495137",
"0.54949415",
"0.5483463",
"0.54005903",
"0.53781474",
"0.5373225",
"0.533676",
"0.5296531",
"0.52581495",
"0.5217053",
"0.51941454",
"0.5192396",
"0.51881605",
"0.5178072",
"0.515457... | 0.8370101 | 0 |
processManager manages os processes clientManager manages engine clientsessions | def __init__(self, processManager, clientManager):
self.processManager = processManager
self.clientManager = clientManager
self.engine_types = {}
self.engine_allocations = {}
self.engine_instances = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_manager(self) -> None:\n\n #Clean out the process list.\n self.process_list.clear()\n for _ in range(self.num_processes):\n p = Process(target=self.multiprocessing_job,\n args=(self.process_job,))\n self.process_list.append(p)\n sel... | [
"0.5890435",
"0.5846474",
"0.5748428",
"0.5668867",
"0.5590558",
"0.55260956",
"0.54729223",
"0.5442344",
"0.54060966",
"0.5403635",
"0.5346425",
"0.5309964",
"0.5304573",
"0.5302362",
"0.5251808",
"0.5246157",
"0.5243853",
"0.5224315",
"0.5209391",
"0.52008444",
"0.51810884"... | 0.64856774 | 0 |
Create a new access id for running engines of given type. return access_id | def allocateEngine(self, engine_type):
if engine_type not in self.engine_types.keys():
raise KeyError("%s is not a recognized engine type" % engine_type)
access_id = uuid.uuid4().hex
self.engine_allocations[access_id] = engine_type
log.msg('Allocated engine access id: %s for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_id(self, view, response_type):\n\n with self._lock:\n if self._id >= self.MAX_ID:\n self._id = -1\n self._id += 1\n self.request_ids[view.id()][str(self._id)] = response_type\n return str(self._id)",
"def get_id(type_: Dict[str, str]) -> i... | [
"0.61568576",
"0.60782933",
"0.5586929",
"0.55606264",
"0.55241716",
"0.54458",
"0.542553",
"0.5377082",
"0.53454125",
"0.5275419",
"0.52663046",
"0.5260153",
"0.5204293",
"0.51612186",
"0.51303667",
"0.5089562",
"0.50874066",
"0.5078152",
"0.5073713",
"0.5069934",
"0.5065967... | 0.7551138 | 0 |
Log frames containing warning chars to pcap file | def log_frame(frame, logfile=PCAP_LOG):
global frame_count
frame_count += 1
pcap_logger = PcapWriter(logfile, append=True)
pcap_logger.write(frame)
pcap_logger.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spoof_packet(packet):",
"def sniffer():\n try:\n sniff(iface=INTERFACE, prn=print_frame, filter='udp and (port bootps or bootps)', store=0)\n except Exception as _e:\n print(\"ERROR - sniffer(): {} {}\".format(_e.args, _e.message))",
"def packet_handler(pkt):\n if pkt[Ether].type == ... | [
"0.5755267",
"0.5720088",
"0.5695309",
"0.54777116",
"0.5387228",
"0.53757334",
"0.5369893",
"0.53325135",
"0.531625",
"0.5298394",
"0.5286504",
"0.5256913",
"0.5240283",
"0.51906246",
"0.5188085",
"0.5185131",
"0.51697636",
"0.5160484",
"0.513072",
"0.51047236",
"0.5099291",... | 0.6517598 | 0 |
Parse and print DHCP options parse for malicious chars highlight offending options | def parse_dhcp_opt(options):
char_found = False
print(" - DHCP -")
for option in options:
warn = False
if type(option) is tuple:
opt_name = option[0]
opt_value = format(option[1])
if any((char in WARNCHARS) for char in opt_value):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_options():\n description = \"\"\"DDoS_Wall is designed to mitigate common types of DDoS attacks. It offers system\n monitoring and will enable TCP cookies if the system is under attack, this helps\n mitigate SYN flood attacks. It also provides protection against HTTP based attacks ... | [
"0.5916661",
"0.5873478",
"0.579024",
"0.55831575",
"0.5463275",
"0.54152185",
"0.5363934",
"0.52955854",
"0.5259283",
"0.5215847",
"0.52032894",
"0.51592785",
"0.51359975",
"0.51315373",
"0.51312023",
"0.51094913",
"0.5105961",
"0.5091456",
"0.5087009",
"0.50587434",
"0.5048... | 0.74298066 | 0 |
Parse and print BOOTP fields parse for malicious chars highlight offending fields | def parse_bootp_fields(bootp_fields):
char_found = False
print(" - BOOTP -")
for field_name in bootp_fields.keys():
warn = False
field_value = format(bootp_fields[field_name])
if any((char in WARNCHARS) for char in field_value):
char_found, warn = True, True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minimalTextCleaning(row, field):\n\n # force encoding\n encoded_text = row[field].encode(encoding = 'ascii',errors = 'replace')\n decoded_text = encoded_text.decode(encoding='ascii',errors='strict')\n remove_funky_chars = str(decoded_text).replace(\"?\", \" \")\n lower_case = str(remove_funky_ch... | [
"0.5502855",
"0.53578335",
"0.5323758",
"0.52993655",
"0.5207881",
"0.51886266",
"0.5160507",
"0.51555645",
"0.5104396",
"0.5065064",
"0.50316495",
"0.494737",
"0.4924509",
"0.49010897",
"0.4861437",
"0.48601133",
"0.4854821",
"0.48494607",
"0.4843747",
"0.4838832",
"0.483324... | 0.6807082 | 0 |
Parse and print DHCP Frames parse sniffed DHCP frames print summary of client requests parse and print server replies log malicious frames | def print_frame(frame):
if 'DHCP' in frame:
bootp_fields = frame[BOOTP].fields
dhcp_options = frame[DHCP].options
type_value = dhcp_options[0][1]
type_name = scapy.layers.dhcp.DHCPTypes[type_value]
print("\n\nFRAME: {}".format(frame.summary()))
print("TYPE: DHCP-{... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_packets(pcap):\n\n # For each packet in the pcap process the contents\n for timestamp, buf, hdr_len in pcap:\n \n # Unpack the Ethernet frame (mac src/dst, ethertype)\n eth = dpkt.ethernet.Ethernet(buf)\n # print('Ethernet Frame: ', mac_addr(eth.src), mac_addr(eth.dst), ... | [
"0.64814144",
"0.63543326",
"0.6281344",
"0.60260224",
"0.59980947",
"0.59980947",
"0.59158593",
"0.5812211",
"0.5695675",
"0.5669232",
"0.5665304",
"0.56055313",
"0.56055176",
"0.5597248",
"0.5554705",
"0.552274",
"0.54796404",
"0.5469622",
"0.5453205",
"0.54153615",
"0.5400... | 0.742832 | 0 |
Instantiate scapy sniffer with DHCP filters | def sniffer():
try:
sniff(iface=INTERFACE, prn=print_frame, filter='udp and (port bootps or bootps)', store=0)
except Exception as _e:
print("ERROR - sniffer(): {} {}".format(_e.args, _e.message)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n print \"Starting Packet Sniffer on [ %s ]:[ %s ]...\" % (self.ifname, self.packet_filter_string)\n self.socket = conf.L2listen(\n type=ETH_P_ALL,\n iface=self.ifname,\n filter=self.packet_filter_string\n )\n\n sniff(\n opened_... | [
"0.6067641",
"0.59605837",
"0.5787008",
"0.5701485",
"0.5633961",
"0.5602509",
"0.5559132",
"0.5497743",
"0.54662603",
"0.53255785",
"0.5319192",
"0.52789766",
"0.52742344",
"0.5273534",
"0.5265276",
"0.5226683",
"0.52039754",
"0.5200303",
"0.5195711",
"0.5183367",
"0.5180388... | 0.6250266 | 0 |
Run Genotype Concordance installed in a Docker image. | def run_concordance(reference, eval_file, truth_file, output_file):
user_name = os.path.expanduser('~')
# Give Docker access to local system.
docker_permission = user_name + ':' + user_name
docker_url = 'us.gcr.io/broad-gotc-prod/genomes-in-the-cloud:2.3.2-1510681135'
cmd = ['docker', 'run', '-i', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(container, util, shell, ver_info, os_cont=None):\n result = util.already_completed(\"_POLYSQUARE_CONFIGURE_CONAN\")\n if result is not util.NOT_YET_COMPLETED:\n return result\n\n py_cont = _setup_python(container, util, shell)\n\n with util.Task(\"\"\"Installing conan\"\"\"):\n wi... | [
"0.5806319",
"0.57277536",
"0.5296187",
"0.51995224",
"0.5182196",
"0.51663417",
"0.51646554",
"0.5141817",
"0.50926673",
"0.5070747",
"0.5064653",
"0.5061752",
"0.504851",
"0.5034603",
"0.50334805",
"0.5023753",
"0.49554652",
"0.4937829",
"0.49363306",
"0.49351192",
"0.49327... | 0.7291072 | 0 |
Process Concordance summary TSV output file. | def process_output_tsv(output_tsv, threshold=None, print_dict=False):
# Set default
if threshold is None:
threshold = 0.95
L = [] # list to capture results
try:
with open(output_tsv, newline='') as csvfile:
file_reader = csv.reader(csvfile, delimiter=' ', quotechar='|')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summarize_tsvs(\n self,\n tsv_dir,\n dd,\n prefix=\"\",\n outlier_threshold=10,\n omit_props=[\n \"project_id\",\n \"type\",\n \"id\",\n \"submitter_id\",\n \"case_submitter_id\",\n \"case_ids\",\n ... | [
"0.6076242",
"0.57384425",
"0.5682988",
"0.5616065",
"0.5610998",
"0.55731404",
"0.5545057",
"0.5540394",
"0.551698",
"0.54889375",
"0.5476647",
"0.54432714",
"0.5418938",
"0.5414568",
"0.54013455",
"0.5332458",
"0.5293008",
"0.5279743",
"0.5266036",
"0.5222815",
"0.52146786"... | 0.67173153 | 0 |
Get segmentation masks from mask_pred and bboxes. | def get_seg_masks(self, mask_pred, det_bboxes, det_labels,
ori_shape, scale_factor, rescale):
if isinstance(mask_pred, torch.Tensor):
mask_pred = mask_pred.sigmoid().cpu().numpy()
assert isinstance(mask_pred, np.ndarray)
# when enabling mixed precision training,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_seg_masks(self, rgba_pred, det_bboxes, det_labels, rcnn_test_cfg,\n ori_shape, scale_factor, rescale):\n if isinstance(rgba_pred, torch.Tensor):\n rgba_pred = rgba_pred.tanh().cpu().numpy()\n assert isinstance(rgba_pred, np.ndarray)\n # when enabling mi... | [
"0.72128326",
"0.70888174",
"0.67961496",
"0.6765662",
"0.67139673",
"0.6710392",
"0.6693274",
"0.6631748",
"0.65883905",
"0.6580554",
"0.6570391",
"0.6564199",
"0.64919823",
"0.64462066",
"0.6259196",
"0.62372243",
"0.6229616",
"0.62007165",
"0.61606365",
"0.6132862",
"0.611... | 0.73250324 | 0 |
Get the mask scores. mask_score = bbox_score mask_iou | def get_mask_scores(self, mask_iou_pred, det_bboxes, det_labels):
inds = range(det_labels.size(0))
mask_scores = 0.3*mask_iou_pred[inds, det_labels +
1] +det_bboxes[inds, -1]
mask_scores = mask_scores.cpu().numpy()
det_labels = det_labels.cpu().numpy()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mask_bbox_and_score(yolact_net: Yolact, img, threshold=0.0, max_predictions=1):\n with torch.no_grad():\n frame = torch.from_numpy(img).cuda().float()\n batch = FastBaseTransform()(frame.unsqueeze(0))\n preds = yolact_net(batch)\n\n h, w, _ = img.shape\n\n save = cfg.r... | [
"0.65144867",
"0.6466221",
"0.6315222",
"0.62637913",
"0.62122744",
"0.6192767",
"0.6178452",
"0.6105629",
"0.6087383",
"0.6032142",
"0.60265553",
"0.5911425",
"0.590602",
"0.5874414",
"0.58339673",
"0.5812719",
"0.58085567",
"0.5778155",
"0.5765579",
"0.5738613",
"0.5735049"... | 0.7327434 | 0 |
Check the decode raises when serialization format not understood. | def test_decode_raises_when_format_unknown(thing):
with pytest.raises(ValueError):
decode(thing) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_decode_errors(self):\n if self._invalid_encoded:\n self.assert_raises((ValueError, jsonschema.exceptions.ValidationError),\n self.import_cls.decode,\n self._invalid_encoded[0], self.typedef)",
"def test_parser_raises_decode_er... | [
"0.76443183",
"0.6766991",
"0.66602975",
"0.6390798",
"0.6320673",
"0.625708",
"0.6246748",
"0.62028134",
"0.61936754",
"0.61199266",
"0.6112819",
"0.6088191",
"0.60746866",
"0.6062305",
"0.60596335",
"0.6036647",
"0.6026336",
"0.60108435",
"0.5991173",
"0.5982825",
"0.597084... | 0.74039584 | 1 |
return the index of the first 'x' character | def index_of_x(word: str, position=0):
if word[position] == 'x':
return position
else:
return index_of_x(word, position + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_charindex(self, x, y):\r\n verts = self.shapes[0].buf[0].vertices\r\n x = x - self.x + verts[2][0]\r\n y = y - self.y + verts[0][1]\r\n nv = len(verts)\r\n for i in range(0, nv, 4):\r\n vtr = verts[i] # top right\r\n vbl = verts[i + 2] # bottom left\r\n if x >= vbl[0] and x <... | [
"0.71218747",
"0.6918496",
"0.6851387",
"0.66528195",
"0.6589345",
"0.6521937",
"0.6521937",
"0.6521937",
"0.6400876",
"0.6359979",
"0.63255304",
"0.63255304",
"0.63255304",
"0.62182313",
"0.6203542",
"0.61581415",
"0.61581415",
"0.61581415",
"0.61581415",
"0.6097176",
"0.609... | 0.8036832 | 0 |
Get data from the spreadsheet. | def read(rng, sheets_service=_sheets_service, spreadsheet_id=None):
# Get the default spreadsheet ID if it's not provided
# (Do this instead of setting the default in the kwargs so that a user
# can import gsheet;SPREADSHEET_ID = 'whatever'.
if spreadsheet_id is None:
spreadsheet_id = SPREADSHE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sales_data():\n print(\"Retrieving all the sales information...\")\n data = SHEET.worksheet('sales')\n print(\"Compilation complete!\\n\")\n return data",
"def _get_sheets_data(service=SHEETS):\n\n data_sheet = service.spreadsheets().values().get(spreadsheetId=SHEETS_FILE_ID,range='Sheet1'... | [
"0.6790523",
"0.6777845",
"0.6775767",
"0.6765728",
"0.6616499",
"0.6523082",
"0.65013665",
"0.6461865",
"0.6416124",
"0.64080983",
"0.63914007",
"0.63894963",
"0.6387209",
"0.6380976",
"0.63768816",
"0.63675785",
"0.6285232",
"0.6264446",
"0.62039644",
"0.6077867",
"0.606754... | 0.7193218 | 0 |
Returns true if circuits is the empty tensor. | def _check_empty(circuits):
return len(circuits) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return ch.prod(ch.tensor(self.x.shape)).item() == 0",
"def is_empty(self):\n return self._connected and self._length == 1 and self._degree > 1",
"def is_empty(self):\n return len(self.__nodes) == 0",
"def is_empty(self):\n return self._sum() == 0",
"def is_... | [
"0.81573635",
"0.7855352",
"0.7834296",
"0.7720283",
"0.7688964",
"0.7661219",
"0.7661219",
"0.7654285",
"0.7642995",
"0.76323026",
"0.76065236",
"0.75914824",
"0.75830877",
"0.75828665",
"0.7563768",
"0.75532037",
"0.75532037",
"0.75415987",
"0.75406486",
"0.7535155",
"0.753... | 0.80994695 | 1 |
Compute states from a batch of circuits. Returns a NumPy array containing the final circuit state for each `cirq.Circuit` in `circuits`, given that the corresponding `cirq.ParamResolver` in `param_resolvers` was used to resolve any symbols in it. If simulator is a `cirq.DensityMatrixSimulator` this final state will be ... | def batch_calculate_state(circuits, param_resolvers, simulator):
_validate_inputs(circuits, param_resolvers, simulator, 'analytic')
if _check_empty(circuits):
empty_ret = np.zeros((0, 0), dtype=np.complex64)
if isinstance(simulator, cirq.DensityMatrixSimulator):
empty_ret = np.zeros(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_calculate_expectation(circuits, param_resolvers, ops, simulator):\n _validate_inputs(circuits, param_resolvers, simulator, 'expectation')\n\n if _check_empty(circuits):\n return np.zeros((0, 0), dtype=np.float32)\n\n if not isinstance(ops, (list, tuple, np.ndarray)):\n raise TypeEr... | [
"0.58188546",
"0.5551796",
"0.5021508",
"0.48379582",
"0.47804806",
"0.4764913",
"0.47616875",
"0.47420448",
"0.4741493",
"0.45859724",
"0.45655003",
"0.45604125",
"0.45604125",
"0.45371944",
"0.45361343",
"0.45323488",
"0.4480623",
"0.44601914",
"0.4459688",
"0.44425797",
"0... | 0.8099694 | 0 |
Compute expectations from a batch of circuits. Returns a `np.ndarray` containing the expectation values of `ops` applied to a specific circuit in `circuits`, given that the corresponding `cirq.ParamResolver` in `param_resolvers` was used to resolve any symbols in the circuit. Specifically the returned array at index `i... | def batch_calculate_expectation(circuits, param_resolvers, ops, simulator):
_validate_inputs(circuits, param_resolvers, simulator, 'expectation')
if _check_empty(circuits):
return np.zeros((0, 0), dtype=np.float32)
if not isinstance(ops, (list, tuple, np.ndarray)):
raise TypeError('ops mus... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_calculate_sampled_expectation(circuits, param_resolvers, ops,\n n_samples, sampler):\n _validate_inputs(circuits, param_resolvers, sampler, 'sample')\n if _check_empty(circuits):\n return np.zeros((0, 0), dtype=np.float32)\n\n if not isinstance(ops, ... | [
"0.6261093",
"0.53508174",
"0.522588",
"0.5034467",
"0.49775633",
"0.48176643",
"0.47775078",
"0.47406253",
"0.46378827",
"0.45835137",
"0.45601445",
"0.455885",
"0.45550862",
"0.454358",
"0.4536093",
"0.45003018",
"0.4475048",
"0.44724002",
"0.4461446",
"0.44417736",
"0.4420... | 0.7719441 | 0 |
Compute expectations from sampling a batch of circuits. Returns a `np.ndarray` containing the expectation values of `ops` applied to a specific circuit in `circuits`, given that the corresponding `cirq.ParamResolver` in `param_resolvers` was used to resolve any symbols in the circuit. Specifically the returned array at... | def batch_calculate_sampled_expectation(circuits, param_resolvers, ops,
n_samples, sampler):
_validate_inputs(circuits, param_resolvers, sampler, 'sample')
if _check_empty(circuits):
return np.zeros((0, 0), dtype=np.float32)
if not isinstance(ops, (list, tupl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_calculate_expectation(circuits, param_resolvers, ops, simulator):\n _validate_inputs(circuits, param_resolvers, simulator, 'expectation')\n\n if _check_empty(circuits):\n return np.zeros((0, 0), dtype=np.float32)\n\n if not isinstance(ops, (list, tuple, np.ndarray)):\n raise TypeEr... | [
"0.72501415",
"0.58004814",
"0.4905321",
"0.47827",
"0.47498298",
"0.4736599",
"0.46041152",
"0.45866206",
"0.4567811",
"0.45643",
"0.4550887",
"0.45144355",
"0.45084292",
"0.44942206",
"0.44744077",
"0.44529006",
"0.44403884",
"0.4397027",
"0.43552658",
"0.43533057",
"0.4348... | 0.72037685 | 1 |
Sample from circuits. Returns a `np.ndarray` containing n_samples samples from all the circuits in circuits given that the corresponding `cirq.ParamResolver` in `param_resolvers` was used to resolve any symbols. Specifically the returned array at index `i,j` will correspond to a `np.ndarray` of booleans representing bi... | def batch_sample(circuits, param_resolvers, n_samples, simulator):
_validate_inputs(circuits, param_resolvers, simulator, 'sample')
if _check_empty(circuits):
return np.zeros((0, 0, 0), dtype=np.int8)
if not isinstance(n_samples, int):
raise TypeError('n_samples must be an int.'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_calculate_sampled_expectation(circuits, param_resolvers, ops,\n n_samples, sampler):\n _validate_inputs(circuits, param_resolvers, sampler, 'sample')\n if _check_empty(circuits):\n return np.zeros((0, 0), dtype=np.float32)\n\n if not isinstance(ops, ... | [
"0.5617212",
"0.5055469",
"0.49890578",
"0.4874516",
"0.48128292",
"0.47914252",
"0.46780062",
"0.46774754",
"0.46511295",
"0.46511295",
"0.4650094",
"0.46462202",
"0.46053076",
"0.4597321",
"0.45894894",
"0.45774463",
"0.45640483",
"0.45406157",
"0.4537965",
"0.4535856",
"0.... | 0.7646142 | 0 |
Rerank the test predict paraphrases according to the ranker | def rerank(test_predicted_paraphrases, test_features, ranker, minimum_score):
new_test_predicted_paraphrases = { (w1, w2) : [] for (w1, w2) in test_predicted_paraphrases.keys() }
for ((w1, w2), curr_paraphrases), curr_paraphrase_features in tqdm.tqdm(zip(
test_predicted_paraphrases.items(), test_fe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, test_data):\n return self.leader.predict(test_data)",
"def rerank_candidates(s, pred2sub_rank, all_predictions, rerank_top=20):\n predicted_smiles = []\n model_input = []\n for (predict_smi, label), _ in Counter(all_predictions).most_common(rerank_top):\n if predict_smi =... | [
"0.666519",
"0.66547555",
"0.6356968",
"0.6331515",
"0.63056386",
"0.6284501",
"0.6251712",
"0.6226527",
"0.6217676",
"0.6214155",
"0.6188862",
"0.6187148",
"0.61608523",
"0.61207634",
"0.6112756",
"0.61088276",
"0.6094322",
"0.6068124",
"0.6056098",
"0.6043708",
"0.6043401",... | 0.74521303 | 0 |
Uses the Java scorer class to evaluate the current predictions against the gold standard | def evaluate(predictions, gold_file, out_prediction_file):
# Save the evaluations to a file
with codecs.open(out_prediction_file, 'w', 'utf-8') as f_out:
for (w1, w2), curr_paraphrases in predictions.items():
for paraphrase, score in curr_paraphrases:
f_out.write('\t'.join((w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(gold, predictions):\n # gold = {i[\"id\"]:i[\"label\"] for i in read(goldfile)}\n # sys = {i[\"id\"]:i[\"prediction\"] for i in read(sysfile)}\n\n labels, preds = [], []\n for idx in gold:\n labels.append(gold[idx])\n preds.append(predictions[idx])\n\n precision_macro, rec... | [
"0.6964401",
"0.68686116",
"0.68332684",
"0.6827365",
"0.6802344",
"0.67987424",
"0.67133963",
"0.66858834",
"0.6635252",
"0.65584445",
"0.654457",
"0.6538255",
"0.6466884",
"0.6406567",
"0.63995945",
"0.6382254",
"0.63536125",
"0.6352743",
"0.6352538",
"0.63470036",
"0.63342... | 0.7871295 | 0 |
Gets the language model and retrieves the best k paraphrases for each nouncompound. | def predict_paraphrases(model, noun_compounds, words, word2index, UNK, k, unrelated_threshold):
paraphrases = {(w1, w2): defaultdict(float) for (w1, w2) in noun_compounds}
for (w1, w2) in tqdm.tqdm(noun_compounds):
w1_index, w2_index = word2index.get(w1, UNK), word2index.get(w2, UNK)
# Returns... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recognize_ngram(models: dict, test_set: SinglesData,probs,BIC_guesses):\n warnings.filterwarnings(\"ignore\", category=DeprecationWarning)\n probabilities = []\n guesses = []\n\n model = arpa.loadf(\"devel-lm-M3.sri.lm\")\n lm = model[0] # ARPA files may contain several models.\n # TODO impl... | [
"0.6086925",
"0.58658475",
"0.5675693",
"0.5606296",
"0.55020744",
"0.54597014",
"0.5406017",
"0.53975177",
"0.53480196",
"0.53395545",
"0.53378415",
"0.5311126",
"0.5265781",
"0.52246004",
"0.5221439",
"0.5218099",
"0.5198805",
"0.5190028",
"0.5162071",
"0.5107365",
"0.50935... | 0.65650994 | 0 |
Gets the paraphrase word indices and returns the text | def get_paraphrase_text(words, par_indices):
paraphrase_words = [words[i] for i in par_indices]
paraphrase = ' '.join(paraphrase_words)
yield paraphrase | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_paraphrase_vector(w1, w2, paraphrase, model, word2index, UNK):\n paraphrase = paraphrase.replace(w1, '[w1]').replace(w2, '[w2]')\n par_indices = tuple([word2index.get(w, UNK) for w in paraphrase.split()])\n return model.__compute_state__(par_indices, -1).npvalue()",
"def __getitem__(self, in... | [
"0.6314425",
"0.6210464",
"0.6197732",
"0.6069608",
"0.59872603",
"0.59198254",
"0.58468634",
"0.5836494",
"0.58288574",
"0.58069897",
"0.5805492",
"0.5784904",
"0.5778147",
"0.5773557",
"0.57684636",
"0.5756537",
"0.57161903",
"0.5708709",
"0.5705941",
"0.5698667",
"0.569617... | 0.76571596 | 0 |
Gets a list of ranked paraphrases for each nouncompound and extracts features from them | def generate_features(paraphrases, pos2index, prep2index, model, wv, word2index, UNK):
features = []
for (w1, w2), curr_paraphrases in tqdm.tqdm(paraphrases.items()):
features.append([extract_paraphrase_features(w1, w2, paraphrase, pos2index, prep2index,
mode... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_nouns(self, review):\n review_features = []\n for sent in review:\n doc = self.nlp(sent)\n # noun_phrase = [np.text for np in doc.noun_chunks]\n nouns = [unicode(lemma(str(word).lower())) for word in doc if word.pos == NOUN]\n review_features.appen... | [
"0.68040013",
"0.6160954",
"0.6086475",
"0.60117227",
"0.5977144",
"0.5969226",
"0.59136415",
"0.58758855",
"0.5782871",
"0.5655927",
"0.56308424",
"0.56187904",
"0.5608957",
"0.55873907",
"0.5565955",
"0.556548",
"0.55610794",
"0.5515918",
"0.5476384",
"0.5451666",
"0.544050... | 0.6619479 | 1 |
Gets a textual paraphrase and returns its vector | def compute_paraphrase_vector(w1, w2, paraphrase, model, word2index, UNK):
paraphrase = paraphrase.replace(w1, '[w1]').replace(w2, '[w2]')
par_indices = tuple([word2index.get(w, UNK) for w in paraphrase.split()])
return model.__compute_state__(par_indices, -1).npvalue() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_paraphrase_text(words, par_indices):\n paraphrase_words = [words[i] for i in par_indices]\n paraphrase = ' '.join(paraphrase_words)\n yield paraphrase",
"def parse(self, text):\n return self.dict.txt2vec(text)",
"def paragraph(self, text):\n return [text]",
"def embed(text: str... | [
"0.6398331",
"0.6294282",
"0.6231671",
"0.61348563",
"0.5986641",
"0.5968212",
"0.5966133",
"0.5963177",
"0.58148247",
"0.569725",
"0.5689744",
"0.5685823",
"0.5682646",
"0.5677916",
"0.5668583",
"0.5667986",
"0.5667986",
"0.5667986",
"0.5667986",
"0.5667986",
"0.56595486",
... | 0.6377952 | 1 |
Loads the train gold file | def load_gold(train_gold_file):
with codecs.open(train_gold_file, 'r', 'utf-8') as f_in:
lines = [line.strip().split('\t') for line in f_in]
train_gold = { (w1, w2) : {} for (w1, w2, paraphrase, score) in lines }
for w1, w2, paraphrase, score in lines:
train_gold[(w1, w2)][paraphrase] = flo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_training(self):\n path = \"./training/\" + self.training + \".json\"\n\n data = {}\n\n with open(path, \"r\") as infile:\n data = json.load(infile)\n\n self.states = data[\"states\"]\n self.transitions = data[\"transitions\"]\n self.matrix = data[\"matr... | [
"0.6897506",
"0.67354053",
"0.6667864",
"0.65146667",
"0.635465",
"0.63222456",
"0.63073456",
"0.627639",
"0.6255569",
"0.623886",
"0.62086767",
"0.6179395",
"0.6166554",
"0.61660075",
"0.613589",
"0.6132006",
"0.61087006",
"0.6100346",
"0.60898167",
"0.60873204",
"0.6081146"... | 0.7779592 | 0 |
Draws the maze, the dots in it and the number of PacMan's life. | def draw(self, DISP, life_counter:int, level:int):
assert self.is_init, 'Call first Game_Field.init() before draw game!'
y_count,x_count = 3, 0
start_maze = 0, 0
DISP.fill(Colors.colors['BLACK'])
# Maze get blit on the Screen of the game
DISP.blit(self.maz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_pacman_life(self, life_counter, DISP):\r\n for i in range(1, life_counter):\r\n # Position depends on the value i\r\n # Draw yellow circle\r\n pg.draw.circle(DISP, Colors.colors['YELLOW'], (i * self.grid_size * 2, self.grid_size * 35), 20)\r\n # Draw Pac-... | [
"0.68036896",
"0.66837734",
"0.6516421",
"0.6496038",
"0.6458555",
"0.64394176",
"0.64266",
"0.6377301",
"0.6111388",
"0.6104686",
"0.5927574",
"0.59211004",
"0.589521",
"0.5876166",
"0.58611715",
"0.58321404",
"0.5815164",
"0.5815077",
"0.57957387",
"0.5789465",
"0.5784682",... | 0.7114484 | 0 |
Returns the spwan position of the asked Object. | def find_startpos(self, searched_object:str):
fak = 1 #< When the figure needs to be pushed to the right -> fak = 1 else fak = 0
# The main figures spwan position beginns at index 14 and ends at size(self.look_up_table) - 9
start_index = 14
y = start_index
end_index = -9
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_pos(self):\n return self._pos",
"def get_pos(self):\n return self.pos",
"def get_pos(self):\r\n return self.pos",
"def get_position(self):\n return self.position",
"def get_position(self):\n return self.position",
"def get_position(self):\n return self._... | [
"0.68347555",
"0.6812192",
"0.6796328",
"0.66932124",
"0.66932124",
"0.66725576",
"0.66494673",
"0.6641232",
"0.6641232",
"0.6637379",
"0.6598867",
"0.6583544",
"0.6581534",
"0.6581534",
"0.65665764",
"0.6547338",
"0.6542076",
"0.6497624",
"0.6476217",
"0.6476217",
"0.6476217... | 0.69355536 | 0 |
Draws a blackline (if pink is False otherwise the line will be pink) on the position (indizes[0] grid_size, indizes[1] grid_size). Side indicates whether the line should be drawn horizontally or vertically. Possible values {'u', 'l'} 'u' > Up ; 'l' > Left | def draw_line(self, DISP, side:str, indizes:tuple, pink = False):
offset = 1 #< Just to draw the line nicely
pos = (indizes[0] - 1) * self.grid_size, indizes[1] * self.grid_size
# Check if it's a pink line
if pink:
start_pos = pos[0], pos[1] + self.grid_size // 2
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_gray_grid(self):\n gray = \"#D3D3D3\"\n # Draw the vertical lines\n for x in range(0, self.width, self.scale):\n self.canvas.create_line(x, 0, x, self.height, fill=gray)\n\n # Draw the horizontal lines\n for y in range(0, self.height, self.scale):\n ... | [
"0.60905635",
"0.60611",
"0.5898274",
"0.577904",
"0.57544893",
"0.5718297",
"0.5708298",
"0.57033575",
"0.56043583",
"0.5601031",
"0.5553713",
"0.5548981",
"0.5547163",
"0.55251795",
"0.55206865",
"0.5516502",
"0.5490055",
"0.54690945",
"0.5459518",
"0.5452845",
"0.5427957",... | 0.78228533 | 0 |
Draws PacMan's life amount in the bottom left. | def draw_pacman_life(self, life_counter, DISP):
for i in range(1, life_counter):
# Position depends on the value i
# Draw yellow circle
pg.draw.circle(DISP, Colors.colors['YELLOW'], (i * self.grid_size * 2, self.grid_size * 35), 20)
# Draw Pac-Man's mouth as ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_pavement():\n\n roberto.penup()\n roberto.goto(-345, -100)\n roberto.pendown()\n roberto.begin_fill()\n for i in range(4): # this loop draws a big black rectangle that is positioned at the bottom part of the screen\n roberto.forward(684)\n roberto.right(90)\n roberto.end_f... | [
"0.6292268",
"0.6246137",
"0.6228797",
"0.6222331",
"0.6200098",
"0.61066025",
"0.60988146",
"0.6033265",
"0.58881223",
"0.5880672",
"0.57524556",
"0.5713298",
"0.56595075",
"0.56576735",
"0.5637695",
"0.56332254",
"0.56199527",
"0.5602028",
"0.55786675",
"0.5556037",
"0.5520... | 0.73064053 | 0 |
Draws either 'READY!' or 'GAMER OVER!' on the screen depending on how much life PacMan has left. | def draw_ready_lose(self, DISP, life_counter = 1):
# When the life_counter isn't 0 that means Pac-Man is still alive and 'READY!' will be drawn in yellow
if life_counter != 0:
string = 'READY!'
color = Colors.colors['YELLOW']
# When the life_counter is 0 that means P... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_game_over(self):\n arcade.draw_rectangle_filled(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2,\n SCREEN_WIDTH // 2,\n SCREEN_HEIGHT // 1.5, arcade.color.BRONZE)\n arcade.draw_rectangle_filled(SCREEN_WIDTH // 2, 410, 600, 140, ... | [
"0.7441325",
"0.6980884",
"0.68780446",
"0.68211037",
"0.67693114",
"0.6738885",
"0.6699298",
"0.6676315",
"0.6635156",
"0.6546319",
"0.65387833",
"0.64995813",
"0.6484807",
"0.6474597",
"0.6462329",
"0.6454529",
"0.64513975",
"0.6450406",
"0.64430106",
"0.6425439",
"0.640726... | 0.796553 | 0 |
Resets the look up table. | def reset(self):
self.look_up_table = list(map(convert_to_list, self.const_look_up_table)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.table[:, :] = 0\n self.counts[:] = 0\n self.names = []\n self.hashesperid.resize(0)\n self.dirty = True",
"def reset(self):\n self._execute(\"DELETE FROM collection_table\")\n self._execute(\"DELETE FROM keyword_table\")",
"def reset_the_... | [
"0.6960028",
"0.67768866",
"0.6724996",
"0.6678758",
"0.6642319",
"0.65906394",
"0.65219396",
"0.6482897",
"0.64673764",
"0.639391",
"0.6384903",
"0.63602144",
"0.63567054",
"0.6356691",
"0.63014615",
"0.6225302",
"0.6221067",
"0.62178195",
"0.6217742",
"0.62106055",
"0.62002... | 0.8225295 | 0 |
Convertes the element to a list and return it. Is needed to convert the const_look_up_table to changeable list. | def convert_to_list(element):
return list(element) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_list(self) -> list:\n return self.A.tolist()",
"def to_list(self):\n return self._elements",
"def _convert_to_list(self, input_argument):\n if type(input_argument) is not list:\n input_argument = [input_argument]\n return input_argument",
"def _to_list( self, inp... | [
"0.6409021",
"0.6351938",
"0.62845224",
"0.6241752",
"0.62297237",
"0.62132937",
"0.62060744",
"0.617495",
"0.61564463",
"0.6084512",
"0.6074898",
"0.6057083",
"0.6023193",
"0.59878004",
"0.5978984",
"0.5939005",
"0.5932452",
"0.5926511",
"0.5925766",
"0.5913518",
"0.5887244"... | 0.73658144 | 0 |
To get the article images of a particular article | def article_images(id):
try:
query_string = '&artile_id='+str(id)
logger.info('Calling the api' + APIURL + '/images/?format=json'+query_string)
response = requests.get(APIURL + '/images/?format=json'+query_string)
parser = json.loads(response.content)
return parser
exce... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_images(self, article: BeautifulSoup):\n images = []\n content = article.select_one(self.parsing_template.content)\n\n if content:\n body_images = content.select(self.parsing_template.image_element)\n else:\n body_images = None\n\n if body_images:\n ... | [
"0.77207536",
"0.72780406",
"0.71895903",
"0.70886946",
"0.682747",
"0.6754981",
"0.65347177",
"0.64971083",
"0.64266795",
"0.637952",
"0.63597786",
"0.63298064",
"0.63253367",
"0.6325001",
"0.63128334",
"0.6282863",
"0.62725353",
"0.6267499",
"0.623031",
"0.62206644",
"0.618... | 0.7589555 | 1 |
To show the article with the search functionality | def search_news(request):
try:
query_string = ''
if request.GET['search_text'].strip() != '':
query_string = '&title='+request.GET['search_text']
response = requests.get(APIURL + '/articles/?format=json'+query_string)
parser = json.loads(response.content)
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def articleSearch(article_name):\n search_article_name = article_name.split(\"\")\n search_name_format = \"+\".join(search_article_name)\n searched_articles = search_articles(search_name_format)\n\n return render_template('search.html',articles = searched_articles)",
"def _on_articles_search(self, ev... | [
"0.7400061",
"0.7266843",
"0.70456195",
"0.68651915",
"0.6729217",
"0.6725937",
"0.6601247",
"0.6546082",
"0.64893246",
"0.6468126",
"0.6450786",
"0.6408295",
"0.6402254",
"0.6347182",
"0.6298593",
"0.6281749",
"0.62285197",
"0.6203344",
"0.61995083",
"0.6182697",
"0.61822957... | 0.74824566 | 0 |
Return version number applicable to the run_id. Most plugins just have a single version (in .__version__) but some may be at different versions for different runs (e.g. timedependent corrections). | def version(self, run_id=None):
return self.__version__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version_id(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"version_id\")",
"def get_version(self):\r\n\r\n return self.versions[0].number",
"def plugin_version(self):\n return self.__plugin_version",
"def get_version(self):\n return self.cur_config['version'... | [
"0.67273575",
"0.65237164",
"0.6444607",
"0.6440514",
"0.6420765",
"0.63832146",
"0.62829304",
"0.6261697",
"0.6239985",
"0.62183326",
"0.6203545",
"0.61928713",
"0.6148159",
"0.6143039",
"0.6109259",
"0.60980326",
"0.60925746",
"0.6088433",
"0.60486424",
"0.6047197",
"0.6042... | 0.8039234 | 0 |
Return dependencies grouped by data kind | def dependencies_by_kind(self, require_time=None):
if require_time is None:
require_time = \
len(self.dependencies_by_kind(require_time=False)) > 1
deps_by_kind = dict()
key_deps = []
for d in self.depends_on:
k = self.deps[d].data_kind
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_dependencies(package, dependency_type):\n for dependency_list in package.candidate.get_dependencies(dependency_type):\n for dependency in dependency_list.or_dependencies:\n yield dependency.name",
"def extract_deps(self, srcinfo):\n packages = {}\n pkgname = \"\"\n\... | [
"0.5978568",
"0.5900116",
"0.5787478",
"0.57377934",
"0.5695874",
"0.5687845",
"0.5683911",
"0.56371874",
"0.56361187",
"0.5633754",
"0.55988735",
"0.5536381",
"0.5515188",
"0.54281086",
"0.54215205",
"0.5414568",
"0.54068094",
"0.53991544",
"0.53707707",
"0.53679395",
"0.535... | 0.73225474 | 0 |
This function formats allcause mortality to be used for the ratein files. | def format_mortality_for_rate_in(mortality, input_dir):
# calculate what we need for age inputs
ages = get_age_bounds(input_dir)
mortality = mortality.merge(ages, on = ['age_group_id'])
mortality["age"] = (mortality["age_lower"] + mortality["age_upper"]) / 2
# in the function that c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatter(text):\n repl_map = {\n \"degC\": \"$^o$C\",\n \"K\": \"$^o$C\",\n \"month-1\": \"month$^{{-1}}$\",\n \"day-1\": \"day$^{{-1}}$\",\n \"d-1\": \"day$^{{-1}}$\",\n \"decade-1\": \"decade$^{{-1}}$\",\n \"year-1\": \"year... | [
"0.56308043",
"0.55896634",
"0.5553141",
"0.5513256",
"0.52830166",
"0.524594",
"0.5244249",
"0.52430886",
"0.523628",
"0.52355766",
"0.517552",
"0.51725256",
"0.51179194",
"0.507156",
"0.5056503",
"0.5018005",
"0.49559215",
"0.49474514",
"0.49109378",
"0.48775613",
"0.487119... | 0.6800289 | 0 |
Defines the Vagrant virtual machine's environment variables. Environments define and contain the information need to SSH into a server, e.g. IP address, SSH key, username, and possibly password. | def vagrant():
# Use Python's subprocess to run 'vagrant ssh-config' and parse results
raw_ssh_config = subprocess.Popen(['vagrant', 'ssh-config'],
stdout=subprocess.PIPE).communicate()[0]
ssh_config = dict([l.strip().split() for l in raw_ssh_config.split("\n")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vagrant(name=''):\n config = ssh_config(name)\n\n extra_args = _settings_dict(config)\n env.update(extra_args)",
"def v():\n env.user = 'vagrant'\n env.hosts = [env.local_host] # Update the Vagrantinit file if you change this\n\n # retrieve the IdentityFile:\n result = local('vagrant s... | [
"0.7282356",
"0.7034894",
"0.67848927",
"0.6616908",
"0.6489212",
"0.64254236",
"0.6412653",
"0.62720144",
"0.6206219",
"0.61621267",
"0.6110087",
"0.61064553",
"0.6077876",
"0.6071599",
"0.6066594",
"0.59957147",
"0.59937173",
"0.5987203",
"0.5979769",
"0.59783363",
"0.59336... | 0.8097556 | 0 |
Install the Python package 'virtualenv' so we can install Python packages safely into a virtualenv and not the system Python. | def sub_install_virtualenv():
sudo('pip install virtualenv') # Need sudo b/c installing to system Python | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_virtualenv():\n from .project import sudo_project, virtualenv_path\n\n with sudo():\n virtualenv.install()\n\n with sudo_project():\n virtualenv.create(virtualenv_path())",
"def setup_virtualenv():\n run('virtualenv -p %(python)s --no-site-packages %(env_path)s;' % env)\n ... | [
"0.83808315",
"0.8182777",
"0.7798719",
"0.77791345",
"0.76520973",
"0.76431155",
"0.7454994",
"0.74138564",
"0.7388706",
"0.7281482",
"0.7109159",
"0.7094787",
"0.7041513",
"0.7030718",
"0.7024118",
"0.6981084",
"0.68995255",
"0.68034196",
"0.6760135",
"0.6666842",
"0.666375... | 0.8402382 | 0 |
Install the Flask apps' Python requirements into the virtualenv. We need to activate the virtualenv before installing into it. We do that with the command 'source /server/bin/activate'. The application requirements live in the requirements.txt file shared with the VM. This file lives at /vagrant/flask_ml/requirements.t... | def sub_install_python_requirements():
# Activate the virtualenv
activate = 'source {0}/{1}/bin/activate'.format(
env.virtualenv['dir'], env.virtualenv['name'])
run(activate)
# Install Python requirements
install = 'pip install -r /vagrant/Flask_app/requirements.txt'
# Join and execute... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sub_install_python_requirements_aws():\n # Activate the virtualenv\n activate = 'source {0}/{1}/bin/activate'.format(\n env.virtualenv['dir'], env.virtualenv['name'])\n run(activate)\n\n # make sure the directory is there\n run('mkdir -p /home/ubuntu')\n\n # put the local directory '/U... | [
"0.7874438",
"0.756458",
"0.7495984",
"0.7365335",
"0.7352082",
"0.72606426",
"0.72560936",
"0.72021437",
"0.7105091",
"0.7051789",
"0.69526684",
"0.68236876",
"0.68107194",
"0.68042004",
"0.6791009",
"0.6771425",
"0.67663604",
"0.667629",
"0.66111684",
"0.66001976",
"0.65740... | 0.849011 | 0 |
Run the Flask development server on the VM. | def dev_server():
# Activate the virtualenv
activate = 'source {0}/{1}/bin/activate'.format(
env.virtualenv['dir'], env.virtualenv['name'])
# Run the file app.py to start the Flask app
dev_server = 'python vagrant/Flask_app/app.py'
run(activate + '; ' + dev_server) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(site):\n\n # Run the \"startdevserver\" script on the VM.\n # That will start the Yesod development server.\n Vagrant.run_script_on_vm('startdevserver', site)",
"def main():\n # Debug is enabled by default, can be disabled by environment variable\n debug = not os.environ.get(\"... | [
"0.75379694",
"0.73693675",
"0.73543936",
"0.73468",
"0.7300184",
"0.72539234",
"0.7252573",
"0.72484344",
"0.71830666",
"0.7180276",
"0.7075799",
"0.7050976",
"0.7048948",
"0.7034422",
"0.6966635",
"0.6955733",
"0.6950286",
"0.6947638",
"0.69259727",
"0.68738633",
"0.6862888... | 0.8405365 | 0 |
Install the Flask apps' Python requirements into the aws. We need to activate the virtualenv before installing into it. We do that with the command 'source /server/bin/activate'. We copy the Flask apps' directory using Fabric's copy mechanism to /home/ubuntu. The application requirements live in the requirements.txt fi... | def sub_install_python_requirements_aws():
# Activate the virtualenv
activate = 'source {0}/{1}/bin/activate'.format(
env.virtualenv['dir'], env.virtualenv['name'])
run(activate)
# make sure the directory is there
run('mkdir -p /home/ubuntu')
# put the local directory '/Users/jenniferc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sub_install_python_requirements():\n # Activate the virtualenv\n activate = 'source {0}/{1}/bin/activate'.format(\n env.virtualenv['dir'], env.virtualenv['name'])\n run(activate)\n\n # Install Python requirements\n install = 'pip install -r /vagrant/Flask_app/requirements.txt'\n\n # Jo... | [
"0.7395356",
"0.7240425",
"0.71181935",
"0.7063829",
"0.6867161",
"0.6847857",
"0.6746025",
"0.6720098",
"0.6698959",
"0.6648408",
"0.66291994",
"0.6622043",
"0.6606572",
"0.6581406",
"0.6560728",
"0.6560198",
"0.65439075",
"0.6528172",
"0.64761424",
"0.6450129",
"0.64466447"... | 0.8832733 | 0 |
Read the specified configuration file, return an instance of ConfigObj with the file contents. If no file is specified, look in the standard locations for weewx.conf. Returns the filename of the actual configuration file, as well as the ConfigObj. | def read_config(config_path, args=None, locations=DEFAULT_LOCATIONS,
file_name='weewx.conf'):
# Find and open the config file:
config_path = find_file(config_path, args,
locations=locations, file_name=file_name)
# Now open it up and parse it.
config_dict = con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getConfigFile(inFileName):\r\n\r\n configFile = ConfigObj(inFileName)\r\n return configFile",
"def read_config_file(f):\n\n if isinstance(f, six.string_types):\n f = os.path.expanduser(f)\n\n try:\n config = ConfigObj(f, interpolation=False, encoding='utf8')\n except ConfigObjErr... | [
"0.70306796",
"0.69833416",
"0.6939661",
"0.67386365",
"0.66881275",
"0.66806364",
"0.66645765",
"0.6642026",
"0.66187704",
"0.65870726",
"0.65609807",
"0.65542424",
"0.6477274",
"0.642738",
"0.63993204",
"0.6385674",
"0.6378292",
"0.6370475",
"0.6345146",
"0.6344783",
"0.634... | 0.698747 | 1 |
If a driver has a configuration editor, then use that to insert the stanza for the driver in the config_dict. If there is no configuration editor, then inject a generic configuration, i.e., just the driver name with a single 'driver' element that points to the driver file. | def modify_config(config_dict, stn_info, logger, debug=False):
driver_editor = None
driver_name = None
driver_version = None
# Get the driver editor, name, and version:
driver = stn_info.get('driver')
if driver:
try:
# Look up driver info:
driver_editor, driver_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_driver(self, config):\n raise NotImplementedError",
"def prompt_for_driver_settings(driver):\n settings = dict()\n try:\n __import__(driver)\n driver_module = sys.modules[driver]\n loader_function = getattr(driver_module, 'confeditor_loader')\n editor = load... | [
"0.6013708",
"0.56654024",
"0.5542582",
"0.5438296",
"0.5362613",
"0.52685124",
"0.5168918",
"0.5117495",
"0.50873053",
"0.50542545",
"0.50474286",
"0.50392866",
"0.50289696",
"0.50102735",
"0.5009427",
"0.49728853",
"0.49707973",
"0.49681544",
"0.4954418",
"0.49533752",
"0.4... | 0.7435699 | 0 |
Merge the configuration dictionary into the template dictionary, overriding any options. Return the results. | def merge_config(config_dict, template_dict):
# Turn off interpolation so what gets merged is the symbolic name
# (such as WEEWX_ROOT), and not its interpolated value.
csave, config_dict.interpolation = config_dict.interpolation, False
tsave, template_dict.interpolation = template_dict.interpolation, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_merge_template(\n self, template_name: str, dry_run: Optional[bool] = True\n ):\n\n config = self.nornir.run(\n task=self.render_template_apply, \n template_name=template_name\n )\n\n return config",
"def get_config_template(self) -> cconfig.Conf... | [
"0.66615707",
"0.6118342",
"0.60106754",
"0.5975559",
"0.5952871",
"0.5946836",
"0.5901115",
"0.59000844",
"0.58537644",
"0.5729377",
"0.5718389",
"0.5718389",
"0.5643264",
"0.5632022",
"0.5610437",
"0.5588955",
"0.5586331",
"0.55536616",
"0.5533419",
"0.55260843",
"0.5491966... | 0.7422343 | 0 |
Extract station info from config dictionary. | def get_station_info(config_dict):
stn_info = dict()
if config_dict is not None:
if 'Station' in config_dict:
stn_info['location'] = weeutil.weeutil.list_as_string(config_dict['Station'].get('location'))
stn_info['latitude'] = config_dict['Station'].get('latitude')
st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_station(station_id):\n return STATIONS.station_details_for(station_id)",
"def show_info(self):\n print 'Querying the station for the configuration...'\n config = self.station.getConfig()\n for key in sorted(config):\n print '%s: %s' % (key, config[key])",
"def station... | [
"0.59641033",
"0.5936034",
"0.5896959",
"0.5843976",
"0.5788015",
"0.5775463",
"0.57568306",
"0.57168424",
"0.5668025",
"0.5643908",
"0.5641532",
"0.5591261",
"0.5546629",
"0.54703164",
"0.53777015",
"0.53747267",
"0.5364926",
"0.5330737",
"0.52979475",
"0.5289177",
"0.527992... | 0.7870094 | 0 |
Move the section with key src to just before (after=False) or after (after=True) the section with key dst. | def reorder_sections(config_dict, src, dst, after=False):
bump = 1 if after else 0
# We need both keys to procede:
if src not in config_dict.sections or dst not in config_dict.sections:
return
# If index raises an exception, we want to fail hard.
# Find the source section (the one we intend ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(self, dst, src): # pragma: no cover\n raise NotImplementedError(\"Implement this\")",
"def move_task_to_previous_section(task):\n sourceSection = task.section\n lastSection = None # keeps track of the last seen section\n board = task.section.board\n\n for section in board.sectio... | [
"0.5842042",
"0.580982",
"0.578126",
"0.51932806",
"0.51496595",
"0.5131615",
"0.5126525",
"0.512234",
"0.5045291",
"0.4967211",
"0.49648216",
"0.49382284",
"0.49148327",
"0.48354185",
"0.48345056",
"0.48243433",
"0.47993344",
"0.47946876",
"0.4787239",
"0.4776789",
"0.477643... | 0.7374589 | 0 |
Reorder any sections in concordance with a reference ordering. See the definition for canonical_ordering for the details of the tuple used to describe a section. | def reorder_to_ref(config_dict, section_tuple=canonical_order):
if not len(section_tuple):
return
# Get the names of any subsections in the order they should be in:
subsection_order = [x[0] for x in section_tuple[1]]
# Reorder the subsections, then the scalars
config_dict.sections = reorder(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reorder_sections(config_dict, src, dst, after=False):\n bump = 1 if after else 0\n # We need both keys to procede:\n if src not in config_dict.sections or dst not in config_dict.sections:\n return\n # If index raises an exception, we want to fail hard.\n # Find the source section (the one... | [
"0.6032717",
"0.56960714",
"0.56764495",
"0.5591503",
"0.55622596",
"0.5329738",
"0.53044915",
"0.52889836",
"0.5190959",
"0.5150666",
"0.5129984",
"0.5109528",
"0.503666",
"0.5016965",
"0.49835104",
"0.49655825",
"0.49630913",
"0.49468616",
"0.4930213",
"0.49283034",
"0.4924... | 0.66799027 | 0 |
Reorder the names in name_list, according to a reference list. | def reorder(name_list, ref_list):
result = []
# Use the ordering in ref_list, to reassemble the name list:
for name in ref_list:
# These always come at the end
if name in ['FTP', 'RSYNC']:
continue
if name in name_list:
result.append(name)
# For any that w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reorder(self, flair_list: list[str]):\n self._reorder(flair_list, is_link=False)",
"def reorder(self, flair_list: list[str]):\n self._reorder(flair_list, is_link=True)",
"def sortednameslist(nameslist):\n sortednames = sorted(nameslist, key=lambda x: x[1])\n return sortednames",
"def ... | [
"0.6722222",
"0.67198366",
"0.6607647",
"0.6175491",
"0.61730516",
"0.5887209",
"0.5796876",
"0.57955277",
"0.5737509",
"0.57170206",
"0.5698204",
"0.5652035",
"0.5644076",
"0.5640249",
"0.56090343",
"0.5593094",
"0.5591264",
"0.55881953",
"0.5580639",
"0.5577209",
"0.5573619... | 0.83331525 | 0 |
Remove fields from a_dict that are present in b_dict | def remove_and_prune(a_dict, b_dict):
for k in b_dict:
if isinstance(b_dict[k], dict):
if k in a_dict and type(a_dict[k]) is configobj.Section:
remove_and_prune(a_dict[k], b_dict[k])
if not a_dict[k].sections:
a_dict.pop(k)
elif k in a_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip(a, b):\n out = {}\n for key, value in a.items():\n if key in b:\n out[key] = value\n return out",
"def task_2_remove_dict_fields(data: DT, redundant_keys: List[str]) -> DT:\n dict2 = copy.deepcopy(data)\n for item in dict2:\n for key in redundant_keys:\n ... | [
"0.7011635",
"0.6817846",
"0.67553777",
"0.66520184",
"0.66498756",
"0.65856653",
"0.65826637",
"0.64512944",
"0.6419275",
"0.6335364",
"0.6279814",
"0.6227952",
"0.61030716",
"0.6099511",
"0.5987218",
"0.5982835",
"0.59815437",
"0.59327006",
"0.59226257",
"0.5914336",
"0.587... | 0.74013305 | 0 |
Prepend the value to every instance of the label in dict a_dict | def prepend_path(a_dict, label, value):
for k in a_dict:
if isinstance(a_dict[k], dict):
prepend_path(a_dict[k], label, value)
elif k == label:
a_dict[k] = os.path.join(value, a_dict[k]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepend_attribute_label(table, header):\n for row in table:\n for i in range(len(row)):\n row[i] = header[i] + \"=\" + str(row[i])",
"def add_to_label_index_dict(label, starting_index, ending_index, label_index_dict):\r\n\tlabel = label.upper()\r\n\tif label in label_index_dict.keys():\r... | [
"0.62885374",
"0.5871335",
"0.5721377",
"0.56856835",
"0.5602765",
"0.5561603",
"0.54777884",
"0.5451436",
"0.544827",
"0.5412233",
"0.5362796",
"0.5349844",
"0.5286626",
"0.52848953",
"0.52824056",
"0.527682",
"0.52599835",
"0.5250375",
"0.52483773",
"0.5239945",
"0.5234623"... | 0.68243814 | 0 |
Scan the drivers folder, extracting information about each available driver. Return as a dictionary, keyed by the driver module name. Valid drivers must be importable, and must have attribute "DRIVER_NAME" defined. | def get_driver_infos(driver_pkg_name='weewx.drivers', excludes=['__init__.py']):
__import__(driver_pkg_name)
driver_package = sys.modules[driver_pkg_name]
driver_pkg_directory = os.path.dirname(os.path.abspath(driver_package.__file__))
driver_list = [os.path.basename(f) for f in glob.glob(os.path.join(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_drivers(dirpath):\n\n return all_drivers",
"def get_driver_names():\n return drivers.keys()",
"def list_drivers(self):\n return self.ironic_client.driver.list()",
"def getDrivers(self):\n return [self.driver]",
"def get_driver_list():\n return list(object_store.ObjectStorageD... | [
"0.729208",
"0.7261885",
"0.6827925",
"0.67849773",
"0.6691345",
"0.6581389",
"0.63602537",
"0.62989587",
"0.62372786",
"0.60738206",
"0.6021191",
"0.5959028",
"0.587157",
"0.58378494",
"0.5824736",
"0.5796958",
"0.5758254",
"0.57539886",
"0.5739294",
"0.57340384",
"0.5723755... | 0.81375885 | 0 |
Get information about all the available drivers, then print it out. | def print_drivers():
driver_info_dict = get_all_driver_infos()
keys = sorted(driver_info_dict)
print "%-25s%-15s%-9s%-25s" % (
"Module name", "Driver name", "Version", "Status")
for d in keys:
print " %(module_name)-25s%(driver_name)-15s%(version)-9s%(status)-25s" % driver_info_dict[d] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_driver_list(outfile=None):\n if not outfile:\n outfile = sys.stdout\n print(\"List of output drivers:\", file=outfile)\n for drv in sorted(GenericDriver.drivers):\n print(\" \", \"driver\", drv, file=outfile)\n formats = GenericDriver.drivers[drv].driver_formats\n d... | [
"0.73859334",
"0.7062846",
"0.7051157",
"0.6904719",
"0.6622632",
"0.66191065",
"0.64681315",
"0.6348724",
"0.6334314",
"0.6290319",
"0.6273544",
"0.62370235",
"0.6196706",
"0.6146711",
"0.6138265",
"0.6082094",
"0.60701346",
"0.59430975",
"0.5926224",
"0.5819765",
"0.5818428... | 0.81833833 | 0 |
Load the configuration editor from the driver file | def load_driver_editor(driver_module_name):
__import__(driver_module_name)
driver_module = sys.modules[driver_module_name]
editor = None
driver_name = None
driver_version = 'undefined'
if hasattr(driver_module, 'confeditor_loader'):
loader_function = getattr(driver_module, 'confeditor_lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confeditor_loader():\n return MQTTSubscribeDriverConfEditor()",
"def load(self,filename=None):\n if not filename:\n if self.__configfile:\n filename=self.__configfile\n self.__create_default_config()\n else:\n raise Exception(_('EVO... | [
"0.6992621",
"0.6453294",
"0.637084",
"0.62900895",
"0.62488085",
"0.6138954",
"0.6079617",
"0.60206604",
"0.6002656",
"0.59966636",
"0.5996375",
"0.5989108",
"0.5976054",
"0.5946294",
"0.592618",
"0.58801323",
"0.58166254",
"0.57937706",
"0.5771818",
"0.5726982",
"0.5711009"... | 0.7000054 | 0 |
Get the installer in the given extension installer subdirectory | def get_extension_installer(extension_installer_dir):
old_path = sys.path
try:
# Inject the location of the installer directory into the path
sys.path.insert(0, extension_installer_dir)
try:
# Now I can import the extension's 'install' module:
__import__('install'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetPackageDirectory():\n return os.path.dirname(__file__)",
"def get_extension(publisher_id, extension_id, organization=None, detect=None):\n organization = resolve_instance(detect=detect, organization=organization)\n extension_client = get_extension_client(organization)\n return extension_client... | [
"0.5897479",
"0.5840253",
"0.5825115",
"0.58030903",
"0.57243335",
"0.56099784",
"0.5539198",
"0.5520097",
"0.5488922",
"0.54647434",
"0.5424",
"0.54016614",
"0.5384804",
"0.5378252",
"0.5375597",
"0.53719527",
"0.5369558",
"0.53444946",
"0.53417146",
"0.5329628",
"0.5324527"... | 0.7098988 | 0 |
Calculate and return the candidate to vote fractions (<= 1.0). | def calculate_vote_fractions():
return _calculate_vote_fractions(models.get_candidate_to_vote_count()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calculate_vote_fractions(candidate_to_vote_count):\n total_votes = sum(candidate_to_vote_count.values()) or 1\n return {\n candidate: vote_count / total_votes\n for candidate, vote_count\n in candidate_to_vote_count.items()\n }",
"def get_percentage_f_votes(self):\n\n vo... | [
"0.75605893",
"0.69409996",
"0.67276734",
"0.66677374",
"0.66306704",
"0.6629966",
"0.6464066",
"0.64514613",
"0.6433749",
"0.6381045",
"0.6285484",
"0.62798536",
"0.6264931",
"0.62023294",
"0.62009144",
"0.618005",
"0.61743987",
"0.61708397",
"0.6135812",
"0.6129021",
"0.611... | 0.846586 | 0 |
From a dictionary from candidate to vote count, calculate candidate to vote fractions (<= 1.0). | def _calculate_vote_fractions(candidate_to_vote_count):
total_votes = sum(candidate_to_vote_count.values()) or 1
return {
candidate: vote_count / total_votes
for candidate, vote_count
in candidate_to_vote_count.items()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_vote_fractions():\n return _calculate_vote_fractions(models.get_candidate_to_vote_count())",
"def p(party, vote_count, s):\n return t(party, vote_count) / d(s)",
"def relative(dict):\n retval = {}\n count = float(sum(dict.values()))\n for k, v in dict.iteritems():\n retval[k... | [
"0.7560761",
"0.6411826",
"0.63160956",
"0.6029443",
"0.59476733",
"0.5888285",
"0.58650106",
"0.5859354",
"0.5820625",
"0.57457083",
"0.5741211",
"0.5699178",
"0.56415486",
"0.56034905",
"0.5574403",
"0.5570699",
"0.5569077",
"0.5520476",
"0.5504502",
"0.55002844",
"0.548549... | 0.8189057 | 0 |
Get interesting objects currently visible from the given latitude and longitude. | def get_visible_objects(lat, lon):
visible = []
observer = ephem.Observer()
observer.lat = str(lat)
observer.lon = str(lon)
for object_class in AstroObject.INTERESTING_OBJECTS:
obj = object_class()
obj.compute(observer)
if obj.alt >= MIN_ALT:
visible.append(AstroO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def browse(self, lat, lon):\n places = self.filter(active=True).order_by('-id')[:10]\n items = []\n for item in places:\n item.distance = item.compute_distance(lat, lon)\n item.orientation = self.orientation(int(item.compute_orientation(lat,lon)))\n items.appen... | [
"0.6773734",
"0.675765",
"0.60374904",
"0.5840118",
"0.56242305",
"0.5490242",
"0.54837286",
"0.54837286",
"0.54733807",
"0.5456372",
"0.54531646",
"0.54208964",
"0.54179657",
"0.5407709",
"0.53875333",
"0.53752196",
"0.5362545",
"0.5361334",
"0.5344775",
"0.53195256",
"0.531... | 0.80503064 | 0 |
Based on the nucleotide base context number, return a list of strings representing each context. | def get_all_context_names(context_num):
if context_num == 0:
return ['None']
elif context_num == 1:
return ['A', 'C', 'T', 'G']
elif context_num == 1.5:
return ['C*pG', 'CpG*', 'TpC*', 'G*pA',
'A', 'C', 'T', 'G']
elif context_num == 2:
dinucs = list(set(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_basestrings(self):\n baseStrs = set()\n for x in self.xvals():\n for y in self.yvals():\n p = self.get_plaquette(x, y)\n if p is not None and p.base is not None:\n baseStrs.add(p.base)\n return list(baseStrs)",
"def get_cont... | [
"0.59381366",
"0.5821346",
"0.57032585",
"0.563676",
"0.55630386",
"0.5479997",
"0.542715",
"0.54053235",
"0.537017",
"0.5345842",
"0.5339015",
"0.53155655",
"0.5313239",
"0.524433",
"0.52112395",
"0.51804495",
"0.5082934",
"0.5076986",
"0.50575507",
"0.5039618",
"0.50278604"... | 0.7266602 | 0 |
Retrieves relevant information about the effect of a somatic SNV on the amino acid of a gene. Information includes the germline codon, somatic codon, codon position, germline AA, and somatic AA. | def get_aa_mut_info(coding_pos, somatic_base, gene_seq):
# if no mutations return empty result
if not somatic_base:
aa_info = {'Reference Codon': [],
'Somatic Codon': [],
'Codon Pos': [],
'Reference Nuc': [],
'Reference AA': [],... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_aa_change( self ):\n for k,v in self.obj_mi.hash_isoforms.iteritems(): #k = string that is isoform_id, v = Isoform instance\n obj_tt = self.create_transcript_instances( k )\n\n #METHOD 1: get the original codon & mutated codon\n # orig_codon = obj_tt.ret... | [
"0.59315807",
"0.575898",
"0.5419792",
"0.5360489",
"0.5178644",
"0.5133092",
"0.5076269",
"0.5016404",
"0.50073624",
"0.49305987",
"0.4925875",
"0.4907826",
"0.4898044",
"0.48776296",
"0.4859834",
"0.48461547",
"0.48436293",
"0.4819732",
"0.4792958",
"0.47673345",
"0.4765182... | 0.64199305 | 0 |
Get all currently running threads as thread collection | def get_currently_running(cls, include_main_thread: bool = True) -> 'ThreadCollection':
result = []
for thread in threading.enumerate():
# noinspection PyProtectedMember
if not include_main_thread and isinstance(thread, threading._MainThread):
continue
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threads(self):\n return self.rpc.call(MsfRpcMethod.CoreThreadList)",
"def threads(self, **kwargs):\n return stats.threads(self._host, self._session, **kwargs)",
"def message_threads(self):\r\n return resource.MessageThreads(self)",
"def getThreads():\r\n return multiprocessing.cpu... | [
"0.75837064",
"0.70621043",
"0.69586414",
"0.6720364",
"0.6488229",
"0.6472203",
"0.63923824",
"0.6276579",
"0.6254887",
"0.6225861",
"0.61866957",
"0.61829114",
"0.6157111",
"0.61470133",
"0.59425855",
"0.5896691",
"0.5887221",
"0.5858366",
"0.58357793",
"0.5832114",
"0.5819... | 0.7452421 | 1 |
Build a thread collection | def from_class(cls, cls_to_use, iteratable, **kwargs) -> 'ThreadCollection':
return ThreadCollection([cls_to_use(it, **kwargs) for it in iteratable]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_threads(self, process, flag):\n\t\tself.parallel_threads.append(self.prepare_batch(process, flag))",
"def build() -> List[asyncio.Task]:",
"def __init__(self, w, p, location, foldername, featurefiles, maskfiles, nclasses, kw={}, num_threads=4, batch_size=1):\n super(ThreadedDataSetCollecti... | [
"0.6166909",
"0.6116655",
"0.6116042",
"0.6010415",
"0.60033154",
"0.59811956",
"0.5939592",
"0.5796228",
"0.57790613",
"0.57728904",
"0.5721909",
"0.5709346",
"0.56963396",
"0.56963146",
"0.56402516",
"0.56117487",
"0.5586219",
"0.55479497",
"0.5544311",
"0.5542954",
"0.5517... | 0.6234942 | 0 |
Is any of the threads a daemon? Also, when used a setter sets daemon attribute. | def daemon(self) -> bool:
return any(thread.daemon for thread in self.threads) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_to_daemon(self):\n self.thread.daemon = True\n self.logger.debug(\"thread is now daemon\")",
"def other_threads_are_active():\n return len(fake_threads) >= 2",
"def _daemonExists(self):\n return os.path.exists(self._lockFilename)",
"def is_alive(self) -> bool:\n return ... | [
"0.65501016",
"0.5723341",
"0.5670083",
"0.5493096",
"0.54841435",
"0.5469615",
"0.5426391",
"0.5406348",
"0.54056203",
"0.53998053",
"0.53947",
"0.5384649",
"0.5375056",
"0.53434217",
"0.53425556",
"0.5332634",
"0.52664685",
"0.52310926",
"0.521617",
"0.5171693",
"0.51684225... | 0.7762536 | 0 |
Add a thread to the collection | def add(self, thread: Thread) -> 'ThreadCollection':
self.threads.append(thread)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_thread(self, name):\n\n thread = Thread( name=name, thread_id=self._thread_id)\n self._threads.append( thread )\n self._thread_index[ name ] = self._thread_id \n\n self._thread_id += 1",
"def append(self, thd):\n if not isinstance(thd, threading.Thread):\n ra... | [
"0.7124437",
"0.6656607",
"0.6487381",
"0.64771247",
"0.64394623",
"0.6426365",
"0.6206292",
"0.6206292",
"0.6206292",
"0.6206292",
"0.6199234",
"0.6140896",
"0.6122313",
"0.6118141",
"0.61104184",
"0.60446006",
"0.6034069",
"0.60123575",
"0.6002139",
"0.5850961",
"0.5833845"... | 0.857151 | 0 |
Call terminate() on all threads that have this method | def terminate(self, *args, **kwargs) -> 'ThreadCollection':
for thread in self.threads:
try:
thread.terminate(*args, **kwargs)
except AttributeError:
pass
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def terminate_all(self):\n self._stop_all('terminate')",
"def terminate(self):",
"def cleanup():\n for th in THREAD_REGISTER.values():\n th.exit()\n th.join(timeout=3)",
"def terminate(self): # pragma: no cover ; not tested / running over multiprocessing\n\n self.loop = False... | [
"0.73901415",
"0.7210479",
"0.7186092",
"0.70327073",
"0.70017165",
"0.69788647",
"0.69788647",
"0.6957858",
"0.6951186",
"0.6922973",
"0.6858244",
"0.684549",
"0.68124145",
"0.6783078",
"0.67689455",
"0.6763414",
"0.67251503",
"0.6700467",
"0.6697825",
"0.6697244",
"0.669039... | 0.731831 | 1 |
Is at least one thread alive? | def is_alive(self) -> bool:
return any(thread.is_alive() for thread in self.threads) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alive(self):\n return self._thread is not None",
"def other_threads_are_active():\n return len(fake_threads) >= 2",
"def alive(self):\n return self._thread.is_alive()",
"def is_alive(self) -> bool:\n if self._thread is None:\n return False\n return self._thread.i... | [
"0.7850146",
"0.765176",
"0.7537609",
"0.7525823",
"0.7311284",
"0.7273257",
"0.7271938",
"0.7242515",
"0.72092927",
"0.7203256",
"0.70997065",
"0.70031345",
"0.69912636",
"0.69321656",
"0.6891094",
"0.6878961",
"0.68776757",
"0.68285125",
"0.6826723",
"0.6787953",
"0.6787200... | 0.7966522 | 0 |
Add a thread collection or a thread to this collection and return a new collection | def __add__(self, other: tp.Union['ThreadCollection', Thread, tp.Iterable[Thread]]):
if isinstance(other, Thread):
other = [other]
elif isinstance(other, ThreadCollection):
other = other.threads
else:
other = list(other)
return ThreadCollection(self.th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, thread: Thread) -> 'ThreadCollection':\n self.threads.append(thread)\n return self",
"def __iadd__(self, other: tp.Union['ThreadCollection', Thread, tp.Iterable[Thread]]):\n if isinstance(other, Thread):\n other = [other]\n elif isinstance(other, ThreadCollect... | [
"0.741004",
"0.7373582",
"0.555869",
"0.54820925",
"0.5466185",
"0.5417148",
"0.53353214",
"0.5322943",
"0.53202814",
"0.53149694",
"0.5253452",
"0.5218059",
"0.51454335",
"0.5134045",
"0.5118661",
"0.5117001",
"0.51031727",
"0.5098868",
"0.5087811",
"0.50637823",
"0.49973348... | 0.78848195 | 0 |
Perform the given move on the board; color gives the color pf the piece to play (1=white,1=black) | def execute_move(self, move, color):
(x, y) = move
# Add the piece to the empty square.
assert self[x][y] == 0
self[x][y] = color | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_move(self, move, color):\n\n #Much like move generation, start at the new piece's square and\n #follow it on all 8 directions to look for a piece allowing flipping.\n\n # Add the piece to the empty square.\n # print(move)\n flips = [flip for direction in self.__direct... | [
"0.7862946",
"0.73048145",
"0.7228364",
"0.7127093",
"0.70286006",
"0.69958055",
"0.6862473",
"0.6852248",
"0.6812398",
"0.6768464",
"0.6758164",
"0.6730595",
"0.6702749",
"0.6688776",
"0.66503227",
"0.6621769",
"0.65978765",
"0.65928787",
"0.6572336",
"0.6541384",
"0.6492052... | 0.80116236 | 0 |
Check if user credentials are provided. | def _has_auth(creds: Dict[str, str]) -> bool:
if creds.get("user") in [None, ""] or creds.get("passwd") in [None, ""]:
warnings.warn("Credentials were not supplied. Public data access only.", NoAuthWarning)
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_credentials(self):\n return self.username and self.password and self.url and self.xml_rpc",
"def _validate_credentials(self):\n\n # There should be a client_id and client secret\n return \"client_id\" in self.credentials.keys() and \"client_secret\" in self.credentials.keys() \\\n ... | [
"0.7321096",
"0.7241036",
"0.72268534",
"0.72180253",
"0.71465886",
"0.7132538",
"0.709354",
"0.70793575",
"0.7062491",
"0.70085",
"0.7006556",
"0.7005246",
"0.6997193",
"0.6955116",
"0.69186634",
"0.6916556",
"0.6883263",
"0.6859741",
"0.6831319",
"0.68288535",
"0.6823778",
... | 0.74056166 | 0 |
Return a dataframe with all available competitions and seasons. Returns pd.DataFrame A dataframe containing all available competitions and seasons. See | def competitions(self) -> DataFrame[Any]: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def games(self, competition_id: int, season_id: int) -> DataFrame[Any]:",
"def get_full_advanced_stats_df(season):\n stats = get_full_advanced_stats(season)\n stats_df = pd.DataFrame.from_dict(stats)\n\n return stats_df",
"def to_dataframe(self):\n \n #Try importing pandas\n try:\... | [
"0.7688012",
"0.6392126",
"0.6229848",
"0.60829717",
"0.5984204",
"0.5927727",
"0.58281636",
"0.5801889",
"0.5691693",
"0.5605408",
"0.5596733",
"0.5557909",
"0.55564725",
"0.55335134",
"0.5525764",
"0.5518164",
"0.55177367",
"0.5403855",
"0.53800285",
"0.53598124",
"0.534979... | 0.64431465 | 1 |
Return a dataframe with all available games in a season. | def games(self, competition_id: int, season_id: int) -> DataFrame[Any]: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_games(season):\n url = BASE_URL.format(season)\n json_data = requests.get(url, headers=HEADERS).json()\n all_games = json_data[\"resultSets\"][0][\"rowSet\"]\n return all_games",
"def season_games(year):\n\tLOG.debug('Getting season %d', year)\n\tdata = read_html(io=season_games_url(year)... | [
"0.7518974",
"0.7216193",
"0.69166124",
"0.6773283",
"0.6454651",
"0.6447401",
"0.63100016",
"0.6252245",
"0.62492555",
"0.62466854",
"0.6190892",
"0.6139664",
"0.61248934",
"0.6104807",
"0.61029416",
"0.60744864",
"0.606464",
"0.60395813",
"0.6014391",
"0.5986732",
"0.597665... | 0.80317754 | 0 |
Return a dataframe with both teams that participated in a game. | def teams(self, game_id: int) -> DataFrame[Any]: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def opponent_games(df, team, gameids):\n games = df[df.gameid.isin(gameids)]\n opponent_games = games[games.team != team].drop_duplicates(subset=['gameid'])[['gameid', 'team']]\n opponent_games.columns = ['gameid', 'opponent']\n\n return opponent_games",
"def get_teams_table(games_table: pd.DataFrame... | [
"0.74349976",
"0.7242164",
"0.7087932",
"0.6803562",
"0.67570406",
"0.6662141",
"0.656011",
"0.63300014",
"0.6244529",
"0.6117553",
"0.6106412",
"0.6092822",
"0.6076452",
"0.6065396",
"0.60509604",
"0.60246193",
"0.5997856",
"0.5974332",
"0.59698075",
"0.5960873",
"0.5953214"... | 0.7984827 | 0 |
Return a dataframe with all players that participated in a game. | def players(self, game_id: int) -> DataFrame[Any]: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def players(self):\n if self.players_cache is None:\n team_df = self.teams()\n self.players_cache = self.ea.players_endpoint(\n team_df[\"id\"].tolist())\n\n columns = [\"teamId\", \"playerId\", \"name\", \"position\"]\n all_players = []\n for team i... | [
"0.72494656",
"0.692754",
"0.66677886",
"0.66561776",
"0.66296536",
"0.6581351",
"0.64445984",
"0.6435483",
"0.63926226",
"0.63095874",
"0.62390083",
"0.61859995",
"0.6165702",
"0.6164053",
"0.6135402",
"0.6125713",
"0.61095655",
"0.6101006",
"0.6087651",
"0.6083399",
"0.6073... | 0.78324765 | 0 |
Return a dataframe with the event stream of a game. | def events(self, game_id: int) -> DataFrame[Any]: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dataframe(self):\n # Using a list here appears faster than using a generator expression\n df = pd.DataFrame.from_records(\n [{'event_id' : x.event_id,\n 'time_delta' : x.time_delta,\n 'src_id' : x.src_id,\n 't' : x.cur_time,\n ... | [
"0.6735974",
"0.658607",
"0.639075",
"0.6216606",
"0.61860037",
"0.6032813",
"0.5884575",
"0.561907",
"0.5530112",
"0.55259526",
"0.55163866",
"0.55126965",
"0.5502637",
"0.548082",
"0.5476669",
"0.5474925",
"0.5468282",
"0.5466279",
"0.54192626",
"0.5407201",
"0.5400746",
... | 0.78088486 | 0 |
This function is to help "mark" a time. (This has nothing to do with time signatures.) Once a time has been marked, it cannot be overwritten. | def mark(self, markName, markTime):
if markName not in self._marks:
self._marks[markName] = markTime | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setTime(self,time):\n self.time = time",
"def setTimepoint(self, tp):\n\t\tpass",
"def setSubmitTime(t):",
"def set_time(self, time):\n self._time = time",
"def change_time(self, new_time):\r\n self.when = new_time",
"def fake_time(cls, ignored):\n cls.FAKE_TIME += 2\n return c... | [
"0.64071274",
"0.64021486",
"0.62739956",
"0.6238053",
"0.6189398",
"0.61800396",
"0.61446834",
"0.61446834",
"0.61446834",
"0.61446834",
"0.61446834",
"0.611402",
"0.61078215",
"0.6094264",
"0.6091451",
"0.6091134",
"0.6058427",
"0.59317034",
"0.59317034",
"0.59317034",
"0.5... | 0.6745942 | 0 |
Get ServerType rows filtered by parameters. | def get(cls, id=None, name=None):
filters = dict()
if id:
cls.validate_id(id)
filters.update({"id": id})
if name:
cls.validate_name(name)
filters.update({"name": name})
result = ServerType.query.filter_by(**filters).all()
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_servers_types():\n ret = _get_list(\n lambda server: server.type if server.type not in ['vanilla.winter', 'vanilla.desert', 'pvp'] else False,\n lambda server: server.type_name\n )\n\n # Extra server type filters\n ret.append({\n 'value': 'pacific+edelweiss',\n '... | [
"0.62041783",
"0.5481276",
"0.5455004",
"0.53396076",
"0.5333453",
"0.51994854",
"0.5172975",
"0.51684576",
"0.5117118",
"0.51120913",
"0.5088386",
"0.5041316",
"0.5016562",
"0.49916086",
"0.4974847",
"0.49555188",
"0.4940552",
"0.49327105",
"0.49035612",
"0.49030566",
"0.486... | 0.6560987 | 0 |
Add new ServerType row. | def add(cls, name):
cls.validate_name(name)
new_status = ServerType(name)
DB.session.add(new_status)
DB.session.commit()
return new_status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_type(self, typename, db):\n self._dbs[typename] = db\n return None",
"def add_server(self, server):\n self.all_servers[server.server_id] = server\n self.servers_jobs_list[server.server_id] = server.jobs\n if server.status:\n self.servers_online[server.server_... | [
"0.60778517",
"0.6060359",
"0.6057143",
"0.59926903",
"0.59444785",
"0.5700356",
"0.56260115",
"0.5434323",
"0.54240054",
"0.54132724",
"0.54123",
"0.5392928",
"0.53589714",
"0.534125",
"0.52916306",
"0.5278637",
"0.5270139",
"0.52691203",
"0.5250192",
"0.52493966",
"0.523300... | 0.6391639 | 0 |
Delete existing ServerType row. | def delete(cls, type_obj):
DB.session.delete(type_obj)
DB.session.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self):\n type_model = request.json\n\n type_model = namedtuple(\"Type\", type_model.keys())(*type_model.values())\n repository = TypeRepository(\n FLASK_APP.config[\"DBUSER\"],\n FLASK_APP.config[\"DBPASS\"],\n FLASK_APP.config[\"DBHOST\"],\n ... | [
"0.6278826",
"0.6110024",
"0.6028006",
"0.57840484",
"0.5764372",
"0.5753501",
"0.57470953",
"0.5610394",
"0.559078",
"0.5457402",
"0.5433302",
"0.54309165",
"0.5374889",
"0.53612924",
"0.5356078",
"0.5348519",
"0.5304489",
"0.52823716",
"0.52790445",
"0.52747625",
"0.5267816... | 0.62874836 | 0 |
Returns the a list of projects ids as a json collection | def projects():
response = jsonify(projects_service.get_top_level_projects_ids())
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_projects(self):\n projects = []\n for project in self.server.projects:\n projects.append({'id': utils.slugify(project),\n 'name': project})\n response.content_type = 'application/json'\n return json.dumps(projects)",
"def project_list_jso... | [
"0.75772965",
"0.7346891",
"0.6982037",
"0.6979936",
"0.69269097",
"0.68894607",
"0.68818957",
"0.687884",
"0.6872077",
"0.68604904",
"0.67864627",
"0.6733254",
"0.6730592",
"0.6694601",
"0.66470087",
"0.65639174",
"0.65596277",
"0.6508292",
"0.64831495",
"0.6436257",
"0.6401... | 0.8037049 | 0 |
Returns the defined projects settings | def projects_settings():
return map_settings(settings_repository.settings) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_projects(self):\n return conf.projects",
"def settings():\n return _get_settings()[1]",
"def getSettings(self):\n return self.cfg",
"def get_settings():\n return SettingCollection.build()",
"def get_projects(self):\n if not self.validate():\n raise SettingCustomV... | [
"0.7944305",
"0.73158234",
"0.7182883",
"0.7087642",
"0.70306367",
"0.7016714",
"0.692769",
"0.6903739",
"0.68574196",
"0.68574196",
"0.67924243",
"0.67372715",
"0.6725301",
"0.66855377",
"0.66544014",
"0.66251636",
"0.66251636",
"0.66042525",
"0.6602571",
"0.6597946",
"0.658... | 0.8683347 | 0 |
Initiates an upload operation if file is missing. Once initiated the client is then responsible for uploading the file to temporary location (returned as 'upload_url') and finalizing the upload with call to 'finishUpload'. If file is already in the store, returns ALREADY_UPLOADED status. This method is not intended to ... | def begin_upload(self, request):
def error(msg):
return BeginUploadResponse(
status=BeginUploadResponse.Status.ERROR,
error_message=msg)
hash_algo = _HASH_ALGO_MAPPING[request.hash_algo]
if not impl.is_valid_hash_digest(hash_algo, request.file_hash):
return error('Invalid ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _upload(self) -> None:\n\n # filename given?\n filename = str(uuid.uuid4()) if self.filename is None else self.filename\n\n # check\n if self._upload_path is None:\n raise ValueError(\"No upload URL given.\")\n\n # send data and return image ID\n async... | [
"0.6213354",
"0.611551",
"0.609969",
"0.6060533",
"0.59731025",
"0.596974",
"0.5960028",
"0.59207714",
"0.5891002",
"0.588581",
"0.5852322",
"0.578891",
"0.57868373",
"0.57859796",
"0.5756303",
"0.57519907",
"0.57443607",
"0.57438284",
"0.5733361",
"0.5730023",
"0.5728268",
... | 0.6714775 | 0 |
Finishes pending upload or queries its status. Client should finalize Google Storage upload session first. Once GS upload is finalized and 'finishUpload' is called, the server starts hash verification. Uploading client will get 'VERIFYING' status response. It can continue polling on this method until server returns 'PU... | def finish_upload(self, request):
service = impl.get_cas_service()
if service is None:
raise endpoints.InternalServerErrorException('Service is not configured')
# Verify the signature if upload_session_id and grab the session. Broken
# or expired signatures are treated in same way as missing uplo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finish(cls, upload, location=None, bytes_downloaded=0):\n path = \"uploader/finish/%s\" % upload[\"id\"]\n LOGGER.debug(path)\n payload = {\"bytes_transferred\": bytes_downloaded, \"location\": location}\n try:\n return Backend.put(path, payload, headers=Backend.headers()... | [
"0.6578386",
"0.6393663",
"0.6311609",
"0.6290126",
"0.60276514",
"0.60131735",
"0.5975046",
"0.5960346",
"0.59039724",
"0.5867309",
"0.58376634",
"0.5834494",
"0.58318",
"0.57598555",
"0.5730202",
"0.566053",
"0.5659524",
"0.56517065",
"0.5646021",
"0.5644596",
"0.5566163",
... | 0.7069291 | 0 |
This function extracts all the desired characteristics of all new job postings of the title and location specified and returns them in single file. | def find_jobs_from(website, job_title, location, search_category, filename="results.xls"):
jobs_list = []
if website == 'Indeed':
job_soup = load_jobs_div(job_title, location)
jobs_list, num_listings = extract_job_details(
job_soup, search_category)
return jobs_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_details( session_requests, job_id ):\n \n url_prefix = CONFIG[\"url_prefix\"]\n \n #Extract html from web\n url = CONFIG[\"url_jobno\"] + str(job_id)\n tree = scrape_html(session_requests, url)\n \n #Extact description\n title = \"; \".join(tree.xpath(\"//p[@class='listheader... | [
"0.59336495",
"0.54380137",
"0.5429791",
"0.54140365",
"0.5314504",
"0.52315474",
"0.52120095",
"0.51939267",
"0.514179",
"0.5081871",
"0.5067355",
"0.50288165",
"0.5007095",
"0.498127",
"0.4966571",
"0.4955825",
"0.49111816",
"0.48940977",
"0.4887455",
"0.48834094",
"0.48777... | 0.5668499 | 1 |
Function to calculate the initial conditions to pass to ODEINT by converting units. Principally, converting initial disc mass from solar masses to grams, and calculating an initial angular frequency from a spin period in milliseconds. Usage >>> init_conds(P, MdiscI) | def init_conds(P, MdiscI):
Mdisc0 = MdiscI * Msol # Disc mass
omega0 = (2.0 * np.pi) / (1.0e-3 * P) # Angular frequency
return np.array([Mdisc0, omega0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _conditions(self, beg=-90, intvl=20, con_type='ori', stim='bar', \n\t\t\t\t\tbiphasic=True, unit='deg', con_list=[], temp_freq = 2):\n\t\t\n\t\t\n\t\tcon_types = ['ori', 'spat_freq', 'temporal_freq', 'chromatic', 'dl_bar']\n\t\tstims = ['bar', 'grating']\n\t\t\n\t\t\n\t\t# Checking if condition and stimulus ty... | [
"0.5232874",
"0.49474928",
"0.481711",
"0.47140566",
"0.46764776",
"0.46613753",
"0.46540195",
"0.46355078",
"0.46241882",
"0.45480436",
"0.45396182",
"0.45278305",
"0.45237565",
"0.45031017",
"0.44977742",
"0.441719",
"0.440181",
"0.43717387",
"0.43717176",
"0.4368938",
"0.4... | 0.81253755 | 0 |
Function to pass to ODEINT which will calculate a disc mass and angular frequency for given time points. Usage >>> ODEs(y, t, B, MdiscI, RdiscI, epsilon, delta, n) | def ODEs(y, t, B, MdiscI, RdiscI, epsilon, delta, n=1.0, alpha=0.1, cs7=1.0,
k=0.9):
# Initial conditions
Mdisc, omega = y
# Constants
Rdisc = RdiscI * 1.0e5 # Disc radius - cm
tvisc = Rdisc / (alpha * cs7 * 1.0e7) # Viscous timescale - s
mu = 1.0e15 * B * (R ** 3.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ODEfun(y,t,params):\n Im = y[0]\n Is = y[1]\n Ic = y[2]\n R = y[3]\n \n\n try:\n\n r = params['r']\n p = params['p']\n N = params['N']\n R0 = params['R0']\n k = params['k']\n m = params['m']\n n = params['n']\n m1 = params['m1']\n ... | [
"0.6069243",
"0.56809527",
"0.56642264",
"0.5610305",
"0.5605983",
"0.5572216",
"0.5515019",
"0.5499972",
"0.5472058",
"0.53189695",
"0.5267097",
"0.5251063",
"0.52329373",
"0.52322376",
"0.5201223",
"0.5186913",
"0.5179746",
"0.51516527",
"0.5148114",
"0.5146022",
"0.5140198... | 0.76782846 | 0 |
Convert a value or value array to a new unit and return a copy if inplace=False | def _to(
value: Union["Value", "ValueArray"], units: Union[Unit, str], inplace: bool
) -> Any:
if value.units == units:
return value
if value.units is None:
raise RuntimeError("Cannot convert with units=None")
try:
units = next(
imp_unit
for imp_unit in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_inplace_set_value(self):\r\n dtype = self.dtype\r\n if dtype is None:\r\n dtype = theano.config.floatX\r\n\r\n shp = (100/4,1024)#100KB\r\n\r\n x = numpy.zeros(shp, dtype=dtype)\r\n x = self.cast_value(x)\r\n x_shared = self.... | [
"0.65486306",
"0.60225356",
"0.591445",
"0.5828519",
"0.57220453",
"0.56878066",
"0.5627219",
"0.55983126",
"0.5587363",
"0.5563561",
"0.5548048",
"0.55333346",
"0.55041456",
"0.5413328",
"0.5399218",
"0.53800756",
"0.53422016",
"0.5341972",
"0.53012186",
"0.5295247",
"0.5289... | 0.72108907 | 0 |
Is an energy equal to another? Compares only the value, with implicit unit conversion | def __eq__(self, other: Any) -> bool:
tol_ha = 0.0000159 # 0.01 kcal mol-1
# A PotentialEnergy is not equal to a FreeEnergy, for example
if isinstance(other, Value) and not isinstance(other, self.__class__):
return False
if isinstance(other, Value):
other = oth... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if set(self.comp) != set(other.comp):\n return False\n if abs(self.energy - other.energy) > 1e-6:\n return False\n for key in self.comp:\n if abs(self.unit_comp[key] - other.unit_comp[key]) > 1e-6:\n return False\n ... | [
"0.7066215",
"0.69051033",
"0.65359586",
"0.6492319",
"0.64670944",
"0.6329468",
"0.63137656",
"0.63081795",
"0.62765265",
"0.62765265",
"0.62765265",
"0.62765265",
"0.62645483",
"0.6250249",
"0.62463707",
"0.62171537",
"0.62097025",
"0.6207712",
"0.61770636",
"0.6160313",
"0... | 0.7190593 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.