query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Converts the boolean of a grid to a character. | def boolean_to_xo(boolean):
return {
False: 'X',
True: 'O'
}.get(boolean) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __boolToChar(self, boolean):\n\n if boolean:\n return '1'\n else:\n return '0'",
"def state_to_char(observation):\n if observation == self.TileState.CLEAN.value:\n return \"-\"\n if observation == self.TileState.DIRTY.value:\n ... | [
"0.7116065",
"0.6241624",
"0.6022058",
"0.6007529",
"0.5949365",
"0.58978575",
"0.58007675",
"0.5697261",
"0.56580883",
"0.5642525",
"0.5559029",
"0.55482435",
"0.5536672",
"0.55057585",
"0.5464283",
"0.5461742",
"0.54190403",
"0.54068124",
"0.5394293",
"0.53650624",
"0.53421... | 0.5492796 | 14 |
Set user's password without save. | def test_set_password_without_save(self):
user = UserModel()
user.password = "is_god"
assert isinstance(user.password, HashedPassword), "password should be hashed"
assert user.password == "is_god" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setpassword(self, pwd):\n pass",
"def set_password(self, password):\n self.password = password",
"def update_password(self, user, password):\n user.password = hashers.make_password(password)",
"def set_password(self, password):\n self.PASSWORD = password",
"def set_password(... | [
"0.8370104",
"0.7977953",
"0.7948715",
"0.78393275",
"0.78218645",
"0.78083926",
"0.778647",
"0.7753911",
"0.77458394",
"0.7745551",
"0.7718007",
"0.771477",
"0.7713753",
"0.7675904",
"0.7666784",
"0.7649039",
"0.7626858",
"0.7587661",
"0.75855166",
"0.7577332",
"0.7577332",
... | 0.7268963 | 45 |
Set user's password with save. | def test_set_password_with_save(self):
user = UserModel.objects.get(email="lemmy@imotorhead.com")
user.password = "is_god"
user.save()
assert isinstance(user.password, HashedPassword), "password should be hashed"
assert user.password == "is_god" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setpassword(self, pwd):\n pass",
"def change_password(self):\n self.test_user.set_password(self.create_user_data()['password1'])\n self.test_user.save()",
"def save(self, commit=True):\n user = super(UserForm, self).save(commit=False)\n user.set_password(self.cleaned_data... | [
"0.7905599",
"0.78841126",
"0.7843748",
"0.77898395",
"0.7770465",
"0.7722984",
"0.74430025",
"0.7440685",
"0.74249965",
"0.73715544",
"0.7369432",
"0.73550016",
"0.7341939",
"0.73407733",
"0.7327272",
"0.7318722",
"0.73134434",
"0.73026556",
"0.7298048",
"0.72918826",
"0.723... | 0.76471704 | 6 |
Evaluate the absolute error for poses to a ground truth. | def evaluate_error_absolute(poses_to_test: List[Tuple[str, kapture.PoseTransform]],
poses_ground_truth: List[Tuple[str, kapture.PoseTransform]]
) -> List[Tuple[str, float, float]]:
poses_ground_truth_as_dict = {name: pose for name, pose in poses_ground_truth}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _evaluate(self, state):\n leading_power_error = self.get_leading_power_error(state)\n if np.isfinite(leading_power_error):\n return -float(leading_power_error)\n else:\n return self._default_value",
"def calc_ground_truth_policy_value(self, action_dist: np.ndarray) -> float:\n check... | [
"0.6493396",
"0.61360085",
"0.6067173",
"0.60115486",
"0.60107553",
"0.5945455",
"0.59215415",
"0.5891091",
"0.5891091",
"0.58867097",
"0.58620715",
"0.58589554",
"0.5834993",
"0.5828642",
"0.5801907",
"0.5773756",
"0.5757872",
"0.5755355",
"0.5686975",
"0.56765413",
"0.56764... | 0.6143336 | 1 |
Converts a mangled C++ name to a valid python identifier. | def MAKE_NAME(name):
name = name.replace('$', 'DOLLAR')
name = name.replace('.', 'DOT')
if name.startswith('__'):
return '_X' + name
elif name[0] in '01234567879':
return '_' + name
return name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_python_name(self, name):\n # FIXME see cindex.SpellingCache\n for k, v in [('<', '_'), ('>', '_'), ('::', '__'), (',', ''), (' ', ''),\n (\"$\", \"DOLLAR\"), (\".\", \"DOT\"), (\"@\", \"_\"), (\":\", \"_\"),\n ('-', '_')]:\n if k in name: #... | [
"0.71853274",
"0.70570505",
"0.6908706",
"0.6741958",
"0.6688559",
"0.66267854",
"0.6577075",
"0.6554791",
"0.6535899",
"0.6521695",
"0.6342569",
"0.6283068",
"0.6270476",
"0.6172326",
"0.6117909",
"0.6055",
"0.5973267",
"0.5972315",
"0.59421307",
"0.59408534",
"0.5926178",
... | 0.6219825 | 13 |
returns an item having no 'value' key | def item_without_value():
return {'name':'box'} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_without_name():\n return {'value':340}",
"def item_with_bad_value():\n return {'name':'box',\n 'value':'thirty'}",
"def might_contain(self, value):\n h = self.hash_value(value)\n return self.values[h]",
"def testValuesWithoutData(self):\n collection = TagValueCo... | [
"0.6959445",
"0.6882983",
"0.63159955",
"0.6311257",
"0.62987405",
"0.62560177",
"0.61644316",
"0.61462814",
"0.6102566",
"0.60479707",
"0.60385144",
"0.5951182",
"0.57839084",
"0.5733387",
"0.57045144",
"0.5689173",
"0.56776094",
"0.5670749",
"0.5611334",
"0.5579161",
"0.557... | 0.71848667 | 0 |
GIVEN a flask application WHEN a user adds an item with incorrect value THEN check that a bad request response is provided | def test_create_item_incorrect_value(test_client,item_with_bad_value):
item = {'name':'table top', 'value':'thirty'}
response = test_client.post(BASE_URL,
data=json.dumps(item_with_bad_value),
content_type='application/json')
data = json.loa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_application_errors(self):\r\n with self.flask_app.app_context():\r\n\r\n self.register()\r\n self.new_application()\r\n\r\n res = self.update_application(new_name=\"\")\r\n assert \"This field is required\" in res.data\r\n\r\n res = self... | [
"0.6625819",
"0.651897",
"0.64484036",
"0.64032555",
"0.6320849",
"0.62915367",
"0.6266476",
"0.6252747",
"0.6248677",
"0.6164203",
"0.6164105",
"0.6149116",
"0.6111299",
"0.6110656",
"0.60990953",
"0.6057881",
"0.60342103",
"0.6030507",
"0.6018995",
"0.6004213",
"0.6002298",... | 0.6651751 | 0 |
GIVEN a flask application WHEN a user updates a valid item THEN check that a valid response is provided | def test_update_item_good(test_client, item):
response = test_client.put(GOOD_ITEM_URL,
data=json.dumps(item),
content_type='application/json')
data = json.loads(response.get_data())
assert response.status_code == 200
assert data['it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_12_update_application(self, Mock, mock):\r\n with self.flask_app.app_context():\r\n html_request = FakeRequest(json.dumps(self.pkg_json_not_found), 200,\r\n {'content-type': 'application/json'})\r\n Mock.return_value = html_request\r\n\r\n... | [
"0.7009168",
"0.66727924",
"0.6579731",
"0.65227413",
"0.6362692",
"0.6354952",
"0.63390976",
"0.6278084",
"0.6226785",
"0.6207882",
"0.6200606",
"0.6158867",
"0.6131634",
"0.61084455",
"0.6092587",
"0.5999919",
"0.59828687",
"0.59695166",
"0.5921381",
"0.5919343",
"0.591663"... | 0.57789195 | 38 |
GIVEN a flask application WHEN a user updates a non existent item id THEN check that a valid 404 response is provided | def test_update_item_incorrect_id(test_client, item):
response = test_client.put(BAD_ITEM_URL,
data=json.dumps(item),
content_type='application/json')
data = json.loads(response.get_data())
assert response.status_code == 404
assert data['e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_05d_get_nonexistant_app_update(self):\r\n self.register()\r\n # GET\r\n res = self.app.get('/app/noapp/update', follow_redirects=True)\r\n assert res.status == '404 NOT FOUND', res.status\r\n # POST\r\n res = self.update_application(short_name=\"noapp\")\r\n ... | [
"0.7389095",
"0.7101388",
"0.70127696",
"0.66654366",
"0.6602685",
"0.6506175",
"0.63723445",
"0.63387007",
"0.6292213",
"0.62813187",
"0.6258391",
"0.6184267",
"0.6177875",
"0.6160117",
"0.61584467",
"0.6145705",
"0.6143569",
"0.6135169",
"0.61084354",
"0.6086671",
"0.607960... | 0.70387673 | 2 |
GIVEN a flask applicatin WHEN a user updates an item, providing an incorrect content type THEN check that a valid 400 response is provided | def test_update_item_incorrect_content_type(test_client, item):
response = test_client.put(GOOD_ITEM_URL,
data=json.dumps(item))
data = json.loads(response.get_data())
assert response.status_code == 400
assert data['error'] == app.BAD_REQUEST | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_item_incorrect_value_type(test_client, item_with_bad_value):\n\n response = test_client.put(GOOD_ITEM_URL,\n data=json.dumps(item_with_bad_value),\n content_type='application/json')\n\n data = json.loads(response.get_data())\n\n a... | [
"0.7235813",
"0.6553306",
"0.6545673",
"0.64651114",
"0.64642936",
"0.6398381",
"0.6358209",
"0.6335581",
"0.6256608",
"0.6228232",
"0.6225134",
"0.6224841",
"0.6201355",
"0.61985964",
"0.61769384",
"0.6174337",
"0.61457133",
"0.6143786",
"0.61370873",
"0.60921085",
"0.607999... | 0.7248537 | 0 |
GIVEN a flask application WHEN a user updates an item, providing an incorrect value type THEN check that a valid 400 response is provided | def test_update_item_incorrect_value_type(test_client, item_with_bad_value):
response = test_client.put(GOOD_ITEM_URL,
data=json.dumps(item_with_bad_value),
content_type='application/json')
data = json.loads(response.get_data())
assert respons... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_application_errors(self):\r\n with self.flask_app.app_context():\r\n\r\n self.register()\r\n self.new_application()\r\n\r\n res = self.update_application(new_name=\"\")\r\n assert \"This field is required\" in res.data\r\n\r\n res = self... | [
"0.6851784",
"0.6587387",
"0.64580625",
"0.6382713",
"0.6377108",
"0.633658",
"0.6260496",
"0.62319046",
"0.6226128",
"0.62143725",
"0.62043226",
"0.6198981",
"0.6102735",
"0.60989565",
"0.6066915",
"0.6061347",
"0.6051372",
"0.60408425",
"0.60354966",
"0.6024505",
"0.6002906... | 0.7405215 | 0 |
GIVEN a flask application WHEN a user deletes an item that does not exist THEN check that a valid 404 response is provided | def test_delete_item_incorrect_id(test_client):
response = test_client.delete(GOOD_ITEM_URL)
data = json.loads(response.get_data())
assert response.status_code == 404
assert data['error'] == app.NOT_FOUND | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_user_404(self):\n resp = self.app.delete('/users/thisuserdoesntexist')\n assert resp.status_code == 404",
"def test_05d_get_nonexistant_app_delete(self):\r\n self.register()\r\n # GET\r\n res = self.app.get('/app/noapp/delete', follow_redirects=True)\r\n ... | [
"0.7317368",
"0.72177124",
"0.71755594",
"0.6655081",
"0.6627839",
"0.6609978",
"0.65999764",
"0.6529177",
"0.65287083",
"0.6412621",
"0.6401429",
"0.6392713",
"0.6333492",
"0.6331474",
"0.6297594",
"0.6268003",
"0.6259176",
"0.6254021",
"0.6249084",
"0.62441254",
"0.6241765"... | 0.6776175 | 3 |
Renders the home view of the app | def home(request):
return render(request, 'home.html', {'GOOGLE_API_KEY': GOOGLE_API_KEY}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_home():\r\n\treturn render_template(\"index.html\")",
"def home():\n\n return render_template('home_page.html')",
"def home():\n\n return render_template(\"home.html\")",
"def home():\n return render_template('home.html')",
"def home():\n return render_template('home.html')",
"def ... | [
"0.8555407",
"0.8488411",
"0.8413842",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8340244",
"0.8330458",
"0.8330458",
"... | 0.0 | -1 |
Return matrix to rotate about axis defined by point and direction. | def rotation_matrix(angle, direction, point=None):
sina = math.sin(angle)
cosa = math.cos(angle)
direction = unit_vector(direction[:3])
# rotation matrix around unit vector
R = np.diag([cosa, cosa, cosa])
R += np.outer(direction, direction) * (1.0 - cosa)
direction *= sina
R += n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def axisangle2matrix(angle, direction, point=None):\r\n sina = math.sin(angle)\r\n cosa = math.cos(angle)\r\n direction = unit_vector(direction[:3])\r\n # rotation matrix around unit vector\r\n R = numpy.diag([cosa, cosa, cosa])\r\n R += numpy.outer(direction, direction) * (1.0 - cosa)\r\n dir... | [
"0.7728551",
"0.73258036",
"0.7262272",
"0.7243947",
"0.6818176",
"0.68091345",
"0.674825",
"0.66802233",
"0.6598905",
"0.6585141",
"0.6514585",
"0.6479495",
"0.64701617",
"0.64399165",
"0.6438013",
"0.6398001",
"0.63943183",
"0.6366432",
"0.6365902",
"0.6365282",
"0.63568646... | 0.7375879 | 1 |
Sample noise from gaussian distribution with parameters means and covs | def sample_gaussian(params, typ='numpy', batch_size=100):
if typ =='tensorflow':
means, covs = tf.split(params,2,axis=-1)
shape = tf.shape(means)
eps = tf.random.normal(shape, dtype=tf.float32)
noise = means + tf.multiply(eps,tf.sqrt(1e-10+covs))
elif typ =='numpy':
means... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_gaussian_noise(image ):\n sigma = image.std()\n for ch in range(image.shape[2] ):\n sigma = min(sigma, image[:,:,ch].std() )\n image = random_noise(image, var = sigma**2)\n return image",
"def add_gaussian_noise(self, samples):\n\n if 'sigma' in self.gaussian_component:\n ... | [
"0.72112334",
"0.7184942",
"0.71693134",
"0.7144554",
"0.70815593",
"0.70332384",
"0.69560814",
"0.69505167",
"0.6892077",
"0.6797149",
"0.6775827",
"0.6758287",
"0.67192024",
"0.66998935",
"0.66853905",
"0.6666638",
"0.66629636",
"0.66487336",
"0.6634397",
"0.6624826",
"0.66... | 0.7035633 | 5 |
set the message to field of the message data to be too long | def step_impl_the_msg_to_is_set_too_long(context):
context.bdd_helper.message_data["msg_to"][0] = "x" * (constants.MAX_TO_LEN + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_length(self, field, tag_id, value):\n # pylint: disable=unused-argument\n if tag_id not in {8, 9, 10}:\n self._message_length += len(field) + 1\n if self._message_length >= self._max_length:\n raise FIXLengthTooLongError(\n f'message too long: {... | [
"0.75982594",
"0.6912993",
"0.6690516",
"0.65358305",
"0.6464621",
"0.64632267",
"0.64477795",
"0.6445162",
"0.64210004",
"0.61839885",
"0.6012873",
"0.59908015",
"0.5970882",
"0.5957988",
"0.59407127",
"0.5919903",
"0.5918912",
"0.5886433",
"0.58727854",
"0.5840071",
"0.5823... | 0.75016 | 1 |
Creates Channel instance from data, which are channel contents parsed by Marconppa.core.parse.lark | def parsed_channel(cls, data):
attributes = {}
waveforms = {}
for i in data.keys():
if i == "Enabled":
enabled = Waveform.from_waveform_dict(data["Enabled"])
elif type(data[i]) is dict and not i == "Enabled":
waveforms[i] = Waveform.from_w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_data(cls, data):\n self = object.__new__(cls)\n self.id = parse_id(data)\n self._set_icon(data)\n self.bot = parse_bot(data)\n self.description = parse_description(data)\n self.name = parse_name(data)\n return self",
"def _parse(self, data):\n prot... | [
"0.6344082",
"0.62770414",
"0.6124182",
"0.6100969",
"0.5772407",
"0.5748528",
"0.5712783",
"0.5621832",
"0.5610919",
"0.55837476",
"0.55604476",
"0.5531649",
"0.54476166",
"0.5444936",
"0.53936535",
"0.53854156",
"0.53696924",
"0.53603363",
"0.52876216",
"0.52803725",
"0.526... | 0.66053873 | 0 |
Rowwise normalization, assumes number of rows in all matrices are same | def normalize(*matrices, method="l1", return_split=False):
if len(matrices) == 0:
return None
sizes = [m.shape[1] for m in matrices]
mat = np.hstack(matrices)
if method == "l1":
mat /= mat.sum(axis=1).reshape(-1, 1)
elif method == "l2":
mat = mat**2
mat /= mat.sum(axi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalizeRows(x):\n N = x.shape[0]\n x /= np.sqrt(np.sum(x ** 2, axis=1)).reshape((N, 1)) + 1e-30\n return x",
"def normalizeRows(x):\n # this is the same as norm function which takes sqrt(sum of squares of elements along each matrix-row)\n norm_row = np.sqrt(np.sum(x**2, axis=1)) # axis = 0 ... | [
"0.75488883",
"0.7532844",
"0.75252324",
"0.74362904",
"0.7345702",
"0.72406524",
"0.71726876",
"0.71670806",
"0.71199",
"0.7117851",
"0.70422256",
"0.69521815",
"0.6940228",
"0.692185",
"0.68722206",
"0.68722206",
"0.68430114",
"0.68232256",
"0.68122333",
"0.6810206",
"0.680... | 0.6761125 | 24 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8195649",
"0.8095532",
"0.803007",
"0.8019817",
"0.7994959",
"0.7991904",
"0.79818887",
"0.79766536",
"0.7961735",
"0.7957412",
"0.79385704",
"0.7935568",
"0.79352015",
"0.7932079",
"0.79270303",
"0.7925357",
"0.79243845",
"0.7923781",
"0.792341",
"0.79226786",
"0.7918532"... | 0.7815597 | 97 |
ARN to be used for invoking Lambda Function from API Gateway to be used in aws_api_gateway_integration's `uri`. | def invoke_arn(self) -> str:
return pulumi.get(self, "invoke_arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lambda_arn_lookup(session, lambda_name):\n if session is None:\n return None\n\n client = session.client(\"lambda\")\n response = client.get_function(FunctionName=lambda_name)\n if response is None:\n return None\n else:\n return response['Configuration']['FunctionArn']",
... | [
"0.6594228",
"0.6574651",
"0.6182666",
"0.61284226",
"0.60756713",
"0.5967239",
"0.5939838",
"0.59359926",
"0.59165627",
"0.59165627",
"0.59165627",
"0.59165627",
"0.59165627",
"0.59165627",
"0.59165627",
"0.59165627",
"0.59165627",
"0.59165627",
"0.59165627",
"0.59165627",
"... | 0.7131957 | 0 |
Make sure the string is alphanumeric. We do this to sanitize our table names (since DBAPI parameter substitution doesn't work for table names). | def _scrub(self, string):
if not string.isalnum():
raise ValueError("Table name cannot include non-alphanumerics.")
return string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_column_name(string):\n string = unidecode(string.replace(' ', '_').lower())\n return re.sub(r'[^0-9a-z_]','', string)",
"def scrub(self, table_name):\n\n return ''.join( chr for chr in table_name if chr.isalnum() )",
"def _database_username_validate(s):\n if len(s) < 1 or len(s) > 63:\... | [
"0.7241796",
"0.7110954",
"0.6877788",
"0.6602363",
"0.64133453",
"0.6387862",
"0.638604",
"0.63723433",
"0.6363177",
"0.63207275",
"0.631537",
"0.63034743",
"0.6271295",
"0.6261939",
"0.6257038",
"0.6216058",
"0.61869186",
"0.61620057",
"0.60696435",
"0.60495406",
"0.6042183... | 0.8332586 | 0 |
Return the argument `string` converted to a byte string if it's a unicode string. Otherwise just return the string. | def as_bytes(string):
return same_string_type_as(b"", string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def give_me_bytes(string):\n return string.encode('utf8') if isinstance(string, str) else string",
"def try_unicode(string):\n if isinstance(string, str):\n return string.decode(\"utf-8\")\n else:\n return string",
"def to_bytes(string):\n assert isinstance(string, basestring)\n if... | [
"0.8278024",
"0.7736119",
"0.7689373",
"0.7395637",
"0.73836964",
"0.7364347",
"0.7337859",
"0.73056084",
"0.7291564",
"0.7269342",
"0.7209619",
"0.7171058",
"0.71597844",
"0.71165085",
"0.7064262",
"0.70489335",
"0.7032391",
"0.6983224",
"0.6981754",
"0.6957466",
"0.69491947... | 0.7509173 | 3 |
Return the argument `string` converted to a unicode string if it's a byte string. Otherwise just return the string. | def as_unicode(string):
return same_string_type_as("", string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def try_unicode(string):\n if isinstance(string, str):\n return string.decode(\"utf-8\")\n else:\n return string",
"def _convert_string_to_unicode(string):\n result = string\n\n try:\n if string is not None and not isinstance(string, six.text_type):\n result = string.d... | [
"0.8249616",
"0.79847986",
"0.7885491",
"0.774407",
"0.770393",
"0.7655451",
"0.7518738",
"0.74957335",
"0.74674356",
"0.7411469",
"0.7306435",
"0.7280405",
"0.72704726",
"0.7210421",
"0.7196348",
"0.7085675",
"0.7072564",
"0.7067109",
"0.70505875",
"0.70435506",
"0.7020564",... | 0.79086107 | 2 |
Return the argument `string` converted to a the default string type for the Python version. For unicode strings, `LOSSLESS_ENCODING` is used for encoding or decoding. | def as_default_string(string):
return same_string_type_as(compat.default_string_type(), string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_fix(string):\n if not isinstance(string, six.string_types):\n if six.PY3:\n try:\n string = str(string, 'utf-8')\n except Exception:\n try:\n string = str(string, 'latin-1')\n except Exception:\n ... | [
"0.7082454",
"0.6812608",
"0.6803907",
"0.66702986",
"0.65263957",
"0.64519304",
"0.6444418",
"0.634512",
"0.62910765",
"0.6289816",
"0.6205547",
"0.6198973",
"0.61961764",
"0.61776716",
"0.615632",
"0.61370057",
"0.6123959",
"0.61216235",
"0.6115156",
"0.60863787",
"0.607011... | 0.7913541 | 0 |
The Amazon Resource Name (ARN) of the listener. | def listener_arn(self) -> Optional[str]:
return pulumi.get(self, "listener_arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name(listener_id):\n return \"{}{}\".format(f5_const.PREFIX_LISTENER, listener_id)",
"def listener_description(self) -> str:\n return pulumi.get(self, \"listener_description\")",
"def event_source_arn(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"event_source_arn\"... | [
"0.6687682",
"0.65637684",
"0.6509131",
"0.6478412",
"0.6478412",
"0.6437506",
"0.6421728",
"0.6421728",
"0.6396982",
"0.6396982",
"0.6396982",
"0.6338194",
"0.6299437",
"0.62569517",
"0.6231384",
"0.6220336",
"0.6177935",
"0.6177935",
"0.6177935",
"0.6177935",
"0.6177935",
... | 0.8437001 | 0 |
Helper for getting the single output feature of a model. | def get_single_output_feature(model: BaseModel) -> BaseFeatureMixin:
return next(iter(model.output_features.values())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model_output_and_feature(\n model,\n batch_x\n):\n outputs, features = model.get_output_and_feature(batch_x, training=False)\n return outputs, features",
"def get_model_output(\n model,\n batch_x\n):\n outputs = model(batch_x, training=False)\n return outputs",
"def get_model_feature(\n... | [
"0.7442841",
"0.67368835",
"0.65878844",
"0.642245",
"0.6183685",
"0.6183685",
"0.61482877",
"0.6128813",
"0.60387766",
"0.58651304",
"0.5817236",
"0.58047664",
"0.57686275",
"0.5737404",
"0.5733157",
"0.5697566",
"0.56953955",
"0.5663911",
"0.5657049",
"0.5656346",
"0.565088... | 0.8817143 | 0 |
Compute softmax values for each sets of scores in x. | def softmax(x: npt.NDArray) -> npt.NDArray:
row_wise_max = np.max(x, axis=1).reshape(-1, 1)
exp_x = np.exp(x - row_wise_max)
return exp_x / np.sum(exp_x, axis=1).reshape(-1, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.77987385",
"0.7762009",
"0.7761647",
"0.77591646",
"0.76599663",
"0.76599663",
"0.76599663",
"0.76599663",
"0.75852114",
"0.743222",
"0.7408266",
"0.739256",
"0.73172486",
"0.7269417",
"0.7262718",
"0.72612756",
"0.72568876",
"0.7230255",
"0.7215012",
"0.720197",
"0.720152... | 0.73593086 | 12 |
Tests password grant client using invalid access_token. Should get the value of the RESPONSE variable as response. | def test_legacy_client_invalid_access_token(self):
self.legacy_client._client.access_token = 'invalidaccesstoken'
response = self.legacy_client.request('GET', urljoin(BASE_URL, MOCK_ENDPOINT))
self.assertEquals(response.content, RESPONSE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reset_passwd_bad_token(self, test_client):\n response = test_client.post('/api/auth/reset', json=dict(\n reset_password_token=str(\n create_access_token(identity=UserModel(uuid=uuid.uuid4()))),\n password=\"Azerty!123\"))\n res = json.loads(response.data)... | [
"0.7945359",
"0.7509812",
"0.7192609",
"0.70503557",
"0.7032285",
"0.7015873",
"0.6997684",
"0.69743353",
"0.69549245",
"0.69501334",
"0.6931089",
"0.6873215",
"0.68258214",
"0.6778011",
"0.6744043",
"0.67386097",
"0.67342347",
"0.6731648",
"0.67307115",
"0.66999334",
"0.6698... | 0.6848939 | 12 |
Find the shortest distance between two lines in the form y(t1) = r1 + v1 t1 and y(t2) = r2 + v2 t2 If the two lines are parallel then distance will be correct but there are infinitely many (t1, t2) that gives that distance, of which the function will pick only one of For bounded t1 and t2, see shortest_distance_bounded | def line_line_shortest_dist_unbounded(r1: np.ndarray, v1: np.ndarray, r2: np.ndarray, v2: np.ndarray,
eps: float = 1e-5) -> Tuple[float, Tuple[float, float]]:
# check that lines are not parallel
# normalised dot product must not be 1 or -1
if np.abs(np.dot(v1, v2)) < n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_line_shortest_dist_bounded(r1: np.ndarray, v1: np.ndarray, r2: np.ndarray, v2: np.ndarray,\n eps: float = 1e-5) -> Tuple[float, Tuple[float, float]]:\n\n # check against unbounded version first\n best_dist, (best_t1, best_t2) = line_line_shortest_dist_unbounded(r1,... | [
"0.7688705",
"0.72383654",
"0.703323",
"0.70010114",
"0.68556476",
"0.68519527",
"0.6795732",
"0.67852193",
"0.6650775",
"0.6583123",
"0.6526396",
"0.65094787",
"0.6466398",
"0.6451611",
"0.64506114",
"0.6424365",
"0.6417061",
"0.6410363",
"0.63699245",
"0.63277406",
"0.63201... | 0.7512283 | 1 |
Find the shortest distance between two lines in the form y(t1) = r1 + v1 t1 and y(t2) = r2 + v2 t2 where 0 <= t1, t2 <= 1 If the two lines are parallel then there may be infinitely many (t1, t2) that gives minimal distance but the function will only give one of the valid solutions For unbounded t1 and t2, see shortest_... | def line_line_shortest_dist_bounded(r1: np.ndarray, v1: np.ndarray, r2: np.ndarray, v2: np.ndarray,
eps: float = 1e-5) -> Tuple[float, Tuple[float, float]]:
# check against unbounded version first
best_dist, (best_t1, best_t2) = line_line_shortest_dist_unbounded(r1, v1, r2, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_line_shortest_dist_unbounded(r1: np.ndarray, v1: np.ndarray, r2: np.ndarray, v2: np.ndarray,\n eps: float = 1e-5) -> Tuple[float, Tuple[float, float]]:\n\n # check that lines are not parallel\n # normalised dot product must not be 1 or -1\n if np.abs(np.dot(v1... | [
"0.775275",
"0.7173928",
"0.6953018",
"0.6942969",
"0.69399667",
"0.68104494",
"0.67582613",
"0.6741229",
"0.6726619",
"0.6711318",
"0.6623188",
"0.66149825",
"0.66066223",
"0.6599096",
"0.6532751",
"0.6495348",
"0.6459801",
"0.64263487",
"0.64104116",
"0.6399223",
"0.6380627... | 0.7179989 | 1 |
Returns starting state of the board. | def initial_state():
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_state(self):\r\n return np.zeros(self.board_size, dtype=np.int8)",
"def start_state():\n return chess.Board()",
"def startingState(self):\n # Returns starting position and 4 false because no corners are visited yet\n return (self.startingPosition, (False, False, False, False))... | [
"0.8081514",
"0.7890486",
"0.7534929",
"0.72789717",
"0.72789717",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
... | 0.0 | -1 |
True if `node` is a process class. A process class is a class whose bases contain the name $KW_PROCESS_DEF. | def is_process_class(node):
if isinstance(node, ClassDef):
for b in node.bases:
if isinstance(b, Name) and b.id == KW_PROCESS_DEF:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isclass(object):\n if not inspect.isclass(object):\n return False\n if isbuiltin(object):\n return False\n return type not in inspect.getmro(object)",
"def isclass(object):\r\n return isinstance(object, (type, types.ClassType))",
"def class_is(cls: Class) -> bool:\n pass",
... | [
"0.655758",
"0.65332294",
"0.65198153",
"0.6371962",
"0.6361161",
"0.6326915",
"0.6168784",
"0.6137304",
"0.6049639",
"0.603711",
"0.59486866",
"0.59046435",
"0.5879915",
"0.5852993",
"0.5834936",
"0.5803222",
"0.57775855",
"0.5755141",
"0.57380825",
"0.5737106",
"0.57368344"... | 0.9123996 | 0 |
Convenience method to instantiate an expression node. | def create_expr(self, exprcls, ast, params=None, nopush=False):
if params is None:
expr = exprcls(self.current_parent, ast=ast)
else:
expr = exprcls(self.current_parent, ast=ast, **params)
if not nopush:
self.push_state(expr)
return expr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_expression(expression: str) -> nodes.ExpNode:\r\n\r\n tokens = tokenize(expression)\r\n node = build_expression_tree(tokens)\r\n\r\n return node",
"def convert_exp(node, **kwargs):\n return create_basic_op_node('Exp', node, kwargs)",
"def expression_ast_node(self):\n node = self.as... | [
"0.66690403",
"0.65890986",
"0.6388806",
"0.63711005",
"0.62891746",
"0.62891746",
"0.6280932",
"0.62340486",
"0.6224012",
"0.61840016",
"0.6148236",
"0.6148236",
"0.60829765",
"0.5976024",
"0.5886891",
"0.5849652",
"0.5801457",
"0.5801457",
"0.5801206",
"0.5791902",
"0.57440... | 0.72887707 | 0 |
Parse all branches in an await statement. 'stmtobj' is the DistNode instance of the await statement to be populated; 'node' is the input Python AST node corresponding to the outermost 'If' statement. This method is common code to parse the second to last branches of AwaitStmt and LoopingAwaitStmt, since the first branc... | def parse_branches_for_await(self, stmtobj, node):
has_timeout = False
else_ = [node]
while True:
if len(else_) == 0:
break
elif len(else_) == 1 and isinstance(else_[0], If):
node = else_[0]
self.debug("checking await branch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_async_stmt(self, node: Node) -> Iterator[Line]:\n yield from self.line()\n\n children = iter(node.children)\n for child in children:\n yield from self.visit(child)\n\n if child.type == token.ASYNC or child.type == STANDALONE_COMMENT:\n # STANDALON... | [
"0.5492106",
"0.5315386",
"0.5305906",
"0.51987165",
"0.5159142",
"0.5027113",
"0.498277",
"0.48006976",
"0.47863525",
"0.47139806",
"0.46591306",
"0.46243605",
"0.45984608",
"0.4474116",
"0.44683757",
"0.4454898",
"0.44446585",
"0.44364792",
"0.43934777",
"0.43777758",
"0.43... | 0.80681074 | 0 |
Transforms an H5py Attributes set to a dict. Converts unicode string keys into standard strings and each value into a numpy array. | def get_nifti1hdr_from_h5attrs(h5attrs):
hdr = nib.Nifti1Header()
for k in list(h5attrs.keys()):
hdr[str(k)] = np.array(h5attrs[k])
return hdr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dict(\n self,\n attributes: Iterable[str] = (\"xyz\", \"viewdir\", \"imgsz\", \"f\", \"c\", \"k\", \"p\"),\n ) -> Dict[str, tuple]:\n return {key: helpers.numpy_to_native(getattr(self, key)) for key in attributes}",
"def decode(self, attr_value):\n # Set the attribute type\n... | [
"0.6273163",
"0.6238491",
"0.60178626",
"0.59820515",
"0.59540015",
"0.5917772",
"0.5784124",
"0.56589144",
"0.5649177",
"0.55536574",
"0.5443483",
"0.54375136",
"0.5435946",
"0.53815705",
"0.53619564",
"0.5360929",
"0.5357357",
"0.5350832",
"0.53446954",
"0.5331633",
"0.5331... | 0.4993594 | 55 |
Constructs a new object and sets the err_code. | def __init__(self, err_code=None):
self.err_code = err_code
if self.err_code in [member.value for name, member in NrfjprogdllErr.__members__.items()]:
err_str = 'An error was reported by NRFJPROG DLL: {} {}.'.format(self.err_code, NrfjprogdllErr(self.err_code).name)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, from_email):\n self.code = 400\n self.from_email = from_email\n Error.__init__(self)",
"def __init__(self, cmd, returncode, err):\n self.cmd = cmd\n self.returncode = returncode\n self.stderr = err\n super(Error, self).__init__(\"%s(%d):\\n%s\" ... | [
"0.7250533",
"0.7121805",
"0.67407286",
"0.67291516",
"0.6727062",
"0.6712496",
"0.65943885",
"0.6573297",
"0.65446734",
"0.653595",
"0.64752626",
"0.6393396",
"0.63846684",
"0.6342004",
"0.6335791",
"0.63228005",
"0.63133067",
"0.62776124",
"0.62608504",
"0.62608504",
"0.626... | 0.7363331 | 0 |
Reads one uint32_t from the given address. | def read_u32(self, addr):
if not self._is_u32(addr):
raise ValueError('The addr parameter must be an unsigned 32-bit value.')
addr = ctypes.c_uint32(addr)
data = ctypes.c_uint32()
result = self._lib.NRFJPROG_read_u32(addr, ctypes.byref(data))
if result != Nrfjprogdl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_uint32(self):\n bytes = self.data[:4]\n value = struct.unpack('!I',bytes)[0]\n self.data = self.data[4:]\n return value",
"def read_uint32(self, timeout = 0):\n return struct.unpack(\"!I\", self.read(4, timeout))[0]",
"def UINT32(dump,addr):\n return dump.ROM[addr... | [
"0.74605775",
"0.72654206",
"0.72361827",
"0.72340083",
"0.7198595",
"0.69844973",
"0.6983256",
"0.689552",
"0.689552",
"0.6859159",
"0.6682239",
"0.64660364",
"0.64456624",
"0.6412558",
"0.6404227",
"0.6378974",
"0.6332016",
"0.6254665",
"0.6211742",
"0.61968654",
"0.6163783... | 0.73873127 | 1 |
Reads the number of RAM sections in the device. | def read_ram_sections_count(self):
count = ctypes.c_uint32()
result = self._lib.NRFJPROG_read_ram_sections_count(ctypes.byref(count))
if result != NrfjprogdllErr.SUCCESS:
raise APIError(result)
return count.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_ram_sections_size(self):\n sections_size_list_size = ctypes.c_uint32(self.read_ram_sections_count())\n sections_size = (ctypes.c_uint32 * sections_size_list_size.value)()\n \n result = self._lib.NRFJPROG_read_ram_sections_size(ctypes.byref(sections_size), sections_size_list_siz... | [
"0.7352075",
"0.6750111",
"0.6580009",
"0.65029943",
"0.6450874",
"0.64242095",
"0.64123845",
"0.64123845",
"0.6306166",
"0.6302806",
"0.6284676",
"0.6202259",
"0.614262",
"0.61313456",
"0.6099081",
"0.6061234",
"0.60554683",
"0.6038339",
"0.60124433",
"0.6008071",
"0.5995252... | 0.790749 | 0 |
Reads the size in bytes of the RAM sections in the device. | def read_ram_sections_size(self):
sections_size_list_size = ctypes.c_uint32(self.read_ram_sections_count())
sections_size = (ctypes.c_uint32 * sections_size_list_size.value)()
result = self._lib.NRFJPROG_read_ram_sections_size(ctypes.byref(sections_size), sections_size_list_size)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ram_size(self):\n\t\treturn call_sdk_function('PrlVmCfg_GetRamSize', self.handle)",
"def ram_size(self) -> pulumi.Output[float]:\n return pulumi.get(self, \"ram_size\")",
"def get_host_ram_size(self):\n\t\treturn call_sdk_function('PrlSrvCfg_GetHostRamSize', self.handle)",
"def get_total_ram_s... | [
"0.76060396",
"0.7243078",
"0.7214628",
"0.71283555",
"0.69231516",
"0.6875077",
"0.6868923",
"0.680422",
"0.678019",
"0.6732679",
"0.6701869",
"0.6700879",
"0.6689206",
"0.66586924",
"0.6651337",
"0.6593511",
"0.6593511",
"0.65704083",
"0.6569436",
"0.65309244",
"0.64161175"... | 0.76325065 | 0 |
Reads the version of the device connected to the emulator. | def read_device_version(self):
version = ctypes.c_int()
result = self._lib.NRFJPROG_read_device_version(ctypes.byref(version))
if result != NrfjprogdllErr.SUCCESS:
raise APIError(result)
return DeviceVersion(version.value).name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_version(self):\n\n # Display info message\n log.info(\"get_version\")\n\n # By default empty string\n version = \"\"\n\n # Run get version on the device\n output = await self.send_command(self.cmd_get_version)\n\n # Seek \"Version \" and \",\" to get t... | [
"0.74363184",
"0.7408226",
"0.69415605",
"0.6938506",
"0.6823203",
"0.66631424",
"0.6620424",
"0.6445345",
"0.6418246",
"0.63731045",
"0.63592994",
"0.6358473",
"0.63533896",
"0.6347753",
"0.6342288",
"0.63346815",
"0.630771",
"0.62881714",
"0.628783",
"0.62597597",
"0.623962... | 0.7234476 | 2 |
Ensure correct exception is raised when invalid email specified. | def test_initializer_with_bad_emails_passed(self):
for bad_email in self.bad_emails:
with raises(GTmetrixInvalidEmail):
gt = GTmetrixInterface(bad_email) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_email_when_logging_in(self):\n pass",
"def validate_email(self, email):\n user = User.query.filter_by(email=email.data).first()\n if user is not None:\n raise ValidationError('Please use a different email address.')",
"def test_invalid_email_account_input(self):... | [
"0.7454961",
"0.7422428",
"0.73768336",
"0.7277472",
"0.7224521",
"0.71356344",
"0.7091218",
"0.7074175",
"0.7058544",
"0.70581603",
"0.69338495",
"0.6890561",
"0.6887649",
"0.68856263",
"0.6860983",
"0.6849489",
"0.68414706",
"0.6829037",
"0.6808504",
"0.6803273",
"0.6792323... | 0.62169564 | 96 |
Ensure correct exception is raised for invalid email via settings. | def test_initializer_with_bad_emails_default(self):
for bad_email in self.bad_emails:
with raises(GTmetrixInvalidEmail):
settings.GTMETRIX_REST_API_EMAIL = bad_email
gt = GTmetrixInterface() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_email_when_logging_in(self):\n pass",
"def test_invalid_email_address_input(self):\n email_addr = '*@domain.loc'\n addr = SpokeEmailAddress(self.org_name, self.user_id)\n self.assertRaises(error.InputError, addr.get, email_addr)",
"def test_invalid_email_account_inp... | [
"0.7331171",
"0.6790501",
"0.67648584",
"0.6653664",
"0.6649247",
"0.64694893",
"0.64140385",
"0.64044905",
"0.6383289",
"0.63709015",
"0.62525195",
"0.6233839",
"0.6228184",
"0.6219368",
"0.62145823",
"0.61761713",
"0.6173339",
"0.6140917",
"0.6128471",
"0.6126067",
"0.61086... | 0.6298328 | 10 |
Ensure correct exception is raised when email is None. | def test_email_is_None(self):
settings.GTMETRIX_REST_API_EMAIL = None
with raises(GTmetrixEmailIsNone):
gt = GTmetrixInterface() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_email_when_logging_in(self):\n pass",
"def validate_email(self, email):\n user = User.query.filter_by(email=email.data).first()\n if user is not None:\n raise ValidationError('Please use a different email address.')",
"def test_private_create_user_without_email(... | [
"0.70582503",
"0.680179",
"0.674283",
"0.6674118",
"0.6627228",
"0.6544808",
"0.65004957",
"0.6496558",
"0.6476551",
"0.6432398",
"0.64202744",
"0.64022255",
"0.639223",
"0.6388189",
"0.63824826",
"0.63722885",
"0.6336065",
"0.628049",
"0.6271358",
"0.6251391",
"0.6246619",
... | 0.71447194 | 0 |
Ensure correct exception is raised when API key is None. | def test_api_key_is_None(self):
settings.GTMETRIX_REST_API_KEY = None
with raises(GTmetrixAPIKeyIsNone):
gt = GTmetrixInterface() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_api_key(self):\n\n self.assertRaises(Exception, kaput.init, None, '123')",
"def test_key_none(self):\n try:\n AlphaVantage()\n self.fail(msg='A None api key must raise an error')\n except ValueError:\n self.assertTrue(True)",
"def test_key_none(... | [
"0.77560174",
"0.76446766",
"0.76446766",
"0.7602997",
"0.7458726",
"0.7422191",
"0.7373884",
"0.7192134",
"0.71258014",
"0.7118628",
"0.7076128",
"0.70733726",
"0.701515",
"0.6926657",
"0.6896923",
"0.6856009",
"0.68159527",
"0.67521113",
"0.6700488",
"0.66895646",
"0.665630... | 0.7506823 | 4 |
Property that returns the name (ref) of this font. | def ref(self) -> str:
return self._ref | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getElementName(self):\n return _libsbml.TextGlyph_getElementName(self)",
"def font(self):\n return self[\"font\"]",
"def font(self):\n return self[\"font\"]",
"def font(self):\n return self[\"font\"]",
"def font(self):\n\treturn self.m_font",
"def font(self):\n\treturn sel... | [
"0.7318253",
"0.72829306",
"0.72829306",
"0.72829306",
"0.71841156",
"0.71841156",
"0.70032424",
"0.69875574",
"0.69780207",
"0.6975267",
"0.69513994",
"0.69286174",
"0.689845",
"0.6875197",
"0.6855921",
"0.6830856",
"0.6830856",
"0.6830856",
"0.68273556",
"0.68273556",
"0.68... | 0.0 | -1 |
Testing .should_render with authenticated user in readonly mode | def test_should_render_with_user_in_read_only(self) -> None:
self.request.user = User.objects.get(username='doc')
# Turning on read-only mode prevents creation of some objects so call
# _create_request_context first.
request_context = self._create_request_context(user=self.request.user)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_with_authenticated(self) -> None:\n with override_feature_check(unified_banner_feature.feature_id, False):\n self.request.user = User.objects.get(username='doc')\n self.assertTrue(\n self.action.should_render(\n context=self._cre... | [
"0.74514544",
"0.733686",
"0.73367846",
"0.731717",
"0.72554845",
"0.7090943",
"0.7090943",
"0.7042401",
"0.6940355",
"0.6940355",
"0.68994427",
"0.68871844",
"0.68871844",
"0.68701977",
"0.68701977",
"0.6814364",
"0.677291",
"0.6734949",
"0.66852564",
"0.6663528",
"0.6537689... | 0.80076516 | 0 |
Testing .should_render with superuser in readonly mode | def test_should_render_with_superuser_in_read_only(self) -> None:
self.request.user = User.objects.get(username='admin')
# Turning on read-only mode prevents creation of some objects so call
# _create_request_context first.
request_context = self._create_request_context(user=self.reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_with_user_in_read_only(self) -> None:\n self.request.user = User.objects.get(username='doc')\n\n # Turning on read-only mode prevents creation of some objects so call\n # _create_request_context first.\n request_context = self._create_request_context(user=self.req... | [
"0.797763",
"0.75428736",
"0.7526946",
"0.73408777",
"0.73408777",
"0.7320224",
"0.71348166",
"0.71348166",
"0.7109874",
"0.7090042",
"0.7058259",
"0.7058259",
"0.70454884",
"0.70380366",
"0.69843984",
"0.6957058",
"0.69528633",
"0.6949069",
"0.6949069",
"0.6828154",
"0.68024... | 0.80491155 | 0 |
Testing AddGeneralCommentAction.should_render with authenticated user | def test_should_render_with_authenticated(self) -> None:
with override_feature_check(unified_banner_feature.feature_id, False):
self.request.user = User.objects.get(username='doc')
self.assertTrue(
self.action.should_render(
context=self._create_reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_user_with_can_edit_reviewrequest(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(user=self.create_user())))",
"def test_should_render_for_user(self) -> None:\n self.assertFalse(self.action.should_render(\n ... | [
"0.7207594",
"0.71631515",
"0.7016978",
"0.66650844",
"0.66650844",
"0.6650457",
"0.6641605",
"0.661972",
"0.6585243",
"0.652319",
"0.6433386",
"0.6395934",
"0.63753045",
"0.6296443",
"0.62556934",
"0.6254704",
"0.619638",
"0.6138733",
"0.61252654",
"0.6124634",
"0.6124634",
... | 0.6983535 | 3 |
Testing AddGeneralCommentAction.should_render with authenticated user | def test_should_render_with_anonymous(self) -> None:
with override_feature_check(unified_banner_feature.feature_id, False):
self.assertFalse(
self.action.should_render(context=self._create_request_context())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_user_with_can_edit_reviewrequest(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(user=self.create_user())))",
"def test_should_render_for_user(self) -> None:\n self.assertFalse(self.action.should_render(\n ... | [
"0.7207006",
"0.71624136",
"0.7014683",
"0.6983014",
"0.6664293",
"0.6664293",
"0.6649253",
"0.6640937",
"0.6618635",
"0.6583004",
"0.65242714",
"0.64344454",
"0.6396997",
"0.63738066",
"0.62975335",
"0.6254493",
"0.6253624",
"0.6196815",
"0.6137627",
"0.6125279",
"0.6123602"... | 0.0 | -1 |
Testing DeleteAction.should_render with standard user | def test_should_render_with_published(self) -> None:
self.assertFalse(self.action.should_render(
context=self._create_request_context(
user=self.create_user(),
delete_reviewrequest=False))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete(self, client, users):\n user = users[0]\n url = reverse('users:delete', args=(user.pk,))\n response = client.get(url)\n assert response.status_code == 405\n response = client.post(url)\n assert response.status_code == 302\n assert response.url == rev... | [
"0.70547354",
"0.70107913",
"0.7004414",
"0.69771314",
"0.69582945",
"0.6956348",
"0.6901423",
"0.6901423",
"0.6869667",
"0.6846094",
"0.6804972",
"0.6790064",
"0.6781285",
"0.6732302",
"0.6727654",
"0.67233634",
"0.67095923",
"0.66421187",
"0.66409165",
"0.6590441",
"0.65790... | 0.0 | -1 |
Testing SubmitAction.should_render with delete_reviewrequest permission | def test_should_render_with_permission(self) -> None:
self.assertTrue(self.action.should_render(
context=self._create_request_context(
user=self.create_user()))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_with_submitted(self) -> None:\n self.assertFalse(self.action.should_render(\n context=self._create_request_context(\n status=ReviewRequest.SUBMITTED,\n can_edit_reviewrequest=False)))",
"def test_should_render_with_submitted(self) -> None:\n ... | [
"0.75271714",
"0.7344784",
"0.7235159",
"0.7139551",
"0.70953876",
"0.70604724",
"0.70341945",
"0.68519115",
"0.6822009",
"0.67859674",
"0.67341405",
"0.66789305",
"0.65090257",
"0.635289",
"0.63489854",
"0.6322629",
"0.62811244",
"0.62464947",
"0.61629283",
"0.6130923",
"0.6... | 0.6204196 | 18 |
Testing DownloadDiffAction.should_render on diff viewer revision page | def test_should_render_on_diff_viewer_revision(self) -> None:
self.assertTrue(self.action.should_render(
context=self._create_request_context(
url_name='view-diff-revision'))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_on_diff_viewer(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(\n url_name='view-diff')))",
"def test_should_render_on_interdiff(self) -> None:\n self.assertTrue(self.action.should_render(\n ... | [
"0.83775145",
"0.8289545",
"0.78473103",
"0.71890813",
"0.7097729",
"0.6764223",
"0.650113",
"0.64987487",
"0.6482964",
"0.6395149",
"0.6214179",
"0.62034947",
"0.6025509",
"0.5973645",
"0.5962278",
"0.59599113",
"0.5933343",
"0.5931815",
"0.5916268",
"0.5905906",
"0.57801276... | 0.8616411 | 0 |
Testing DownloadDiffAction.should_render on review request page with repository but no diff | def test_should_render_on_review_request_with_repository(self) -> None:
review_request = self.create_review_request(create_repository=True)
self.assertFalse(self.action.should_render(
context=self._create_request_context(
review_request=review_request,
url_na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_on_diff_viewer(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(\n url_name='view-diff')))",
"def test_should_render_on_review_request_with_repository_and_diff(\n self,\n ) -> None:\n review... | [
"0.7754138",
"0.7713281",
"0.7699996",
"0.7438683",
"0.7124885",
"0.7084052",
"0.69895416",
"0.6968374",
"0.6928051",
"0.6649646",
"0.6631256",
"0.66295385",
"0.6499621",
"0.64620256",
"0.64596045",
"0.64441293",
"0.644155",
"0.6379703",
"0.6350943",
"0.6334656",
"0.62594265"... | 0.6945492 | 8 |
Testing DownloadDiffAction.should_render on review request page with repository and diff history | def test_should_render_on_review_request_with_repository_and_diff(
self,
) -> None:
review_request = self.create_review_request(create_repository=True)
self.create_diffset(review_request)
self.assertTrue(self.action.should_render(
context=self._create_request_context(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_on_diff_viewer(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(\n url_name='view-diff')))",
"def test_should_render_on_interdiff(self) -> None:\n self.assertTrue(self.action.should_render(\n ... | [
"0.77910864",
"0.7777426",
"0.7682554",
"0.7187873",
"0.6929177",
"0.69143766",
"0.66998",
"0.6668523",
"0.661293",
"0.657886",
"0.6427038",
"0.64234275",
"0.64174855",
"0.6410569",
"0.6212819",
"0.6206998",
"0.618092",
"0.6180652",
"0.61484027",
"0.612429",
"0.6051135",
"0... | 0.7816348 | 0 |
Testing DownloadDiffAction.should_render on review request page without repository | def test_should_render_on_review_request_without_repository(self) -> None:
self.assertFalse(self.action.should_render(
context=self._create_request_context(
url_name='review-request-detail'))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_on_diff_viewer(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(\n url_name='view-diff')))",
"def test_should_render_on_review_request_with_repository_and_diff(\n self,\n ) -> None:\n review... | [
"0.7697551",
"0.7670038",
"0.7613932",
"0.7427935",
"0.71732986",
"0.7168049",
"0.7008761",
"0.69408983",
"0.6758537",
"0.6706286",
"0.66249204",
"0.6513537",
"0.64972883",
"0.6437695",
"0.6418223",
"0.6402991",
"0.633593",
"0.63318497",
"0.630383",
"0.6290195",
"0.625938",
... | 0.7407111 | 4 |
Testing EditReviewAction.should_render with authenticated user | def test_should_render_with_authenticated(self) -> None:
with override_feature_check(unified_banner_feature.feature_id, False):
self.assertTrue(self.action.should_render(
context=self._create_request_context(
user=User.objects.get(username='doc')))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_user_with_can_edit_reviewrequest(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(user=self.create_user())))",
"def test_should_render_for_user(self) -> None:\n self.assertFalse(self.action.should_render(\n ... | [
"0.8599244",
"0.76221794",
"0.75852954",
"0.7081106",
"0.70259064",
"0.68972456",
"0.68813974",
"0.68464667",
"0.6834606",
"0.6803036",
"0.6798159",
"0.6798159",
"0.6784587",
"0.6759837",
"0.66952646",
"0.6682992",
"0.666559",
"0.66337097",
"0.6616717",
"0.65788424",
"0.65348... | 0.6661435 | 17 |
Testing EditReviewAction.should_render with authenticated user | def test_should_render_with_anonymous(self) -> None:
with override_feature_check(unified_banner_feature.feature_id, False):
self.assertFalse(self.action.should_render(
context=self._create_request_context())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_user_with_can_edit_reviewrequest(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(user=self.create_user())))",
"def test_should_render_for_user(self) -> None:\n self.assertFalse(self.action.should_render(\n ... | [
"0.8599678",
"0.7624998",
"0.7587424",
"0.70835865",
"0.70292944",
"0.69008857",
"0.6884847",
"0.6847483",
"0.6838115",
"0.68066674",
"0.6802112",
"0.6802112",
"0.6788367",
"0.6762419",
"0.6697853",
"0.66866815",
"0.66681165",
"0.6663902",
"0.6663902",
"0.66350853",
"0.661863... | 0.0 | -1 |
Testing EditReviewAction.should_render with authenticated user in readonly mode | def test_should_render_with_user_in_read_only(self) -> None:
with override_feature_check(unified_banner_feature.feature_id, False):
super().test_should_render_with_user_in_read_only() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_user_with_can_edit_reviewrequest(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(user=self.create_user())))",
"def test_should_render_with_user_in_read_only(self) -> None:\n self.request.user = User.objects.get(use... | [
"0.83706677",
"0.7599034",
"0.7584141",
"0.75592184",
"0.725162",
"0.7045682",
"0.7045682",
"0.7036535",
"0.7022729",
"0.69853616",
"0.6905408",
"0.68588436",
"0.6828346",
"0.6818323",
"0.6783553",
"0.6658626",
"0.662889",
"0.65211576",
"0.652105",
"0.6498449",
"0.6498449",
... | 0.6394639 | 23 |
Testing EditReviewAction.should_render with superuser in readonly mode | def test_should_render_with_superuser_in_read_only(self) -> None:
with override_feature_check(unified_banner_feature.feature_id, False):
super().test_should_render_with_superuser_in_read_only() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_user_with_can_edit_reviewrequest(self) -> None:\n self.assertTrue(self.action.should_render(\n context=self._create_request_context(user=self.create_user())))",
"def test_should_render_for_user(self) -> None:\n self.assertFalse(self.action.should_render(\n ... | [
"0.83639276",
"0.76599526",
"0.76423806",
"0.76321733",
"0.74272186",
"0.7270355",
"0.7104314",
"0.7066008",
"0.70650584",
"0.70097446",
"0.6995623",
"0.6946107",
"0.6946107",
"0.68171036",
"0.67885864",
"0.6787406",
"0.6756553",
"0.6676307",
"0.6676307",
"0.6650827",
"0.6616... | 0.660424 | 21 |
Testing ShipItAction.should_render with authenticated user in readonly mode | def test_should_render_with_user_in_read_only(self) -> None:
with override_feature_check(unified_banner_feature.feature_id, False):
super().test_should_render_with_user_in_read_only() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_with_user_in_read_only(self) -> None:\n self.request.user = User.objects.get(username='doc')\n\n # Turning on read-only mode prevents creation of some objects so call\n # _create_request_context first.\n request_context = self._create_request_context(user=self.req... | [
"0.75318605",
"0.7349973",
"0.72334635",
"0.7210595",
"0.7160369",
"0.70847636",
"0.7055283",
"0.7055283",
"0.6923289",
"0.67042536",
"0.664933",
"0.6550036",
"0.65016043",
"0.65016043",
"0.64827687",
"0.64827687",
"0.6451957",
"0.63858503",
"0.6344336",
"0.6324199",
"0.62915... | 0.6545128 | 12 |
Testing UpdateMenuAction.should_render for normal user | def test_should_render_for_user(self) -> None:
self.assertFalse(self.action.should_render(
context=self._create_request_context(
user=self.create_user(),
can_edit_reviewrequest=False))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_render_for_user(self) -> None:\n self.assertFalse(self.action.should_render(\n context=self._create_request_context(\n can_change_status=False,\n user=self.create_user())))",
"def test_should_render_user_with_can_change_status(self) -> None:\n ... | [
"0.7358709",
"0.69584554",
"0.6839753",
"0.6834072",
"0.6668127",
"0.66482276",
"0.6533988",
"0.6523498",
"0.65175974",
"0.63896227",
"0.63859",
"0.6342983",
"0.6247167",
"0.61903006",
"0.61903006",
"0.6144086",
"0.61329347",
"0.61329347",
"0.60927844",
"0.6068036",
"0.603191... | 0.6862708 | 2 |
Creates a local `PasswordPolicy` instance Parameters can be supplied on creation of the instance or given by setting the properties on the instance after creation. Parameters marked as `required` must be set for one or more operations on the entity. For details on when they are required please see the documentation for... | def __init__(self, _client=None, minimum_length=None):
super().__init__(_client=_client)
# inline imports for avoiding circular references and bulk imports
# fields
self._minimum_length = fields.IntegerField(value=minimum_length) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: Optional[PolicyPasswordDefaultArgs] = None,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def AddPasswordPolicyMinLength(parser):\n parser.add_argument(\n '--password-policy-min-length',... | [
"0.61535984",
"0.5872361",
"0.5814216",
"0.54333234",
"0.5307084",
"0.52602905",
"0.52050066",
"0.5192926",
"0.5150016",
"0.51398796",
"0.5077292",
"0.5067204",
"0.50543684",
"0.5034869",
"0.5034869",
"0.49692696",
"0.4968326",
"0.49046943",
"0.48645148",
"0.4864281",
"0.4857... | 0.0 | -1 |
When the game is over clear the screen and display a game over message | def displayGameOver():
screen.fill(pygame.Color('black'), (0, 0, SCREEN_SIZE[0], SCREEN_SIZE[1]))
goText, rect1 = GAME_FONT.render('Game Over', WHITE)
paText, rect2 = GAME_FONT.render('Press [Enter] to play again', WHITE)
width1 = goText.get_width()
height1 = goText.get_height()
width2 = paText.get_width()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game_over(self):\n if self.alive:\n return\n\n self.screen.fill(Color.BLACK)\n self.draw_text(\n \"GAME OVER\", WIN_CENTER, font=FONT_M, size=48, color=Color.WHITE\n )\n again = \"Press any key to play again\"\n again_pos = CENTER_W, WIN_H - BLOCK... | [
"0.80920416",
"0.78605276",
"0.783621",
"0.7732328",
"0.77193934",
"0.76720893",
"0.76268965",
"0.7622656",
"0.7472521",
"0.74137056",
"0.73719174",
"0.73044",
"0.72926575",
"0.728372",
"0.72714436",
"0.7237865",
"0.7228063",
"0.72257113",
"0.7140525",
"0.70916843",
"0.707990... | 0.74491936 | 9 |
Returns the length of the dataset. | def __len__(self):
if self.mode.lower() == 'train':
return len(self.train_data)
elif self.mode.lower() == 'val':
return len(self.val_data)
elif self.mode.lower() == 'test':
return len(self.test_data)
else:
raise RuntimeError("Unexpected dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return self._dataset.size(dirs=self._dirs)",
"def dataset_size(self):\n return self.dataset.size",
"def length(self) -> int:\n return len(self.data)",
"def size(self) -> int:\r\n return self.da.length()",
"def size(self) -> int:\n return self.da.lengt... | [
"0.83699137",
"0.82944065",
"0.82489866",
"0.8196022",
"0.8165865",
"0.8165865",
"0.8165865",
"0.8165865",
"0.8165246",
"0.8165246",
"0.8165246",
"0.8137399",
"0.8098832",
"0.8098466",
"0.8093488",
"0.8084871",
"0.80494523",
"0.79925597",
"0.79760975",
"0.7974805",
"0.7961297... | 0.7864654 | 32 |
Return True if ``i`` is contained in FreeGroup. | def __contains__(self, i):
if not isinstance(i, FreeGroupElement):
return False
group = i.group
return self == group | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(self, g):\n if not isinstance(g, FreeGroupElement):\n return False\n elif self != g.group:\n return False\n else:\n return True",
"def __contains__(self, i):\n if not isinstance(i, Permutation):\n raise TypeError(\"A Permutation... | [
"0.7190415",
"0.6773943",
"0.65448916",
"0.6507174",
"0.6496256",
"0.6340962",
"0.6328278",
"0.60016507",
"0.5907625",
"0.5897921",
"0.586647",
"0.568023",
"0.5636958",
"0.5635286",
"0.56333977",
"0.56119436",
"0.55686116",
"0.55582297",
"0.5503539",
"0.5497165",
"0.54368114"... | 0.86510825 | 0 |
No ``FreeGroup`` is equal to any "other" ``FreeGroup``. | def __eq__(self, other):
return self is other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n group = self.group\n if not isinstance(other, group.dtype):\n return False\n return tuple.__eq__(self, other)",
"def __eq__(self, other):\n if not isinstance(other, GroupModel):\n return False\n\n return self.__dict__ == other.__... | [
"0.680781",
"0.6629172",
"0.649419",
"0.6467049",
"0.6384119",
"0.63658315",
"0.6360766",
"0.63132966",
"0.63064766",
"0.6254017",
"0.622681",
"0.6146064",
"0.6144021",
"0.6121116",
"0.6029886",
"0.59881395",
"0.5987677",
"0.5944904",
"0.5887829",
"0.58711296",
"0.5870397",
... | 0.5505167 | 74 |
Return the index of the generator `gen` from ``(f_0, ..., f_(n1))``. Examples ======== >>> from sympy.combinatorics import free_group >>> F, x, y = free_group("x, y") >>> F.index(y) 1 >>> F.index(x) 0 | def index(self, gen):
if isinstance(gen, self.dtype):
return self.generators.index(gen)
else:
raise ValueError("expected a generator of Free Group %s, got %s" % (self, gen)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_group_index(self, index):\n\n g_index = 0\n for group in self.groups:\n if group[0] == index:\n g_index = group[1]\n break\n return g_index",
"def get_index_for_group(groups, which_group):\n group_indexes = np.where(groups == float(which_g... | [
"0.66409075",
"0.5960486",
"0.5729509",
"0.5537799",
"0.5483446",
"0.53788847",
"0.53269875",
"0.52567786",
"0.52378565",
"0.5236926",
"0.5199934",
"0.5187903",
"0.5177708",
"0.5170345",
"0.5170345",
"0.5109942",
"0.51041853",
"0.5096748",
"0.5087298",
"0.50445455",
"0.500817... | 0.76296705 | 0 |
Returns if the group is Abelian. Examples ======== >>> from sympy.combinatorics import free_group >>> f, x, y, z = free_group("x y z") >>> f.is_abelian False | def is_abelian(self):
return self.rank in (0, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_abelian(self):\n if self._is_abelian is not None:\n return self._is_abelian\n\n self._is_abelian = True\n gens = [p._array_form for p in self.generators]\n for x in gens:\n for y in gens:\n if y <= x:\n continue\n ... | [
"0.677203",
"0.5576917",
"0.541992",
"0.539555",
"0.53742665",
"0.521224",
"0.5192372",
"0.51815444",
"0.51405585",
"0.50329155",
"0.49684983",
"0.49408498",
"0.49355304",
"0.49182686",
"0.48758173",
"0.48634103",
"0.4836765",
"0.48366687",
"0.4835472",
"0.4828485",
"0.480235... | 0.7342095 | 0 |
r"""Returns whether the word is cyclically reduced or not. A word is cyclically reduced if by forming the cycle of the word, the word is not reduced, i.e a word w = `a_1 ... a_n` is called cyclically reduced if `a_1 \ne a_n^{1}`. Examples ======== >>> from sympy.combinatorics import free_group >>> F, x, y = free_group(... | def is_cyclically_reduced(self):
if not self:
return True
return self[0] != self[-1]**-1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_cyclic(self):\n return self._.b[0] == 2 and self._.c[-1] in [1, 2] and \\\n all(x == 1 for x in self._.b[1:-1] + self._.c[1:-1])",
"def is_cyclic_conjugate(self, w):\n l1 = len(self)\n l2 = len(w)\n if l1 != l2:\n return False\n w1 = self.identity_c... | [
"0.6900463",
"0.67388237",
"0.6497785",
"0.64112645",
"0.632175",
"0.6258167",
"0.6223497",
"0.6168997",
"0.6069463",
"0.5856837",
"0.58147407",
"0.5768923",
"0.5700124",
"0.5636912",
"0.5630098",
"0.5530994",
"0.5505602",
"0.5505602",
"0.5478468",
"0.54674065",
"0.5448675",
... | 0.7015829 | 0 |
Return if the project can be transfered to another member. | def check_if_project_can_be_transfered(project, new_owner):
if project.owner is None:
return {'can_be_updated': False, 'reason': ERROR_PROJECT_WITHOUT_OWNER}
if project.owner == new_owner:
return (True, None)
if project.is_private:
current_projects = new_owner.owned_projects.filter... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_object_permission(self, request, view, obj):\n if Contributor.objects.filter(project=obj, user=request.user):\n return True\n else:\n return False",
"def check_if_project_can_be_created_or_updated(project):\n if project.owner is None:\n return {'can_be_update... | [
"0.63639104",
"0.6322275",
"0.61260897",
"0.6048867",
"0.6004571",
"0.5937367",
"0.59325814",
"0.5924727",
"0.5855072",
"0.584445",
"0.58444226",
"0.58417124",
"0.5816573",
"0.58079535",
"0.5795928",
"0.57497674",
"0.57416356",
"0.5723752",
"0.5709887",
"0.5696954",
"0.566198... | 0.74156016 | 0 |
Tokenizes each sentence in a given text. | def tokenize(text):
text.lower() # convert to lowercase
text = re.sub(r"[^a-zA-Z0-9]", " ", text) #remove punctuation
words = word_tokenize(text) # tokenize by individual word
words = [w for w in words if w not in stopwords.words("english")] #remove stop words
lemmed = [WordNetLemmatizer().lemm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(text):\n sentence = Sentence(text)\n return sentence.tokens()",
"def sentence_tokenizer(text):\n return sent_tokenize(text)",
"def process_token_sentence(text):\n\n sentences = nltk.sent_tokenize(text)\n tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences]\... | [
"0.84118587",
"0.8093714",
"0.7868064",
"0.78056514",
"0.77664",
"0.7671708",
"0.7608955",
"0.7574081",
"0.7526311",
"0.7507174",
"0.75069135",
"0.7493405",
"0.7488409",
"0.74365354",
"0.7431596",
"0.7421613",
"0.7403201",
"0.73916394",
"0.73871404",
"0.73830426",
"0.73816246... | 0.7162911 | 57 |
Return True if the user is authenticated. | def is_authenticated(self):
return self.authenticated | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_authenticated(self):\n return self.user is not None and self.state == AuthenticationOptions.authenticated",
"def is_authenticated(self):\n return bool(get_auth_token())",
"def is_authenticated(self):\n return True",
"def is_authenticated(self):\n return True",
"def is_aut... | [
"0.8739372",
"0.87086535",
"0.86574197",
"0.86574197",
"0.86574197",
"0.86574197",
"0.86574197",
"0.86574197",
"0.86574197",
"0.8613915",
"0.8609252",
"0.8578436",
"0.83723366",
"0.83587176",
"0.8258534",
"0.82273275",
"0.8209421",
"0.8200795",
"0.8174884",
"0.81280386",
"0.8... | 0.8580474 | 17 |
False, as anonymous users aren't supported. | def is_anonymous():
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_anonymous(self):\r\n return False",
"def is_anonymous(self):\n return False",
"def is_anonymous(self):\n return False",
"def is_anonymous(self):\n return False",
"def is_anonymous(self):\n return False",
"def is_anonymous(self):\n return False",
"def is_... | [
"0.8379807",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"0.8359887",
"... | 0.8561902 | 0 |
Converts TFRecord files into a shuffled TensorFlow Dataset. | def read_spectra_data(filename, spectrum_length, data_folder=''):
if type(filename) != str or type(data_folder) != str:
raise TypeError('The name of the file and the name of the folder must be strings.')
filename, ext = filename.split('.')
if ext!='tfrecord':
raise ValueError('Only TFRecord ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataset(file_pattern, batch_size, mode):\n\n def _parse(serialized_example):\n \"\"\"Parse serialized example and return feature_dict and label.\n\n Args:\n serialized_example: tf.example to parse.\n\n Returns:\n Parsed features dictionary and label.\n ... | [
"0.70708394",
"0.6984583",
"0.6954118",
"0.69068485",
"0.68694144",
"0.6803351",
"0.67904186",
"0.6775984",
"0.67526853",
"0.66990167",
"0.6654804",
"0.6641447",
"0.6617425",
"0.65913147",
"0.6586793",
"0.65395486",
"0.6520876",
"0.6498638",
"0.6494804",
"0.6481804",
"0.64751... | 0.60523534 | 63 |
Converts TFRecord files into a shuffled TensorFlow Dataset. | def read_pictures_data(filename, pic_size=(), data_folder=''):
if type(filename) != str or type(data_folder) != str:
raise TypeError('The name of the file and the name of the folder must be strings.')
filename, ext = filename.split('.')
if ext!='tfrecord':
raise ValueError('Only TFRecord fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataset(file_pattern, batch_size, mode):\n\n def _parse(serialized_example):\n \"\"\"Parse serialized example and return feature_dict and label.\n\n Args:\n serialized_example: tf.example to parse.\n\n Returns:\n Parsed features dictionary and label.\n ... | [
"0.7071222",
"0.6984681",
"0.6954484",
"0.6907981",
"0.6869055",
"0.68028486",
"0.67925924",
"0.6776728",
"0.67525876",
"0.67019",
"0.6655968",
"0.66426855",
"0.6617795",
"0.65901035",
"0.6587326",
"0.653948",
"0.65190196",
"0.6499118",
"0.6496618",
"0.6484091",
"0.6474525",
... | 0.6170709 | 42 |
r"""return first item from list if found otherwise none okk | def get_first_item(videos):
return next(iter(videos or []), None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(items):\n return next(iter(items or []), None)",
"def first(items):\r\n return items[0]",
"def first(l):\n return next(iter(l), None)",
"def find_first_match(_list, _item):\n for _list_item in _list:\n if _item[\"pid\"] == _list_item[\"pid\"]:\n return _list_item\n ... | [
"0.79093784",
"0.7856811",
"0.78539026",
"0.77249295",
"0.75646484",
"0.75646484",
"0.75035685",
"0.74602383",
"0.7361084",
"0.7292255",
"0.7148363",
"0.7148363",
"0.71095866",
"0.7075033",
"0.7048509",
"0.703273",
"0.7010336",
"0.6988924",
"0.6936167",
"0.69057256",
"0.68409... | 0.7417115 | 8 |
conv2d returns a 2d convolution layer with full stride. | def conv2d(self, x, W):
return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_conv2d():\n img = np.array([\n [0.3, 0.5, 0.7, 0.9],\n [0.1, 0.3, 0.5, 0.7],\n [0.9, 0.7, 0.5, 0.3],\n ])\n template = np.array([\n [1, 0],\n [1, 0],\n ])\n template = np.flipud(np.fliplr(template))\n return fftconvolve(img, template, mode='valid')",
... | [
"0.7630156",
"0.7626982",
"0.7578824",
"0.7464681",
"0.7457871",
"0.7457871",
"0.74261373",
"0.74261373",
"0.74261373",
"0.74261373",
"0.7386211",
"0.73378277",
"0.7330424",
"0.7329812",
"0.73138624",
"0.73019135",
"0.7296958",
"0.72700316",
"0.7246276",
"0.72318506",
"0.7196... | 0.7208653 | 20 |
weight_variable generates a weight variable of a given shape. | def weight_variable(self, shape, var_name):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.get_variable(name=var_name,initializer=initial) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight_variable(shape):\n initial = tf.truncated_normal(shape, stddev=0.1)\n return tf.get_variable(\n 'weight', initializer=initial, regularizer=tf.nn.l2_loss)",
"def weight_variable(shape):\n initial = tf.truncated_normal(shape)\n return tf.Variable(initial)",
"def create_weight_variable(shape):... | [
"0.82676965",
"0.8235079",
"0.8158509",
"0.81565243",
"0.8139453",
"0.8139453",
"0.8139453",
"0.8137277",
"0.8134324",
"0.8134324",
"0.8134324",
"0.8134324",
"0.8134324",
"0.8134324",
"0.8134324",
"0.8134324",
"0.8134324",
"0.8134324",
"0.8120561",
"0.8064735",
"0.79782254",
... | 0.79819095 | 20 |
Get the lattice constants of the state. Returns | def get_lattice_constants(self):
return self._graph_state.get_lattice_constants() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lattice_settings(self):\n return (self.a, self.b, self.c,\n self.alpha*radians, self.beta*radians, self.gamma*radians)",
"def lattice(self):\n return self._lattice",
"def get_constants(self):\n return self.D1, self.D2, self.A1, self.A2, \\\n self.F1, self... | [
"0.6866264",
"0.66561985",
"0.65907115",
"0.6516603",
"0.64904904",
"0.6471194",
"0.64104176",
"0.6378221",
"0.61902696",
"0.61383915",
"0.5984384",
"0.593454",
"0.5927517",
"0.58042145",
"0.5797073",
"0.5797073",
"0.57853884",
"0.57301885",
"0.56958234",
"0.568637",
"0.56670... | 0.85337126 | 0 |
Get the number of vertices in the topology graph. Returns | def get_num_vertices(self):
return self._graph_state.get_num_vertices() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertexCount(self):\n return self._nVertices",
"def num_vertices(self):\r\n return len(self.__graph_dict.keys())",
"def num_vertices(self):\n return self._top_exp.number_of_vertices()",
"def get_vertices_count(self) -> int:\n # TODO: verify the following claim:\n raise N... | [
"0.8494007",
"0.84706014",
"0.84362966",
"0.8408586",
"0.8352349",
"0.82162935",
"0.82021534",
"0.82021534",
"0.81882036",
"0.8073063",
"0.8004586",
"0.79659986",
"0.7869201",
"0.7819893",
"0.77238595",
"0.76018393",
"0.7486051",
"0.7473548",
"0.72208834",
"0.7087607",
"0.708... | 0.8829969 | 0 |
Get the number of edges in the topology graph. Returns | def get_num_edges(self):
return self._graph_state.get_num_edges() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_edges(self) -> int:\n return self.graph.number_of_edges()",
"def edge_count(self) -> int:\n return self._n_edges",
"def num_of_edge(self):\n try:\n return self.edges\n except:\n print(\"ERROR: No graph exists\")",
"def return_num_edges(self):\n ... | [
"0.8686444",
"0.8638674",
"0.847325",
"0.8345188",
"0.83200467",
"0.8304378",
"0.829368",
"0.8270642",
"0.82480764",
"0.8228368",
"0.82062995",
"0.820033",
"0.8175072",
"0.8133289",
"0.81150794",
"0.8088452",
"0.8087728",
"0.8086729",
"0.8018403",
"0.79606706",
"0.787471",
... | 0.85895705 | 2 |
Yield the atoms of the molecule being constructed. Yields | def get_atoms(self):
yield from self._molecule_state.get_atoms() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_atoms(self):\n\n yield from self._atoms",
"def iter_atoms(self):\n for frag in self.iter_fragments():\n for atm in frag.iter_atoms():\n yield atm",
"def iter_atoms(self):\n for frag in self.fragment_list:\n for atm in frag.atom_list:\n ... | [
"0.8011574",
"0.78660303",
"0.78034097",
"0.7753432",
"0.7739809",
"0.75989985",
"0.7531456",
"0.7494171",
"0.74786854",
"0.7377939",
"0.7361573",
"0.7354699",
"0.7341813",
"0.7309324",
"0.72983533",
"0.7130057",
"0.7130057",
"0.7050334",
"0.7050334",
"0.6969389",
"0.6953987"... | 0.81352127 | 0 |
Yield the building blocks. Building blocks are yielded in an order based on their position in the topology graph. For two equivalent topology graphs, but with different building blocks, equivalently positioned building blocks will be yielded at the same time. Yields | def get_building_blocks(self):
yield from self._graph_state.get_building_blocks() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blocks(self):\n if self._ast:\n for block in self._ast[2]:\n yield block",
"def get_building_blocks(self, level=1, debug=False):\n\n def get_aidx_star(dic, ias, kas):\n iat, jat = kas\n if dic[iat] == 0:\n return iat, jat\n ... | [
"0.6349287",
"0.62876844",
"0.6051521",
"0.6021396",
"0.59326154",
"0.5890511",
"0.5828531",
"0.57174164",
"0.56966513",
"0.56827176",
"0.5629966",
"0.5613233",
"0.55688125",
"0.55533314",
"0.5526669",
"0.55260444",
"0.5520337",
"0.5511756",
"0.54762584",
"0.546514",
"0.54404... | 0.74806494 | 0 |
Convert UTC date to milliseconds If using offset strings add "UTC" to date string e.g. "now UTC", "11 hours ago UTC" | def date_to_milliseconds(date_str):
epoch = datetime.utcfromtimestamp(0).replace(tzinfo=pytz.utc)
d = dateparser.parse(date_str)
if d.tzinfo is None or d.tzinfo.utcoffset(d) is None:
d = d.replace(tzinfo=pytz.utc)
return int((d - epoch).total_seconds() * 1000.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def localtime2utc(date):\n return date + (datetime.utcnow() - datetime.now())",
"def utctime(stamp):\n return stamp + utc_offset",
"def utc_offset_convert(utc_offset):\n offset=abs(utc_offset)\n hour=str(offset//3600)\n if len(hour)==1:\n hour=str(0)+hour\n\n minute=str(offset%3600//60... | [
"0.64481956",
"0.634694",
"0.6254732",
"0.6003736",
"0.5982545",
"0.59646976",
"0.5949488",
"0.5901419",
"0.58542246",
"0.58535445",
"0.5822483",
"0.5822483",
"0.5817604",
"0.5816955",
"0.58017975",
"0.5787012",
"0.57715726",
"0.5726599",
"0.5696866",
"0.56891525",
"0.5687866... | 0.6040377 | 3 |
Determines the number of excess connections and nodes between two genomes. | def count_excess_genes(genome1, genome2):
count = 0
inno1 = max(genome1.nodes.keys())
inno2 = max(genome2.nodes.keys())
for i in range(max(inno1, inno2) + 1):
n1 = genome1.nodes.get(i, None)
n2 = genome2.nodes.get(i, None)
if (n1 is None and inno1 < ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_matching_genes(genome1, genome2):\n count = 0\n\n inno1 = max(genome1.nodes.keys())\n inno2 = max(genome2.nodes.keys())\n\n for i in range(max(inno1, inno2) + 1):\n n1 = genome1.nodes.get(i, None)\n n2 = genome2.nodes.get(i, None)\n if not (n1 ... | [
"0.7361382",
"0.72803974",
"0.70326364",
"0.6851672",
"0.6647004",
"0.65134394",
"0.65020245",
"0.6424856",
"0.6422673",
"0.6420795",
"0.6410791",
"0.64107877",
"0.6343099",
"0.6336188",
"0.6334963",
"0.6332288",
"0.6295267",
"0.6267459",
"0.6256581",
"0.62542903",
"0.6234851... | 0.7764498 | 0 |
Determines the number of disjoint connections and nodes between two genomes. | def count_disjoint_genes(genome1, genome2):
count = 0
inno1 = max(genome1.nodes.keys())
inno2 = max(genome2.nodes.keys())
for i in range(max(inno1, inno2) + 1):
n1 = genome1.nodes.get(i, None)
n2 = genome2.nodes.get(i, None)
if (n1 is None and inno1 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_matching_genes(genome1, genome2):\n count = 0\n\n inno1 = max(genome1.nodes.keys())\n inno2 = max(genome2.nodes.keys())\n\n for i in range(max(inno1, inno2) + 1):\n n1 = genome1.nodes.get(i, None)\n n2 = genome2.nodes.get(i, None)\n if not (n1 ... | [
"0.74092317",
"0.7306025",
"0.67916024",
"0.67113155",
"0.6644957",
"0.6625719",
"0.6597679",
"0.65031475",
"0.64326185",
"0.6404905",
"0.63642615",
"0.63510627",
"0.6263144",
"0.61996305",
"0.6192155",
"0.6192069",
"0.61820394",
"0.617884",
"0.61564946",
"0.61513907",
"0.611... | 0.79438657 | 0 |
Parse a yaml configuration string | def __init__ (self, config_yaml):
configdef = yaml.safe_load(io.StringIO(config_yaml))
if "filters" not in configdef:
configdef = dict(filters=[configdef])
self._configs = []
for definition in configdef["filters"]:
config = Bunch( valid_from = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yaml_parse(yamlstr):\n try:\n # PyYAML doesn't support json as well as it should, so if the input\n # is actually just json it is better to parse it with the standard\n # json parser.\n return json.loads(yamlstr, object_pairs_hook=OrderedDict)\n except ValueError:\n loa... | [
"0.70751566",
"0.6905611",
"0.68781406",
"0.685709",
"0.6741789",
"0.66602236",
"0.66593003",
"0.656402",
"0.6539586",
"0.65306675",
"0.6517556",
"0.65078825",
"0.645184",
"0.6443837",
"0.6442316",
"0.6359812",
"0.63446283",
"0.6340231",
"0.63296056",
"0.63150954",
"0.6307937... | 0.0 | -1 |
Plot the correlation matrix for all features listed in the cols param | def plot_correlation_matrix(dataset: pd.DataFrame, cols: List[str]):
fig = px.imshow(dataset[cols].corr())
fig.update_layout(
autosize=False,
width=900,
height=1000)
fig.show()
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def features_correlation(df, cols, target, fig_size=(6,6), path=None):\n f, ax = plt.subplots(1, figsize=fig_size)\n ax.set_xlabel(\"Feature Correlation\")\n visualizer = FeatureCorrelation(labels=list(cols))\n visualizer.fit(df[cols], df[target])\n f.tight_layout()\n if(p... | [
"0.75140464",
"0.74514484",
"0.74052197",
"0.7236237",
"0.717602",
"0.71594715",
"0.69576234",
"0.6952677",
"0.6909094",
"0.68331105",
"0.6783362",
"0.6749775",
"0.67407316",
"0.671042",
"0.6673981",
"0.6672141",
"0.6605096",
"0.6584971",
"0.65831524",
"0.6552678",
"0.6522828... | 0.7818899 | 0 |
String for representing the Model object. | def __str__(self):
return self.typeImo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
Plots a confusion matrix given some input | def plot_confusion_matrix(cm, my_tags, title='Confusion matrix', cmap=plt.cm.Blues):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(my_tags))
target_names = my_tags
plt.xticks(tick_marks, target_names, rotation=45)
plt.yticks(tic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()",
"def plot_confusion_matrix(cm, class_names):\n figure = plt.figure(figsize=(10, 10))\n plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)\n plt.title(\... | [
"0.8161471",
"0.80150074",
"0.79347026",
"0.78729504",
"0.78694254",
"0.7867225",
"0.7858596",
"0.78459156",
"0.7795161",
"0.7775234",
"0.77735937",
"0.77645767",
"0.77563524",
"0.7726299",
"0.7716574",
"0.7710101",
"0.77078474",
"0.77045697",
"0.7690752",
"0.7680288",
"0.766... | 0.7593767 | 52 |
Tokenization using NLTK tokenizer | def tokenize_text(text):
tokens = []
for sent in nltk.sent_tokenize(text):
for word in nltk.word_tokenize(sent):
if len(word) < 2:
continue
tokens.append(word.lower())
return tokens | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenizer(self):\n tokenizer = RegexpTokenizer(r'\\w+')\n \n self.tweet_tokenized_train = [tokenizer.tokenize(x.lower()) for x in self.tweet_prepro_train]\n self.tweet_tokenized_test = [tokenizer.tokenize(x.lower()) for x in self.tweet_prepro_test]",
"def preprocess_sent(sent):\n ... | [
"0.7267561",
"0.7218116",
"0.7192194",
"0.7191581",
"0.71773136",
"0.7127248",
"0.7081596",
"0.7074144",
"0.70685524",
"0.7062013",
"0.7062013",
"0.6992854",
"0.6986077",
"0.6974034",
"0.69734263",
"0.694933",
"0.69455796",
"0.69289595",
"0.6919697",
"0.69157934",
"0.69099385... | 0.0 | -1 |
Obtain the most important words for a class | def most_influential_words(model, vectorizer, genre_index=0, num_words=10):
features = vectorizer.get_feature_names()
max_coef = sorted(enumerate(model.coef_[genre_index]), key=lambda x:x[1], reverse=True)
return [[features[x[0]], x[1] ] for x in max_coef[:num_words]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_main_words(idioms_set):\r\n main_words = Counter([idiom.split()[-1] for idiom in idioms_set])\r\n print('main words:', '\\n', main_words)\r\n print('top 50 main words:', '\\n', main_words.most_common(50)) \r\n return list(main_words)",
"def top_question_words(args, examples, word_dict):\n ... | [
"0.7045568",
"0.6916421",
"0.6706692",
"0.6560265",
"0.6364509",
"0.63523245",
"0.63223714",
"0.6310918",
"0.63019496",
"0.62716067",
"0.6197724",
"0.6181018",
"0.6135581",
"0.6112092",
"0.61117387",
"0.6111627",
"0.6109262",
"0.61037457",
"0.6081116",
"0.6039679",
"0.603842"... | 0.57231677 | 53 |
Returns initializer that initializes array with the allzero array. | def Zero(dtype=None):
return Constant(0.0, dtype=dtype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero_init(self, shape):\n return np.zeros((shape[0],shape[1]))",
"def __array__(self):\n return np.zeros(self.shape, self.dtype)",
"def zero(self):\n return np.zeros([self.nx])",
"def shared_mem_zero_initializer(shape, dtype, name): # pylint: disable=unused-argument\n data = empty_sh... | [
"0.6827694",
"0.6806285",
"0.6550301",
"0.654935",
"0.65310127",
"0.65004337",
"0.64385927",
"0.64043725",
"0.6366739",
"0.63465846",
"0.63086647",
"0.6273209",
"0.6272587",
"0.6268909",
"0.62589014",
"0.62511927",
"0.62347555",
"0.62199867",
"0.62038255",
"0.61950916",
"0.61... | 0.0 | -1 |
An instance of BankAccount object. | def example_bank_account():
return BankAccount("Test User", 1000.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bank_account():\n return BankAccount()",
"def account(self):\r\n return Account(self)",
"def account(self):\n return Account(self)",
"def generate_bank_account(user_data: dict) -> BankAccount:\n bank_account = BankAccount(user_data[\"bank_account_number\"],\n ... | [
"0.83124053",
"0.75329465",
"0.75081885",
"0.73725003",
"0.7358681",
"0.7349119",
"0.70814943",
"0.68626934",
"0.6776419",
"0.6775096",
"0.6754097",
"0.6712957",
"0.6706183",
"0.66772014",
"0.65859956",
"0.64276075",
"0.6424409",
"0.6419647",
"0.6418199",
"0.64170915",
"0.627... | 0.8185616 | 1 |
separates a dict into haskeys and nothaskeys pairs, using either a list of keys or a filtering function. | def winnow_by_keys(dct, keys=None, filter_func=None):
has = {}
has_not = {}
for key in dct:
key_passes_check = False
if keys is not None:
key_passes_check = key in keys
elif filter_func is not None:
key_passes_check = filter_func(key)
if key_passes_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_filter(d, keys, into=dict):\n \n if hasattr(keys, \"__call__\"):\n f = keys\n keys = filter(f, d.keys())\n return into(map(lambda k:(k,d[k]), keys))",
"def dict_filter(indict, key_list):\n \n return dict((key, value) for key, value in list(indict.items()) if key in key_list)... | [
"0.7068494",
"0.6861831",
"0.6750113",
"0.6734329",
"0.6704897",
"0.66897655",
"0.65348476",
"0.6449124",
"0.64393973",
"0.6366392",
"0.62941235",
"0.61988235",
"0.6183261",
"0.61704093",
"0.61321944",
"0.61171293",
"0.61014825",
"0.60677016",
"0.60602033",
"0.6035641",
"0.59... | 0.6361867 | 10 |
The computer entity that is programmed for zero mercy | def hal_9000(self, hal_board):
# if HAL can win, HAL swiftly eliminates Dave
for num in range(0, 8):
pit_board = self.copy_board(hal_board)
if self.check_if_empty(pit_board, num):
pit_board[num] = "O"
if self.check_for_win(pit_board, "O"):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_entity(self):\n return self.entities[len(self.device_data[CONF_ENTITIES])]",
"def description(self):\n return 'computer'",
"def entity(self):\n return self._entity",
"def entity(self):\n return self._entity",
"def unknownEntity():\n return Entity(u'', IEntities, '... | [
"0.62016016",
"0.5856308",
"0.55960715",
"0.55960715",
"0.5583072",
"0.5511388",
"0.5485846",
"0.5480992",
"0.5473292",
"0.5466145",
"0.54443574",
"0.5413429",
"0.53965366",
"0.53919804",
"0.53836054",
"0.53487015",
"0.5334898",
"0.53327817",
"0.53262186",
"0.5254537",
"0.524... | 0.0 | -1 |
Return the vector of partial derivatives \partial C_x / \partial a for the output activations. | def cost_derivative(self, output_activations, y):
return 2 * (output_activations - y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_partials(self, inputs, partials):\n SOC = inputs['SOC']\n temperature = inputs['temperature']\n P_bat = inputs['P_bat']\n\n # dI_dP\n dV_dvoc = IR * self.exponential\n dV_dT = - IR * self.voc * np.exp(alpha*(temperature[4, :] - T0)/T0) * alpha / T0\n dVo... | [
"0.6179747",
"0.6113179",
"0.6110102",
"0.6063869",
"0.6060675",
"0.5840477",
"0.58356196",
"0.57909757",
"0.5785478",
"0.576321",
"0.56648666",
"0.56212157",
"0.5613195",
"0.56029624",
"0.56029624",
"0.56029624",
"0.56029624",
"0.5575484",
"0.5562849",
"0.5559713",
"0.554512... | 0.5345927 | 43 |
Derivative of the sigmoid function. | def sigmoid_prime(z):
return cp.exp(-z) / ((1 + cp.exp(-z)) ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid_derivative(x):\n return x * (1-x)",
"def sigmoid_derivative(x):\n return x * (1.0 - x)",
"def sigmoid_derivative(x):\n\n return sigmoid(x) * (1 - sigmoid(x))",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def sigmoid_der... | [
"0.8472813",
"0.84482265",
"0.839465",
"0.8346568",
"0.8346568",
"0.8297082",
"0.80527747",
"0.77512693",
"0.77058387",
"0.74962187",
"0.7465983",
"0.74511427",
"0.73991024",
"0.73818743",
"0.73804784",
"0.7347313",
"0.73190165",
"0.73073244",
"0.7189697",
"0.71123916",
"0.70... | 0.0 | -1 |
Builds and returns Dataloader. | def get_each_loader(data_path, batch_size, trn_negnum, shuffle=True, num_workers=0):
dataset = ML_Dataset(data_path, trn_negnum)
if data_path.endswith('trn') == True:
collate = dataset.train_collate
else:
collate = test_collate
data_loader = data.DataLoader(dataset=dataset,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataloader(self):\n\n # load / split data\n train_data = self.data.get_train_data()\n if self.args.use_dev:\n train_data, dev_data = self.data.split_data(train_data)\n test_data = self.data.get_test_data()\n\n #print(train_data[0])\n #print(dev_data[0])\n ... | [
"0.6889868",
"0.688255",
"0.6745007",
"0.67274445",
"0.67172325",
"0.649437",
"0.6482951",
"0.6473919",
"0.6442454",
"0.6431744",
"0.6392834",
"0.6386863",
"0.63354766",
"0.62538815",
"0.6204135",
"0.61978376",
"0.6108685",
"0.61018723",
"0.60760283",
"0.60642105",
"0.6062031... | 0.0 | -1 |
r""" Optionally Saves, updates and then reloads the miner training state. | def checkpoint( self ):
last_saved = self.get_saved_state()
if last_saved == None or last_saved['epoch_loss'] >= self.epoch_loss:
self.save()
self.metagraph.load()
self.metagraph.sync()
self.metagraph.save()
self.reload() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_train_state(self):\n\n # Save one model at least\n if self.train_state['epoch_index'] == 0:\n # torch.save(self.classifier.state_dict(), self.train_state['model_filename'])\n self.save_model()\n self.train_state['stop_early'] = False\n\n # Save model... | [
"0.6849049",
"0.6589345",
"0.6516164",
"0.6449981",
"0.63682586",
"0.6184475",
"0.61263484",
"0.60954535",
"0.6081368",
"0.60764295",
"0.60736096",
"0.6058315",
"0.6058315",
"0.60204685",
"0.5982164",
"0.5971745",
"0.5971745",
"0.596791",
"0.5949599",
"0.59413695",
"0.5936962... | 0.5513232 | 69 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.