query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Builds a histogram of values given an iterable of mappings and a key. For each mapping "m" with key "key" in iterator, the value m[key] is considered. Returns a list of tuples (hash, count, proportion, value), where "hash" is a sha1sum hash of the value. "count" is the number of occurences of values that hash to "hash"... | def build_histogram(iterator, key):
buckets = defaultdict(int)
values = {}
num_objects = 0
for obj in iterator:
num_objects += 1
try:
val = obj[key]
except (KeyError, TypeError):
continue
value_hash = hashlib.sha1()
value_hash.update(sya... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_list(hash_map, keys):\n word_counts = [] # initialize empty list for word counts\n\n # iterate through all keys in the set\n for key in keys:\n value = hash_map.get(key) # fetch value for the current key\n word_counts.append((key, value)) # append the tuple formatted (key, val... | [
"0.62433976",
"0.5874765",
"0.5807315",
"0.5762578",
"0.5741219",
"0.567829",
"0.5661489",
"0.5657134",
"0.5650179",
"0.5650179",
"0.558463",
"0.558463",
"0.55465764",
"0.55321306",
"0.5517353",
"0.55055034",
"0.54166317",
"0.5399882",
"0.53576636",
"0.5314523",
"0.53041196",... | 0.8098769 | 0 |
Test fail when trying to signup with an existing email | def test_signup_existing_email(self):
url = '/0/chefs'
data = {
'email': self.user.email,
'password': 'secret',
'name': 'John',
'surname': 'Doe',
'language': 'es',
}
resp = self.client.post(url, data=data)
self.assertEqu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_signup_missing_email(self):\n\n invalid_u = User.signup(None, \"testuser\", \"testpass\", \"Test\", \"User\", None)\n \n uid = 99999\n invalid_u.id = uid\n\n with self.assertRaises(exc.IntegrityError) as context:\n db.session.commit()",
"def test_register_ex... | [
"0.8121672",
"0.8100355",
"0.79914504",
"0.7966945",
"0.79290634",
"0.78825",
"0.78538597",
"0.78521883",
"0.7835272",
"0.78132766",
"0.7812779",
"0.77946997",
"0.7790612",
"0.77850413",
"0.7742307",
"0.7736527",
"0.77243173",
"0.7717619",
"0.7701845",
"0.7695915",
"0.7685317... | 0.8455592 | 0 |
Test fail when sending invalid params at signup | def test_signup_invalid_params(self):
url = '/0/chefs'
# No data
data = {}
resp = self.client.post(url, data=data)
self.assertEqual(resp.status_code, 400)
self.assertEqual(resp.data['code'], 400)
self.assertEqual(resp.data['message'], 'Invalid parameters')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_registration_fails_for_missing_parameters(self):\n resp = self.test_client.post(\"/api/v1/auth/register\")\n self.assertEqual(resp.status_code, 400)\n data = json.loads(resp.data)\n self.assertEqual(\n data[\"message\"],\n \"you need to enter both the... | [
"0.7844327",
"0.77811277",
"0.7775406",
"0.76737154",
"0.7640591",
"0.75956047",
"0.74659085",
"0.73942053",
"0.7378038",
"0.7337052",
"0.73232025",
"0.73102736",
"0.73099387",
"0.7291879",
"0.7289674",
"0.72811973",
"0.7267153",
"0.7262471",
"0.72411805",
"0.7226106",
"0.722... | 0.7986197 | 0 |
Test get self Chef | def test_get_self(self):
url = '/0/chefs'
resp = self.client.get(url)
self.assertPermissionDenied(resp)
headers = self.login()
resp = self.client.get(url, **headers)
self.assertEqual(resp.status_code, 200)
self.assertIn('chef', resp.data)
self.assertEqua... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_system(self):\n pass",
"def test_get_run(self):\n pass",
"def test_get_recipe_information(self):\n pass",
"def test_get_commands(self):\n self.installer.os = \"amazonLinux\"\n commands = self.installer._get_commands()\n assert len(commands) > 0\n ... | [
"0.6476642",
"0.634032",
"0.6107374",
"0.60835195",
"0.6045064",
"0.6035675",
"0.60203016",
"0.60191286",
"0.5964071",
"0.58675206",
"0.5860166",
"0.5804437",
"0.5799616",
"0.5771165",
"0.57573444",
"0.57526183",
"0.57388955",
"0.5721284",
"0.57191247",
"0.57172894",
"0.56791... | 0.6809186 | 0 |
Test get Chef with photo | def test_get_chef_with_photo(self):
url = '/0/chefs/' + str(self.user.pk)
headers = self.login()
resp = self.client.get(url, **headers)
self.assertEqual(resp.status_code, 200)
self.assertIn('chef', resp.data)
self.assertNotIn('photo', resp.data['chef'])
self.user... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_photos(self):\n recipe = Recipes.objects.create(chef=self.user, draft=False, private=False)\n photo = Photos.objects.create(recipe=recipe, photo_order=1)\n\n url = '/0/chefs/%i/photos' % self.user.pk\n\n resp = self.client.get(url)\n self.assertPermissionDenied(resp)... | [
"0.72576076",
"0.7185627",
"0.7070028",
"0.6913519",
"0.6779656",
"0.67234474",
"0.6634403",
"0.66217315",
"0.66099155",
"0.6528186",
"0.65029997",
"0.6425517",
"0.6420477",
"0.64150953",
"0.6414753",
"0.63893515",
"0.6307123",
"0.62892",
"0.6271793",
"0.62598026",
"0.6230758... | 0.820912 | 0 |
Test get drafts of a chef | def test_get_drafts(self):
r1 = Recipes.objects.create(chef=self.user, name="Recipe 1", draft=True)
r2 = Recipes.objects.create(chef=self.user, name="Recipe 2", draft=False)
url = '/0/chefs/%i/drafts' % self.user.pk
resp = self.client.get(url)
self.assertPermissionDenied(resp)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_load_draft(league):\n draft = league.draft_results()\n assert(len(draft) == 144)\n #mcdavid 1st\n assert(draft[0]['player_key'] == '396.p.6743')\n # carter hart 67th\n assert(draft[66]['player_key'] == '396.p.7156')\n # zadorov last\n assert(draft[-1]['player_key'] == '396.p.599... | [
"0.6352454",
"0.6243344",
"0.60634345",
"0.59144443",
"0.58387285",
"0.5779342",
"0.56427056",
"0.56400126",
"0.56305224",
"0.55719894",
"0.55666673",
"0.5556045",
"0.5539719",
"0.5524101",
"0.552297",
"0.5499391",
"0.5492469",
"0.5491132",
"0.54893005",
"0.54730755",
"0.5471... | 0.7398199 | 0 |
Test get books of a chef | def test_get_books(self):
book1 = Book.objects.create(chef=self.user)
book2 = Book.objects.create(chef=self.user, book_type=Book.TO_SELL)
url = '/0/chefs/%i/books' % self.user.pk
resp = self.client.get(url)
self.assertPermissionDenied(resp)
headers = self.login()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_books_method(self):\n result = self.book.get_books()\n self.assertTrue(result)",
"def test_read_book(self):\n\n delete_books()\n\n book = create_book(\"title one\")[\"book\"]\n\n with test_client.get(\"/book/{}/\".format(book[\"id\"])) as response:\n\n s... | [
"0.7180482",
"0.7024727",
"0.69065464",
"0.6828925",
"0.676341",
"0.6632599",
"0.652474",
"0.65187514",
"0.6503426",
"0.65010756",
"0.6440636",
"0.64365",
"0.6412048",
"0.6401122",
"0.6395345",
"0.6385182",
"0.6355214",
"0.63172936",
"0.628445",
"0.62715685",
"0.62551796",
... | 0.71184486 | 1 |
Test get photos of a chef | def test_get_photos(self):
recipe = Recipes.objects.create(chef=self.user, draft=False, private=False)
photo = Photos.objects.create(recipe=recipe, photo_order=1)
url = '/0/chefs/%i/photos' % self.user.pk
resp = self.client.get(url)
self.assertPermissionDenied(resp)
he... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_chef_with_photo(self):\n url = '/0/chefs/' + str(self.user.pk)\n headers = self.login()\n resp = self.client.get(url, **headers)\n self.assertEqual(resp.status_code, 200)\n self.assertIn('chef', resp.data)\n self.assertNotIn('photo', resp.data['chef'])\n\n ... | [
"0.7743782",
"0.6829301",
"0.67836845",
"0.6772251",
"0.6643747",
"0.6615853",
"0.65598196",
"0.6522996",
"0.6504507",
"0.6496941",
"0.6473579",
"0.64030343",
"0.63989407",
"0.6277306",
"0.6260105",
"0.622099",
"0.6200895",
"0.61987615",
"0.6191987",
"0.61844575",
"0.61583775... | 0.7300395 | 1 |
Test registration with facebook | def test_signup_facebook(self, mocked_facebook, mocked_sendy):
url = '/0/chefs'
data = {
'email': 'johndoe@example.com',
'fb_access_token': 'TOKEN',
'name': 'John',
'surname': 'Doe',
'language': 'es',
}
mocked_facebook.return_va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_signup_login_facebook(self, mocked_facebook, mocked_sendy):\n url = '/0/chefs'\n data = {\n 'email': 'johndoe@example.com',\n 'fb_access_token': 'TOKEN',\n 'name': 'John',\n 'surname': 'Doe',\n 'language': 'es',\n }\n mocke... | [
"0.7900534",
"0.741936",
"0.73794997",
"0.7275501",
"0.7215751",
"0.72008",
"0.7192416",
"0.7087651",
"0.707313",
"0.7060629",
"0.70167506",
"0.70075756",
"0.69956833",
"0.69721985",
"0.6927428",
"0.6919743",
"0.6918986",
"0.6916858",
"0.69100404",
"0.6909286",
"0.6903661",
... | 0.77579355 | 1 |
Test registration with a photo | def test_signup_photo(self, mocked_sendy):
url = '/0/chefs'
data = {
'email': 'johndoe@example.com',
'password': 'secret',
'name': 'John',
'surname': 'Doe',
'language': 'es',
'photo': IMAGES['png'],
}
resp = self.cli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_get_registered(self):\n img = BytesIO(b'images/Screen_Shot_2019-12-24_at_12.33.34.png')\n img.name = \"myimage.png\"\n url = reverse(\"register_user\")\n response = self.client.post(url, { \"username\": \"janedoe\", \"email\":\"janedoe@email.com\", \"password\":\"123\", \"... | [
"0.7926338",
"0.75307405",
"0.7283007",
"0.7208024",
"0.71915627",
"0.71540934",
"0.68165654",
"0.68001765",
"0.6796672",
"0.674159",
"0.6666542",
"0.6594835",
"0.6593995",
"0.6576625",
"0.6517541",
"0.6502099",
"0.6501964",
"0.6443999",
"0.64113736",
"0.6374036",
"0.6367903"... | 0.7955134 | 0 |
Test get chef's facebook id | def test_get_chef_facebook_id(self):
url = '/0/facebook'
self.user.fb_user_id = 'FB_ID'
self.user.fb_access_token = 'TOKEN'
self.user.save()
resp = self.client.get(url)
self.assertPermissionDenied(resp)
headers = self.login()
resp = self.client.get(url,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_chef_facebook_id(self):\n url = '/0/facebook'\n\n data = {'fb_user_id': 'FB_ID', 'fb_access_token': 'TOKEN'}\n\n resp = self.client.post(url, data)\n self.assertPermissionDenied(resp)\n\n headers = self.login()\n\n # Without data\n resp = self.client.po... | [
"0.73383886",
"0.69110185",
"0.65447694",
"0.63805336",
"0.62422544",
"0.62227225",
"0.6216214",
"0.6182178",
"0.6166742",
"0.6134784",
"0.6118882",
"0.6092159",
"0.6026129",
"0.6008636",
"0.59688044",
"0.596521",
"0.5961509",
"0.5940854",
"0.58199996",
"0.5752718",
"0.569061... | 0.8471372 | 0 |
Test set chef's facebook id | def test_set_chef_facebook_id(self):
url = '/0/facebook'
data = {'fb_user_id': 'FB_ID', 'fb_access_token': 'TOKEN'}
resp = self.client.post(url, data)
self.assertPermissionDenied(resp)
headers = self.login()
# Without data
resp = self.client.post(url, **header... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_chef_facebook_id(self):\n url = '/0/facebook'\n\n self.user.fb_user_id = 'FB_ID'\n self.user.fb_access_token = 'TOKEN'\n self.user.save()\n\n resp = self.client.get(url)\n self.assertPermissionDenied(resp)\n\n headers = self.login()\n resp = self... | [
"0.79430753",
"0.66861093",
"0.62252456",
"0.59206605",
"0.5812997",
"0.5798508",
"0.57349694",
"0.5734449",
"0.5725819",
"0.5719309",
"0.5678224",
"0.5661664",
"0.5649968",
"0.5649178",
"0.564226",
"0.5627347",
"0.56215537",
"0.5605089",
"0.55495596",
"0.54952425",
"0.548698... | 0.78903675 | 1 |
Test delete chef's facebook id | def test_delete_chef_facebook_id(self):
url = '/0/facebook'
self.user.fb_user_id = 'FB_ID'
self.user.fb_access_token = 'TOKEN'
self.user.save()
resp = self.client.delete(url)
self.assertPermissionDenied(resp)
headers = self.login()
resp = self.client.de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_id_delete(self):\n pass",
"def test_get_chef_facebook_id(self):\n url = '/0/facebook'\n\n self.user.fb_user_id = 'FB_ID'\n self.user.fb_access_token = 'TOKEN'\n self.user.save()\n\n resp = self.client.get(url)\n self.assertPermissionDenied(resp)\n\n ... | [
"0.6959481",
"0.6900694",
"0.68606555",
"0.68168575",
"0.6722174",
"0.6570718",
"0.6499945",
"0.64777905",
"0.64528614",
"0.64465207",
"0.6391612",
"0.6390442",
"0.6386338",
"0.63839215",
"0.6376821",
"0.6372202",
"0.6361435",
"0.6347037",
"0.6328622",
"0.6328622",
"0.6309848... | 0.87928045 | 0 |
Test get chef's facebook friends to follow | def test_get_chef_facebook_friends_to_follow(self, mocked_facebook):
url = '/0/facebook/friends'
mocked_facebook.return_value = {
'data': [
{
'name': 'Friend1',
'id': 'FB_ID1'
},
{
'n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add_followers(self):\n pass",
"def follows_target_check(twitter,top_followers_list):\n yes_follow_list = []\n not_follow_list = []\n following_dict = {}\n target = 'HillaryClinton'\n \n for user in top_followers_list:\n params = {'source_id':user, 'target_screen_name':tar... | [
"0.6975192",
"0.664485",
"0.66437894",
"0.66080886",
"0.6545551",
"0.6520821",
"0.6515515",
"0.64823484",
"0.64600056",
"0.64239573",
"0.6390204",
"0.6386054",
"0.63784146",
"0.63372743",
"0.63342613",
"0.6311041",
"0.6188004",
"0.61508006",
"0.612374",
"0.6114839",
"0.610388... | 0.8386643 | 0 |
rotates the complete matrix according to x,y,z | def rotatematrix(m, x, y ,z):
for i in xrange(x):
m = rotatem_x(m)
for i in xrange(y):
m = rotatem_y(m)
for i in xrange(z):
m = rotatem_z(m)
return m | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate(self, x=0, y=0, z=0):\n\t\tquaternion = R.from_euler('xyz', [x, y, z], degrees=True)\n\t\trotation_matrix = np.array(quaternion.as_matrix())\n\t\trotation_matrix = np.pad(rotation_matrix, [(0, 1), (0, 1)], mode='constant')\n\t\trotation_matrix[3,3] = 1\n\n\t\tself.matrix = np.matmul(self.matrix, rotatio... | [
"0.7443821",
"0.72906315",
"0.70417315",
"0.70232594",
"0.69875175",
"0.69020265",
"0.6857698",
"0.68385106",
"0.67997444",
"0.677776",
"0.67739475",
"0.67630064",
"0.6741109",
"0.66981894",
"0.6683466",
"0.66559166",
"0.66322666",
"0.6608254",
"0.6603616",
"0.6599171",
"0.65... | 0.7946977 | 0 |
Checks if the organism is elgible for a QN job and if so dispatches it. An organism is eligible for a QN job if it has more than MIN samples on a single platform. | def dispatch_qn_job_if_eligible(organism: Organism) -> None:
samples = Sample.processed_objects.filter(
organism=organism,
has_raw=True,
technology="MICROARRAY",
is_processed=True,
platform_name__contains="Affymetrix",
)
if samples.count() < MIN:
logger.info(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_fit_more(self):\n\n return len(self._requeue_jobs) < MAX_NUM",
"def can_run_experiment(self, info, device):\n nb_qubit_max = self.backends[device]['nq']\n nb_qubit_needed = info['nq']\n return nb_qubit_needed <= nb_qubit_max, nb_qubit_max, nb_qubit_needed",
"def handle(self,... | [
"0.61850584",
"0.5900076",
"0.5773874",
"0.55981344",
"0.5565287",
"0.55206895",
"0.5452229",
"0.5430043",
"0.5409027",
"0.5397476",
"0.53824",
"0.5199531",
"0.518388",
"0.51629543",
"0.5160733",
"0.5147695",
"0.5147695",
"0.5147695",
"0.51367724",
"0.51311034",
"0.51042396",... | 0.76257104 | 0 |
Dispatch QN_REFERENCE creation jobs for all Organisms with a platform with enough processed samples. | def handle(self, *args, **options):
if options["organisms"]:
organism_names = options["organisms"].split(",")
organisms = Organism.objects.filter(name__in=organism_names)
else:
organisms = Organism.objects.all()
for organism in organisms:
dispatc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dispatch_qn_job_if_eligible(organism: Organism) -> None:\n samples = Sample.processed_objects.filter(\n organism=organism,\n has_raw=True,\n technology=\"MICROARRAY\",\n is_processed=True,\n platform_name__contains=\"Affymetrix\",\n )\n\n if samples.count() < MIN:\n ... | [
"0.6475256",
"0.55186105",
"0.50689244",
"0.5050482",
"0.501838",
"0.50102156",
"0.49754617",
"0.493003",
"0.48858607",
"0.48584223",
"0.4837625",
"0.48150113",
"0.48086077",
"0.47463083",
"0.4714161",
"0.47113824",
"0.47051105",
"0.47018775",
"0.46838635",
"0.4679192",
"0.46... | 0.568913 | 1 |
Set which boxes are visible. | def set_visible_boxes(self, idx_box_vis):
if not self.variable_vis:
raise ValueError('Variable visibility must be enabled via "variable_vis"')
# Find which boxes are now visible that weren't last update of 'self.visible_boxes',
# and vice-versa
newbox_vis = np.setdi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_visible(self, state: bool):\n self.box.set_visible(state)\n if not state:\n self.add_box.set_visible(False)",
"def show_box(self, coor):\n\n for i in range(self.boxes.shape[0]):\n for j in range(self.boxes.shape[0]):\n self.boxes[i, j].set_visible... | [
"0.6871116",
"0.6863543",
"0.68359274",
"0.68055904",
"0.68055904",
"0.68055904",
"0.68055904",
"0.68055904",
"0.68055904",
"0.68055904",
"0.68055904",
"0.68055904",
"0.68055904",
"0.68055904",
"0.6683516",
"0.663565",
"0.65381724",
"0.63933444",
"0.63039213",
"0.6302516",
"0... | 0.72460145 | 0 |
Array of indexes of boxes that are currently visible. | def visible_boxes(self):
if not self.variable_vis:
raise ValueError('Variable visibility must be enabled via "variable_vis".')
return self._visible_boxes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activeChildWellIndices(self):\n return self._activeWellIndices",
"def get_34index_list(self):\n msk = self.load_mask()\n return [i for (i,v) in enumerate(msk) if v==1]",
"def indices(self):\n slice_list = []\n for axis in range(self.ndim):\n if axis in self.dis... | [
"0.667127",
"0.66098076",
"0.649953",
"0.64284825",
"0.6357638",
"0.634663",
"0.6343066",
"0.62989444",
"0.62894857",
"0.62763494",
"0.6264251",
"0.62637955",
"0.625783",
"0.62535286",
"0.62453705",
"0.619242",
"0.6191503",
"0.6182959",
"0.61586684",
"0.6135255",
"0.6127939",... | 0.67173785 | 0 |
The vispy.visuals.MeshVisual that used to fill in. | def mesh(self):
return self._mesh | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mesh(self):\n self._ensure_mesh()\n return self._mesh",
"def get_mesh(self):\n return self.mesh",
"def getMesh(self):\n return self.mesh",
"def show_mesh(self):\n g = self.build_gmsh()\n if g:\n mesh = cfm.GmshMesh(g)\n mesh.el_type = self.e... | [
"0.6806747",
"0.65791893",
"0.6558242",
"0.6491259",
"0.62664014",
"0.6237129",
"0.6208497",
"0.615927",
"0.60939723",
"0.60888344",
"0.60705",
"0.5994552",
"0.59809655",
"0.5952687",
"0.5920004",
"0.5856578",
"0.58521825",
"0.5839071",
"0.57246846",
"0.570731",
"0.56939",
... | 0.66739905 | 1 |
Plot a curve of one or more classification metrics vs. epoch. | def plot_curve(epochs, hist, list_of_metrics):
# list_of_metrics should be one of the names shown in:
# https://www.tensorflow.org/tutorials/structured_data/imbalanced_data#define_the_model_and_metrics
plt.figure()
plt.xlabel("Epoch")
plt.ylabel("Value")
for m in list_of_metrics:
x = hist[m]
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_learning_curve(self):\n\n # Loop output classes\n for c in range(1,self.n_output_classes):\n # Get data\n x_values = np.array(self.n_class_samples_list[c])\n accuracy = np.array(self.accuracy_list[c])\n precision = np.array(self.precision_list[c])\... | [
"0.74008095",
"0.7243723",
"0.7237462",
"0.7235167",
"0.7196403",
"0.7191028",
"0.7170476",
"0.7084031",
"0.70716345",
"0.70501333",
"0.7032067",
"0.70216435",
"0.7007549",
"0.69880277",
"0.6926381",
"0.6898733",
"0.68972385",
"0.6889812",
"0.686029",
"0.6845836",
"0.68317056... | 0.73830307 | 1 |
if user enters an amount that is not enough, they should not be given the item and their money should be returned | def test_amount_not_enough(self):
item, change, _ = give_item_and_change('coke', .50)
self.assertIsNone(item)
self.assertEqual(change, 0.5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def amount_entered():\n while True: #Run until a suitable input is passed.\n try:\n amt = int(input(\"Enter value you wish to trade >>> \"))\n if amt <= 0:\n raise Exception\n return amt\n except ValueError: #if a string is entered\n print... | [
"0.70608425",
"0.7048668",
"0.6820923",
"0.6761242",
"0.6565699",
"0.6541074",
"0.6474827",
"0.646314",
"0.64538455",
"0.64456546",
"0.6440168",
"0.6427558",
"0.6369602",
"0.6368873",
"0.63403964",
"0.6331443",
"0.62916195",
"0.6288129",
"0.6280676",
"0.6277007",
"0.62600404"... | 0.7405286 | 0 |
only to be called for contextless purposes. in templates, use is_votable | def is_votable_slow(self):
return self.is_votable and not self._current_user_vote | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_voters():",
"def get_voters():",
"def _vote(self, team):\r\n return True",
"def can_vote(age):\n return age >= 18",
"def can_view(self, user):\r\n return True",
"def can_be_viewed_by(self,user):\n return True",
"def should_render(\n self,\n *,\n cont... | [
"0.6347413",
"0.6347413",
"0.62672406",
"0.5919822",
"0.5908369",
"0.5898732",
"0.5872455",
"0.5872455",
"0.5865792",
"0.5843716",
"0.5758735",
"0.5755841",
"0.57297236",
"0.5581121",
"0.5575616",
"0.55574644",
"0.55574566",
"0.5542494",
"0.5519472",
"0.5515512",
"0.5515512",... | 0.6545112 | 0 |
returns the Vote object of this link for the specified user (or the currently logged in user if user is not specified) or None if the user has not voted on it yet | def _user_vote(self, user):
from . import Vote
if not user.is_authenticated:
return None
return (
Vote.query
.filter(Vote.type == 'links')
.filter(Vote.user_id == user.id)
.filter(Vote.thing_id == self.id)
.first()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_for_user(self, obj, user):\n if not user.is_authenticated:\n return None\n content_object = ContentType.objects.get_for_model(obj)\n try:\n vote = self.get(voter=user, content_type=content_object, object_id=obj._get_pk_val())\n\n except ObjectDoesNotExist:\... | [
"0.7796545",
"0.7590941",
"0.75795954",
"0.62007797",
"0.6159514",
"0.6088877",
"0.5955817",
"0.5776241",
"0.57702315",
"0.57532567",
"0.56499624",
"0.55581504",
"0.5533404",
"0.55273354",
"0.5515895",
"0.5509523",
"0.54279643",
"0.5415073",
"0.5415073",
"0.5415073",
"0.54150... | 0.8448549 | 0 |
Gets general annotation data for a dataset. Basically everything that the annotation Web UI needs, like classes and their colors, which keys to press for each class, and progress. | def annotation_data(dataset_name):
try:
classnames = get_classnames(dataset_name)
except FileNotFoundError:
return None
else:
# Removing R from this would not be sufficient, and would look like a bug
all_keys = 'abcdefghijklmnopqrstuvwxyz'
colors... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_annotations(self) -> List[Dict[int, Dict[str, Any]]]:\n annotations = []\n for item in self.collector:\n data_file_type = os.path.basename(item).split(\".\")[-1]\n annotations.append(\n load_annotation_file(\n os.path.join(\n ... | [
"0.6100371",
"0.5930464",
"0.58168316",
"0.57694376",
"0.57194066",
"0.56618434",
"0.56347775",
"0.5609098",
"0.55929613",
"0.55875194",
"0.5569791",
"0.55386776",
"0.55345094",
"0.55141187",
"0.55112606",
"0.55028033",
"0.5489555",
"0.54789513",
"0.54480016",
"0.5446405",
"0... | 0.7287963 | 0 |
Calculate the magnitude of a 3d vector | def vector_3d_magnitude(x, y, z):
return math.sqrt((x * x) + (y * y) + (z * z)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magnitude(v):\n if len(v.arr) != 4 or v[3] != 0.0:\n raise ValueError(\"Only use this function with vectors.\")\n return np.sqrt(np.sum(np.square(v.arr)))",
"def vector_magnitude(v):\n\n v = np.atleast_2d(v)\n\n return np.sqrt((v**2).sum(axis=1))",
"def magnitude( vectors ):\n vectors... | [
"0.77811116",
"0.759065",
"0.7551002",
"0.7550866",
"0.7518799",
"0.7386942",
"0.7368965",
"0.7349469",
"0.73449564",
"0.7306271",
"0.72413987",
"0.71244526",
"0.7120417",
"0.7073096",
"0.70674366",
"0.7043916",
"0.70030254",
"0.687828",
"0.67796177",
"0.67767006",
"0.6765149... | 0.8485649 | 0 |
Returns a slice of y with a specified width | def windowcut(y, i, j, dur=1, sr=16000, discard_short=True):
if dur < len(y)/sr:
left = round((i+j)/2)-round(dur*sr/2)
right = left+round(dur*sr)
if left < 0:
left = 0
right = round(dur*sr)
elif right > len(y):
right = len(y)
left = rig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop_scope(self, x, yin_start, scope_shift):\n return torch.stack(\n [\n x[\n i,\n yin_start\n + scope_shift[i] : yin_start\n + self.yin_scope\n + scope_shift[i],\n ... | [
"0.5745769",
"0.56596357",
"0.56081295",
"0.5587428",
"0.5543565",
"0.5526532",
"0.5512229",
"0.54833853",
"0.54370314",
"0.5419847",
"0.53095645",
"0.53095645",
"0.5308653",
"0.528652",
"0.52655846",
"0.5227977",
"0.5204625",
"0.5199836",
"0.5189389",
"0.5183875",
"0.5170519... | 0.612583 | 0 |
The function collect the adjusted close prices of all given stocks in "tickers" and save it in a csv. It's useful for collecting timeseries | def download_stock_price_hist(
tickers = [ 'AAPL' ],
price_column = 'Adj Close', # assume it's the Adjusted Close price that are interested
start = datetime.date( 2009, 12, 31 ), # assume start is guaranteed to be a weekday
end = datetime.date( 2015, 12, 31 ),
csv_file = "stock_price_test.csv",
):
# Che... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gather_stock_data(tickers, save=True):\n prices = pd.DataFrame()\n ts = TimeSeries(key='EY2QBMV6MD9FX9CP', output_format='pandas')\n\n for ticker in tickers:\n successful_grab = False\n ticker_daily_adj = None\n\n while successful_grab is not True:\n try:\n ... | [
"0.7676052",
"0.65778995",
"0.6491287",
"0.62602",
"0.62568295",
"0.6210967",
"0.6161625",
"0.6123165",
"0.60736",
"0.6038035",
"0.6005312",
"0.598648",
"0.59670985",
"0.5935379",
"0.59336746",
"0.5927037",
"0.5919231",
"0.5854586",
"0.5815284",
"0.5735999",
"0.57307273",
"... | 0.68193996 | 1 |
drop the db after each test | def tearDown(self):
db.drop_all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n app.db.drop_database('local')\n app.db.close()",
"def tearDown(self):\n with app.app_context():\n db = app.db.get_db()\n cur = db.cursor()\n with app.open_resource('sql/drop_tests.sql', mode='r') as f:\n cur.execute(f.read... | [
"0.8770249",
"0.87615293",
"0.8755055",
"0.87394303",
"0.8652944",
"0.8602954",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
"0.85897136",
... | 0.87856054 | 0 |
Ensure id is correct for the current/logged in user | def test_get_by_id(self):
with self.client:
self.client.post('/users/login', data=dict(
username="eschoppik", password='secret'
), follow_redirects=True)
self.assertTrue(current_user.id == 1)
self.assertFalse(current_user.id == 20) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_id(self, id):",
"def test_wrong_id(self):\n self.request.matchdict = {'user_id': int(self.request.user.id)+4}\n self.request.json_body = {}\n result = user_id_put_view(self.request)['d']\n self.assertEqual(result, error_dict('api_errors', 'not authenticated for this request'... | [
"0.71248406",
"0.69235414",
"0.69196355",
"0.6904955",
"0.6854695",
"0.68270594",
"0.67593163",
"0.67175955",
"0.67118835",
"0.6628256",
"0.6587404",
"0.6533205",
"0.6528264",
"0.647162",
"0.6466161",
"0.6448794",
"0.6445844",
"0.6387218",
"0.6369543",
"0.6369119",
"0.6351478... | 0.70606107 | 1 |
Ensure that the login page loads correctly | def test_login_page_loads(self):
response = self.client.get('/users/login')
self.assertIn(b'Please login', response.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_login(self, resp: ResponseContextManager) -> None:\n is_login_page = '__appianCsrfToken' in resp.cookies\n if resp.ok and is_login_page:\n self.login()\n elif not resp.ok:\n # Check login page actually returns a csrf token\n login_page_resp = self.get... | [
"0.73760843",
"0.71508247",
"0.7103101",
"0.70669746",
"0.70501286",
"0.7037683",
"0.69945127",
"0.69945127",
"0.69325566",
"0.693044",
"0.6920101",
"0.6901194",
"0.6886291",
"0.6876428",
"0.6860329",
"0.6851631",
"0.6819138",
"0.67941445",
"0.6789541",
"0.6769932",
"0.676877... | 0.74059683 | 0 |
Get the absolute position of a corner. | def absolute_position(corner: str):
screen = ui.main_screen().rect
if corner == Corner.TOP_LEFT:
return (0, 0)
elif corner == Corner.TOP_RIGHT:
return (screen.width, 0)
elif corner == Corner.BOTTOM_LEFT:
return (0, screen.height)
elif corner ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relative_position(self) -> Tuple[int, int]:\n return self.position[0] - self.region.rect.x, self.position[1] - self.region.rect.y",
"def relative_position(self) -> Tuple[int, int]:\n return self.position[0] - self.region.rect.x, self.position[1] - self.region.rect.y",
"def get_absolute_pos(x,... | [
"0.6634786",
"0.6634786",
"0.6623731",
"0.6619794",
"0.6616437",
"0.6604719",
"0.6572081",
"0.6554048",
"0.65352184",
"0.6524717",
"0.65233713",
"0.6521669",
"0.64607877",
"0.645872",
"0.6423324",
"0.6406516",
"0.6397813",
"0.6383624",
"0.63822013",
"0.6361139",
"0.63440365",... | 0.7907764 | 0 |
Click a position, relative to a corner. | def corner_click(position: Corner) -> None:
actions.self.corner_hover(Corner)
actions.mouse_click() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click(pos=(0, 0)):\n pyautogui.click(x=pos[0], y=pos[1])",
"def click(xy, offset_xy=(0,0)):\n (x,y) = xy\n (offset_x, offset_y) = offset_xy\n x = x + offset_x\n y = y + offset_y\n move_to((x,y))\n win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)\n win32api.mouse_eve... | [
"0.7769098",
"0.7308915",
"0.7297762",
"0.7030748",
"0.69894505",
"0.6878038",
"0.6859976",
"0.6858614",
"0.68559927",
"0.6754344",
"0.6660804",
"0.6593836",
"0.6580712",
"0.65693444",
"0.6496045",
"0.64715344",
"0.6298699",
"0.6289323",
"0.62853897",
"0.62313634",
"0.6216485... | 0.8152278 | 0 |
Print the mouse position relative to each corner. Use to get hardcodable positions. | def print_mouse_positions() -> None:
mouse_pos = ctrl.mouse_pos()
print(f"Absolute mouse pos: {mouse_pos}")
screen = ui.main_screen().rect
print(f"Main screen: {screen}")
for corner in [
Corner.TOP_LEFT,
Corner.TOP_RIGHT,
Corner.BOTTOM_L... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_mouse_position(x_pos=0, y_pos=0):\n print('x-axis:', x_pos, ' Y-axis: ', y_pos, flush=True)",
"def mousePositionRaw(self):",
"def mousePositionRaw(self):",
"def mousePosition(self):",
"def print_mouse_event(self, event, what):\n print('%s - pos: %r, button: %s, delta: %r' %\n ... | [
"0.7387262",
"0.69946706",
"0.69946706",
"0.68717116",
"0.67130166",
"0.66660905",
"0.66269225",
"0.65681857",
"0.65366256",
"0.63911045",
"0.60892487",
"0.60873604",
"0.60664666",
"0.60659",
"0.60434276",
"0.6039815",
"0.6035616",
"0.6003942",
"0.5998977",
"0.5984918",
"0.59... | 0.81904465 | 0 |
Make an image of differences between the first and second clip using ImageMagick. Will raise an exception if more than 2 clips are passed to the constructor. | def magick_compare(self) -> None:
# Make diff images
if len(self.clips) > 2:
Status.fail(f'{self.__class__.__name__}: "magick_compare" can only be used with two clips!', exception=ValueError)
self.path_diff = self.path / 'diffs'
try:
subprocess.call(['magick', 'c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli(fig1, fig2, out):\n click.echo('\\n' + '.' * 50)\n\n # open first image\n image1 = Image.open(fig1)\n\n # open second image\n image2 = Image.open(fig2)\n\n # retrieve the image dimensions.\n width, height = image1.size\n width2, height2 = image2.size\n\n if [width, height] != [wi... | [
"0.624791",
"0.57677054",
"0.5656094",
"0.5443441",
"0.5401006",
"0.5328892",
"0.52844095",
"0.52791625",
"0.52341545",
"0.5206452",
"0.51734555",
"0.51449054",
"0.511724",
"0.51007843",
"0.50973564",
"0.5077471",
"0.5071751",
"0.5052234",
"0.5048019",
"0.5021675",
"0.4992363... | 0.62435144 | 1 |
Upload to slow.pics with given configuration | def upload_to_slowpics(self, config: SlowPicsConf = default_conf) -> None:
# Upload to slow.pics
all_images = [sorted((self.path / name).glob('*.png')) for name in self.clips.keys()]
if self.path_diff:
all_images.append(sorted(self.path_diff.glob('*.png'))) # type: ignore
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_snaphot(self, url, filename):\n\n req_for_image = requests.get(url)\n IMAGE_FILE = BytesIO(req_for_image.content)\n\n img = Image.open(IMAGE_FILE)\n # here, we create an empty string buffer\n buffer = BytesIO()\n img.save(buffer, \"JPEG\", quality=60)\n b... | [
"0.6390859",
"0.61168593",
"0.607823",
"0.59952694",
"0.59203124",
"0.5899646",
"0.5867831",
"0.5843152",
"0.580407",
"0.57941586",
"0.5784766",
"0.57775533",
"0.56902266",
"0.56626356",
"0.56574404",
"0.5635237",
"0.5611183",
"0.557807",
"0.5567737",
"0.55670696",
"0.5551331... | 0.8017105 | 0 |
Convenience method to create a user manually. | def create_user(self):
User.objects.create_user('test', 'testing@test.com', 'testing') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user(self):\n return User.objects.create_user(**self.user_data)",
"def create_user(self, **kwargs):\n kwargs = self._prepare_create_user_args(**kwargs)\n user = self.user_model(**kwargs)\n # noinspection PyUnresolvedReferences\n return self.save(user)",
"def create... | [
"0.84284955",
"0.8256174",
"0.81976753",
"0.8048271",
"0.7933476",
"0.7924386",
"0.79241693",
"0.79064405",
"0.7898101",
"0.78852206",
"0.7818084",
"0.7807617",
"0.77973396",
"0.7777655",
"0.7771802",
"0.77607566",
"0.775554",
"0.7746862",
"0.77113354",
"0.7707604",
"0.769603... | 0.8268673 | 1 |
Convenience method that returns the value returned from posting /api/register with test user data | def post_user(self):
return self.client.post('/api/register', {'username': 'test', 'password': 'testing'}, format='json') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_user(self):\n response = self.client.post(self.register_url, self.register_data, format='json')\n return response",
"def test_register(self):\n # Register good data\n data = mock_data['register']\n data = json.dumps(data)\n response = self.client.post(\n ... | [
"0.79784954",
"0.76484907",
"0.7586805",
"0.75265926",
"0.751983",
"0.7486969",
"0.74536526",
"0.7415454",
"0.73605394",
"0.73265904",
"0.73183036",
"0.7305393",
"0.727419",
"0.7264769",
"0.7246377",
"0.72366166",
"0.72164387",
"0.7209809",
"0.72043324",
"0.7199858",
"0.71688... | 0.8221954 | 0 |
Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for noncookie uses. To decode a value not stored as a cookie use the optional value argument to get_secure_cookie. | def create_signed_value(self, name, value):
timestamp = str(int(time.time()))
value = base64.b64encode(value)
signature = self._cookie_signature(name, value, timestamp)
value = "|".join([value, timestamp, signature])
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_secure_cookie( name, value=None ):",
"def set_secure_cookie( name, value, **kwargs ):",
"def decode_signed_value( name, value ):",
"def create_signed_value( name, value ):",
"def sign(self, value: str, timestamp: int = None) -> str:\n timestamp = timestamp or int(time.time())\n return... | [
"0.6637055",
"0.6335417",
"0.6251725",
"0.6224434",
"0.6218173",
"0.61984545",
"0.59713936",
"0.57362914",
"0.57362914",
"0.57362914",
"0.57331383",
"0.57247233",
"0.57106113",
"0.5667315",
"0.5567969",
"0.55134684",
"0.550191",
"0.5480218",
"0.53795123",
"0.53457123",
"0.533... | 0.6966465 | 0 |
if one client sends the correct answer, that will close the current question and send both of them a wait delay. If the second client ignores that and sends a timed_out that should then be ignored in favor of the new question | def test_timed_out_after_correct_answer(self):
(user, client), (user2, client2) = self._create_two_connected_clients()
battle = client.current_client_battles[str(user._id)]
battle.rules['no_questions'] = 2
self._create_question()
self._create_question()
battle.min_wait_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_timed_out_after_wrong_answer(self):\n (user, client), (user2, client2) = self._create_two_connected_clients()\n battle = client.current_client_battles[str(user._id)]\n battle.rules['no_questions'] = 3\n self._create_question()\n self._create_question()\n self._cre... | [
"0.7495978",
"0.6053929",
"0.5879573",
"0.57639295",
"0.574705",
"0.5609191",
"0.5534354",
"0.55327255",
"0.5498602",
"0.54945",
"0.54879904",
"0.5482634",
"0.5468472",
"0.5459262",
"0.544764",
"0.5429914",
"0.5415597",
"0.53722477",
"0.5348782",
"0.53448504",
"0.5331468",
... | 0.7941565 | 0 |
if one client sends the correct answer, that will close the current question and send both of them a wait delay. If the second client ignores that and sends a timed_out that should then be ignored in favor of the new question | def test_timed_out_after_wrong_answer(self):
(user, client), (user2, client2) = self._create_two_connected_clients()
battle = client.current_client_battles[str(user._id)]
battle.rules['no_questions'] = 3
self._create_question()
self._create_question()
self._create_questio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_timed_out_after_correct_answer(self):\n (user, client), (user2, client2) = self._create_two_connected_clients()\n battle = client.current_client_battles[str(user._id)]\n battle.rules['no_questions'] = 2\n self._create_question()\n self._create_question()\n\n battl... | [
"0.7941759",
"0.60539633",
"0.5878274",
"0.57633615",
"0.5746768",
"0.5607931",
"0.5534128",
"0.55330086",
"0.54986674",
"0.54959106",
"0.5488982",
"0.54822683",
"0.5467383",
"0.54589397",
"0.5447852",
"0.5429059",
"0.5414662",
"0.5373624",
"0.53498834",
"0.53451174",
"0.5332... | 0.7496497 | 1 |
Returns all possible substrings from string | def __get_all_possible_substrings(base_string):
substrings = []
for n in range(1, len(base_string) + 1):
for i in range(len(base_string) - n + 1):
substrings.append(base_string[i:i + n])
return substrings | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subs(input_string):\n length = len(input_string)\n return [input_string[i:j+1] for i in xrange(length) for j in xrange(i,length)]",
"def get_substrings(string, n):\n substrings = set()\n\n for i in range(len(string) - n + 1):\n substrings.add(string[i:i+n])\n\n return [substring for sub... | [
"0.7558087",
"0.7136203",
"0.68534404",
"0.6638399",
"0.65625757",
"0.65106237",
"0.6446263",
"0.6429863",
"0.641203",
"0.6372371",
"0.62816674",
"0.62804395",
"0.6205983",
"0.61538947",
"0.6139199",
"0.60962164",
"0.6095457",
"0.60795236",
"0.6059808",
"0.60547954",
"0.60365... | 0.853459 | 0 |
Returns all candidates sorted by leftovers_count parameter | def __get_candidates_best_by_leftovers_count(substrings, base_string):
candidates = []
for element in substrings:
elements_count = base_string.count(element)
leftovers_count = len(base_string.replace(element, ""))
candidates.append([element, elements_count, leftovers_count])
candidat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_candidates_best_by_elements_count(substrings):\n candidates = []\n best_leftover = substrings[0][2]\n for element in substrings:\n if element[2] == best_leftover:\n candidates.append(element)\n candidates.sort(reverse=True, key=lambda x: x[1])\n return candidates",
"def... | [
"0.6552511",
"0.63088584",
"0.59395087",
"0.58303636",
"0.57138914",
"0.5692777",
"0.56461126",
"0.5624564",
"0.5565643",
"0.5555702",
"0.5529659",
"0.5528722",
"0.55041605",
"0.5468694",
"0.54568607",
"0.54567075",
"0.5369894",
"0.5364155",
"0.5324101",
"0.5313352",
"0.53036... | 0.6589607 | 0 |
Returns all candidates sorted by substring_count parameter | def __get_candidates_best_by_elements_count(substrings):
candidates = []
best_leftover = substrings[0][2]
for element in substrings:
if element[2] == best_leftover:
candidates.append(element)
candidates.sort(reverse=True, key=lambda x: x[1])
return candidates | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_candidates_best_by_leftovers_count(substrings, base_string):\n candidates = []\n for element in substrings:\n elements_count = base_string.count(element)\n leftovers_count = len(base_string.replace(element, \"\"))\n candidates.append([element, elements_count, leftovers_count])\... | [
"0.7601704",
"0.57925",
"0.5785811",
"0.57252425",
"0.56875575",
"0.5674585",
"0.5650752",
"0.56438947",
"0.55514383",
"0.55237985",
"0.55229783",
"0.5514106",
"0.5510217",
"0.55069023",
"0.55041426",
"0.54983985",
"0.54959655",
"0.5426884",
"0.5422324",
"0.5410447",
"0.53935... | 0.743758 | 1 |
Get mapping dict of service types | def get_service_mapping():
# Get all Service types:
all_service_type = requests.get(base_url + 'services/v2/service_types', headers=headers3).json()
# Make Dict of service names and ids
service_name_to_id = {service_type['attributes']['name']:service_type['id'] for service_type in all_service_type['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_type_mapping():\n return {\n Box.SPACE_NAME: Box,\n Dict.SPACE_NAME: Dict,\n Discrete.SPACE_NAME: Discrete\n }",
"def list_services(self):\n service_types = list(self.services.keys())\n service_types.sort()\n\n services = {}\n fo... | [
"0.7148652",
"0.69539016",
"0.677271",
"0.65662247",
"0.63725734",
"0.62752503",
"0.626193",
"0.623429",
"0.62054604",
"0.61644703",
"0.61461675",
"0.6043616",
"0.60345",
"0.6029466",
"0.6017146",
"0.5986938",
"0.5957674",
"0.59273297",
"0.59249467",
"0.5899342",
"0.5892947",... | 0.7781699 | 0 |
Get mapping dict of events | def get_event_mapping():
# Get all events:
all_events = requests.get(base_url + 'check-ins/v2/events', headers=headers3).json()
# Make Dict of event names and ids
event_to_id = {event['attributes']['name']:event['id'] for event in all_events['data']}
return event_to_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_map(self) -> dict:\n return self._event_map",
"def get_event_actions_mapping(self):\n return None",
"def parse_events(events_dict):\n return events_dict['events']",
"def create_events():\n events = {}\n events[\"Workers_can_proceed\"] = mp.Event()\n for i in range(NUM_WORK... | [
"0.80639976",
"0.6997986",
"0.68349934",
"0.66129386",
"0.6574959",
"0.64685273",
"0.64532745",
"0.64484024",
"0.64381576",
"0.6359469",
"0.63124835",
"0.63021064",
"0.63021064",
"0.62903833",
"0.6268375",
"0.6241141",
"0.6240614",
"0.62224525",
"0.6191082",
"0.6187281",
"0.6... | 0.72078437 | 1 |
Get location id from event id | def get_location_id(event_id, loc_name):
# Get all locations:
all_locations = requests.get(base_url + f'check-ins/v2/events/{event_id}/locations', headers=headers3).json()
# Make Dict of location names and ids
location_to_id = {location['attributes']['name']:location['id'] for location in all_locati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id(self) -> str:\n return self._event.get('id')",
"def get_event_by_id(event_id):\n db = get_db()\n return db.execute((\n 'SELECT id, name, start_time, end_time, location '\n 'FROM event WHERE id=?'),\n (event_id,)).fetchone()",
"def get_location_by_id(self, location_id):"... | [
"0.70892364",
"0.68705934",
"0.68487877",
"0.671715",
"0.66815215",
"0.65408355",
"0.64933246",
"0.64408857",
"0.6257067",
"0.6248813",
"0.62349504",
"0.6233402",
"0.6211422",
"0.6202817",
"0.616206",
"0.61552113",
"0.6094231",
"0.60508996",
"0.5985182",
"0.5935654",
"0.59334... | 0.7565096 | 0 |
Get a future service plan and future service plans times | def get_future_plans(service_id, indx):
# Get service type latest plan and also include plan times
service_plans = requests.get(base_url + f'services/v2/service_types/{service_id}/plans?filter=future&order=sort_date&per_page=1&include=plan_times&offset={indx}', headers=headers3).json()
# Get plan i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plans():",
"def _get_service_plan(self, service_name, service_plan_name):\n self._assert_space()\n key = ' / '.join([service_name, service_plan_name])\n if key in self._service_plan:\n return self._service_plan[key]\n self._get_service(service_name)\n service_pla... | [
"0.61407393",
"0.6079679",
"0.58951896",
"0.5810577",
"0.57075036",
"0.5627977",
"0.5582494",
"0.54750943",
"0.54399997",
"0.53883713",
"0.5374862",
"0.53398436",
"0.5339664",
"0.5310947",
"0.52710015",
"0.5268247",
"0.5259629",
"0.5187249",
"0.5183262",
"0.5164232",
"0.51580... | 0.70387816 | 0 |
The length of a generated token | def token_length(self):
return 32 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(self):\n return len(self.tokens)",
"def Length(self) -> int:",
"def Length(self) -> int:",
"def __len__(self):\n return len(self._tokens)",
"def parse_len_token(self, token, context):\n match = Ftype_character.len_token_re.match(token)\n if match is not None:\n ... | [
"0.8090891",
"0.72398555",
"0.72398555",
"0.72175467",
"0.7071612",
"0.69847536",
"0.6974451",
"0.6898202",
"0.68943214",
"0.68943214",
"0.689186",
"0.68851024",
"0.6876461",
"0.68388605",
"0.6801382",
"0.67994404",
"0.6776136",
"0.6754608",
"0.6752794",
"0.6728152",
"0.67083... | 0.8225514 | 0 |
The type of access token we are using | def token_type(self):
return 'Bearer' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_type(self) -> str:\n return self._token_type",
"def token_type(self) -> str:\n return self._token_type",
"def get_auth_token(self, request: Request, type=\"Bearer\") -> str:\n if \"Authorization\" not in request.headers:\n raise AuthenticationRequiredException\n ... | [
"0.72079873",
"0.72079873",
"0.71791047",
"0.70688397",
"0.7021812",
"0.69597125",
"0.6859751",
"0.6741833",
"0.6722053",
"0.6722053",
"0.6722053",
"0.6722053",
"0.6722053",
"0.6722053",
"0.6722053",
"0.6722053",
"0.6716401",
"0.6669683",
"0.6669683",
"0.6669683",
"0.6669683"... | 0.7798354 | 0 |
How long until the access token expires defaults to 1 hour | def token_expires_in(self):
return 60 * 60 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_token(self):\n now = timezone.now()\n limit = now - timedelta(days=20)\n # TODO: use expires_in from response data?\n print(self.token_refresh_date)\n print(limit)\n if self.token_refresh_date < limit:\n url = '{}refresh_access_token'.format(conf.INS... | [
"0.7069979",
"0.68552774",
"0.6793371",
"0.6770057",
"0.6759449",
"0.6665038",
"0.66025156",
"0.6565258",
"0.6553815",
"0.6531839",
"0.6502029",
"0.6496467",
"0.6471388",
"0.6422638",
"0.64030856",
"0.6399166",
"0.6317765",
"0.6317765",
"0.6289671",
"0.62332964",
"0.6198888",... | 0.82809424 | 0 |
Generate a random authorization code. | def generate_authorization_code(self):
return gen_api_key(length=self.token_length) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_code(self):\n code = ''.join(\n random.choices(string.ascii_lowercase + string.digits, k=5))\n self.code = '{}{}'.format(self.user.id, code)",
"def create_secret_code():\n characters = string.ascii_uppercase + string.digits\n size = 6\n return ''.join(random.choice(... | [
"0.75588864",
"0.74285436",
"0.74177575",
"0.7316583",
"0.7104523",
"0.71042585",
"0.70178926",
"0.69639707",
"0.6927824",
"0.67356384",
"0.6693077",
"0.6623431",
"0.6611711",
"0.65914744",
"0.65532476",
"0.6545281",
"0.6539805",
"0.6536347",
"0.6520258",
"0.6507461",
"0.6504... | 0.7840646 | 0 |
Generate a random access token. | def generate_access_token(self):
return gen_api_key(length=self.token_length) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_new_token(self):\n self.access_token = random_auth_key()",
"def generate_token():\n chars = ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')\n rand = random.SystemRandom()\n random_string = ''.join(rand.choice(chars) for _ in range(40))\n return hmac.new(\n ... | [
"0.82569",
"0.745192",
"0.7336344",
"0.7269252",
"0.72377497",
"0.71828794",
"0.6926926",
"0.6832841",
"0.68226",
"0.681461",
"0.68085945",
"0.6764717",
"0.6703978",
"0.6695814",
"0.66630363",
"0.66609293",
"0.66137046",
"0.6607952",
"0.65929705",
"0.65886843",
"0.6582464",
... | 0.80414665 | 1 |
Generate a random refresh token. | def generate_refresh_token(self):
return gen_api_key(length=self.token_length) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_new_token(self):\n self.access_token = random_auth_key()",
"def refresh_token():\n json_request = request.json\n refresh_token = json_request.get('refresh_token')\n if not refresh_token:\n return msg.errors.bad_request(\n 'You should provide refresh token for this c... | [
"0.76322883",
"0.74220634",
"0.7369915",
"0.7336193",
"0.72870505",
"0.72259885",
"0.7058188",
"0.705621",
"0.70044553",
"0.6850953",
"0.6800217",
"0.6707107",
"0.6685085",
"0.66625905",
"0.6657137",
"0.6596008",
"0.65536267",
"0.654388",
"0.65340185",
"0.6531621",
"0.6472953... | 0.828994 | 0 |
Verifies the authorization request and returns an auth code if requested | def verify_auth_request(self, *args, **kwargs):
if len(args) == 1:
url = args[0]
qs = get_query_string(url)
response_type = qs.pop('response_type', None)
client_id = qs.pop('client_id', None)
redirect_uri = qs.pop('redirect_uri', None)
scop... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_auth_code(self, code):\n raise NotImplementedError(\n \"\"\"\n verify_scope must be implemented by a child class\n \"\"\"\n )",
"def validate_code(request):\n user_id = api.keystone.get_user_id(request)\n print \"USER CHECK\"\n print user_id\... | [
"0.6792753",
"0.67879415",
"0.6754928",
"0.66999227",
"0.664164",
"0.6627876",
"0.6587151",
"0.6568782",
"0.6545388",
"0.6545202",
"0.65152884",
"0.6478774",
"0.64485216",
"0.6409453",
"0.6403518",
"0.63865304",
"0.6366206",
"0.63432086",
"0.63319945",
"0.63268024",
"0.630369... | 0.69689685 | 0 |
This persists the authorization code to a datastore for checking against on the next request | def save_auth_code(self, client_id, code, scope, redirect_uri):
raise NotImplementedError(
"""
save_auth_code must be implemented by a child class
"""
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_authorization_code(self, client_id, code, request, *args, **kwargs):\n log.debug('Persist authorization code %r for client %r', code, client_id)\n request.client = request.client or self._clientgetter(client_id)\n self._grantsetter(client_id, code, request, *args, **kwargs)\n r... | [
"0.685759",
"0.5918923",
"0.5841991",
"0.5800864",
"0.577557",
"0.5707651",
"0.56489456",
"0.55262905",
"0.5508438",
"0.5504208",
"0.5499275",
"0.5497645",
"0.5494326",
"0.5481592",
"0.5458928",
"0.54573834",
"0.53886586",
"0.53853977",
"0.53600675",
"0.5358889",
"0.5333976",... | 0.65713686 | 1 |
This validates that the auth_code is legitimate and attached to an active user Should return True or False | def verify_auth_code(self, code):
raise NotImplementedError(
"""
verify_scope must be implemented by a child class
"""
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_code(request):\n user_id = api.keystone.get_user_id(request)\n print \"USER CHECK\"\n print user_id\n user = api.keystone.user_get(request, user_id)\n user_auth_code = request.GET.get('auth_code', None)\n secret = request.GET.get('secret', None)\n\n #Generate ... | [
"0.6985009",
"0.66595393",
"0.6610769",
"0.6547535",
"0.6466121",
"0.64294356",
"0.6392488",
"0.6385686",
"0.62999517",
"0.61672914",
"0.61525494",
"0.6117841",
"0.6110402",
"0.6084039",
"0.6073808",
"0.6050932",
"0.60406595",
"0.6035373",
"0.60296535",
"0.5996132",
"0.598898... | 0.707134 | 0 |
This validates that the redirect_uri provided is registered to the client in your datastore Should return True or False | def verify_redirect_uri(self, client_id, redirect_uri):
raise NotImplementedError(
"""
verify_redirect_uri must be implemented by a child class
"""
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_redirect_uri(self, client_id, redirect_uri, request, *args, **kwargs):\n request.client = request.client or self._clientgetter(client_id)\n client = request.client\n if hasattr(client, 'validate_redirect_uri'):\n return client.validate_redirect_uri(redirect_uri)\n ... | [
"0.80277336",
"0.7236486",
"0.71824515",
"0.68947905",
"0.6661132",
"0.6546087",
"0.6481456",
"0.6375012",
"0.629049",
"0.62775546",
"0.61968976",
"0.6091642",
"0.59686536",
"0.59132814",
"0.5844726",
"0.5840806",
"0.58395845",
"0.58297205",
"0.57988995",
"0.57804567",
"0.572... | 0.7555295 | 1 |
The tags associated with the Message. Could be None. | def tags(self) -> Optional[dict]:
return self._tags | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags(self) -> Optional[Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Optional[Sequence[str]]:\n return pulumi.get(self, \"tags\")",
"def tags(self):\n return self.get(\"tags\")",
"def tags(self) -> dict:\n\n return self._tags or None # store trivial tags as e... | [
"0.7801532",
"0.7703974",
"0.7688504",
"0.7630333",
"0.7615479",
"0.7615479",
"0.7615479",
"0.7615479",
"0.7615479",
"0.7615479",
"0.7615479",
"0.7615479",
"0.75930405",
"0.75923294",
"0.75471735",
"0.74428624",
"0.74302846",
"0.7429466",
"0.7429466",
"0.7425446",
"0.7413681"... | 0.7742009 | 1 |
|coro| Method which retrieves stream information on the channel, provided it is active (Live). Returns | async def get_stream(self) -> dict:
data = await self._http.get_streams(channels=[self.name])
try:
return data[0]
except IndexError:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_stream(self) -> dict:\n return await self.channel.get_stream()",
"def stream(self):\n\t\tdata = self._client.get(\"streams\", self.name)['stream']\n\t\tif data is not None:\n\t\t\tdata.pop('channel', None)\n\t\treturn data",
"def get_stream(self, channel_name):\n self.stream = json.... | [
"0.8051792",
"0.7381777",
"0.665298",
"0.6583245",
"0.6575644",
"0.63711935",
"0.63618785",
"0.626605",
"0.62416095",
"0.6187988",
"0.6113333",
"0.60948426",
"0.6018285",
"0.5974652",
"0.59557825",
"0.5927819",
"0.5906061",
"0.58414173",
"0.5837924",
"0.5830262",
"0.5758679",... | 0.77008027 | 1 |
A boolean indicating whether the User is Turbo. Could be None if no Tags were received. | def is_turbo(self) -> bool:
return self.turbo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_television(self) -> bool:\n if self.client_name() in ('Kylo', 'Espial TV Browser'):\n return True\n return TV_FRAGMENT.search(self.user_agent) is not None",
"def is_bot(self) -> undefined.UndefinedOr[bool]:",
"def has_tags(self):\n return bool(self.tags)",
"def is_tenta... | [
"0.5975257",
"0.5843303",
"0.5841019",
"0.5770941",
"0.5770941",
"0.5764691",
"0.57447207",
"0.57420564",
"0.5726559",
"0.5702824",
"0.56921756",
"0.56321627",
"0.55923325",
"0.5584644",
"0.55655676",
"0.55470127",
"0.5535996",
"0.5490517",
"0.54521006",
"0.53535885",
"0.5321... | 0.6886303 | 0 |
A boolean indicating whether the User is a subscriber of the current channel. Could be None if no Tags were received. | def is_subscriber(self) -> bool:
return self.subscriber | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_subscriber(self):\n if self.user is None:\n return False\n if unicode(self.user._id) in self.barcamp.subscribers:\n return True\n return False",
"def is_subscriber(self):\n try:\n return self.get_subscription().get('@type') != 'free'\n ex... | [
"0.7942302",
"0.7375643",
"0.7002319",
"0.689127",
"0.6655376",
"0.66528237",
"0.6612391",
"0.62456584",
"0.6236883",
"0.6226055",
"0.6186541",
"0.6153759",
"0.60777044",
"0.6073368",
"0.60588056",
"0.6031138",
"0.59170586",
"0.58796746",
"0.57811135",
"0.5758006",
"0.5751468... | 0.77070755 | 1 |
The badges associated with the User. Could be an empty Dict if no Tags were received. | def badges(self) -> dict:
return self._badges | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRobloxBadges(userId):\n url = f\"https://accountinformation.roblox.com/v1/users/{userId}/roblox-badges\"\n r = requests.get(url)\n j = json.loads(r.text)\n return j",
"def get(self) -> Iterable[Union[Mapping, int, None]]:\n badges = self.client.get_badges()\n retu... | [
"0.6866523",
"0.65146655",
"0.63965136",
"0.62054354",
"0.58355975",
"0.58312416",
"0.5766076",
"0.5588374",
"0.5582012",
"0.54887116",
"0.5471924",
"0.54631025",
"0.541698",
"0.5362237",
"0.5343415",
"0.5336226",
"0.5312547",
"0.5305591",
"0.5285464",
"0.52728367",
"0.526344... | 0.7892412 | 0 |
|coro| Method which retrieves stream information on the channel stored in Context, provided it is active (Live Returns dict Dict containing active streamer data. Could be None if the stream is not live. Raises HTTPException Bad request while fetching streams. | async def get_stream(self) -> dict:
return await self.channel.get_stream() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_stream(self) -> dict:\n\n data = await self._http.get_streams(channels=[self.name])\n\n try:\n return data[0]\n except IndexError:\n pass",
"def stream(self):\n\t\tdata = self._client.get(\"streams\", self.name)['stream']\n\t\tif data is not None:\n\t\t\td... | [
"0.75702065",
"0.67921305",
"0.6257685",
"0.62386304",
"0.6161859",
"0.61304474",
"0.609498",
"0.6094159",
"0.60804814",
"0.5905744",
"0.5871197",
"0.5746808",
"0.5739209",
"0.57316095",
"0.5689709",
"0.5653746",
"0.5613071",
"0.5573039",
"0.55681455",
"0.5562832",
"0.5516599... | 0.7385613 | 1 |
Sets up the standard island map. | def setup_maps(self):
super().setup_maps()
sprite_classes = {
"Obstacles": Wall,
"Background": QuestSprite,
}
self.add_map(TiledMap(resolve_resource_path("images/island/island.tmx"), sprite_classes)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_maps(self):\n super().setup_maps()\n sprite_classes = {\n \"walls\": Wall,\n \"play\": Background,\n \"exit\": Background,\n }\n island_map = TiledMap((\"images/qwerty_game_1.tmx\"), sprite_classes)\n self.add_map(island_map)",
"def __... | [
"0.7265102",
"0.69269395",
"0.6895909",
"0.6665102",
"0.6394695",
"0.6318594",
"0.6241702",
"0.61914027",
"0.6168343",
"0.6157474",
"0.6133331",
"0.61102325",
"0.60776055",
"0.59733725",
"0.59733725",
"0.5957042",
"0.5941652",
"0.594105",
"0.59341586",
"0.59300625",
"0.590345... | 0.72836506 | 0 |
As in other examples, assigns all sprites in the "Obstacles" layer to be walls. | def setup_walls(self):
self.wall_list = self.get_current_map().get_layer_by_name("Obstacles").sprite_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_walls(self):\n self.wall_list = self.get_current_map().get_layer_by_name(\"walls\").sprite_list",
"def add_walls(self):\n for x in range(self.width):\n self.add_thing(Wall(), (x, 0))\n self.add_thing(Wall(), (x, self.height - 1))\n\n for y in range(self.height... | [
"0.7613916",
"0.67729795",
"0.6738331",
"0.63915414",
"0.626012",
"0.6249966",
"0.62025875",
"0.6169142",
"0.61558133",
"0.61539805",
"0.60857564",
"0.6060428",
"0.60447943",
"0.60199165",
"0.6016821",
"0.6001422",
"0.59767026",
"0.5943057",
"0.59379256",
"0.5924689",
"0.5811... | 0.81163895 | 0 |
wraps a string within single qoute. Mostly needed for insert into database | def wrap_with_in_single_quote(s):
return "'{}'".format(s) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qstring(self, s):\n\n if '\"' in s or ' ' in s or '\\\\' in s:\n return '\"' + s.replace('\\\\', '\\\\\\\\').replace('\"', '\\\\\"') + '\"'\n else:\n return s",
"def quote(s):\n if isinstance(s, str):\n if \" \" in s or len(s.split()) > 1:\n start, end... | [
"0.7357636",
"0.70734096",
"0.6990583",
"0.69030076",
"0.67781955",
"0.66734624",
"0.6578122",
"0.6562084",
"0.65618634",
"0.65006495",
"0.6492088",
"0.6490486",
"0.64646506",
"0.64400494",
"0.64112735",
"0.6396136",
"0.6389765",
"0.638212",
"0.6373073",
"0.6366212",
"0.63542... | 0.7279222 | 1 |
returns md5 hashed password | def get_hashed_value(password):
salt = 'saifulBoss'
password = salt + password
return md5(password.encode('utf-8')).hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_password(password):\n return hashlib.md5(password).hexdigest()",
"def _create_md5(self, password) -> str:\n md5_hash = hashlib.md5(password.encode(\"utf-8\")).hexdigest()\n self.logger.debug(\"created md5 hash: %s\", md5_hash)\n\n return md5_hash",
"def to_hash(password):\n ... | [
"0.85117745",
"0.8031083",
"0.7865687",
"0.7858549",
"0.78492856",
"0.77523303",
"0.7710148",
"0.75820285",
"0.7581162",
"0.750511",
"0.74373454",
"0.7422173",
"0.7403926",
"0.7369566",
"0.7347021",
"0.7316815",
"0.7263541",
"0.7245339",
"0.7239279",
"0.7191727",
"0.71888846"... | 0.80907196 | 1 |
Delete the `n`th element from the supplied list `l` and return the resulting list. | def pop_and_return(l, n):
o = l.copy()
if (n >= len(l)) or (n < 0):
raise ValueError("Index n = %d out of range" % (n))
if len(l) == 0:
raise ValueError("The supplied list must contain at least one element.")
del o[n]
return o | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop(lst, n): # noqa: N805\n for _ in range(n):\n try:\n lst = lst.tail\n except AttributeError:\n break\n return lst",
"def del_from_list(l, elements, count=0):\n return _remove_elements_from_list(l, elements, None, count)",
"def drop(i... | [
"0.76152366",
"0.68506825",
"0.68460673",
"0.6674738",
"0.6519919",
"0.6411165",
"0.6317477",
"0.6257754",
"0.6228628",
"0.61837226",
"0.6085985",
"0.6027428",
"0.60008734",
"0.59967196",
"0.5925724",
"0.5918213",
"0.5918213",
"0.59132695",
"0.5902579",
"0.58495694",
"0.58382... | 0.78068995 | 0 |
Override this to do any servicespecific initialization | def initService(self): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_init(self):\n\n pass",
"def init_services(self):\n service_prefix = rospy.get_name() + \"/\"\n\n self._request_components_serv = rospy.Service(service_prefix +\n 'list_components',\n ListComp... | [
"0.7318107",
"0.721846",
"0.70419437",
"0.6983712",
"0.6983712",
"0.6983712",
"0.6966745",
"0.6950469",
"0.69004095",
"0.6882781",
"0.6850522",
"0.6740089",
"0.6729622",
"0.6729622",
"0.6729622",
"0.6729622",
"0.6729622",
"0.6729622",
"0.6729622",
"0.6729622",
"0.6727437",
... | 0.8269538 | 0 |
Returns a task for the given class `name` or type, or None. | def getTask(self, name):
for t in self.tasks:
if isinstance(name, str):
if t.name == name:
return t
else:
if t.__class__ is name:
return t
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_task(self, name):\n res = Task()\n self.GetTask(name, res)\n return res",
"def task_by_type(qs, task_type):\n for task in qs:\n if task.type == task_type:\n return task\n return None",
"def get_task(self, u_name):\n rai... | [
"0.7046765",
"0.7023009",
"0.6943184",
"0.6686502",
"0.66718686",
"0.66415167",
"0.6624116",
"0.65350837",
"0.6532999",
"0.6526461",
"0.64754677",
"0.63859135",
"0.6356256",
"0.6324332",
"0.62372583",
"0.62365824",
"0.61092407",
"0.6106103",
"0.61002696",
"0.6061775",
"0.6025... | 0.8375071 | 0 |
Request a graceful shutdown. Does not block. | def shutdown(self):
self.logger.info("Received graceful shutdown request")
self.stop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def shutdown_gracefully(self) -> None:",
"async def shutdown_gracefully(self) -> None:",
"def request_shutdown(self, restart=False):",
"def request_shutdown(self, kernel_id, restart=False):",
"def shutdown(self):\n self.req_shutdown = True",
"def shutdown(self):\n self.shutdown_reques... | [
"0.7409461",
"0.7409461",
"0.7391829",
"0.71747464",
"0.70665526",
"0.6845416",
"0.6801792",
"0.6633282",
"0.65604484",
"0.6521576",
"0.65183425",
"0.6464831",
"0.6464831",
"0.64030904",
"0.636419",
"0.6333115",
"0.6330935",
"0.63081044",
"0.63011456",
"0.62946767",
"0.625604... | 0.7560451 | 0 |
Request a graceful restart. Does not block. | def restart(self):
self.logger.info("Received graceful restart request")
self._restart = True
self.stop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def do_force_restart(self):\n if self.config[\"allow_restart_requests\"]:\n os._exit(42)\n else:\n return self._rpc_failure(\"Restart disallowed by configuration\")",
"def attempt_restart(self):\n self.controller.publish(self, 'restart')",
"def restart(self):\n ... | [
"0.7772912",
"0.7263124",
"0.7245009",
"0.71927315",
"0.719068",
"0.7186406",
"0.7109044",
"0.7063854",
"0.6949366",
"0.69067913",
"0.6904618",
"0.6888579",
"0.6879974",
"0.68628997",
"0.6830718",
"0.682366",
"0.6802731",
"0.6802731",
"0.6781907",
"0.67575556",
"0.6754284",
... | 0.8317874 | 0 |
Count clip of a gram | def count_clip(gram, grams, reference):
clip = 0
n = len(gram.split(' '))
count_wi = 0
for g in grams:
if gram == g:
count_wi += 1
# print('count_wi:', count_wi)
for ref in reference:
ref_list = ref.split(' ')
count_ref = 0
for i in range(len(ref_list)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count():",
"def cal_pn(grams_set, grams, candidate, reference):\n count = 0\n for gram in grams_set:\n # print(gram)\n count += count_clip(gram, grams, reference)\n # calculate log() for p, so '+10**-8' avoid 'p==0'\n p = count / len(grams) + 10**-8 \n return p",
"def clippingc... | [
"0.6071192",
"0.59242237",
"0.5802611",
"0.57847875",
"0.5759973",
"0.5750524",
"0.572034",
"0.5685732",
"0.56412256",
"0.5637095",
"0.5602329",
"0.5563017",
"0.55156827",
"0.54847884",
"0.5453589",
"0.5435633",
"0.5429448",
"0.54287434",
"0.5422308",
"0.54129076",
"0.5397255... | 0.76374227 | 0 |
tests that passing in a kwarg to the update method that isn't a column will fail | def test_invalid_update_kwarg(self):
with self.assertRaises(ValidationError):
TestQueryUpdateModel.objects(partition=uuid4(), cluster=3).update(bacon=5000) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_update_kwarg(self):\r\n with self.assertRaises(ValidationError):\r\n TestQueryUpdateModel.objects(partition=uuid4(), cluster=3).update(bacon=5000)",
"def test_invalid_update_kwarg(self):\n m0 = TestUpdateModel.create(count=5, text='monkey')\n with self.assertRaise... | [
"0.7227087",
"0.7104254",
"0.7074279",
"0.6329433",
"0.62189066",
"0.61630607",
"0.6159414",
"0.6145743",
"0.6094437",
"0.60466427",
"0.59687847",
"0.59339607",
"0.5895221",
"0.58757293",
"0.5865568",
"0.5816516",
"0.57398236",
"0.5725852",
"0.5719",
"0.5708378",
"0.57044303"... | 0.72344637 | 0 |
setting a field to null in the update should issue a delete statement | def test_null_update_deletes_column(self):
partition = uuid4()
for i in range(5):
TestQueryUpdateModel.create(partition=partition, cluster=i, count=i, text=str(i))
# sanity check
for i, row in enumerate(TestQueryUpdateModel.objects(partition=partition)):
self.ass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_null_update_deletes_column(self):\r\n partition = uuid4()\r\n for i in range(5):\r\n TestQueryUpdateModel.create(partition=partition, cluster=i, count=i, text=str(i))\r\n\r\n # sanity check\r\n for i, row in enumerate(TestQueryUpdateModel.objects(partition=partition)... | [
"0.6961704",
"0.67482066",
"0.65010685",
"0.61259604",
"0.5992511",
"0.5938201",
"0.5856239",
"0.5753922",
"0.57415175",
"0.5727646",
"0.5726502",
"0.57241607",
"0.57241607",
"0.5721469",
"0.57177246",
"0.57076424",
"0.57003665",
"0.56877303",
"0.56858563",
"0.56692576",
"0.5... | 0.7050896 | 0 |
The CQL behavior is if you set a key in a map to null it deletes that key from the map. Test that this works with __update. | def test_map_update_none_deletes_key(self):
partition = uuid4()
cluster = 1
TestQueryUpdateModel.objects.create(
partition=partition, cluster=cluster,
text_map={"foo": '1', "bar": '2'})
TestQueryUpdateModel.objects(
partition=partition, clu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_map_update_none_deletes_key(self):\r\n # partition = uuid4()\r\n # cluster = 1\r\n # TestQueryUpdateModel.objects.create(\r\n # partition=partition, cluster=cluster,\r\n # text_map={\"foo\": '1', \"bar\": '2'})\r\n # TestQueryUpdateModel.objects(\r... | [
"0.7591701",
"0.64201266",
"0.6304367",
"0.6299304",
"0.6194888",
"0.6107784",
"0.6074144",
"0.59651446",
"0.59280145",
"0.5914961",
"0.58507895",
"0.58324605",
"0.58044624",
"0.57662004",
"0.5711495",
"0.5688181",
"0.5680886",
"0.56762064",
"0.56690216",
"0.56450295",
"0.563... | 0.7424211 | 1 |
Test that map item removal with update(__remove=...) works PYTHON688 | def test_map_update_remove(self):
partition = uuid4()
cluster = 1
TestQueryUpdateModel.objects.create(
partition=partition,
cluster=cluster,
text_map={"foo": '1', "bar": '2'}
)
TestQueryUpdateModel.objects(partition=partition, cluster=cluster).... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_map_remove_rejects_non_sets(self):\n partition = uuid4()\n cluster = 1\n TestQueryUpdateModel.objects.create(\n partition=partition,\n cluster=cluster,\n text_map={\"foo\": '1', \"bar\": '2'}\n )\n with self.assertRaises(ValidationError):... | [
"0.71496063",
"0.6998314",
"0.6717322",
"0.6676355",
"0.6534673",
"0.6512091",
"0.645768",
"0.64257306",
"0.64203507",
"0.6369451",
"0.6358273",
"0.6289909",
"0.62580013",
"0.6257078",
"0.6239999",
"0.62256265",
"0.6181995",
"0.61457175",
"0.6121318",
"0.61211246",
"0.6121124... | 0.7701655 | 0 |
Map item removal requires a set to match the CQL API PYTHON688 | def test_map_remove_rejects_non_sets(self):
partition = uuid4()
cluster = 1
TestQueryUpdateModel.objects.create(
partition=partition,
cluster=cluster,
text_map={"foo": '1', "bar": '2'}
)
with self.assertRaises(ValidationError):
Test... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, item):\n try:\n entry = self.set.pop(item)\n entry[-1] = self.REMOVED\n except KeyError:\n print(\"Can't remove a non-existing item\")",
"def _remove_copyset(mapping: MutableMapping[T, CopySet['Entity']], key: T, ent: 'Entity') -> None:\n copyset... | [
"0.66514295",
"0.6571657",
"0.6545378",
"0.6522333",
"0.65185094",
"0.6443647",
"0.6430008",
"0.63862544",
"0.63650626",
"0.63025415",
"0.6232438",
"0.6213155",
"0.6206721",
"0.6181063",
"0.6170815",
"0.61475635",
"0.61284",
"0.611241",
"0.61095846",
"0.6069405",
"0.60679823"... | 0.6858619 | 0 |
Test to ensure that an extra DELETE is not sent if an object is read from the DB with a None value 3.9 PYTHON719 only three queries are executed, the first one for inserting the object, the second one for reading it, and the third one for updating it object_mapper | def test_an_extra_delete_is_not_sent(self):
partition = uuid4()
cluster = 1
TestQueryUpdateModel.objects.create(
partition=partition, cluster=cluster)
obj = TestQueryUpdateModel.objects(
partition=partition, cluster=cluster).first()
self.assertFalse({k:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_edge_case_with_write_concern_0_return_None(self):\n p1 = self.Person(name=\"User Z\", age=20).save()\n del_result = p1.delete(w=0)\n assert del_result is None",
"def test_get(self):\n objects = self.populate()\n for obj in objects:\n found = models.st... | [
"0.6682354",
"0.64057285",
"0.6280417",
"0.6232558",
"0.6079348",
"0.6004791",
"0.60003245",
"0.595957",
"0.59452885",
"0.5933317",
"0.5926694",
"0.5922889",
"0.5921724",
"0.590885",
"0.59038156",
"0.59009415",
"0.5898185",
"0.5885365",
"0.58850574",
"0.58849925",
"0.5869666"... | 0.6737397 | 0 |
Overrides get function then adds a model of type Restaurant to the view whose id = restaurant_id | def get(self, request, pk, *args, **kwargs):
self.restaurant = get_object_or_404(Restaurant, id=pk)
self.page_title = "{} Information".format(self.restaurant.name)
def get_list_or_none(klass, *args, **kwargs):
queryset = _get_queryset(klass)
obj_list = list(queryset.filt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, request, restaurant_id, *args, **kwargs):\n self.restaurant = get_object_or_404(Restaurant, id=restaurant_id)\n return super().get(request, *args, **kwargs)",
"def get_random_restaurant(self, request, **kwargs):\n restaurant = Restaurant.objects.order_by(\n '?'\n ... | [
"0.82593495",
"0.6128801",
"0.5976258",
"0.59254146",
"0.57850933",
"0.577613",
"0.5775901",
"0.57478505",
"0.5729911",
"0.5692035",
"0.56844246",
"0.56034964",
"0.5585453",
"0.5549611",
"0.54296017",
"0.5421414",
"0.5405741",
"0.5395842",
"0.5391386",
"0.5368653",
"0.5354807... | 0.6749007 | 1 |
Overrides get function then adds a model of type Restaurant to the view whose id = restaurant_id | def get(self, request, restaurant_id, *args, **kwargs):
self.restaurant = get_object_or_404(Restaurant, id=restaurant_id)
return super().get(request, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, request, pk, *args, **kwargs):\n self.restaurant = get_object_or_404(Restaurant, id=pk)\n self.page_title = \"{} Information\".format(self.restaurant.name)\n\n def get_list_or_none(klass, *args, **kwargs):\n queryset = _get_queryset(klass)\n obj_list = list(... | [
"0.6746951",
"0.6127299",
"0.59782755",
"0.59246576",
"0.5785238",
"0.5777184",
"0.577502",
"0.5749527",
"0.5731349",
"0.56908524",
"0.5684393",
"0.56052846",
"0.5584952",
"0.5548897",
"0.54310036",
"0.5422598",
"0.54060316",
"0.5397571",
"0.5391655",
"0.53670406",
"0.5354484... | 0.82582694 | 0 |
wget twitter URL and parse out URLs | def get_trend_urls():
trends = []
twitter = 'http://search.twitter.com/'
tmp = 'tmp' + str(random.randint(0,1000))
os.system('wget %s --output-document=%s' % (twitter, tmp))
with open(tmp) as f:
for line in f:
if 'a href' in line and 'search?q' in line:
trends.ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_url():\n urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',\n new_tweet)\n return urls",
"def get_links_from_tweet(tweet):\n if tweet.has_key('entities'):\n if tweet['entities'].has_key('urls'):\n if tweet['entities'][... | [
"0.68655646",
"0.66298056",
"0.62968886",
"0.6094173",
"0.5966897",
"0.58850116",
"0.5880054",
"0.58753675",
"0.58562684",
"0.58468866",
"0.58187366",
"0.581417",
"0.57802767",
"0.57750183",
"0.5772893",
"0.5772719",
"0.5762832",
"0.5744211",
"0.57211214",
"0.571953",
"0.5696... | 0.7178669 | 0 |
Given the object geometry generate a 3D plot using Geometry3D library Renderer instance | def plot_3d_object(object_):
# Initialize renderer instance
r = Renderer()
# Add surfaces and goal regions to the renderer instance
for surf in object_:
r.add((object_[surf][0],'b',1))
if len(object_[surf])>2:
r.add((object_[surf][2],'r',1))
r.add((gPoint(-15,-15,-1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot3d(self):\n plot_rupture_wire3d(self)",
"def plotTerrain3d(self, gdf: gpd.GeoDataFrame, fig_size: tuple=(12, 10), size: float=0.01):\n fig, ax = plt.subplots(1, 1, figsize=fig_size)\n ax = plt.axes(projection='3d')\n ax.scatter(gdf.geometry.x, gdf.geometry.y, gdf.elevation, s=... | [
"0.699979",
"0.6854899",
"0.6696654",
"0.65606564",
"0.65247005",
"0.64862555",
"0.64855486",
"0.64444196",
"0.64396155",
"0.63991827",
"0.6364463",
"0.62895536",
"0.6284521",
"0.62425154",
"0.62332267",
"0.6223329",
"0.6215087",
"0.60715675",
"0.60688156",
"0.60422426",
"0.5... | 0.79453415 | 0 |
Given the object geometry, determine neighbors for each surface | def get_neighbors(object_):
# Initialize neighbors dictionary
neighbors = dict()
# For each surface in object dictionary
for surf in object_:
# Selected surface
current_surface = object_[surf][0]
# Surface normal
current_normal = object_[surf][1]
# Rest of th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def neighbors(self):\n return self.mesh.neighbors()",
"def _get_single_direction_neighbors(object_idx, ui_v_dist, ui_h_dist):\n neighbor_dict = {}\n vertical_dist = ui_v_dist[object_idx]\n horizontal_dist = ui_h_dist[object_idx]\n bottom_neighbors = np.array([\n idx for idx in range(len(vertical_... | [
"0.70040745",
"0.6541992",
"0.64760965",
"0.63982475",
"0.63982475",
"0.6391575",
"0.6362306",
"0.63613594",
"0.63120025",
"0.6269004",
"0.6226812",
"0.62244326",
"0.62244326",
"0.62144446",
"0.62144446",
"0.6202256",
"0.61859506",
"0.61818993",
"0.6158315",
"0.6152837",
"0.6... | 0.73999304 | 0 |
Given the object surface dict and neighbors dict, generate an unfolded surface for the desired surface centering a selected surface | def unfold_surface(surface_dict,neighbors_dict,surf_idx,other,neighbor,show=False):
# Visualization
p = Renderer()
p.add((surface_dict[surf_idx][0],'r',1))
# Normal of the center surface
current_normal = surface_dict[surf_idx][1]
# Normal of the neighboring surface
candidate_normal = other... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unfold_object(current_surface,surface_dict,neighbors_dict):\n\n # Initialize a dictionary for the unfolded surfaces\n unfolded_surfaces = dict()\n\n # Generate a list of surface numbers\n surface_list = list(surface_dict.keys())\n\n # Add center surface to dictionary without modification\n un... | [
"0.7424394",
"0.6814888",
"0.5967758",
"0.5692729",
"0.5601582",
"0.5594345",
"0.5561491",
"0.5481942",
"0.54616654",
"0.54466075",
"0.5438576",
"0.54213005",
"0.5418105",
"0.5338465",
"0.5325525",
"0.5324954",
"0.5324351",
"0.53149396",
"0.5309649",
"0.5297013",
"0.52767515"... | 0.7474481 | 0 |
Given the object surface dictionary and neighbors dictionary, unfold rest of the surfaces with a selected surface at the center | def unfold_object(current_surface,surface_dict,neighbors_dict):
# Initialize a dictionary for the unfolded surfaces
unfolded_surfaces = dict()
# Generate a list of surface numbers
surface_list = list(surface_dict.keys())
# Add center surface to dictionary without modification
unfolded_surface... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unfold_surface(surface_dict,neighbors_dict,surf_idx,other,neighbor,show=False):\n\n # Visualization\n p = Renderer()\n p.add((surface_dict[surf_idx][0],'r',1))\n\n # Normal of the center surface\n current_normal = surface_dict[surf_idx][1]\n # Normal of the neighboring surface\n candidate_... | [
"0.7613577",
"0.6724186",
"0.5619329",
"0.5326774",
"0.52730316",
"0.527127",
"0.52315",
"0.5224766",
"0.51455975",
"0.5141383",
"0.5130152",
"0.5116327",
"0.5095988",
"0.50457686",
"0.5040918",
"0.5028932",
"0.50051355",
"0.4972177",
"0.49689552",
"0.49586454",
"0.49513674",... | 0.8169945 | 0 |
Get the critic associated with this actor. | def critic(self) -> CriticType:
if not self._critic:
raise ValueError("no critic associated with this actor")
return self._critic | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_critics(self):\n actors = [ddpg_agent.critic for ddpg_agent in self.maddpg_agent]\n return actors",
"def _critic(self, image):\n return torch.mean(self.critic(image))",
"def critic(self, critic: CriticType) -> None:\n self._critic = critic",
"def ability(self, ability):\n\... | [
"0.6419532",
"0.5767918",
"0.56854165",
"0.5523613",
"0.54817516",
"0.5477361",
"0.541997",
"0.5398939",
"0.53664863",
"0.5311079",
"0.5240227",
"0.52047384",
"0.5190481",
"0.5189437",
"0.5118587",
"0.50764984",
"0.5053034",
"0.50138736",
"0.5009325",
"0.49982783",
"0.4973842... | 0.84475094 | 0 |
Set the critic of this actor. You probably do not want to do this manually. | def critic(self, critic: CriticType) -> None:
self._critic = critic | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def critic(self) -> CriticType:\n if not self._critic:\n raise ValueError(\"no critic associated with this actor\")\n return self._critic",
"def set_CriticsPick(self, value):\n super(SearchByReviewerInputSet, self)._set_input('CriticsPick', value)",
"def criticize(self, env: Fak... | [
"0.6765269",
"0.55871475",
"0.53288627",
"0.5272914",
"0.5172377",
"0.51469475",
"0.51087296",
"0.5046028",
"0.50317234",
"0.4984842",
"0.4978813",
"0.49477944",
"0.49282527",
"0.49237365",
"0.49106264",
"0.48933023",
"0.48489824",
"0.4830805",
"0.48293337",
"0.4826514",
"0.4... | 0.8091018 | 0 |
Generate policy parameters onthefly based on an environment state. | def _gen_policy_params(self, state: State) -> Tensor:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gen_policy_params(self, state: State) -> Tensor:\n return self.network(state)",
"def build_policy(env, Vvalues):\n Vpolicy = torch.zeros(NUM_STATES)\n\n for state in range(NUM_STATES):\n _, index = next_step_evaluation(env, state, Vvalues)\n Vpolicy[state] = index.item()\n\n re... | [
"0.6997905",
"0.6333678",
"0.6001725",
"0.6001725",
"0.58902913",
"0.5871921",
"0.58525336",
"0.57313406",
"0.5689953",
"0.56655127",
"0.56550616",
"0.5647602",
"0.5634601",
"0.5625977",
"0.5622746",
"0.55883676",
"0.55883676",
"0.55755997",
"0.5521223",
"0.5510471",
"0.55086... | 0.7477268 | 0 |
Generate the behavioural policy based on the given parameters and the distribution family of this actor. | def _gen_behaviour(self, params: Tensor) -> Distribution:
# TODO: check for parameter size mismatches
# TODO: support params being for multiple different distributions
if len(params.size()) == 1:
params = params.unsqueeze(0)
elif len(params.size()) > 2:
# FIXME: ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def act(self, state: State) -> Distribution:\n return self._gen_behaviour(self._gen_policy_params(state))",
"def create_greedy_policy(self):\n\n def policy_fn(state):\n return self.actor_baseline.predict([[state]])[0][0]\n\n return policy_fn",
"def make_decision_with_policy(self... | [
"0.69731206",
"0.65240955",
"0.60581094",
"0.5933542",
"0.58577895",
"0.58535635",
"0.58448905",
"0.5797706",
"0.5698496",
"0.5630963",
"0.5575867",
"0.55735415",
"0.5571977",
"0.5564916",
"0.553127",
"0.5499231",
"0.5448355",
"0.5441939",
"0.54395163",
"0.5424341",
"0.539192... | 0.6820135 | 1 |
Generate the PCL document printing a same line with various Horizontal Motion Index values (HMI). | def print_hmi_demo( printer_socket ):
print( 'Horizontal Motion Index demo' )
print( '----------------------------' )
print( 'Printer IP: %s\nPrinter Port: %i' % printer_socket )
medium = PrinterSocketAdapter( printer_socket )
# Very simple printout + usual initialization commands
d = HpPclDocument( 'cp850', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writePOVRAYHeader(self, fh):\n settings = self.mainWindow.preferences.povrayForm\n\n focalPoint = self.camera.GetFocalPoint()\n campos = self.camera.GetPosition()\n viewup = self.camera.GetViewUp()\n angle = settings.viewAngle\n if settings.shadowless:\n sha... | [
"0.5855003",
"0.56978124",
"0.5614265",
"0.55788046",
"0.55214256",
"0.55017865",
"0.53626406",
"0.5358919",
"0.53464925",
"0.5337525",
"0.5325445",
"0.53254324",
"0.5279234",
"0.5271747",
"0.5269328",
"0.5254424",
"0.5251807",
"0.52497333",
"0.5235495",
"0.52344364",
"0.5231... | 0.7059355 | 0 |
Frame routine, including main pipeline, triplet builup, and trajectory pipeline. | def run_frame(self, image):
self.frame_idx += 1
# run main pipeline
t0 = datetime.now()
disp = self.main_pipeline(image)
t1 = datetime.now()
logging.info('main pipeline: {}'.format(get_tdiff(t0, t1)))
# prepare image sequence of 3 for trajectory pipeline
t0 = datetime.now()
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_pipeline(frame, keep_state=True):\n\n global line_lt, line_rt, processed_frames\n\n # undistort the image using coefficients found in calibration\n undistorted_img = undistort(frame, mtx, dist)\n\n # binarize the frame and highlight lane lines\n binarized_img = binarize(undistorted_img)\... | [
"0.64260715",
"0.6129523",
"0.6008771",
"0.6003277",
"0.5954754",
"0.59039664",
"0.5864619",
"0.5844462",
"0.5808007",
"0.57920486",
"0.57749957",
"0.57749957",
"0.57749957",
"0.57749957",
"0.57749957",
"0.57749957",
"0.5700318",
"0.56840724",
"0.5669105",
"0.566348",
"0.5663... | 0.7119006 | 0 |
Main pipeline of trackingbydetection. From one image, we can obtain a list of detected objects along with their bounding boxes, labels, and depth. Objects are tracked with the data association solver and a list of trackers. | def main_pipeline(self, image):
# detection
t0 = datetime.now()
bbox_list, score_list, label_list = self.det.inference(image)
t1 = datetime.now()
logging.info('main pipeline (det): {}'.format(get_tdiff(t0, t1)))
# estimation
t0 = datetime.now()
disp = self.est.inference(image)
dep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_objects(interpreter, image):\n set_input_tensor(interpreter, image)\n interpreter.invoke()\n\n # Get all output details\n #boxes = get_output_tensor(interpreter, 0)\n classes = get_output_tensor(interpreter, 1)\n scores = get_output_tensor(interpreter, 2)\n #count = int(get_output_tensor(interpre... | [
"0.6946796",
"0.6760437",
"0.6635849",
"0.66155344",
"0.6591393",
"0.65542084",
"0.6482883",
"0.64753896",
"0.63018554",
"0.63015753",
"0.62848926",
"0.6262375",
"0.61878157",
"0.6185116",
"0.6184772",
"0.6178074",
"0.61592215",
"0.61547065",
"0.61352974",
"0.60970944",
"0.60... | 0.6867465 | 1 |
Trajectory pipeline of trackingbydetection. Given a previous egomotion transformation matrix and a triplet of images, we can obtain the egomotion for the new frame and accumulate it on previous pose to generate 3D coordinate transformation matrix. Then all objects are projected to 3D coordinate to generate absolute tra... | def traj_pipeline(self, prev_trmat=None):
# image_seq = [image(frame_idx-2), image(frame_idx-1), image(frame_idx)]
# egomotion update
egomo = self.est.get_egomotion(self.image_seq)
# egomotion transformation
assert self.frame_idx >= 2, 'invalid self.frame_idx'
if prev_trmat is None:
asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_pipeline(self, image):\n # detection\n t0 = datetime.now()\n bbox_list, score_list, label_list = self.det.inference(image)\n t1 = datetime.now()\n logging.info('main pipeline (det): {}'.format(get_tdiff(t0, t1)))\n \n # estimation\n t0 = datetime.now()\n disp = self.est.inference(... | [
"0.63010347",
"0.62757874",
"0.62689936",
"0.59285986",
"0.5928235",
"0.5921437",
"0.5783612",
"0.56781733",
"0.56098306",
"0.55962694",
"0.5596124",
"0.55675745",
"0.5542845",
"0.5538803",
"0.55189425",
"0.54891604",
"0.5424595",
"0.54225814",
"0.541845",
"0.5406309",
"0.538... | 0.7915945 | 0 |
returns a matrix with sourcesink pairs on the yaxis and version on the xaxis | def get_matrix(self, app):
# get all source-sink combinations as y-labels
ylabels = []
for apk in app['apks']:
for data in apk['data'].keys():
if data not in ylabels:
ylabels.append(data)
ylabels.sort()
if len(ylabels) == ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateNeighborMap(self):\n A=[]\n for key,value in self._ts_dict.iteritems():\n A.append(np.array([i.replace(\"#\",\" \")\n .split()[0:4] for i in value.index])\n .astype(float))\n\n B=np.array(A[0]).reshape(len(A[0]),4)\n ... | [
"0.54319865",
"0.53537995",
"0.53168917",
"0.5256393",
"0.51762635",
"0.51466733",
"0.5050392",
"0.5049039",
"0.5042114",
"0.50266486",
"0.5022293",
"0.5015575",
"0.5006958",
"0.5006378",
"0.4996374",
"0.49779284",
"0.49577492",
"0.4901869",
"0.48976383",
"0.48949212",
"0.488... | 0.6360529 | 0 |
init config, batch_size, epochs. | def __init__(self, config):
self.model = None
self.config = config
self.batch_size = config.get('batch_size')
self.epochs = config.get('epochs')
self.steps_per_epoch = config.get('steps_per_epoch')
self.validation_steps = config.get('validation_steps')
self.distri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, classCount):\n self.NUM_CLASSES = 1+classCount\n self.STEPS_PER_EPOCH = self.STEPS_PER_EPOCH / self.IMAGES_PER_GPU\n self.VALIDATION_STEPS = self.VALIDATION_STEPS / self.IMAGES_PER_GPU\n super(ModelConfig, self).__init__()",
"def init_input_pipeline(self, config):\n... | [
"0.7023804",
"0.6994861",
"0.6986887",
"0.69548535",
"0.6946242",
"0.69346786",
"0.68955725",
"0.68943435",
"0.6829831",
"0.6821801",
"0.6818673",
"0.6742996",
"0.67338043",
"0.6723518",
"0.6714932",
"0.6707389",
"0.6679911",
"0.6676357",
"0.66759074",
"0.6658294",
"0.6651317... | 0.78860265 | 0 |
You should implements inputs. | def inputs(self):
return NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input(self):",
"def inputs(self):\n pass",
"def process_inputs(self, inputs):",
"def processInputs(self):",
"def input(self):\r\n pass",
"def __call__(self, *inputs):\n raise NotImplementedError",
"def call(self, inputs):\n raise NotImplementedError",
"def out(self, inputs):",... | [
"0.8273351",
"0.8123075",
"0.8098877",
"0.79928917",
"0.7894954",
"0.7837142",
"0.76479155",
"0.751315",
"0.7328494",
"0.73143715",
"0.73143715",
"0.7313171",
"0.72914857",
"0.7180601",
"0.7165914",
"0.7165914",
"0.7165914",
"0.7165914",
"0.7058984",
"0.7046415",
"0.70070934"... | 0.82329375 | 1 |
Build optimizer, default to sgd. | def optimizer(self):
return 'sgd' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile(self, gen_optimizer, disc_optimizer):\n self.gen_optimizer = gen_optimizer\n self.disc_optimizer = disc_optimizer",
"def compile_optimizer(self):\n optimizer = torch.optim.Adam(self.parameters(), lr=self.cfg.learning_rate)\n\n return optimizer",
"def build_optimizer(cfg:... | [
"0.6707388",
"0.65863216",
"0.6496739",
"0.64689183",
"0.64221466",
"0.6369505",
"0.63093096",
"0.6238498",
"0.6227908",
"0.6220927",
"0.6189515",
"0.6155221",
"0.6149654",
"0.61448663",
"0.6075913",
"0.60669714",
"0.6042588",
"0.60317975",
"0.59488785",
"0.59424376",
"0.5942... | 0.6680733 | 1 |
Build loss function, default to `mse`. | def loss(self):
return 'mse' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss_fn(self, targets, outputs, model):",
"def make_loss(self, logit=None, labels=None):\r\n return nn.functional.mse_loss(logit, labels, reduction='mean') # The MSE Loss\r",
"def _build_loss(self, **kwargs):\n pass",
"def build_loss(self):\n\n opt = tf.train.AdamOptimizer(self.... | [
"0.69963366",
"0.67683053",
"0.67106676",
"0.6673715",
"0.651554",
"0.64021844",
"0.639622",
"0.63460386",
"0.63432056",
"0.6308764",
"0.63011605",
"0.626922",
"0.6213675",
"0.6199582",
"0.61774623",
"0.6169041",
"0.6168795",
"0.61373484",
"0.6129343",
"0.6110672",
"0.6110042... | 0.68811774 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.