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 |
|---|---|---|---|---|---|---|
Check phase and amplitude values. | def _phampcheck(pha, amp):
assert pha.ndim == 3, ("`pha` should have a shape of (n_pha, n_epochs,"
" n_times)")
assert amp.ndim == 3, ("`amp` should have a shape of (n_pha, n_epochs,"
" n_times)")
assert pha.shape[1:] == amp.shape[1:]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_amplitude_damping_error_raises_invalid_phase_param(self):\n self.assertRaises(NoiseError,\n lambda: phase_amplitude_damping_error(0, -0.5, 0))\n self.assertRaises(NoiseError,\n lambda: phase_amplitude_damping_error(0, 1.1, 0))",
"def test_p... | [
"0.6330298",
"0.6048818",
"0.5883289",
"0.5877129",
"0.5870355",
"0.58168006",
"0.5809527",
"0.5797412",
"0.5774019",
"0.5642041",
"0.5579561",
"0.54734993",
"0.54658425",
"0.54479057",
"0.5440763",
"0.54205173",
"0.5369781",
"0.53484726",
"0.53235435",
"0.53225404",
"0.53094... | 0.6848933 | 0 |
Get the dcomplex value. | def dcomplex(self):
return self._dcomplex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(self):\n return complex(*self.points[0, :2])",
"def complex_value(self) -> global___Expression.ComplexValue:",
"def to_float_complex(self):\r\n return eval(str(self))",
"def __complex__(self):\n return complex(self.q[0], self.q[1])",
"def __complex__(self) -> complex:\n ... | [
"0.7609465",
"0.7561717",
"0.71161824",
"0.70365214",
"0.70332503",
"0.6865073",
"0.6778516",
"0.67586607",
"0.6553343",
"0.62245595",
"0.6223936",
"0.61530626",
"0.6044746",
"0.6036414",
"0.5984434",
"0.59224284",
"0.58692884",
"0.5846835",
"0.58340853",
"0.5825428",
"0.5816... | 0.87845105 | 0 |
Get the cycle value. | def cycle(self):
return self._cycle | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cycleInterval(self):\n return self.processCycleInterval",
"def get_duty_cycle(self):\n return self._mixer.duty_cycle",
"def calculate(self, cycle):\n # at first cycle just return the initial value\n if cycle == 0:\n self.current_value.append(self.current_value[0])\n ... | [
"0.7036989",
"0.6872306",
"0.6794951",
"0.6439719",
"0.6369555",
"0.6299084",
"0.6281027",
"0.6240008",
"0.6211102",
"0.61720306",
"0.616593",
"0.6137996",
"0.6132796",
"0.61175",
"0.61065483",
"0.6058376",
"0.60472214",
"0.5992888",
"0.5989826",
"0.5944338",
"0.5932194",
"... | 0.7457267 | 0 |
Check the idpac parameter. | def _idcheck(self, idpac):
idpac = np.atleast_1d(idpac)
if not all([isinstance(k, int) for k in idpac]) and (len(idpac) != 3):
raise ValueError("idpac must be a tuple/list of 3 integers.")
# Ozkurt PAC case (doesn't need surrogates and normalization)
if idpac[0] == 4:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_id(self, id):",
"def _check_id(self, keyword):\n if keyword not in self.request.data:\n return '{} parameter is missing'.format(keyword)\n \"\"\" Check if <keyword> parameter is not None \"\"\"\n if self.request.data[keyword] == '':\n return '{} ID cannot be N... | [
"0.68211854",
"0.6542005",
"0.6363666",
"0.6119142",
"0.59657526",
"0.57905686",
"0.578351",
"0.5720292",
"0.56856227",
"0.56744486",
"0.5666618",
"0.5654327",
"0.56513685",
"0.563408",
"0.56145275",
"0.557647",
"0.5570213",
"0.55660504",
"0.55331635",
"0.5527438",
"0.5522027... | 0.704618 | 0 |
Get the idpac value. | def idpac(self):
return self._idpac | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id(self) -> str:\n return self.value",
"def get_value(self, id):\n if DataParticleKey.has(id):\n return self.contents[id]\n else:\n raise NotImplementedException(\"Value %s not available in particle!\", id)",
"def id(self) -> str:\n return self._values.get(... | [
"0.6422306",
"0.637725",
"0.6133646",
"0.6104251",
"0.60849047",
"0.60849047",
"0.6068303",
"0.5982238",
"0.5940879",
"0.59189636",
"0.5918092",
"0.59175366",
"0.5889997",
"0.5872195",
"0.5867956",
"0.5859247",
"0.5841381",
"0.58147335",
"0.5806197",
"0.5777832",
"0.5765284",... | 0.67864466 | 0 |
Array of pvalues of shape (n_amp, n_pha, n_times). | def pvalues(self):
return self._pvalues | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pvalues(self) -> np.ndarray:\n\n poialt = None\n return self.calculator.pvalue(\n poinull=self.poinull, poialt=poialt, qtilde=self.qtilde, onesided=False\n )[0]",
"def _paa(self):\n self.paa = np.array([self.series[i * self.points_per_symbol : (i + 1) * self.points_per_... | [
"0.6764058",
"0.63784707",
"0.6057404",
"0.6032705",
"0.59480387",
"0.5938672",
"0.5903855",
"0.5902943",
"0.57894516",
"0.5772734",
"0.57146883",
"0.5714575",
"0.5697712",
"0.5654047",
"0.55390763",
"0.55390763",
"0.55390763",
"0.55345464",
"0.5515229",
"0.54989374",
"0.5498... | 0.6426311 | 1 |
Simple commandline program demonstrating how to update ESXi Advanced Settings | def main():
parser = cli.Parser()
parser.add_required_arguments(cli.Argument.CLUSTER_NAME)
parser.add_custom_argument('--key', required=True, action='store',
help='Name of ESXi Advanced Setting to update')
parser.add_custom_argument('--value', required=True, action='store... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_httpdConf():\n t2 = sp.Popen(\n [\n '/opt/OAM/oracle/product/11.1.1/as_1/webgate/ihs/tools/setup/InstallTools/EditHttpConf -f /opt/WebSphere/HTTPServer/conf/httpd.conf -w /opt/OAM/oracle/Middleware/Oracle_OAMWebGate1 -oh /opt/OAM/oracle/product/11.1.1/as_1/ -ws ihs'\n ],\n ... | [
"0.6087795",
"0.60598695",
"0.58556294",
"0.58270216",
"0.57581455",
"0.56364655",
"0.56357604",
"0.5577082",
"0.55593485",
"0.5540698",
"0.5534614",
"0.55324364",
"0.54594076",
"0.54538155",
"0.5439679",
"0.53816175",
"0.53816175",
"0.53798205",
"0.5376617",
"0.53448373",
"0... | 0.76114184 | 0 |
Perform model selection for each submetric. | def model_selection(
self, checkpoint: tf.train.Checkpoint, global_step: tf.Variable
) -> None:
super().model_selection(checkpoint, global_step)
for child in self.children_real_fake:
child[0].model_selection(checkpoint, global_step)
child[1].model_selection(checkpoint... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_sub_models(self):\r\n sub_data_grid = [0.1 * i for i in range(1, 10)]\r\n self.sub_models = [\r\n copy.deepcopy(self.model_) for _ in range(len(sub_data_grid))]\r\n # fit sub-models to subset of data\r\n for key, data_size in enumerate(sub_data_grid):\r\n X, _,... | [
"0.63483095",
"0.56364626",
"0.55192274",
"0.5258996",
"0.5174944",
"0.51519",
"0.51482755",
"0.51422143",
"0.5127364",
"0.5059312",
"0.50340956",
"0.5018602",
"0.5015776",
"0.50114787",
"0.4976124",
"0.4917183",
"0.49122682",
"0.48837668",
"0.48835084",
"0.48746747",
"0.4871... | 0.62093556 | 1 |
Reset the state of the metric and the state of each child metric. | def reset_states(self) -> None:
self._metric.reset_states()
# for each child log
for child in self.children_real_fake:
child[0].reset_states()
child[1].reset_states() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_state(self):\n for name in self.metrics:\n self.metrics[name].reset_state()",
"def reset_all(self) -> None:\n for metric in self:\n metric.reset()",
"def reset(self):\n self.sum_metric = 0.\n self.num_inst = 0.\n self.metrics.reset_stats()",
... | [
"0.82238764",
"0.77645385",
"0.73283005",
"0.7173071",
"0.6932412",
"0.68975675",
"0.6843947",
"0.67603815",
"0.66905093",
"0.66511273",
"0.6638176",
"0.65932524",
"0.6548352",
"0.6466021",
"0.64608437",
"0.645761",
"0.6415591",
"0.63856936",
"0.6370135",
"0.6332321",
"0.6331... | 0.81875545 | 1 |
The update_view() method is where widgets must update their view state to reflect a changed model state. | def update_view(self):
raise NotImplementedError("Widget descendents MUST implement the update_view() method!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateView(self):\n self.View._viewData = self.Model.ModelViewData",
"def update(self, view, show_errors):\n raise NotImplementedError(\"calling abstract method\")",
"def Update(self):\n\n # note this function should be overloaded; this line is simply\n # indicating that the ove... | [
"0.7918083",
"0.7340189",
"0.73107225",
"0.7105659",
"0.7077301",
"0.6941106",
"0.6804262",
"0.6764076",
"0.6706164",
"0.6508334",
"0.6473907",
"0.6453222",
"0.64362353",
"0.6422566",
"0.6390599",
"0.63683826",
"0.61973524",
"0.6168402",
"0.61443233",
"0.6107695",
"0.6078922"... | 0.8317985 | 0 |
Find the beginning of a circularly linked list. This is what's suggested in the book. | def find_loop_beginning(head):
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow == fast:
break;
if fast is None or fast.next is None:
return None
slow = head
while slow != fast:
slow = slow.next
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_beginning_alternate(head):\n\n seen = set()\n\n current = head\n\n while current:\n if current not in seen:\n seen.add(current)\n else:\n return current\n current = current.next",
"def before(self,p):\r\n \r\n current = self.head #test fr... | [
"0.673181",
"0.64527637",
"0.6423697",
"0.6419647",
"0.63654405",
"0.63571566",
"0.6250675",
"0.6216663",
"0.62092304",
"0.6207125",
"0.61910325",
"0.6148362",
"0.6096458",
"0.60185343",
"0.59724563",
"0.5960783",
"0.5923166",
"0.59089005",
"0.5889104",
"0.58618844",
"0.58548... | 0.74206805 | 0 |
Signal the service manager this service is ready for incoming connections. | def signal_ready(self):
self.logger.debug("service is ready") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ready(self, component):\n self.fire(connect(self.host, self.port))",
"def serverExplicitReady (self):\n self.server_ready.set()",
"def _keep_alive(self):\n yield WaitDBusNameChange('org.freesmartphone.ogsmd')\n logger.error(\"org.freesmartphone.ogsmd crashed\")\n logger.i... | [
"0.6477853",
"0.64093304",
"0.6400658",
"0.631628",
"0.6189157",
"0.6183084",
"0.61228293",
"0.6070699",
"0.6047075",
"0.6017886",
"0.59742904",
"0.5964411",
"0.5943451",
"0.59117025",
"0.590115",
"0.59007597",
"0.5898927",
"0.58845115",
"0.586696",
"0.5862807",
"0.5856922",
... | 0.75560504 | 0 |
Run the service and start an alert processing queue. | def run_service(self):
self.alerts_queue = Queue(maxsize=SERVICE_ALERT_QUEUE_SIZE)
self.thread_server = Thread(target=self._on_server_start)
# self.thread_server.daemon = True
self.thread_server.start()
try:
while self.thread_server.is_alive():
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start( self ):\n\n self.service()",
"def run(self):\n\n try:\n self.send_alert('SUCCESS', \"Job START\", None)\n self.cron_process()\n self.send_alert('SUCCESS', \"Job FINAL\", None)\n sys.exit(0)\n\n except Exception:\n alert_data =... | [
"0.67463285",
"0.67347056",
"0.6679237",
"0.66444355",
"0.63789487",
"0.6340074",
"0.62862885",
"0.62155163",
"0.62041086",
"0.61977464",
"0.6195389",
"0.6175035",
"0.617003",
"0.61376995",
"0.6089883",
"0.6057593",
"0.60447055",
"0.6039054",
"0.6015456",
"0.59937465",
"0.598... | 0.77147806 | 0 |
Return a dictionary of docker run parameters. | def docker_params(self):
return {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _GetRunParameters() -> dict[str, str]:\n result = {}\n for kv in FLAGS.ycsb_run_parameters:\n param, value = kv.split('=', 1)\n result[param] = value\n return result",
"def get_run_vars(**kwargs):\n run_guid = str(uuid.uuid4())\n logging.debug(\"Run guid: \" + run_guid)\n run_timestamp = da... | [
"0.6961295",
"0.67106736",
"0.64564407",
"0.6214051",
"0.61941326",
"0.61711454",
"0.60194224",
"0.5934555",
"0.5886167",
"0.5858846",
"0.5808654",
"0.5761431",
"0.57423866",
"0.5677927",
"0.5677827",
"0.5675855",
"0.56382406",
"0.5634306",
"0.5600462",
"0.5583224",
"0.556793... | 0.82288444 | 0 |
Return docker image name. | def docker_image_name(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_image_name():\n try:\n return os.environ['AIRFLOW_IMAGE']\n except KeyError:\n raise Exception(\"Please provide docker image name to pytest using environment variable AIRFLOW_IMAGE\")",
"def build_image_name(self, tag):\n return self.repository_name + ':' + tag",
"def contain... | [
"0.7595361",
"0.7496212",
"0.74817425",
"0.7301941",
"0.7281677",
"0.72610414",
"0.71842706",
"0.70049363",
"0.6996756",
"0.6996756",
"0.69679266",
"0.68323594",
"0.6816819",
"0.6778676",
"0.67522925",
"0.65728354",
"0.6569516",
"0.65458554",
"0.6545557",
"0.6545557",
"0.6513... | 0.88263226 | 0 |
Fetch log lines from the docker service. | def get_lines(self):
return self._container.logs(stream=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tail(name):\n\n try:\n container = CLIENT.containers.get(name)\n for line in container.logs(stream=True):\n click.secho(line.strip(), bg='blue', fg='white')\n except docker.errors.NotFound as err:\n print(err)",
"def getLogs():",
"def getLogs():",
"def docker_logs():... | [
"0.67450833",
"0.65477407",
"0.65477407",
"0.652438",
"0.6452338",
"0.63144886",
"0.62514055",
"0.6243246",
"0.6165015",
"0.61648506",
"0.60669696",
"0.60665655",
"0.60642326",
"0.60436934",
"0.604075",
"0.597968",
"0.5967887",
"0.59570384",
"0.59567606",
"0.59567606",
"0.594... | 0.68686134 | 0 |
Service run loop function. Run the desired docker container with parameters and start parsing the monitored file for alerts. | def on_server_start(self):
self._container = self._docker_client.containers.run(self.docker_image_name, detach=True, **self.docker_params)
self.signal_ready()
for log_line in self.get_lines():
try:
alert_dict = self.parse_line(log_line)
if alert_dict:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n while self.container.process(): pass",
"def run(self, container_config: ContainerConfig) -> Container:",
"def main():\n update_delay = getenv('UPDATE_DELAY', '300')\n notification_url = getenv('NOTIFICATION_URL', '')\n\n try:\n client = docker.from_env()\n except Conn... | [
"0.6918262",
"0.666673",
"0.66225386",
"0.6581498",
"0.6499584",
"0.64725",
"0.64658123",
"0.64235383",
"0.6351714",
"0.62632513",
"0.62218505",
"0.61029136",
"0.60585356",
"0.60412455",
"0.5996417",
"0.5962951",
"0.58978754",
"0.588363",
"0.58645767",
"0.5862686",
"0.5860227... | 0.69328016 | 0 |
Returns the groups that student has pinned in the semester. | def student_pins_in_semester(cls, student: Student, semester: Semester) -> Iterable[Group]:
pins = cls.objects.filter(
group__course__semester_id=semester.pk, student_id=student.pk).select_related(
'group__course', 'group__teacher', 'group__teacher__user')
return map(lambda p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups(self):\n return self.get_data(\"groups\")",
"def getGroups():\r\n return Group.getGroups()",
"def get_pingroups(self):\n return self.groups[:]",
"def groups(self):\n return self._groups",
"def groups(self):\n return self._groups",
"def groups(self):\n ... | [
"0.6343496",
"0.6327441",
"0.6258202",
"0.6173955",
"0.6173955",
"0.6173955",
"0.61730474",
"0.6089153",
"0.604123",
"0.59844464",
"0.58546764",
"0.58169734",
"0.5782748",
"0.5778014",
"0.57720155",
"0.57691854",
"0.5749677",
"0.5744375",
"0.57386863",
"0.56823593",
"0.567034... | 0.74207866 | 0 |
Takes in text file of customer orders and determines which customers have under and overpaid | def parse_customer_orders(customer_order_file, melon_cost = STANDARD_MELON_COST):
print("List of customers that over or underpaid:")
customer_order_data = open(customer_order_file)
for line in customer_order_data:
line = line.rstrip()
order = line.split('|')
customer_number = order[0]
cus... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_underpaid_customers(customer_data_file):\n\n customer_data = open(customer_data_file) # open file\n\n # iterate over each line and split into list\n for line in customer_data:\n customer_tokens = line.split(\"|\")\n\n # assign values in list to a variable\n customer_name = c... | [
"0.7628724",
"0.7197826",
"0.6252441",
"0.62034154",
"0.6119454",
"0.6082852",
"0.5900393",
"0.56806165",
"0.556333",
"0.5451902",
"0.54410166",
"0.54008764",
"0.5396279",
"0.53768545",
"0.527498",
"0.52302504",
"0.5220914",
"0.5170838",
"0.51663524",
"0.51286876",
"0.5101955... | 0.7751232 | 0 |
finds a streetname in a sentence | def find_street(self, text):
text = text.replace('"', '')
result = ''
textarr = text.split()
for i in range(0, len(textarr)):
if textarr[i] in self.streets:
# decide if the result is nearly empty or not to add the word with or without a space
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_streetname(self):\n index = self.index\n \n name = \"\"\n for i in range(4):\n if index + i == self.length:\n break\n if self.words[index+i]['word'] == ',':\n break\n # Hack\n if self.words[index+i]['wor... | [
"0.63387036",
"0.6236272",
"0.5984141",
"0.5845484",
"0.5773116",
"0.5770286",
"0.57690305",
"0.5583882",
"0.5559595",
"0.55324596",
"0.55166733",
"0.5515807",
"0.5500466",
"0.5477386",
"0.5448344",
"0.5434349",
"0.54337937",
"0.54199994",
"0.54190683",
"0.5414442",
"0.539677... | 0.7376819 | 0 |
finds a cityname in a sentence | def find_city(self, text):
result = ''
textarr = text.split()
for i in range(0, len(textarr)):
if textarr[i] in self.cities:
if len(result) < 2:
result = result + textarr[i]
else:
result = result + ' ' + texta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_city(input_city: str) -> str:\n # input_city = string.capwords(input_city.lower())\n result = filterString(input_city).cities\n return result",
"def get_city(string):\n city = \"\"\n previous_ch = None;\n\n #For each character in string\n for ch in string:\n #break if it is... | [
"0.6652408",
"0.6177309",
"0.616365",
"0.6129531",
"0.6122067",
"0.60630864",
"0.6027139",
"0.6019338",
"0.5897321",
"0.58484304",
"0.57878816",
"0.5768438",
"0.57649213",
"0.57584417",
"0.5734249",
"0.57068497",
"0.5670053",
"0.56673646",
"0.56379014",
"0.5612974",
"0.560588... | 0.77218676 | 0 |
Used to initialize an object of the Tag images class Sets the value of an api key and secret that will be used to access the immaga api. | def __init__(self):
#print ("Object created")
self.apikey='acc_4fc1a435b3188b5'
self.secret = 'f49c4be14a048d5de7e7f6c564b52022'
self.fileToIdMap = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, apikey, secret):\n self.apikey = apikey\n self.secret = secret",
"def __init__(self, apiKey, apiSecret):\n self.apiKey = apiKey\n self.apiSecret = apiSecret",
"def __init__(self, access_key, secret_key, **kwargs):\r\n pass",
"def __init__(self,ima... | [
"0.7338047",
"0.71174985",
"0.69308114",
"0.6831729",
"0.6798931",
"0.6640764",
"0.65946454",
"0.65909046",
"0.6477678",
"0.6416036",
"0.64157826",
"0.64157826",
"0.64157826",
"0.6381126",
"0.63754076",
"0.63645685",
"0.63314426",
"0.63117063",
"0.6281324",
"0.62380874",
"0.6... | 0.7314177 | 1 |
Used to upload a file using the imagga API and recevies a resource Id in response from the API that can be used later to fetch the tags for that image | def uploadFile(self,path):
response = requests.post('https://api.imagga.com/v1/content',
auth=(self.apikey, self.secret),
files={'image': open(path, 'r')})
json_data = json.loads(response.text)
uploadedData=json_data[u'uploaded'][0]
resourceId... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTagsUsingId(self,resourceId):\n response = requests.get('https://api.imagga.com/v1/tagging?content=%s' % resourceId,\n auth=(self.apikey, self.secret))\n #print ('printing response')\n #print (response.json())",
"def upload_image(self, request, pk=None):\n ... | [
"0.66734195",
"0.6341102",
"0.63172114",
"0.6272347",
"0.6266277",
"0.6243718",
"0.6198456",
"0.6197522",
"0.605657",
"0.60328776",
"0.60218036",
"0.601501",
"0.6004016",
"0.5960162",
"0.59470075",
"0.5941067",
"0.5923321",
"0.59046566",
"0.5884713",
"0.5860891",
"0.5849617",... | 0.77716404 | 0 |
This function is used to get tags from the imagga API using the resource Id of an image that has been already uploaded suing the API | def getTagsUsingId(self,resourceId):
response = requests.get('https://api.imagga.com/v1/tagging?content=%s' % resourceId,
auth=(self.apikey, self.secret))
#print ('printing response')
#print (response.json()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTagsUsingImageUrl(self,ImageUrl):\n #print ('printing type')\n #print (type(ImageUrl))\n response = requests.get('https://api.imagga.com/v1/tagging?url=%s' %ImageUrl,\n auth=(self.apikey, self.secret))\n status = response.status_code\n ... | [
"0.7171173",
"0.68453175",
"0.6251234",
"0.62165534",
"0.6186737",
"0.61687976",
"0.61485964",
"0.6127316",
"0.612485",
"0.6112442",
"0.6096555",
"0.6087492",
"0.6063449",
"0.6063449",
"0.6051594",
"0.600367",
"0.59775704",
"0.5960997",
"0.59180933",
"0.58844393",
"0.58644325... | 0.82594734 | 0 |
Returns an approximation for the square root of 2 | def get_sqrt_2():
return 1.41421356 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sqrt(x):\n return 0.0",
"def root2(self):\r\n if self.discriminant() < 0.0:\r\n return None\r\n return(-self.__b - math.sqrt(self.discriminant()))/(2*self.__a)",
"def sqrt(a):",
"def my_sqrt(x):\n square_root = x**(0.5)\n return square_root",
"def squared_error(a, b):\... | [
"0.70666325",
"0.6928877",
"0.67747307",
"0.6770068",
"0.66439813",
"0.65621257",
"0.6500922",
"0.6497867",
"0.64964163",
"0.64837927",
"0.64723057",
"0.642467",
"0.6380498",
"0.6376349",
"0.63673544",
"0.6355934",
"0.63081634",
"0.62976223",
"0.62954295",
"0.6287609",
"0.624... | 0.8209238 | 0 |
Given the name of a model architecture, returns information about it. There are different base image recognition pretrained models that can be retrained using transfer learning, and this function translates from the name of a model to the attributes that are needed to download and train with it. | def create_model_info(architecture):
architecture = architecture.lower()
is_quantized = False
# pylint: disable=line-too-long
if architecture == 'inception_v3':
data_url = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz'
# pylint: enable=line-too-long
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_model_info(architecture):\n architecture = architecture.lower()\n if architecture == 'inception_v3':\n # pylint: disable=line-too-long\n data_url = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz'\n # pylint: enable=line-too-long\n bottleneck_tensor_name = 'p... | [
"0.6916691",
"0.6681391",
"0.6444777",
"0.624417",
"0.62146807",
"0.6208379",
"0.6196133",
"0.616388",
"0.6163273",
"0.61547303",
"0.60883707",
"0.605068",
"0.602281",
"0.6014021",
"0.5961657",
"0.59610724",
"0.59217554",
"0.5856323",
"0.5817037",
"0.5814102",
"0.580151",
"... | 0.68833935 | 1 |
Returns True if the given method will accept the given number of arguments | def accept_arguments(method, number_of_arguments=1):
if 'method' in method.__class__.__name__:
number_of_arguments += 1
func = getattr(method, 'im_func', getattr(method, '__func__'))
func_defaults = getattr(func, 'func_defaults', getattr(func, '__defaults__'))
number_of_defaults = fu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_take_n_args(func, n=2):\n (pos, args, kwargs, defaults) = inspect.getargspec(func)\n if args is not None or len(pos) >= n:\n return True\n return False",
"def takes_multiple_arguments(func):\n if func in ONE_ARITY_BUILTINS:\n return False\n elif func in MULTI_ARITY_BUILTINS:\... | [
"0.75303423",
"0.71400964",
"0.6614831",
"0.65546584",
"0.64539194",
"0.63745326",
"0.6371333",
"0.63262385",
"0.6316958",
"0.6302882",
"0.62775874",
"0.6263459",
"0.624923",
"0.62149835",
"0.6206251",
"0.6177534",
"0.61633974",
"0.6145997",
"0.6123091",
"0.6105693",
"0.60911... | 0.83025557 | 0 |
Convert sentence into character ngrams. | def sent2ngrams(text, n=3):
if n == "word":
return text.split()
return list(chain(*[word2ngrams(i,n) for i in text.lower().split()])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_grama(sentence, n):\n t = tokenize(sentence)\n n_grams = zip(*[t[i:] for i in range(n)])\n return list(map(lambda n_gram: ' '.join(n_gram), n_grams))",
"def prepare_for_char_n_gram(text):\n # 1. Go to lower case (only good for english)\n # Go to bytes_strings as I had issues removing all \\n... | [
"0.6905743",
"0.6903577",
"0.68765163",
"0.6628413",
"0.6509108",
"0.6437942",
"0.6308937",
"0.62483406",
"0.62425685",
"0.620797",
"0.620785",
"0.6163952",
"0.61213887",
"0.6105343",
"0.6105343",
"0.60966593",
"0.6094098",
"0.60421884",
"0.6012371",
"0.6010471",
"0.5989116",... | 0.71746427 | 0 |
Calculates the mutual information of two Bernoulli distributions, which have marginal probabilities pi and pj, and joint probability pij | def mutual_information(pi, pj, pij):
p_i = 1 - pi
p_j = 1 - pj
p_ij = pj - pij
pi_j = pi - pij
p_i_j = 1 - pi - pj + pij
log_pi = log(pi)
log_pj = log(pj)
log_p_i = log(p_i)
log_p_j = log(p_j)
mi = pij * (log(pij) - log_pi - log_pj) + \
pi_j * (log(pi_j) - log_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateLogJointProbabilities(self, datum):\n\tlogJoint = util.Counter()\n\t#want to calculate log(P(y)) + log(sum(P(fi|y)))\n\t#where y is a label\n\tfor label in self.legalLabels:\n\t\tlogJoint[label] = math.log(self.prior_distribution_prob[label])\n\t\tfor feature, value in datum.items():\n\t\t\tcp = self.... | [
"0.6043151",
"0.60156333",
"0.6014164",
"0.6008936",
"0.5797295",
"0.5795246",
"0.57667917",
"0.5747666",
"0.57251996",
"0.5722892",
"0.57160455",
"0.57153606",
"0.5701949",
"0.5661913",
"0.56310827",
"0.56132853",
"0.5611344",
"0.56095326",
"0.55931115",
"0.5586713",
"0.5553... | 0.65267515 | 0 |
Returns the top N features for each code, as a dictionary | def top_n(self, n):
top = {}
for code, feat_set in self.iteritems():
tuples = sorted(feat_set.items(), reverse=True, key=itemgetter(1))
best = {feat for feat, _ in tuples[:n]}
top[code] = best
return top | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top_n(self,X):\n for col in self.features:\n __levels = list(X[col].value_counts()[:self.n].index)\n __mapper_dict = defaultdict(lambda: \"other\")\n for level in __levels:\n __mapper_dict[level] = level\n self.maps[col] = __mapper_dict",
... | [
"0.7045493",
"0.68079305",
"0.6735287",
"0.6648536",
"0.66007054",
"0.6583027",
"0.65266997",
"0.6502596",
"0.6437721",
"0.6348204",
"0.63421106",
"0.6307811",
"0.6240124",
"0.6163593",
"0.61143017",
"0.6113898",
"0.6049466",
"0.59717476",
"0.5963502",
"0.5963502",
"0.5943791... | 0.8139767 | 0 |
Finds the top N features for each code, and combines them into one set | def top_n_combined(self, n):
top = set()
for feat_set in self.itervalues():
tuples = sorted(feat_set.items(), reverse=True, key=itemgetter(1))
best = {feat for feat, _ in tuples[:n]}
top |= best
return top | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_n(self, n):\n top = {}\n for code, feat_set in self.iteritems():\n tuples = sorted(feat_set.items(), reverse=True, key=itemgetter(1))\n best = {feat for feat, _ in tuples[:n]}\n top[code] = best\n return top",
"def getFeatures(self, N=2):\n fea... | [
"0.77501446",
"0.69936115",
"0.6839073",
"0.6678788",
"0.65109205",
"0.6441362",
"0.6432797",
"0.64097303",
"0.6379659",
"0.6346589",
"0.62943107",
"0.62879056",
"0.62455964",
"0.62260306",
"0.6196",
"0.61614007",
"0.6101471",
"0.6098816",
"0.6080669",
"0.60713273",
"0.600119... | 0.741327 | 1 |
Returns all features above a given threshold, for each code, as a dictionary | def top_thresh(self, threshold):
top = {}
for code, feat, value in self.iter_all():
if value > threshold:
top.setdefault(code, set()).add(feat)
return top | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_threshold_data(self):\n return [list(x) for x in list(zip(self.thresholds,self.autothreshs))]",
"def top_thresh_combined(self, threshold):\n top = set()\n for _, feat, value in self.iter_all():\n if value > threshold:\n top.add(feat)\n return top",
... | [
"0.6092464",
"0.6040696",
"0.5911231",
"0.5871276",
"0.58198225",
"0.57508934",
"0.5744876",
"0.57417125",
"0.57314384",
"0.5701979",
"0.56878763",
"0.5675058",
"0.5626919",
"0.55963606",
"0.5580953",
"0.55501527",
"0.5530408",
"0.54997575",
"0.54785794",
"0.54684657",
"0.545... | 0.75132626 | 0 |
Returns all features above a given threshold | def top_thresh_combined(self, threshold):
top = set()
for _, feat, value in self.iter_all():
if value > threshold:
top.add(feat)
return top | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def constant_feature_detect(data, threshold=0.98):\n\n data_copy = data.copy(deep=True)\n quasi_constant_feature = []\n for feature in data_copy.columns:\n predominant = (\n (data_copy[feature].value_counts() / np.float(len(data_copy)))\n .sort_values(ascending=False)\n ... | [
"0.67724615",
"0.6744393",
"0.6697787",
"0.64925915",
"0.6473832",
"0.6393646",
"0.6355978",
"0.63160557",
"0.6268308",
"0.6240548",
"0.6230896",
"0.62297076",
"0.62268436",
"0.6213398",
"0.61530584",
"0.61528814",
"0.6126025",
"0.612239",
"0.6113373",
"0.6096261",
"0.6085691... | 0.67508703 | 1 |
Given metacodes to refer to sets of codes (as a dictionary), returns a collapsed MatrixDict for the metacodes, and a dictionary from metacodes to withingroup MatrixDicts | def split(self, bins):
collapsed = MatrixDict()
sub_dicts = dict()
for meta, group in bins.iteritems():
collapsed[meta] = Counter()
small = MatrixDict()
sub_dicts[meta] = small
for code in group:
collapsed[meta].update(self[code])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_mat_scikit_strandOriented(sralist, scikit_data):\n\n scikit_mat = {}\n seq_codons = {}\n seq_aa = {}\n\n for geneID in scikit_data[sralist[0]][0].keys():\n for ix, dataset in enumerate(sralist):\n\n if geneID in scikit_data[dataset][0].keys():\n ... | [
"0.5699556",
"0.55466795",
"0.5449271",
"0.53204334",
"0.51851237",
"0.5126019",
"0.5045089",
"0.504331",
"0.4962563",
"0.49360684",
"0.4921014",
"0.4908856",
"0.4907208",
"0.48832354",
"0.4870563",
"0.48667565",
"0.48653126",
"0.48527104",
"0.48509914",
"0.482652",
"0.482029... | 0.56757593 | 1 |
Sets up matrices of raw features, mutual information, and pointwise mutual information, for all feature types, using Crubadan | def setup_crubadan():
for n in [1,2,3,4,5,'word']:
for option in ['mi','pmi']:
get_matrix(datasource='crubadan', n=n, option=option) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_weka_mfcc_13():\n global ARGS\n\n ## ten thu muc can trich chon vector dac trung (RLS, LMS, NLMS, Kalman, Non)\n name = '';\n fout = open('weka/MFCC78_TUNNING_{}_dataset.arff'.format(name), 'w')\n fout.write('@RELATION {}_dataset\\n\\n'.format(name))\n\n fout.write('@ATTRIBUTE MEAN_MFC... | [
"0.566647",
"0.55598354",
"0.5541794",
"0.5504785",
"0.54042417",
"0.538785",
"0.5356959",
"0.534212",
"0.5297698",
"0.52874094",
"0.5279998",
"0.52716905",
"0.5225172",
"0.5224692",
"0.52150524",
"0.5182384",
"0.51801354",
"0.5162534",
"0.51415783",
"0.51337063",
"0.5095402"... | 0.6060722 | 0 |
Verifies if interface has LDP IGP sync enabled from command 'show mpls ldp igp sync' | def is_interface_igp_sync_mpls_enabled(
interface, device, vrf="", parsed_output=""):
if not parsed_output:
try:
parsed_output = device.parse(
"show mpls ldp igp sync interface {intf}".format(
intf=interface
)
)
except ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_lldp_cli(self):\n c = self.cli(\"show lldp local\", cached=True)\n return \"LLDP: enabled\" in c",
"def has_lldp_cli(self):\n with self.profile.switch(self):\n cmd = self.cli(\"show lldp configuration\", ignore_errors=True)\n return \"State: Enabled\" in cmd",
... | [
"0.66260916",
"0.651009",
"0.6395822",
"0.62540615",
"0.60676736",
"0.60518986",
"0.58828115",
"0.5681195",
"0.5653346",
"0.5479342",
"0.5373872",
"0.5261237",
"0.5195693",
"0.5190285",
"0.51733655",
"0.51673096",
"0.5154982",
"0.51280886",
"0.5104634",
"0.50953496",
"0.50902... | 0.6641543 | 0 |
Checks if ldp neighbor is in state | def is_mpls_ldp_neighbor_in_state(
device, interface, state, max_time=60, check_interval=10):
log.info("Checking if ldp neighbor is in state: {}".format(state))
timeout = Timeout(max_time, check_interval)
while timeout.iterate():
current_state = get_mpls_ldp_peer_state(device, interface)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_state(self, state):\n if state == self.get_state():\n return True\n return False",
"def any_neighbor_burning(self):\n neighbors = self.world.get_four_neighbors(self, Patch.null)\n states = [patch.state for patch in neighbors]\n return \"orange\" in states",
... | [
"0.6367279",
"0.6310479",
"0.6153617",
"0.6097785",
"0.60964394",
"0.60934556",
"0.60925645",
"0.607505",
"0.6062781",
"0.6027459",
"0.6008171",
"0.59937817",
"0.59611005",
"0.59408355",
"0.5910434",
"0.5909995",
"0.58977383",
"0.5888232",
"0.5887616",
"0.58848786",
"0.587542... | 0.72238296 | 0 |
Verifies local label for entries with a prefix inside subnet | def verify_mpls_forwarding_table_local_label_for_subnet(
device, subnet, min_range, max_range, in_range=True, max_time=120,
check_interval=30):
log.info(
'Checking all entries where the prefix falls inside subnet {subnet} '
'range'.format(subnet=subnet))
try:
subnet = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_network_prefix(self):\n try:\n cidr = netaddr.IPNetwork(self.network + \"/\" + str(self.prefix))\n except netaddr.core.AddrFormatError:\n raise ValueError(_(\"Invalid IP address and prefix\"))\n address = netaddr.IPAddress(self.network)\n if address !... | [
"0.6734672",
"0.6574683",
"0.6369013",
"0.6135932",
"0.613052",
"0.6053565",
"0.59815437",
"0.59054047",
"0.58765453",
"0.58623344",
"0.57834035",
"0.5730456",
"0.5721581",
"0.5705269",
"0.56926876",
"0.56861806",
"0.5671456",
"0.56681013",
"0.56641465",
"0.564824",
"0.562253... | 0.69044614 | 0 |
Verifies counters for mdt in mpls forwardingtable | def verify_mpls_forwarding_table_vrf_mdt(device,
vrf,
prefix_type,
expected_prefix,
bytes_labeled_switched,
mdt_cnt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_mpls_forwarding_table_gid_counter(device, \n prefix_type,\n bytes_labeled_switched,\n mdt_data_cnt=1, \n ... | [
"0.71232027",
"0.55071765",
"0.5474587",
"0.54264295",
"0.54073167",
"0.5361839",
"0.5301228",
"0.527873",
"0.5258551",
"0.5222574",
"0.51857626",
"0.51734704",
"0.51614994",
"0.51614994",
"0.51557",
"0.51416653",
"0.51377505",
"0.5131841",
"0.51258326",
"0.50988114",
"0.5098... | 0.6841063 | 1 |
Verifies counters for gid in mpls forwardingtable | def verify_mpls_forwarding_table_gid_counter(device,
prefix_type,
bytes_labeled_switched,
mdt_data_cnt=1,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_mpls_forwarding_table_vrf_mdt(device,\n vrf,\n prefix_type,\n expected_prefix,\n bytes_labeled_switched,\n ... | [
"0.58503115",
"0.56503093",
"0.54093647",
"0.51790994",
"0.51638466",
"0.51638466",
"0.5140393",
"0.512758",
"0.5119441",
"0.5099528",
"0.5099528",
"0.5094484",
"0.50789124",
"0.5043495",
"0.5042665",
"0.5024693",
"0.49946415",
"0.49840707",
"0.49792945",
"0.49787706",
"0.497... | 0.7282933 | 0 |
Verifying mpls label value with label stack value | def verify_mpls_summary_label(device,label_stack,prefix):
result = []
out = device.execute("show platform software fed switch active mpls summary | include LABEL")
p = re.compile(r'Num+\s+of+\s+\S+\s+entries+\s+allocated:\s+(\d+).*$')
for line in out.splitlines():
line = line.strip()
m =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_label():\n label_path = pjoin(data_path, \"label\", \"lh.BA1.label\")\n label = read_label(label_path)\n # XXX : test more\n assert_true(np.all(label > 0))",
"def test_labels(self):\n self.compliance_tester.test_labels(self.oi)",
"def _is_label(self) -> bool:\n return self.li... | [
"0.6814712",
"0.6218965",
"0.62018466",
"0.6134756",
"0.60504586",
"0.5940852",
"0.58625305",
"0.58483016",
"0.5828307",
"0.57745486",
"0.5709931",
"0.5656981",
"0.5624229",
"0.5590461",
"0.5536696",
"0.55355984",
"0.5523098",
"0.5514222",
"0.5502461",
"0.54806566",
"0.546779... | 0.74220926 | 0 |
Verifying mpls lspa value with bgp value | def verify_mpls_summary_lspa(device,bgp_value):
result = []
out = device.execute("show platform software fed switch active mpls summary | include LSPA")
p = re.compile(r'^Num of LSPA entries allocated:\s+(\d+).*$')
for line in out.splitlines():
line = line.strip()
m = p.match(line)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_lsp_config_ospf_aaf(self):\n return self.__lsp_config_ospf_aaf",
"def test_zipcode_is_successfully_mapped(self):\n\n zipcode = '11111'\n cleaned_zipcode_data_input = {'11111': [('NY', '5')]}\n cleaned_plan_data_input = {('NY', '5'): ['294.44', '294.87', '339.6']}\n\n expec... | [
"0.5664946",
"0.5498119",
"0.54807645",
"0.5396602",
"0.53346395",
"0.53158236",
"0.5230665",
"0.52085155",
"0.5196975",
"0.513931",
"0.51270133",
"0.51185805",
"0.51120174",
"0.50604105",
"0.5045792",
"0.50241166",
"0.50217867",
"0.50016034",
"0.49814975",
"0.49694496",
"0.4... | 0.7596018 | 0 |
get entities and relations from an .ann file >> entities, relations = read_ann_file("page0034","./LO10015953/1998_151/") print the first entity >> entities[entities.keys()[0]] | def read_ann_file(fileid, ann_dir):
ann_file = "%s/%s.ann"%(ann_dir,fileid)
with codecs.open(ann_file, 'r', 'utf-8') as f:
data = f.read()
rows = data.split('\n')
entities = {}
ent_count = 0
relations = {}
#annotations = []
for row in rows:
cols = row.split("\t")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_nell_relations():\n\trel=os.walk(\"nell/relations\")\n\trelation=[]\n\tfor i in rel:\n\t\ttrel=i[2]\n\tfor i in trel:\n\t\trelation.append(' '.join(segment(i.split(':')[1])))\n\treturn relation",
"def extract_entities(filename):\n logger.info(\"Processing entities for file {}\".format(filename))\n ... | [
"0.6087546",
"0.6080326",
"0.59581083",
"0.5925132",
"0.5851662",
"0.57610863",
"0.571646",
"0.56649166",
"0.56606",
"0.5581556",
"0.5479269",
"0.538515",
"0.53746676",
"0.5341086",
"0.53395224",
"0.5339429",
"0.5321982",
"0.5321982",
"0.5310216",
"0.5303833",
"0.52945286",
... | 0.74412495 | 0 |
find entities to be tagged as conjunction (u'entity_type' == u'metaannotation') create annotations and add them to MongoDB add the annotation_id to the list of top_entities | def tag_conjunction_entities(annotated_pages):
for page_id in annotated_pages:
page = Page.objects(id=page_id).first()
#page = db_conn.pages.find_one({"_id":page_id}) # TODO: refactor
annotation_ids = [p.id for p in page["annotations_ids"]]
all_annotations = list(Annotation.objects(i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_annotationactions(annotations):\n\t\tif annotations is None:\n\t\t\treturn\n\t\tcon = mdb.connect('localhost', 'root', 'sensepass', 'sensecambrowser')\n\t\twith con:\n\t\t\tfor annotation in annotations:\n\t\t\t\tusername = annotation[0]\n\t\t\t\tpath = annotation[1]\n\t\t\t\tconcept = annotation[2]\n\t... | [
"0.5453468",
"0.5426386",
"0.5375784",
"0.528742",
"0.5226528",
"0.521499",
"0.518845",
"0.51522666",
"0.506763",
"0.49903837",
"0.49584666",
"0.48881808",
"0.48729774",
"0.48088244",
"0.48034838",
"0.47948122",
"0.47548062",
"0.47448945",
"0.47270653",
"0.4710129",
"0.469866... | 0.74160254 | 0 |
Test that when mothur errors with invalid mothur_path set. | def test_bad_mothur_path(self):
m = Mothur(**self.init_vars, mothur_path='.')
self.set_current_dirs(m)
with self.assertRaises(PermissionError):
m.help()
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mothur_error_1(self):\n\n m = Mothur(**self.init_vars)\n self.set_current_dirs(m)\n\n with self.assertRaises(RuntimeError):\n m.invalid.command()\n\n return",
"def test_mothur_error_2(self):\n\n m = Mothur(**self.init_vars)\n self.set_current_dirs(m)\... | [
"0.7764365",
"0.7468218",
"0.6692804",
"0.6672382",
"0.6611696",
"0.65818805",
"0.65730065",
"0.6489663",
"0.6470183",
"0.6467379",
"0.64672154",
"0.63741547",
"0.6364399",
"0.6360623",
"0.6333774",
"0.63138086",
"0.6308435",
"0.6246205",
"0.622981",
"0.61926633",
"0.61622477... | 0.80041486 | 0 |
Test that mothur remembers current files. | def test_existing_current_files(self):
m = Mothur(**self.init_vars)
self.set_current_dirs(m)
m.summary.seqs(fasta='test_fasta_1.fasta')
m.summary.seqs()
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fileinuse (self):\t\t\n\t\t# open a file:\n\t\ttestfilepath = os.path.join (self.testfolder, \"fileinuse.txt\")\n\t\tf = open(testfilepath,\"a\") #opens file with name of \"test.txt\"\n\t\tf.write(\"This file is now opened and i'm writting on it \\n\")\n\t\tself.assertEqual (MD.fileinuse(testfilepath), T... | [
"0.6444351",
"0.6426072",
"0.6283591",
"0.6172118",
"0.61503386",
"0.6138525",
"0.6099608",
"0.60918367",
"0.6083042",
"0.6072693",
"0.60709596",
"0.60503495",
"0.6015749",
"0.60109216",
"0.60021085",
"0.59650034",
"0.5952662",
"0.59276223",
"0.5914321",
"0.5912039",
"0.59116... | 0.6801063 | 0 |
Function should load a dictionary from a file | def load_dictionary(filepath):
# context manager read binary
with open(filepath, 'rb') as file:
# pickle load
return pickle.load(file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LoadDictFile(file,dict_,cast_type):\n\twith open(file,'r') as f:\n\t\tfor line in f:\n\t\t\tline = line.rstrip()\n\t\t\tlst = line.split('=')\n\t\t\tdict_[cast_type(lst[1])] = lst[0]",
"async def load(self, file: IO) -> dict:",
"def load_dictionary(filename):\n filename = os.path.join(FILE_DIR, 'assets/... | [
"0.77157265",
"0.7536715",
"0.75327575",
"0.72952855",
"0.72682524",
"0.7195715",
"0.7186805",
"0.71676797",
"0.7131927",
"0.7061436",
"0.7047471",
"0.70369333",
"0.7028529",
"0.69849616",
"0.6973206",
"0.6962486",
"0.6944044",
"0.6879049",
"0.68786466",
"0.6878157",
"0.68545... | 0.7720703 | 0 |
Calculate margin loss according to Hinton's paper. L = T_c max(0, m_plus||v_c||)^2 + lambda_ (1T_c) max(0, ||v_c||m_minus)^2 | def _margin_loss(self,
logits,
labels,
m_plus=0.9,
m_minus=0.1,
lambda_=0.5):
logits_shape = logits.get_shape()
num_caps = logits_shape[1]
max_square_plus = tf.square(tf.maximum(
0., m_plus - utils.get_ve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contrastive_loss(margin=1):\n\n def loss(y_true, y_pred):\n xs, xt = y_pred[:, 0], y_pred[:, 1]\n ys, yt = y_true[:, 0], y_true[:, 1]\n\n dist = euclidean_distance(xs, xt)\n label = labels_equal(ys, yt)\n\n losses = label * K.square(dist) + (1 - label) * K.square(\n ... | [
"0.63930035",
"0.6346131",
"0.6125172",
"0.60885173",
"0.6012759",
"0.5932477",
"0.5866596",
"0.5846412",
"0.5810569",
"0.58080727",
"0.58073467",
"0.57562715",
"0.57552606",
"0.57339376",
"0.5686424",
"0.56798446",
"0.56685346",
"0.56635207",
"0.5641313",
"0.56332296",
"0.56... | 0.6888408 | 0 |
Tests if letters/strings are handled correctly. | def test_letters(self):
self.assertFalse(validate_measure_input('a', self.measures))
self.assertFalse(validate_measure_input('1a', self.measures)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_words_with_numbers(self):\n\n test_string = \"1. FC Köln\"\n test_anagram = \"anagram\"\n with pytest.raises(ValueError) as exc_info:\n is_anagram(test_string, test_anagram)\n expected_error_msg = \"should only contain letters!\"\n assert exc_info.match(expect... | [
"0.71309525",
"0.7097389",
"0.6901242",
"0.6896055",
"0.6818811",
"0.6768303",
"0.6766348",
"0.6739837",
"0.6655418",
"0.66384023",
"0.6630305",
"0.6609714",
"0.6550024",
"0.6545507",
"0.6535795",
"0.6516263",
"0.651611",
"0.65053606",
"0.65000904",
"0.6480222",
"0.6458952",
... | 0.7154401 | 0 |
Converts input to a long number (arbitrary precision python long) | def to_long(x):
if isinstance(x, long):
return x
elif isinstance(x, int):
return long(x)
else:
return bytes_to_long(to_bytes(x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertToLong(boolean: bool) -> int:\n ...",
"def to_long_int(val):\n return long(val) if six.PY2 else int(val)",
"def __long__(self):\n return long(self.micros() // 1000000) # pragma: PY2",
"def bit_to_long(bits: str) -> Decimal:\n ints = int(bits, 2)\n result = Decimal(ints) / Dec... | [
"0.71833193",
"0.7089014",
"0.70808446",
"0.69977486",
"0.6903322",
"0.6887901",
"0.6800366",
"0.66683525",
"0.6633847",
"0.6587081",
"0.655539",
"0.6547889",
"0.6509656",
"0.644731",
"0.6438394",
"0.6419857",
"0.6412716",
"0.6406161",
"0.6363855",
"0.63358366",
"0.62108755",... | 0.7544155 | 0 |
Converts input to byte array. If already a byte array, return directly. | def to_bytearray(x):
if isinstance(x, bytearray):
return x
else:
return bytearray(x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_bytearray(self):\n\n if self.index < 7:\n return self.buf + bytearray([self.byte])\n else:\n return self.buf",
"def test_to_Bytes(self) -> None:\n self.assertEqual(to_bytes('Hello'),\n bytearray('Hello', 'utf-8'),\n ... | [
"0.6864896",
"0.68567413",
"0.674494",
"0.6716814",
"0.6703331",
"0.6647375",
"0.657145",
"0.65504086",
"0.65273243",
"0.6525264",
"0.64911836",
"0.6486141",
"0.6486141",
"0.64731306",
"0.6405747",
"0.63683736",
"0.6367405",
"0.6331301",
"0.6328856",
"0.62902015",
"0.61904055... | 0.78577083 | 0 |
Left padding with zero bytes to a given block size | def left_zero_pad(s, blocksize):
if blocksize > 0 and len(s) % blocksize:
s = (blocksize - len(s) % blocksize) * b('\000') + s
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def naive_block_padding(b: bytes, size: int) -> bytes:\n assert size <= 0xff\n\n l = len(b)\n if l > 0 and l % size == 0:\n return b\n\n return b + b'\\x00' * (size - (l % size))",
"def Pad(value, block_size):\n assert block_size < 256\n pad_length = block_size - (len(value) % block_size)\n ... | [
"0.8370115",
"0.7093651",
"0.6898142",
"0.6859687",
"0.6717382",
"0.65926135",
"0.65867615",
"0.65632814",
"0.65010875",
"0.6465424",
"0.646267",
"0.6437639",
"0.64141816",
"0.6324179",
"0.6253785",
"0.62460166",
"0.622652",
"0.61822593",
"0.61756",
"0.6170126",
"0.6151013",
... | 0.7142999 | 1 |
Replaces given portion of the byte string with the replacement, returns new array | def bytes_replace(byte_str, start_idx, stop_idx, replacement):
return byte_str[:start_idx] + replacement + byte_str[stop_idx:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytes_transform(byte_str, start_idx, stop_idx, fction):\n return bytes_replace(byte_str, start_idx, stop_idx, fction(byte_str[start_idx:stop_idx]))",
"def replace(a, old, new, count=None):\n return _to_bytes_or_str_array(\n _vec_string(a, object_, 'replace', [old, new] + _clean_args(count)), a)"... | [
"0.70731133",
"0.62173766",
"0.59386647",
"0.593747",
"0.57612884",
"0.5440963",
"0.52149284",
"0.5202526",
"0.5186644",
"0.5149682",
"0.51198226",
"0.5117189",
"0.51111066",
"0.51036936",
"0.50337416",
"0.50139666",
"0.5010379",
"0.49768823",
"0.49707997",
"0.4932125",
"0.49... | 0.7562967 | 0 |
Takes portion of the byte array and passes it to the function for transformation. Result is replaced in the byte string, new one is created. | def bytes_transform(byte_str, start_idx, stop_idx, fction):
return bytes_replace(byte_str, start_idx, stop_idx, fction(byte_str[start_idx:stop_idx])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_bytearray(func):\n def wrapped(ber, *args, **kwargs):\n return func(bytearray(ber), *args, **kwargs)\n return wrapped",
"def bytes_replace(byte_str, start_idx, stop_idx, replacement):\n return byte_str[:start_idx] + replacement + byte_str[stop_idx:]",
"def swap_byte(byte_array, inde... | [
"0.6739505",
"0.6147692",
"0.59799117",
"0.5650199",
"0.54705834",
"0.54443973",
"0.53769463",
"0.53197944",
"0.52554286",
"0.519301",
"0.51607287",
"0.51203686",
"0.5112078",
"0.510789",
"0.50480986",
"0.50392234",
"0.50298625",
"0.4998115",
"0.49935344",
"0.49289808",
"0.49... | 0.70879704 | 0 |
UnPads data with given padding. | def unpad(data, *args, **kwargs): # pragma: no cover
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpad(padded_data):\r\n num_padded_bytes = ord(padded_data[-1])\r\n return padded_data[:-num_padded_bytes]",
"def __unpad(self, data):\n return data[0:-ord(data[-1])]",
"def __UnPad(self, padded):\n pad = ord(padded[-1])\n return padded[:-pad]",
"def _UnPad(self, padded):\n pad ... | [
"0.7991166",
"0.72844607",
"0.7097542",
"0.70551294",
"0.6789257",
"0.6728896",
"0.67067367",
"0.66098905",
"0.6554104",
"0.65322286",
"0.64679575",
"0.6453025",
"0.64359903",
"0.6385539",
"0.6341794",
"0.6241951",
"0.6167369",
"0.61502737",
"0.6148065",
"0.61398244",
"0.6016... | 0.79424536 | 1 |
Returns AESECB instance that can be used for [incremental] encryption/decryption in ProcessData. Uses zero IV. | def aes_ecb(key):
return AES.new(key, AES.MODE_ECB) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aes_cbc(key, iv=None):\n return AES.new(key, AES.MODE_CBC, iv if iv is not None else get_zero_vector(16))",
"def new(key,mode=MODE_ECB,IV=None,counter=None,segment_size=None):\n return AES(key,mode,IV,counter,segment_size)",
"def _derive_crypto(self, pad_string): # XXX consider secret_seed\n s... | [
"0.63271695",
"0.60247505",
"0.5949071",
"0.58235",
"0.573209",
"0.5639496",
"0.5624119",
"0.5622613",
"0.5622613",
"0.55989546",
"0.55408275",
"0.55408275",
"0.5507309",
"0.54683155",
"0.5438487",
"0.54055506",
"0.53939086",
"0.53629184",
"0.5359377",
"0.5335843",
"0.5326016... | 0.64419377 | 0 |
Returns AESCBC instance that can be used for [incremental] encryption/decryption in ProcessData. Uses zero IV. | def aes_cbc(key, iv=None):
return AES.new(key, AES.MODE_CBC, iv if iv is not None else get_zero_vector(16)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new(key,mode=MODE_ECB,IV=None,counter=None,segment_size=None):\n return AES(key,mode,IV,counter,segment_size)",
"def aes(encrypt, key, data):\n cipher = AES.new(key, AES.MODE_CBC, get_zero_vector(16))\n if encrypt:\n return cipher.encrypt(data)\n else:\n return cipher.decrypt(data)"... | [
"0.6574353",
"0.6556711",
"0.64435697",
"0.64173234",
"0.62514883",
"0.62330794",
"0.6186859",
"0.6179042",
"0.61665446",
"0.61548847",
"0.6117961",
"0.6045605",
"0.6024071",
"0.6006862",
"0.59993553",
"0.5986824",
"0.59542495",
"0.5917819",
"0.5906413",
"0.58804756",
"0.5826... | 0.77608013 | 0 |
Returns AESCTR instance that can be used for [incremental] encryption/decryption in ProcessData. Uses zero IV. | def aes_ctr(key, counter=None):
return AES.new(key, AES.MODE_CTR, counter=(counter if counter is not None else Counter.new(128))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encryptAESCTR(key, plaintext):\n # 128-bit iv, securely generated\n iv = os.urandom(16)\n cipher = Cipher(algorithms.AES(key), modes.CTR(iv), backend=default_backend())\n encryptor = cipher.encryptor()\n ciphertext = encryptor.update(plaintext) + encryptor.finalize()\n return (iv, ciphertext)... | [
"0.73573077",
"0.6901903",
"0.6791584",
"0.6706533",
"0.6585748",
"0.6567221",
"0.6291709",
"0.6291537",
"0.6176709",
"0.6174848",
"0.61711013",
"0.61466664",
"0.6124014",
"0.5979416",
"0.5888942",
"0.5830648",
"0.5803025",
"0.58018255",
"0.57647514",
"0.57589465",
"0.5758341... | 0.753134 | 0 |
AES265CBCMAC on the data used in ProcessData. Does not use padding (data has to be already padded). | def cbc_mac(key, data):
engine = AES.new(key, AES.MODE_CBC, get_zero_vector(16))
return engine.encrypt(data)[-16:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CBCMACbasedOnAES(message, key):\n\n # Convert the message into bytes\n message1 = bytes(message)\n # Convert the key into bytes\n key1 = bytes(key)\n\n # Create the AES object\n aes_obj = AES.new(key1, AES.MODE_CBC, iv)\n # Encrypt the message\n MAC = aes_obj.encrypt(message1)\n # Re... | [
"0.7094102",
"0.6343049",
"0.61295545",
"0.6099766",
"0.60898626",
"0.6043543",
"0.6009596",
"0.58651805",
"0.58164257",
"0.581059",
"0.5750753",
"0.5717469",
"0.57139987",
"0.564498",
"0.56241363",
"0.561242",
"0.5610914",
"0.55836046",
"0.5528407",
"0.55279326",
"0.55140543... | 0.79774415 | 0 |
Simple RAW RSA encryption method, returns byte string. Returns byte string of the same size as the modulus (left padded with 0) | def rsa_enc(data, modulus, exponent):
modulus = to_long(modulus)
exponent = to_long(exponent)
data = to_long(data)
return long_to_bytes(pow(data, exponent, modulus), long_byte_size(modulus)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_encrypted_password(password, rsa_mod, pub_exp):\n public_key = RSA.construct((rsa_mod, pub_exp))\n cipher = PKCS1_v1_5.new(public_key)\n ciphertext = cipher.encrypt(bytes(password, 'utf_8'))\n return base64.b64encode(ciphertext)",
"def rsa_encrypt(message, publickey):\r\n \r\n # A key objec... | [
"0.67541856",
"0.6722137",
"0.66991395",
"0.6649675",
"0.6631256",
"0.6612831",
"0.6589475",
"0.65471846",
"0.64938384",
"0.64437604",
"0.6402936",
"0.63886666",
"0.6387991",
"0.6299383",
"0.62502104",
"0.60981125",
"0.60580474",
"0.6026036",
"0.6020607",
"0.5996862",
"0.5970... | 0.7327985 | 0 |
A little helper to wrap a sequencing file (or join and wrap R1/R2 pairs) and return a merged file_object | def _wrap_files(filename, logger=None, validate=True):
if isinstance(filename, tuple):
if not validate:
raise UploadException('Validation is required in order to auto-interleave files.')
file_obj = FASTXTranslator(open(filename[0], 'rb'), pair=open(filename[1], 'rb'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def joinInds(r1,r2,outfname):\n outf = open(outfname,'w')\n f1 = file(r1,'r')\n f2 = file(r2,'r')\n for row1 in f1:\n outf.write('%s\\n' % (row1.strip()))\n for row1 in f2:\n outf.write('%s\\n' % (row1.strip()))\n outf.close()",
"def process_reads_joined(args):\n\n watson_joined_r1 = t... | [
"0.572869",
"0.5557239",
"0.5488398",
"0.5372837",
"0.5360017",
"0.5318559",
"0.5221222",
"0.52029955",
"0.51902723",
"0.5150185",
"0.5119459",
"0.5107674",
"0.5077772",
"0.50298285",
"0.5009346",
"0.4998611",
"0.4991757",
"0.49609476",
"0.49526083",
"0.4907287",
"0.48981005"... | 0.5905716 | 0 |
Uploads several files to the One Codex server, autodetecting sizes and using the appropriate downstream upload functions. Also, wraps the files with a streaming validator to ensure they work. | def upload(files, session, samples_resource, server_url, threads=DEFAULT_UPLOAD_THREADS,
validate=True, log_to=None, metadata=None, tags=None):
if threads is None:
threads = 1
filenames = []
file_sizes = []
for file_path in files:
normalized_filename, file_size = _file_stats(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_file(\n files: List[UploadFile] = File(...),\n # JSON serialized string\n meta: Optional[str] = Form(\"null\"), # type: ignore\n additional_params: Optional[str] = Form(\"null\"), # type: ignore\n fileconverter_params: FileConverterParams = Depends(FileConverterParams.as_form), # type:... | [
"0.6732185",
"0.6465537",
"0.64610445",
"0.6355578",
"0.6296223",
"0.6295011",
"0.6111432",
"0.61030525",
"0.60987955",
"0.60602444",
"0.60228014",
"0.6015733",
"0.5915797",
"0.58912164",
"0.5890179",
"0.587315",
"0.5869973",
"0.58551884",
"0.585341",
"0.58388096",
"0.582997"... | 0.64983374 | 1 |
Test that store keeps recently gotten objects fresh. | def test02StoreRefresh(self):
s = utils.FastStore(max_size=5)
keys = []
for i in range(0, 5):
keys.append(s.Put(i, i))
# This should not raise because keys[0] should be refreshed each time its
# gotten
for i in range(0, 1000):
s.Get(keys[0])
s.Put(i, i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_transition(self):\n # Make sure we push the upgraded items out of cache\n gc.collect()\n\n self.assertEqual(self.store.getItemByID(1).attribute, 'one')\n self.assertEqual(\n self.store.findUnique(Dummy, Dummy.attribute == 'two').storeID,\n 2)\n self... | [
"0.697085",
"0.69429755",
"0.6841165",
"0.6710148",
"0.6481923",
"0.6461961",
"0.64603156",
"0.645962",
"0.64174074",
"0.6410219",
"0.64075446",
"0.64039254",
"0.64001304",
"0.6375129",
"0.6361893",
"0.63442135",
"0.6313537",
"0.628334",
"0.6275245",
"0.6243623",
"0.6206671",... | 0.71434987 | 0 |
Transform a data entry. Use NER to regconize the productrelated named entities and mark them in the sequence. Normalize the numbers into the same format. | def transform(self, entry):
res = ''
doc = self.nlp(entry, disable=['tagger', 'parser'])
ents = doc.ents
start_indices = {}
end_indices = {}
for ent in ents:
start, end, label = ent.start, ent.end, ent.label_
if label in ['NORP', 'GPE', '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self, entry):\r\n res = ''\r\n doc = self.nlp(entry, disable=['tagger', 'parser'])\r\n ents = doc.ents\r\n start_indices = {}\r\n end_indices = {}\r\n\r\n for ent in ents:\r\n start, end, label = ent.start, ent.end, ent.label_\r\n if lab... | [
"0.75562656",
"0.61985934",
"0.5599489",
"0.55611694",
"0.5552373",
"0.5512243",
"0.54974383",
"0.5449704",
"0.5446658",
"0.54295605",
"0.5342212",
"0.5342212",
"0.5341705",
"0.5302645",
"0.5300407",
"0.52712303",
"0.5196985",
"0.51722336",
"0.51490843",
"0.51453876",
"0.5136... | 0.788057 | 0 |
Transform a data entry. Use NER to regconize the productrelated named entities and mark them in the sequence. Normalize the numbers into the same format. | def transform(self, entry):
res = ''
doc = self.nlp(entry, disable=['tagger', 'parser'])
ents = doc.ents
start_indices = {}
end_indices = {}
for ent in ents:
start, end, label = ent.start, ent.end, ent.label_
if label in ['PERSON', 'ORG',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self, entry):\r\n res = ''\r\n doc = self.nlp(entry, disable=['tagger', 'parser'])\r\n ents = doc.ents\r\n start_indices = {}\r\n end_indices = {}\r\n\r\n for ent in ents:\r\n start, end, label = ent.start, ent.end, ent.label_\r\n if lab... | [
"0.7879832",
"0.61991173",
"0.5601704",
"0.55614793",
"0.55525833",
"0.5511357",
"0.54981124",
"0.54509777",
"0.54464257",
"0.5428605",
"0.53433484",
"0.53433484",
"0.53431886",
"0.53011644",
"0.5300773",
"0.5271714",
"0.5198004",
"0.5173124",
"0.51489216",
"0.51479363",
"0.5... | 0.7555181 | 1 |
Lists region tags in a directory. This method lists the region tags for snippets parsed from a given directory, filtered based on whether each tag was detected by an AST parser (or not). It can also display test counts and/or source filenames for each region tag. | def list_region_tags(
data_json: str,
root_dir: str,
show_detected: bool,
show_undetected: bool,
show_test_counts: bool,
show_filenames: bool,
output_file: Optional[str] = None
) -> None:
invocation = cli_list_region_tags_datatypes.ListRegionTagsInvocation(
data_json,
roo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tags(directory=None):\n out = check_output('git tag -l', shell=True, cwd=directory)\n return [l.strip() for l in out.splitlines()]",
"def readDirectory():\n tagdir = \"tagreplacements\"\n data = os.listdir(tagdir)\n for d in data:\n processFile(os.path.join(tagdir,d))\n \n ... | [
"0.59012514",
"0.5551803",
"0.5343597",
"0.53303736",
"0.52444696",
"0.5199622",
"0.51976204",
"0.5193635",
"0.51501286",
"0.51477724",
"0.5129671",
"0.49715024",
"0.49408093",
"0.49267346",
"0.4917415",
"0.4906032",
"0.48901626",
"0.48855624",
"0.48729616",
"0.48576432",
"0.... | 0.6683967 | 0 |
Lists snippet source file paths in a directory. This method lists the source files for snippets parsed from a given directory. It can also filter listed source files based on how many (all, some, or none) of their methods are tested using the show_tested_files parameter. | def list_source_files(
data_json: str,
root_dir: str,
show_tested_files: str,
output_file: str = None
) -> None:
tested_files_filter = ShowTestedFilesOption.UNSPECIFIED
if show_tested_files == 'all':
tested_files_filter = ShowTestedFilesOption.ALL_TESTED
if show_tested_files == 'some... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_sources(config, base_dir, verbose=False):\n for source in config.sources_under(abspath(base_dir)):\n if verbose:\n print(\"# %s (%s)\" % (source.nicedir, ' '.join(source.info)))\n else:\n print(source.nicedir)",
"def walkSource(sourcedir):\n for parent, dnames, ... | [
"0.65945834",
"0.6350072",
"0.6207375",
"0.61457",
"0.5851436",
"0.5821924",
"0.58109605",
"0.5760024",
"0.57160944",
"0.57134724",
"0.5702457",
"0.57011604",
"0.56663465",
"0.5661994",
"0.56595105",
"0.56462985",
"0.5584346",
"0.5582579",
"0.55690575",
"0.5564514",
"0.556436... | 0.648332 | 1 |
Adds snippet mapping to XUnit results This method injects testsnippet mappings into XUnit test results provided via stdin. It then saves the modified XUnit results to a file (if output_file is specified) or prints them to stdout (if output_file is not specified). | def inject_snippet_mapping(
data_json: str,
root_dir: str,
stdin_lines: List[str],
output_file: str = None
) -> None:
grep_tags, source_tags, ignored_tags, source_methods = (
analyze.analyze_json(data_json, root_dir))
xunit_tree = etree.fromstring(''.join(stdin_lines))
for elem in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_outputs(self, monkeypatch, script_runner):\n monkeypatch.setattr(\"builtins.input\", lambda _: \"n\")\n _ = script_runner.run(\n \"spectrafit\",\n \"spectrafit/test/test_data.txt\",\n \"-i\",\n \"spectrafit/test/test_input_2.json\",\n )\n ... | [
"0.52753115",
"0.5105577",
"0.5007354",
"0.49727327",
"0.49370566",
"0.4909723",
"0.48898146",
"0.48776826",
"0.48700637",
"0.48604727",
"0.4830978",
"0.48222542",
"0.48195934",
"0.47960544",
"0.47797915",
"0.47585177",
"0.47288483",
"0.47284773",
"0.4692374",
"0.468757",
"0.... | 0.69448084 | 0 |
Validates .driftdata.yml files in a directory This method coordinates the function calls necessary to validate .driftdata.yml files in a given directory. (The validation process requires data provided by analyze_json(), and this method is responsible for passing that in.) | def validate_yaml(
data_json: str,
root_dir: str,
output_file: str = None
) -> None:
grep_tags, source_tags, ignored_tags, source_methods = (
analyze.analyze_json(data_json, root_dir))
(is_valid, output) = cli_yaml.validate_yaml_syntax(
root_dir, grep_tags, source_tags)
if is_v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_and_validate_data_dir(data_dir):\n paths = [data_dir] + [os.path.join(data_dir, name) for name in FILE_NAMES]\n exists = [(path, os.path.exists(path)) for path in paths]\n try:\n for path, exist in exists:\n if not exist:\n raise ValidationError(path)\n except... | [
"0.70002323",
"0.64700806",
"0.62435204",
"0.5982702",
"0.59821767",
"0.59097767",
"0.588178",
"0.5777706",
"0.57355917",
"0.5618488",
"0.5482903",
"0.546748",
"0.5457439",
"0.543201",
"0.54215956",
"0.5412129",
"0.5409269",
"0.5399892",
"0.5397897",
"0.5377141",
"0.5340466",... | 0.6470534 | 1 |
Precache all of the expected reference files in this Pipeline and all of its constituent Steps process method is called. | def _precache_reference_files(self, input_file):
from .. import datamodels
gc.collect()
if self._is_association_file(input_file):
return
try:
with datamodels.open(input_file) as model:
pass
except (ValueError, TypeError, IOError):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_process(self):\n pass",
"def pre_process(self):\n pass",
"def pre_process(self):\n pass",
"def pre_process(self):\n pass",
"def pre_process(self):\n pass",
"def _preprocess(self) -> None:\n self.cache = Cache(self._db, self._collection)",
"def _process(... | [
"0.67565",
"0.67565",
"0.67565",
"0.67565",
"0.67565",
"0.6575263",
"0.64304614",
"0.6406577",
"0.6208569",
"0.6208569",
"0.6208569",
"0.6208569",
"0.6050709",
"0.6029473",
"0.6004142",
"0.5949255",
"0.5798601",
"0.5706825",
"0.5704216",
"0.56844485",
"0.567021",
"0.5655070... | 0.78635967 | 0 |
Return all divs that contain movie info | def parse_movies(self):
soup = super().get_soup()
return soup.find_all("div", class_="lister-item") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrape_movie_page(dom):\n # to save the information\n info = []\n\n # find the information block needed\n header = dom.find(\"div\", \"title_wrapper\")\n\n # find the title and strip the string\n name_dom = header.h1.get_text().encode(\"utf-8\")\n name = str(name_dom)[2:-16]\n info.appe... | [
"0.67132944",
"0.66726196",
"0.66449946",
"0.65623224",
"0.6446526",
"0.62505364",
"0.6215223",
"0.59938693",
"0.58345604",
"0.5773485",
"0.5759078",
"0.57380635",
"0.571512",
"0.5705588",
"0.5701006",
"0.56361914",
"0.56170136",
"0.56035405",
"0.5601901",
"0.55887705",
"0.55... | 0.73239434 | 0 |
estimate the transition matrix row i column j represents to logprobability of transitions from the i'th tag to the j'th tag this implements an AddOne Smoothing on the transition, since some possible transitions do not occur in the training set | def estimate_transition(train):
trans = [[1 for i in xrange(len(TAGS))] for j in xrange(len(TAGS))]
for sent in train:
new_sent = add_start_and_stop(sent)
for i in xrange(len(new_sent) - 1):
tag1, tag2 = new_sent[i][1], new_sent[i + 1][1] # index 1 is the tag in the tuple of (word, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(log_emlik, log_startprob, log_transmat):\n alpha = np.zeros(log_emlik.shape)\n\n alpha[0,:] = log_startprob[0:-1] + log_emlik[0,:]\n\n sum_row = 0;\n log_transmat = log_transmat[0:-1];\n\n\n for frame in range(1,len(log_emlik)):\n\n for state in range(0,len(log_emlik[0])):\n\n ... | [
"0.65470827",
"0.6429482",
"0.62792164",
"0.6264566",
"0.6230956",
"0.6206846",
"0.6199234",
"0.6097541",
"0.60864514",
"0.6033581",
"0.6028445",
"0.5963852",
"0.5952879",
"0.59384346",
"0.5900302",
"0.5865873",
"0.5838711",
"0.58203197",
"0.57051677",
"0.5702328",
"0.5687007... | 0.70866513 | 0 |
estimate the emission matrix row i column j represents the logprob of the i'th tag emitting j'th word | def estimate_emission(train):
emission = [[0 for i in xrange(len(WORDS))] for j in xrange(len(TAGS))]
for sent in train:
new_sent = add_start_and_stop(sent)
for word, tag in new_sent:
emission[TAG2INDEX[tag]][WORDS2INDEX[word]] += 1
# normalize so each row has sum of 1
for ro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_prob(self):",
"def log_prob(sentence, LM, smoothing=False, delta=0, vocabSize=0):\n word_list = sentence.split()\n log_prob = 0\n for i in range(len(word_list)-1):\n print(word_list[i], word_list[i+1])\n bi_count = LM['bi'][word_list[i]][word_list[i+1]]\n uni_count = LM['uni... | [
"0.65082157",
"0.64951247",
"0.6309652",
"0.628724",
"0.62518716",
"0.6247146",
"0.6247146",
"0.620198",
"0.6158398",
"0.61074936",
"0.6092002",
"0.6087706",
"0.60593224",
"0.6029009",
"0.598404",
"0.59732735",
"0.59465975",
"0.59084207",
"0.5887237",
"0.5881242",
"0.5880657"... | 0.6677257 | 0 |
Checks that val matches expval within tol. | def check_eq(self, val, expval, tol=None):
if type(val) == dict:
for k in val:
check_eq(val[k], expval[k], tol)
else:
try:
if tol and hasattr(val, '__rsub__'):
are_eq = abs(val - expval) < tol
else:
are_eq = val == expval
if hasattr(are_eq, 'all'):
are_eq = are_eq.all()
if not ar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_eq(val, expval, tol=None):\n if type(val) == dict:\n for k in val:\n check_eq(val[k], expval[k], tol)\n else:\n try:\n if tol and hasattr(val, '__rsub__'):\n are_eq = abs(val - expval) < tol #absolute check\n if not are_eq:\n ... | [
"0.74817556",
"0.73392266",
"0.66608334",
"0.64932805",
"0.6435671",
"0.63631684",
"0.6357435",
"0.6345592",
"0.6262903",
"0.60201436",
"0.59483665",
"0.58813614",
"0.5870131",
"0.582173",
"0.58084345",
"0.57534915",
"0.5746604",
"0.5743785",
"0.57117945",
"0.56994355",
"0.56... | 0.74903756 | 0 |
Get indices of agents in array | def get_agent_indices(array):
agent_indices = np.argwhere(array != 0)
return agent_indices | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_agent_indices_of_type(array, agent_type):\t\n\tagent_indices = np.argwhere(array == agent_type)\n\treturn agent_indices",
"def get_vacancy_indices(array):\t\n\tvacancy_indices = np.argwhere(array == 0)\n\treturn vacancy_indices",
"def agent_locs_idx(self):\n return tuple(self.agent_locs.T)",
"... | [
"0.7976538",
"0.70531416",
"0.70311135",
"0.6646779",
"0.6600509",
"0.64596474",
"0.63922334",
"0.63716406",
"0.6315002",
"0.6268353",
"0.6263609",
"0.6165633",
"0.6158411",
"0.61511016",
"0.6067781",
"0.60366654",
"0.60299534",
"0.60228944",
"0.6012805",
"0.59855855",
"0.591... | 0.85050434 | 0 |
Get indices of agents in array | def get_agent_indices_of_type(array, agent_type):
agent_indices = np.argwhere(array == agent_type)
return agent_indices | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_agent_indices(array):\t\n\tagent_indices = np.argwhere(array != 0)\n\treturn agent_indices",
"def get_vacancy_indices(array):\t\n\tvacancy_indices = np.argwhere(array == 0)\n\treturn vacancy_indices",
"def agent_locs_idx(self):\n return tuple(self.agent_locs.T)",
"def atom_idxs(self):\n\n ... | [
"0.85050434",
"0.70531416",
"0.70311135",
"0.6646779",
"0.6600509",
"0.64596474",
"0.63922334",
"0.63716406",
"0.6315002",
"0.6268353",
"0.6263609",
"0.6165633",
"0.6158411",
"0.61511016",
"0.6067781",
"0.60366654",
"0.60299534",
"0.60228944",
"0.6012805",
"0.59855855",
"0.59... | 0.7976538 | 1 |
Get indices of vacancies in array | def get_vacancy_indices(array):
vacancy_indices = np.argwhere(array == 0)
return vacancy_indices | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_agent_indices(array):\t\n\tagent_indices = np.argwhere(array != 0)\n\treturn agent_indices",
"def occ_indices(self):\n indices = []\n for index,item in enumerate(self):\n if item==1:\n indices.append(index)\n return indices",
"def getCavityInds(board):\n ... | [
"0.6924578",
"0.67764175",
"0.66333616",
"0.6404924",
"0.6271628",
"0.61819667",
"0.6155188",
"0.6143064",
"0.61233395",
"0.6095246",
"0.60415274",
"0.6010839",
"0.59939235",
"0.59420985",
"0.5935518",
"0.5873053",
"0.5868035",
"0.5846514",
"0.5841468",
"0.5787059",
"0.577237... | 0.84648967 | 0 |
Get a list of all the sessions | def get_sessions_list():
sessions = Session.query.all()
result = sessions_schema.dump(sessions).data
return jsonify({'status': 'success', 'message': None, 'data': result}), 200 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sessions(self):\n return utils.listItems(self, '/status/sessions')",
"def get_sessions(self):\n\n return self.all_sessions",
"def sessions(self):\n logger.debug(\"Get sessions\")\n return self._raw_api.sessions.get()",
"def sessions(self):\n return list(Session.get_sess... | [
"0.83981013",
"0.83946335",
"0.8330105",
"0.82899654",
"0.7961469",
"0.784901",
"0.77497256",
"0.7688982",
"0.7669113",
"0.7566318",
"0.7515964",
"0.7467716",
"0.74600327",
"0.73789865",
"0.7288659",
"0.72665817",
"0.7257374",
"0.72267705",
"0.71327496",
"0.71148413",
"0.7099... | 0.8545833 | 0 |
Convert sample number to video time, using snc information. | def convert_sample_to_video_time(sample, orig_s_freq, sampleStamp,
sampleTime):
if sample < sampleStamp[0]:
s_freq = orig_s_freq
id0 = 0
elif sample > sampleStamp[-1]:
s_freq = orig_s_freq
id0 = len(sampleStamp) - 1
else:
id0 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_snc(snc_file):\r\n with open(snc_file, 'rb') as f:\r\n filebytes = f.read()\r\n i = 352 # end of header\r\n\r\n sampleStamp = []\r\n sampleTime = []\r\n while i < len(filebytes):\r\n sampleStamp.append(unpack('<i', filebytes[i:(i + 4)])[0])\r\n i += 4\r\n sampl... | [
"0.6075722",
"0.59033084",
"0.5844779",
"0.58410543",
"0.56027436",
"0.5512384",
"0.55118567",
"0.5421982",
"0.5421982",
"0.54197514",
"0.531594",
"0.5266349",
"0.52508074",
"0.51986617",
"0.5169903",
"0.51641965",
"0.51315343",
"0.51209456",
"0.5116544",
"0.5101688",
"0.5090... | 0.6431291 | 0 |
Converts a Microsoft filetime number to a Python datetime. The new datetime object is time zonenaive but is equivalent to tzinfo=utc. | def _filetime_to_dt(ft):
# Get seconds and remainder in terms of Unix epoch
s, ns100 = divmod(ft - EPOCH_AS_FILETIME, HUNDREDS_OF_NANOSECONDS)
# Convert to datetime object
dt = datetime.utcfromtimestamp(s)
# Add remainder in as microseconds. Python 3.2 requires an integer
dt = dt.replace(m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fileTime(ft):\n return datetime(1601, 1, 1) + timedelta(microseconds=ft / 10)",
"def filetime_to_time(filetime):\r\n total = filetime.dwHighDateTime << 32 | filetime.dwLowDateTime\r\n return total / 10000000 - SECONDS_BETWEEN_EPOCHS",
"def microseconds_to_datetime(ms):\n return datetime... | [
"0.66038",
"0.64271015",
"0.6318054",
"0.6016368",
"0.60009575",
"0.59586394",
"0.5908033",
"0.5838013",
"0.5741333",
"0.56662536",
"0.556872",
"0.55569816",
"0.55468",
"0.55346006",
"0.5509647",
"0.5491392",
"0.5456959",
"0.5437118",
"0.5429036",
"0.5412592",
"0.5404405",
... | 0.6847953 | 0 |
Find the channel names within a string. The channel names are stored in the .ent file. We can read the file with _read_ent and we can parse most of the notes (comments) with _read_notes however the note containing the montage cannot be read because it's too complex. So, instead of parsing it, we just pass the string of... | def _find_channels(note):
id_ch = note.index('ChanNames')
chan_beg = note.index('(', id_ch)
chan_end = note.index(')', chan_beg)
note_with_chan = note[chan_beg + 1:chan_end]
return [x.strip('" ') for x in note_with_chan.split(',')] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_where_ref_channel(ome_meta: str, ref_channel: str):\n\n channels, channel_names, channel_ids, channel_fluors = extract_channel_info(str_to_xml(ome_meta))\n\n # strip cycle id from channel name and fluor name\n if channel_fluors != []:\n fluors = [re.sub(r'^(c|cyc|cycle)\\d+(\\s+|_)', '', f... | [
"0.61524904",
"0.54154235",
"0.5043923",
"0.49835595",
"0.49823162",
"0.4954471",
"0.4927213",
"0.49230048",
"0.48484543",
"0.47972777",
"0.47366056",
"0.47282827",
"0.4686948",
"0.46719527",
"0.46640122",
"0.46640122",
"0.46640122",
"0.46640122",
"0.46640122",
"0.46640122",
... | 0.6283344 | 0 |
Reads eeg file, but it doesn't work, the data is in text format, but based on Excel. You can read it from the editor, there are still a couple of signs that are not in Unicode. | def _read_eeg(eeg_file):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readascii(file_name):\n data = np.loadtxt(file_name)\n z = data[0,1:]\n nuInu = data[1:,1:]\n lmu = data[1:,0]\n return EBL(z, lmu, nuInu)",
"def read_data_nmt():\n data_dir = download_extract('fra-eng')\n with open(os.path.join(data_dir, 'fra.txt'), 'r') as f:\n ... | [
"0.6500846",
"0.6287905",
"0.61276597",
"0.6083316",
"0.5967664",
"0.5928223",
"0.590499",
"0.5823214",
"0.580512",
"0.5782175",
"0.5782034",
"0.5758312",
"0.572088",
"0.57156545",
"0.5699795",
"0.5670146",
"0.5667998",
"0.5663116",
"0.5649543",
"0.5640101",
"0.56308514",
"... | 0.75984216 | 0 |
Read notes stored in .ent file. This is a basic implementation, that relies on turning the information in the string in the dict format, and then evaluate it. It's not very flexible and it might not read some notes, but it's fast. I could not implement a nice, recursive approach. Returns | def _read_ent(ent_file):
with open(ent_file, 'rb') as f:
f.seek(352) # end of header
note_hdr_length = 16
allnote = []
while True:
note = {}
note['type'], = unpack('<i', f.read(4))
note['length'], = unpack('<i', f.read(4))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def textparse(self,\r\n analysetext,\r\n depth=0,\r\n keys=None,\r\n re_entering=False,\r\n newindex=Index(1)):\r\n if keys is None:\r\n keys = set()\r\n if LEFTNOTE not in analysetext \\\r\n or ... | [
"0.59489506",
"0.5723152",
"0.5570973",
"0.55582917",
"0.55383897",
"0.5525788",
"0.54965717",
"0.5495745",
"0.54364556",
"0.5431625",
"0.5365782",
"0.53186834",
"0.52833766",
"0.5266868",
"0.5246145",
"0.52257246",
"0.5211744",
"0.5200317",
"0.51792866",
"0.51473814",
"0.514... | 0.7163977 | 0 |
Return information about etc. ETC contains only 4 4bytes, I cannot make sense of it. The EEG file format does not have an explanation for ETC, it says it's similar to the end of STC, which has 4 int, but the values don't match. | def _read_etc(etc_file):
with open(etc_file, 'rb') as f:
f.seek(352) # end of header
v1 = unpack('<i', f.read(4))[0]
v2 = unpack('<i', f.read(4))[0]
v3 = unpack('<i', f.read(4))[0] # always zero?
v4_a = unpack('<h', f.read(2))[0] # they look like two values
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_uef_details(chunks):\n\n\tpos, chunk = find_next_chunk(chunks, 0, [0x0])\n\n\tif pos == None:\n\n\t\toriginator = 'Unknown'\n\n\telif chunk[1] == '':\n\n\t\toriginator = 'Unknown'\n\telse:\n\t\toriginator = chunk[1]\n\n\tpos, chunk = find_next_chunk(chunks, 0, [0x5])\n\n\tif pos == None:\n\n\t\tmachine, k... | [
"0.58750796",
"0.5783517",
"0.5726136",
"0.5682117",
"0.56699634",
"0.56375575",
"0.5590525",
"0.5566887",
"0.5555271",
"0.5457735",
"0.5429024",
"0.5426631",
"0.54007834",
"0.53922826",
"0.53848773",
"0.53045607",
"0.52531636",
"0.52309084",
"0.5179032",
"0.51650894",
"0.515... | 0.6807424 | 0 |
Read Synchronization File and return sample stamp and time Returns | def _read_snc(snc_file):
with open(snc_file, 'rb') as f:
filebytes = f.read()
i = 352 # end of header
sampleStamp = []
sampleTime = []
while i < len(filebytes):
sampleStamp.append(unpack('<i', filebytes[i:(i + 4)])[0])
i += 4
sampleTime.append(_filetime_to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trc_get_sample_time(path):\n datX, datY, m = readTrc.readTrc(path)\n return int(np.ceil(m['HORIZ_INTERVAL'] * 1e9))",
"def get_time_stamp():\n with open(TIME_STAMP_FILE_NAME, 'r') as f:\n s = f.readline()\n return s",
"def _read_stc(stc_file):\r\n hdr = _read_hdr_file(stc_file) # rea... | [
"0.6234124",
"0.6035637",
"0.59519786",
"0.59323096",
"0.5886322",
"0.5867882",
"0.58369714",
"0.582474",
"0.579488",
"0.5787041",
"0.57290554",
"0.56658626",
"0.56468034",
"0.5646631",
"0.5640535",
"0.5572029",
"0.5562968",
"0.55088305",
"0.548805",
"0.54814637",
"0.542931",... | 0.6828902 | 0 |
Reads header of one KTLX file. | def _read_hdr_file(ktlx_file):
with open(ktlx_file, 'rb') as f:
hdr = {}
assert f.tell() == 0
hdr['file_guid'] = hexlify(f.read(16))
hdr['file_schema'], = unpack('<H', f.read(2))
if not hdr['file_schema'] in (1, 3, 7, 8, 9):
raise NotImplementedError('R... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_header(self):\n\n stream = self.stream\n\n self._seek_to_table(tables.header)\n\n # Read header[0 ... 1]\n checksum = stream.read_unsigned_byte4()\n design_font_size = stream.read_fix_word()\n\n # Read header[2 ... 11] if there\n character_info_table_posit... | [
"0.6898563",
"0.68805265",
"0.67390066",
"0.6717703",
"0.6684781",
"0.66508096",
"0.6539705",
"0.64888555",
"0.64824027",
"0.6445436",
"0.64279646",
"0.64254093",
"0.6398718",
"0.6375504",
"0.6320351",
"0.62575525",
"0.62472034",
"0.62335426",
"0.62308323",
"0.62160414",
"0.6... | 0.7324444 | 0 |
Read the data based on begsam and endsam. | def return_dat(self, chan, begsam, endsam):
dat = empty((len(chan), endsam - begsam))
dat.fill(NaN)
stc, all_stamp = _read_stc(join(self.filename, self._basename +
'.stc'))
all_erd = [x['segment_name'] for x in all_stamp]
all_beg ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_sam(in_file, out_file, read_type , strand):\n out_handle = open(out_file , 'a')\n if strand == 'watson':\n nt = ['C']\n else:\n nt = ['G']\n count = 0\n # print 'Warning, only works for forward mapped reads'\n mismatch = 0\n clip_count_total = 0\n for line in open(in... | [
"0.5934895",
"0.59241706",
"0.5840809",
"0.582142",
"0.5647263",
"0.5634226",
"0.56286997",
"0.56286997",
"0.56286997",
"0.56159234",
"0.5551919",
"0.55345964",
"0.5510557",
"0.5498402",
"0.54786116",
"0.5465325",
"0.54512054",
"0.5419072",
"0.5403033",
"0.5394056",
"0.536412... | 0.714962 | 0 |
checks to see if player's have both properly assigned their ships returns a bool if they are all the same length | def ready(self):
return len(self.player1.ships) == len(
self.player2.ships) == len(self.SHIP_INFO) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collision_check(self, board, row, column, orientation, ship_length):\n if orientation == 'H':\n for i in range(column, column + ship_length):\n if board[row][i] == SHIP:\n if self.user == 'player':\n print('\\nA SHIP IS ALREADY WITHIN T... | [
"0.71249855",
"0.7037971",
"0.6833168",
"0.66666186",
"0.66377825",
"0.65926397",
"0.65868586",
"0.657777",
"0.65634197",
"0.6475417",
"0.6472937",
"0.6469852",
"0.64128685",
"0.63272935",
"0.6292894",
"0.629135",
"0.62506694",
"0.62478065",
"0.6228461",
"0.62217534",
"0.6218... | 0.7337338 | 0 |
Function to assign NAICS codes to each dataframe activity | def assign_naics(df):
# assign sector source name
df['SectorSourceName'] = 'NAICS_2012_Code'
# coa equivalent to soybean farming: 11111
df.loc[df['Activity'] == 'SOYBEANS', 'Sector'] = '11111'
# coa aggregates to oilseed (except soybean) farming: 11112
df.loc[df['Activity'] == 'CANOLA', 'Sect... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_naics_map():\n # Read in list of industry topics.\n naics_codes = pd.read_excel(\n \"https://www.census.gov/eos/www/naics/2017NAICS/2-6%20digit_2017_Codes.xlsx\"\n )\n naics_codes = naics_codes.iloc[:, [1, 2]]\n naics_codes.columns = ['NAICSCode', 'Title']\n\n # Replace all ran... | [
"0.62657547",
"0.5777256",
"0.5766559",
"0.5695102",
"0.55280215",
"0.5374754",
"0.53336036",
"0.5316607",
"0.51982963",
"0.51940614",
"0.5129864",
"0.5121012",
"0.5087258",
"0.50848216",
"0.5082501",
"0.5035871",
"0.50266254",
"0.50045556",
"0.49961746",
"0.4968147",
"0.4965... | 0.680527 | 0 |
Returns the maximum element size representable in a given number of bytes. | def maximum_element_size_for_length(length):
return (2**(7*length)) - 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maxsize(self) -> int:\n return self._maxsize",
"def max_bytes(self) -> int:\n return self.width * self.height * 3",
"def maxsize(self):\r\n return self._maxsize",
"def maximum_size(self):\n return self._maximum_size",
"def max_size_bytes(self) -> Optional[float]:\n re... | [
"0.7550465",
"0.74025136",
"0.7332234",
"0.72707653",
"0.725339",
"0.7113349",
"0.6979818",
"0.69535756",
"0.6915955",
"0.6903534",
"0.6900205",
"0.6843633",
"0.683692",
"0.680336",
"0.67847925",
"0.6776855",
"0.67743033",
"0.67694736",
"0.6762796",
"0.6736242",
"0.67008376",... | 0.7842188 | 0 |
Reads an element ID from a filelike object. | def read_element_id(stream):
byte = ord(stream.read(1))
length, id_ = decode_vint_length(byte, False)
if length > 4:
raise IOError('Cannot decode element ID with length > 8.')
for i in xrange(0, length - 1):
byte = ord(stream.read(1))
id_ = (id_ * 2**8) + byte
return id_, length | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_id_from_file(path):\n\n with open(path) as id_file:\n return id_file.readline().strip()",
"def read_id_from_file(file):\n input = open(file, 'r')\n id = input.readline().strip()\n input.close()\n return id",
"def read(self, unique_id: str) -> str:\n with open_(self.source ... | [
"0.65801114",
"0.6545467",
"0.60709023",
"0.59532404",
"0.5805889",
"0.5792757",
"0.5731121",
"0.56899375",
"0.5678524",
"0.567053",
"0.56351477",
"0.56158924",
"0.55909675",
"0.55863947",
"0.5566814",
"0.5534864",
"0.55279255",
"0.5519386",
"0.55087686",
"0.5480547",
"0.5423... | 0.6691103 | 0 |
Reads an encoded signed integer value from a filelike object. | def read_signed_integer(stream, size):
value = 0
if size > 0:
first_byte = ord(stream.read(1))
value = first_byte
for i in xrange(1, size):
byte = ord(stream.read(1))
value = (value << 8) | byte
if (first_byte & 0b10000000) == 0b10000000:
value = -(2**(size*8) - value)
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_int(\n file: BinaryIO, endianness: Text = \"little\", signed: bool = True\n) -> int:\n data = file.read(n=sys.int_info.sizeof_digit)\n if not data:\n return None\n data = int.from_bytes(\n bytes=data, byteorder=endianness, signed=signed\n )\n return data",
"def readint(se... | [
"0.7411413",
"0.65649873",
"0.6499215",
"0.6499107",
"0.6391303",
"0.629808",
"0.61122745",
"0.6078385",
"0.60505146",
"0.6009621",
"0.5977738",
"0.5939649",
"0.5931516",
"0.58979434",
"0.58930606",
"0.5833177",
"0.5825247",
"0.578908",
"0.5777397",
"0.5770762",
"0.5745353",
... | 0.6939638 | 1 |
Reads an encoded date (and time) value from a filelike object. | def read_date(stream, size):
if size != 8:
raise IOError('Cannot read date values with lengths other than 8 bytes.')
data = stream.read(size)
nanoseconds = struct.unpack('>q', data)[0]
delta = datetime.timedelta(microseconds=(nanoseconds // 1000))
return datetime.datetime(2001, 1, 1, tzinfo=None) + delta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_read(date_string, *, convert_to_current_timezone: bool = False):\n return date_parse(date_string, convert_to_current_timezone=convert_to_current_timezone)",
"def extract_datetime(fpath):\n try:\n handle = open(fpath, 'rb')\n if hexlify(handle.read(2)) != hexlify(u'MZ'):\n ... | [
"0.6164642",
"0.61344737",
"0.6128683",
"0.60509974",
"0.59189224",
"0.58169645",
"0.5601924",
"0.5600066",
"0.55651736",
"0.5554819",
"0.55227613",
"0.53807944",
"0.5368459",
"0.53584975",
"0.5337453",
"0.53092223",
"0.5302614",
"0.5294248",
"0.5276244",
"0.52726966",
"0.526... | 0.62823355 | 0 |
Returns the bitmask for the first byte of a variablelength integer (used for element ID and size descriptors). | def vint_mask_for_length(length):
return 0b10000000 >> (length - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_bit(byte, ii):\n return (byte >> (7 - ii)) & 1",
"def canonicalizeInt(val):\n b = ByteArray(val)\n if len(b) == 0:\n b = ByteArray(0, length=1)\n if (b[0] & 0x80) != 0:\n b = ByteArray(0, length=len(b) + 1) | b\n return b",
"def bitfield(x, m):\n b = [1 if digit=='1' el... | [
"0.62082124",
"0.60682136",
"0.5937691",
"0.59195036",
"0.5906546",
"0.5867376",
"0.57760066",
"0.5773513",
"0.5771923",
"0.5730466",
"0.57286847",
"0.568844",
"0.56530154",
"0.5646461",
"0.5640586",
"0.5636843",
"0.56017965",
"0.56014925",
"0.5587604",
"0.5575569",
"0.557284... | 0.6737998 | 0 |
Encodes an element ID. | def encode_element_id(element_id):
length = MAXIMUM_ELEMENT_ID_LENGTH
while length and not (element_id & (vint_mask_for_length(length) << ((length - 1) * 8))):
length -= 1
if not length:
raise ValueError('Cannot encode invalid element ID %s.' % hex(element_id))
data = bytearray(length)
for index in reverse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pack_id(self, id_):\r\n return self._packer.pack(id_)",
"def to_id(id):\n return int(id.strip('<@&#!>')) if id.isdigit() else id.strip('<@&#!>')",
"def encode(id_number, alphabet=ALPHABET):\n if id_number == 0:\n return alphabet[0]\n\n alphabet_len = len(alphabet) # Cache\n\n resu... | [
"0.62542",
"0.6039877",
"0.6009433",
"0.59211427",
"0.57896245",
"0.5775442",
"0.5769035",
"0.57665056",
"0.57568634",
"0.575354",
"0.5737201",
"0.5701971",
"0.56917953",
"0.5672285",
"0.56670433",
"0.56328964",
"0.56212103",
"0.5612443",
"0.56114316",
"0.56114316",
"0.560703... | 0.76211905 | 0 |
Encodes an element size. If element_size is None, the size will be encoded as unknown. If length is not None, the size will be encoded in that many bytes; otherwise, the size will be encoded in the minimum number of bytes required, or in 8 bytes if the size is unknown (element_size is None). | def encode_element_size(element_size, length=None):
if length is not None and (length < 1 or length > MAXIMUM_ELEMENT_SIZE_LENGTH):
raise ValueError('Cannot encode element sizes into representations shorter than one byte long or longer than %i bytes long.' % MAXIMUM_ELEMENT_SIZE_LENGTH)
if element_size is not Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetElementSize(self, element_id, size):\r\n \r\n if element_id == AUI_TBART_SEPARATOR_SIZE:\r\n self._separator_size = size\r\n elif element_id == AUI_TBART_GRIPPER_SIZE:\r\n self._gripper_size = size\r\n elif element_id == AUI_TBART_OVERFLOW_SIZE:\r\n ... | [
"0.56427765",
"0.54864275",
"0.53210574",
"0.53199404",
"0.5276948",
"0.5246423",
"0.50896436",
"0.5073148",
"0.5051058",
"0.4987533",
"0.49866846",
"0.49718985",
"0.49568963",
"0.49457988",
"0.49426863",
"0.49251276",
"0.49173674",
"0.49100426",
"0.49059072",
"0.49059072",
"... | 0.81233203 | 0 |
Encodes an unsigned integer value. If length is not None, uint will be encoded in that many bytes; otherwise, uint will be encoded in the minimum number of bytes required. If uint is None or 0, the minimum number of bytes required is 0. | def encode_unsigned_integer(uint, length=None):
if uint is None:
uint = 0
if uint > ((2**((MAXIMUM_UNSIGNED_INTEGER_LENGTH if length is None else length) * 8)) - 1):
raise ValueError('Cannot encode unsigned integer value %i as it would have an encoded representation longer than %i bytes.' % (uint, (MAXIMUM_UNSI... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wUInt(self, value):\n self.w(struct.pack(self.endian + \"I\", value))",
"def _EncodeWithBytesLength(value: Any,\n bytes_len: int) -> bytes:\n if isinstance(value, str):\n value = int(value)\n\n max_val = (1 << (bytes_len * 8)) - 1\n if valu... | [
"0.6292111",
"0.6215636",
"0.6208055",
"0.6119022",
"0.602818",
"0.5937389",
"0.59157234",
"0.5832344",
"0.5765607",
"0.5750855",
"0.5619181",
"0.5619181",
"0.5488594",
"0.5488594",
"0.5481343",
"0.5440878",
"0.54195607",
"0.54000723",
"0.5393811",
"0.53793865",
"0.5347306",
... | 0.80095994 | 0 |
Encodes a signed integer value. If length is not None, sint will be encoded in that many bytes; otherwise, sint will be encoded in the minimum number of bytes required. If sint is None or 0, the minimum number of bytes required is 0. | def encode_signed_integer(sint, length=None):
if sint is None:
sint = 0
if not (-(2**(7+(8*((MAXIMUM_SIGNED_INTEGER_LENGTH if length is None else length)-1)))) <= sint <= (2**(7+(8*((MAXIMUM_SIGNED_INTEGER_LENGTH if length is None else length)-1))))-1):
raise ValueError('Cannot encode signed integer value %i as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_int(n):\n return struct.pack(\">I\", n)",
"def _SignedVarintEncoder():\n\n local_int2byte = struct.Struct('>B').pack\n\n def EncodeSignedVarint(write, value, unused_deterministic=None):\n if value < 0:\n value += (1 << 64)\n bits = value & 0x7f\n value >>= 7\n while value:\n ... | [
"0.6160891",
"0.61495453",
"0.6095626",
"0.6045101",
"0.6044109",
"0.5948104",
"0.5934116",
"0.5894467",
"0.5781891",
"0.5776574",
"0.5776574",
"0.5750566",
"0.572282",
"0.5718657",
"0.5670719",
"0.56644106",
"0.5617225",
"0.55705786",
"0.5550196",
"0.5541467",
"0.5530392",
... | 0.8030049 | 0 |
Encodes a floating point value. If length is not None, float_ will be encoded in that many bytes; otherwise, float_ will be encoded in 0 bytes if float_ is None or 0, and 8 bytes in all other cases. If float_ is not None or 0 and length is 0, ValueError will be raised. | def encode_float(float_, length=None):
if length not in (None, 0, 4, 8):
raise ValueError('Cannot encode floating point values with lengths other than 0, 4, or 8 bytes.')
if float_ is None:
float_ = 0.0
if float_ == 0.0:
if length is None:
length = 0
else:
if length is None:
length = 8
elif length... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _(_: FloatType, value: float) -> bytes:\n return _FLOAT_STRUCT.pack(value)",
"def _FloatingPointEncoder(wire_type, format):\n\n value_size = struct.calcsize(format)\n if value_size == 4:\n def EncodeNonFiniteOrRaise(write, value):\n # Remember that the serialized form uses little-endian byte ord... | [
"0.6710306",
"0.6560253",
"0.63308567",
"0.61957926",
"0.6169508",
"0.61655265",
"0.588011",
"0.58457315",
"0.57714254",
"0.5718342",
"0.5712409",
"0.5698937",
"0.5676826",
"0.5632183",
"0.5582555",
"0.55614686",
"0.5539769",
"0.53476864",
"0.5309657",
"0.5296124",
"0.5264630... | 0.8402409 | 0 |
Encodes an ASCII string value. If length is not None, string will be encoded in that many bytes by padding with zero bytes at the end if necessary; otherwise, string will be encoded in the minimum number of bytes required. If string is None or empty, the minimum number of bytes required is 0. | def encode_string(string, length=None):
if string is None:
string = ''
if length is None:
length = len(string)
else:
if length < len(string):
raise ValueError('Cannot encode ASCII string value \'%s\' as it would have an encoded representation longer than %i bytes.' % (string, length))
elif length > len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_unicode_string(string, length=None):\n\t\n\tif string is None:\n\t\tstring = u''\n\treturn encode_string(string.encode('utf_8'), length)",
"def _encode_str(self, string):\n result = self._encode_vint(len(string))\n result += string\n return result",
"def writeString(self, value:... | [
"0.7050221",
"0.6734654",
"0.6510249",
"0.6410837",
"0.6102716",
"0.6075612",
"0.605387",
"0.6032113",
"0.58995247",
"0.5884761",
"0.5870271",
"0.5863834",
"0.5819045",
"0.5758772",
"0.5666918",
"0.5663049",
"0.5657152",
"0.56518674",
"0.55831885",
"0.5579522",
"0.5543135",
... | 0.8222988 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.