query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
RuleWithOperations is a tuple of Operations and Resources. It is recommended to make sure that all the tuple expansions are valid. | def __init__(__self__, *,
api_groups: Optional[Sequence[str]] = None,
api_versions: Optional[Sequence[str]] = None,
operations: Optional[Sequence[str]] = None,
resources: Optional[Sequence[str]] = None,
scope: Optional[str] = None):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_rules(self) -> Optional[Sequence['outputs.NamedRuleWithOperationsPatch']]:\n return pulumi.get(self, \"resource_rules\")",
"def resource_rules(self) -> Optional[Sequence['outputs.NamedRuleWithOperations']]:\n return pulumi.get(self, \"resource_rules\")",
"def _compile_operation_rule(... | [
"0.58989966",
"0.5875806",
"0.56885695",
"0.5519066",
"0.5519066",
"0.54430383",
"0.54430383",
"0.52643144",
"0.5257297",
"0.51952976",
"0.50445753",
"0.50359285",
"0.5013755",
"0.49892578",
"0.49741092",
"0.494571",
"0.4943864",
"0.49407735",
"0.49303278",
"0.49281582",
"0.4... | 0.0 | -1 |
ObjectSelector decides whether to run the webhook based on if the object has matching labels. objectSelector is evaluated against both the oldObject and newObject that would be sent to the webhook, and is considered to match if either object matches the selector. A null object (oldObject in the case of create, or newOb... | def object_selector(self) -> Optional['_meta.v1.outputs.LabelSelector']:
return pulumi.get(self, "object_selector") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_selector(self) -> Optional['_meta.v1.outputs.LabelSelectorPatch']:\n return pulumi.get(self, \"object_selector\")",
"def object_selector(self) -> Optional['_meta.v1.outputs.LabelSelectorPatch']:\n return pulumi.get(self, \"object_selector\")",
"def object_selector(self) -> Optional['_m... | [
"0.6504774",
"0.6504774",
"0.6504774",
"0.46324268",
"0.46075478",
"0.45837897",
"0.45533273",
"0.45282823",
"0.44923168",
"0.4475264",
"0.44605938",
"0.4435445",
"0.44078732",
"0.43742326",
"0.4373357",
"0.43520212",
"0.4286432",
"0.42862844",
"0.42757705",
"0.42624018",
"0.... | 0.64562577 | 4 |
NamespaceSelector decides whether to run the webhook on an object based on whether the namespace for that object matches the selector. If the object itself is a namespace, the matching is performed on object.metadata.labels. If the object is another cluster scoped resource, it never skips the webhook. | def namespace_selector(self) -> Optional['_meta.v1.outputs.LabelSelectorPatch']:
return pulumi.get(self, "namespace_selector") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namespace_selector(self) -> Optional['_meta.v1.outputs.LabelSelector']:\n return pulumi.get(self, \"namespace_selector\")",
"def namespace_selector(self) -> Optional['_meta.v1.outputs.LabelSelector']:\n return pulumi.get(self, \"namespace_selector\")",
"def namespace_selector(self) -> Optiona... | [
"0.61505044",
"0.61505044",
"0.61505044",
"0.55928576",
"0.55928576",
"0.55928576",
"0.5499146",
"0.5499146",
"0.5499146",
"0.5199044",
"0.5176694",
"0.5031577",
"0.49377888",
"0.49080932",
"0.4837504",
"0.480669",
"0.48050517",
"0.47186306",
"0.46861464",
"0.46817052",
"0.46... | 0.6185619 | 1 |
ObjectSelector decides whether to run the webhook based on if the object has matching labels. objectSelector is evaluated against both the oldObject and newObject that would be sent to the webhook, and is considered to match if either object matches the selector. A null object (oldObject in the case of create, or newOb... | def object_selector(self) -> Optional['_meta.v1.outputs.LabelSelectorPatch']:
return pulumi.get(self, "object_selector") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_selector(self) -> Optional['_meta.v1.outputs.LabelSelector']:\n return pulumi.get(self, \"object_selector\")",
"def object_selector(self) -> Optional['_meta.v1.outputs.LabelSelector']:\n return pulumi.get(self, \"object_selector\")",
"def object_selector(self) -> Optional['_meta.v1.out... | [
"0.64562577",
"0.64562577",
"0.64562577",
"0.46324268",
"0.46075478",
"0.45837897",
"0.45533273",
"0.45282823",
"0.44923168",
"0.4475264",
"0.44605938",
"0.4435445",
"0.44078732",
"0.43742326",
"0.4373357",
"0.43520212",
"0.4286432",
"0.42862844",
"0.42757705",
"0.42624018",
... | 0.6504774 | 1 |
Compute a stoplist of `n` tokens. | def create_stoplist(self, n, feature, language, basis='corpus'):
pipeline = [
{'$match': {'feature': feature, 'language': language}},
]
if basis == 'corpus':
pipeline.append(
{'$project': {
'_id': False,
'index': Tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_grams(tokens, n):\n return zip(*[tokens[i:] for i in range(n)])",
"def n_split(text1: Iterable, n: int) -> list:\n\n return [text1[k:k + n] for k in range(0, len(text1), n)]",
"def split_into_n(s, n):\n return [s[k:k + n] for k in range(0, len(s), n)]",
"def split_list_into_sublists_of_siz... | [
"0.63319945",
"0.62540734",
"0.6011296",
"0.5965497",
"0.5937081",
"0.5926734",
"0.5925072",
"0.588251",
"0.58429164",
"0.5829372",
"0.5798192",
"0.5786993",
"0.5729767",
"0.5718834",
"0.5663768",
"0.5632978",
"0.5607424",
"0.56007063",
"0.5591931",
"0.5591931",
"0.5585464",
... | 0.64984894 | 0 |
Calculates the distance between two positions | def _get_trivial_distance(positions):
diff = np.abs(positions[0] - positions[1])
if diff:
return diff + 1
else:
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(pos1, pos2):\n return math.sqrt((pos1[0] - pos2[0])**2. + (pos1[1] - pos2[1])**2.)",
"def dist(pos1, pos2):\n a, b = pos1\n c, d = pos2\n \n return sqrt((a-c)**2 + (b-d)**2)",
"def getDistance(pos1, pos2):\r\n return ((pos1[0] - pos2[0]) ** 2 + (pos1[1] - pos2[1]) ** 2) ** 0.5",
... | [
"0.8428521",
"0.8326586",
"0.83080405",
"0.808734",
"0.77856445",
"0.77551603",
"0.7743387",
"0.76857173",
"0.7677639",
"0.76744515",
"0.760708",
"0.76041555",
"0.75843275",
"0.75741565",
"0.75730973",
"0.7563276",
"0.7540361",
"0.7528646",
"0.75231034",
"0.75201976",
"0.7515... | 0.0 | -1 |
A POST with invalid JSON is an error. | def test_error_no_json(self, app, data_queues, metricsmock):
res = self._call(app, "\xae", method="post", status=400)
detail = "JSONDecodeError('Expecting value: line 1 column 1 (char 0)')"
self.check_response(data_queues, res, "parse_error", details={"decode": detail})
metricsmock.asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_JSON_returns_error(self):\n\n response = self.client.post(\n reverse('transcript:record_telegram'),\n content_type='application/json',\n data='''{\"something\":''')\n\n self.assertEqual(response.status_code, 400)\n self.assertEqual(response.con... | [
"0.78569204",
"0.7748738",
"0.77473855",
"0.76111704",
"0.7580805",
"0.75174755",
"0.7184666",
"0.71757674",
"0.71383077",
"0.7041253",
"0.70384777",
"0.6982874",
"0.6972615",
"0.69343084",
"0.69057626",
"0.68960035",
"0.68927073",
"0.68500185",
"0.6842608",
"0.68354905",
"0.... | 0.6766023 | 23 |
Omitting the API key is a 400 error. | def test_no_api_key(self, app, data_queues, redis, metricsmock, logs):
res = self._call(app, api_key=None, ip=self.test_ip, status=400)
self.check_response(data_queues, res, "invalid_key")
metricsmock.assert_incr_once(
self.metric_type + ".request", tags=[self.metric_path, "key:none"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_api_key(x_api_key: str = Security(api_key_header_auth)):\n\n if x_api_key != API_KEY:\n raise HTTPException(\n status_code=status.HTTP_401_UNAUTHORIZED,\n detail=\"Invalid API Key\",\n )",
"def test_incorrect_api_key(self):\n with self.subTest(\"Missing API... | [
"0.7391124",
"0.70752287",
"0.67565364",
"0.67308754",
"0.6723097",
"0.6587633",
"0.6580283",
"0.651728",
"0.64918995",
"0.64464116",
"0.64196974",
"0.63978416",
"0.6352706",
"0.63420165",
"0.63235754",
"0.63078076",
"0.629226",
"0.6279587",
"0.6222863",
"0.6219825",
"0.62156... | 0.6108584 | 28 |
An invalid API key is sanitized to the same as no key. | def test_invalid_api_key(self, app, data_queues, redis, metricsmock, logs):
res = self._call(app, api_key="invalid_key", ip=self.test_ip, status=400)
self.check_response(data_queues, res, "invalid_key")
metricsmock.assert_incr_once(
self.metric_type + ".request", tags=[self.metric_pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_api_key(x_api_key: str = Security(api_key_header_auth)):\n\n if x_api_key != API_KEY:\n raise HTTPException(\n status_code=status.HTTP_401_UNAUTHORIZED,\n detail=\"Invalid API Key\",\n )",
"def a_valid_api_key(configuration):\n configuration.api_key[\"apiKeyAut... | [
"0.7216783",
"0.6859832",
"0.67122006",
"0.6638784",
"0.66364956",
"0.66364956",
"0.6544489",
"0.6487009",
"0.6426013",
"0.6385455",
"0.63412976",
"0.6334017",
"0.6317279",
"0.6300673",
"0.62709343",
"0.6262382",
"0.62359405",
"0.62293065",
"0.6160595",
"0.6146745",
"0.614294... | 0.620479 | 18 |
r""" Attempt to parse ``text``. If it parses cleanly to a single string literal, return its value. Otherwise return ``None``. >>> _test_parse_string_literal(r'"foo\n" r"\nbar"', None) 'foo\n\\nbar' | def _test_parse_string_literal(text, flags):
text = FileText(text)
if PY2:
try:
text.joined.encode('ascii')
except UnicodeError:
text = FileText(u'# encoding: utf-8\n' + unicode(text), filename=text.filename)
try:
module_node = _parse_ast_nodes(text, flags, F... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_string(cstr):\n ret = ''\n if _RUNNING_PYTHON3 and ULog._disable_str_exceptions:\n ret = _parse_string(cstr, 'ignore')\n else:\n ret = _parse_string(cstr)\n return ret",
"def parseStr(s):\n\n return _parseHelper(s.split(\"\\n\"))",
"def parse_text(... | [
"0.5842667",
"0.5618485",
"0.56167006",
"0.5583283",
"0.5542042",
"0.54999197",
"0.5475283",
"0.543814",
"0.541331",
"0.5266765",
"0.5242462",
"0.5216988",
"0.5193203",
"0.51850575",
"0.5164346",
"0.5150462",
"0.5112822",
"0.5095806",
"0.50734085",
"0.50076634",
"0.49420857",... | 0.7277454 | 0 |
Create new r singlequbit gate. | def __init__(
self, theta: ParameterValueType, phi: ParameterValueType, label: Optional[str] = None
):
super().__init__("r", 1, [theta, phi], label=label) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _template_circuit(self, amp_param) -> QuantumCircuit:\n gate = Gate(name=self.__rabi_gate_name__, num_qubits=1, params=[amp_param])\n\n circuit = QuantumCircuit(1)\n circuit.append(gate, (0,))\n circuit.measure_active()\n\n return circuit",
"def _template_circuit(self, amp_... | [
"0.62880856",
"0.6281091",
"0.6211601",
"0.6173668",
"0.6084045",
"0.60125744",
"0.597463",
"0.5939833",
"0.5913786",
"0.590543",
"0.58104956",
"0.58021367",
"0.5794017",
"0.5630649",
"0.5561157",
"0.55341953",
"0.5529456",
"0.5522379",
"0.55172116",
"0.54558975",
"0.545555",... | 0.0 | -1 |
Return a numpy.array for the R gate. | def __array__(self, dtype=None):
theta, phi = float(self.params[0]), float(self.params[1])
cos = math.cos(theta / 2)
sin = math.sin(theta / 2)
exp_m = exp(-1j * phi)
exp_p = exp(1j * phi)
return numpy.array([[cos, -1j * exp_m * sin], [-1j * exp_p * sin, cos]], dtype=dtype... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_R(angles):\n cs, ss = np.cos(angles), np.sin(angles)\n zeros, ones = np.zeros(len(cs)), np.ones(len(cs))\n Rs = np.array(\n [[cs, ss, zeros], [-ss, cs, zeros], [zeros, zeros, ones]], dtype=np.float32\n ) # (3, 3, N)\n\n return Rs.transpose((2, 0, 1))",
"def get_array(self):\n ... | [
"0.64161867",
"0.6314216",
"0.62355024",
"0.61247754",
"0.61197245",
"0.6112341",
"0.6110332",
"0.6077362",
"0.60369945",
"0.5988638",
"0.5966489",
"0.59268564",
"0.5926733",
"0.5922453",
"0.5886348",
"0.5868226",
"0.583655",
"0.58294815",
"0.58294815",
"0.58283305",
"0.58252... | 0.0 | -1 |
Return the configuration data of the user. | def config_data(self):
if self._key not in self._user_keys():
raise CouldNotFindUserException(self._key, self._user_keys())
return next(data for data in self.CONFIG_DATA if data.key == self._key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_config(self):\n\n return self.__user_config",
"def get_user_data(self):\n return self.user_data",
"def get_user_data(self):\n return self.user_data",
"def get(self):\n config = self.user_file.parseString(self.content)\n return config",
"def user_data(self):\n ... | [
"0.82107943",
"0.74919313",
"0.74919313",
"0.74144644",
"0.7058112",
"0.701797",
"0.7009727",
"0.69936085",
"0.6965996",
"0.6965826",
"0.68877935",
"0.68784714",
"0.68647695",
"0.68565",
"0.68558943",
"0.68555415",
"0.68514436",
"0.68341523",
"0.6821567",
"0.6804861",
"0.6784... | 0.78220844 | 1 |
Return the media path. | def __str__(self):
return self.video_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def media_path(self):\n return self._path",
"def path_media(self) -> Path:\n return self.path_supervisor / MEDIA_DATA",
"def get_media_directory():\n\treturn _paths[_MEDIA_DIRECTORY_KEY]",
"def get_media_path(self, filename):\n return join(settings.CMS_PAGE_MEDIA_PATH, \"%d\" % self.id, ... | [
"0.9062577",
"0.8385267",
"0.82831967",
"0.80998045",
"0.7792922",
"0.75078267",
"0.7481333",
"0.7335179",
"0.72402334",
"0.72402334",
"0.72179145",
"0.717697",
"0.69695556",
"0.6942414",
"0.6928708",
"0.6922968",
"0.6892658",
"0.6884245",
"0.6854536",
"0.6847473",
"0.684152"... | 0.0 | -1 |
It creates a onehot vector with a 1.0 in position represented by index | def onehot(index):
classNum=2#1
onehot = np.zeros(classNum)#这代表种类类型
onehot[index] = 1.0
return onehot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot(index):\n\toutput = np.zeros(100)\n\toutput[index] = 1\n\treturn output",
"def oneHot(index, n):\n x = np.zeros(n)\n x[index] = 1\n return x",
"def one_hot(index, dims, dtype=np.uint8):\n\n seq_len = len(index)\n ret = np.zeros((seq_len, dims), dtype)\n for i in range(seq_len):\n ... | [
"0.9184559",
"0.8825344",
"0.85994714",
"0.84946597",
"0.83207494",
"0.81589353",
"0.8152737",
"0.8073309",
"0.8060789",
"0.80439085",
"0.7853966",
"0.7841132",
"0.7782498",
"0.7770441",
"0.77196914",
"0.77196914",
"0.77196914",
"0.77196914",
"0.7674075",
"0.7671743",
"0.7647... | 0.90727466 | 1 |
Remove m from untried_moves and add a new child node for this move. Return the added child node. | def add_child(self, m, s):
n = Node(move=m, parent=self, state=s)
self.untried_moves.remove(m)
self.child_nodes.append(n)
return n | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AddChild(self, m, s):\n n = Node(move=m, parent=self, state=s)\n self.untriedMoves.remove(m)\n self.childNodes.append(n)\n return n",
"def AddChild(self, m, s):\n n = Node(move=m, parent=self, state=s)\n self.untriedMoves.remove(m)\n self.childNodes.append(n)\... | [
"0.7896557",
"0.7896557",
"0.7248093",
"0.7072638",
"0.7017592",
"0.68352014",
"0.68026847",
"0.6385622",
"0.60786456",
"0.59329075",
"0.56287676",
"0.5617678",
"0.55258834",
"0.54593515",
"0.54224527",
"0.5306626",
"0.5270355",
"0.5252668",
"0.52102196",
"0.52102196",
"0.521... | 0.8113934 | 0 |
Compute the next indent. | def indent(self):
print (self.indent_size*self.n_indent*' ',end='',flush=True, file=self.fp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_indent(op):\n ret = \"\"\n for ii in range(op):\n # Would tab be better?\n ret += \" \"\n return ret",
"def indent(self, increment=1):\n # increase the indentation level\n self._level += increment\n # and adjust the margin filler\n self.leader = self._indenter * self... | [
"0.6588084",
"0.65101653",
"0.6506656",
"0.6427669",
"0.6427669",
"0.62648153",
"0.6157851",
"0.610626",
"0.60889804",
"0.6059578",
"0.6030092",
"0.60117376",
"0.5932191",
"0.59064144",
"0.59027904",
"0.5884138",
"0.5876161",
"0.58736193",
"0.5845099",
"0.58375573",
"0.577470... | 0.58159393 | 20 |
Open a new indent bracket for the log. | def open(self,msg):
self.unhang()
self.indent()
print(msg,end='',flush=True, file=self.fp)
self.hanging=True
self.n_indent+=1
self.t_last=time.time() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enter(self):\n self.indent += 1",
"def indent(self):\n return self.__class__(self.stream, self.style, self.dialect,\n self.indentation_level + 1)",
"def _increaseindentation(self):\n self._indentlist.append(self._curindent)\n if not self._equalsigns[... | [
"0.63720626",
"0.63553363",
"0.63300574",
"0.63167554",
"0.6173447",
"0.6121826",
"0.6119627",
"0.60854554",
"0.60854554",
"0.60370636",
"0.58527756",
"0.5806137",
"0.57808965",
"0.577337",
"0.57444227",
"0.57136214",
"0.5688544",
"0.56771344",
"0.5639523",
"0.5636844",
"0.55... | 0.51618654 | 49 |
export json file to Hard Disk | def export(self, path):
with open(path, 'w', encoding='utf-8') as f:
json.dump(self.data, f, ensure_ascii=False)
self.path = path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_json(path):\n export_db(path)",
"def save_to_file(data):\n\ttry:\n\t\toutput_file = open(\"output.json\", \"w\")\n\t\toutput_file.write(json.dumps(data))\n\texcept:\n\t print(Fore.GREEN + \"File not found or path is incorrect\")\n\tfinally:\n\t print(Fore.GREEN + \"Success go to output.jso... | [
"0.73209536",
"0.7157034",
"0.70314497",
"0.692613",
"0.692171",
"0.684962",
"0.6836541",
"0.6827527",
"0.682569",
"0.6811672",
"0.6795095",
"0.6785412",
"0.67660373",
"0.67634755",
"0.675192",
"0.6746764",
"0.6699262",
"0.66979474",
"0.6677845",
"0.6677845",
"0.667456",
"0... | 0.7359675 | 0 |
Apply BatchNorm, Relu, 3x3 Conv2D, optional bottleneck block and dropout. | def __conv_block(ip, nb_filter, bottleneck=False,
dropout_rate=None, weight_decay=1e-4):
concat_axis = 1 if K.image_data_format() == 'channels_first' else -1
x = BatchNormalization(axis=concat_axis, epsilon=1.1e-5, fused=fuse)(ip)
x = Activation('relu')(x)
if bottl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __conv_block(self, x, stage, branch, nb_filter, dropout_rate=None, weight_decay=1e-4):\n\t\teps = 1.1e-5\n\t\tconv_name_base = \"conv\" + str(stage) + \"_\" + str(branch)\n\t\trelu_name_base = \"relu\" + str(stage) + \"_\" + str(branch)\n\n\t\t# 1x1 Convolution (Bottleneck layer)\n\t\tinter_channel = nb_filter... | [
"0.6870552",
"0.6617072",
"0.65638894",
"0.64518076",
"0.6448735",
"0.6413475",
"0.6398698",
"0.6394284",
"0.6388518",
"0.63775635",
"0.6374446",
"0.63673294",
"0.6365973",
"0.6362543",
"0.6341161",
"0.63305867",
"0.62932247",
"0.6292031",
"0.6282075",
"0.6273056",
"0.6268018... | 0.70604265 | 0 |
Build a dense_block where the output of each conv_block is fed to subsequent ones. | def __dense_block(x, nb_layers, nb_filter, growth_rate, bottleneck=False,
dropout_rate=None, weight_decay=1e-4,
grow_nb_filters=True, return_concat_list=False):
concat_axis = 1 if K.image_data_format() == 'channels_first' else -1
x_list = [x]
for i i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dense_block(x):\n h1 = _conv_block(x, 32)\n h1 = tf.keras.layers.Concatenate()([x, h1])\n\n h2 = _conv_block(h1, 32)\n h2 = tf.keras.layers.Concatenate()([x, h1, h2])\n\n h3 = _conv_block(h2, 32)\n h3 = tf.keras.layers.Concatenate()([x, h1, h2, h3])\n\n h4 = _conv_block(h3, 32)\n h4 = tf.keras.layers.C... | [
"0.7320509",
"0.73200613",
"0.72024345",
"0.697243",
"0.6824698",
"0.67776823",
"0.6731264",
"0.6731264",
"0.6715076",
"0.67008",
"0.66734636",
"0.6647114",
"0.66404796",
"0.65914774",
"0.658613",
"0.64910203",
"0.6485165",
"0.64833343",
"0.6462071",
"0.6458514",
"0.64405066"... | 0.6310679 | 28 |
Apply BatchNorm, Relu 1x1, Conv2D, optional compression, dropout and Maxpooling2D. | def __transition_block(ip, nb_filter, compression=1.0, weight_decay=1e-4):
concat_axis = 1 if K.image_data_format() == 'channels_first' else -1
x = BatchNormalization(axis=concat_axis, epsilon=1.1e-5, fused=fuse)(ip)
x = Activation('relu')(x)
x = Conv2D(int(nb_filter * compression), (1,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv_bn(in_channels, \n out_channels, \n kernel_size, \n stride, \n padding, \n norm_layer,\n track_running_stats,\n affine, \n domain_specific=False):\n \n if domain_specific:\n # use 2 domains and default set... | [
"0.66982466",
"0.65911496",
"0.63842136",
"0.63681895",
"0.63061404",
"0.6221652",
"0.62119734",
"0.6202046",
"0.61898035",
"0.6180233",
"0.61398166",
"0.61282593",
"0.607547",
"0.60572475",
"0.60393584",
"0.60241413",
"0.60209775",
"0.59956324",
"0.59935766",
"0.59911615",
"... | 0.0 | -1 |
Return the class of the device. | def device_class(self):
return self._device_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return self.sensor_type[\"class\"]",
"def device_class(self):\n return self.type",
"def device_class(self):\n return self.type",
"def device_class(self):\n return self.type",
"def device_class(self):\r\n return self._device_class",
"def get_cla... | [
"0.9065848",
"0.90097666",
"0.90097666",
"0.90097666",
"0.8984305",
"0.8983965",
"0.8975813",
"0.8975813",
"0.8975813",
"0.8975813",
"0.8975813",
"0.8939265",
"0.8904466",
"0.88507956",
"0.8705679",
"0.870415",
"0.870415",
"0.8660871",
"0.8659881",
"0.85736346",
"0.85736346",... | 0.8966391 | 11 |
Get the state of this virus particle's resistance to a drug. This method is called by getResistPop() in Patient to determine how | def isResistantTo(self, drug):
# TODO
try:return self.resistances[drug]
except:return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getResistence(self):\n return self.resistence",
"def getResistPop(self, drugResist):\n\n # Variable to hold the number of resistant viruses\n virus_pop = 0\n\n # Checks each virus in viruses of a patient\n for virus in self.viruses:\n drugsResisted = 0\n ... | [
"0.6702044",
"0.6339946",
"0.62971777",
"0.61240363",
"0.61240363",
"0.59820527",
"0.56072134",
"0.5542137",
"0.5485364",
"0.54819393",
"0.5475738",
"0.54744315",
"0.54487824",
"0.54269034",
"0.5425222",
"0.5423521",
"0.54153854",
"0.541362",
"0.54010385",
"0.53608316",
"0.53... | 0.54758745 | 10 |
Returns a 2D image kernel for motion blur effect. | def motion_blur_kernel(kernel_size, angle):
if kernel_size % 2 == 0:
raise ValueError('kernel_size must be an odd number!')
if angle < 0 or angle > np.pi:
raise ValueError('angle must be between 0 (including) and pi (not including)')
norm_angle = 2.0 * angle / np.pi
if norm_angle >... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RandomMotionBlur(img, kernel):\r\n kernel_motion_blur = CreateMotionKernel(kernel)\r\n dst = cv2.filter2D(img, -1, kernel_motion_blur)\r\n return dst",
"def filter2D(img, kernel = (5,5)):\n\ttmp = img.copy()\n\tk = np.ones((kernel[0], kernel[1]), np.float32) / (kernel[0]*kernel[1])\n\tdst = cv2.filt... | [
"0.7283915",
"0.7140816",
"0.7023423",
"0.70101225",
"0.70101225",
"0.6991672",
"0.6846618",
"0.66945076",
"0.6636728",
"0.66259897",
"0.6605494",
"0.6526139",
"0.65212506",
"0.64418656",
"0.64344084",
"0.6368762",
"0.63521224",
"0.6334014",
"0.6283472",
"0.62730896",
"0.6266... | 0.64234024 | 15 |
create a symbolic output tensor according to the input and num_channels. | def resblock(input_tensor, num_channels):
step_1_conv = Conv2D(num_channels, (3, 3), padding='same')(input_tensor)
step_2_relu = Activation('relu')(step_1_conv)
step_3_conv = Conv2D(num_channels, (3, 3), padding='same')(step_2_relu)
output = Add()([input_tensor, step_3_conv])
return Activation(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_out(self, in_channels):\n raise NotImplementedError",
"def output(x_tensor, num_outputs, name=\"output\"):\n with tf.name_scope(name):\n return tf.layers.dense(x_tensor, num_outputs)",
"def get_hot_enc(input, channels=3):\n if len(input.shape)==2:\n input = input.unsqueez... | [
"0.6197386",
"0.5951119",
"0.58993644",
"0.58042645",
"0.5790721",
"0.5775568",
"0.5763804",
"0.57286006",
"0.5711782",
"0.566964",
"0.5665339",
"0.56541854",
"0.5632984",
"0.56196564",
"0.56024987",
"0.55770755",
"0.55770755",
"0.55770755",
"0.55740595",
"0.55542624",
"0.551... | 0.5540199 | 20 |
Settings for ecommerce tests | def ecommerce_settings(settings):
settings.CYBERSOURCE_SECURITY_KEY = CYBERSOURCE_SECURITY_KEY
settings.CYBERSOURCE_SECURE_ACCEPTANCE_URL = CYBERSOURCE_SECURE_ACCEPTANCE_URL
settings.CYBERSOURCE_REFERENCE_PREFIX = CYBERSOURCE_REFERENCE_PREFIX
settings.ECOMMERCE_EMAIL = "ecommerce@example.com" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self) -> None:\n self.default = Product('Test Product')\n self.tester = Product('Tester', price=15, weight=2)",
"def test_act_on_settings(self):\n pass # TODO(tlarsen)",
"def test_act_on_settings(self):\n pass # TODO(tlarsen)",
"def setup_prod():\n setup_general()",... | [
"0.6596972",
"0.6387029",
"0.6387029",
"0.6294741",
"0.62926245",
"0.6178814",
"0.61680466",
"0.6162457",
"0.61512816",
"0.61200273",
"0.6050988",
"0.603545",
"0.60093886",
"0.599446",
"0.59902996",
"0.59851176",
"0.59034777",
"0.5898435",
"0.5878348",
"0.5877592",
"0.5866852... | 0.7348304 | 0 |
If CyberSource POSTs with fields missing, we should at least save it in a receipt. It is very unlikely for Cybersource to POST invalid data but it also provides a way to test that we save a Receipt in the event of an error. | def test_missing_fields(client, mocker):
data = {}
for _ in range(5):
data[FAKE.text()] = FAKE.text()
mocker.patch(
"ecommerce.views.IsSignedByCyberSource.has_permission", return_value=True
)
try:
# Missing fields from Cybersource POST will cause the KeyError.
# In th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_POST_receipt(self):\n\t\t# list should have no receipts at first\n\t\tself.POST_list()\n\t\tlist_data = self.GET_data('/api/list/' + self.list_id)\n\t\tself.assertTrue(('receipts' not in list_data) or not len(list_data['receipts']))\n\n\t\t# after post receipt and its _id should be in list.receipts\n\t\ts... | [
"0.6355556",
"0.6241451",
"0.6235465",
"0.60819006",
"0.6039528",
"0.6026913",
"0.60134166",
"0.5994399",
"0.5970237",
"0.59693354",
"0.59605694",
"0.59394586",
"0.59214956",
"0.59057224",
"0.5885579",
"0.5864299",
"0.58319306",
"0.58186555",
"0.5802582",
"0.57921714",
"0.574... | 0.72392446 | 0 |
Test if a request is made for a not existing bootcamp run | def test_bootcamp_run_detail_fake_run(test_data, client):
user, _, _ = test_data
bootcamp_run_detail_url = reverse(
"bootcamp-run-detail",
kwargs={"username": user.username, "run_key": 123_456_789},
)
client.force_login(user)
assert (
client.get(bootcamp_run_detail_url).statu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _running_locally(coreapi_url, jobs_api_url):\n return not (coreapi_url and jobs_api_url)",
"def available(self):\n existing_url = self.context.get_personal_fundraising_campaign_url()\n same = existing_url == self.context.absolute_url()\n creating = 'create-personal-campaign-page' in s... | [
"0.61426",
"0.58326644",
"0.5812619",
"0.578944",
"0.5771344",
"0.5764883",
"0.57473797",
"0.57418466",
"0.57273436",
"0.5710144",
"0.5705302",
"0.56915516",
"0.56696975",
"0.56621456",
"0.5659947",
"0.5647635",
"0.5645536",
"0.5633153",
"0.5612597",
"0.5603417",
"0.55997324"... | 0.5677895 | 12 |
Get a user by id or slug | def get_user(self, user_id):
uri = 'users/' + user_id
return self.make_request(uri) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(id):\n pass",
"def get_user_by_slug(self, slug):\n users = self.get_users({ 'profile_url': slug })\n if len(users) > 0:\n return users[0]",
"def get(id):\n return User.query.filter_by(id=id).first()",
"def get_by_id(user_id: int) -> Optional[User]:\n user = ... | [
"0.8035785",
"0.7991731",
"0.77811617",
"0.76520264",
"0.7636256",
"0.76316124",
"0.7606467",
"0.7601722",
"0.75807446",
"0.75596803",
"0.75213355",
"0.7516144",
"0.7511616",
"0.7511616",
"0.7511616",
"0.7511616",
"0.7508023",
"0.74741817",
"0.74545884",
"0.74407727",
"0.7438... | 0.7279362 | 29 |
Read textfile line by line Reads textfile with splitlines attribute. Returns a list with the contents of the textfile, every row contains one entry. | def read_txt_by_lines(path):
with open(path, "r") as f:
buffer = f.read().splitlines()
f.close()
return buffer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lineReadfile(filename):\n#\t\"input:filename output=readlines() \"\n\tf = open(filename)\n\tlist1 =[]\n\twhile 1:\n\t\ts = f.readline()\n\t\tif s==\"\":\n\t\t\tbreak\n\t\ts=string.replace(s,\"\\n\",\"\")\n\t\tif s==\"\":\n\t\t\tcontinue\n\t\tlist1.append(s)\n\tf.close()\n\treturn list1",
"def read_file_in_li... | [
"0.7453147",
"0.7359046",
"0.73428",
"0.728118",
"0.7247222",
"0.7196997",
"0.71782666",
"0.7177947",
"0.7116076",
"0.7109894",
"0.7107066",
"0.71024007",
"0.7051611",
"0.7045261",
"0.6933051",
"0.69276714",
"0.689581",
"0.6882676",
"0.68765837",
"0.6848725",
"0.68406165",
... | 0.7096376 | 12 |
Calculate yaw from quaternion | def quat_to_yaw_deg(qx,qy,qz,qw):
degree = pi/180
sqy = qy*qy
sqz = qz*qz
siny = 2 * (qw*qz+qx*qy)
cosy = 1 - 2*(qy*qy+qz*qz)
yaw = int(atan2(siny,cosy)/degree)
return yaw | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yaw_pitch_roll(self):\n\n self._normalise()\n yaw = np.arctan2(2*(self.q[0]*self.q[3] - self.q[1]*self.q[2]),\n 1 - 2*(self.q[2]**2 + self.q[3]**2))\n pitch = np.arcsin(2*(self.q[0]*self.q[2] + self.q[3]*self.q[1]))\n roll = np.arctan2(2*(self.q[0]*self.q[1] - self.q[2]*s... | [
"0.783125",
"0.7745037",
"0.7661946",
"0.75522274",
"0.74395573",
"0.7401408",
"0.7311998",
"0.73104393",
"0.72531104",
"0.7094526",
"0.6944425",
"0.69329786",
"0.69141245",
"0.6913764",
"0.68724704",
"0.68664414",
"0.68565625",
"0.68238753",
"0.6806968",
"0.6756935",
"0.6734... | 0.784347 | 0 |
Get the front element. | def peek(self):
if len(self.popStack) != 0:
# popStack中有元素
return self.popStack[-1]
if len(self.pushStack) == 0:
# 两个栈都没有元素了
return
while self.pushStack != []:
# popStack中没有元素而pushStack中有元素时
temp = self.pushStack.pop(-1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFront(self):\n\t\tfront = self.queue[self.front]\n\t\treturn front\n\t\tpass",
"def getFront(self):\n if not self.isEmpty():\n return self._data[0]\n else:\n return -1",
"def front(self):\n return self.queue[0] if not self.empty() else None",
"def peek_front(... | [
"0.82009244",
"0.79261875",
"0.7852642",
"0.7791182",
"0.77886623",
"0.75723046",
"0.752337",
"0.7510604",
"0.7478953",
"0.7379256",
"0.7379256",
"0.734284",
"0.7323573",
"0.7320296",
"0.7291721",
"0.72772557",
"0.7269801",
"0.72657627",
"0.7253295",
"0.72355044",
"0.72213495... | 0.0 | -1 |
Returns whether the queue is empty. | def empty(self):
if len(self.pushStack) == len(self.popStack) == 0:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return len(self.the_queue) == 0",
"def is_empty(self):\n return len(self.__queue) > 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return self.queue == []",
"def ... | [
"0.9270249",
"0.92506766",
"0.923635",
"0.923635",
"0.9155843",
"0.9098441",
"0.9095006",
"0.90922606",
"0.90731245",
"0.9053733",
"0.89205354",
"0.89137155",
"0.8877591",
"0.88436323",
"0.88436323",
"0.8835949",
"0.88038146",
"0.8758203",
"0.87577534",
"0.87310195",
"0.86462... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Taskrouter.V1.WorkflowInstance {}>".format(context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Taskrouter.V1.WorkflowContext {}>".format(context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
return "<Twilio.Taskrouter.V1.WorkflowPage>" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
return "<Twilio.Taskrouter.V1.WorkflowList>" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Given a cloud id as stored in `self.cloud_ids`, return the path (relative to `self.raw_dir`) of the corresponding raw cloud. | def id_to_relative_raw_path(self, id):
return osp.join(self.id_to_base_id(id) + '.ply') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def processed_to_raw_path(self, processed_path):\n # Extract useful information from <path>\n stage, hash_dir, cloud_id = \\\n osp.splitext(processed_path)[0].split('/')[-3:]\n\n # Remove the tiling in the cloud_id, if any\n base_cloud_id = self.id_to_base_id(cloud_id)\n\n ... | [
"0.6120425",
"0.5900228",
"0.5594266",
"0.55325145",
"0.55314106",
"0.5480562",
"0.5472034",
"0.53768766",
"0.53605086",
"0.52571714",
"0.5213335",
"0.51456136",
"0.504145",
"0.50242543",
"0.50029874",
"0.49535552",
"0.49527803",
"0.49491975",
"0.49378446",
"0.49378446",
"0.4... | 0.61298406 | 0 |
Return whether MNPuzzle self is equivalent to other. | def __eq__(self, other):
return (type(self) == type(other) and
self.from_grid == other.from_grid and
self.to_grid == other.to_grid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n for i in range(len(self.puzzle)):\n for j in range(len(self.puzzle[0])):\n if(self.puzzle[i][j] != other.puzzle[i][j]):\n return False\n return True",
"def equals(self, other: InputTransform) -> bool:\n return super().eq... | [
"0.7884084",
"0.7809546",
"0.7805344",
"0.7694956",
"0.75914407",
"0.7474761",
"0.7468896",
"0.74044824",
"0.7375316",
"0.73414105",
"0.73191506",
"0.73190105",
"0.7264524",
"0.7263841",
"0.7250105",
"0.7250105",
"0.7229176",
"0.72085124",
"0.71788704",
"0.7175089",
"0.717454... | 0.70519614 | 33 |
Return a userfriendly string representation of MNPuzzle self. | def __str__(self):
final_string = 'From:'
for row in self.from_grid:
final_string += '\n' + ' '.join(row)
final_string += '\nTo:'
for row in self.to_grid:
final_string += '\n' + ' '.join(row)
return final_string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n puzzle_string = '—' * 13 + '\\n'\n for i in range(self.PUZZLE_NUM_ROWS):\n for j in range(self.PUZZLE_NUM_COLUMNS):\n puzzle_string += '│{0: >2}'.format(str(self.position[i][j]))\n if j == self.PUZZLE_NUM_COLUMNS - 1:\n ... | [
"0.7900187",
"0.7732959",
"0.7619398",
"0.7501598",
"0.7330119",
"0.72773033",
"0.71929115",
"0.7189792",
"0.7189489",
"0.7182761",
"0.7174535",
"0.71411514",
"0.71378136",
"0.713304",
"0.7124015",
"0.71098524",
"0.7104289",
"0.7038175",
"0.7021828",
"0.7021828",
"0.7021828",... | 0.0 | -1 |
Test asserts that the dataframe made from the read_commandline function is identical to the test dataframe from which the .csv file was created. | def test_read_commandline(dataframe):
# create a temporary .csv file from test data
temp_dir = tempfile.gettempdir()
dataframe.to_csv(f"{temp_dir}/dataframe.csv", index=0)
# create a new dataframe from the temporary .csv using
# the cat command from the bash commandline
if sys.platform in [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_from_file_csv(self):\n with TemporaryDirectory() as tmp:\n fp, df_test = save_simple_dataframe(tmp, 'test.csv')\n df_read = BaseDataClass.from_file(fp).df\n self.assertEqual(\n pd.testing.assert_frame_equal(df_test, df_read),\n None,\n ... | [
"0.70678663",
"0.6973909",
"0.68561196",
"0.6809812",
"0.65900654",
"0.65708643",
"0.6538297",
"0.64942354",
"0.64647907",
"0.6437283",
"0.638025",
"0.6336569",
"0.6325615",
"0.6294349",
"0.6272604",
"0.6226562",
"0.62224954",
"0.6213068",
"0.6208523",
"0.61556876",
"0.613355... | 0.82945 | 0 |
Selects a color from the matplotlib css color database. | def colorGenerator(skippedColors=10):
colors = list(mcolors.CSS4_COLORS)
for start in itertools.cycle(range(20, 20 + skippedColors)):
for i in range(start, len(colors), skippedColors):
yield colors[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _color(self,c):\n return self.colorlist[c%len(self.colorlist)]",
"def pickAColor():\n color = _tkCall(tkColorChooser.askcolor)\n if color[0] != None:\n return Color(color[0][0], color[0][1], color[0][2])",
"def select_color(self):\n\t\tresult = tkinter.colorchooser.askcolor(self.center[... | [
"0.6730433",
"0.6686478",
"0.6650432",
"0.64860964",
"0.640928",
"0.63835466",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
"0.6332146",
... | 0.0 | -1 |
Set the value and update the color. Notes valmin/valmax are set on the parent to 0 and len(depths). | def set_val(self, val):
val = int(val)
# valmax is not allowed, since it is out of the array.
# valmin is allowed since 0 index is in depth array.
if val < self.valmin or val >= self.valmax:
# invalid, so ignore
return
# activate color is first since we st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setColor(self,value):\n\t\tself.politics = value if(type(value) is int)else int(value[1:],16)\n\t\tself.canvas.itemconfig('node_'+self.identifier,fill=self.toRGB())",
"def set_val(self, val):\n val = np.sort(val)\n _api.check_shape((2,), val=val)\n # Reset value to allow _value_in_bounds... | [
"0.6640877",
"0.6548799",
"0.6307354",
"0.62737453",
"0.6163058",
"0.61619",
"0.607332",
"0.60614914",
"0.6049167",
"0.6023975",
"0.5941608",
"0.58719933",
"0.5844159",
"0.57223743",
"0.571449",
"0.5702216",
"0.5687083",
"0.5661152",
"0.5626655",
"0.56171894",
"0.56026465",
... | 0.79558706 | 0 |
Initialize this dataset class. | def __init__(self, opt):
BaseDataset.__init__(self, opt)
self.data_folder = os.path.join(opt.dataroot, opt.phase)
self.image_file_names = sorted(os.listdir(self.data_folder))
self.batch_size = opt.batch_size
self.z_dim = opt.z_dim
self.imsize = opt.crop_size
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.__dataset = None",
"def __init__(self, dataset):\n self._dataset = dataset",
"def __init__(self, dataset: Dataset):\n self.dataset = dataset",
"def __init__(self, config):\n logger.info(f\"{self.__class__.__name__}: Dataset initializing ...\")\n s... | [
"0.816631",
"0.81641185",
"0.8013762",
"0.76137954",
"0.7422038",
"0.7393049",
"0.7352237",
"0.73437655",
"0.7111143",
"0.71019876",
"0.7099074",
"0.7096382",
"0.70223516",
"0.696418",
"0.6961817",
"0.6889772",
"0.6879775",
"0.68740934",
"0.68599087",
"0.68520594",
"0.6842619... | 0.6730716 | 35 |
Returns true if both objects are equal | def __eq__(self, other):
# type: (object) -> bool
if not isinstance(other, ViewportState):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
# type: (object) -> bool
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"... | 0.80920255 | 7 |
Check the object permission. | def has_object_permission(self, request, view, obj):
if Contributor.objects.filter(project=obj, user=request.user):
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_object_permission(permission, request, view, obj):\n if not permission().has_object_permission(request, view, obj):\n view.permission_denied(\n request, message=getattr(permission, 'message', None)\n )",
"def check_object_permissions(self, request, obj):\n for permiss... | [
"0.819445",
"0.81272614",
"0.80648726",
"0.80339557",
"0.7997648",
"0.79193723",
"0.7913107",
"0.79067785",
"0.7887055",
"0.7887055",
"0.7885634",
"0.788116",
"0.7873367",
"0.7826268",
"0.7817024",
"0.78163",
"0.781547",
"0.78135246",
"0.7799382",
"0.77802294",
"0.77571464",
... | 0.74095666 | 39 |
Check the object permission. | def has_object_permission(self, request, view, obj):
if Contributor.objects.filter(project=obj, user=request.user):
permission = Contributor.objects.filter(project=obj, user=request.user)[0]
return permission.permission == "author"
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_object_permission(permission, request, view, obj):\n if not permission().has_object_permission(request, view, obj):\n view.permission_denied(\n request, message=getattr(permission, 'message', None)\n )",
"def check_object_permissions(self, request, obj):\n for permiss... | [
"0.819445",
"0.81272614",
"0.80648726",
"0.80339557",
"0.7997648",
"0.79193723",
"0.7913107",
"0.79067785",
"0.7887055",
"0.7887055",
"0.7885634",
"0.788116",
"0.7873367",
"0.7826268",
"0.7817024",
"0.78163",
"0.781547",
"0.78135246",
"0.7799382",
"0.77802294",
"0.77571464",
... | 0.7328788 | 41 |
Check the object permission. | def has_object_permission(self, request, view, obj):
return not obj.permission == "author" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_object_permission(permission, request, view, obj):\n if not permission().has_object_permission(request, view, obj):\n view.permission_denied(\n request, message=getattr(permission, 'message', None)\n )",
"def check_object_permissions(self, request, obj):\n for permiss... | [
"0.819445",
"0.81272614",
"0.80648726",
"0.80339557",
"0.7997648",
"0.79193723",
"0.7913107",
"0.79067785",
"0.7887055",
"0.7887055",
"0.7885634",
"0.788116",
"0.7873367",
"0.7826268",
"0.7817024",
"0.78163",
"0.781547",
"0.78135246",
"0.7799382",
"0.77802294",
"0.77571464",
... | 0.7474281 | 36 |
Check the object permission. | def has_permission(self, request, view):
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_object_permission(permission, request, view, obj):\n if not permission().has_object_permission(request, view, obj):\n view.permission_denied(\n request, message=getattr(permission, 'message', None)\n )",
"def check_object_permissions(self, request, obj):\n for permiss... | [
"0.819445",
"0.81272614",
"0.80648726",
"0.80339557",
"0.7997648",
"0.79193723",
"0.7913107",
"0.79067785",
"0.7887055",
"0.7887055",
"0.7885634",
"0.788116",
"0.7873367",
"0.7826268",
"0.7817024",
"0.78163",
"0.781547",
"0.78135246",
"0.7799382",
"0.77802294",
"0.77571464",
... | 0.6930524 | 68 |
Clip and convert an image to np.uint8. Args | def _clip(image):
return np.clip(image, 0, 255).astype(np.uint8) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_uint8(image):\n\tnp.clip(image, 0, 255, out=image)\n\treturn image.astype(np.uint8)",
"def to_uint8(f):\n from numpy import array, clip, uint8\n\n img = array(clip(f,0,255),uint8)\n return img",
"def unscale(image):\n return tf.cast(tf.math.multiply(image, 255), tf.uint8)",
"def convert_im... | [
"0.73004645",
"0.64434946",
"0.63479",
"0.63420886",
"0.5932686",
"0.5874442",
"0.5867836",
"0.58601403",
"0.5803097",
"0.5790521",
"0.5748678",
"0.5711535",
"0.56931335",
"0.568761",
"0.5683812",
"0.5664944",
"0.56201494",
"0.5617284",
"0.5581774",
"0.55719745",
"0.5566959",... | 0.7418486 | 0 |
Compute the total score for a player's game of bowling. | def bowling_one(balls):
frame_scores = []
i = 0
while len(frame_scores) < 10:
current_roll = balls[i]
if current_roll == 10:
next_roll = balls[i + 1]
next_next_roll = balls[i + 2]
frame_scores.append(current_roll + next_roll + next_next_roll)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_score(player_cards):\n score = sum(player_cards)\n return score",
"def score(self,player, board):\r\n numPlayer = 0\r\n numOpp = 0\r\n for i in self.squares():\r\n if board[i] == player:\r\n numPlayer+= SQUARE_WEIGHTS[i]\r\n else:\r\n ... | [
"0.7650006",
"0.7633847",
"0.7527698",
"0.7469793",
"0.7452517",
"0.7387711",
"0.71954083",
"0.718596",
"0.7141511",
"0.7030778",
"0.6992324",
"0.6973871",
"0.69504803",
"0.6932902",
"0.6905502",
"0.6903267",
"0.688952",
"0.6878671",
"0.68137366",
"0.6786484",
"0.6777656",
... | 0.0 | -1 |
Calculate the heuristic value of a game state from the point of view of the given player. | def custom_score(game, player):
if game.is_loser(player):
return float("-inf")
if game.is_winner(player):
return float("inf")
return __heuristic3__(game, player) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def utility(self, state, player):\n if state.isWin() or state.isLose():\n return state.getScore()\n\n # In case of cycle.\n if player == PACMAN:\n return INFINITY\n else:\n return -INFINITY",
"def calculate_utility(state, player):\n thisPlayer = pla... | [
"0.7160031",
"0.7126443",
"0.6840133",
"0.6816918",
"0.67986786",
"0.65901345",
"0.6581988",
"0.6449993",
"0.6436957",
"0.6435461",
"0.6433362",
"0.6419876",
"0.64143103",
"0.6406242",
"0.6401132",
"0.63523954",
"0.63402605",
"0.6339346",
"0.6311418",
"0.6307777",
"0.6277502"... | 0.64499426 | 8 |
Calculate the heuristic value of a game state from the point of view of the given player. Uses the parameters provided in weights[] | def eval_func(self, game, player):
if game.is_loser(player):
return float("-inf")
if game.is_winner(player):
return float("inf")
own_moves = len(game.get_legal_moves(player))
opp_moves = len(game.get_legal_moves(game.get_opponent(player)))
if gam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_score_naive(self, game_state, player, weights):\n # walls score\n other_players = [p for p in game_state.players if p != player]\n my_walls = player.num_walls\n their_walls = max([p.num_walls for p in other_players])\n walls_diff = (my_walls - their_walls)\n # pa... | [
"0.7177373",
"0.68247616",
"0.64440054",
"0.6387609",
"0.6283614",
"0.6247294",
"0.6201958",
"0.6201958",
"0.6201958",
"0.6201958",
"0.6201958",
"0.6201958",
"0.6201958",
"0.61478233",
"0.6127142",
"0.61173964",
"0.60248256",
"0.60247",
"0.59869456",
"0.59860605",
"0.5977224"... | 0.6346142 | 4 |
Default home page display when user enters the url | def home_view(request):
message = "GET / - The base API route\nPOST /api/v1/auth/ - for registering a new account and signing up\nGET /api/v1/portfolio/{id}/ - for retrieving a user's portfolio\nPOST /api/v1/stock/ - for creating a new company record\nGET /api/v1/stock/{id}/ - for retrieving a companies information... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def go_home(self):\r\n if self.home_url is not None:\r\n self.set_url(self.home_url)",
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home():\n\n # sets the page to load depending on the type of user\n # if none specified the login screen will be displayed\n ... | [
"0.7668816",
"0.7577727",
"0.75730103",
"0.7525394",
"0.7522126",
"0.7496628",
"0.74945855",
"0.7466226",
"0.7451552",
"0.74181354",
"0.74171096",
"0.7408227",
"0.73769134",
"0.7376027",
"0.7376027",
"0.73559433",
"0.735086",
"0.7345017",
"0.7345017",
"0.7340173",
"0.73274153... | 0.0 | -1 |
Delete a scaling group if there are no entities belonging to the scaling group. If successful, no response body will be returned. | def delete_scaling_group(self, request):
group = self.store.get_scaling_group(self.log, self.tenant_id,
self.group_id)
force = extract_bool_arg(request, 'force', False)
return controller.delete_group(
self.dispatcher, log, transaction_id(r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete():\n name = request.json['name']\n group = models.user.Group.get(name)\n if not group:\n raise Absent('Group does not exists.', deletion=False)\n else:\n models.db.session.delete(group)\n models.db.session.commit()\n return response(200, deletion=True)",
"def de... | [
"0.67925584",
"0.6676837",
"0.6622869",
"0.6583672",
"0.65556115",
"0.6447706",
"0.6446245",
"0.64028823",
"0.63720226",
"0.6365238",
"0.6305437",
"0.6258469",
"0.6244676",
"0.61977446",
"0.61608195",
"0.61599296",
"0.61253375",
"0.61201614",
"0.61199766",
"0.6067289",
"0.605... | 0.79625654 | 0 |
Pause a scaling group. This means that no scaling policies will get executed (execution will be rejected). This is an idempotent operation pausing an already paused group does nothing. | def pause_scaling_group(self, request):
group = self.store.get_scaling_group(
self.log, self.tenant_id, self.group_id)
return controller.pause_scaling_group(
self.log, transaction_id(request), group, self.dispatcher) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pause_scaling_group(log, transaction_id, scaling_group, dispatcher):\n if not tenant_is_enabled(scaling_group.tenant_id, config_value):\n raise NotImplementedError(\"Pause is not implemented for legay groups\")\n return perform(dispatcher,\n conv_pause_group_eff(scaling_group, tr... | [
"0.7695504",
"0.7276188",
"0.7137577",
"0.61898124",
"0.61122686",
"0.603153",
"0.58547",
"0.5822203",
"0.5817363",
"0.5803151",
"0.57746464",
"0.57746464",
"0.5751726",
"0.56664234",
"0.5643777",
"0.55803317",
"0.5575569",
"0.5559275",
"0.5553459",
"0.55483395",
"0.55279815"... | 0.7803774 | 0 |
Return a participant in this conference. | def participant(self, sid):
return Participant(self, sid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getParticipant(self, discordId):\n if discordId in participants:\n return participants[discordId]\n else:\n return None",
"def participant(self, sid):\r\n return Participant(self, sid)",
"def participant_id(self):\n return self.data[\"id\"]",
"def partici... | [
"0.72046083",
"0.703881",
"0.67052925",
"0.6300894",
"0.6294788",
"0.62100816",
"0.6181115",
"0.6156547",
"0.6144625",
"0.60970587",
"0.60328543",
"0.59512925",
"0.589766",
"0.5822871",
"0.58099806",
"0.5790752",
"0.57761496",
"0.5708563",
"0.55543476",
"0.5511341",
"0.549857... | 0.7080376 | 1 |
Creates a random Bezier curve of degree deg between points st and end. Used for developing purposes. | def rndBezier(deg, st, end):
if (deg == 0):
print("ERROR: The bezier curve degree has to be greater than 0")
return
totalLength = dist(st[0], st[1], end[0], end[1])
varLength = totalLength / deg
controlP = np.zeros((deg + 1, 2))
controlP[0] = np.asarray(st)
for i in range(deg - 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initPoly(deg, st, end):\n if (deg == 0):\n print(\"ERROR: The bezier curve degree has to be greater than 0\")\n return\n controlP = np.zeros((deg + 1, 2))\n controlP[0] = np.asarray(st)\n for i in range(deg - 1):\n point = controlP[i] + 1 / deg * (np.asarray(end) - np.asarray(s... | [
"0.6735812",
"0.62409556",
"0.6128898",
"0.59693897",
"0.58591384",
"0.58243567",
"0.57288355",
"0.56791764",
"0.56591725",
"0.5613972",
"0.56002206",
"0.5586161",
"0.55115736",
"0.548937",
"0.5426974",
"0.53957564",
"0.5360223",
"0.5346464",
"0.5339668",
"0.5326595",
"0.5281... | 0.81868535 | 0 |
Find the set of nodes reachable from this node (including the node). Return is a set of integers. | def reachable(self, node, adjacencyList, followOnAdjacencyList=None):
visited = set()
def dfs(fNode):
if fNode not in visited:
visited.add(fNode)
list(map(dfs, adjacencyList[fNode]))
if followOnAdjacencyList is not None:
li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_reachable_nodes(self, source: Node) -> Set[Node]:\n nodes_found: Set[Node] = {source}\n queue = [source]\n while queue:\n v = queue.pop()\n for e in v.outgoing_edges:\n if e.node_to not in nodes_found:\n nodes_found.add(e.node_to)... | [
"0.7296934",
"0.7092169",
"0.70596015",
"0.7005512",
"0.7000364",
"0.69020015",
"0.6899064",
"0.6848201",
"0.6847079",
"0.683086",
"0.6689352",
"0.6687347",
"0.664796",
"0.66347694",
"0.66301626",
"0.6509228",
"0.650443",
"0.6480518",
"0.6434538",
"0.63981146",
"0.6397733",
... | 0.0 | -1 |
Returns true if there are any cycles in the graph, which is represented as an adjacency list. | def isAcyclic(self, adjacencyList):
def cyclic(fNode, visited, stack):
if fNode not in visited:
visited.add(fNode)
assert fNode not in stack
stack.append(fNode)
for tNode in adjacencyList[fNode]:
if cyclic(tNode, vi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_cycle(self):\n traversed = dict()\n for i in self.adj_list:\n traversed[i] = False\n\n for i in self.adj_list:\n if not traversed[i]:\n if self.has_cycle_helper(i, traversed, -1):\n return True\n return False",
"def is_ac... | [
"0.79342306",
"0.78799105",
"0.7653055",
"0.7563285",
"0.7180815",
"0.71524304",
"0.7145887",
"0.7013198",
"0.69577783",
"0.6809838",
"0.67981017",
"0.6736561",
"0.6720564",
"0.6707665",
"0.6696526",
"0.6678177",
"0.6646088",
"0.66392225",
"0.663645",
"0.66328865",
"0.6611120... | 0.7528858 | 4 |
This is an abstract class used to instantiate a database given a folder containing various file resources. When creating a Database class, the load_data function is called where the file resources are load as a DataFrame and performs necessary processings. This class provides an interface for RNA classes to annotate va... | def __init__(self, path, file_resources: Dict, source_col_name: str = None, target_col_name: str = None,
source_index: str = None, target_index: str = None, edge_attr: List[str] = None, filters: dict = None,
directed: bool = True, relabel_nodes: dict = None, verbose: bool = False):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data_path='data', db_params=ideagens):\n my_path = path.abspath(data_path)\n self.path = my_path\n\n self.db_params = db_params\n self.db = get_db(self.db_params)",
"def __init__(self, root_dir, annotation_file, transform=None):\n self.root_dir = root_dir\n ... | [
"0.6647819",
"0.6397069",
"0.6354014",
"0.6218223",
"0.61998284",
"0.6086568",
"0.6061298",
"0.6009826",
"0.59659237",
"0.59281945",
"0.5909195",
"0.58908904",
"0.5875746",
"0.5859631",
"0.5843262",
"0.5827883",
"0.58244896",
"0.58155924",
"0.5815304",
"0.5805956",
"0.5804437... | 0.53747773 | 75 |
Convert matrix of token ids into strings | def to_lines(self, matrix, crop=True):
lines = []
for line_ix in map(list,matrix):
if crop:
if line_ix[0] == self.bos_ix:
line_ix = line_ix[1:]
if self.eos_ix in line_ix:
line_ix = line_ix[:line_ix.index(self.eos_ix)]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_string_array(matrix):\n res = []\n for row in matrix:\n res.append(''.join(row))\n return '\\n'.join(res)",
"def matrix_to_str(matrix):\n output_str = \"[\"\n for i in matrix:\n output_str += \"[\"\n for j in i:\n output_str += str... | [
"0.6612506",
"0.6504981",
"0.6298419",
"0.6298419",
"0.628061",
"0.62243813",
"0.6204719",
"0.6183098",
"0.61808413",
"0.6170656",
"0.6130394",
"0.6124223",
"0.6028791",
"0.5953577",
"0.58969325",
"0.58903843",
"0.5822055",
"0.58115304",
"0.57968414",
"0.57855535",
"0.5784645... | 0.0 | -1 |
Switch on the LED. | def switch_on(self):
if threading.current_thread() != self._blinking_thread:
self._blinking_thread.unregister(self)
GPIO.output(self.pin, GPIO.HIGH) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_on(self):\n GPIO.output(self.gpio, True) # turn on light",
"def setLED(self):\n newValue = 0\n while newValue != '':\n newValue = input('Enter 0 or 1 to turn LED on or off or enter to exit.\\n')\n \n if newValue == '0':\n self.board.w... | [
"0.8169446",
"0.80078214",
"0.78626806",
"0.77106386",
"0.7581997",
"0.7579719",
"0.74839616",
"0.7457253",
"0.7394008",
"0.73702383",
"0.7356243",
"0.7353404",
"0.7313382",
"0.726793",
"0.7227901",
"0.7201615",
"0.7120204",
"0.71123457",
"0.7079622",
"0.7055739",
"0.70464486... | 0.78942364 | 2 |
Switch off the LED. | def switch_off(self):
if threading.current_thread() != self._blinking_thread:
self._blinking_thread.unregister(self)
GPIO.output(self.pin, GPIO.LOW) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self):\n print(\"Turning the lights off\")\n self.led.all_off()\n self.client.publish(STATE_TOPIC, OFF) #publish",
"def turn_off(self):\n GPIO.output(self.gpio, False) # turn off light",
"def turn_off(self):\n self.handleCommand(1)\n self._state = STATE_O... | [
"0.8566237",
"0.8554572",
"0.82871026",
"0.81795263",
"0.8168383",
"0.81602025",
"0.8151963",
"0.8091471",
"0.7998849",
"0.7984244",
"0.79522836",
"0.7872218",
"0.78054094",
"0.7803678",
"0.7792981",
"0.7756382",
"0.77311605",
"0.77235824",
"0.77206516",
"0.77036095",
"0.7686... | 0.8332468 | 2 |
Switch off and stop the blinking thread. | def quit(self):
self.switch_off()
self._blinking_thread.stop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def switch_off(self):\n if threading.current_thread() != self._blinking_thread:\n self._blinking_thread.unregister(self)\n GPIO.output(self.pin, GPIO.LOW)",
"def off_switch(self):\n self._switch_callback = None",
"def turn_off(self, **kwargs):\n self.robot.pause_cleaning(... | [
"0.828817",
"0.7239973",
"0.7199364",
"0.7198174",
"0.7182316",
"0.7133912",
"0.71314734",
"0.71077996",
"0.71077996",
"0.70924217",
"0.7086729",
"0.70526946",
"0.7050104",
"0.7048751",
"0.7043728",
"0.7038531",
"0.70182234",
"0.69688004",
"0.69668037",
"0.69494116",
"0.69445... | 0.8257933 | 1 |
Tests whether ``RoleManagerMetadataApplicationRoleConnection.from_data`` works as intended. | def test__RoleManagerMetadataApplicationRoleConnection__from_data():
integration_id = 202301150005
data = {
'integration_id': str(integration_id)
}
metadata = RoleManagerMetadataApplicationRoleConnection.from_data(data)
_assert_is_every_attribute_set(metadata)
vampytest.as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__RoleManagerMetadataApplicationRoleConnection__to_data():\n integration_id = 202301150006\n \n metadata = RoleManagerMetadataApplicationRoleConnection(\n integration_id = integration_id\n )\n \n expected_data = {\n 'integration_id': str(integration_id),\n 'guild_conn... | [
"0.72700346",
"0.67431384",
"0.57812655",
"0.5577804",
"0.5289391",
"0.5229587",
"0.52133775",
"0.519593",
"0.5076414",
"0.49436608",
"0.4906069",
"0.48754257",
"0.48150232",
"0.47816363",
"0.47616816",
"0.47108835",
"0.4678398",
"0.46730247",
"0.46708363",
"0.46526524",
"0.4... | 0.8163409 | 0 |
C = (g^(M^(e mod n)))((r^m)mod (m^2)) | def encrypt(_g, _s, _e, _n, _m):
r = gmpy2.xmpz(1)
g = gmpy2.xmpz(_g)
s = gmpy2.xmpz(_s)
e = gmpy2.xmpz(_e)
n = gmpy2.xmpz(_n)
m = gmpy2.xmpz(_m)
b1 = f_mod(e, n)
b1 = pow(g, pow(s, b1))
b1 = mul(b1, f_mod(pow(r,m), pow(m,2)))
return b1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ECMFactor(n, sieve, limit, times):\n for _ in range(times):\n g = n\n while g == n:\n curve, point = randomCurve(n)\n g = gcd(n, curve.discriminant().remainder())\n \n if g > 1:\n return g\n\n for prime in sieve:\n prod = pri... | [
"0.7037409",
"0.7007121",
"0.67641306",
"0.6752192",
"0.6738003",
"0.6726312",
"0.6647986",
"0.6633587",
"0.6574364",
"0.6542397",
"0.64660656",
"0.64597243",
"0.644045",
"0.64177483",
"0.63950163",
"0.6387623",
"0.63871264",
"0.63725555",
"0.63536185",
"0.63476896",
"0.63234... | 0.6425005 | 13 |
This function reads SQL database through sqlalchemy and loads database table into Pandas dataframe extracting feature values and target values | def load_data(database_filepath):
# load data from database
engine = create_engine('sqlite:///{}'.format(database_filepath))
# Create datframe by quering database
df = pd.read_sql("SELECT * from messages", engine)
# Feature selection
X = df['message']
# Choosing column na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_training_data(db_conn):\n return pd.read_sql('''select * from churn_model.churn_data;''', db_conn)",
"def targets_to_dataframe(conn):\n return connect_database.get_table_into_pandas('target_info',conn)",
"def load_data(database_path):\n\n try:\n engine = create_engine(f\"sqlite:///{data... | [
"0.70252293",
"0.6982166",
"0.68791294",
"0.65387046",
"0.6474624",
"0.64607066",
"0.64592546",
"0.64498615",
"0.64391613",
"0.6424813",
"0.6390264",
"0.6381552",
"0.63677883",
"0.6362419",
"0.6353745",
"0.6300753",
"0.62926835",
"0.6241063",
"0.6161258",
"0.6154829",
"0.6154... | 0.6243174 | 17 |
Simple image plotting wrapper | def plot_img(img, savefig="test.png", **kwargs):
plt.figure()
if img.ndim > 2:
plt.imshow(cv2.cvtColor(img.astype(np.uint8), cv2.COLOR_BGR2RGB), **kwargs)
else:
plt.imshow(img.astype(np.uint8), **kwargs)
plt.axis("off")
if savefig:
cv2.imwrite(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot(data, interactive=False):\n if interactive:\n plt.ion()\n fig = plt.figure()\n fig.canvas.draw()\n image = call_imshow(data)\n else:\n fig = plt.figure()\n image = call_imshow(data)\n plt.show()\n return fig, image",
"def plot_image(img, label=\"... | [
"0.722285",
"0.7139101",
"0.7127996",
"0.711136",
"0.70447594",
"0.703394",
"0.69963914",
"0.6929877",
"0.6929877",
"0.6929877",
"0.69226825",
"0.6869958",
"0.67979544",
"0.67860055",
"0.6781733",
"0.6771797",
"0.6771162",
"0.6728001",
"0.6702688",
"0.66706306",
"0.662369",
... | 0.67218447 | 18 |
Determines patch masks and match centers for both source and target patches | def get_patches(self):
self.get_source_patch_masks()
self.get_target_patch_masks()
self.get_source_patches() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_target_patch_masks(self):\n self.target_patch_masks = {\n patch_center: self.get_patch_mask(patch_center)\n for patch_center in self.anchor_points\n }\n for patch in self.target_patch_masks:\n self.updated_structure_mask[self.target_patch_masks[patch]] ... | [
"0.72775877",
"0.71869683",
"0.6329769",
"0.6109868",
"0.5946034",
"0.58988786",
"0.5833438",
"0.5783357",
"0.57539546",
"0.56932914",
"0.5683626",
"0.56612754",
"0.56517494",
"0.5602133",
"0.55849206",
"0.55780846",
"0.55373704",
"0.55333847",
"0.5509592",
"0.5497487",
"0.54... | 0.6374971 | 2 |
Initialize the first row of the cost matrix, M (1) from white board drawing | def initialize_cost_matrix(self):
self.cost_matrix = np.zeros(
(len(self.anchor_points), len(self.patch_centers)), dtype=np.float64
)
target_point = self.anchor_points[0]
for i in range(len(self.patch_centers)):
source_point = self.patch_centers[i]
Es_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_cost_matrix(self): \n cost_matrix = np.zeros((self.N+self.M, self.N+self.M))\n\n for i in range(self.N):\n for j in range(self.M):\n cost_matrix[i, j] = self.substitute_cost(i, j)\n \n for i in range(self.M):\n for j in range(self.M):... | [
"0.6778801",
"0.6502844",
"0.63555235",
"0.6186499",
"0.61482126",
"0.60644877",
"0.60593796",
"0.6013477",
"0.5955823",
"0.57806474",
"0.57806474",
"0.5724883",
"0.57155377",
"0.57113713",
"0.5698522",
"0.5662982",
"0.5650547",
"0.56478083",
"0.5647795",
"0.56431234",
"0.564... | 0.671456 | 1 |
Return this LocNode's value | def getval(self) -> typing.Optional[dict]:
return self.val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self):\n return self.node_value",
"def loc_value(self):\n return self._loc_value[1]",
"def getValue(self):\n return _libsbml.ASTNode_getValue(self)",
"def value(self):\n return self.get_attribute(\"value\", str(self.children))",
"def getval(self):\r\n return sel... | [
"0.8031546",
"0.77826613",
"0.7465206",
"0.7234131",
"0.70805246",
"0.70354545",
"0.7032114",
"0.699002",
"0.69704956",
"0.69698685",
"0.6968212",
"0.6968212",
"0.6968212",
"0.696381",
"0.69408774",
"0.69345343",
"0.69345343",
"0.6929328",
"0.6929328",
"0.6927064",
"0.6915589... | 0.0 | -1 |
Return a list of all reagent item statuses. | def get_reagent_item_status_list(self) -> DBRecList:
raise NotImplementedError('not implemented') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def statuses(self):\n return self._get_paged(\"statuses\")",
"def statuses(self):\n big = BigCommerceAPI()\n response = big.get('orderstatuses')\n return response.text",
"def get_statuses(self):\n return self.statuses",
"def get_all(self) -> List[Status]:\n return se... | [
"0.70572025",
"0.68753785",
"0.6789352",
"0.67099434",
"0.65530634",
"0.65277624",
"0.6363759",
"0.6321006",
"0.63142306",
"0.6250614",
"0.6250614",
"0.6200735",
"0.61752236",
"0.61752236",
"0.6167747",
"0.6167586",
"0.61452305",
"0.61122316",
"0.60808724",
"0.60225064",
"0.5... | 0.7845527 | 0 |
List payouts. Returns a [cursorpaginated](apiusagecursorpagination) list of your payouts. | def list(self,params=None, headers=None):
path = '/payouts'
response = self._perform_request('GET', path, params, headers,
retry_failures=True)
return self._resource_for(response) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_checked_outs():\n no_token = 'Y'\n list_of_books = overdrive_apis.get_list_of_checkouts(no_token)\n return render_template('hold_list.html', list_of_books=list_of_books, what='checkout')",
"def get_payouts():\n s = TimedSerializer(current_app.config['rpc_signature'])\n s.loads(request.data... | [
"0.6320229",
"0.6241012",
"0.5917347",
"0.55352646",
"0.52601737",
"0.5076912",
"0.50157565",
"0.50087124",
"0.50021195",
"0.4996705",
"0.49791443",
"0.4974983",
"0.4970509",
"0.49375552",
"0.49313858",
"0.48553878",
"0.48523268",
"0.48517752",
"0.4844017",
"0.48370248",
"0.4... | 0.7446098 | 0 |
Get a single payout. Retrieves the details of a single payout. For an example of how to reconcile the transactions in a payout, see [this guide](eventsreconcilingpayoutswithevents). | def get(self,identity,params=None, headers=None):
path = self._sub_url_params('/payouts/:identity', {
'identity': identity,
})
response = self._perform_request('GET', path, params, headers,
retry_failures=True)
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(self,params=None, headers=None):\n path = '/payouts'\n \n\n response = self._perform_request('GET', path, params, headers,\n retry_failures=True)\n return self._resource_for(response)",
"def get(self, payment):\n return payment",... | [
"0.59275705",
"0.5628925",
"0.5618046",
"0.5596309",
"0.558108",
"0.5541119",
"0.5478816",
"0.54574823",
"0.5217998",
"0.52085954",
"0.51963013",
"0.5195348",
"0.50894785",
"0.5029707",
"0.50150126",
"0.49570936",
"0.4941692",
"0.49182224",
"0.48873544",
"0.48731235",
"0.4863... | 0.6470658 | 0 |
Sets the learning rate to the initial LR decayed by 10 every args.lr_drop epochs | def adjust_learning_rate(optimizer, epoch):
lr = args.lr * (0.1 ** (epoch // args.lr_drop))
print('lr= '+str(lr), flush=True)
for param_group in optimizer.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(optimizer, epoch, args):\n lr = args.lr * (0.3 ** (epoch // args.lr_decay))\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr",
"def adjust_learning_rate(optimizer, epoch, args):\r\n lr = args.lr * (0.1 ** (epoch // 30))\r\n for param_group ... | [
"0.7352336",
"0.7333978",
"0.72885704",
"0.7282347",
"0.72648644",
"0.726462",
"0.7256753",
"0.7253272",
"0.72382236",
"0.72373194",
"0.72373194",
"0.72373194",
"0.72340554",
"0.7228736",
"0.72230136",
"0.7220188",
"0.7210714",
"0.7208806",
"0.72068775",
"0.72039914",
"0.7187... | 0.75878245 | 0 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0, keepdim=Tru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Return a sum total of several dictionaries. | def sum_dicts(*args):
result = dict()
for arg in args:
result.update(arg)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_dictionares(dicts: dict):\n\n def reducer(accumulator, element):\n for key, value in element.items():\n accumulator[key] = accumulator.get(key, 0) + value\n return accumulator\n\n return reduce(reducer, dicts, {})",
"def sum(self):\n return sum(self.items())",
"def... | [
"0.7690904",
"0.73174846",
"0.73051286",
"0.72677666",
"0.716861",
"0.7052999",
"0.69231606",
"0.6882448",
"0.6847206",
"0.6804574",
"0.67773473",
"0.6701605",
"0.6701533",
"0.66912395",
"0.66120344",
"0.660227",
"0.66002333",
"0.6530555",
"0.6473131",
"0.6434731",
"0.6411104... | 0.72450846 | 4 |
Create a random hex color | def random_color():
r = lambda: random.randint(0, 255)
color = ('%02X%02X%02X' % (r(), r(), r()))
return color | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_hex_color():\n r = randint(0, 255)\n g = randint(0, 255)\n b = randint(0, 255)\n\n return '#%x%x%x' % (r, g, b)",
"def rand_color(x):\n random.seed(x)\n color = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)\n color = '#%02x%02x%02x' % color\n return col... | [
"0.8972932",
"0.81565833",
"0.8070119",
"0.8046609",
"0.7978272",
"0.78821385",
"0.7880014",
"0.783659",
"0.78061885",
"0.7778768",
"0.776845",
"0.76735973",
"0.7561245",
"0.7314368",
"0.7228979",
"0.72285986",
"0.7185438",
"0.71798426",
"0.7157546",
"0.7154343",
"0.7099737",... | 0.83276933 | 1 |
Inserts a value to the heap. | def insert(self, value):
self.heap.append(value)
self._shiftUp() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, value):\n self.heap.append(value)\n index = len(self.heap) - 1\n self._percolate_up(index)",
"def insert(self, key, value):\n self.heap.append(None)\n hi = HeapItem(key,value)\n self.siftup(hi, len(self.heap)-1)\n return hi",
"def insert(self,ke... | [
"0.88196313",
"0.82914025",
"0.82426745",
"0.82133466",
"0.81545436",
"0.81498545",
"0.80577403",
"0.7922794",
"0.7849871",
"0.7674401",
"0.76577246",
"0.7655261",
"0.7616019",
"0.7521071",
"0.75024974",
"0.74980086",
"0.74963194",
"0.7463579",
"0.74433964",
"0.74140525",
"0.... | 0.8886361 | 0 |
The indicated value for the VPLS Id Assigned Number attribute. The default is 0. | def VplsIdAssignedNumber(self):
return self._get_attribute('vplsIdAssignedNumber') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def VsiIdAssignedNumber(self):\n return self._get_attribute('vsiIdAssignedNumber')",
"def VplsIdAsNumber(self):\n return self._get_attribute('vplsIdAsNumber')",
"def VplsIdAssignedNumberStep(self):\n return self._get_attribute('vplsIdAssignedNumberStep')",
"def VplsIdType(self):\n ... | [
"0.76749665",
"0.7372743",
"0.7046495",
"0.6611994",
"0.6417205",
"0.63544697",
"0.633049",
"0.6116104",
"0.5928075",
"0.59177536",
"0.5909815",
"0.5770851",
"0.57539123",
"0.57042104",
"0.56712717",
"0.56116766",
"0.5538851",
"0.5513119",
"0.55040973",
"0.5503051",
"0.549345... | 0.8216867 | 0 |
The VPLS ID type, one of AS and IP. Default is AS. | def VplsIdType(self):
return self._get_attribute('vplsIdType') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ip_type(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"ip_type\")",
"def VplsIdAsNumber(self):\n return self._get_attribute('vplsIdAsNumber')",
"def ip_type(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"ip_type\")",
"def type(self) -> Optional[pulumi.Inp... | [
"0.617248",
"0.6131267",
"0.6048633",
"0.59055555",
"0.58932656",
"0.58127064",
"0.58113873",
"0.58039254",
"0.5783582",
"0.5771179",
"0.57523865",
"0.57469696",
"0.573458",
"0.5708333",
"0.5701703",
"0.5684939",
"0.5661624",
"0.5643624",
"0.56361705",
"0.56361705",
"0.563488... | 0.7176309 | 0 |
Retrieves a single instance of bgp4VpnBgpAdVplsRange data from the server. | def read(self, href):
return self._read(href) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fusion_api_get_ipv4_range(self, uri=None, param='', api=None, headers=None):\n return self.ipv4range.get(uri=uri, api=api, headers=headers, param=param)",
"def get_ip_range(self):\n return self._ip_range",
"def getRange(self):\n return self.range",
"def fusion_api_get_vsn_range(s... | [
"0.5818055",
"0.563778",
"0.5499236",
"0.54218036",
"0.5256655",
"0.52278125",
"0.5220286",
"0.5218447",
"0.5195881",
"0.5110039",
"0.5105795",
"0.50950694",
"0.5068814",
"0.506147",
"0.5060568",
"0.50443",
"0.5030232",
"0.5030232",
"0.50281316",
"0.5003587",
"0.49711668",
... | 0.0 | -1 |
Get the value of the card for the purposes of the count. | def get_card_value(self, card):
if card >= 10:
return 10
if card == 1:
return 11
return card | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self, card):\n return self.valores[self.deck.index(card)]",
"async def get_card_value(card):\n return ex.first_result(await ex.conn.fetchrow(\"SELECT value FROM blackjack.cards WHERE id = $1\", card))",
"def get_value(self):\n \n value = 0\n ace = False\n\n ... | [
"0.80048424",
"0.7558608",
"0.7213102",
"0.7182821",
"0.7171359",
"0.7035289",
"0.6992966",
"0.69261545",
"0.68542933",
"0.6762942",
"0.6658885",
"0.6554658",
"0.65510786",
"0.648137",
"0.6425735",
"0.6400239",
"0.6273015",
"0.62284356",
"0.62059027",
"0.6165098",
"0.61159074... | 0.762364 | 1 |
Opens a new database connection if there is none yet for the current application context. | def get_db(server_id):
DATABASE = "DATABASE" + str(server_id)
print(DATABASE)
tracktop = _app_ctx_stack.top
if not hasattr(tracktop, 'track_db0') and server_id == 0:
tracktop.track_db0 = sqlite3.connect(app.config[DATABASE], detect_types=sqlite3.PARSE_DECLTYPES)
tracktop.track_db0.row_fa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_open():\n if not hasattr(g, 'sqlite_db'):\n g.sqlite_db = db_connect()\n return g.sqlite_db",
"def open_database(self):\n if self._conn is None:\n self._conn = sqlite3.connect(self._db_path)",
"def open_db(db_name: str = DB_NAME) -> DBConnection:\n return sqlite3.connec... | [
"0.7737639",
"0.7582971",
"0.73180443",
"0.71693045",
"0.70220166",
"0.6966687",
"0.6954785",
"0.69486743",
"0.6897534",
"0.6842663",
"0.68292314",
"0.68191963",
"0.680592",
"0.67950195",
"0.67697805",
"0.6762173",
"0.6751266",
"0.6746273",
"0.67316663",
"0.670031",
"0.668866... | 0.0 | -1 |
Shift input ids one token to the right, and wrap the last non pad token (usually ). | def shift_tokens_right(input_ids, pad_token_id):
prev_output_tokens = input_ids.clone()
index_of_eos = (input_ids.ne(pad_token_id).sum(dim=1) - 1).unsqueeze(-1)
prev_output_tokens[:, 0] = input_ids.gather(1, index_of_eos).squeeze()
prev_output_tokens[:, 1:] = input_ids[:, :-1]
return prev_outpu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_tokens_right(self, input_ids, pad_token_id):\n prev_output_tokens = input_ids.clone()\n index_of_eos = (input_ids.ne(pad_token_id).sum(dim=1) - 1).unsqueeze(-1)\n prev_output_tokens[:, 0] = input_ids.gather(1, index_of_eos).squeeze()\n prev_output_tokens[:, 1:] = input_ids[:, :-1]\n return... | [
"0.8141209",
"0.7356376",
"0.7302423",
"0.62760633",
"0.5989989",
"0.5901887",
"0.57361895",
"0.5569694",
"0.55039227",
"0.5472055",
"0.5472055",
"0.5472055",
"0.5459301",
"0.5419903",
"0.53397924",
"0.53197056",
"0.5286252",
"0.52811766",
"0.5208013",
"0.51893353",
"0.518071... | 0.8175183 | 0 |
Prepare masks that ignore padding tokens in the decoder and a causal mask for the decoder if none are provided. This mimics the default behavior in fairseq. To override it pass in masks. | def _prepare_bart_decoder_inputs(
config, input_ids, decoder_input_ids=None, decoder_padding_mask=None, causal_mask_dtype=torch.float32
):
pad_token_id = config.pad_token_id
if decoder_input_ids is None:
decoder_input_ids = shift_tokens_right(input_ids, pad_token_id)
bsz, tgt_len = decoder... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_masking(self, masks):\n self.masks = masks",
"def prepareMask(self, mask):\n\n # Make sure that the mask has the same\n # number of voxels as the atlas image.\n # Use nearest neighbour interpolation\n # for resampling, as it is most likely\n # that the mask... | [
"0.66787624",
"0.5992953",
"0.59493387",
"0.5806535",
"0.5670196",
"0.56646276",
"0.56476253",
"0.5622995",
"0.5621455",
"0.55875957",
"0.5529941",
"0.5492848",
"0.5470644",
"0.54528314",
"0.54391444",
"0.54390395",
"0.54333967",
"0.5423804",
"0.5418299",
"0.54100585",
"0.537... | 0.6272836 | 1 |
Return nan instead (more robust) of nothing (loss of index parity). Median is more robust than mean. | def outlier(arr, as_nan=True, thresh=0.05, show=False, report=False):
if len(arr) < 3:
return arr
if show:
plt.subplot(1,2,1) # Plot part 1 first
plt.plot(np.random.random(len(arr)), thing1, 'o', color='blue',
markeredgecolor='none', alpha=0.4)
plt.title('With outliers')
med_res = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nanmedian(arr, **kwargs):\r\n return ma.median( ma.masked_where(arr!=arr, arr), **kwargs )",
"def mad_median(y):\n\n # YOUR CODE HERE\n if len(y) == 0:\n return 0.\n \n return np.mean(np.abs(y - np.median(y)))",
"def nanmean(x: torch.FloatTensor):\n nan_mask = torch.isnan(x)\n ... | [
"0.7277392",
"0.69705164",
"0.68347484",
"0.67609304",
"0.67459476",
"0.6598331",
"0.659477",
"0.6577432",
"0.65659493",
"0.6561792",
"0.6551442",
"0.65445304",
"0.6514302",
"0.65127885",
"0.65127885",
"0.6505533",
"0.6500362",
"0.6458916",
"0.6438456",
"0.6398109",
"0.634112... | 0.0 | -1 |
Calculate interburst interval coefficient of variation. | def ibi_cv(bstart, bstop):
ibis = []
for b in range(len(bstart)-1):
if bstart[b+1] > bstop[b]: # ortho, correct
ibis.append(bstart[b+1] - bstop[b])
else:
print(' In %s, %.2f starts before burst ends at %.2f'
%(cell_id, bstart[b+1], bstop[b]))
return np.mean(ibis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gini_coefficient(x):\n diffsum = 0\n for i, xi in enumerate(x[:-1], 1):\n diffsum += np.sum(np.abs(xi - x[i:]))\n return diffsum / (len(x) ** 2 * np.mean(x))",
"def coefficient_variation(self):\n std, mean = self.std()\n coefficient_variation = std/mean\n print(f\"Coeffic... | [
"0.6393203",
"0.6207591",
"0.6195008",
"0.5875815",
"0.57561606",
"0.57197726",
"0.56928813",
"0.56749415",
"0.56507593",
"0.5567023",
"0.5557998",
"0.54877394",
"0.5456385",
"0.54320294",
"0.5416997",
"0.5385559",
"0.5382477",
"0.53780407",
"0.53671503",
"0.53364134",
"0.533... | 0.0 | -1 |
Write the new df (with the clust_inds column) to a new csv file, but use all the columns from the original csv. | def writeNewDF(df, original_name, new_name):
try:
orig = pd.read_csv(original_name)
except:
print('Could not find or load %s' %original_name)
newcol = []
orig_tms, new_tms = list(orig.times.values), list(df.times.values)
for i in range(orig.shape[0]):
if orig_tms[i] in new_tms:
newcol.app... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_index(self, file_name):\n self.df_index.to_csv(file_name, sep='\\t')",
"def save_clusters(df_clu, bus):\n dirname = os.path.dirname(__file__)\n folder = os.path.join(dirname, '../Clusters/')\n file_path = folder + 'Bus_' + str(bus) + '.csv'\n df_clu.to_csv(file_path, sep=',', encodin... | [
"0.6270441",
"0.6233784",
"0.6230068",
"0.59784067",
"0.5845556",
"0.58446866",
"0.58254105",
"0.57847196",
"0.5775274",
"0.57743657",
"0.57593477",
"0.57382405",
"0.5719709",
"0.57143116",
"0.5713007",
"0.5660907",
"0.56608474",
"0.5646629",
"0.5639858",
"0.56334585",
"0.562... | 0.66875494 | 0 |
Checks if the queue is full. If length of the array = capacity | def isFull(self):
return self.size == self.capacity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isFull(self):\r\n if (len(self.queue) == self.maxlen):\r\n return True\r\n else:\r\n return False",
"def isFull(self):\n return len(self.queue) == self.size",
"def isFull(self) -> bool:\n return self.count == self.capacity",
"def isFull(self) -> bool:\n ... | [
"0.8243399",
"0.8116667",
"0.7512367",
"0.7512367",
"0.7481536",
"0.74761736",
"0.7446499",
"0.7412954",
"0.7412954",
"0.7376846",
"0.73320967",
"0.722053",
"0.72035635",
"0.71983624",
"0.71550983",
"0.7147962",
"0.71364105",
"0.71245646",
"0.7121453",
"0.71193403",
"0.70688"... | 0.77101356 | 2 |
Checks if the queue is empty. Front and Rear are at the same position. | def isEmpty(self):
if self.size == 0:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty(self) -> bool: \n if(self.queue is not None and len(self.queue) > 0):\n print(\"len > 0\" )\n return False\n else:\n print(\"len = 0\" )\n return True",
"def isEmpty(self) -> bool:\n if self.front == self.rear:\n return True\n ... | [
"0.802168",
"0.80206406",
"0.80157465",
"0.7984915",
"0.7976422",
"0.78603065",
"0.78595746",
"0.7837328",
"0.7835442",
"0.78305703",
"0.78305703",
"0.78277683",
"0.7788282",
"0.77881783",
"0.7783926",
"0.7769781",
"0.7739886",
"0.7732143",
"0.7722253",
"0.76707864",
"0.76635... | 0.0 | -1 |
Gets the element at the front of the queue | def getFront(self):
front = self.queue[self.front]
return front
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def front(self):\n return self.queue[0] if not self.empty() else None",
"def front(queue):\n if empty_queue(queue):\n raise IndexError(\"Queue is empty!\")\n else:\n return queue.front.value",
"def Front(self):\r\n if (len(self.queue) >= 1):\r\n return self.queue[0]... | [
"0.863565",
"0.85876423",
"0.8262497",
"0.8199349",
"0.8142919",
"0.8119887",
"0.8119887",
"0.81194574",
"0.81194574",
"0.8095368",
"0.8071027",
"0.8029827",
"0.8023997",
"0.8023762",
"0.80135787",
"0.8007365",
"0.7980079",
"0.79781455",
"0.79189056",
"0.7881961",
"0.78775406... | 0.8828211 | 0 |
Gets the element at the rear of the queue | def getRear(self):
rear = self.queue[self.rear]
return rear | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Rear(self):\r\n if (len(self.queue) >= 1):\r\n return self.queue[-1]\r\n else:\r\n return -1",
"def Rear(self):\n if self.isEmpty():\n return -1\n else:\n return self.queue[self.rear - 1]",
"def Rear(self):\n if self.isEmpty():\... | [
"0.79273635",
"0.7885271",
"0.7885271",
"0.78627443",
"0.78627443",
"0.78563255",
"0.7839446",
"0.7763032",
"0.7737314",
"0.7728852",
"0.7726813",
"0.7685761",
"0.7663426",
"0.7656322",
"0.7647468",
"0.76411307",
"0.7617875",
"0.7602192",
"0.7591403",
"0.75396156",
"0.7529405... | 0.7950408 | 0 |
Draw a sample from the normal distribution based on the mean and std pairs values a vector containing mean and standard deviation pairs pairs how many pairs the vector contains randomize boolean for really drawing a random sample instead of using the maximum likelihood values | def _draw_from_distr(self, values, pairs, randomize):
# sample size one less than pairs specification as pairs contain
# the total mass and component percentages. These are transformed
# into component masses
sample = [None for i in range(len(pairs)-1)]
for i in range(len(pairs))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal(mean, std):\n\n return random.gauss(mean, std)",
"def draw(self, nsamples):\n \n if self.dist == 'normal':\n mean = self.mean\n sd = self.sd\n self.sample = sd * np.random.randn(nsamples) + mean\n \n elif self.dist == 'poisson... | [
"0.7447999",
"0.7197481",
"0.6864649",
"0.6820152",
"0.6783022",
"0.6781596",
"0.6633428",
"0.6585596",
"0.6565232",
"0.63914496",
"0.6378227",
"0.6376844",
"0.6367755",
"0.63280845",
"0.629468",
"0.62851274",
"0.6271981",
"0.6258002",
"0.62300134",
"0.621335",
"0.6199399",
... | 0.62722933 | 16 |
sets mute to specific value | def set_mute(cls, mute: bool):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mute(self, value: bool) -> None:\n self.audio_mixer.setmute(value)\n self.update_status()",
"def mute_volume(self, mute):\n mute_numeric = '1' if mute else '0'\n self._lms.query(self._id, 'mixer', 'muting', mute_numeric)\n self.update_ha_state()",
"def set_mute(self, trac... | [
"0.82080686",
"0.8040739",
"0.7972243",
"0.7928214",
"0.7918955",
"0.7626789",
"0.7612275",
"0.7486662",
"0.73271835",
"0.73062056",
"0.72171974",
"0.7142333",
"0.7094243",
"0.7056901",
"0.70527345",
"0.7005203",
"0.69862056",
"0.6986194",
"0.6978512",
"0.69333375",
"0.689570... | 0.77314484 | 5 |
returns the mute status | def get_mute(cls) -> bool:
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mute(self):\n return on_off_bool(self.get(COMMAND_UIC, 'GetMute')['mute'])",
"def mute(self) -> bool:\n return bool(self.audio_mixer.getmute()[0])",
"def getSafetyMute(self, unitCode=0):\n resp = self.XAPCommand('SFTYMUTE', unitCode=unitCode)\n return bool(int(resp))",
"as... | [
"0.81131196",
"0.75747645",
"0.7535899",
"0.7334661",
"0.7321568",
"0.73022544",
"0.7295821",
"0.70787257",
"0.70787257",
"0.70787257",
"0.7027964",
"0.6937151",
"0.69201064",
"0.6892316",
"0.68694514",
"0.6846512",
"0.6839677",
"0.6812334",
"0.6803103",
"0.67730725",
"0.6758... | 0.70603335 | 10 |
Flask decorator that allow to set Expire and Cache headers. | def docache(minutes=5, content_type='application/json; charset=utf-8'):
def fwrap(f):
@wraps(f)
def wrapped_f(*args, **kwargs):
r = f(*args, **kwargs)
then = datetime.now() + timedelta(minutes=minutes)
rsp = Response(r, content_type=content_type)
rsp.h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cache_headers_decorator(route_function, cache_headers):\n\n @functools.wraps(route_function)\n def decorated_function(*args, **kwargs):\n response = flask.make_response(\n route_function(*args, **kwargs)\n )\n\n if response.status_code == 200:\n # Only add cach... | [
"0.7566276",
"0.69809616",
"0.69809616",
"0.69174796",
"0.6915464",
"0.6883607",
"0.68154144",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",
"0.6784055",... | 0.719012 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.