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 |
|---|---|---|---|---|---|---|
Make list of X direction lower shapes points. | def X_lower_shape_points(ix, iy, w_sen, t_sen, n_w_sen):
p0 = (ix, iy)
p1 = (ix - w_sen + n_w_sen / 2, iy + t_sen)
p2 = (ix - w_sen + n_w_sen / 2, iy)
p3 = (ix - n_w_sen / 2, iy)
p4 = (ix - n_w_sen / 2, iy - t_sen)
p5 = (ix + w_sen - n_w_sen / 2, iy - t_sen)
p6 = (ix + w_sen - n_w_sen / 2, i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def m4_make_lower_shape_points_list(tx, ty, m4_info, SEN_info):\n \"\"\"\n 1 Get information from m4_info & SEN_info\n \"\"\"\n x_m4 = m4_info[0]\n y_m4 = m4_info[1]\n z_m = m4_info[2]\n\n m4_points = m4_info[3]\n\n m4_p0 = m4_points[0]\n m4_p1 = m4_points[1]\n m4_p2 = m4_points[2]\... | [
"0.6320917",
"0.62811863",
"0.6210549",
"0.61966574",
"0.6059359",
"0.605593",
"0.6055158",
"0.5814835",
"0.57486415",
"0.57407343",
"0.571419",
"0.5711649",
"0.57050455",
"0.5694207",
"0.5677146",
"0.5669279",
"0.565381",
"0.5623116",
"0.5617289",
"0.5586283",
"0.55789524",
... | 0.6464736 | 0 |
Random 5 digits of alphabet | def make_salt(length=5):
return ''.join(random.choice(letters) for x in xrange(length)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_string():\n\n return ''.join(random.choices(string.ascii_uppercase + string.digits, k=5))",
"def random_string():\n\n k = random.randint(5, 10)\n return ''.join(random.choices(string.ascii_letters + string.digits, k=k))",
"def random_string():\n return \"\".join(random.choice(string.asci... | [
"0.78213584",
"0.7708212",
"0.7491699",
"0.74589",
"0.7457989",
"0.74525815",
"0.74484015",
"0.7407967",
"0.7390644",
"0.73543483",
"0.72804344",
"0.727288",
"0.72603625",
"0.72139746",
"0.7204488",
"0.71635324",
"0.71582377",
"0.7152711",
"0.71511906",
"0.7123333",
"0.711095... | 0.0 | -1 |
valid whether password correct | def valid_pw(name, pw, pw_hash):
salt = pw_hash.split(',')[0]
return pw_hash == make_pw_hash(name, pw, salt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_password_valid(password):\n #TODO : This should also be handled by the front_end\n pass",
"def test_valid_password(self):\n pass_field = Field(\"\".join(['x' * (int(self.app.config['MAX_PWD_LEN']))]))\n\n valid_password(None, pass_field)",
"def _check_password(self, password)... | [
"0.83105725",
"0.8192471",
"0.81128794",
"0.793743",
"0.78877413",
"0.7887513",
"0.7843677",
"0.7833507",
"0.78028756",
"0.7796956",
"0.77675325",
"0.77218556",
"0.7713398",
"0.7689081",
"0.76875025",
"0.7669623",
"0.76478475",
"0.7630184",
"0.76227564",
"0.7615847",
"0.76071... | 0.7130485 | 92 |
Find user by id and return User instance | def by_id(cls, uid):
return cls.get_by_id(uid, parent=users_key()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_id(cls, _id):\n user = cls.query.filter_by(id=_id).first()\n return user",
"def find_user_by_id(id: str) -> User:\n\n # Find the id user in the database, else return None\n return User.query.get(int(id))",
"def get_user_by_id(self, id):\n\t\treturn self.users.get(id)",
... | [
"0.88356465",
"0.86847526",
"0.8344704",
"0.8289288",
"0.82892406",
"0.82566357",
"0.8255499",
"0.8231893",
"0.81936353",
"0.81817716",
"0.8135062",
"0.81252325",
"0.80607116",
"0.80583674",
"0.80583674",
"0.80583674",
"0.80583674",
"0.8050866",
"0.8050866",
"0.8050866",
"0.8... | 0.0 | -1 |
Find user by name and return User instance | def by_name(cls, name):
return cls.all().filter('name =', name).get() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_user(user_name):\n return User.find_by_user_name(user_name)",
"def get_user(name):\n try:\n return User.objects.get(name=name)\n except ObjectDoesNotExist:\n raise ObjectDoesNotFound(\"There is no user '{}'.\".format(name))",
"def get_by_name(self, user_name):\n user = (\... | [
"0.865375",
"0.8282687",
"0.80495924",
"0.796054",
"0.7813288",
"0.77741134",
"0.7747922",
"0.7697314",
"0.7670952",
"0.7652187",
"0.7588112",
"0.75486934",
"0.74666613",
"0.74559027",
"0.74378765",
"0.74308354",
"0.7409131",
"0.7400524",
"0.73883736",
"0.7371949",
"0.7319743... | 0.0 | -1 |
An 404 Not found error should be raised if the organization id is unknown. | def test_admin_api_organization_accesses_request_create_with_unknown_course_id(
self,
):
admin = factories.UserFactory(is_staff=True, is_superuser=True)
self.client.login(username=admin.username, password="password")
organization = factories.OrganizationFactory.build()
user =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def organization_get_not_found(self, client, jwt_token):\n assert client.get('/organizations/' + '0',\n headers={'Authorization': 'Bearer ' + jwt_token})\\\n .status == '404 NOT FOUND'",
"def test_get_for_not_found_organization(self):\n user = User.create(name='f... | [
"0.7568415",
"0.7467321",
"0.6944504",
"0.6873842",
"0.67347634",
"0.6411725",
"0.6372259",
"0.6367035",
"0.63490963",
"0.63358927",
"0.62869716",
"0.62514883",
"0.6250246",
"0.62174195",
"0.6206224",
"0.6189275",
"0.618833",
"0.61802447",
"0.615761",
"0.6157276",
"0.6134447"... | 0.0 | -1 |
Super admin user should be able to update an organization access. | def test_admin_api_organization_accesses_request_update(self):
admin = factories.UserFactory(is_staff=True, is_superuser=True)
self.client.login(username=admin.username, password="password")
organization = factories.OrganizationFactory()
user = factories.UserFactory()
organizatio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_admin_api_organization_accesses_request_partial_update(self):\n admin = factories.UserFactory(is_staff=True, is_superuser=True)\n self.client.login(username=admin.username, password=\"password\")\n organization = factories.OrganizationFactory()\n user = factories.UserFactory()\... | [
"0.7190737",
"0.7182109",
"0.7080574",
"0.70416015",
"0.7003325",
"0.6804883",
"0.6712875",
"0.6694655",
"0.6648704",
"0.64786714",
"0.6471279",
"0.63952607",
"0.6322459",
"0.6280174",
"0.6267157",
"0.6218351",
"0.6195968",
"0.6152777",
"0.61404884",
"0.6131489",
"0.612798",
... | 0.7386519 | 0 |
An 404 Not found error should be raised if the organization access id is unknown. | def test_admin_api_organization_accesses_request_update_with_unknown_course_id(
self,
):
admin = factories.UserFactory(is_staff=True, is_superuser=True)
self.client.login(username=admin.username, password="password")
organization = factories.OrganizationFactory.build()
user =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def organization_get_not_found(self, client, jwt_token):\n assert client.get('/organizations/' + '0',\n headers={'Authorization': 'Bearer ' + jwt_token})\\\n .status == '404 NOT FOUND'",
"def test_get_for_not_found_organization(self):\n user = User.create(name='f... | [
"0.73385584",
"0.71663094",
"0.7020113",
"0.6800524",
"0.6501556",
"0.64868635",
"0.63885957",
"0.62663186",
"0.6253688",
"0.6249672",
"0.6221513",
"0.62093896",
"0.6186588",
"0.61748356",
"0.6170144",
"0.61689043",
"0.61338794",
"0.61313",
"0.61157495",
"0.6101569",
"0.60818... | 0.55796057 | 96 |
Super admin user should be able to partially update an organization access. | def test_admin_api_organization_accesses_request_partial_update(self):
admin = factories.UserFactory(is_staff=True, is_superuser=True)
self.client.login(username=admin.username, password="password")
organization = factories.OrganizationFactory()
user = factories.UserFactory()
org... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_admin_api_organization_accesses_request_update_with_partial_payload(self):\n admin = factories.UserFactory(is_staff=True, is_superuser=True)\n self.client.login(username=admin.username, password=\"password\")\n organization = factories.OrganizationFactory()\n user = factories.U... | [
"0.7161842",
"0.70744413",
"0.7061919",
"0.7020701",
"0.67596644",
"0.6739014",
"0.660485",
"0.65404636",
"0.6449868",
"0.64491725",
"0.6305281",
"0.6301918",
"0.62915576",
"0.6280812",
"0.62268907",
"0.62256503",
"0.6167171",
"0.6147628",
"0.61470556",
"0.613307",
"0.6113966... | 0.7368714 | 0 |
Computes IoU between two boxes. | def compute_iou(box1, box2):
box1 = tf.expand_dims(box1, -2)
box1_xy = box1[..., 0:2]
box1_wh = box1[..., 2:4]
box1_mins = box1_xy - box1_wh / 2.
box1_maxs = box1_xy + box1_wh / 2.
box2 = tf.expand_dims(box2, 0)
box2_xy = box2[..., 0:2]
box2_wh = box2[..., 2:4]
box2_mins = box2_xy -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _iou(box1: np.ndarray, box2: np.ndarray) -> np.ndarray:\n b1_x0, b1_y0, b1_x1, b1_y1 = box1\n b2_x0, b2_y0, b2_x1, b2_y1 = box2\n\n int_x0 = max(b1_x0, b2_x0)\n int_y0 = max(b1_y0, b2_y0)\n int_x1 = min(b1_x1, b2_x1)\n int_y1 = min(b1_y1, b2_y1)\n\n int_area = max(int_x1 - int_x0, 0) * max... | [
"0.8039398",
"0.7979957",
"0.7947741",
"0.7947741",
"0.79169625",
"0.78891015",
"0.7865228",
"0.781971",
"0.7767087",
"0.7725088",
"0.77196676",
"0.76781106",
"0.76716",
"0.7648488",
"0.7568621",
"0.75479656",
"0.75358826",
"0.75111145",
"0.7469537",
"0.73633987",
"0.73409504... | 0.74600375 | 19 |
Returns the specific sysmon device name as per Device Tree. (e.g. xlnx,versalsysmon) | def find_iio_device_name(self):
self.iio_device_dir()
self.console.runcmd(f"cat name", expected="\r\n")
iio_device_name = self.console.output()
return iio_device_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kdev_name(self):\n return self._sysfs",
"def get_sys_name(self):\n\t\treturn call_sdk_function('PrlVmDev_GetSysName', self.handle)",
"def get_dev_name(self):\n\t\treturn call_sdk_function('PrlSrvCfgHdd_GetDevName', self.handle)",
"def get_sys_name(self):\n\t\treturn call_sdk_function('PrlSrvCfgHdd... | [
"0.6725904",
"0.6587865",
"0.65052974",
"0.6448212",
"0.64102924",
"0.63466",
"0.6336755",
"0.63181424",
"0.6293844",
"0.62467617",
"0.6161453",
"0.6151816",
"0.6151816",
"0.6130236",
"0.609116",
"0.60722494",
"0.6070211",
"0.6064709",
"0.60507816",
"0.6035826",
"0.6030525",
... | 0.61775535 | 10 |
Sets the threshold levels for the given supply. Has to be used to explicitly trigger an alarm. | def set_threshold_levels(self, event_name, val):
if self.validate_supply_name(event_name, "events/") and val:
self.console.runcmd(f"echo {val} > events/{event_name}")
else:
assert (
False
), "A valid event name or the value, is not given while setting ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setThresholdLevel(self, *args):\n return _libsbml.Input_setThresholdLevel(self, *args)",
"def setThreshold(self, threshold): # real signature unknown; restored from __doc__\n pass",
"def set_als_thresholds(self, low_thr, high_thr):\n if not (0 <= low_thr <= 0xFFFF and 0 <= high_thr <= ... | [
"0.68676805",
"0.6481637",
"0.6192433",
"0.60998166",
"0.5922252",
"0.58493024",
"0.58493024",
"0.58493024",
"0.58493024",
"0.58493024",
"0.5750799",
"0.573871",
"0.5726446",
"0.5610387",
"0.55546314",
"0.5419278",
"0.54132664",
"0.5400695",
"0.5390194",
"0.5386677",
"0.53740... | 0.64615875 | 2 |
Calculates sum of NAN values per column for each data set | def missing_values():
print('Missings in the train data:', train_data.isnull().sum()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def col_sums(\n x: DataFrame,\n na_rm: bool = False,\n # dims: int = 1,\n # weights = None,\n # freq = None,\n # n = None\n) -> Iterable[NumericType]:\n return x.agg(sum, na_rm=na_rm)",
"def nansum(array_data, axis=0):\n\n mdat = np.ma.masked_array(array_data, np... | [
"0.6805278",
"0.65869236",
"0.6514956",
"0.64584655",
"0.6266595",
"0.6263416",
"0.6260861",
"0.62537825",
"0.62497795",
"0.624509",
"0.6209497",
"0.6183607",
"0.61039627",
"0.60813385",
"0.602591",
"0.59990644",
"0.5971328",
"0.59699774",
"0.5967973",
"0.5965358",
"0.5963957... | 0.60225934 | 15 |
Returns an int64_list from a bool / enum / int / uint. | def _int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value=value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _BoolsToInts(arg_list):\n result = []\n for arg in arg_list:\n if isinstance(arg, (list, tuple)):\n result.append(_BoolsToInts(arg))\n elif arg is True:\n result.append(1)\n elif arg is False:\n result.append(0)\n else:\n result.append(arg)\n\n return result",
"def convertT... | [
"0.68806016",
"0.659591",
"0.646043",
"0.6447361",
"0.63662255",
"0.62898934",
"0.62705195",
"0.6215276",
"0.61031455",
"0.5950929",
"0.5944742",
"0.5901341",
"0.5864068",
"0.5864068",
"0.5856132",
"0.5843577",
"0.58429956",
"0.5830027",
"0.5801629",
"0.57937616",
"0.57937616... | 0.5532331 | 46 |
Given token arrays of arbitrary lengths, concats/splits them into arrays of equal length Returns equallength token arrays, followed by a a final array of trailing tokens (which may be shorter) | def arrays_to_sequences(token_list_iterable, sequence_length=2049):
accum = []
for l in token_list_iterable:
accum.extend(l)
if len(accum) > sequence_length:
chunks = split_list(accum, sequence_length)
yield from chunks[:-1]
accum = chunks[-1]
if len(acc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_tokens(tokens):\n target_length = roundup2(len(tokens))\n padding_length = target_length - len(tokens)\n tokens = [PADDING_TOKEN] * padding_length + tokens\n return tokens",
"def input_transpose_max_len(sents, pad_token,MAX_LEN):\n\n batch_size = len(sents)\n\n sents_t = []\n for i ... | [
"0.669269",
"0.60766286",
"0.6038572",
"0.59766895",
"0.5802202",
"0.57402205",
"0.56858736",
"0.5646659",
"0.56047946",
"0.5540123",
"0.5540123",
"0.54752225",
"0.5456827",
"0.54337645",
"0.54314643",
"0.53846574",
"0.5369658",
"0.53367466",
"0.5300207",
"0.5291902",
"0.5276... | 0.674038 | 0 |
Tests if it accepts negative numbers | def test_if_input_is_negative(self):
self.assertEquals(prime_numbers(-5), "Numbers less than or equal to zero are not allowed!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isnegative(x):\n if x < 0 :\n return True\n return False",
"def is_negative(self, a):\n return a < 0",
"def is_negative(self):\n return (self._num < 0)",
"def is_nonnegative(self, a):\n return a >= 0",
"def is_Negative(self):\n return self.signature() < 0",
"d... | [
"0.7994915",
"0.7994529",
"0.79554963",
"0.75531757",
"0.7533481",
"0.75301135",
"0.7279797",
"0.7274011",
"0.72569823",
"0.7242016",
"0.7196805",
"0.7188929",
"0.71457916",
"0.70805043",
"0.7070099",
"0.70591664",
"0.70060784",
"0.69043154",
"0.6903663",
"0.6898359",
"0.6896... | 0.73414373 | 6 |
Test that the view returns a 200 response and uses correct template | def test_index_view_basic(self):
request = self.factory.get("/")
with self.assertTemplateUsed('solos/index.html'):
response = index(request)
self.assertEqual(response.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_view(self):\n self.assertEqual(status.HTTP_200_OK, self.response.status_code)",
"def test_view_success_code(self):\n response = self.client.get(self.get_url())\n self.assertEqual(response.status_code, 200)",
"def test_view_success_code(self):\n response = self.client.get(se... | [
"0.81794447",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
"0.7933966",
... | 0.73358154 | 50 |
Test that the solo view returns a 200 response, uses the correct template and has the correct context | def test_basic(self):
#* using request factory is independent of existence of the path and calls the view as a function.
#* it may well be get('nonesense/') unless this argument is needed in the view function
#* it calls the view as a regular function and tests its effects
request = self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_view(self):\n self.assertEqual(status.HTTP_200_OK, self.response.status_code)",
"def test_index_view_basic(self):\n request = self.factory.get(\"/\")\n with self.assertTemplateUsed('solos/index.html'):\n response = index(request)\n self.assertEqual(response.sta... | [
"0.77218807",
"0.7598806",
"0.75926405",
"0.74535424",
"0.742512",
"0.7422633",
"0.73288095",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
"0.7313393",
... | 0.6997645 | 54 |
Returns True if an object is iterable and not a string or ProxyUnicode type, otherwise returns False. Returns bool | def isIterable(obj):
# type: (Any) -> bool
if isinstance(obj, basestring):
return False
elif isinstance(obj, ProxyUnicode):
return False
try:
iter(obj)
except TypeError:
return False
else:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_non_string_iterable(obj: object) -> bool:\n return not (isinstance(obj, str) or isinstance(obj, bytes))\\\n and isinstance(obj, Iterable)",
"def nonstringiter(obj):\n return not isinstance(obj, string_types) and isinstance(obj, Iterable)",
"def isiterable(obj, strings=False, isinstance=isin... | [
"0.8439261",
"0.8023444",
"0.7855693",
"0.7853518",
"0.77362233",
"0.7683119",
"0.7630059",
"0.7629651",
"0.7613312",
"0.7610749",
"0.75610113",
"0.7556645",
"0.7548027",
"0.74414647",
"0.7438966",
"0.74135894",
"0.7392979",
"0.7359369",
"0.7341111",
"0.72592026",
"0.71393645... | 0.8389547 | 1 |
Returns True if an object is a number or complex type, otherwise returns False. Returns bool | def isScalar(obj):
# type: (Any) -> bool
return isinstance(obj, numbers.Number) and not isinstance(obj, complex) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_number(obj):\n try:\n complex(obj) # for int, long, float and complex\n except ValueError:\n return False\n\n return True",
"def is_numeric(obj):\n return isinstance(obj, (int, float, complex))",
"def isNumber(val):\n try:\n _ = complex(val)\n return True\... | [
"0.850838",
"0.80411804",
"0.7555758",
"0.7540831",
"0.74649554",
"0.7439259",
"0.7389749",
"0.73686296",
"0.734229",
"0.72434026",
"0.7214011",
"0.7076347",
"0.70687836",
"0.6971529",
"0.67784196",
"0.6773819",
"0.6749837",
"0.6739436",
"0.6716252",
"0.6686213",
"0.6640015",... | 0.7794131 | 2 |
same as `operator.isSequenceType` Returns bool | def isSequence(obj):
# type: (Any) -> bool
return isinstance(obj, Sequence) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_sequence(self) -> bool:\n return isinstance(self.yaml_node, yaml.SequenceNode)",
"def is_seq_of(seq, expected_type, seq_type=None):\n if seq_type is None:\n exp_seq_type = abc.Sequence\n else:\n assert isinstance(seq_type, type)\n exp_seq_type = seq_type\n if not isins... | [
"0.77310807",
"0.7522069",
"0.74707985",
"0.74157387",
"0.71542764",
"0.7090137",
"0.70358473",
"0.70296526",
"0.6922433",
"0.69150037",
"0.68182665",
"0.680354",
"0.66974884",
"0.6683497",
"0.62242824",
"0.620153",
"0.6187421",
"0.61847335",
"0.6180915",
"0.6125895",
"0.6098... | 0.7277847 | 4 |
Returns True if an object is a mapping (dictionary) type, otherwise returns False. same as `operator.isMappingType` Returns bool | def isMapping(obj):
# type: (Any) -> bool
return isinstance(obj, Mapping) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quacks_like_dict(object):\n return isinstance(object, Mapping)",
"def is_mapping(self) -> bool:\n return isinstance(self.yaml_node, yaml.MappingNode)",
"def quacks_like_dict(object):\n return isinstance(object, collections.Mapping)",
"def is_typed_dict(self) -> bool:\n return True",
... | [
"0.761448",
"0.7603603",
"0.7455878",
"0.7203158",
"0.70684886",
"0.6996251",
"0.67649657",
"0.672957",
"0.66903645",
"0.6584784",
"0.6569784",
"0.6546765",
"0.64099777",
"0.6362406",
"0.625995",
"0.6229461",
"0.6193939",
"0.6074202",
"0.60736847",
"0.6064628",
"0.6061763",
... | 0.81585056 | 0 |
convert a sequence of integers into a tuple of slice objects | def sequenceToSlices(intList, sort=True):
slices = []
if intList:
if sort:
intList = sorted(intList)
start = intList[0]
stop = None
step = None
lastStep = None
lastVal = start
for curr in intList[1:]:
curr = int(curr)
t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_slices(start: Sequence[int], stop: Sequence[int] = None) -> Tuple[slice, ...]:\n if stop is not None:\n check_len(start, stop)\n return tuple(map(slice, start, stop))\n\n return tuple(map(slice, start))",
"def _slice(self, start, stop, step=None):\n\n slices = [slice(None)] *... | [
"0.72965604",
"0.676421",
"0.6471331",
"0.6322668",
"0.63043547",
"0.6155816",
"0.6091736",
"0.6089929",
"0.60747325",
"0.6068256",
"0.60222465",
"0.6013632",
"0.59986544",
"0.5975222",
"0.5968436",
"0.5961795",
"0.5949501",
"0.594688",
"0.5945627",
"0.59308153",
"0.5904504",... | 0.6016609 | 11 |
Produces a string representation of this CommitData suitable for consumption by `git hashobject`. | def __str__(self):
ret = StringIO()
print >> ret, 'tree', self.tree
for parent in self.parents:
print >> ret, 'parent', parent
print >> ret, 'author', self.author
print >> ret, 'committer', self.committer
for key, value in self.other_header_lines:
print >> ret, key, value
print >... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n string = \"\"\n for transaction in self.transaction_list:\n string += transaction.hash+\"|\"\n string = string[:-1]\n return string",
"def toHashBase(self) -> str:\r\n\r\n if self.hashBase != '':\r\n self_repr = '{}'.format(self.hashBa... | [
"0.6921575",
"0.6691194",
"0.6523012",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
"0.65196276",
... | 0.6553016 | 2 |
Generate random temporary directory path. | def tempdir(self):
path = tempfile.gettempdir()
return os.path.join(path, 'parquet-index-test-' + str(uuid.uuid4())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_unique_temp_dir(base_temp_dir):\n return os.path.join(base_temp_dir, uuid.uuid4().hex)",
"def random_directory():\n dirname = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8))\n directory = tempfile.mkdtemp(suffix=dirname)\n if not os.path.exists(directory):\n ... | [
"0.7955663",
"0.78911084",
"0.7835875",
"0.7778619",
"0.76107264",
"0.7486762",
"0.7395961",
"0.7303972",
"0.7265596",
"0.72541773",
"0.7222599",
"0.71741474",
"0.7156583",
"0.71411204",
"0.71155816",
"0.7107063",
"0.70750684",
"0.7069002",
"0.7065493",
"0.70356303",
"0.70160... | 0.71132064 | 15 |
Gets the reward for the state. A child class can redefine the reward function if reward other than zero is desired. | def reward(self):
if self._state is None:
return 0
return self.reward_fn(self._state) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reward(self) -> float:\n\n if not self._reward_provided:\n self._reward_provided = True\n return self._reward\n\n return 0",
"def get_reward(self):\n\t\t# returns the reward for current state\n\n\t\t#temporary line for testing:\n\t\t#return self.reward_idea() # also not wo... | [
"0.8337681",
"0.8272733",
"0.8192957",
"0.80949503",
"0.8077979",
"0.8039705",
"0.78654593",
"0.7844821",
"0.783671",
"0.7771977",
"0.77295446",
"0.7722538",
"0.77047217",
"0.7693523",
"0.76748097",
"0.76741314",
"0.7668153",
"0.76664543",
"0.7662597",
"0.76061165",
"0.753600... | 0.8641399 | 0 |
Adds a star by the client for the streaming user with the given identifier. | def add_star_streamer(client_id, streamer_id, now=None):
now = _get_now(now)
try:
# Get the indexed name of the streaming user.
streamer_indexed_name = session.query(User.indexed_name)\
.filter(User.id == streamer_id)\
.one()\
.indexed_name
# Add the client's star for the streaming user.
starred_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def star(request):\n account = models.Account.current_user_account\n account.user_has_selected_nickname() # This will preserve account.fresh.\n if account.stars is None:\n account.stars = []\n keyid = request.issue.key.id()\n if keyid not in account.stars:\n account.stars.append(keyid)\n account.put... | [
"0.6484428",
"0.60593",
"0.6016559",
"0.5993658",
"0.58933765",
"0.58512646",
"0.5798695",
"0.57883924",
"0.57639474",
"0.5663742",
"0.5600678",
"0.5592011",
"0.5589608",
"0.5504904",
"0.55000395",
"0.5496943",
"0.54632324",
"0.5415375",
"0.5398816",
"0.5398816",
"0.5385724",... | 0.68346536 | 0 |
Returns the DisplayedSettings for the given client. If no settings have yet been saved by the user, default values are returned. | def get_settings(client_id):
try:
settings = session.query(Settings)\
.filter(Settings.user_id == client_id)\
.one()
return DisplayedSettings(settings.time_format,
settings.country,
settings.time_zone)
except sa_orm.exc.NoResultFound:
session.rollback()
return DisplayedSettings(_DEFAULT_SETTIN... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_settings_from_client(client):\r\n settings = {\r\n 'username': '',\r\n 'api_key': '',\r\n 'timeout': client.timeout or '',\r\n 'endpoint_url': client.endpoint_url,\r\n }\r\n try:\r\n settings['username'] = client.auth.username\r\n settings['api_key'] = cli... | [
"0.61949265",
"0.612399",
"0.612399",
"0.60198313",
"0.5857258",
"0.57249576",
"0.5521653",
"0.5513769",
"0.5493364",
"0.54921097",
"0.54804647",
"0.5441547",
"0.54284537",
"0.5404012",
"0.53787446",
"0.53768396",
"0.5367986",
"0.5362676",
"0.53589255",
"0.5329758",
"0.531492... | 0.7964128 | 0 |
Creates a NoiseProperties object using the provided metrics. Only one of decay_constant, xeb_fidelity, and pauli_error should be specified. | def __init__(
self,
*,
t1_ns: float = None,
decay_constant: float = None,
xeb_fidelity: float = None,
pauli_error: float = None,
p00: float = None,
p11: float = None,
) -> None:
if not any([t1_ns, decay_constant, xeb_fidelity, pauli_error, p00,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, noise_properties: NoiseProperties) -> None:\n if noise_properties is not None:\n self._noise_properties = noise_properties\n else:\n raise ValueError('A NoiseProperties object must be specified')",
"def create_metric(self) -> 'LossMetric':\n return Pe... | [
"0.5402906",
"0.50032413",
"0.50032413",
"0.48961177",
"0.4816246",
"0.48139068",
"0.479556",
"0.47715113",
"0.46958685",
"0.45607477",
"0.45489034",
"0.45285803",
"0.45160702",
"0.45116127",
"0.44704401",
"0.44532296",
"0.44422716",
"0.44329062",
"0.44289175",
"0.4371672",
"... | 0.4813943 | 5 |
Calculates the average error from the depolarization decay constant. | def average_error(self, num_qubits: int = 1):
if self._p is not None:
N = 2 ** num_qubits
return (1 - self._p) * (1 - 1 / N)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_avg_deg_rate(mean_concentration, half_life):\n ave_degradation_rate = math.log(2) / half_life * mean_concentration\n\n return ave_degradation_rate",
"def average_grad(self):\n\n # Compute the respective gradients\n grad_line_1 = self.gradient(0,1)\n grad_line_2 = self.gradien... | [
"0.6446011",
"0.62988204",
"0.61347944",
"0.6130401",
"0.61201656",
"0.6013243",
"0.5972188",
"0.59247255",
"0.59165037",
"0.5897437",
"0.586813",
"0.5863137",
"0.5862266",
"0.58584076",
"0.58546907",
"0.58498013",
"0.5833294",
"0.58290046",
"0.5786158",
"0.5781671",
"0.57695... | 0.0 | -1 |
data must be a 4D tensor generated by tf.constant() applied on a 4D numpy array with [image index, IMAGE_WIDTH, IMAGE_HEIGHT, CHANNEL] | def conv_net_model(x, keep_prob):
# Could use tf.truncated_normal() instead of tf.random_normal(),
# see what is the best choice
# note tf.truncated() is used in the FCN implementation
with tf.variable_scope('weights'):
weights = {'W_d_conv1': utils.weight_def([3, 3, NUM_CHANNELS, 64], stddev=S... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _4d_tensor(self, name, tensor, **kwargs):\r\n h, w, c, num_tensor = tensor.shape.as_list()\r\n\r\n # Try to visualise convolutional filters or feature maps\r\n # See: https://gist.github.com/kukuruza/03731dc494603ceab0c5\r\n # input shape: (Y, X, C, N)\r\n if c != 1 and c != ... | [
"0.66522455",
"0.64622504",
"0.6241878",
"0.60918915",
"0.60167897",
"0.6001384",
"0.59810376",
"0.5954063",
"0.5855514",
"0.58535093",
"0.58463126",
"0.5777403",
"0.5763165",
"0.5713662",
"0.57050216",
"0.56863683",
"0.5633618",
"0.56268376",
"0.5603604",
"0.55850065",
"0.55... | 0.0 | -1 |
Initialization function with one input to set the name of the animal during initialization. | def __init__(self, name):
super(Animal, self).__init__()
self._name = None # : Internal class attribute
# _ before variable indicates that this variable should not
# be used by the user directly.
# - self is special keyword in classes that points to itself.
# The name se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__, *,\n name: pulumi.Input[str]):\n pulumi.set(__self__, \"name\", name)",
"def _init(self, **kwds):\n name = kwds.get('name')\n if name and not self.data.has_key('name'):\n self.set_name(name)\n self.characterID = kwds.get('characterID',... | [
"0.70692563",
"0.685416",
"0.6831673",
"0.6831673",
"0.6831673",
"0.6831673",
"0.6831673",
"0.6831673",
"0.6649546",
"0.6649546",
"0.6477993",
"0.63886464",
"0.63818246",
"0.63818246",
"0.63744396",
"0.6365853",
"0.63610303",
"0.63610303",
"0.63610303",
"0.63610303",
"0.63610... | 0.74329746 | 0 |
A function that returns None or the archive path | def do_pack():
now = datetime.now()
time_now = now.strftime("%Y%m%d%H%M%S")
archive_name = "versions/web_static_" + time_now + ".tgz"
local('mkdir -p versions')
archive_command = local("tar -zcvf " + archive_name + " web_static")
if archive_command.succeeded:
return archive_name
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def archive_path(self):\n return os.path.join(self.destination_directory, self.__archive_name__)",
"def getZipArchiveFullPath(self):\n\n if self._mode == \"zip\":\n return self._rootExportPath + \".zip\"\n\n return \"\"",
"def get_archive_file_path(self,results):\n path =... | [
"0.72898483",
"0.7054521",
"0.6790323",
"0.67624706",
"0.6576224",
"0.65636045",
"0.652096",
"0.63905036",
"0.6261571",
"0.61803585",
"0.61362636",
"0.61055744",
"0.6064658",
"0.60122055",
"0.600557",
"0.58931756",
"0.5825155",
"0.5750824",
"0.57331026",
"0.5720983",
"0.57172... | 0.5411983 | 53 |
Transforms nby1 vector of class labels into nbyn_classes array of onehot encoded labels | def _onehot(y, n_classes=False):
if not n_classes:
"""Create one-hot encoded labels."""
n_classes = len(set(y))
out = np.zeros((len(y), n_classes))
for i, ii in enumerate(y):
out[i][ii] += 1
y_onehot = out.astype(int)
return y_onehot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encode(labels, num_classes=None):\n if num_classes is None:\n num_classes = len(np.unique(labels))\n return np.eye(num_classes)[labels]",
"def one_hot_encode(labels, num_classes=None):\n if num_classes is None:\n num_classes = len(np.unique(labels))\n return np.eye(num_classes)[labels]",
... | [
"0.81767994",
"0.81767994",
"0.81690663",
"0.8121356",
"0.80816406",
"0.80516374",
"0.80303967",
"0.8008132",
"0.79923594",
"0.79521966",
"0.7885251",
"0.784354",
"0.7818501",
"0.78122574",
"0.7804777",
"0.7786913",
"0.7781721",
"0.777938",
"0.7775648",
"0.7768926",
"0.774957... | 0.794875 | 10 |
Given an array return a CArray with non zero column index | def _non_zero_columns_search(array):
col_num = array.shape[1]
non_zero_col = CArray([], dtype=int)
for c in range(col_num):
col = array[:, c]
if col.any() == True:
non_zero_col = non_zero_col.append(c)
return non_zero_col | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def columnIndexes(a):\n nrows = (a.size-2)+1\n return a[1*np.arange(nrows)[:,None] + np.arange(2)]",
"def as_column_vector(array):\n if array.ndim != 1:\n raise ValueError(\"Array must be 1D\")\n\n idx = _new_attribute_label('idx', array)\n ds = array.datashape.copy()\n ds.dim_low = list... | [
"0.62538207",
"0.6154312",
"0.6062021",
"0.60301137",
"0.5969816",
"0.59055144",
"0.5810338",
"0.58099645",
"0.57873833",
"0.5745728",
"0.5734758",
"0.57009387",
"0.56720334",
"0.5642919",
"0.563061",
"0.5613356",
"0.5587208",
"0.5561727",
"0.55554765",
"0.5542187",
"0.553801... | 0.72024924 | 0 |
get Mac Address of any Interface | def getMacAddress(self, wlanInterface):
self.wlanInterface = wlanInterface
self.storeMacAddress=[]
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', '%s'[:15]) % str(self.wlanInterface))
self.storeMacAddress.append(''... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_mac_address():\n if not sys.platform.startswith('linux'):\n raise RuntimeError(\n 'Cannot get the MAC address on non-Linux platforms'\n )\n ifname = get_default_iface_name_linux()\n s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n info... | [
"0.8049024",
"0.8045483",
"0.8015131",
"0.7972817",
"0.79490703",
"0.78957516",
"0.78957516",
"0.77264905",
"0.7550115",
"0.74143314",
"0.74143314",
"0.7157507",
"0.71216154",
"0.707797",
"0.70584434",
"0.70262265",
"0.70019925",
"0.69836116",
"0.6937341",
"0.693331",
"0.6933... | 0.71830404 | 11 |
Fixed window data extracting function. Uses t test to determine extraction criteria. Extraction is perfomed by sliding a fixed length window over input data and searching for instances where the current window rejects the null hypothesis. Minimum spacing between windows is given by parameter minSpace. Alpha is the reje... | def extractAnomalyTTest(data, windowLength, minSpacing, alpha = 0.05):
#TODO Perhaps come up with a better way to do this. For now this
#is only a maximum local fixed window. In the future this should
#probably be something that allows for varying length to more
#preciecly find the "anomaly"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def window_data(data: np.ndarray):\n\n w_len = 128\n stride = w_len // 2\n\n no_offset_windows = np.split(data, 10)\n offset_windows = np.split(data[stride:-stride], 9)\n windows = [0] * 19\n windows[::2] = no_offset_windows\n windows[1::2] = offset_windows\n windows = np.array(windows, dty... | [
"0.58701444",
"0.5726213",
"0.55810636",
"0.5569914",
"0.55507034",
"0.5540501",
"0.5531356",
"0.55309486",
"0.548879",
"0.5486942",
"0.5463883",
"0.5437892",
"0.54050124",
"0.5397988",
"0.53779846",
"0.53587174",
"0.5345446",
"0.5327882",
"0.5317267",
"0.52903324",
"0.528192... | 0.6724515 | 0 |
Layer normalize the tensor x, averaging over the last dimension. | def layer_norm(x, filters=None, epsilon=1e-6, scope=None, reuse=None):
if filters is None:
filters = x.get_shape()[-1]
with tf.variable_scope(scope, default_name="layer_norm", values=[x], reuse=reuse):
scale = tf.get_variable(
"layer_norm_scale", [filters], regularizer=regularizer, i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(self, x, train=True):\n if train is not None:\n mean, variance = tf.nn.moments(x, [0,1,2])\n assign_mean = self.mean.assign(mean)\n assign_variance = self.variance.assign(variance)\n with tf.control_dependencies([assign_mean, assign_variance]):\n return tf.nn.batch_norm_... | [
"0.7025246",
"0.7000931",
"0.69984037",
"0.6946193",
"0.6926463",
"0.6913268",
"0.6907985",
"0.68715054",
"0.6863467",
"0.6787572",
"0.6776529",
"0.67483455",
"0.6723166",
"0.6712802",
"0.6702004",
"0.66976094",
"0.6691674",
"0.66691875",
"0.6619964",
"0.6619837",
"0.65780723... | 0.0 | -1 |
Returns a list of all handlers of a logger that log to a tty. | def get_tty_handlers(logger):
return [handler for handler in getattr(logger, "handlers", []) if is_tty_handler(handler)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLogFileHandles(logger):\n handles = []\n for handler in logger.handlers:\n handles.append(handler.stream.fileno())\n if logger.parent:\n handles += getLogFileHandles(logger.parent)\n return handles",
"def fileHandlers(self):\n fileHandlers = list()\n handlers = self... | [
"0.71982026",
"0.62994397",
"0.5751824",
"0.56048995",
"0.556734",
"0.555454",
"0.5543403",
"0.5517564",
"0.5478096",
"0.54584783",
"0.54036176",
"0.5385153",
"0.53521574",
"0.5337145",
"0.5278097",
"0.52677524",
"0.5235817",
"0.5229933",
"0.5197669",
"0.51968634",
"0.5180891... | 0.8712313 | 0 |
A view to render the unlockables page for hunt participants. | def unlockables(request):
team = Hunt.objects.get(is_current_hunt=True).team_from_user(request.user)
if(team is None):
return render(request, 'access_error.html', {'reason': "team"})
unlockables = Unlockable.objects.filter(puzzle__in=team.solved.all())
return render(request, 'unlockables.html', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def moderation_view():\n\n # Ensure that the current user is an admin.\n assert users.get_current_user() and users.is_current_user_admin()\n\n config = ModerationConfig.get()\n\n # Approve something, if we were asked to.\n if request.form.get(\"approve\"):\n key = ndb.Key(urlsafe=request.form... | [
"0.597726",
"0.562676",
"0.553994",
"0.54994315",
"0.5352594",
"0.5345847",
"0.53340966",
"0.5248988",
"0.52161324",
"0.5203938",
"0.5195951",
"0.51842046",
"0.5180686",
"0.5166324",
"0.5165731",
"0.5147741",
"0.51413",
"0.51388186",
"0.51265883",
"0.5114786",
"0.51147664",
... | 0.7834212 | 0 |
returns number of normalized exact tag overlap | def baseline_score(self,t0,t1):
return len(set(t0) & set(t1))/len(set(t0).union(set(t1))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOverlap(self):\n return 0.5",
"def normalized_overlap(g, node_1, node_2):\n inter = len(set(nx.neighbors(g, node_1)).intersection(set(nx.neighbors(g, node_2))))\n unio = len(set(nx.neighbors(g, node_1)).union(set(nx.neighbors(g, node_2))))\n return float(inter)/float(unio)",
"def iOverla... | [
"0.64430654",
"0.6401267",
"0.6281209",
"0.62124556",
"0.6187946",
"0.61526525",
"0.6050267",
"0.60221505",
"0.59994835",
"0.5987334",
"0.59605724",
"0.5950121",
"0.5886532",
"0.5871876",
"0.5870326",
"0.5870326",
"0.586041",
"0.5842859",
"0.5839354",
"0.5835769",
"0.5824277"... | 0.0 | -1 |
Load and return the current commandline configuration. The configuration is only loaded once. Successive calls to the modular `load` function will return the same instance. | def load():
global tinyConfig
if not tinyConfig:
tinyConfig = CmdArgs()
return tinyConfig | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load():\n # get (or create) config path\n p = initialize()\n return load_config(open(p['config']))",
"def _load_config():\n\tcfg = configparser.ConfigParser()\n\tcfg.read(join(get_current_path(), 'ib.config'))\n\treturn cfg",
"def load_configuration():\n configuration = Configuration()\n if ... | [
"0.7336868",
"0.69311017",
"0.65522903",
"0.6530449",
"0.6503045",
"0.6483553",
"0.6451366",
"0.6442381",
"0.6419799",
"0.64148504",
"0.6392256",
"0.63451207",
"0.62834287",
"0.627105",
"0.62688684",
"0.62609017",
"0.6245446",
"0.6230625",
"0.6228713",
"0.62223095",
"0.622055... | 0.6743513 | 2 |
Check if these OrcID is equal to an other OrcID. In respect of the id. | def __eq__(self, other):
return self.id == other.id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isEqual (self, other) :\n return self.id == other.getIdent ()",
"def __eq__(self, other):\n return self.__id == other.get_id()",
"def __eq__(self, other):\n return int(self.id) == int(other.id)",
"def __eq__(self, other):\n return type(self) == type(other) and self.id == other... | [
"0.747879",
"0.7266907",
"0.72576016",
"0.7242096",
"0.7187398",
"0.7074712",
"0.70691085",
"0.7067314",
"0.70253456",
"0.7024658",
"0.6878445",
"0.67814875",
"0.6741414",
"0.6728308",
"0.6681014",
"0.6679176",
"0.65962785",
"0.6595509",
"0.6589473",
"0.6550453",
"0.65329134"... | 0.718855 | 4 |
Function that turn a dict that contains the date in the ORCID way into a Date object. | def get_date(d):
return Date(d["year"]["value"], d["month"]["value"] if d["month"] else None,
d["day"]["value"] if d["day"] else None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertSODate(datenum):\n #Date numbers seem to start with 0 = 2001-01-01\n base_date = datetime.date(2001, 1, 1)\n #add key from the spot on object to this base date to get the date\n record_date = base_date + datetime.timedelta(days=int(datenum))\n record_date = record_date.isoformat()\n re... | [
"0.67103845",
"0.65077037",
"0.6472918",
"0.632484",
"0.6321037",
"0.6319199",
"0.62691396",
"0.626546",
"0.6239458",
"0.62359816",
"0.61819774",
"0.6102789",
"0.60954094",
"0.60304004",
"0.6023996",
"0.6023849",
"0.6015135",
"0.6000726",
"0.59992474",
"0.59763217",
"0.595750... | 0.7070992 | 0 |
Computes the sum of elements across dimensions of a matrix in log domain. | def logsumexp(input_matrix, reduction_indices=1, keep_dims=False):
max_input_matrix1 = input_matrix.max(reduction_indices, keepdims=keep_dims)
max_input_matrix2 = max_input_matrix1
if not keep_dims:
max_input_matrix2 = np.expand_dims(max_input_matrix2, reduction_indices)
return np.log(
np.sum(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(matrix):\n\n return float(sum([sum(row) for row in matrix]))",
"def log_sum_exp(x, dim=0):\n max_x = torch.max(x, dim)[0]\n new_x = x - max_x.unsqueeze(dim).expand_as(x)\n return max_x + (new_x.exp().sum(dim)).log()",
"def _compute_log_xi_sum(n_samples, n_components, fwdlattice, \\\n ... | [
"0.6855982",
"0.6811655",
"0.675893",
"0.6717405",
"0.6629505",
"0.65911853",
"0.6511967",
"0.6497679",
"0.6486722",
"0.644598",
"0.64402413",
"0.6421305",
"0.640366",
"0.63712543",
"0.6304618",
"0.6279552",
"0.6235805",
"0.6219433",
"0.61737114",
"0.6169506",
"0.6148941",
... | 0.6579959 | 6 |
The set of arguments for constructing a LocalRulestackOutboundUntrustCertificateAssociation resource. | def __init__(__self__, *,
certificate_id: pulumi.Input[str]):
pulumi.set(__self__, "certificate_id", certificate_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: LocalRulestackOutboundUntrustCertificateAssociationArgs,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Option... | [
"0.81332207",
"0.5703714",
"0.54818267",
"0.50368434",
"0.50118756",
"0.49961534",
"0.49413702",
"0.4803111",
"0.4796441",
"0.4760363",
"0.47326705",
"0.46885884",
"0.46819913",
"0.4674787",
"0.46747667",
"0.46729615",
"0.46648973",
"0.46547133",
"0.46440223",
"0.46421427",
"... | 0.0 | -1 |
Given two integers a and b, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return a or b. | def get_sum(a,b):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSum(self, a, b):\n #\n # 首先,sum 存放每次循环中 a 与 b 的异或值,也就是直接相加值;\n # b 存放每次的进位值,然后 a 存储 sum (也就是直接相加值)进入下一次循环(当进位值非空);\n # 当且仅当进位值为空时,用户的上一次循环中的 sum 已经是可以直接相加的异或结果了,此时得到结果,返回。\n #\n # if a == 0:\n # return b\n # if b == 0:\n # return a\n ... | [
"0.7579851",
"0.7443714",
"0.73597956",
"0.71004945",
"0.6967132",
"0.6952337",
"0.6915755",
"0.6897606",
"0.6885795",
"0.6861058",
"0.68518573",
"0.68453354",
"0.68404263",
"0.68202627",
"0.6724225",
"0.6712659",
"0.6685773",
"0.6649433",
"0.6649433",
"0.65845054",
"0.655858... | 0.72160023 | 3 |
Initialize queue with numbers from 110 as Tuple of (num, length) que = [(i, 1) for i in range(1, 10)] visited = set(que) ans = [] | def numsSameConsecDiff(self, N: int, K: int) -> List[int]:
# Solution - 28 ms
# Solution 2 - 24 ms
deltas = [-K, K] if K > 0 else [K]
results = deque(range(10))
threshold = 10 ** (N - 1) if N > 1 else 0
while results[0] < threshold:
n = results.popleft()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, maxNumbers: int):\n self.numbers_q=collections.deque()\n self.numbers_set=set()\n for i in range(maxNumbers):\n self.numbers_q.append(i)\n self.numbers_set.add(i)",
"def __init__(self):\r\n self.queue = []\r\n self.num = 0\r\n sel... | [
"0.6906392",
"0.65136164",
"0.6352924",
"0.6251828",
"0.6117427",
"0.60590136",
"0.59781104",
"0.59702986",
"0.59641683",
"0.5943144",
"0.59328115",
"0.5905267",
"0.58742195",
"0.5871732",
"0.58491427",
"0.5843421",
"0.5843017",
"0.5842768",
"0.5841678",
"0.5838143",
"0.58366... | 0.0 | -1 |
Load logins from json file and return it | def valid_logins():
login_data = json.load(open('data/login_data.json', 'r', encoding="utf8"))
return (random.choice(login_data['name']),
random.choice(login_data['email']),
random.choice(login_data['password'])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_users():\n with open(user_path, \"r\") as infile:\n return json.load(infile)",
"def load_users(self):\n return self.um.read_json(\"users.json\")",
"def loadProfiles():\n with open(userProfilesDir, \"r\") as infile:\n profiles = json.loads(\"\\n\".join(infile.readlines()))\n ... | [
"0.70639575",
"0.6985728",
"0.6777194",
"0.6566473",
"0.65107685",
"0.6458668",
"0.6436967",
"0.63220876",
"0.6314326",
"0.6278566",
"0.62209475",
"0.6050645",
"0.6011422",
"0.59591264",
"0.5951789",
"0.59275174",
"0.5911429",
"0.5898042",
"0.58328205",
"0.58327734",
"0.58153... | 0.5978686 | 13 |
calculate energy of a structure | def get_stru_energy(struct, sequence,react=None):
if type( react) == type(None):
cmd = "echo \"%s\n%s\" | RNAeval" % (sequence,struct)
else:
fname = tempfile._get_default_tempdir() + '/' + next(tempfile._get_candidate_names()) + "rea.tmp"
rna_io.write_shape(fname, react)
cmd = "e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calc_energy( self, V_a, eos_d ):\n pass",
"def energy_tot(P,F,H,molecule):\n return energy_el(P,F,H) + energy_n(molecule)",
"def energy(self):\n sum_energy = 0.0\n for i in range(0,self.natoms-1):\n for j in range(i+1,self.natoms):\n rij = ... | [
"0.76774234",
"0.7097585",
"0.7039587",
"0.70269674",
"0.70151436",
"0.7006467",
"0.6965693",
"0.69573426",
"0.69470024",
"0.69146925",
"0.69032913",
"0.68752635",
"0.6871304",
"0.6856653",
"0.68374234",
"0.6775301",
"0.6771913",
"0.6751203",
"0.6742225",
"0.67213726",
"0.668... | 0.6119658 | 76 |
Given a dict with the default value, set this to all entries in the database if it does not exist. | def update_with_defaults(self, default_values: dict):
updates = []
for key, value in default_values.items():
for item in self._collect.find({key: {"$exists": False}}, {'_id': True}):
updates.append(pymongo.UpdateOne(item, {"$set": {key: value}}))
if len(updates):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_default_from_dict(self, key, value):\n pass",
"def setdefault_key_value(self):\n raise NotImplementedError",
"def setDefaultDict( self, inDict ):\n self._defDict= inDict\n self._loadedDefaults= list()",
"def save_as_default(self):\n self.default_data = self.get_a... | [
"0.65441644",
"0.6432855",
"0.6403098",
"0.6349219",
"0.63057935",
"0.6292835",
"0.6291248",
"0.6271243",
"0.62391806",
"0.6108104",
"0.6093149",
"0.60876113",
"0.603912",
"0.6030563",
"0.6000747",
"0.598536",
"0.5919914",
"0.59001905",
"0.5862641",
"0.5856397",
"0.58509463",... | 0.5838183 | 21 |
Calculates the entropy of a single column(position) in the transposed MSA. H(i) = sum_x(P(x)ln2(P(x))) | def entropy(column_string):
frequencies = dict()
total = len(column_string)
entropy = 0
for i in column_string:
if i in frequencies:
frequencies[i] +=1
else:
frequencies[i] = 1
for key in frequencies:
frequencies[key] /= total
entropy += frequencies[key]*math.log(frequencies[key], 2)
return -entrop... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entropy(x):\n nz = np.nonzero(x)[0]\n return -np.sum(x[nz]*np.log2(x[nz]))",
"def entropy(target_col):\n elements,counts = np.unique(target_col,return_counts = True)\n entropy = np.sum([(-counts[i]/np.sum(counts))*np.log2(counts[i]/np.sum(counts)) for i in range(len(elements))])\n return entro... | [
"0.70718306",
"0.70689386",
"0.6929866",
"0.6863574",
"0.68609893",
"0.6691708",
"0.662683",
"0.66016823",
"0.6591959",
"0.6557916",
"0.6492585",
"0.64463156",
"0.6439454",
"0.64204806",
"0.64175445",
"0.6409665",
"0.6405161",
"0.638332",
"0.6369886",
"0.6350011",
"0.6347478"... | 0.62074804 | 35 |
Rate encodes a single categorical column. Value in the column represents the frequency the category occurred. | def _rate_encode_category(x):
raw_count = x.value_counts().loc[x]
rate = raw_count / x.shape[0]
return rate.values | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_metric(self) -> mt.Metric:\n return mt.CategoricalAccuracy()",
"def get_metric(self) -> mt.Metric:\n return mt.CategoricalAccuracy()",
"def count_rate(df):\n number_of_rate = dict(df.count())\n return number_of_rate",
"def _set_rate(self):\r\n interval = self.data.iloc[2, 0... | [
"0.5452952",
"0.5452952",
"0.5281905",
"0.5244035",
"0.52079874",
"0.5195408",
"0.51031643",
"0.50920916",
"0.5071273",
"0.5051154",
"0.5030001",
"0.5028329",
"0.50180995",
"0.50117314",
"0.49619097",
"0.4953953",
"0.4953953",
"0.4937364",
"0.4911109",
"0.48904726",
"0.488794... | 0.7680952 | 0 |
Crop patches with width 'w' and height 'h' from the image 'im' | def img_crop(im, w, h):
list_patches = []
imgwidth = im.shape[0]
imgheight = im.shape[1]
is_2d = len(im.shape) < 3
for i in range(0,imgheight,h):
for j in range(0,imgwidth,w):
if is_2d:
im_patch = im[j:j+w, i:i+h]
else:
im_patch = im[j:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop(img, i, j, h, w):\n return img.crop((j, i, j + w, i + h))",
"def crop(img, i, j, h, w):\n return img.crop((j, i, j + w, i + h))",
"def faceCrop(im,x,y,w,h,m):\r\n sizeX, sizeY = im.size\r\n new_x, new_y = max(0,x-m*w), max(0,y-m*h)\r\n new_w = w + 2*m*w if sizeX > (new_x + w + 2*m*w) el... | [
"0.74041873",
"0.74041873",
"0.69971424",
"0.6880926",
"0.67720145",
"0.6755159",
"0.66762334",
"0.66373825",
"0.65363497",
"0.65167564",
"0.65036094",
"0.64810187",
"0.6446353",
"0.6371432",
"0.6306344",
"0.62828374",
"0.6262334",
"0.623639",
"0.62033856",
"0.6177951",
"0.61... | 0.81997514 | 0 |
Clean up path remove repeated and trailing separators. | def _cleanpath(self, path):
slashes = self.remotepathsep*2
while slashes in path:
path = path.replace(slashes,self.remotepathsep)
if path.endswith(self.remotepathsep):
path = path[:-1]
return path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cleanup_path(path):\n return string.join(filter(None, string.split(path, '/')), '/')",
"def _trim_path(path):\n if path.endswith(\"/\"):\n path = path[:-1] # remove / at the end\n \n return path",
"def clean_path(path: str) -> str:\n previous_path = \"\"\n next_path = path\n whil... | [
"0.79813063",
"0.7316052",
"0.7298997",
"0.71896416",
"0.7185246",
"0.71379447",
"0.7052017",
"0.70361805",
"0.7034464",
"0.6992357",
"0.69409937",
"0.68996847",
"0.68013793",
"0.674557",
"0.6729001",
"0.67250544",
"0.6650338",
"0.66169626",
"0.6524884",
"0.6501558",
"0.64973... | 0.7600111 | 2 |
Attach a lot of summaries to a Tensor (for TensorBoard visualization). | def variable_summaries(name, var):
with tf.name_scope('{}_summaries'.format(name)):
mean = tf.reduce_mean(var)
tf.summary.scalar('mean', mean)
with tf.name_scope('stddev'):
stddev = tf.sqrt(tf.reduce_mean(tf.square(var - mean)))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_summary(self):\n for k, v in self.metrics.items():\n tf.summary.scalar(k, v)\n \n self.summary_op = tf.summary.merge_all()",
"def build_summaries(self):\n\n # Loss summary.\n tf.summary.scalar('loss', self.loss)\n\n merged = tf.summary.merge_all()\n self.summary_op = merged\n ... | [
"0.7071791",
"0.6970259",
"0.6970259",
"0.6800256",
"0.67872906",
"0.67407334",
"0.66669947",
"0.66576326",
"0.66193783",
"0.66085786",
"0.6595776",
"0.65836215",
"0.6581151",
"0.655297",
"0.6500364",
"0.6459978",
"0.64145213",
"0.6294558",
"0.62718755",
"0.62713677",
"0.6265... | 0.57042426 | 66 |
creates and returns a dictionary based on given items. giving items as 'key_value_pairs' means giving keys and values as separate arguments | def create_dictionary(self,*key_value_pairs,**items):
if len(key_value_pairs)%2 !=0:
raise ValueError("create dictionary failed. there should be"
"an even number of key-value-pairs")
return self.set_to_dictionary({},*key_value_pairs,**items) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_to_dictionary(self,dictionary,*key_value_pairs,**items):\r\n if len(key_value_pairs) %2 !=0:\r\n raise ValueError(\"Adding data to a dictionary failed.There\"\r\n \"should be an even number of key-value-pairs.\")\r\n for i in range(0,len(key_value_pairs)... | [
"0.6850609",
"0.66062856",
"0.6445895",
"0.6365228",
"0.6312939",
"0.62647146",
"0.6259993",
"0.62531984",
"0.62238854",
"0.61990124",
"0.609982",
"0.60596275",
"0.5942542",
"0.59137344",
"0.5910209",
"0.5889282",
"0.5882027",
"0.58035",
"0.5792526",
"0.5768763",
"0.5757427",... | 0.7842525 | 0 |
returns a copy of the given dictionary. the given dictionary is never altered by this keyword | def copy_dictionary(self,dictionary):
return dictionary.copy() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n return pdict(dict.copy(self))",
"def __copy__(self):\n d = dict()\n d.update(self.items())\n return d",
"def copy(self):\n return self.from_dict(self.to_dict(True))",
"def _copy(query_dict):\n\n memo = { }\n\n result = query_dict.__class__('',\n e... | [
"0.7676748",
"0.7617941",
"0.7513389",
"0.70081407",
"0.6922026",
"0.6908425",
"0.6886668",
"0.6885612",
"0.68280923",
"0.6776255",
"0.6714648",
"0.6666588",
"0.6661702",
"0.66448253",
"0.6634488",
"0.6614255",
"0.65327835",
"0.65181935",
"0.6491104",
"0.64838743",
"0.6455869... | 0.852308 | 0 |
returns 'keys' of the given 'dictionary' 'keys' are returned in sorted order .the given 'dictionary' is never altered by this keyword | def get_dictionary_keys(self,dictionary):
return sorted(dictionary) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sorted_keys(dictionary):\n assertor.assert_type(dictionary, dict)\n return sorted(dictionary.keys())",
"def sort_map_by_keys(dictionary):\n logging.debug('============== IN sort_map_by_keys: ================')\n d = OrderedDict(sorted(dictionary.items()))\n return d",
"def sorted_values(dict... | [
"0.84209216",
"0.7800901",
"0.70769274",
"0.70418227",
"0.6966482",
"0.6932801",
"0.6897497",
"0.68723255",
"0.6839095",
"0.682824",
"0.68167055",
"0.68127865",
"0.681045",
"0.67656803",
"0.6746759",
"0.67201465",
"0.67159766",
"0.6648268",
"0.6636311",
"0.6616749",
"0.658337... | 0.8769019 | 0 |
return list of all nodes in a graph | def nodes(self):
return self.dict.keys() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodes(self):\n return list(self.__graph.keys())",
"def nodes(self):\n\n return list(set(self._graph.keys() + [x for x in itertools.chain.from_iterable(self._graph.values())]))",
"def extract_nodes(graph):\n return graph.get_nodes()",
"def get_node_list(self):\n return [[node] for ... | [
"0.81285065",
"0.81284255",
"0.7986554",
"0.7984016",
"0.79566425",
"0.79187447",
"0.7901351",
"0.7867166",
"0.7814747",
"0.7626598",
"0.7621024",
"0.7603313",
"0.75777876",
"0.75078875",
"0.7470206",
"0.7458932",
"0.7394281",
"0.7384234",
"0.737691",
"0.7370024",
"0.7356149"... | 0.6784964 | 63 |
True if node 'n' is contained in the graph, False if not. | def has_node(self, n):
return n in self.dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_node(self, n):\n return n in self.node_dict",
"def __contains__(self, n):\n try:\n return n in self.node\n except TypeError:\n return False",
"def has_node(self, node: str) -> bool:\n return self.graph.has_node(node)",
"def __contains__(self, gid: uui... | [
"0.83624595",
"0.82728463",
"0.72301203",
"0.70063794",
"0.6994926",
"0.6889675",
"0.6814944",
"0.67925674",
"0.6773637",
"0.6771879",
"0.67528355",
"0.6727434",
"0.67156684",
"0.6703343",
"0.66824937",
"0.6592867",
"0.6584939",
"0.6584939",
"0.652289",
"0.6509774",
"0.649361... | 0.8265258 | 2 |
Adds a new edge to the graph connecting 'n1' to 'n2', if either n1 or n2 are not already present in the graph, they should be added. | def add_edge(self, n1, n2, weight=0):
self.add_node(n1)
self.add_node(n2)
self.dict[n1][n2] = weight | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, n1, n2, weight=0):\n self.add_node(n1)\n self.add_node(n2)\n if n2 in self.node_dict[n1]:\n raise ValueError(\"Edge already exists\")\n self.node_dict[n1][n2] = weight",
"def add_edge(self,node1,node2):\n # add nodes if not already in graph\n ... | [
"0.83229494",
"0.8296899",
"0.82405484",
"0.82202995",
"0.8172307",
"0.80298114",
"0.80170995",
"0.79751945",
"0.79358095",
"0.79270476",
"0.790668",
"0.79015416",
"0.78941774",
"0.78895175",
"0.7872519",
"0.7844411",
"0.7842273",
"0.7839225",
"0.7838129",
"0.7809432",
"0.780... | 0.79155815 | 10 |
returns True if there is an edge connecting n1 and n2, False if not, raises an error if either of the supplied nodes are not in g. | def adjacent(self, n1, n2):
try:
return n2 in self.dict[n1]
except KeyError:
raise KeyError('Node(s) not in graph.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def are_connected(self, node1, node2):\n return bool( self.get_edge(node1, node2) )",
"def is_connected(self, node1, node2):\r\n\r\n return node1 in self.graph and node2 in self.graph[node1]",
"def is_connected(self, node1, node2):\r\n\r\n return node1 in self._graph and node2 in self._gra... | [
"0.70518076",
"0.6954305",
"0.6883817",
"0.68820786",
"0.6862133",
"0.68259096",
"0.68143004",
"0.6737855",
"0.66859156",
"0.651525",
"0.646166",
"0.64334476",
"0.6419163",
"0.63574374",
"0.63284636",
"0.6311556",
"0.6275818",
"0.62560385",
"0.6246771",
"0.6237341",
"0.620179... | 0.6741381 | 7 |
Strips text if text is a string and not None | def stripNotNone(text):
if text is None:
return text
return text.strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def noneToBlankString(text):\n if text in (None, \"None\"):\n return \"\"\n else:\n return str(text)",
"def filter_out_data(text):\n if len(text) < 30:\n return None\n return text",
"def clean_text(self, text) -> Union[str, None]:\n if text and ''.join(text.split()):\n ... | [
"0.70052266",
"0.69989777",
"0.6940541",
"0.6883805",
"0.6873635",
"0.6871773",
"0.6869124",
"0.6728554",
"0.66507006",
"0.6485951",
"0.6337267",
"0.6304469",
"0.6276311",
"0.6263055",
"0.62528527",
"0.622912",
"0.61822724",
"0.6138188",
"0.61239105",
"0.61113423",
"0.6110102... | 0.78735155 | 0 |
Make sure the passwords match and are reasonably strong. | def validate(self, data):
password = data['password']
password2 = data['password2']
if password != password2:
raise serializers.ValidationError("Passwords do not match.")
pw_results = zxcvbn.password_strength(password)
strength = pw_results['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_password_salts_are_random(self):\n self.user.password = '123456'\n self.user2.password = '123456'\n self.assertTrue(self.user.password_hash != self.user2.password_hash)",
"def test06_password_mixture(self):\n self.set_complexity(length=14, numeric=1, upper=1, lower=1, special... | [
"0.7565452",
"0.744423",
"0.7184821",
"0.70896167",
"0.7059353",
"0.6969448",
"0.69638056",
"0.69314134",
"0.6871152",
"0.6845535",
"0.6841995",
"0.683328",
"0.68324494",
"0.6784773",
"0.6780269",
"0.6716528",
"0.6712425",
"0.6705994",
"0.6692625",
"0.66850924",
"0.6676746",
... | 0.6230988 | 80 |
Compute and create a plt.figure for the confusion matrix. | def plot_confusion_matrix(y_pred, y_true, classes_list):
fig = plt.figure(figsize=(8, 8))
cm = confusion_matrix(y_pred, y_true)
plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)
plt.title('Confusion matrix')
plt.colorbar()
tick_marks = np.arange(len(classes_list))
plt.xticks(tick_ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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(\"Confusion matrix\")\n plt.colorbar()\n tick_marks = np.arange(len(class_names))\n plt.xticks(tick_marks, class_names, rotation=45)\n plt.yticks(tick_... | [
"0.76378006",
"0.7538706",
"0.7414774",
"0.7409197",
"0.74053234",
"0.73584485",
"0.73408395",
"0.732357",
"0.7316564",
"0.73154837",
"0.72781175",
"0.7257628",
"0.71955526",
"0.71893877",
"0.7189244",
"0.7187937",
"0.7172829",
"0.7135574",
"0.71033466",
"0.71033084",
"0.7100... | 0.7262683 | 11 |
Initialize the Snapcast group device. | def __init__(self, group, uid_part, entry_id):
self._attr_available = True
self._group = group
self._entry_id = entry_id
self._uid = f"{GROUP_PREFIX}{uid_part}_{self._group.identifier}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, device, group):\n super().__init__(device, group)\n self._sensor_type = SENSOR_TYPES.get(self._insteon_device_group.name)",
"def init(\n self,\n fsdp_root: \"FullyShardedDataParallel\",\n process_group: dist.ProcessGroup,\n ) -> None:\n self.process... | [
"0.6174313",
"0.58061534",
"0.5791827",
"0.5735662",
"0.56251293",
"0.5574636",
"0.55519974",
"0.5540415",
"0.5528399",
"0.55002207",
"0.5480682",
"0.5457478",
"0.5445082",
"0.5420409",
"0.5405941",
"0.5389548",
"0.5387072",
"0.538559",
"0.5381504",
"0.5371608",
"0.5371008",
... | 0.5333165 | 26 |
Return the ID of snapcast group. | def unique_id(self):
return self._uid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_id(self):\n return self._id",
"def id(self):\n return self._group",
"def group_id(self) -> str:\n return pulumi.get(self, \"group_id\")",
"def group_id(self) -> str:\n return pulumi.get(self, \"group_id\")",
"def group_id(self):\n return self._group_id",
"def ... | [
"0.75321466",
"0.7524809",
"0.7450004",
"0.7450004",
"0.739933",
"0.739933",
"0.739933",
"0.7339864",
"0.7224272",
"0.7141996",
"0.7127781",
"0.71107",
"0.70619184",
"0.6882426",
"0.6882426",
"0.6882426",
"0.6576977",
"0.65670955",
"0.65372217",
"0.6522578",
"0.6504903",
"0... | 0.0 | -1 |
Return the state attributes. | def extra_state_attributes(self):
state_attrs = {}
if self.latency is not None:
state_attrs["latency"] = self.latency
return state_attrs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.828... | 0.0 | -1 |
Transform a length1 pytorch Variable or Tensor to scalar. Suppose tx is a torch Tensor with shape tx.size() = torch.Size([1]), then npx = tx.cpu().numpy() has shape (1,), not 1. | def to_scalar(vt):
if isinstance(vt, Variable):
return vt.data.cpu().numpy().flatten()[0]
if torch.is_tensor(vt):
return vt.cpu().numpy().flatten()[0]
raise TypeError('Input should be a variable or tensor') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tensor2scalar(x):\n if isinstance(x, float):\n return x\n return x.cpu().detach().item()",
"def scalar(val: torch.Tensor):\n return val.item()",
"def to_scalar(vt):\n if isinstance(vt, Variable):\n return vt.data.cpu().numpy()[0]\n if torch.is_tensor(vt):\n return vt.cpu().numpy()[0... | [
"0.7183169",
"0.7059463",
"0.7018484",
"0.659343",
"0.6504539",
"0.6455741",
"0.6364318",
"0.6363998",
"0.62532496",
"0.62107074",
"0.617769",
"0.6077553",
"0.60545844",
"0.59830314",
"0.59695107",
"0.590905",
"0.5886396",
"0.58833444",
"0.5874004",
"0.58702725",
"0.5852054",... | 0.6986642 | 3 |
Decay exponentially in the later phase of training. All parameters in the optimizer share the same learning rate. | def adjust_lr_exp(optimizer, base_lr, ep, total_ep, start_decay_at_ep):
assert ep >= 1, "Current epoch number should be >= 1"
if ep < start_decay_at_ep:
return
for g in optimizer.param_groups:
g['lr'] = (base_lr * (0.001 ** (float(ep + 1 - start_decay_at_ep)
/ (total_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decay(self):\n if self.l_rate > self.l_rate_bound[0] and self.l_rate - self.decay_rate > 0.0:\n self.l_rate -= self.decay_rate\n elif self.l_rate - self.decay_rate <= 0.0 or self.l_rate < self.l_rate_bound[0]:\n self.l_rate = self.l_rate_bound[0]\n\n for layer in self... | [
"0.73073995",
"0.7188299",
"0.7141604",
"0.7141604",
"0.71214825",
"0.709998",
"0.70627195",
"0.70188093",
"0.6974986",
"0.69556373",
"0.69534534",
"0.6952221",
"0.6945993",
"0.6939619",
"0.6922862",
"0.6921824",
"0.6908557",
"0.6895963",
"0.6890419",
"0.6886585",
"0.6870398"... | 0.6896839 | 17 |
Multiplied by a factor at the BEGINNING of specified epochs. All parameters in the optimizer share the same learning rate. | def adjust_lr_staircase(optimizer, base_lr, ep, decay_at_epochs, factor):
assert ep >= 1, "Current epoch number should be >= 1"
if ep not in decay_at_epochs:
return
ind = find_index(decay_at_epochs, ep)
for g in optimizer.param_groups:
g['lr'] = base_lr * factor ** (ind + 1)
print('=====> lr adjuste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(optimizer, lr_factor, epoch):\n #lr = args.lr * (0.1 ** (epoch // 30))\n print('the learning rate is set to {0:.5f}'.format(lr_factor[epoch]*args.lr))\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr_factor[epoch]*args.lr",
"def adjust_learning_rate(o... | [
"0.7113544",
"0.70357907",
"0.6988679",
"0.69865876",
"0.6901707",
"0.6891242",
"0.6806891",
"0.6751895",
"0.6751766",
"0.67462426",
"0.67285407",
"0.67174757",
"0.6711819",
"0.6708797",
"0.6689218",
"0.6689218",
"0.66806006",
"0.66727084",
"0.66697687",
"0.6667069",
"0.66622... | 0.64927083 | 58 |
Sets the author on the embed object. | def set_author(self, **kwargs):
self.author_name = kwargs.get('name')
self.author_url = kwargs.get('url')
self.author_icon = kwargs.get('icon_url') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_author (self, author):\n self.author = author",
"def author(self, author):\n self._author = author",
"def author(self, author):\n\n self._author = author",
"def author(self, author):\n\n self._author = author",
"def set_author(self, author):\n self.author = author... | [
"0.8217383",
"0.80453765",
"0.7959115",
"0.7959115",
"0.79441345",
"0.7757595",
"0.7514848",
"0.74400467",
"0.7245462",
"0.72074866",
"0.7160151",
"0.6938365",
"0.65808654",
"0.64917445",
"0.64917445",
"0.64917445",
"0.64585584",
"0.64470404",
"0.64470404",
"0.64470404",
"0.6... | 0.7072091 | 11 |
Makes a POST request to Discord with the message payload. | def send(self):
payload = self.format_payload()
# Makes sure that the required fields are provided before
# sending the payload.
if not self.webhook_url:
print ('Error: Webhook URL is required.')
elif not payload:
print ('Error: Message payload cannot be empty.')
else:
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send(data, webhook_url):\n dis_data = data\n url = webhook_url\n headers = {\"Content-Type\": \"application/json\"}\n discord_request = requests.post(url, data=json.dumps(dis_data), headers=headers)\n\n try:\n discord_request.raise_for_status()\n except requests.exceptions.HTTPError as... | [
"0.690218",
"0.66697055",
"0.65777516",
"0.65308434",
"0.641231",
"0.640462",
"0.63927865",
"0.6330926",
"0.630515",
"0.6290296",
"0.6255871",
"0.6250351",
"0.62402916",
"0.61637014",
"0.6133146",
"0.61261094",
"0.61244595",
"0.6096707",
"0.6088893",
"0.60804373",
"0.6074452"... | 0.6328293 | 8 |
Obtain the maximum end date for all the periods. Returns | def maxend (self):
maxend = self.list[0]["period"].end
for actor in self.list:
if maxend < actor["period"].end:
maxend = actor["period"].end
return maxend | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bundle_end_date(self):\n if not self._bundle_end_date:\n max_date = self.engine.execute(\n \"\"\"\n SELECT\n MAX(end_date)\n FROM (\n SELECT\n end_date\n FROM\n ... | [
"0.6812721",
"0.6675194",
"0.6504102",
"0.6503208",
"0.6503208",
"0.6503208",
"0.6439226",
"0.64038974",
"0.64038974",
"0.63469046",
"0.63469046",
"0.61774576",
"0.6168872",
"0.6167924",
"0.61671704",
"0.61629415",
"0.61612743",
"0.61504257",
"0.610582",
"0.60973006",
"0.6030... | 0.78753257 | 0 |
Get age (in days) for each actor, relative to date. The age for each actor is the difference between date and their first activity. Age is positive for actors who were already active before date, and negative for actors active only after date. | def age (self, date, offset = timedelta(0)):
ages = [{"id": actor["id"],
"name": actor["name"],
"age": date - actor["period"].start + offset}
for actor in self.list]
return ActorsDuration(ages, date) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_age(self):\n for employee in self:\n if employee.sudo().birthday:\n employee.age = relativedelta(\n fields.Date.from_string(fields.Date.today()),\n fields.Date.from_string(employee.sudo().birthday)).years\n else:\n ... | [
"0.6828357",
"0.6739668",
"0.6736136",
"0.6715061",
"0.6715061",
"0.6715061",
"0.6715061",
"0.66956526",
"0.6690617",
"0.6599577",
"0.6592482",
"0.64882755",
"0.64775413",
"0.6420146",
"0.64089006",
"0.6290197",
"0.6276019",
"0.62375677",
"0.61796474",
"0.61387414",
"0.612080... | 0.7625493 | 0 |
Determine the image and repo from artifacts, or parent artifacts | def _get_image_from_artifact(self):
try:
image = self.info.artifacts["image"]["file"]
repository = self.info.artifacts["image"].get("repository")
except (AttributeError, KeyError):
parent_artifacts = self.info.parent.get("artifacts", {})
image = parent_art... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def required_images(self):\n required = set()\n deployment_type = self.get_var(\"openshift_deployment_type\")\n host_groups = self.get_var(\"group_names\")\n # containerized etcd may not have openshift_image_tag, see bz 1466622\n image_tag = self.get_var(\"openshift_image_tag\", ... | [
"0.5984173",
"0.59787935",
"0.5924479",
"0.59142756",
"0.59056824",
"0.58895946",
"0.5854135",
"0.57982993",
"0.5712957",
"0.57107997",
"0.56966674",
"0.5645014",
"0.56311285",
"0.55962485",
"0.5564793",
"0.5543641",
"0.5479576",
"0.5456488",
"0.53845036",
"0.538348",
"0.5378... | 0.7100933 | 0 |
Fake L{reactor.spawnProcess}, that logs all the process arguments and returns a L{DummyProcess}. | def spawnProcess(self, processProtocol, executable, args=(), env={},
path=None, uid=None, gid=None, usePTY=0,
childFDs=None):
proc = DummyProcess(self, executable, args, env, path,
processProtocol, uid, gid, usePTY, childFDs)
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_managed_process(\n *unused_args: str, **unused_kwargs: str\n) -> ContextManager[scripts_test_utils.PopenStub]:\n return contextlib.nullcontext(\n enter_result=scripts_test_utils.PopenStub(alive=False))",
"def test_basic(self):\n # start()\n # As the lock is mocked out, this provides a... | [
"0.71459705",
"0.68630904",
"0.6753379",
"0.6548701",
"0.6535807",
"0.6382773",
"0.632711",
"0.61472315",
"0.61184067",
"0.6082397",
"0.60684645",
"0.60643655",
"0.60519993",
"0.5954809",
"0.5936036",
"0.5931801",
"0.5923",
"0.59037334",
"0.58966017",
"0.5882999",
"0.5875886"... | 0.6536725 | 4 |
L{ProcessMonitor.removeProcess} removes the process from the public processes list. | def test_removeProcess(self):
self.pm.startService()
self.pm.addProcess("foo", ["foo"])
self.assertEqual(len(self.pm.processes), 1)
self.pm.removeProcess("foo")
self.assertEqual(len(self.pm.processes), 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeProcess(self, name):\n self.stopProcess(name)\n del self.processes[name]",
"def delete_process(self, pid):\n del self.processes[pid]",
"def unregister_proc(self, pid: int):\n self.processes.remove(pid)",
"def removeProcessToMonitor(self, pid = None):\n\n if pid ==... | [
"0.73370546",
"0.69379884",
"0.6837745",
"0.6561334",
"0.6370796",
"0.6280941",
"0.61442095",
"0.60770357",
"0.5943861",
"0.59131926",
"0.5722543",
"0.5535331",
"0.5518671",
"0.5271959",
"0.52434796",
"0.52180356",
"0.52026397",
"0.51433074",
"0.512536",
"0.5065361",
"0.50645... | 0.6237855 | 6 |
Creates and returns dictionary of test variables. | def get_variables(interface):
# basic settings
bd_name = 'bd_persist'
sub_if_id = 1
sub_if_name = interface + '.' + str(sub_if_id)
variables = {
# VxLan settings
'vx_interface': 'vx_tunnel_test',
'vxlan_settings': {'src': '192.168.0.2',
'dst': '192... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dictOfRandomVariables(self):\n return dict()",
"def _get_test_variables():\n if __name__ == \"__main__\":\n return _MOCKUP_TEST_VARIABLES\n else:\n return BuiltIn().get_variables()",
"def make_vars(tups):\n return dict([(varname, value) for varname, value in tups])",
"def set_... | [
"0.7146327",
"0.6960978",
"0.68589664",
"0.6780129",
"0.6730224",
"0.6643693",
"0.6511674",
"0.64971393",
"0.6451066",
"0.63540256",
"0.63318485",
"0.62468594",
"0.6243047",
"0.6200931",
"0.6178312",
"0.61763716",
"0.6157774",
"0.61571205",
"0.6129747",
"0.61164826",
"0.60960... | 0.0 | -1 |
Send a message to Slack (using 1.x API for python2 compatibility) | def slack_post(title="Test", message="Hello world!", color="#999999"):
attach = dict(fallback=message, title=title, text=message, color=color)
r = client.chat_postMessage(
channel=CHANNEL, attachments=[attach], username=f"{HOSTNAME} DBA alert"
)
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_slack(self, message):\n self.slack_client.api_call('chat.postMessage', channel=self.slack_channel, text=message, username=self.username, icon_emoji=self.slack_icon_emoji)\n print(\"Slack Notification sent\")",
"def send_message_to_slack(text):\n\n try:\n post = {\n \"t... | [
"0.7941588",
"0.7888074",
"0.75683343",
"0.74583167",
"0.74387807",
"0.73947537",
"0.72893906",
"0.70918965",
"0.7076772",
"0.70649385",
"0.70635957",
"0.69902235",
"0.69671786",
"0.6947133",
"0.6863298",
"0.68310267",
"0.6825425",
"0.68032664",
"0.6777842",
"0.67486495",
"0.... | 0.72199637 | 7 |
Computes the sum of bits in n mod 2. | def parity(n):
# bin(n) returns 0b....
# bin(n)[2:] trims "ob"
return sum(int(x) for x in bin(n)[2:]) % 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nextPowerOf2(n):\n count = 0; \n \n # First n in the below \n # condition is for the \n # case where n is 0 \n if (n and not(n & (n - 1))): \n return n \n \n while( n != 0): \n n >>= 1\n count += 1\n \n return 1 << count;",
"def solution2(n):\n ones =... | [
"0.71478206",
"0.70750785",
"0.7046894",
"0.70166343",
"0.69310427",
"0.68998146",
"0.68893903",
"0.68882096",
"0.6826794",
"0.678979",
"0.67819035",
"0.67767817",
"0.6765639",
"0.6746692",
"0.67268234",
"0.6710847",
"0.66844726",
"0.66811794",
"0.66655976",
"0.6647687",
"0.6... | 0.6217979 | 56 |
Return posterior probabilities OR sequence segmentation. If the MAXPRODUCT algorithm is selected, this method returns the most likely sequence segmentation as a list of integers. Each integer in the list marks where a segment begins. If the SUMPRODUCT algorithm is selected, this method returns the posterior probabiliti... | def infer(self):
# In the max-product algorithm, the most likely hypotheses are
# tracked. Recover the most likely segment boundaries by performing a
# back-trace.
if self.__alg__ == 'maxprod':
# Find the most likely hypothesis.
max_hypothesis = max(self.__hypot... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_segmentation(self) -> Dict[str, Any]:\n for sample_token in tqdm(self.sample_tokens, disable=not self.verbose):\n sample = self.nusc.get('sample', sample_token)\n # Get the sample data token of the point cloud.\n sd_token = sample['data']['LIDAR_TOP']\n\n ... | [
"0.58536303",
"0.5461574",
"0.53169847",
"0.52293",
"0.52198684",
"0.52184343",
"0.5194421",
"0.51746124",
"0.5149888",
"0.51464635",
"0.51283896",
"0.50972444",
"0.5084264",
"0.5052799",
"0.5036352",
"0.50322825",
"0.5006233",
"0.49612784",
"0.49584192",
"0.4956369",
"0.4949... | 0.7316798 | 0 |
Initialization of grid parameters and correlation radius in points | def initialize(self, **params):
self._n_x = params['n_x']
self._n_y = params['n_y']
self._dx = params['dx']
self._dy = params['dy']
self._r_corr_in_points = self._r_corr_in_meters // max(self._dx, self._dy) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_grid(self):\n self.pts = np.array(\n np.meshgrid(\n np.arange(self.net_dim[0]) + 1,\n np.arange(self.net_dim[1]) + 1\n )\n ).reshape(2, np.prod(self.net_dim)).T\n if self.topo == \"hexagonal\":\n self.pts[:, 0] = self.pts[... | [
"0.6307908",
"0.6288814",
"0.612999",
"0.6120697",
"0.6120397",
"0.6073723",
"0.60621566",
"0.5956167",
"0.59454066",
"0.5942787",
"0.5942787",
"0.5942787",
"0.5942787",
"0.5942787",
"0.5904307",
"0.59009",
"0.5822595",
"0.5770236",
"0.5762691",
"0.57382095",
"0.5727292",
"... | 0.64924186 | 0 |
Add a run to a run set. | def add_pacbio_run(run_set, sample_entry):
### Init ###
# Check protocol
if sample_entry['Protocol'] != 'hifi' and sample_entry['Protocol'] != 'clr':
raise RuntimeError('Protocol not supported: ' + sample_entry['Protocol'])
UPLOAD_FILE_NAME_FORMAT = UPLOAD_FILE_NAME_FORMAT_BAM
# Check MD... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_runs(self,runs):\n for r in runs:\n self.add(r)",
"def add_run(self, beta_run, icount=2):\n counter = icount\n if beta_run.run_number in self.beta_runs:\n if \"add{}_\".format(counter - 1) in beta_run.run_number:\n beta_run.run_number = beta_run.r... | [
"0.755014",
"0.6382405",
"0.63631463",
"0.6314343",
"0.61989987",
"0.60958844",
"0.60784763",
"0.60235304",
"0.59610486",
"0.59159327",
"0.59108174",
"0.5851961",
"0.5739181",
"0.56877947",
"0.5619967",
"0.56143016",
"0.5578914",
"0.55497617",
"0.55302167",
"0.55143917",
"0.5... | 0.5195309 | 46 |
Returns a BertSelfAttention2 layer based on model_1 and model_2. | def _add_bert_self_attention_layer(model_1, model_2):
class Config:
pass
config = Config()
config.hidden_size = model_1.all_head_size + model_2.all_head_size
config.num_attention_heads = (
model_1.num_attention_heads + model_2.num_attention_heads
)
config.output_attentions = mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,\n m1_model: KBModelM1,\n functionalities: Dict[int, float],\n inverse_functionalities: Dict[int, float],\n relation_id_to_density: Dict[int, float],\n relation_id_to_distinct_subjects: Dict[int, int],\n ... | [
"0.5917746",
"0.58876956",
"0.57883567",
"0.5716416",
"0.56941223",
"0.5594753",
"0.55759466",
"0.55740947",
"0.5524735",
"0.5516693",
"0.54700893",
"0.5467188",
"0.54449064",
"0.5426601",
"0.54153585",
"0.5386755",
"0.5379582",
"0.5371798",
"0.53674465",
"0.53575575",
"0.533... | 0.8021525 | 0 |
Returns an embedding layer with a weight matrix | def _add_embedding_layer(model_1, model_2):
result_layer = torch.nn.Embedding(
model_1.num_embeddings, model_1.embedding_dim + model_2.embedding_dim
)
result_layer.weight = torch.nn.Parameter(
torch.cat((model_1.weight.data, model_2.weight.data), dim=1)
)
return result_layer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def embedding(input, weight, padding_idx=None):\n if padding_idx is not None:\n num_embeddings = weight.size(0)\n if padding_idx > 0:\n if padding_idx >= num_embeddings:\n raise ValueError('<padding_idx> must be within embedding matrix.')\n elif padding_idx < 0:\n ... | [
"0.69794565",
"0.68703884",
"0.6856147",
"0.6842559",
"0.67836607",
"0.6773442",
"0.6623473",
"0.66096264",
"0.6604349",
"0.65209067",
"0.65154594",
"0.648971",
"0.6470586",
"0.6322218",
"0.6321226",
"0.63058066",
"0.6193853",
"0.618376",
"0.618047",
"0.6172435",
"0.6165832",... | 0.66812307 | 6 |
Returns a linear layer that has the following | def _add_linear_layer(model_1, model_2):
data_1 = model_1.weight.data
data_2 = model_2.weight.data
new_weight_top = torch.cat((data_1, torch.zeros((data_1.shape[0], data_2.shape[1])).cuda()), dim=1)
new_weight_bottom = torch.cat((torch.zeros((data_2.shape[0], data_1.shape[1])).cuda(), data_2), dim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear(x,output_dim):\n w=tf.get_variable(\"w\", [x.get_shape()[1], output_dim])\n b=tf.get_variable(\"b\", [output_dim], initializer=tf.constant_initializer(0.0))\n return tf.nn.xw_plus_b(x,w,b)",
"def _add_final_linear_layer(model_1, model_2):\n data_1 = model_1.weight.data\n data_2 = model_2.weig... | [
"0.6445529",
"0.6421191",
"0.624913",
"0.6225397",
"0.61821175",
"0.6104525",
"0.6093496",
"0.5932845",
"0.59166753",
"0.5916506",
"0.5899539",
"0.58350694",
"0.57631826",
"0.57461447",
"0.574171",
"0.57402617",
"0.5734494",
"0.5719483",
"0.57170665",
"0.5715677",
"0.5715677"... | 0.63397986 | 2 |
Returns a linear layer that has the following | def _add_linear_layer_with_noise(model_1, model_2):
data_1 = model_1.weight.data
data_2 = model_2.weight.data
top_right = torch.zeros((data_1.size()[0], data_2.size()[1]))
torch.nn.init.normal_(top_right, mean=0, std=1e-07)
if data_1.is_cuda:
top_right = top_right.to(1)
new_weight_top = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear(x,output_dim):\n w=tf.get_variable(\"w\", [x.get_shape()[1], output_dim])\n b=tf.get_variable(\"b\", [output_dim], initializer=tf.constant_initializer(0.0))\n return tf.nn.xw_plus_b(x,w,b)",
"def _add_final_linear_layer(model_1, model_2):\n data_1 = model_1.weight.data\n data_2 = model_2.weig... | [
"0.64456916",
"0.64214367",
"0.6339791",
"0.6249253",
"0.62254167",
"0.6182655",
"0.6104743",
"0.6094154",
"0.5933119",
"0.59168106",
"0.5916457",
"0.5899818",
"0.5835721",
"0.5763616",
"0.57461506",
"0.57418495",
"0.5740365",
"0.5734632",
"0.5719577",
"0.57172143",
"0.571562... | 0.5650892 | 24 |
Returns a linear layer that has the following | def _add_final_linear_layer(model_1, model_2):
data_1 = model_1.weight.data
data_2 = model_2.weight.data
new_weight = torch.cat((data_1, data_2), dim=1)
new_bias = model_1.bias + model_2.bias
result_model = torch.nn.Linear(
model_1.in_features + model_2.in_features, model_1.out_features
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear(x,output_dim):\n w=tf.get_variable(\"w\", [x.get_shape()[1], output_dim])\n b=tf.get_variable(\"b\", [output_dim], initializer=tf.constant_initializer(0.0))\n return tf.nn.xw_plus_b(x,w,b)",
"def _add_linear_layer(model_1, model_2):\n data_1 = model_1.weight.data\n data_2 = model_2.weight.dat... | [
"0.64451456",
"0.6339345",
"0.62492096",
"0.62248355",
"0.6182295",
"0.61040753",
"0.6093247",
"0.5933044",
"0.5916729",
"0.5915626",
"0.589922",
"0.58361584",
"0.576348",
"0.57455975",
"0.57407355",
"0.5739732",
"0.5734045",
"0.57188743",
"0.5716391",
"0.571501",
"0.571501",... | 0.6420726 | 1 |
Given a label image and two coordinates, it will draw a line which intensity is 0. | def cut_neck(template, r0, c0, r1, c1):
# rr, cc, _ = line_aa(r0, c0, r1, c1)
rr, cc = line(r0, c0, r1, c1)
template[rr, cc] = 0
return template | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_line(image, pt1, pt2, color):\n\n\t# TODO -> Add your line drawing code here\n\n\t# Sample code to draw white dots at pt1 and pt2 positions\n\tset_pixel(image, pt1, color)\n\tset_pixel(image, pt2, color)",
"def _plot_line(self, image, x1, y1, x2, y2, width, color):\n\n draw = ImageDraw.Draw(image... | [
"0.6234152",
"0.62001014",
"0.61421424",
"0.60221624",
"0.6007346",
"0.59946513",
"0.5889682",
"0.5884753",
"0.58257747",
"0.58198285",
"0.5808387",
"0.5800585",
"0.57726914",
"0.57498044",
"0.57217324",
"0.57005906",
"0.564463",
"0.56421626",
"0.56381905",
"0.5634665",
"0.56... | 0.0 | -1 |
_getCmsswVersion_ Return a string representing the CMSSW version to be used. | def getCmsswVersion(self):
if not self.crabPSet:
return self.step.data.application.setup.cmsswVersion
# CRAB3 needs to use an environment var to get the version
return os.environ.get("CMSSW_VERSION", "") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCmsswVersion(self):\n return self[\"CMSSW_VERSION\"]",
"def getCmsswVersion(self):\n if not self.crabPSet:\n return self.step.data.application.setup.cmsswVersion\n else:\n # CRAB3 needs to use an environment var to get the version\n return os.environ.g... | [
"0.8768621",
"0.83873713",
"0.62814695",
"0.61708075",
"0.6069534",
"0.5977843",
"0.5931922",
"0.591451",
"0.57908386",
"0.5789783",
"0.5772911",
"0.5703937",
"0.56753844",
"0.56592184",
"0.5657275",
"0.5563059",
"0.55555725",
"0.5528619",
"0.5478674",
"0.54770994",
"0.547403... | 0.8353171 | 2 |
Return file name from path | def get_filename(filepath):
return os.path.basename(filepath) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_name(path):\n return os.path.basename(path)",
"def getfilename(path):\r\n return path.split('\\\\').pop().split('/').pop().rsplit('.', 1)[0]",
"def file_name(path):\n return os.path.basename(path).split('.')[0]",
"def get_file_name(path: str) -> str:\n return os.path.splitext(os.path... | [
"0.88987064",
"0.85714877",
"0.8565595",
"0.85344785",
"0.85113364",
"0.85056174",
"0.84267795",
"0.81734324",
"0.81536955",
"0.81456125",
"0.8066949",
"0.78927577",
"0.78440505",
"0.78382343",
"0.7813387",
"0.77886176",
"0.77730495",
"0.77517617",
"0.77012",
"0.76750296",
"0... | 0.76330316 | 20 |
Build the home (index.html) page and, optionally, the trends.html toplevel page. | def build_htmlhome(sample, htmldir, htmlhome='index.html', pixscale=0.262,
racolumn='RA', deccolumn='DEC', #diamcolumn='GROUP_DIAMETER',
maketrends=False, fix_permissions=True):
import legacyhalos.html
htmlhomefile = os.path.join(htmldir, htmlhome)
print('Building ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n template_stories = [\"silly_story\", \"excited_story\"]\n\n return render_template(\"homepage.html\", story_list = template_stories)",
"def home_page():\n\n return render_template('index.html', stories=stories.values())",
"def homepage():\n return render_template('home/index.html', ti... | [
"0.73568046",
"0.7154184",
"0.7088814",
"0.7078633",
"0.7047227",
"0.703737",
"0.703737",
"0.70124763",
"0.6990189",
"0.69790936",
"0.69705665",
"0.696519",
"0.69599545",
"0.6909411",
"0.69082963",
"0.68861127",
"0.6858096",
"0.6858096",
"0.6858096",
"0.6858096",
"0.6858096",... | 0.0 | -1 |
Create a list of colors corresponding to the countries list | def color_label_generator(clusters):
colors = ['green', 'red', 'blue']
point_colors = ["" for i in range(12)]
for i, cluster in enumerate(clusters):
for point_num in cluster:
point_colors[point_num] = colors[i]
return point_colors | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_colors(countries, max_users):\n for country_code in countries:\n countries[country_code]['color_rgb'] = [\n calculate_color(\n countries[country_code]['percentage_of_users'],\n max_users,\n 8,\n 229\n ),\n ... | [
"0.6920807",
"0.6713507",
"0.67083573",
"0.64908546",
"0.6403987",
"0.6397412",
"0.6341364",
"0.63167465",
"0.62841797",
"0.6214844",
"0.6175581",
"0.6130313",
"0.60408163",
"0.59948736",
"0.5988846",
"0.59804195",
"0.5963954",
"0.59511524",
"0.59439653",
"0.5907104",
"0.5860... | 0.55719346 | 50 |
Yield `count` batches, where each batch is a list of (timestep, batch_idx) tuples. | def batches(self, batch_size, count):
entries = self.entries()
for _ in range(count):
yield [next(entries) for _ in range(batch_size)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def EpochBatchIterator(\n batch_builder: BaseBatchBuilder,\n target_graph_counts: Iterable[int],\n start_graph_count: int = 0,\n):\n total_graph_count = start_graph_count\n for target_graph_count in target_graph_counts:\n total_graph_count += target_graph_count\n batches = _LimitBatche... | [
"0.6850149",
"0.6569519",
"0.6529254",
"0.65169454",
"0.6504593",
"0.65036285",
"0.64625293",
"0.63094896",
"0.63094896",
"0.63094896",
"0.6283559",
"0.62557447",
"0.62408483",
"0.6236669",
"0.6198028",
"0.61864483",
"0.6185714",
"0.61809576",
"0.6176542",
"0.617281",
"0.6138... | 0.7464114 | 0 |
Compute pdf of N(0,1) | def n_pdf(x):
return 1/np.sqrt(2*np.pi)*np.exp(-x**2/2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdf(self, xs):\n xs = np.atleast_2d(xs)\n return self.factor * np.exp(-0.5 * np.sum(xs * xs, axis=0))",
"def pdf(self, x):\n\t\treturn 1.5 * np.power(x,2) ##obtained after finding z from integrating x^2 from -1 to 1",
"def pdf(self, grid, dataSegment):\n return (grid[0] ** dataSegment[... | [
"0.75401795",
"0.7330846",
"0.73120934",
"0.71898323",
"0.7157154",
"0.7125751",
"0.7113969",
"0.7113969",
"0.706644",
"0.70426714",
"0.7024148",
"0.69957614",
"0.6970906",
"0.6962027",
"0.6915569",
"0.69102865",
"0.6900861",
"0.6900004",
"0.68974847",
"0.6895707",
"0.6892713... | 0.78154564 | 0 |
Returns True if no items on a stack, otherwise returns False | def is_empty(self):
if self.length == 0:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self): #checks to see if stack is empty or not\n if self.num_items == 0:\n return True\n else:\n return False",
"def is_empty(self):\n return self._stack_items == []",
"def is_empty(self):\n return len(self.the_stack) == 0",
"def e... | [
"0.86767447",
"0.8331035",
"0.83149",
"0.8295163",
"0.8231015",
"0.82291174",
"0.8185003",
"0.8185003",
"0.8179008",
"0.8152708",
"0.81432045",
"0.80912656",
"0.8086269",
"0.80625623",
"0.79820514",
"0.79718",
"0.79718",
"0.79704833",
"0.79704833",
"0.7883596",
"0.785111",
... | 0.0 | -1 |
Returns a last item from stack | def last_item(self):
return self.container[self.length-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop(self):\n item = self.stack[-1]\n self.stack = self.stack[:-1]\n return item",
"def remove_last_item_from_stack(self):\n if self.length > 0:\n return self.container.pop()\n else:\n return None",
"def pop(self):\n if self.is_empty():\n ... | [
"0.8170887",
"0.8026986",
"0.7561193",
"0.7518914",
"0.74832183",
"0.74796206",
"0.74288094",
"0.7394494",
"0.7377728",
"0.73743236",
"0.7347266",
"0.7338143",
"0.7300595",
"0.72679627",
"0.72423935",
"0.7235669",
"0.7227278",
"0.7227278",
"0.7227278",
"0.7217285",
"0.7194533... | 0.7974505 | 2 |
Test light switch setup from config entry with unknown entity registry id. | async def test_config_entry_unregistered_uuid(
hass: HomeAssistant, target_domain: str
) -> None:
fake_uuid = "a266a680b608c32770e6c45bfe6b8411"
config_entry = MockConfigEntry(
data={},
domain=DOMAIN,
options={
CONF_ENTITY_ID: fake_uuid,
CONF_TARGET_DOMAIN: t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_config_entry_entity_id(\n hass: HomeAssistant, target_domain: Platform\n) -> None:\n config_entry = MockConfigEntry(\n data={},\n domain=DOMAIN,\n options={\n CONF_ENTITY_ID: \"switch.abc\",\n CONF_TARGET_DOMAIN: target_domain,\n },\n ti... | [
"0.7338543",
"0.66584027",
"0.6646935",
"0.6613546",
"0.65766186",
"0.655548",
"0.6489315",
"0.6377924",
"0.63634884",
"0.63606393",
"0.6348558",
"0.6242547",
"0.61899567",
"0.61600906",
"0.61280656",
"0.611042",
"0.60724175",
"0.6061826",
"0.60113525",
"0.5987852",
"0.597952... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.