query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
check to see whether an id is for a user | def is_user(id):
return id.startswith('U') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def userIDExists(self, id : int) -> bool:\n return id in self.users.keys()",
"def hasUser(self, id):\n try:\n self.getUser(id)\n return True\n except KeyError:\n return False",
"def check_user(user):\n result_user = search_column_with_constraint(choose_d... | [
"0.79370236",
"0.75839674",
"0.7334541",
"0.732782",
"0.72933257",
"0.7157885",
"0.71560794",
"0.70645714",
"0.70558435",
"0.7010881",
"0.6988318",
"0.69240403",
"0.69037765",
"0.6896436",
"0.6886491",
"0.6883643",
"0.6861566",
"0.6858304",
"0.6853838",
"0.6834101",
"0.683142... | 0.8175753 | 0 |
broadcast a new user joining the group | def user_joined_group(cls, group, user):
text = "{} joined the group chat".format(user.username)
cls._broadcast_group(group, None, group, text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_new_user(self, user):\n # join to default group\n g = self.root.get('community-general')\n if g:\n self.join_group(user, g)",
"def join_server(self, data, user):\n # User will spawn in one of following rooms\n user.room = choice((\"100\", \"300\", \"800\",... | [
"0.66464144",
"0.6612628",
"0.65133005",
"0.65117073",
"0.64265233",
"0.6303679",
"0.6245498",
"0.6235882",
"0.6231058",
"0.6172051",
"0.61579597",
"0.61176723",
"0.60869974",
"0.6015817",
"0.6015379",
"0.601436",
"0.5992443",
"0.59782267",
"0.59572095",
"0.59416044",
"0.5917... | 0.71382284 | 0 |
broadcast a user leaving the group | def user_left_group(cls, group, user):
text = "{} left the group chat".format(user.username)
cls._broadcast_group(group, None, group, text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def leave_room(self, label):\n user = self.user\n room = await self.get_room(label)\n\n await self.channel_layer.group_send(\n room.group_name,\n {\n 'type': 'chat.leave',\n 'label': label,\n 'username': user.username,\n ... | [
"0.68877256",
"0.6836113",
"0.6618386",
"0.6293848",
"0.62480164",
"0.6209803",
"0.61928344",
"0.61679953",
"0.61453825",
"0.6137914",
"0.61103255",
"0.6071488",
"0.59881574",
"0.59806395",
"0.5946936",
"0.592674",
"0.5914093",
"0.59117216",
"0.59084827",
"0.5901252",
"0.5890... | 0.7276704 | 0 |
Start an oef node. | def _start_oef_node(self, network_node): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def launch_oef():\n script_path = os.path.join(\"scripts\", \"oef\", \"launch.py\")\n configuration_file_path = os.path.join(\"scripts\", \"oef\", \"launch_config.json\")\n print(\"Launching new OEF Node...\")\n subprocess.Popen(\n [\"python3\", script_path, \"-c\", configuration_file_path, \"--... | [
"0.73455715",
"0.67564565",
"0.6507637",
"0.5896183",
"0.5798123",
"0.56471074",
"0.5645573",
"0.5598258",
"0.5573087",
"0.556594",
"0.55550206",
"0.5545505",
"0.5535845",
"0.5517319",
"0.5511",
"0.55073994",
"0.5473905",
"0.5468678",
"0.54667735",
"0.54622465",
"0.54570323",... | 0.82847816 | 0 |
Test that a generated protocol's serialisation + deserialisation work correctly. | def test_generated_protocol_serialisation(self):
# create a message
reply_message = {1: "number one", 2: "number two", 7: "number seven"}
# message 1
message = TwoPartyNegotiationMessage(
message_id=1,
dialogue_reference=(str(0), ""),
target=0,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_proto_serialization() -> None:\n\n uid = UID(value=uuid.UUID(int=333779996850170035686993356951732753684))\n obj = SpecificLocation(id=uid, name=\"Test\")\n\n blob = SpecificLocation.get_protobuf_schema()(id=sy.serialize(uid), name=\"Test\")\n\n assert sy.serialize(obj, to_proto=True) == blob\... | [
"0.6951617",
"0.68632156",
"0.67302066",
"0.661847",
"0.6527949",
"0.6503405",
"0.6458234",
"0.63932693",
"0.63932693",
"0.6388795",
"0.63429564",
"0.63004637",
"0.6290241",
"0.62630475",
"0.6233855",
"0.618288",
"0.61746454",
"0.6163066",
"0.6099586",
"0.6083544",
"0.6072765... | 0.7254605 | 0 |
Test that a generated protocol could be used in exchanging messages between two agents. | def test_generated_protocol_end_to_end(self):
# AEA components
ledger_apis = LedgerApis({}, FETCHAI)
wallet_1 = Wallet({FETCHAI: FETCHAI_PRIVATE_KEY_FILE})
wallet_2 = Wallet({FETCHAI: FETCHAI_PRIVATE_KEY_FILE})
identity_1 = Identity(
name="my_aea_1",
add... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_identify(self):\n\n protocol_a, transport_a, tree_a, _ = self.create_protocol('protocol_a')\n protocol_b, transport_b, tree_b, _ = self.create_protocol('protocol_b')\n\n transport_a.get_extra_info.return_value = ('127.0.0.1', 1000)\n transport_b.get_extra_info.return_value = ('... | [
"0.6693443",
"0.65527207",
"0.64990115",
"0.64490074",
"0.64464223",
"0.6435972",
"0.641256",
"0.63902915",
"0.6338546",
"0.6269686",
"0.6266628",
"0.6260895",
"0.6249174",
"0.61818177",
"0.61632335",
"0.61631536",
"0.61530423",
"0.61333424",
"0.6118203",
"0.60873365",
"0.605... | 0.6860271 | 0 |
Test _specification_type_to_python_type method unsupported type. | def test__specification_type_to_python_type_unsupported_type(self):
with self.assertRaises(TypeError):
_specification_type_to_python_type("unsupported_type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_type_error(self):\n self._error_test(TypeError)",
"def test_raises_type_error(self):\n wrong_type = dict()\n self.assertRaises(\n TypeError, util.convert_protobuf_to_proto_plus, wrong_type\n )",
"def test_value_error_for_computing_missing_type():\n with pytest... | [
"0.6947089",
"0.6929546",
"0.6844311",
"0.6795259",
"0.66925305",
"0.6652292",
"0.6652253",
"0.6572005",
"0.65506715",
"0.6511283",
"0.64829165",
"0.6474207",
"0.64679945",
"0.64503706",
"0.64311326",
"0.6370294",
"0.6370191",
"0.6354397",
"0.6286515",
"0.6261668",
"0.6253150... | 0.91027087 | 0 |
Test _union_sub_type_to_protobuf_variable_name method tuple. | def test__union_sub_type_to_protobuf_variable_name_tuple(self, mock):
_union_sub_type_to_protobuf_variable_name("content_name", "Tuple")
mock.assert_called_once() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _union_sub_type_to_protobuf_variable_name(\n content_name: str, content_type: str\n) -> str:\n if content_type.startswith(\"FrozenSet\"):\n sub_type = _get_sub_types_of_compositional_types(content_type)[0]\n expanded_type_str = \"set_of_{}\".format(sub_type)\n elif content_type.startswit... | [
"0.7497985",
"0.54891527",
"0.5454183",
"0.5442474",
"0.5129124",
"0.5115415",
"0.51112336",
"0.5045163",
"0.5033024",
"0.5018397",
"0.49975044",
"0.49971396",
"0.49895564",
"0.4978763",
"0.4951379",
"0.49307013",
"0.49243486",
"0.48797363",
"0.48714188",
"0.485954",
"0.48464... | 0.8391995 | 0 |
Test _includes_custom_type method positive result. | def test__includes_custom_type_positive(self, *mocks):
content_type = "Union[str]"
result = self.protocol_generator._includes_custom_type(content_type)
self.assertTrue(result)
content_type = "Optional[str]"
result = self.protocol_generator._includes_custom_type(content_type)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _includes_custom_type(content_type: str) -> bool:\n\n if content_type.startswith(\"Optional\"):\n sub_type = _get_sub_types_of_compositional_types(content_type)[0]\n result = _includes_custom_type(sub_type)\n elif content_type.startswith(\"Union\"):\n sub_types = _get_sub_types_of_co... | [
"0.7456461",
"0.6151709",
"0.57726073",
"0.5564573",
"0.5552539",
"0.5481914",
"0.5474497",
"0.54267174",
"0.5376972",
"0.534768",
"0.5330371",
"0.5328861",
"0.5311295",
"0.5270746",
"0.52539307",
"0.5240947",
"0.5239048",
"0.5234515",
"0.5231774",
"0.5193669",
"0.5185735",
... | 0.7806248 | 0 |
Convert a text to a format ROUGE understands. The text is assumed to contain one sentence per line. | def convert_text_to_rouge_format(text, title="dummy title"):
sentences = text.split("\n")
sent_elems = [
"<a name=\"{i}\">[{i}]</a> <a href=\"#{i}\" id={i}>"
"{text}</a>".format(i=i, text=sent)
for i, sent in enumerate(sentences, start=1) if sent != '']
html = """<html>
<head>
<title... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert(text):\n return NewDocument.from_rst(text).format()",
"def preprocess(self, text):\r\n return text",
"def preprocess(self, text):\n if self.model_name == \"bert-base-arabert\":\n return self._old_preprocess(\n text,\n do_farasa_tokenization=... | [
"0.66363716",
"0.61474895",
"0.6118832",
"0.6097702",
"0.609217",
"0.60894656",
"0.6057062",
"0.60051125",
"0.6003964",
"0.59820795",
"0.59751576",
"0.5925597",
"0.5902075",
"0.5848546",
"0.5844513",
"0.5837306",
"0.58300614",
"0.58283144",
"0.5815858",
"0.5792594",
"0.577824... | 0.6489249 | 1 |
Conditional Entropy Calculates the conditional Shannon Entropy for two discrete distributions. This metric gives the entropy of the distribution of x in case the distribution of y is known. | def conditional_entropy(x, y, bins, normalize=False):
# get the bins
bins = get_2D_bins(x, y, bins)
# calculate H(x,y) and H(y)
hjoint = joint_entropy(x,y,bins)
hy = entropy(y, bins[1])
if normalize:
normalizer = entropy(x, bins[0])
conditional_entropy = hjoint - hy
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conditional_entropy(f1, f2):\n\n ce = ee.entropyd(f1) - ee.midd(f1, f2)\n return ce",
"def entropy(y):\n return -1 * sum(\n [\n pipe(np.sum(y == value) / len(y), lambda ratio: ratio * np.log(ratio))\n for value in set(y)\n ]\n )",
"def conditional_entropy(sel... | [
"0.7481201",
"0.6875717",
"0.6782211",
"0.6750487",
"0.6720426",
"0.6655979",
"0.6648373",
"0.6570259",
"0.6566688",
"0.64887154",
"0.64597607",
"0.64407265",
"0.63953054",
"0.6383221",
"0.63512045",
"0.63497704",
"0.63459283",
"0.63403004",
"0.6330119",
"0.6322664",
"0.62897... | 0.71850336 | 1 |
Cross Entropy Calculates the cross entropy of two discrete distributions x and y. | def cross_entropy(x, y, bins, xy_probabilities=False):
# calculate probabilities if probabilities == False
if xy_probabilities:
# same bins for x and y -> same length of x and y if xy_probabilities == True
assert len(x) == len(y)
# if x does not sum up to 1, raise an error
if not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_entropy(x, y):\n\n if len(y.shape) == 1:\n return F.cross_entropy(x, y)\n if y.shape[1] == 1:\n y = y.squeeze(1)\n return F.cross_entropy(x, y)\n\n return torch.mean(\n torch.div(\n F.binary_cross_entropy_with_logits(x, y, reduction=\"none\"),\n ... | [
"0.7399793",
"0.7246357",
"0.71943384",
"0.70277774",
"0.6669306",
"0.6637702",
"0.6602384",
"0.65894943",
"0.65266645",
"0.6473503",
"0.6437216",
"0.642684",
"0.63894004",
"0.6365542",
"0.6353329",
"0.63220906",
"0.628778",
"0.6279644",
"0.62760943",
"0.6269529",
"0.62406224... | 0.7348612 | 1 |
r"""Joint Entropy Calculates the joint entropy of two discrete distributions x and y. This is the combined Entropy of X added to the conditional Entropy of x given y. | def joint_entropy(x, y, bins):
# assert array length
assert len(x) == len(y)
# get the bins, x and y get their own bins in case of joint entropy
bins = get_2D_bins(x, y, bins)
# get the joint histogram
joint_hist = np.histogram2d(x, y, bins)[0]
# calculate the joint probability and add a ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mutual_information(x, y):\r\n\r\n # INSERT YOUR CODE HERE\r\n xvalue, xcount = np.unique(x,return_counts = True)\r\n probx = xcount.astype(float)/len(x)\r\n Hyx = 0.0\r\n for pxval,xval in zip(probx,xvalue):\r\n Hyx += (pxval)*entropy(y[x==xval])\r\n \r\n Ixy = entropy(y) - Hyx\r\n ... | [
"0.6370943",
"0.63690835",
"0.63631195",
"0.6334478",
"0.6209416",
"0.6186507",
"0.60127246",
"0.5941165",
"0.58904195",
"0.5855695",
"0.5840326",
"0.5787013",
"0.5770392",
"0.57627195",
"0.5750125",
"0.5739848",
"0.5735412",
"0.56943065",
"0.56919396",
"0.5672802",
"0.565470... | 0.7735844 | 0 |
r"""KullbackLeibler Divergence Calculates the KullbackLeibler Divergence between two discrete distributions x and y. X is considered to be an empirical discrete distribution while y is considered to be the real discrete distribution of the underlying population. | def kullback_leibler(x, y, bins, xy_probabilities=False):
if xy_probabilities:
# if x does not sum up to 1, raise an error
if not np.isclose(sum(x),1,atol=0.0001):
raise ValueError('Probabilities in vector x do not sum up to 1.')
# if y does not sum up to 1, raise an error
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kl_bern(x, y):\n x = min(max(x, eps), 1-eps)\n y = min(max(y, eps), 1-eps)\n return x*log(x/y) + (1-x)*log((1-x)/(1-y))",
"def kl_divergence(x,y):\n\tassert (isinstance(x, BayesNet) and isinstance(y, BayesNet)), 'Must pass in BayesNet objects.'\n\tassert (x==y), 'Passed-in BayesNet objects are not s... | [
"0.70139825",
"0.6948134",
"0.6635383",
"0.6421419",
"0.63527554",
"0.6301051",
"0.62800944",
"0.62187314",
"0.6194453",
"0.6156323",
"0.6144021",
"0.61299276",
"0.61106426",
"0.6105154",
"0.6101856",
"0.6100986",
"0.6093369",
"0.6083329",
"0.60363257",
"0.6034415",
"0.601664... | 0.7132836 | 0 |
Main method to get dependent review IDs of a specific review request on the ReviewBoard. | def main():
parameters = parse_parameters()
review_request_url = "%s/api/review-requests/%s/" % (REVIEWBOARD_URL,
parameters.review_id)
handler = ReviewBoardHandler()
review_request = handler.api(review_request_url)["review_request"]
review_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_review_request(self, rid):\r\n rsp = self.api_call('api/review-requests/%s/' % rid)\r\n return rsp['review_request']",
"def get_review_request(self, request_id, api_root):\n try:\n request = api_root.get_review_request(review_request_id=request_id)\n except APIError, e:\n ... | [
"0.57654417",
"0.5477173",
"0.5378847",
"0.5101541",
"0.5080031",
"0.4982286",
"0.49632528",
"0.49589026",
"0.49061635",
"0.48880798",
"0.488128",
"0.4835317",
"0.48325068",
"0.4829637",
"0.48200688",
"0.48102397",
"0.47959515",
"0.4773191",
"0.4731234",
"0.4722772",
"0.47219... | 0.6459412 | 0 |
Initalize with a usersupplied list of segments. | def __init__(self, segments, lemma = None, case = None):
self.segments = segments
if isinstance(self.segments, str):
self.segments = [Segment.new_segment(s) for s in self.segments]
self.lemma = lemma
self.case = case | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_segments(self):\n for strand in self.strand_list:\n strand.construct_segment()",
"def set_segments(self, segments):\n self.send_command(Command.SET_SEGMENT_COUNT, [segments])",
"def form_segment(self, node_oid):\n # init empty segment and stuff\n new_segment = S... | [
"0.6232747",
"0.596336",
"0.58711517",
"0.5702215",
"0.55154556",
"0.5394213",
"0.53759134",
"0.53305984",
"0.5308964",
"0.529063",
"0.5197425",
"0.51839024",
"0.5133967",
"0.5053822",
"0.50320536",
"0.5010542",
"0.50038457",
"0.4999929",
"0.49838173",
"0.4962347",
"0.4960938... | 0.6051361 | 1 |
Create a WordForm of the given CV shape with random segments. | def random_segs(cls, shape, lemma = None, case = None):
# For each C or V segment in `shape`, initialize a random Segment of the
# appropriate type. Initialize a new WordForm with all these Segments.
return cls([Segment(seg_type = seg) for seg in shape], lemma, case) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_word(self):\r\n\r\n template = self.word_constructions.get()\r\n word = \"\"\r\n for c in template:\r\n if c == \"v\":\r\n letter = self.get_letter(100)\r\n else:\r\n letter = self.get_letter(0)\r\n word += letter\r\n\r\... | [
"0.61004114",
"0.5693294",
"0.55114466",
"0.5438077",
"0.53612614",
"0.5311946",
"0.52376354",
"0.51894677",
"0.5161035",
"0.5152379",
"0.5143327",
"0.5127287",
"0.51046485",
"0.50831926",
"0.50809175",
"0.5080614",
"0.5072338",
"0.5021304",
"0.50183684",
"0.4984602",
"0.4969... | 0.72299457 | 0 |
Add the suffix vowel. | def add_suffix(self, suffix):
# Append the suffix vowel to this WordForm.
self.segments.append(Segment.new_segment(suffix)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_suffix(word, suffix):\n suffix, sep, rest = suffix.partition(' ')\n expanded = _add_suffix(word, suffix)\n return expanded + sep + rest",
"def get_vowel_names():",
"def _replace_suffix(self, word, suffix, replacement):\n assert word.endswith(suffix), \"Given word doesn't end with given ... | [
"0.5983021",
"0.5954164",
"0.59408945",
"0.5778313",
"0.5686185",
"0.5563964",
"0.5542913",
"0.55272454",
"0.54683185",
"0.5462567",
"0.54531056",
"0.5446963",
"0.54377186",
"0.5427365",
"0.53498006",
"0.53402376",
"0.53384125",
"0.5302798",
"0.52940315",
"0.5291557",
"0.5278... | 0.7781676 | 0 |
Entrench at the level of the WordForm. | def entrench_word(self, cloud, paradigms, informativity, categorization,
unique_base):
# Entrench within the WordForm's own cloud. Iterate over positions in
# the WordForm (up to three Segments).
for pos, seg in enumerate(self.segments):
if pos < 3:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _commit_level(self):\n assert self.current_level is not None, \"Cannot write a level with an empty name\"\n # Create a new level descriptor in the lump directory\n self.wad.add_lump(self.current_level, None)\n # Add the lumps to WAD file\n self.wad.add_lump('THINGS', self.lum... | [
"0.51781356",
"0.5135534",
"0.51090235",
"0.50966406",
"0.5095478",
"0.5094889",
"0.5074766",
"0.5069701",
"0.49998125",
"0.49493456",
"0.4920468",
"0.49131694",
"0.4900337",
"0.48817414",
"0.48688623",
"0.48541382",
"0.48305783",
"0.48229364",
"0.4820413",
"0.47837245",
"0.4... | 0.5143527 | 1 |
Add noise to the nonsuffix segments in the WordForm. | def add_noise(self):
self.segments = deepcopy(self.segments)
# Iterate through each of the first three Segments in the WordForm.
for i in range(3):
# Add noise to each Segment.
self.segments[i].add_noise() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_noise(self, words, lengths):\n words, lengths = self.word_shuffle(words, lengths)\n words, lengths = self.word_dropout(words, lengths)\n # words, lengths = self.word_blank(words, lengths)\n return words, lengths",
"def add_noise(self, data):",
"def remove_noise(text):\n\n ... | [
"0.61349237",
"0.6130484",
"0.60680324",
"0.604623",
"0.5941968",
"0.58597803",
"0.58269954",
"0.58108455",
"0.56916386",
"0.56686974",
"0.56611174",
"0.55890733",
"0.55856615",
"0.55645496",
"0.556166",
"0.55571675",
"0.5511801",
"0.55111974",
"0.5508282",
"0.5461142",
"0.54... | 0.8073021 | 0 |
Return the similarity between this WordForm and the one provided. | def similarity(self, wf, positions = None, features = None):
# The similarity is the inverse square of the distance between the two
# WordForms. Impose a minimum on distances (to deal with zero).
dist = self.distance(wf, positions = positions, features = features)
if dist < .1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wordSimilarityRatio(sent_1,sent_2):",
"def similarity(self, w1, w2):\r\n return self.represent(w1).dot(self.represent(w2))",
"def similarity(self, w1, w2):\r\n return self.represent(w1).dot(self.represent(w2))",
"def similarity(self, word1, word2):\n common_vect = +np.ones(self.nEmbe... | [
"0.7596557",
"0.747573",
"0.747573",
"0.7371653",
"0.73133916",
"0.7294227",
"0.72550523",
"0.71882695",
"0.71096104",
"0.70324767",
"0.7010185",
"0.6944519",
"0.692075",
"0.6890939",
"0.6874697",
"0.68725497",
"0.67834336",
"0.67505664",
"0.6722828",
"0.6527661",
"0.6500944"... | 0.76069194 | 0 |
Given an Frame object, will return the bytes of that Frame's file. If provided, will also scale the size of the image and convert to the required format. | def convert_frames(frame, img_format: str, scale=None) -> bytes:
path = frame.filename
with open(path, "rb") as image_file:
im = Image.open(image_file)
converted_img = BytesIO()
if scale:
_LOGGER.debug("Scaling the image")
(width, height) = (int(im.width * scale... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_image(self, frame, base64_encode=False):\n #NOTE: tuple (85010, 1) ndarray --> data reduction\n img_buf_arr = cv2.imencode(\".jpeg\", frame)[1]\n if base64_encode:\n img_buf_arr = b\"data:image/jpeg;base64,\" + base64.b64encode(img_buf_arr)\n return img_buf... | [
"0.5845967",
"0.5829252",
"0.568239",
"0.5598484",
"0.5597409",
"0.5580428",
"0.5558993",
"0.55013925",
"0.54556245",
"0.54468995",
"0.54443717",
"0.54354507",
"0.54354507",
"0.54297215",
"0.5396869",
"0.5359741",
"0.5324554",
"0.5318987",
"0.53071946",
"0.53018034",
"0.52503... | 0.7540226 | 0 |
Given a dictionary, changes the key from snake case to lower camel case. | def lower_camel_casify_dict_keys(d: dict) -> dict:
return {to_camel_case(key): value for key, value in d.items()} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_from_camelcase(key):\n s1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', key)\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', s1).lower()",
"def transform_to_camelcase(key):\n return Jsonifiable.lower_first(\n ''.join(c.capitalize() or '_' for c in key.split('_')))",
"def convert_dict_... | [
"0.7801124",
"0.77649593",
"0.77066845",
"0.7620036",
"0.7379338",
"0.7279606",
"0.71873266",
"0.71728736",
"0.7140577",
"0.70116407",
"0.69478273",
"0.69024104",
"0.68458456",
"0.6818799",
"0.6726056",
"0.67258394",
"0.6712159",
"0.6710847",
"0.67080796",
"0.6662867",
"0.659... | 0.7839561 | 0 |
Ensure IPCMessageSubscriber.connect gets wrapped by salt.utils.asynchronous.SyncWrapper. | async def test_ipc_connect_sync_wrapped(io_loop, tmp_path):
if salt.utils.platform.is_windows():
socket_path = ports.get_unused_localhost_port()
else:
socket_path = str(tmp_path / "noexist.ipc")
subscriber = salt.utils.asynchronous.SyncWrapper(
salt.transport.ipc.IPCMessageSubscriber... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_connect(self):\n loop = asyncio.get_event_loop()\n task = loop.create_task(self.connect())\n loop.run_until_complete(task)",
"async def _connect(self):\n pass",
"async def connect(self):\n raise NotImplementedError",
"async def on_connect(self) -> None:",
"async ... | [
"0.65937483",
"0.6521959",
"0.6248328",
"0.60831505",
"0.6030129",
"0.6018049",
"0.58920634",
"0.58730686",
"0.58308804",
"0.5825015",
"0.58228856",
"0.5811319",
"0.58058876",
"0.57596046",
"0.57403564",
"0.5738906",
"0.5736388",
"0.5714165",
"0.5698439",
"0.5685224",
"0.5668... | 0.7188033 | 0 |
Receives a list and a search term. Use a loop to go through the list and see if the string is there. if it is return "string found". if not, return "string not found" | def search_for_string(lst_str, stringy):
if stringy in lst_str:
return "Found string"
else:
return "string not found" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_by_contains(self, tl):\n print(\"Search by string\")\n string = input(\"Please enter search string: \")\n return tl.findall_contains(string)",
"def search(self, q):\n for x in self.strings:\n if q in x:\n return True\n \n return ... | [
"0.7277806",
"0.7085442",
"0.70570374",
"0.7042019",
"0.6853034",
"0.68284607",
"0.6799059",
"0.6741653",
"0.67367554",
"0.6710084",
"0.6704459",
"0.6700498",
"0.65898585",
"0.65151054",
"0.6475276",
"0.6447157",
"0.64241886",
"0.6397633",
"0.6358592",
"0.6356772",
"0.6352888... | 0.8100969 | 0 |
andExpr = relationalExpr { "and" relationalExpr } | def andExpr( ): #DOUBLE CHECK THIS
tok = tokens.peek( )
if debug: print("andExpr: ", tok)
left = relationalExpr( ) #does the left side of the grammar
tok = tokens.peek( )
while tok == "and": #checks to see if there is the token "and" and will preform what is inside the curly bracket since it is a series
tokens... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AND(*expressions):\n return {'$and': list(expressions)}",
"def __and__(self, query):\r\n return And([self, query]).normalize()",
"def and_(a, b):",
"def And(*conditions):\n def andPred(db):\n from functools import reduce\n return reduce(lambda result, c: c(result),\n ... | [
"0.7694933",
"0.7391504",
"0.7278942",
"0.72714126",
"0.72140443",
"0.71525294",
"0.71054393",
"0.7005105",
"0.6971053",
"0.6965941",
"0.69083124",
"0.68721735",
"0.68457156",
"0.68190354",
"0.6809348",
"0.6774739",
"0.67718345",
"0.6753265",
"0.6741417",
"0.67354465",
"0.670... | 0.8083135 | 0 |
relationalExpr = addExpr [ relation addExpr ] | def relationalExpr( ):#MAKE SURE I USED THE RIGHT LOGIC FOR THIS
tok = tokens.peek( )
if debug: print("relationalExpr: ", tok)
left = addExpr( )
expr = ""
tok = tokens.peek( )
if tok in relations:
rel = relation( ) # expecting a relation to start off
right = expression( ) # if there is a relation we expect ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_relation(wn, source, target, new_rel, change_list=None):\n insert_rel(source, new_rel, target, change_list)\n if new_rel in inverse_synset_rels:\n inv_rel_type = inverse_synset_rels[new_rel]\n insert_rel(target, inv_rel_type, source, change_list)",
"def addExpr( ):\n\n\ttok = tokens.p... | [
"0.6230691",
"0.61780995",
"0.60156584",
"0.590059",
"0.58807737",
"0.5856698",
"0.5843209",
"0.58185554",
"0.5784956",
"0.5745773",
"0.57166684",
"0.5676181",
"0.5653579",
"0.5636797",
"0.5615812",
"0.5576591",
"0.5564806",
"0.5537048",
"0.55229557",
"0.5472008",
"0.54082906... | 0.7208437 | 0 |
factor = number | '(' expression ')' | def factor( ):
tok = tokens.peek( )
if debug: print ("Factor: ", tok)
if re.match( Lexer.number, tok ):
expr = Number(tok)
tokens.next( )
tok = tokens.peek( )
return expr
if tok == "(":
tokens.next( ) # or match( tok )
expr = addExpr( )#might need to change to expression( )
tokens.peek( )
tok = ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _num_factor(number, factor):\n assert factor != 0\n return number // factor",
"def make_multiplier(factor):\n return lambda x: factor * x",
"def make_anonymous_factorial():\n return 'YOUR_EXPRESSION_HERE'",
"def make_anonymous_factorial():\n return 'YOUR_EXPRESSION_HERE'",
"def make_anon... | [
"0.65296596",
"0.6441182",
"0.641148",
"0.641148",
"0.641148",
"0.641148",
"0.63577914",
"0.60211015",
"0.5988639",
"0.5983069",
"0.59670454",
"0.5808318",
"0.5783513",
"0.57786024",
"0.57604265",
"0.5731007",
"0.5716077",
"0.57154644",
"0.5681956",
"0.5650473",
"0.56236184",... | 0.74144316 | 0 |
term = factor { ('' | '/') factor } | def term( ):
tok = tokens.peek( )
if debug: print ("Term: ", tok)
left = factor( )
tok = tokens.peek( )
while tok == "*" or tok == "/":
tokens.next()
right = factor( )
left = BinaryExpr( tok, left, right )
tok = tokens.peek( )
return left | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_term(self, node, children):\n if self.debug:\n print(\"Term {}\".format(children))\n term = children[0]\n for i in range(2, len(children), 2):\n if children[i-1] == \"*\":\n term *= children[i]\n else:\n term /= children[... | [
"0.6671328",
"0.5942621",
"0.578661",
"0.5665476",
"0.5546639",
"0.55136436",
"0.55068946",
"0.5483381",
"0.5461509",
"0.5405435",
"0.53730965",
"0.5351918",
"0.5335714",
"0.5334143",
"0.5312731",
"0.5308194",
"0.52843577",
"0.52693665",
"0.52682096",
"0.52596307",
"0.5258266... | 0.7452738 | 0 |
addExpr = term { ('+' | '') term } | def addExpr( ):
tok = tokens.peek( )
if debug: print ("addExpr: ", tok)
left = term( )
tok = tokens.peek( )
while tok == "+" or tok == "-":
tokens.next()
right = term( )
left = BinaryExpr( tok, left, right )
tok = tokens.peek( )
return left | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(text):\n orig = dispb[\"text\"]\n new = orig + text\n ops = [\"+\",\"-\",\"*\",\"/\"]\n # conditions\n # length 21\n if len(new) > 21:\n dispb[\"text\"] = orig\n return 0\n \n # one calc at a time\n if len(orig) > 0:\n if (orig[-1] in ops) & (text in ops):\n ... | [
"0.6888404",
"0.63378376",
"0.63330656",
"0.6294168",
"0.6236394",
"0.6221723",
"0.6219546",
"0.6147867",
"0.61287045",
"0.6115096",
"0.60734725",
"0.60724515",
"0.60708827",
"0.6070692",
"0.60704505",
"0.60387814",
"0.60252726",
"0.5984255",
"0.5975357",
"0.5954446",
"0.5949... | 0.8184933 | 0 |
whileStatement = "while" expression block | def parseWhileStatement( ): # parse rountine for while and uses the while class to print out the appropriate string
tok = tokens.peek( )
if debug: print( "whileStatement: ", tok )
start = match( "while" )
expr = expression( )
blk = parseBlock( )
tok = tokens.peek( )
whileString = whileStatement( start, expr, bl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_while(self: Parser, node: doc.While) -> None:\n with self.var_table.with_frame():\n cond = self.eval_expr(node.test)\n with T.While(cond):\n self.visit_body(node.body)",
"def _While(self, t):\n self.fill(\"while (\")\n self.dispatch(t.test)\n self.write(... | [
"0.806411",
"0.7875308",
"0.76918495",
"0.7558932",
"0.74995136",
"0.7440557",
"0.7426091",
"0.73713285",
"0.7269703",
"0.72638226",
"0.7247464",
"0.7088606",
"0.6975367",
"0.69033563",
"0.6820734",
"0.68020827",
"0.66737217",
"0.6664865",
"0.6610299",
"0.6537933",
"0.6398223... | 0.7981215 | 1 |
ifStatement = "if" expression block [ "else" block ] | def parseIfStatement( ): # parse rountine for the if and uses the if class to print out the appropriate string
tok = tokens.peek( )
if debug: print( "ifStatement: ", tok )
start = match( "if" )
expr = expression( )
blk = parseBlock( )
elseblk = None
tok = tokens.peek( )
if tok == "else":
match( "else" )
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stmt_if(executor, stmt):\n e = Expression()\n result = e.eval(stmt._tokens, symbols=executor._symbols)\n if not result:\n executor.goto_next_line()",
"def test_if_elseif_paren_statement():\n r = convert_code(\n \"{if foo}\\nbar\\n{elseif (foo and bar) or foo and (bar or (foo and bar... | [
"0.75067496",
"0.71437025",
"0.69992465",
"0.69453186",
"0.6932306",
"0.6923417",
"0.6896828",
"0.68624914",
"0.6846336",
"0.68457514",
"0.683607",
"0.683607",
"0.683607",
"0.683607",
"0.6810346",
"0.68025327",
"0.6774503",
"0.6755583",
"0.6644169",
"0.66357064",
"0.6629795",... | 0.7603634 | 0 |
assign = ident "=" expression eoln | def parseAssign( ): # parse rountine for the assign and uses the assign class to print out the appropriate string
tok = tokens.peek( )
if debug: print( "assign: ", tok )
if re.match( Lexer.identifier, tok ):
ident = VarRef( tok )
else:
error( "Invalid identifier" )
tok = tokens.next( )
equals = match( "=" )... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_assign(self: Parser, node: doc.Assign) -> None:\n if len(node.targets) != 1:\n self.report_error(node, \"Consequential assignments like 'a = b = c' are not supported.\")\n lhs = node.targets[0]\n\n if isinstance(node.value, doc.Subscript):\n check_slices = []\n if isinstance... | [
"0.7246561",
"0.6989228",
"0.6973773",
"0.6966724",
"0.6946717",
"0.6939313",
"0.6896663",
"0.6890361",
"0.6872121",
"0.67357904",
"0.6725393",
"0.6725393",
"0.6697676",
"0.66803247",
"0.6641363",
"0.6609404",
"0.6593395",
"0.65624285",
"0.648081",
"0.63984084",
"0.638135",
... | 0.74569654 | 0 |
statement = ifStatement | whileStatement | assign | def statement( ): # parse rountin for statement that makes sure the token is one of the following, eventually there will be an error caught
tok = tokens.peek( )
if debug: print( "statement: ", tok )
if tok == "if":
stat = parseIfStatement( )
return stat
elif tok == "while":
stat = parseWhileStatement( )
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stmt_if(executor, stmt):\n e = Expression()\n result = e.eval(stmt._tokens, symbols=executor._symbols)\n if not result:\n executor.goto_next_line()",
"def _analyse_stmt_Assign(self, statement: ast.Assign, *, next: CFNode) -> CFNode:\n return self._ast_node(statement, next=next, error=s... | [
"0.6292355",
"0.6017129",
"0.58480483",
"0.5790392",
"0.57717943",
"0.57585835",
"0.5709609",
"0.5649995",
"0.56101805",
"0.5588036",
"0.5515717",
"0.550607",
"0.5487956",
"0.5476171",
"0.5472926",
"0.5407076",
"0.54064995",
"0.54023397",
"0.5397795",
"0.5369516",
"0.53665644... | 0.635177 | 0 |
stmtList = { statement } | def stmtList( ):
tok = tokens.peek( )
if debug: print( "stmtList: ", tok )
stat = statement( )
return stat | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stmts_to_stmt(statements):\n if len(statements) == 1:\n return statements[0]\n array = FakeArray(statements, arr_type=pr.Array.NOARRAY)\n return FakeStatement([array])",
"def __init__(self):\n self.Statement = []",
"def parseStmtList( tokens ):\n\n\ttok = tokens.peek( )\n\tast = list... | [
"0.6858657",
"0.6821307",
"0.6613819",
"0.6559915",
"0.64512044",
"0.63355",
"0.6250831",
"0.61308306",
"0.5997265",
"0.58391565",
"0.57354546",
"0.5710025",
"0.5697581",
"0.567703",
"0.567703",
"0.5657745",
"0.55945855",
"0.5572425",
"0.5521451",
"0.5517517",
"0.55145484",
... | 0.8045383 | 0 |
Returns ssh username for connecting to cluster workers. | def get_ssh_user():
return getpass.getuser() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ssh_user(self):\n if self.configuration.get(\"pg_ssh_user\"):\n return \"%s@\" % self.configuration.get(\"pg_ssh_user\")\n else:\n return \"%s@\" % DEFAULT_SSH_USER",
"def get_username(self) -> str:\n try:\n return self[\"user\"]\n except KeyEr... | [
"0.7331437",
"0.6813522",
"0.67854804",
"0.67478967",
"0.67478967",
"0.6733212",
"0.66904676",
"0.66705793",
"0.66705793",
"0.66705793",
"0.6658738",
"0.66570204",
"0.6605207",
"0.65863043",
"0.65245265",
"0.6501686",
"0.6480417",
"0.6475567",
"0.6475105",
"0.64678997",
"0.64... | 0.72012144 | 1 |
Returns ssh key to connecting to cluster workers. If the env var TUNE_CLUSTER_SSH_KEY is provided, then this key will be used for syncing across different nodes. | def get_ssh_key():
path = os.environ.get("TUNE_CLUSTER_SSH_KEY",
os.path.expanduser("~/ray_bootstrap_key.pem"))
if os.path.exists(path):
return path
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host_key(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"host_key\")",
"def cluster_id(self) -> str:\n return pulumi.get(self, \"cluster_id\")",
"def cluster_id(self) -> str:\n return pulumi.get(self, \"cluster_id\")",
"def cluster_id(self) -> str:\n return ... | [
"0.63742065",
"0.61436695",
"0.61436695",
"0.61436695",
"0.61436695",
"0.61436695",
"0.6095634",
"0.6095634",
"0.6095634",
"0.6095634",
"0.60669327",
"0.60669327",
"0.60669327",
"0.60669327",
"0.60669327",
"0.60669327",
"0.60596585",
"0.597747",
"0.58629495",
"0.58629495",
"0... | 0.70618993 | 0 |
writes uuids and extras of given nodes to a file (json). This is useful for import/export because currently extras are lost. Therefore this can be used to save and restore the extras on the nodes. | def export_extras(nodes, filename='node_extras.txt'):
#outstring = ''#' node uuid | extras \n'
outdict = {}
for node in nodes:
if isinstance(node, int): #pk
node = load_node(node)
elif isinstance(node, basestring): #uuid
node = load_node(node)
if not isinsta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_nodes(node, filename):\n\n with open(filename, 'w', newline='') as f:\n writer = csv.DictWriter(f,\n fieldnames=node[0].keys(),\n quoting=csv.QUOTE_ALL)\n writer.writeheader()\n writer.writerows(node)",
"def write(node... | [
"0.6882683",
"0.6683414",
"0.6664386",
"0.6651517",
"0.664519",
"0.64958185",
"0.6158971",
"0.5804926",
"0.56545246",
"0.5637596",
"0.56242365",
"0.5573552",
"0.5563774",
"0.55553705",
"0.5554492",
"0.5551853",
"0.5548628",
"0.5515836",
"0.55090535",
"0.5494786",
"0.54754364"... | 0.846316 | 0 |
reads in nodes uuids and extras from a file and aplies them to nodes in the DB. This is useful for import/export because currently extras are lost. Therefore this can be used to save and restore the extras on the nodes. | def import_extras(filename):
all_extras = {}
# read file
#inputfile = open(filename, 'r')
#lines = inputfile.readlines()
#for line in lines[1:]:
# splitted = line.split(' | ')
# uuid = splitted[0].rstrip(' ')
# extras = splitted[1].rstrip(' ')
# #extras = dict(extras)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_extras(nodes, filename='node_extras.txt'):\n\n #outstring = ''#' node uuid | extras \\n'\n outdict = {}\n for node in nodes:\n if isinstance(node, int): #pk\n node = load_node(node)\n elif isinstance(node, basestring): #uuid\n node = load_node(node)\n\n ... | [
"0.673297",
"0.5395848",
"0.5311601",
"0.5258237",
"0.5242158",
"0.52234995",
"0.50911427",
"0.5082365",
"0.50697577",
"0.5054883",
"0.49930757",
"0.4956298",
"0.4920614",
"0.49156678",
"0.48891574",
"0.4886341",
"0.48851725",
"0.48767012",
"0.48547512",
"0.4849261",
"0.48488... | 0.8099154 | 0 |
This method deletes all AiiDA nodes in the DB, which have a extra trash=True And all their children. Could be advanced to a garbage collector. Be careful to use it. | def delete_trash():
#query db for marked trash
q = QueryBuilder()
nodes_to_delete_pks = []
q.append(Node,
filters = {'extras.trash': {'==' : True}
}
)
res = q.all()
for node in res:
nodes_to_delete_pks.append(node[0].dbnode.pk)
pri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _delete_all(self):\n logging.info(\"Remove all nodes and relations from database.\")\n self.graph.delete_all()\n return",
"def DeleteAllItems(self):\r\n\r\n self.DeleteRoot()",
"def clear_db():\n humans = Human4j.nodes.all()\n for h in humans:\n h.delete()\n bino... | [
"0.75391054",
"0.7246509",
"0.6745943",
"0.6743173",
"0.66865116",
"0.66524655",
"0.6503817",
"0.64772564",
"0.6394675",
"0.63327867",
"0.6293654",
"0.62701166",
"0.6248863",
"0.6222633",
"0.6217673",
"0.6183407",
"0.61382097",
"0.6128062",
"0.61192054",
"0.6104992",
"0.60861... | 0.7323777 | 1 |
returns a list of node uuids for a given group as, name, pk, uuid or group object | def get_nodes_from_group(group, return_format='uuid'):
from aiida.orm import Group
from aiida.common.exceptions import NotExistent
nodes = []
g_nodes = []
try:
group_pk = int(group)
except ValueError:
group_pk = None
group_name = group
if group_pk is not None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getGroup(group: int, name=\"\") -> list:\n groups = mongo.db.groups.find({'id':group},{'_id':0})\n userID_list = []\n user_list = []\n for entry in groups:\n if entry[\"id\"] == group:\n userID_list = userID_list + entry[\"members\"]\n if len(userID_list) != 0:\n for ent... | [
"0.6142465",
"0.5999166",
"0.59815145",
"0.58869386",
"0.5741488",
"0.5735394",
"0.5697292",
"0.5640951",
"0.563847",
"0.56142646",
"0.55772024",
"0.5554826",
"0.5521682",
"0.5469941",
"0.5396493",
"0.5393709",
"0.53740793",
"0.5341698",
"0.5340419",
"0.5333693",
"0.53306866"... | 0.73784983 | 0 |
This function returns the default anchors given the image shapes and the anchors per grid point. The grid has width and height equal to the final's layer output. | def set_anchors(mc):
H, W, C = _get_output_shape(mc)
B = mc.ANCHOR_PER_GRID
X = np.array(mc.INITIAL_ANCHOR_SHAPES)
X[:,0] *= mc.IMAGE_WIDTH
X[:,1] *= mc.IMAGE_HEIGHT
anchor_shapes = np.reshape( # it refers to the anchor width and height
[X] * H * W,
(H, W, B, 2)
)
center_x = np.reshape(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_grid_anchors(grid_sizes, strides, cell_anchors):\n anchors = []\n assert cell_anchors is not None\n\n for size, stride, base_anchors in zip(grid_sizes, strides, cell_anchors):\n grid_height, grid_width = size\n stride_height, stride_width = stride\n\n # For output anchor, comp... | [
"0.71884936",
"0.7036838",
"0.70205647",
"0.692611",
"0.6890038",
"0.6888356",
"0.68680495",
"0.6852056",
"0.68242455",
"0.6721483",
"0.6713985",
"0.6680048",
"0.6649211",
"0.6587107",
"0.6582483",
"0.6504692",
"0.6504201",
"0.65007716",
"0.64910555",
"0.6475948",
"0.64250964... | 0.73078704 | 0 |
Returns a list of created posts for the given author | def create_multiple_posts(author, num, ptext = TEXT, visibility = ACL_DEFAULT):
posts = []
for i in range(num):
posts.append(Post.objects.create(content = ptext, author = author, visibility=visibility))
return posts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\r\n\r\n user = get_object_or_404(User, username=self.kwargs.get('username'))\r\n return Post.objects.filter(author=user).order_by('-date_posted')",
"def get_queryset(self):\n id = self.kwargs['pk']\n target_author=get_object_or_404(Author, pk = id)\n ret... | [
"0.6751652",
"0.6719958",
"0.6679745",
"0.64851755",
"0.6355382",
"0.63139474",
"0.6307772",
"0.62711054",
"0.6250475",
"0.62041193",
"0.61662126",
"0.6099204",
"0.6088763",
"0.60696316",
"0.6060949",
"0.59918046",
"0.59400725",
"0.58352584",
"0.58273214",
"0.58035225",
"0.57... | 0.6749558 | 1 |
Test to ensure that all authors added to relationship are in the returned data Called after a retrieve relationship test has passed | def authors_in_relation(context, data, authors):
guids = [a.id for a in authors]
guids = map( lambda x: str(x).replace('-', ''), guids)
for guid in guids:
context.assertTrue(unicode(guid) in data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_authors(self):\n sample_author()\n sample_author()\n\n res = self.client.get(reverse('authors'))\n authors = Author.objects.all()\n serializer = AuthorSerializer(authors, many=True)\n self.assertEqual(res.data, serializer.data)\n self.assertEqual(r... | [
"0.719106",
"0.6605452",
"0.65803057",
"0.64502394",
"0.6409618",
"0.6390426",
"0.62981063",
"0.6223942",
"0.6172895",
"0.6143107",
"0.6092482",
"0.60106426",
"0.5917884",
"0.587733",
"0.5856236",
"0.5841362",
"0.58273274",
"0.5820912",
"0.5778369",
"0.5765315",
"0.574128",
... | 0.7145637 | 1 |
Create Friends and Friends of Friends and associated posts | def create_friends(friend, friendors, create_post = True, visibility = ACL_DEFAULT):
for friendor in friendors:
friend.add_friend(friendor)
friendor.add_friend(friend)
# FriendRelationship.objects.create(friendor = friendor, friend = friend)
if create_post:
Post.objects.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_friend(request, profile_pk, friend_pk):\n\n profile_object = Profile.objects.get(pk=profile_pk)\n friend_object = profile_object.get_friend_suggestions().get(pk=friend_pk)\n \n profile_object.friends.add(friend_object)\n profile_object.save()\n\n return redirect(reverse('show_profile_page... | [
"0.6206124",
"0.60353947",
"0.5980641",
"0.5965954",
"0.59487104",
"0.56830245",
"0.56672275",
"0.56354594",
"0.56294787",
"0.55971295",
"0.55717593",
"0.5568948",
"0.5557959",
"0.5542263",
"0.54640216",
"0.54584336",
"0.54564565",
"0.54361814",
"0.5435222",
"0.54146063",
"0.... | 0.7941469 | 0 |
Takes post author, comment author and creates a post and associated comment | def create_post_with_comment(pauthor, cauthor, visibility, ptext, ctext):
post = Post.objects.create(content = ptext, author = pauthor, visibility=visibility)
comment = Comment.objects.create(comment = ctext, post = post, author = cauthor)
return (post, comment) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_comment(post, author, content):\n return Comment.objects.create(post=post, author=author, content=content)",
"def postCreate(post):\n post_list = list()\n comments = commentList(post)\n comment_url = \"{}/api/posts/{}/comments\".format(DOMAIN, post.id)\n visible_to = list()\n visible... | [
"0.7968736",
"0.69776434",
"0.680873",
"0.6670445",
"0.6624297",
"0.6575736",
"0.6529041",
"0.6456722",
"0.64194477",
"0.6396711",
"0.6375334",
"0.6340401",
"0.63245595",
"0.6278583",
"0.62078166",
"0.6168181",
"0.6167977",
"0.61602026",
"0.61574775",
"0.6155002",
"0.6143866"... | 0.79196894 | 1 |
Takes response.data and confirms no repeated guids (No repeated posts) | def assertNoRepeatGuids(context, posts):
guids = [p['guid'] for p in posts]
context.assertTrue(len(set(guids)) == len(posts), "Some guids repeated") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_response_reusage_after_replied(self):\n\n post1 = self._create_tweet(\n content=\"I need a foo.\",\n channel=self.inbound,\n demand_matchables=True)\n\n resp1 = Response.objects.upsert_from_post(post1)\n\n support = UserProfile.objects.upsert('Twitter'... | [
"0.5659422",
"0.55370516",
"0.5480621",
"0.5440656",
"0.5439443",
"0.5430286",
"0.53764886",
"0.53743136",
"0.5368204",
"0.53578305",
"0.53345466",
"0.532668",
"0.530157",
"0.5287817",
"0.5268618",
"0.52629507",
"0.5260671",
"0.5257835",
"0.5253612",
"0.52466136",
"0.52329594... | 0.6993569 | 0 |
Compares a list of authors against a list of displaynames | def cross_check(context, authors, poscom):
displaynames = [x['author']['displayname'] for x in poscom]
for author in authors:
if author.user.username not in displaynames:
context.assertFalse(True, "%s not in list" %author.user.username) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_authors( data ) :\n return list(set( chain.from_iterable( [ authors(x) for x in data ] ) ))",
"def display_authors(self, *args):\n return ', '.join(author.name for author in args[0].authors.all()[:3])",
"def test_author_many_lastnames(self):\n inv_search = 'author:\"alvarez gaume, ... | [
"0.64632857",
"0.63929",
"0.6384049",
"0.6332246",
"0.62227446",
"0.6216081",
"0.6199922",
"0.615091",
"0.6108188",
"0.6102564",
"0.6097298",
"0.6095483",
"0.6072117",
"0.60518503",
"0.59991443",
"0.5962012",
"0.595125",
"0.59264",
"0.5892751",
"0.5881848",
"0.5834737",
"0.... | 0.68802696 | 0 |
Cross checks a list of authors against post | def assertAuthorsInPosts(context, authors, posts):
cross_check(context, authors, posts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_check(context, authors, poscom):\n displaynames = [x['author']['displayname'] for x in poscom]\n\n for author in authors:\n if author.user.username not in displaynames:\n context.assertFalse(True, \"%s not in list\" %author.user.username)",
"def author_ManyToMany_entry_check(): ... | [
"0.72640485",
"0.6881462",
"0.6769553",
"0.65692633",
"0.6538516",
"0.63877165",
"0.6319493",
"0.62692463",
"0.60791737",
"0.6033017",
"0.5904452",
"0.5835843",
"0.58165914",
"0.579224",
"0.5788046",
"0.57680523",
"0.57557714",
"0.5726369",
"0.5697314",
"0.56669766",
"0.56610... | 0.7797011 | 0 |
Cross checks a list of authors against comments | def assertAuthorsInComments(context, authors, comments):
cross_check(context, authors, comments) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_check(context, authors, poscom):\n displaynames = [x['author']['displayname'] for x in poscom]\n\n for author in authors:\n if author.user.username not in displaynames:\n context.assertFalse(True, \"%s not in list\" %author.user.username)",
"def assertAuthorsInPosts(context, aut... | [
"0.74669504",
"0.65934074",
"0.6494307",
"0.6315845",
"0.6253867",
"0.62438315",
"0.61274093",
"0.6090594",
"0.5927208",
"0.59244573",
"0.58965456",
"0.5887174",
"0.58157754",
"0.579177",
"0.57523257",
"0.5713481",
"0.5709423",
"0.5708671",
"0.5706471",
"0.56644917",
"0.56633... | 0.7966482 | 0 |
Takes a list of cachedauthors and adds them to the author follower list | def create_cached_author_followers(author, followers):
for f in followers:
author.followers.add(f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addAuthor2():\n\n author_list = list()\n\n authors = Author.objects.all()\n\n for author in authors:\n author_dict = dict()\n author_dict['id'] = \"{}/api/author/{}\".format(DOMAIN, author.id)\n author_dict['host'] = \"{}/api/\".format(author.host_url)\n author_dict['displa... | [
"0.64747363",
"0.6431524",
"0.6423831",
"0.6329321",
"0.6274541",
"0.6242031",
"0.6238875",
"0.62265736",
"0.6178677",
"0.61373085",
"0.6131011",
"0.6087273",
"0.60318464",
"0.59967387",
"0.5986646",
"0.5947148",
"0.5934538",
"0.5911428",
"0.59073174",
"0.590661",
"0.59045154... | 0.81595033 | 0 |
Creates an interior node with the given operator (a token), and left and right operands (other nodes). | def __init__(self, opToken, leftOper, rightOper):
self.operator = opToken
self.leftOperand = leftOper
self.rightOperand = rightOper | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __create_internal_node_by_operator(operator: PatternStructure, sliding_window: timedelta, parent: Node = None):\n operator_type = operator.get_top_operator()\n if operator_type == SeqOperator:\n return SeqNode(sliding_window, parent)\n if operator_type == AndOperator:\n ... | [
"0.6768396",
"0.6402284",
"0.6212105",
"0.6038182",
"0.6029708",
"0.59814626",
"0.59771395",
"0.5969799",
"0.57881653",
"0.57876146",
"0.57825124",
"0.57195956",
"0.56935775",
"0.56912225",
"0.56751347",
"0.559061",
"0.5583933",
"0.5532599",
"0.54641896",
"0.5460819",
"0.5419... | 0.66272795 | 1 |
Returns the expression in prefix form. | def prefix(self):
return str(self.operator) + " " + self.leftOperand.prefix() + " " + self.rightOperand.prefix() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_prefix_expression(cls, expression):\n\t\tlogger.info(f\"in the calculate prefix expression {expression}\")\n\t\telements = expression.split()\n\t\tstack = []\n\t\tfor e in reversed(elements):\n\t\t\tif e.isdigit():\n\t\t\t\tstack.append(int(e))\n\t\t\telse:\n\t\t\t\t# this is an operator\n\t\t\t\tif ... | [
"0.710734",
"0.6866923",
"0.6425482",
"0.63313454",
"0.63313454",
"0.63225156",
"0.63132906",
"0.6267651",
"0.62378424",
"0.62378424",
"0.62378424",
"0.6218811",
"0.6152476",
"0.6141088",
"0.6069823",
"0.6069823",
"0.6055349",
"0.60520095",
"0.6048974",
"0.60268766",
"0.59823... | 0.7265404 | 0 |
Returns the expression in infix form (fully parenthesized). | def infix(self):
return "(" + self.leftOperand.infix() + " " + str(self.operator) + " " + self.rightOperand.infix() + ")" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_infix(string):\n return postfix(infix_to_postfix(string))",
"def infix_to_prefix(self, expr: str) -> str:\n\n # Reverse expr\n expr = reversed(expr)\n\n # Convert expr to list\n expr = list(expr)\n\n # Reverse all parantheses\n for i, e in enumerate(expr)... | [
"0.71687776",
"0.70765674",
"0.70678484",
"0.70356464",
"0.69882065",
"0.6876605",
"0.6813432",
"0.6722101",
"0.6542399",
"0.6502566",
"0.648048",
"0.64614725",
"0.645874",
"0.63886565",
"0.63599867",
"0.632505",
"0.626854",
"0.6246395",
"0.62401587",
"0.62371445",
"0.6197802... | 0.81181073 | 0 |
Returns all possible velocity dispersons from all particles found in the data set. A particle filter can be passed using "filter" which is a list | def compute_velocity_dispersion(data, types = None, fields = None, filter = None):
types_to_fields = {'x': 'particle_velocity_x',
'y': 'particle_velocity_y',
'z': 'particle_velocity_z',
'r': 'particle_velocity_spherical_radius',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_velocities(self):\n\n return np.array([p.velocity for p in self.particles])",
"def particle_forceV(R,N,sigma,epsilon,D):\n F = np.zeros((3,N))\n x = np.zeros(N-1)\n y = np.zeros(N-1)\n z = np.zeros(N-1)\n r = np.zeros(N-1)\n # loop over all particles\n for i in range(N):\n ... | [
"0.5962206",
"0.57577115",
"0.5713186",
"0.56626225",
"0.56291974",
"0.5555897",
"0.5501763",
"0.5466105",
"0.54309624",
"0.54021454",
"0.5381622",
"0.53503567",
"0.53398895",
"0.5317946",
"0.52965754",
"0.5289197",
"0.5287057",
"0.52832603",
"0.52564645",
"0.5244272",
"0.523... | 0.6084097 | 0 |
This api does not return xml | def xml(self):
raise NotImplementedError('This api does not return xml') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml(self, request):\n raise Exception(\"Not Implemented\")",
"def content_api_xml(url, request):\n headers = {'content-type': 'application/xml'}\n content = 'xml string'\n return response(status_code=200,\n content=content,\n headers=h... | [
"0.6906242",
"0.681684",
"0.66007024",
"0.64178306",
"0.6360245",
"0.629127",
"0.61903584",
"0.61852777",
"0.6081651",
"0.6022426",
"0.6001489",
"0.5988445",
"0.59532",
"0.5934724",
"0.5896389",
"0.5798428",
"0.57974744",
"0.57974744",
"0.5797071",
"0.5797071",
"0.576466",
... | 0.75670606 | 0 |
Returns whether erorr is NOAUTH | def noauth(self):
try:
# some endpoints dont return json
return self.json['response'].get('error_id') == 'NOAUTH'
except:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_error():\n return unauthorized('Invalid credentials')",
"def unauthorized():\n return HttpError(401)",
"def check_auth_none(self, username):\n return AUTH_FAILED",
"def test_no_auth(self) -> None:\n channel = self.make_request(\"GET\", self.url, {})\n\n self.assertEqual(40... | [
"0.7120319",
"0.70609397",
"0.7014564",
"0.6881835",
"0.6881835",
"0.6855839",
"0.67338675",
"0.67045474",
"0.66409737",
"0.66409737",
"0.66238505",
"0.6619812",
"0.66152024",
"0.659969",
"0.65859014",
"0.6582713",
"0.6556535",
"0.6549733",
"0.6540464",
"0.6489589",
"0.648874... | 0.81090945 | 0 |
Verify can select Maven option | def test_should_choose_maven(self):
search_str = "//*[text()='Maven Project']"
els = self.driver.find_elements_by_xpath(search_str)
self.assertGreater(len(els), 0, 'Maven project is not found!')
els[0].click() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_install_project(self):\n return True",
"def test_target_repo(self):\n # network may be unavailable, but we are not interested anyway,\n # so we ignore the exitcode\n output = self.run_command(\"selfupdate --check bennr01:dev\", exitcode=None)\n self.assertIn(\"Target: b... | [
"0.56208634",
"0.5418946",
"0.5402192",
"0.5377991",
"0.53591835",
"0.53054255",
"0.5300273",
"0.52879065",
"0.52866113",
"0.5282876",
"0.52460307",
"0.5236804",
"0.5199385",
"0.51885027",
"0.5179016",
"0.5172662",
"0.5153789",
"0.5144154",
"0.5144154",
"0.51356703",
"0.50819... | 0.7265652 | 0 |
Checks that all transformers in self.transformer_list are compatible with methods fit, transform and fit_transform. | def _check_transformers(self):
assert all([hasattr(trf, "fit") for trf in self.transformer_list]), "At least one transformer object is not " \
"compatible with 'fit' method."
assert all([hasattr(trf, "transform") for trf in sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_transforms(self):\n if len(self.transforms) > 1:\n for transform in self.transforms:\n if transform.applies is None:\n raise ValueError(\n 'If more than one transform is provided, each '\n 'provided tran... | [
"0.6600919",
"0.6600919",
"0.6245045",
"0.60071653",
"0.60061026",
"0.597027",
"0.5953561",
"0.57135946",
"0.566122",
"0.5652529",
"0.5621234",
"0.55733705",
"0.5559613",
"0.5533336",
"0.54827064",
"0.5438628",
"0.5429233",
"0.5416639",
"0.5386236",
"0.53803736",
"0.5358731",... | 0.9007204 | 0 |
Deduce correct spark dtype from pandas dtype for column col of pandas dataframe df | def infer_spark_dtype(df, col):
logger = logging.getLogger(__name__ + ".infer_spark_dtype")
pd_dtype = df.dtypes[col]
# get a sample from column col
sample = df[col].dropna()
if sample.shape[0] == 0:
logger.warning("column %s of dtype %s containing nulls found" % (col, pd_dtype))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_dtype(data_df, settings):\n data_df = data_df.astype(settings[\"dtype\"])\n return data_df",
"def change_col_type(df,schema):\n d = {'int':IntegerType(),'str':StringType(),'float':FloatType(),'bool':BooleanType()}\n \n for c,t in schema.items():\n df = df.withColumn(c,col(c).cas... | [
"0.72055167",
"0.70074373",
"0.67383504",
"0.66940576",
"0.66150796",
"0.65282935",
"0.64637434",
"0.64026904",
"0.63992226",
"0.63900924",
"0.63755214",
"0.63500774",
"0.6339335",
"0.63325894",
"0.6327806",
"0.63060737",
"0.62946403",
"0.62688094",
"0.6235217",
"0.6229606",
... | 0.7871534 | 0 |
Run a command and echo it first | def run_cmd(call, cmd, *, echo=True, **kwargs):
if echo:
print('$> ' + ' '.join(map(pipes.quote, cmd)))
return call(cmd, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(command):\n if arguments['--dry-run']:\n print command\n else:\n subprocess.call(command, shell=True)",
"async def terminal(event):\r\n command = utils.raw(event.message)\r\n await event.edit(f\"**Running command:**\\n`{command}`\")\r\n result = subprocess.getoutput(command)\... | [
"0.69847924",
"0.6959119",
"0.69450945",
"0.6919458",
"0.6859296",
"0.6812634",
"0.67663026",
"0.6756266",
"0.67383146",
"0.67201954",
"0.670066",
"0.6692517",
"0.66810435",
"0.6675754",
"0.6665769",
"0.6646724",
"0.65908474",
"0.6578724",
"0.65752876",
"0.6571929",
"0.656086... | 0.696063 | 1 |
Get the last commit to modify the given paths | def last_modified_commit(*paths, **kwargs):
return check_output([
'git',
'log',
'-n', '1',
'--pretty=format:%h',
'--',
*paths
], **kwargs).decode('utf-8') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_diff_to_last_commit(path_to_repository, ignore_subrepositories):\n repo = Repo(path_to_repository)\n if ignore_subrepositories==True:\n unstaged_diff = repo.index.diff(other=None, paths=None, create_patch=False, ignore_submodules=\"all\")\n staged_diff = repo.head.commit.diff(other=Dif... | [
"0.66357094",
"0.646586",
"0.64447695",
"0.6435589",
"0.6427532",
"0.6335761",
"0.629556",
"0.6295136",
"0.6277516",
"0.6207843",
"0.6153193",
"0.61308944",
"0.6121598",
"0.6120476",
"0.60908526",
"0.5947546",
"0.5922661",
"0.5920262",
"0.5910456",
"0.58968264",
"0.5894823",
... | 0.7615342 | 0 |
Return the last modified date (as a string) for the given paths | def last_modified_date(*paths, **kwargs):
return check_output([
'git',
'log',
'-n', '1',
'--pretty=format:%cd',
'--date=iso',
'--',
*paths
], **kwargs).decode('utf-8') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_date_modified(path):\n return str(datetime.datetime.fromtimestamp(os.path.getmtime(path)))",
"def _get_last_modified_date(path):\n last_date = 0\n root_dir, subdirs, files = os.walk(path).next()\n # get subdirs and remove hidden ones\n subdirs = [s for s in subdirs if not s.startswith... | [
"0.8046738",
"0.7416479",
"0.7245152",
"0.7219578",
"0.71944565",
"0.6939524",
"0.67891824",
"0.6737202",
"0.6734333",
"0.67058384",
"0.6656483",
"0.6634494",
"0.6624429",
"0.6620233",
"0.6591059",
"0.6591059",
"0.65882814",
"0.6566373",
"0.6562852",
"0.6555743",
"0.6548625",... | 0.7935193 | 1 |
Return whether the given paths have been changed in the commit range Used to determine if a build is necessary | def path_touched(*paths, commit_range):
return check_output([
'git', 'diff', '--name-only', commit_range, '--', *paths
]).decode('utf-8').strip() != '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_rev_dirty(ctx: \"PlanemoCliContext\", directory: str) -> bool:\n return io.shell([\"git\", \"diff\", \"--quiet\"], cwd=directory) != 0",
"def _can_checkout(wit_path) -> bool:\n\n current_id = _get_head(wit_path)\n changes_to_be_committed = _return_as_string(_get_changes_to_be_committed, wit_path,... | [
"0.6485178",
"0.64627033",
"0.63761",
"0.6337259",
"0.6332157",
"0.6283598",
"0.6267245",
"0.6246275",
"0.6215795",
"0.6191025",
"0.6181917",
"0.6179466",
"0.6164216",
"0.6145015",
"0.6080553",
"0.6079178",
"0.6058201",
"0.6047565",
"0.6034595",
"0.6026013",
"0.6012013",
"0... | 0.8217679 | 0 |
Get docker build args dict, rendering any templated args. | def render_build_args(options, ns):
build_args = options.get('buildArgs', {})
for key, value in build_args.items():
build_args[key] = value.format(**ns)
return build_args | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def docker_build_context(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"docker_build_context\")",
"def docker_build_context(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"docker_build_context\")",
"def read_dockerfile_for_args(target):\n import colorama\n... | [
"0.64995056",
"0.6460428",
"0.5992242",
"0.59243613",
"0.5775845",
"0.56487375",
"0.5570073",
"0.5546533",
"0.5522067",
"0.5497052",
"0.5493939",
"0.54721403",
"0.5428458",
"0.5366059",
"0.5361795",
"0.535775",
"0.5269126",
"0.5204375",
"0.5196358",
"0.51938367",
"0.518926",
... | 0.7038579 | 0 |
Cached getter for docker client | def docker_client():
return docker.from_env() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_docker_client(self) -> \"DockerClient\":",
"def docker_client():\n client = docker.from_env()\n return client",
"def get_client():\n info = {}\n host = os.environ.get('DOCKER_HOST')\n net_host = os.environ.get('DOCKER_NET_HOST')\n\n client_api_version = os.environ.get('DOCKER_AP... | [
"0.7949226",
"0.6975132",
"0.69293606",
"0.6704719",
"0.6433767",
"0.6314111",
"0.6047752",
"0.59885114",
"0.59635204",
"0.5917807",
"0.5916698",
"0.5907519",
"0.5857684",
"0.58574104",
"0.58456975",
"0.5838481",
"0.58354545",
"0.58210045",
"0.58168083",
"0.58074665",
"0.5708... | 0.72880656 | 1 |
Return whether an image needs pushing | def image_needs_pushing(image):
d = docker_client()
try:
d.images.get_registry_data(image)
except docker.errors.APIError:
# image not found on registry, needs pushing
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PrePush(self, image):\n pass",
"def hasImage(self):\n if self.getImage():\n return True\n return False",
"def _pushing(pushop):\n return bool(\n pushop.outgoing.missing\n or pushop.outdatedphases\n or pushop.outobsmarkers\n or pushop.outbookmarks\n... | [
"0.67209774",
"0.66439164",
"0.6631148",
"0.656371",
"0.64065194",
"0.63889164",
"0.6336889",
"0.6315508",
"0.6282437",
"0.6282437",
"0.62279326",
"0.61669666",
"0.6137131",
"0.6032941",
"0.6019985",
"0.59767556",
"0.5969536",
"0.59661514",
"0.5943",
"0.5921205",
"0.59130216"... | 0.7235848 | 0 |
Return whether an image needs building Checks if the image exists (ignores commit range), either locally or on the registry. | def image_needs_building(image):
d = docker_client()
# first, check for locally built image
try:
d.images.get(image)
except docker.errors.ImageNotFound:
# image not found, check registry
pass
else:
# it exists locally, no need to check remote
return False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_needs_pushing(image):\n d = docker_client()\n try:\n d.images.get_registry_data(image)\n except docker.errors.APIError:\n # image not found on registry, needs pushing\n return True\n else:\n return False",
"def check_image(self, tag):\n image_name = self.b... | [
"0.74606645",
"0.7137432",
"0.70654684",
"0.6916333",
"0.6890094",
"0.6849104",
"0.68168086",
"0.6784783",
"0.6744717",
"0.66717255",
"0.6600988",
"0.6536723",
"0.65264153",
"0.65185374",
"0.650834",
"0.6502069",
"0.6478776",
"0.6386925",
"0.6359315",
"0.6355004",
"0.6343484"... | 0.8575527 | 0 |
Update name/values.yaml with modifications | def build_values(name, values_mods):
values_file = os.path.join(name, 'values.yaml')
with open(values_file) as f:
values = yaml.load(f)
for key, value in values_mods.items():
parts = key.split('.')
mod_obj = values
for p in parts:
mod_obj = mod_obj[p]
pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _write_values(self, app_name, chart_dir, values):\n\n data = self._get_values(app_name, chart_dir)\n new_data = {**data, **values}\n new_raw = yaml.dump(new_data)\n\n values_path = \"%s/%s/values.yaml\" % (chart_dir, app_name)\n with open(values_path, mode=\"w\") as values_fi... | [
"0.6856736",
"0.6455863",
"0.6232132",
"0.6048177",
"0.5998861",
"0.5927065",
"0.5708528",
"0.56122386",
"0.5609265",
"0.560229",
"0.5582246",
"0.55429924",
"0.552479",
"0.5504513",
"0.54904646",
"0.54742396",
"0.54720205",
"0.54367936",
"0.54282165",
"0.53917795",
"0.5384969... | 0.69657123 | 0 |
Publish helm chart index to github pages | def publish_pages(name, paths, git_repo, published_repo, extra_message=''):
version = last_modified_commit(*paths)
checkout_dir = '{}-{}'.format(name, version)
check_call([
'git', 'clone', '--no-checkout',
git_remote(git_repo), checkout_dir],
echo=False,
)
check_call(['git', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template(c, release=\"url-shortener\"):\n c.run(f\"helm template {release} {HELM_CHART_DIR} > ./generated-deployment.yml\")",
"def index():\n return render_template(\"charts.html\")",
"def main():\n \n root = Folder(name=os.getcwd(), file='meta.json',\n collection='.github/jeky... | [
"0.6303632",
"0.5992799",
"0.59895986",
"0.56986564",
"0.5615526",
"0.55472004",
"0.5513828",
"0.53691167",
"0.5364688",
"0.5286044",
"0.5263749",
"0.52587676",
"0.5251907",
"0.5230299",
"0.5216074",
"0.52005446",
"0.5190611",
"0.5182666",
"0.5175446",
"0.51723653",
"0.516488... | 0.6350673 | 0 |
Add the domain restrictions. | def add_domains_restriction(self, domain_restriction):
self._domain_restricion = domain_restriction
self._size_var = self._get_size_var()
self._nr_of_bits = self._get_nr_of_bits() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_domain_restrictions(self):\n for index, restriction in enumerate(self._domain_restrictions):\n self.add_specific_domain_restriction(index+1, restriction)",
"async def setjradd(self, ctx, domain):\n allowedDomains = await self.config.guild(ctx.guild).allowedDomains()\n ... | [
"0.7922115",
"0.623785",
"0.60880244",
"0.5960196",
"0.58387566",
"0.57663685",
"0.5692345",
"0.5655885",
"0.56333846",
"0.55938256",
"0.558293",
"0.5558514",
"0.55429906",
"0.5535729",
"0.5511199",
"0.54556143",
"0.5452144",
"0.54225695",
"0.54151505",
"0.54145116",
"0.53412... | 0.7894003 | 1 |
Get the number of bits needed for an item. | def _get_nr_of_bits(self):
return sum(self._size_var) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\r\n return numBits(self.n)",
"def number_of_bits(self) -> int:\n raise NotImplementedError('To be Overidden by the derived class')",
"def bitSizeOf(self) -> int:\n\n return self._numBits",
"def bitSizeOf(self) -> int:\n\n return self._numBits",
"def number_of_... | [
"0.7077946",
"0.70436716",
"0.69864804",
"0.69864804",
"0.6966107",
"0.68727595",
"0.68669325",
"0.68431276",
"0.6806957",
"0.67431825",
"0.67405957",
"0.6726725",
"0.66758716",
"0.6658841",
"0.6658841",
"0.6658841",
"0.6658841",
"0.6658841",
"0.6658841",
"0.6658841",
"0.6658... | 0.7367046 | 0 |
Get a random genom. | def get_random(self):
base_genom = "1" * sum(self._size_var)
return utils.randomise_a_string(base_genom) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_genome(self):\n return random.choice(self.genomes)",
"def generate_random_individual():\n genotype = []\n ### Your code here\n return {'genotype': genotype, 'fitness': None }",
"def random_gene(self):\n size = random.randint(1,50)\n gene = \"\"\n for i in ran... | [
"0.7129977",
"0.68136334",
"0.65213746",
"0.64397925",
"0.6434923",
"0.6387772",
"0.63817495",
"0.6367737",
"0.63332325",
"0.63026583",
"0.62996596",
"0.6297405",
"0.6288606",
"0.62817526",
"0.62786907",
"0.6232036",
"0.6221588",
"0.6218463",
"0.61816496",
"0.6164786",
"0.612... | 0.6945635 | 1 |
Create a new block cipher, configured in CTR mode. | def __init__(self, block_cipher, initial_counter_block,
prefix_len, counter_len, little_endian):
if len(initial_counter_block) == prefix_len + counter_len:
self.nonce = _copy_bytes(None, prefix_len, initial_counter_block)
"""Nonce; not available if there is a fixed suff... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_ctr_cipher(factory, **kwargs):\n\n cipher_state = factory._create_base_cipher(kwargs)\n\n counter = kwargs.pop(\"counter\", None)\n nonce = kwargs.pop(\"nonce\", None)\n initial_value = kwargs.pop(\"initial_value\", None)\n if kwargs:\n raise TypeError(\"Invalid parameters for CTR... | [
"0.7619631",
"0.7126915",
"0.67098886",
"0.65550065",
"0.6327081",
"0.62329865",
"0.6143115",
"0.60997117",
"0.60525525",
"0.59431106",
"0.59406626",
"0.588603",
"0.5855224",
"0.5798523",
"0.5777665",
"0.573847",
"0.5719348",
"0.5686902",
"0.5685684",
"0.56328213",
"0.55945",... | 0.714244 | 1 |
Instantiate a cipher object that performs CTR encryption/decryption. | def _create_ctr_cipher(factory, **kwargs):
cipher_state = factory._create_base_cipher(kwargs)
counter = kwargs.pop("counter", None)
nonce = kwargs.pop("nonce", None)
initial_value = kwargs.pop("initial_value", None)
if kwargs:
raise TypeError("Invalid parameters for CTR mode: %s" % str(kwa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, block_cipher, initial_counter_block,\n prefix_len, counter_len, little_endian):\n\n if len(initial_counter_block) == prefix_len + counter_len:\n self.nonce = _copy_bytes(None, prefix_len, initial_counter_block)\n \"\"\"Nonce; not available if there is... | [
"0.72857714",
"0.7123023",
"0.6978616",
"0.6857513",
"0.6587187",
"0.6543356",
"0.65047663",
"0.645677",
"0.64431256",
"0.6244246",
"0.6212461",
"0.618751",
"0.60572654",
"0.6051523",
"0.6047843",
"0.6029323",
"0.592563",
"0.5921373",
"0.5918702",
"0.59144205",
"0.5887465",
... | 0.7571308 | 0 |
Execute the sequence of SQL statements in {sql} as a single command | def execute(self, *sql):
# assemble the command and pass it on to the connection
return self.postgres.execute(self.connection, "\n".join(sql)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(self,sql):\n # self.results = self.execute_silent(sql)\n # return self.results\n # sql = self.format_sql(sql, **kwargs)\n sql_list = sql.split(';')\n for stmt in sql_list:\n if stmt:\n stmt = stmt.strip()\n if len(stmt) < 10:\n... | [
"0.7174249",
"0.7070815",
"0.70517427",
"0.7040094",
"0.7025959",
"0.6985139",
"0.6980579",
"0.6964437",
"0.69108903",
"0.6902813",
"0.6886875",
"0.6844708",
"0.6828679",
"0.6801381",
"0.67388976",
"0.67349917",
"0.67162806",
"0.66934794",
"0.66897595",
"0.66596186",
"0.66156... | 0.7186094 | 0 |
Return default zoom setting. | def _defaultZoom(self):
return (-1.0, 1.0, -1.0, 1.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zoom(self):\n return self['zoom']",
"def zoom(self):\n return self.container['zoom']",
"def _get_zoom(self) :\n \n # TODO : make it absolute zoom value : a zoom of 1 displays one data\n # pixel in one viewport pixel.\n \n return self._zoom",
"def zoom(self... | [
"0.7723424",
"0.7299348",
"0.72973317",
"0.71936",
"0.70050627",
"0.68496126",
"0.65712726",
"0.625384",
"0.6145273",
"0.6142065",
"0.61153233",
"0.6006282",
"0.5985987",
"0.5982547",
"0.59785664",
"0.59773666",
"0.5952824",
"0.58633906",
"0.5851663",
"0.58423215",
"0.5797127... | 0.8090395 | 0 |
Approximates root of this function using single iteration of Newton's method. | def newtonsMethod(self, x, a):
return x - a * (self._f(x) / self._df(x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newton(f, xinit, tol, N):\n if f(xinit) < tol:\n return xinit\n else:\n n = 1\n while n < N:\n xnew = xinit - (f(xinit) / derivative(f, xinit))\n if abs(f(xnew)) < tol:\n print('Root found. Number of iterations: ', n)\n return xnew\... | [
"0.7563373",
"0.75321746",
"0.7448436",
"0.74475104",
"0.7388106",
"0.7297471",
"0.7297028",
"0.72617483",
"0.72546536",
"0.7249506",
"0.72134876",
"0.7199049",
"0.7197292",
"0.71775806",
"0.71667355",
"0.71341896",
"0.71326596",
"0.7126753",
"0.7094095",
"0.7091968",
"0.7057... | 0.76958627 | 0 |
Converts the generated fractal into an RGB image array | def _toRgbImage(self, fractal, colors, color_offset):
soln_real = adjustRange(fractal[0], 0, 127)
soln_imag = adjustRange(fractal[1], 0, 127)
iters = adjustRange(fractal[2], 0, 128)
rgb_image = np.array([
soln_real + iters,
soln_imag + iters,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _colored_img_to_arr(image, verbose=False):\n height, width = image.size\n arr = np.array(image.getdata())\n arr = arr.reshape(3, height, width)\n r = arr[0]\n g = arr[1]\n b = arr[2]\n return r, g, b",
"def _toRgbImage(self, fractal, colors, color_offset):\n hsv_img = np.array(\n ... | [
"0.7032956",
"0.6756124",
"0.6748998",
"0.66770595",
"0.64644593",
"0.6463771",
"0.64612466",
"0.6436402",
"0.6378915",
"0.6336183",
"0.6302488",
"0.6263761",
"0.624275",
"0.6217485",
"0.62155837",
"0.61859244",
"0.61853856",
"0.61381644",
"0.61203206",
"0.60929006",
"0.60567... | 0.70360917 | 0 |
checking return values for `start` and `end` when calling channel_messages for numbers not multiples of 50. | def test_channel_messages_unlimited_pagination():
clear()
userOne = auth_register('firstuser@gmail.com', '123abc!@#', 'First', 'User')
randChannel = channels_create(userOne['token'], 'randChannel', True)
for _ in range(149):
message_send(userOne['token'], randChannel['channel_id'], 'Hello')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def channel_messages(token, channel_id, start):\n # Check if token is valid and raise AccessError if not\n curr_id = database.get_current_user(token)\n\n # check if user is a member of channel with channel_ID and return AccessError if not\n if is_user_channel_member(channel_id, curr_id) is False:\n ... | [
"0.6338927",
"0.58790916",
"0.53648764",
"0.53105456",
"0.52494335",
"0.5227476",
"0.519632",
"0.51526994",
"0.5122233",
"0.5106034",
"0.50966465",
"0.50898653",
"0.50656456",
"0.5056774",
"0.50472474",
"0.50439817",
"0.5038363",
"0.50265247",
"0.50246954",
"0.50190175",
"0.5... | 0.6797525 | 0 |
checking if the user is already in the channel, raise accesserror if they are | def test_channel_join_already_in_channel():
clear()
user = auth_register('user@gmail.com', '123abc!@#', 'first', 'last')
userchannel_id = channels_create(user['token'], 'userchannel', True)
with pytest.raises(AccessError):
channel_join(user['token'], userchannel_id['channel_id']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def have_channel_open(channels, user):\n for x in channels:\n chan = channels[x]\n if 'is_member' in chan:\n continue\n if chan['user'] == user:\n return True\n return False",
"def have_channel_open(channels, user):\n for x in channels:\n chan = chan... | [
"0.6544167",
"0.6521434",
"0.64236474",
"0.6420696",
"0.63337475",
"0.63098836",
"0.6305338",
"0.62802494",
"0.6259734",
"0.6218568",
"0.6136835",
"0.60846996",
"0.6068947",
"0.6049151",
"0.6002369",
"0.59844506",
"0.597856",
"0.5952112",
"0.5945146",
"0.5934715",
"0.59036577... | 0.7157796 | 0 |
if the channel is private, but no invite is given to the user, then the owner of flockr can join the channel | def test_channel_join_private_owner():
clear()
joiner = auth_register('joiner@gmail.com', '123abc!@#', 'first', 'last')
user = auth_register('user@gmail.com', '123abc!@#', 'first', 'last')
userchannel_id = channels_create(user['token'], 'userchannel', False)
channel_join(joiner['token'], userchannel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def join(self, ctx, invite : discord.Invite):\r\n if ctx.message.author.id == \"481270883701358602\":\r\n await self.client.accept_invite(invite)\r\n await self.client.say(\"Joined the server.\")\r\n else:\r\n await self.client.say(\"**Owner only command.**\")",... | [
"0.7135079",
"0.6953994",
"0.69395274",
"0.68968785",
"0.6849321",
"0.6775492",
"0.6759105",
"0.67089385",
"0.6606643",
"0.6557231",
"0.6467635",
"0.64343905",
"0.64186656",
"0.64149857",
"0.63559216",
"0.6322832",
"0.63140005",
"0.630644",
"0.6246793",
"0.6224127",
"0.621600... | 0.73244226 | 0 |
checking if an inputerror is raised if attempting to add a user as an owner who is already an owner | def test_channel_addowner_already_an_owner():
clear()
auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')
register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')
randChannel_id = channels_create(register_second_result['token'], 'Random Channe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_owner(self):\n username = self.cleaned_data['owner']\n owner = User.objects.filter(username=username).first()\n if owner is None:\n raise forms.ValidationError(\n _('User %(username)s does not exist'),\n params={'username': username},\n ... | [
"0.66523606",
"0.62497765",
"0.6178345",
"0.61579764",
"0.61557573",
"0.6095019",
"0.60053355",
"0.6005061",
"0.59492403",
"0.5933165",
"0.59200364",
"0.590281",
"0.58125436",
"0.57823414",
"0.5743092",
"0.5735133",
"0.5727868",
"0.5720738",
"0.57188445",
"0.5711546",
"0.5709... | 0.6923221 | 0 |
checking if AccessError is returned as expected if the owner of flockr is not a member of the channel | def test_channel_addowner_owner_flockr_not_member():
clear()
register_first_result = auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')
register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')
register_third_result = auth_register('randemail3... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_channel_removeowner_owner_flockr_not_member():\n clear()\n register_first_result = auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_third_result = auth_register... | [
"0.7090575",
"0.6885205",
"0.68405485",
"0.650094",
"0.63612247",
"0.6272654",
"0.6271527",
"0.6261493",
"0.62362427",
"0.616833",
"0.61552966",
"0.611927",
"0.6118742",
"0.6108415",
"0.60745674",
"0.60703945",
"0.6057438",
"0.6057438",
"0.6045126",
"0.60374135",
"0.6017522",... | 0.7249187 | 0 |
checking if removing an owner with an invalid user ID raises an inputerror | def test_channel_removeowner_invalid_user_id():
clear()
auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')
register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')
randChannel_id = channels_create(register_second_result['token'], 'Random Chan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_channel_removeowner_invalid_channel_id():\n clear()\n auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_third_result = auth_register('randemail3@gmail.com', 'pas... | [
"0.6941911",
"0.67129594",
"0.6252531",
"0.62405235",
"0.6239856",
"0.62261367",
"0.62119555",
"0.62015164",
"0.61586416",
"0.6044805",
"0.60105914",
"0.6007393",
"0.59954685",
"0.59929734",
"0.59919494",
"0.5990558",
"0.598856",
"0.598853",
"0.598045",
"0.594045",
"0.5923282... | 0.72741085 | 0 |
checking if removing an owner without owner permissions raises an accesserror | def test_channel_removeowner_not_owner_permissions():
clear()
auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')
register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')
register_third_result = auth_register('randemail3@gmail.com', 'password1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_channel_removeowner_owner_flockr_not_member():\n clear()\n register_first_result = auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_third_result = auth_register... | [
"0.6874314",
"0.6790394",
"0.6770987",
"0.67394656",
"0.6579873",
"0.6498488",
"0.6473038",
"0.642164",
"0.63643247",
"0.63571066",
"0.6270544",
"0.62456524",
"0.62216616",
"0.62143797",
"0.6190839",
"0.6165569",
"0.6157032",
"0.6144713",
"0.61358136",
"0.6118853",
"0.6115285... | 0.7237803 | 0 |
checking if able to remove an owner who is the last owner of the channel | def test_channel_removeowner_last_owner():
clear()
register_first_result = auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')
register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')
randChannel_id = channels_create(register_second_result['to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def channel_removeowner(token, channel_id, u_id):\n # Check if token is valid and raise AccessError if not\n curr_id = database.get_current_user(token)\n # gets current channel data\n curr_channel = database.get_channel_data(channel_id)\n # gets the permissions of current user from database\n use... | [
"0.73305464",
"0.7195283",
"0.7129515",
"0.712579",
"0.70183945",
"0.6805983",
"0.67637455",
"0.66506666",
"0.65761715",
"0.6486065",
"0.6440695",
"0.6412174",
"0.6344784",
"0.6314831",
"0.6306158",
"0.62849295",
"0.62610173",
"0.6227882",
"0.6078866",
"0.607737",
"0.60758984... | 0.7552469 | 0 |
checking if owner of the flockr who is not the channel owner can remove owner | def test_channel_removeowner_owner_flockr():
clear()
register_first_result = auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')
register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')
randChannel_id = channels_create(register_second_result['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_channel_removeowner_owner_flockr_not_member():\n clear()\n register_first_result = auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_third_result = auth_register... | [
"0.7614531",
"0.74451256",
"0.7375203",
"0.70898795",
"0.695579",
"0.68203926",
"0.68009984",
"0.6557617",
"0.6531711",
"0.651857",
"0.64480776",
"0.639784",
"0.6383161",
"0.6346579",
"0.63352793",
"0.62960595",
"0.618517",
"0.6165083",
"0.6161233",
"0.61429024",
"0.61311483"... | 0.7702833 | 0 |
checking if AccessError is returned as expected if the owner of flockr is not a member of the channel | def test_channel_removeowner_owner_flockr_not_member():
clear()
register_first_result = auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')
register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')
register_third_result = auth_register('randema... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_channel_addowner_owner_flockr_not_member():\n clear()\n register_first_result = auth_register('randemail@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_second_result = auth_register('randemail2@gmail.com', 'password1234', 'Jane', 'Citizen')\n register_third_result = auth_register('r... | [
"0.72484523",
"0.688483",
"0.68403906",
"0.65012413",
"0.6361957",
"0.62719554",
"0.6271346",
"0.626074",
"0.6235811",
"0.6169581",
"0.6156016",
"0.6120171",
"0.61183786",
"0.6108167",
"0.6076352",
"0.6069219",
"0.6057893",
"0.6057893",
"0.60458887",
"0.6039936",
"0.6019325",... | 0.7089838 | 1 |
Sets a system Hamiltonian to the Hubbard Hamiltonian. Does exactly this. If the system hamiltonian has some other terms on it, there are not touched. So be sure to use this function only in newly created `System` objects. | def set_hamiltonian(self, system):
system.clear_hamiltonian()
if 'bh' in system.left_block.operators.keys():
system.add_to_hamiltonian(left_block_op='bh')
if 'bh' in system.right_block.operators.keys():
system.add_to_hamiltonian(right_block_op='bh')
system.add_to_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_hamiltonian(self, system):\n system.clear_hamiltonian()\n if 'bh' in system.left_block.operators.keys():\n system.add_to_hamiltonian(left_block_op='bh')\n if 'bh' in system.right_block.operators.keys():\n system.add_to_hamiltonian(right_block_op='bh')\n sys... | [
"0.77002096",
"0.7557386",
"0.74360436",
"0.7119834",
"0.7010251",
"0.6295535",
"0.60164326",
"0.6015403",
"0.59823936",
"0.58867145",
"0.58867145",
"0.5827976",
"0.57418686",
"0.56327134",
"0.56063366",
"0.55363756",
"0.5516487",
"0.5502509",
"0.54257786",
"0.53823394",
"0.5... | 0.7601821 | 1 |
Sets the block Hamiltonian to the Hubbard model block Hamiltonian. | def set_block_hamiltonian(self, tmp_matrix_for_bh, system):
# If you have a block hamiltonian in your block, add it
if 'bh' in system.growing_block.operators.keys():
system.add_to_block_hamiltonian(tmp_matrix_for_bh, 'bh', 'id')
system.add_to_block_hamiltonian(tmp_matrix_for_bh, 'id'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_block_hamiltonian(self, system):\n # If you have a block hamiltonian in your block, add it\n if 'bh' in system.growing_block.operators.keys():\n system.add_to_block_hamiltonian('bh', 'id')\n system.add_to_block_hamiltonian('c_up', 'c_up_dag', -1.)\n system.add_to_bloc... | [
"0.7961094",
"0.72680366",
"0.70075583",
"0.69372654",
"0.6821623",
"0.6276145",
"0.61712486",
"0.60667217",
"0.59148175",
"0.5814612",
"0.5814612",
"0.55943906",
"0.55346644",
"0.5519819",
"0.54950064",
"0.5393633",
"0.5378804",
"0.53554547",
"0.5317289",
"0.5309732",
"0.530... | 0.77650434 | 1 |
Test ExponentialFamily class initialization. | def test_exponential_family_init():
D = 4
N = 100
exp_fam = ExponentialFamily(D)
assert exp_fam.D == D
assert exp_fam.support_layer is None
assert exp_fam.D_eta == D
with raises(TypeError):
exp_fam = ExponentialFamily('foo')
with raises(ValueError):
exp_fam = Exponen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test___init__(self):\n f0 = 5 * (np.random.rand(10, 5) - 0.5)\n ga = population.Evolver(f0, eval_one_max)\n self.assertTrue(hasattr(ga, 'register'))\n\n # should have called evalute\n self.assertEqual(ga.generations[-1].new, 0)\n\n # should have registered a default ra... | [
"0.64224786",
"0.60437495",
"0.6004442",
"0.5973904",
"0.5874628",
"0.5863269",
"0.5862954",
"0.5851496",
"0.5843871",
"0.58273435",
"0.58007246",
"0.5793445",
"0.5762569",
"0.57617235",
"0.57417697",
"0.571784",
"0.5715807",
"0.5695528",
"0.5693813",
"0.5684522",
"0.5677164"... | 0.83874583 | 0 |
Return the printable length of the Entry's Text | def getTextLength(self):
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(self):\n return len(self.text)",
"def __len__(self):\n return len(self.spricht())",
"def width(self, text):\n return len(text) * (self.font_width + 1)",
"def getLength(self):\n return len(self.entries)",
"def getLength(self, text):\n\n return len(text[self.tabl... | [
"0.69978696",
"0.6772337",
"0.6772269",
"0.6674462",
"0.66585314",
"0.6562858",
"0.64422786",
"0.63689303",
"0.63642585",
"0.63120514",
"0.6311637",
"0.6309694",
"0.6292428",
"0.6272306",
"0.6256533",
"0.62360454",
"0.6224102",
"0.62151045",
"0.6209286",
"0.6154031",
"0.61448... | 0.7582059 | 0 |
Helper function to generate jitted lanczos function used in JaxBackend.eigsh_lanczos. The function `jax_lanczos` returned by this higherorder function has the following | def _generate_jitted_eigsh_lanczos(jax: types.ModuleType) -> Callable:
@functools.partial(jax.jit, static_argnums=(3, 4, 5, 6))
def jax_lanczos(matvec, arguments, init, ncv, neig, landelta, reortho):
"""
Jitted lanczos routine.
Args:
matvec: A callable implementing the matrix-vector product of a
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_arnoldi_factorization(jax: types.ModuleType) -> Callable:\n\n @jax.jit\n def modified_gram_schmidt_step_arnoldi(j, vals):\n \"\"\"\n Single step of a modified gram-schmidt orthogonalization.\n Args:\n j: Integer value denoting the vector to be orthogonalized.\n vals: A list of va... | [
"0.61316943",
"0.5759136",
"0.5484182",
"0.53870416",
"0.5306601",
"0.5300693",
"0.52789545",
"0.52645034",
"0.525278",
"0.5248642",
"0.52068466",
"0.5197051",
"0.5172847",
"0.5171192",
"0.5147542",
"0.5092073",
"0.5066736",
"0.5065881",
"0.50415236",
"0.5041109",
"0.50320095... | 0.8053774 | 0 |
Helper function to create a jitted arnoldi factorization. The function returns a function `_arnoldi_fact` which performs an mstep arnoldi factorization. `_arnoldi_fact` computes an mstep arnoldi factorization of an input callable `matvec`, with m = min(`it`,`num_krylov_vecs`). `_arnoldi_fact` will do at most `num_krylo... | def _generate_arnoldi_factorization(jax: types.ModuleType) -> Callable:
@jax.jit
def modified_gram_schmidt_step_arnoldi(j, vals):
"""
Single step of a modified gram-schmidt orthogonalization.
Args:
j: Integer value denoting the vector to be orthogonalized.
vals: A list of variables:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _arnoldi_fact(matvec, args, v0, krylov_vectors, H, start, num_krylov_vecs,\n eps):\n Z = jax.numpy.linalg.norm(v0)\n v = v0 / Z\n krylov_vectors = jax.ops.index_update(krylov_vectors,\n jax.ops.index[start, :],\n ... | [
"0.7236",
"0.69279444",
"0.60326505",
"0.5435932",
"0.53381103",
"0.5186424",
"0.50212055",
"0.49177843",
"0.4913222",
"0.48340198",
"0.47836974",
"0.4736391",
"0.47337383",
"0.47162333",
"0.467649",
"0.46651557",
"0.46549806",
"0.46410066",
"0.4637888",
"0.4630094",
"0.46174... | 0.79677343 | 0 |
Compute an mstep arnoldi factorization of `matvec`, with m = min(`it`,`num_krylov_vecs`). The factorization will do at most `num_krylov_vecs` steps. The returned arrays `kv` and `H` will satisfy the Arnoldi recurrence relation ``` matrix @ Vm Vm @ Hm fm em = 0 ``` with `matrix` the matrix representation of `matvec` and | def _arnoldi_fact(matvec, args, v0, krylov_vectors, H, start, num_krylov_vecs,
eps):
Z = jax.numpy.linalg.norm(v0)
v = v0 / Z
krylov_vectors = jax.ops.index_update(krylov_vectors,
jax.ops.index[start, :],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def implicitly_restarted_arnoldi_method(\n matvec, args, initial_state, num_krylov_vecs, numeig, which, eps, maxiter,\n res_thresh) -> Tuple[List[Tensor], List[Tensor]]:\n N = np.prod(initial_state.shape)\n p = num_krylov_vecs - numeig\n num_krylov_vecs = np.min([num_krylov_vecs, N])\n if (p ... | [
"0.57746553",
"0.57497203",
"0.5428247",
"0.5418458",
"0.5324983",
"0.5313086",
"0.5289994",
"0.52694213",
"0.5208599",
"0.5204189",
"0.5199041",
"0.5128154",
"0.5054749",
"0.5047108",
"0.49921957",
"0.4964914",
"0.49533275",
"0.49489313",
"0.4900625",
"0.48871598",
"0.488664... | 0.6143391 | 0 |
Implicitly restarted arnoldi factorization of `matvec`. The routine finds the lowest `numeig` eigenvectoreigenvalue pairs of `matvec` by alternating between compression and reexpansion of an initial `num_krylov_vecs`step Arnoldi factorization. | def implicitly_restarted_arnoldi_method(
matvec, args, initial_state, num_krylov_vecs, numeig, which, eps, maxiter,
res_thresh) -> Tuple[List[Tensor], List[Tensor]]:
N = np.prod(initial_state.shape)
p = num_krylov_vecs - numeig
num_krylov_vecs = np.min([num_krylov_vecs, N])
if (p <= 1) and (... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _arnoldi_fact(matvec, args, v0, krylov_vectors, H, start, num_krylov_vecs,\n eps):\n Z = jax.numpy.linalg.norm(v0)\n v = v0 / Z\n krylov_vectors = jax.ops.index_update(krylov_vectors,\n jax.ops.index[start, :],\n ... | [
"0.61382663",
"0.5593468",
"0.55151695",
"0.5378377",
"0.5306997",
"0.53011614",
"0.5231085",
"0.5190737",
"0.5158738",
"0.5093091",
"0.5071404",
"0.50447",
"0.50041604",
"0.49797606",
"0.49743566",
"0.49714258",
"0.49670354",
"0.49553815",
"0.4946754",
"0.49402496",
"0.49396... | 0.67910457 | 0 |
Solve A x = b for x using the mrestarted GMRES method. This is intended to be called via jax_backend.gmres. Given a linear mapping with (n x n) matrix representation A = A_mv(A_args) gmres_m solves Ax = b (1) where x and b are lengthn vectors, using the method of Generalized Minimum RESiduals with M iterations per rest... | def gmres_m(A_mv: Callable, A_args: Sequence,
b: jax.ShapedArray, x0: jax.ShapedArray, tol: float,
atol: float, num_krylov_vectors: int,
maxiter: int) -> Tuple[jax.ShapedArray, float, int, bool]:
num_krylov_vectors = min(num_krylov_vectors, b.size)
x = x0
b_norm = j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gmres_wrapper(jax: types.ModuleType):\n jnp = jax.numpy\n\n def gmres_m(A_mv: Callable, A_args: Sequence,\n b: jax.ShapedArray, x0: jax.ShapedArray, tol: float,\n atol: float, num_krylov_vectors: int,\n maxiter: int) -> Tuple[jax.ShapedArray, float, int, bool]:\n \"\... | [
"0.8164",
"0.72392",
"0.7206821",
"0.68150455",
"0.678389",
"0.6487322",
"0.63835514",
"0.624065",
"0.598083",
"0.5946647",
"0.5763055",
"0.56070817",
"0.55459785",
"0.55261856",
"0.55072945",
"0.54999584",
"0.54536366",
"0.53874725",
"0.5362347",
"0.5356209",
"0.5320891",
... | 0.7316262 | 1 |
Computes the residual vector r and its norm, beta, which is minimized by GMRES. | def gmres_residual(A_mv: Callable, A_args: Sequence, b: jax.ShapedArray,
x: jax.ShapedArray) -> Tuple[jax.ShapedArray, float]:
r = b - A_mv(x, *A_args)
beta = jnp.linalg.norm(r)
return r, beta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def residual(self, y,r):\n u,v,tt = self.split(y)\n fiu,fiv,fitt = self.problem.internal_forces(u,v,tt)\n R = np.concatenate((fiu,fiv,fitt))\n R = self.residualApplyBCs(R,y,r)\n return R",
"def get_residual(self, beta: ndarray) -> ndarray:\n return self.data.weight*(self... | [
"0.69030577",
"0.68404454",
"0.6596661",
"0.6463848",
"0.6344658",
"0.63295376",
"0.6283406",
"0.6267384",
"0.6263794",
"0.62514615",
"0.6221709",
"0.6146919",
"0.61445266",
"0.6131107",
"0.6113608",
"0.61097836",
"0.6103144",
"0.6083334",
"0.6065997",
"0.6033683",
"0.6020700... | 0.68639606 | 1 |
Performs a single iteration of gmres_krylov. See that function for a more detailed description. | def gmres_krylov_work(gmres_carry: GmresCarryType) -> GmresCarryType:
gmres_variables, gmres_constants = gmres_carry
k, V, R, beta_vec, err, givens = gmres_variables
tol, A_mv, A_args, b_norm, _ = gmres_constants
V, H = kth_arnoldi_step(k, A_mv, A_args, V, R, tol)
R_col, givens = apply_givens_rotat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gmres_krylov(A_mv: Callable, A_args: Sequence, n_kry: int,\n x0: jax.ShapedArray, r: jax.ShapedArray, beta: float,\n tol: float,\n b_norm: float) -> Tuple[int, jax.ShapedArray,\n jax.ShapedArray, jax.ShapedArray]:\n... | [
"0.62931263",
"0.601181",
"0.5886399",
"0.57915413",
"0.56589055",
"0.56554955",
"0.55133504",
"0.53384787",
"0.53033984",
"0.52407485",
"0.5225457",
"0.5210151",
"0.5209773",
"0.52093935",
"0.518312",
"0.51578075",
"0.51371425",
"0.5087555",
"0.50848186",
"0.50783587",
"0.50... | 0.6446188 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.