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 |
|---|---|---|---|---|---|---|
Provide answer in the return value. This function returns one tuple describing you observations | def answer(self):
return (1, 4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answer(self):\n\n return (1, 2, 1, 2)",
"def answer(self):\n\n return (1, 1, 2, 4)",
"def task9_answer():\n\n return (1, 3, 4, 5)",
"def results(self):\n\n\t\tresults = {'answer':42}\n\n\t\treturn results",
"def __get_data(self, universe:list, factor_pool:list, ret_label:str, start_dat... | [
"0.6732488",
"0.6670362",
"0.6554476",
"0.62387717",
"0.60515916",
"0.6027523",
"0.60140425",
"0.5975857",
"0.59751713",
"0.5964573",
"0.5942693",
"0.58566",
"0.5853647",
"0.58326477",
"0.5828065",
"0.58170116",
"0.5795604",
"0.5785389",
"0.5769348",
"0.5767244",
"0.57561594"... | 0.6743457 | 0 |
Returns the added item. | def added_item(self, uid: str) -> object:
return self._input[uid] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, item):",
"def get_item(self):\n return self.item",
"def get_item(self):\n return self.item",
"def get_item(self):\n raise NotImplementedError",
"def add_item(self):\n item = LibGen.create_item()\n if not self.item_exists(item.call_number):\n self.... | [
"0.74160415",
"0.7138136",
"0.7138136",
"0.706266",
"0.6872149",
"0.66928333",
"0.66887194",
"0.6687491",
"0.66214705",
"0.65819716",
"0.6554912",
"0.6549853",
"0.6518295",
"0.6506271",
"0.6506271",
"0.648759",
"0.6485234",
"0.64600724",
"0.64600724",
"0.64600724",
"0.6444707... | 0.7867647 | 0 |
Get item result by uid. | def get(self, uid: str) -> object:
return self._results[uid] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item_with_id(self, uid):\n for item in self.get_items():\n if item.id == uid:\n return item\n\n return None",
"def get_by_uid(self, uid, **kwargs):\n items = self.search(UID=uid, **kwargs).get('items')\n\n if not items:\n raise LookupError(... | [
"0.7593181",
"0.75671893",
"0.72641826",
"0.719392",
"0.67980444",
"0.6741963",
"0.67064244",
"0.64979196",
"0.64942247",
"0.6450699",
"0.6356397",
"0.6261345",
"0.62500316",
"0.6166366",
"0.6165816",
"0.6129108",
"0.61288935",
"0.6101235",
"0.60794276",
"0.6066852",
"0.60001... | 0.81453663 | 0 |
Resource has pending work. | def pending_work(self) -> bool:
return len(self.ongoing) > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_pending(self):\n return self._state == \"PENDING\"",
"def is_pending(self):\n status = self.get_status()\n return status[\"status\"] == 3",
"def pending(self):\n return 0",
"def is_pending(self):\n return self.type_id == STATE_PENDING",
"def is_pending(self):\n ... | [
"0.7410092",
"0.7407186",
"0.7266239",
"0.7127514",
"0.7081727",
"0.6982759",
"0.68075866",
"0.67374724",
"0.6715299",
"0.666442",
"0.6646339",
"0.6521107",
"0.6490966",
"0.6468425",
"0.6454948",
"0.6444217",
"0.64277786",
"0.6398431",
"0.6390363",
"0.63795155",
"0.63734704",... | 0.767412 | 0 |
Gets information about items in ``Executor`` for debugging. Subclasses can override this method and implement a well suited method to get items current status. | def get_current_status_for_debug(self) -> List[str]:
msgs = []
if self.added_items:
msgs.append(f"{self.class_name} {self.cfg.name} added items:")
for item in self.added_items:
msgs.append(f"\t{item}")
else:
msgs.append(f"No added items in {sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getInfoOnStatus(self):\n raise NotImplementedError();",
"def execute_info(self):\n return self._execute_info",
"def info(self):\n return self.current_run.info",
"def get_details(self):\n status = []\n for key, container in self.containers.items():\n container... | [
"0.6424657",
"0.631913",
"0.61626965",
"0.59027237",
"0.58842343",
"0.588345",
"0.5873142",
"0.58566666",
"0.5813858",
"0.5776814",
"0.5770883",
"0.5770883",
"0.57550246",
"0.57550246",
"0.575277",
"0.57400995",
"0.5728079",
"0.5728079",
"0.5728079",
"0.5728079",
"0.5728079",... | 0.6751712 | 0 |
Tests that liking a message works correctly. | def test_like(self):
message = Message(text="hello world", user_id=self.testuser2.id)
db.session.add(message)
db.session.commit()
message_id = message.id
with self.client as c:
with c.session_transaction() as session:
session[CURR_U... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_like_message(self):\n\n self.u.likes.append(self.m_u2)\n db.session.commit()\n\n self.assertEqual(len(self.u.likes), 1)\n self.assertEqual(self.u.likes[0], self.m_u2)",
"def test_update_like_can_message(self):\n\n self.assertEqual(first=0, second=self.like.likes.all().... | [
"0.7500867",
"0.73392713",
"0.73344636",
"0.7329332",
"0.7234027",
"0.71456903",
"0.70850676",
"0.68999016",
"0.68899083",
"0.6789816",
"0.67514914",
"0.6699322",
"0.6665291",
"0.651895",
"0.64480066",
"0.6421176",
"0.6401107",
"0.6379729",
"0.6366734",
"0.63360304",
"0.63171... | 0.7895267 | 0 |
Tests that unliking a message works correctly. | def test_unlike(self):
message = Message(text="hello world", user_id=self.testuser2.id)
db.session.add(message)
db.session.commit()
like = Likes(message_id=message.id, user_id=self.testuser.id)
db.session.add(like)
db.session.commit()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unlike_mission(self):\n\n self.mission.likes = {0, self.user2.id}\n db.session.commit()\n mission = Mission.query.get(self.mission.id)\n # make sure like is there in mission.likes.\n self.assertEqual(mission.likes, {0, self.user2.id})\n\n with self.client as c:\n ... | [
"0.6753856",
"0.65746415",
"0.650034",
"0.649709",
"0.64039636",
"0.62669873",
"0.6260182",
"0.61631036",
"0.61529106",
"0.608861",
"0.6024869",
"0.5958756",
"0.587565",
"0.5863406",
"0.5832868",
"0.57908106",
"0.57621634",
"0.57574433",
"0.5739922",
"0.5647676",
"0.5647052",... | 0.70695925 | 0 |
Tests that attempting to like/unlike a message whilst unauthorized is rejected. | def test_unauthorized_like(self):
message = Message(text="hello world", user_id=self.testuser2.id)
db.session.add(message)
db.session.commit()
like = Likes(message_id=message.id, user_id=self.testuser.id)
db.session.add(like)
db.session.commit()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unauthenticated_user_liking(self):\n self.like_dislike(self.dislike_url(5))",
"def test_unauthorized_user_like_field(self):\n response = self.client.get(reverse('lessons-detail', args=(1,)))\n self.assertEqual(response.status_code, status.HTTP_200_OK)\n self.assertNotIn('like... | [
"0.74085444",
"0.72086763",
"0.712131",
"0.7073008",
"0.6997627",
"0.6860409",
"0.6685054",
"0.65761566",
"0.6543981",
"0.6496687",
"0.6453958",
"0.6438093",
"0.6388551",
"0.6380686",
"0.6352018",
"0.6291714",
"0.6255084",
"0.624493",
"0.62448287",
"0.62345237",
"0.6231471",
... | 0.79207224 | 0 |
Tests that accessing a following page without credentials is rejected. | def test_unauthorized_following(self):
follow = Follows(
user_being_followed_id = self.testuser2.id,
user_following_id = self.testuser.id
)
db.session.add(follow)
db.session.commit()
with self.client as c:
response = c.get(f"/users/{self.tes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_following_existing_user_not_authenticated(self):\n self.client.credentials()\n response = self.client.post(\n reverse(\n 'follow',\n kwargs={'username': self.followed['user'].get('username')}\n )\n )\n self.assertEqual(respons... | [
"0.7319878",
"0.71709114",
"0.7151044",
"0.71304643",
"0.70958227",
"0.70355564",
"0.7022304",
"0.6899457",
"0.68274623",
"0.68251395",
"0.6824948",
"0.680066",
"0.6796531",
"0.67669344",
"0.67561007",
"0.6736968",
"0.673141",
"0.6721031",
"0.6720389",
"0.6694388",
"0.6694388... | 0.73165977 | 1 |
Tests that accessing a followers page without credentials is rejected. | def test_unauthorized_followers(self):
follow = Follows(
user_being_followed_id = self.testuser.id,
user_following_id = self.testuser2.id
)
db.session.add(follow)
db.session.commit()
with self.client as c:
response = c.get(f"/users/{self.tes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_list_of_followers_without_auth(self):\n with self.settings(\n EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend'):\n response = self.client.get(self.followers_url)\n self.assertEqual(response.data['detail'],\n \"Authentication ... | [
"0.80370384",
"0.75863016",
"0.7411454",
"0.73758006",
"0.7353231",
"0.72279394",
"0.7214382",
"0.714913",
"0.70005536",
"0.69480914",
"0.6931344",
"0.68351185",
"0.6685287",
"0.663357",
"0.658625",
"0.6569212",
"0.6565524",
"0.6525673",
"0.6496285",
"0.6492629",
"0.64847374"... | 0.7781052 | 1 |
check if premium member for valid member | def test_3(self):
c1 = Store.Customer("harold", "qcf", True)
self.assertTrue(c1.is_premium_member(), "not premium member") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_4(self):\n c1 = Store.Customer(\"harold\", \"qcf\", False)\n self.assertFalse(c1.is_premium_member(), \"IS premium member\")",
"async def is_premium(self) -> bool:\n e = await self.request.request(url=f'https://www.roblox.com/mobileapi/userinfo', method='get')\n return e['IsP... | [
"0.6992384",
"0.66777605",
"0.63307333",
"0.62341",
"0.62267804",
"0.6158541",
"0.61556613",
"0.6062128",
"0.60154915",
"0.59984636",
"0.59928083",
"0.5983695",
"0.5938593",
"0.59137547",
"0.58976066",
"0.5860356",
"0.58563644",
"0.5834168",
"0.5796033",
"0.5796006",
"0.57827... | 0.6929887 | 1 |
check if premium member if not valid | def test_4(self):
c1 = Store.Customer("harold", "qcf", False)
self.assertFalse(c1.is_premium_member(), "IS premium member") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_3(self):\n c1 = Store.Customer(\"harold\", \"qcf\", True)\n self.assertTrue(c1.is_premium_member(), \"not premium member\")",
"async def is_premium(self) -> bool:\n e = await self.request.request(url=f'https://www.roblox.com/mobileapi/userinfo', method='get')\n return e['IsPr... | [
"0.6888039",
"0.66828996",
"0.6435083",
"0.63407624",
"0.6059652",
"0.6038428",
"0.6002299",
"0.5986008",
"0.5903139",
"0.5873443",
"0.5762152",
"0.5747567",
"0.5742472",
"0.5736066",
"0.5730407",
"0.57073194",
"0.56902134",
"0.5665418",
"0.5665418",
"0.56482524",
"0.56424147... | 0.7114507 | 0 |
test check out should equal 6.42 for three items at 2 dollars each plus shipping | def test_6(self):
toothpaste = Store.Product(11, "toothpaste", "dental", 2, 4)
milk = Store.Product(12, "milk", "dairy", 2, 3)
eggs = Store.Product(14, "eggs", "dairy", 2, 2)
apple_juice = Store.Product(13, "apple juice", "drink", 1, 1)
s = Store.Store()
s.add_product(to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gold_card(subtotal):\n return subtotal * 0.05",
"def silver_card(subtotal):\n return subtotal * 0.02",
"def test_get_stock_price_summary4(self):\n\n actual = a1.stock_price_summary([0.02, 0.14, 0.10])\n expected = (0.26,0)\n self.assertEqual(actual, expected)",
"def test_calcul... | [
"0.6775019",
"0.6595498",
"0.635339",
"0.6311632",
"0.62834555",
"0.62146467",
"0.6200542",
"0.6175484",
"0.6144745",
"0.61386776",
"0.6119413",
"0.60917616",
"0.60730153",
"0.6065133",
"0.60586363",
"0.60566044",
"0.6050846",
"0.6050451",
"0.6035097",
"0.6016659",
"0.6006021... | 0.68899894 | 0 |
Searches for all drink admins. | def get_drink_admins(self):
admins = self.group('drink')
return admins | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drinkAdmins(self):\n admins = self.group('drink')\n return admins",
"def get_admins(self):\n admins = User.objects.filter(Q(groups__name=self.admin_group_name()) | Q(is_superuser=True)).distinct()\n return admins",
"def get_admins(self):\n return self.admins_group.user_se... | [
"0.7626615",
"0.68719196",
"0.6805782",
"0.6686546",
"0.66309863",
"0.6579962",
"0.656309",
"0.6484229",
"0.6478381",
"0.6406674",
"0.63949853",
"0.62509245",
"0.613989",
"0.6083141",
"0.60780597",
"0.6051802",
"0.6046379",
"0.604062",
"0.60262364",
"0.5981295",
"0.5968331",
... | 0.7636565 | 0 |
Returns a list of groups that a member belongs to. | def get_groups(self, member_dn):
search_result = self.search(base=GROUPS, member=member_dn)
if len(search_result) == 0:
return []
group_list = []
for group in search_result:
group_cn = group['attributes']['cn'][0]
if self.debug:
prin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_groups(self):\n user_node = self.get()\n grouplist = []\n if user_node:\n for rel in graph.match(start_node=user_node, rel_type='in'):\n grouplist.append(Usergroup(id=rel.end_node()['id']))\n return grouplist",
"def find_groups(groups=None, name=None,... | [
"0.7758451",
"0.75771236",
"0.7455061",
"0.74303347",
"0.73591954",
"0.72485995",
"0.72438496",
"0.721254",
"0.7209152",
"0.7169427",
"0.7133967",
"0.711703",
"0.710896",
"0.710896",
"0.710896",
"0.70847243",
"0.70678437",
"0.70632833",
"0.7037165",
"0.6990258",
"0.6983493",
... | 0.8088219 | 0 |
Searches for all RTPs | def get_rtps(self):
rtps = self.group('rtp')
return rtps | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_roku_devices():\n\n\tfound_devices = set()\n\n\t# The UPD M-SEARCH message\n\tmsg = __getmessage__()\n\n\t# Set up UDP socket\n\ts = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)\n\ts.settimeout(2)\n\ts.sendto(msg.encode('utf-8'), ('239.255.255.250', 1900) )\n\n\t# Counter for the t... | [
"0.54896796",
"0.5231175",
"0.51695204",
"0.5163761",
"0.51572496",
"0.5063222",
"0.5016381",
"0.49998677",
"0.4977547",
"0.49723232",
"0.4970052",
"0.49620566",
"0.49414483",
"0.49369073",
"0.49265638",
"0.49259934",
"0.49234992",
"0.49125823",
"0.49091136",
"0.49083737",
"0... | 0.5989913 | 0 |
Calculates 2D hausdorff distance based on predicted and target segmentation mask works for 2D array only! Supports multiclass (semantic segmentation) | def hausdorff_2d_distance(pred: np.ndarray, target: np.ndarray) -> Dict:
assert len(pred.shape) == 2 or len(target.shape) == 2
labels = np.unique(target)
labels = labels[labels != 0]
scores = {}
for label in labels:
mask_pred = pred == label
mask_gt = targ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature_dist(input_labels, struct=np.ones((3, 3))):\n # remove the pixels inside the coherent\n input_errosion = binary_erosion(input_labels, structure=struct)\n input_labels[input_errosion] = 0\n I, J = np.nonzero(input_labels)\n labels = input_labels[I, J]\n coords = np.column_stack((I, J))... | [
"0.6469436",
"0.6366787",
"0.6106287",
"0.61034775",
"0.60753113",
"0.59953755",
"0.5954967",
"0.59157926",
"0.5876313",
"0.58337986",
"0.58266443",
"0.5809017",
"0.58086526",
"0.5808168",
"0.5779059",
"0.5766238",
"0.5747568",
"0.5744262",
"0.5732244",
"0.5729079",
"0.570663... | 0.7233766 | 0 |
Saves the dict with the new numbers of the users to the json file | def _save_users_data_to_json(self):
with open(self._users_numbers_json_path, 'wb') as f:
json.dump(dict(self._users_numbers), f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_json_file(self):\n with open(\"data/save.txt\", \"r+\") as file:\n dictionary = json.load(file)\n user = dictionary[\"Actual Username\"]\n dictionary[user].append(self.score)\n\n with open(\"data/save.txt\", \"w\") as file:\n json.dump(dictionary... | [
"0.7745593",
"0.7146998",
"0.7131358",
"0.70276266",
"0.69209224",
"0.6906528",
"0.6896065",
"0.67190963",
"0.6694532",
"0.65293515",
"0.64926326",
"0.6472562",
"0.6410419",
"0.64005834",
"0.6341129",
"0.6338325",
"0.63258356",
"0.6311408",
"0.62698877",
"0.6129035",
"0.61145... | 0.83313555 | 0 |
Adds the new number of the user to the user's avg data | def _add_data_to_user(self, user, number):
self._users_numbers[user]['sum'] += number
self._users_numbers[user]['counter'] += 1
self._save_users_data_to_json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_mean_user_rating(self):\n self.mean_user_rating = self.ratings.groupby(['user_id'])['rating'].mean().reset_index()",
"def _get_user_avg(self, user):\n return calculate_user_numbers_avg(self._users_numbers, user)",
"def add_to_average(total_count, total_value, new_value):\n return ((... | [
"0.7370114",
"0.72103995",
"0.6370001",
"0.6363194",
"0.63482326",
"0.6336928",
"0.6293731",
"0.6291411",
"0.61962384",
"0.61153215",
"0.60947543",
"0.60275847",
"0.59987086",
"0.5959771",
"0.5927861",
"0.5895361",
"0.5879943",
"0.5874055",
"0.58350474",
"0.57980376",
"0.5796... | 0.741907 | 0 |
Calculates the avg of the user's numbers | def _get_user_avg(self, user):
return calculate_user_numbers_avg(self._users_numbers, user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean(numbers):\n return float(sum(numbers)) / float(len(numbers))",
"def calcUserMeanRating(userRatingGroup):\n userID = userRatingGroup[0]\n ratingSum = 0.0\n ratingCnt = len(userRatingGroup[1])\n if ratingCnt == 0:\n return (userID, 0.0)\n for item in userRatingGroup[1]:\n ... | [
"0.73072195",
"0.7117617",
"0.7076336",
"0.70757735",
"0.7068994",
"0.6980192",
"0.69689524",
"0.695918",
"0.69573164",
"0.6951897",
"0.6939342",
"0.68884647",
"0.6868578",
"0.67754674",
"0.67590624",
"0.67590624",
"0.6749915",
"0.6743124",
"0.673626",
"0.6716683",
"0.6716052... | 0.81641376 | 0 |
Checks if the data of a message is a number or not | def _check_message_is_number(message):
try:
float(message)
return True
except ValueError:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_number(data):\n return len(data) and np.issubdtype(_to_ndarray(data).dtype, np.number)",
"def is_number(self) -> bool:\n return False",
"def is_number(G):\n return True",
"def is_number(self,val):\n try:\n float(val)\n return True\n except ValueErr... | [
"0.7506115",
"0.70249045",
"0.698771",
"0.6913425",
"0.6894809",
"0.68555146",
"0.6834443",
"0.6791668",
"0.6768796",
"0.6759166",
"0.67426765",
"0.6738768",
"0.67286825",
"0.67249095",
"0.67126197",
"0.6678519",
"0.6674555",
"0.665162",
"0.66426355",
"0.6605666",
"0.65988195... | 0.8340901 | 0 |
Gets the user name from the user id by api call from the slack client | def _get_user_name_from_user_id_by_slack_client(self, user_id):
user_info = self.slack_client.api_call('users.info', user=user_id)
if not user_info['ok']:
return
user_name = user_info['user']['name']
self._user_id_to_user_name[user_id] = user_name
return user_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_username_from_api(self):\n result = self.api_query(action=\"query\", meta=\"userinfo\")\n return result[\"query\"][\"userinfo\"][\"name\"]",
"def _get_user_name_from_user_id(self, user_id):\n if user_id in self._user_id_to_user_name.keys():\n return self._user_id_to_user_... | [
"0.748013",
"0.71902126",
"0.71136624",
"0.69366384",
"0.68196195",
"0.6777821",
"0.67232335",
"0.661219",
"0.6596149",
"0.6536261",
"0.65273553",
"0.63704205",
"0.6370292",
"0.6364513",
"0.6342001",
"0.6297765",
"0.6273787",
"0.62715864",
"0.6270835",
"0.62575704",
"0.624428... | 0.79836494 | 0 |
For each message in the chat, calculates the user's numbers avg and sends it to the chat | def process_message(self, data):
if not self._check_message_is_number(data['text']):
return
user_name = self._get_user_name_from_user_id(data['user'])
self._add_data_to_user(user_name, float(data['text']))
self.outputs.append([data['channel'], str(self._get_user_avg(user_name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def voice_message_tally(user_name, msg_logs, scorecard_map):\n for row in msg_logs:\n msg = ujson.loads(row[0])\n if is_my_outgoing_msg(msg):\n if msg['Type'] == RECORDING:\n # I sent a voice msg, that shows my interest, therefore bump my pondness value\n s... | [
"0.66360503",
"0.6507629",
"0.6444656",
"0.60974026",
"0.60704195",
"0.6050756",
"0.59103894",
"0.58927846",
"0.5799758",
"0.5769411",
"0.57484597",
"0.5740269",
"0.5736444",
"0.5718476",
"0.5707916",
"0.56380105",
"0.5597593",
"0.5594113",
"0.5568487",
"0.5565372",
"0.549441... | 0.73034394 | 0 |
Add the product selected in the list of favorite of the user | def add_favorite(request):
print("La fonction pour ajouté un produit est appelé")
query = request.GET.get('_substitute_product','')
print(query)
# query_favorite = query.id
query_name = Product.objects.get(name=query)
print(query_name)
print("ID DU PRODUIT")
username = request.user
u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def see_favorits(request):\n user_name = request.user\n print(user_name)\n # product = UserFavorite.objects.filter(user_name=user_name)\n list_favorits = UserFavorite.objects.all().filter(user_name=user_name)\n favorits_query = list_favorits\n favorits_list = []\n for favorite in favorits_quer... | [
"0.7478756",
"0.6982559",
"0.6971553",
"0.65613437",
"0.65594006",
"0.6503341",
"0.6487205",
"0.646612",
"0.6430867",
"0.63798237",
"0.6359114",
"0.62904596",
"0.62575287",
"0.61742616",
"0.6173648",
"0.6143775",
"0.6127563",
"0.6113219",
"0.6091968",
"0.6089672",
"0.60802436... | 0.7733449 | 0 |
See the favorits of the User | def see_favorits(request):
user_name = request.user
print(user_name)
# product = UserFavorite.objects.filter(user_name=user_name)
list_favorits = UserFavorite.objects.all().filter(user_name=user_name)
favorits_query = list_favorits
favorits_list = []
for favorite in favorits_query:
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_favor(self):\n if \"all\" in self.switches:\n favors = Reputation.objects.exclude(favor=0).order_by(\"-date_gossip_set\")\n self.msg(\"Characters with favor: %s\" % \", \".join(str(ob) for ob in favors))\n return\n org = self.get_organization(check_perm=False... | [
"0.7833284",
"0.7363097",
"0.7361918",
"0.7231697",
"0.71256995",
"0.70869046",
"0.70236176",
"0.69554955",
"0.6939694",
"0.69286466",
"0.68833476",
"0.6857968",
"0.6854023",
"0.68082047",
"0.67787",
"0.677694",
"0.67252666",
"0.6696489",
"0.66769177",
"0.6671317",
"0.6668169... | 0.7412779 | 1 |
reverse black and white color | def reverse_black_and_white(img):
img = 255 - img
return img | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse(color):\n return 255 - color",
"def negative(img): \n for pixel in img:\n x, y, col = pixel \n r, g, b = col\n \n new_color = create_color(255 - r, 255 - g, 255 - b)\n set_color(img, x, y, new_color)",
"def unflip_colors(self):\n self.colors[self... | [
"0.8254546",
"0.66949975",
"0.66061807",
"0.653569",
"0.6441206",
"0.63987577",
"0.6311348",
"0.6268284",
"0.6259552",
"0.6226291",
"0.62072444",
"0.6176793",
"0.61412317",
"0.6112735",
"0.61056167",
"0.60907745",
"0.60805494",
"0.60057807",
"0.5991006",
"0.5955161",
"0.59390... | 0.8097395 | 1 |
Handler for the create_post Lambda function | def handler(event, _context):
model = PostModel()
post_id = model.create(**json.loads(event['body']))
return dump_result({'post_id': post_id}, status_code=201) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self):\n data = request.json\n create_entry(data)\n return None, 201",
"def handle_post(cls, **kwargs):\n raise NotImplementedError",
"def post(self):\n data = request.json\n create_ue(data)\n return None, 201",
"def post(self, *args, **kwargs):\n ... | [
"0.71404606",
"0.70493096",
"0.70490444",
"0.70192987",
"0.6999904",
"0.69663024",
"0.6955587",
"0.6955587",
"0.6955587",
"0.693566",
"0.6901573",
"0.6828901",
"0.67827344",
"0.6765577",
"0.67457926",
"0.6565804",
"0.6565804",
"0.6565804",
"0.6565804",
"0.6565804",
"0.6565804... | 0.7746745 | 0 |
Test single shot run. | def test_qasm_simulator_single_shot(self):
shots = 1
self.qobj.config.shots = shots
result = self.backend.run(self.qobj).result()
self.assertEqual(result.success, True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_takes_shot(self):\n player = TestPlayer()\n self.ai.take_shot(player)\n self.assertEqual(1, player.shots_taken)",
"def test_with_shots_option(self):\n params, target = self._generate_params_target([1])\n sampler = Sampler()\n result = sampler.run(\n c... | [
"0.6926298",
"0.6844326",
"0.65808654",
"0.64677674",
"0.64463276",
"0.63522184",
"0.62838167",
"0.6224712",
"0.62038606",
"0.61977786",
"0.6191925",
"0.61900747",
"0.61691684",
"0.6144995",
"0.61292636",
"0.6105518",
"0.60740775",
"0.605795",
"0.5980819",
"0.59777087",
"0.59... | 0.7838827 | 0 |
Test teleportation as in tutorials | def test_teleport(self):
self.log.info('test_teleport')
pi = np.pi
shots = 2000
qr = QuantumRegister(3, 'qr')
cr0 = ClassicalRegister(1, 'cr0')
cr1 = ClassicalRegister(1, 'cr1')
cr2 = ClassicalRegister(1, 'cr2')
circuit = QuantumCircuit(qr, cr0, cr1, cr2, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teleport(self, agent_host, move_up):\n\n move_by = 4\n if move_up:\n tel_y= self.curr_y+move_by\n else:\n tel_y= self.curr_y-move_by\n tp_command = \"tp {} {} {}\".format(self.curr_x,tel_y,self.curr_z)\n #print(\"X,Y,Z----: {},{},{}\".format(self.curr_x,... | [
"0.64154094",
"0.6116679",
"0.60524917",
"0.5920475",
"0.58300376",
"0.58175176",
"0.5786501",
"0.5777824",
"0.57068455",
"0.57001305",
"0.567256",
"0.56699467",
"0.56529784",
"0.5641191",
"0.5601332",
"0.5596604",
"0.5578883",
"0.55724204",
"0.55621916",
"0.5547075",
"0.5543... | 0.664552 | 0 |
Check if file contents contains potentially malicious scripts | def is_file_containing_malicious_content(self, content: str, file_name: str):
for suspicious_string in self.stringsCausingSuspicions:
# if it's a regexp
if str(suspicious_string.__class__) == "<class '_sre.SRE_Pattern'>":
if len(suspicious_string.findall(content)) > 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_file(file):\n return file.endswith('.py')",
"def test_6_1_1_script_isfile(host):\n assert host.file(AUDIT_SYSTEM_SCRIPT).is_file",
"def is_js_file(fname):\r\n return REJS.search(fname) and \\\r\n TEST_INDICATOR not in fname",
"def allowed_code_file(filename):\n return '.' ... | [
"0.6459682",
"0.6125505",
"0.60841477",
"0.60508496",
"0.6039843",
"0.5953196",
"0.59159344",
"0.5843728",
"0.5819328",
"0.5814489",
"0.57866204",
"0.5785759",
"0.575395",
"0.57477343",
"0.5743713",
"0.57432175",
"0.5721233",
"0.571638",
"0.57074296",
"0.5701537",
"0.5692168"... | 0.7002745 | 0 |
Normalizes the input value between a and b | def normalizeToRange(v, a, b):
return (v - a) / (b - a) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalise(a, b):\n dy = b[1] - a[1]\n dx = b[0] - a[0]\n vector = (dy ** 2 + dx ** 2) ** 0.5\n # Normalise, round and cast to int\n dx = int(round(dx / vector))\n dy = int(round(dy / vector))\n \n return (dx, dy)",
"def normalize(self, factor):",
"def normalize(a, new_max=1.0):\n ... | [
"0.73133886",
"0.72756827",
"0.72715324",
"0.72277474",
"0.71215093",
"0.7071475",
"0.6914894",
"0.6854425",
"0.6828973",
"0.6812168",
"0.6810086",
"0.6793221",
"0.67737037",
"0.67714167",
"0.6674313",
"0.6660673",
"0.66357183",
"0.66268647",
"0.6608468",
"0.6604566",
"0.6600... | 0.78294766 | 0 |
add the individual elements of input vectors together such that a = [1, 2, 3] b = [3, 1, 2] returns [4, 3, 5] | def vectorAdd(a, b):
return [a[i] + b[i] for i, j in enumerate(a)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vector_sum(a, b):\n return a[0] + b[0], a[1] + b[1]",
"def vector_add(a, b):\n assert(len(a) == len(b))\n\n from operator import add\n return tuple(map(add, a, b))",
"def add_vectors(u, v): #11.22.5\r\n new_vector = []\r\n \"\"\"Because they have same length so we\r\n should take advan... | [
"0.8196496",
"0.79972655",
"0.7761827",
"0.7735001",
"0.7697612",
"0.7670196",
"0.76058555",
"0.7546141",
"0.752927",
"0.748474",
"0.7452506",
"0.7419544",
"0.7374155",
"0.7345036",
"0.7340425",
"0.73381585",
"0.72459424",
"0.716269",
"0.7106756",
"0.70690817",
"0.70615125",
... | 0.8270033 | 0 |
Given a start point, a normalized direction, and a distance, returns a point Distance away from Point along Direction | def getPointAwayFrom(startPoint, direction, distance):
x = vectorMultiply(direction, distance)
return vectorAdd(startPoint, x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance_from_point(self, pstart, p_end):\n a = numpy.array((pstart.x, pstart.y, pstart.z))\n b = numpy.array((p_end.x, p_end.y, p_end.z))\n\n distance = numpy.linalg.norm(a - b)\n\n return distance",
"def dist(self, point: np.array):\n return np.linalg.norm(\n ... | [
"0.6927091",
"0.6801812",
"0.6334007",
"0.630479",
"0.62662554",
"0.6253193",
"0.62369823",
"0.62275094",
"0.6216382",
"0.61950785",
"0.61929655",
"0.61823815",
"0.61805975",
"0.6173806",
"0.61560535",
"0.61286265",
"0.61158824",
"0.61145276",
"0.6091202",
"0.6085183",
"0.607... | 0.77925324 | 0 |
Swap empty space with puzzle symbol above it in the grid. y is the index of the tuple containing the empty space in grid, and x is index of empty space in it's tuple. | def swap_up(grid, y, x):
symbol = grid[y - 1][x]
# creates new tuples for the rows changed
new_toprow = grid[y - 1][:x] + tuple('*')
new_botrow = grid[y][:x] + tuple(symbol)
# adds the space after the swapped piece for both rows
if x < len(grid[y]):
new_toprow += tuple(grid[y - 1][x + ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_down(grid, y, x):\n symbol = grid[y + 1][x]\n\n new_botrow = grid[y + 1][:x] + ('*',)\n new_toprow = grid[y][:x] + (symbol,)\n\n if x < len(grid[y]):\n new_toprow += tuple(grid[y][x + 1:])\n new_botrow += tuple(grid[y + 1][x + 1:])\n\n return grid[:y] + (new_toprow, new_botrow... | [
"0.696965",
"0.6735839",
"0.64703715",
"0.6397285",
"0.61380106",
"0.607606",
"0.59848136",
"0.5904753",
"0.5846186",
"0.5727123",
"0.56595033",
"0.5636198",
"0.56330717",
"0.5625095",
"0.5558129",
"0.5525417",
"0.54873925",
"0.54723173",
"0.5454302",
"0.54322326",
"0.5431827... | 0.7374504 | 0 |
Swap empty space with puzzle symbol below it in the grid. y is the index of the tuple containing the empty space in grid, and x is index of empty space in it's tuple. | def swap_down(grid, y, x):
symbol = grid[y + 1][x]
new_botrow = grid[y + 1][:x] + ('*',)
new_toprow = grid[y][:x] + (symbol,)
if x < len(grid[y]):
new_toprow += tuple(grid[y][x + 1:])
new_botrow += tuple(grid[y + 1][x + 1:])
return grid[:y] + (new_toprow, new_botrow) + grid[y + 2:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_up(grid, y, x):\n symbol = grid[y - 1][x]\n\n # creates new tuples for the rows changed\n new_toprow = grid[y - 1][:x] + tuple('*')\n new_botrow = grid[y][:x] + tuple(symbol)\n\n # adds the space after the swapped piece for both rows\n if x < len(grid[y]):\n new_toprow += tuple(gr... | [
"0.74180424",
"0.66296875",
"0.6549329",
"0.6465497",
"0.6142597",
"0.6029525",
"0.5879505",
"0.5810912",
"0.57844555",
"0.5749099",
"0.5671146",
"0.56583124",
"0.55875087",
"0.5543172",
"0.55128974",
"0.5506123",
"0.5487629",
"0.5451147",
"0.54361534",
"0.5432416",
"0.541909... | 0.71059775 | 1 |
Swap empty space with puzzle symbol to the right of it in the grid. y is the index of the tuple containing the empty space in grid, and x is index of empty space in it's tuple. | def swap_right(grid, y, x):
symbol = grid[y][x + 1]
# creates a new tuple for the changed row
new_row = grid[y][:x] + (symbol,) + ('*',)
# adds the space after the swapped piece for the changed row
if x < len(grid[y]) - 2:
new_row += tuple(grid[y][x + 2:])
return grid[:y] + (new_row,)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_up(grid, y, x):\n symbol = grid[y - 1][x]\n\n # creates new tuples for the rows changed\n new_toprow = grid[y - 1][:x] + tuple('*')\n new_botrow = grid[y][:x] + tuple(symbol)\n\n # adds the space after the swapped piece for both rows\n if x < len(grid[y]):\n new_toprow += tuple(gr... | [
"0.73663217",
"0.72030604",
"0.68011993",
"0.6653473",
"0.60992813",
"0.59700453",
"0.5856919",
"0.57826674",
"0.57598525",
"0.5718073",
"0.57124233",
"0.57094514",
"0.56896",
"0.5682443",
"0.56505144",
"0.5583225",
"0.5578579",
"0.55665314",
"0.5561678",
"0.55576843",
"0.554... | 0.7315443 | 1 |
Swap empty space with puzzle symbol to the left of it in the grid. y is the index of the tuple containing the empty space in grid, and x is index of empty space in it's tuple. | def swap_left(grid, y, x):
symbol = grid[y][x - 1]
new_row = grid[y][:x - 1] + ('*',) + (symbol,)
if x < len(grid[y]) - 1:
new_row += grid[y][x + 1:]
return grid[:y] + (new_row,) + grid[y+1:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_up(grid, y, x):\n symbol = grid[y - 1][x]\n\n # creates new tuples for the rows changed\n new_toprow = grid[y - 1][:x] + tuple('*')\n new_botrow = grid[y][:x] + tuple(symbol)\n\n # adds the space after the swapped piece for both rows\n if x < len(grid[y]):\n new_toprow += tuple(gr... | [
"0.72094786",
"0.68437946",
"0.6833086",
"0.65959716",
"0.61538726",
"0.60560024",
"0.5920952",
"0.5818987",
"0.5784264",
"0.5751945",
"0.57293934",
"0.57154316",
"0.57044053",
"0.56647724",
"0.56304044",
"0.56044596",
"0.555539",
"0.5541564",
"0.5538938",
"0.55242604",
"0.55... | 0.7223119 | 0 |
Construct agg_endog on dept_store level | def construct_agg_endog(self):
agg_endog, ratio_df = construct_grouped_ts(self.sales_train, self.endog, agg_1='dept_id', agg_2='store_id', drop_inactive=True, return_ratio=True)
agg_sales_train = self.sales_train.groupby(['dept_id', 'store_id']).size().reset_index() #indicator for dept_store_id
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_aggregate_table(agg: str, dataset: ObservatoryDataset) -> List[Dict]:\n\n data = []\n repos = []\n for paper in dataset.papers:\n for author in paper.authors:\n inst = author.institution\n at = paper.access_type\n oa_coki = paper.oa_coki\n\n # Ch... | [
"0.51928",
"0.519098",
"0.5178761",
"0.50921845",
"0.5083517",
"0.5013119",
"0.49784026",
"0.49634597",
"0.48751375",
"0.48575234",
"0.4815863",
"0.48117444",
"0.48115775",
"0.48054242",
"0.47820938",
"0.47588515",
"0.4725788",
"0.4705937",
"0.46681166",
"0.4654781",
"0.46298... | 0.7497369 | 0 |
Load encoder_exog at timestamp (exog_index), dept_stores (exog_columns). encoder_exog with shape (n_ts, n_timestamp, n_features) Currently, no encoder exog is used for dept_store_level, thus is set all 0. | def load_encoder_exog(self, exog_index, exog_cols):
encoder_exog = np.zeros((exog_cols.shape[0], exog_index.shape[0], 1))
return(encoder_exog.astype(np.float32)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_decoder_exog(self, exog_index, exog_cols):\n decoder_exog = np.repeat(np.array(self.calendar_exog.loc[exog_index]).reshape((1,exog_index.shape[0],-1)), repeats=exog_cols.shape[0], axis=0)\n decoder_exog = np.concatenate([decoder_exog, np.array(self.snap_exog.loc[exog_index, exog_cols].T).res... | [
"0.75448066",
"0.61869884",
"0.50735664",
"0.50666195",
"0.5029381",
"0.4966422",
"0.49151808",
"0.48683658",
"0.48182648",
"0.47745952",
"0.47381002",
"0.47372207",
"0.47243765",
"0.47120556",
"0.46972522",
"0.4653973",
"0.4647424",
"0.46075404",
"0.46064758",
"0.4606467",
"... | 0.7274047 | 1 |
Load decoder_exog at timestamp (exog_index), dept_stores (exog_columns). decoder_exog with shape (n_ts, n_timestamp, n_features) | def load_decoder_exog(self, exog_index, exog_cols):
decoder_exog = np.repeat(np.array(self.calendar_exog.loc[exog_index]).reshape((1,exog_index.shape[0],-1)), repeats=exog_cols.shape[0], axis=0)
decoder_exog = np.concatenate([decoder_exog, np.array(self.snap_exog.loc[exog_index, exog_cols].T).reshape((e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_encoder_exog(self, exog_index, exog_cols):\n encoder_exog = np.zeros((exog_cols.shape[0], exog_index.shape[0], 1))\n return(encoder_exog.astype(np.float32))",
"def prepare_dataset_encoder(self):\n calendar, sales_train, prices_df = self.calendar, self.sales_train, self.prices_df\n ... | [
"0.6400031",
"0.549128",
"0.5342998",
"0.5310045",
"0.52799636",
"0.51366115",
"0.5101912",
"0.5084188",
"0.5063949",
"0.5024628",
"0.5011325",
"0.5000094",
"0.49920833",
"0.49706978",
"0.4955498",
"0.4926493",
"0.4926392",
"0.4908149",
"0.48982498",
"0.4852428",
"0.48472175"... | 0.8127291 | 0 |
Load event_id at timestamp (exog_index), dept_stores (exog_columns). event_name with shape (n_ts, n_timestamp). | def load_event_name(self, exog_index, exog_cols):
event_name = self.event_encoder.transform(self.calendar.loc[exog_index, 'event_name_1']).reshape((1,-1))
event_name = np.repeat(event_name, repeats=exog_cols.shape[0], axis=0)
return(event_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_decoder_exog(self, exog_index, exog_cols):\n decoder_exog = np.repeat(np.array(self.calendar_exog.loc[exog_index]).reshape((1,exog_index.shape[0],-1)), repeats=exog_cols.shape[0], axis=0)\n decoder_exog = np.concatenate([decoder_exog, np.array(self.snap_exog.loc[exog_index, exog_cols].T).res... | [
"0.6103134",
"0.5990384",
"0.58281827",
"0.57115626",
"0.5672822",
"0.56140965",
"0.5546844",
"0.5339346",
"0.51344454",
"0.5069847",
"0.5052246",
"0.5048571",
"0.4947652",
"0.49333274",
"0.48763838",
"0.485143",
"0.4815527",
"0.480106",
"0.4793264",
"0.4761636",
"0.47536895"... | 0.63991827 | 0 |
Build Vanilla LSTM encoderdecoder network. | def build_model(self):
num_layers, num_units, input_window, output_window, encoder_exog_size, decoder_exog_size, dropout_rate, l2_regu =\
self.num_layers, self.num_units, self.input_window, self.output_window, self.encoder_exog_size, self.decoder_exog_size, self.dropout_rate, self.l2_regu
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __build_mol_to_latent_model(self):\n\n # Input tensor (MANDATORY)\n encoder_inputs = Input(shape=self.input_shape, name=\"Encoder_Inputs\")\n\n x = encoder_inputs\n\n # The two encoder layers, number of cells are halved as Bidirectional\n encoder = Bidirectional(\n ... | [
"0.6820037",
"0.67112243",
"0.6623604",
"0.65783787",
"0.6512118",
"0.65099704",
"0.64977014",
"0.63607395",
"0.634724",
"0.6332607",
"0.63037586",
"0.62852144",
"0.6256251",
"0.6255645",
"0.6220524",
"0.62135637",
"0.620888",
"0.62087196",
"0.6197982",
"0.6101629",
"0.609685... | 0.6713481 | 1 |
Return forecast using input_endog. | def get_forecast(self, input_endog):
output_window = self.output_window
val_index = np.arange(input_endog.index[-1]+1, input_endog.index[-1]+1+output_window)
X_endog = input_endog.T.dropna().copy()
obs_items = X_endog.index #store_item pair that has complete input
first... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_predict_end(self, end):\n\n out_of_sample = 0 # will be overwritten if needed\n if end is None: # use data for ARIMA - endog changes\n end = len(self.data.endog) - 1\n\n dates = self.data.dates\n freq = self.data.freq\n\n if isinstance(end, str):\n ... | [
"0.62966007",
"0.5987943",
"0.571518",
"0.5691806",
"0.5684179",
"0.56726193",
"0.5672091",
"0.5671584",
"0.563833",
"0.55245525",
"0.53885925",
"0.5387731",
"0.5384682",
"0.5375867",
"0.53200275",
"0.5293495",
"0.5273004",
"0.52590513",
"0.52562207",
"0.5252408",
"0.5236556"... | 0.8307179 | 0 |
Detect collision between a rectangle and circle. | def collision(rleft, rtop, width, height, # rectangle definition
center_x, center_y, radius): # circle definition
global intX, intY
# complete boundbox of the rectangle
rright, rbottom = rleft + width, rtop + height
# bounding box of the circle
cleft, ctop = center_x-r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __circle_collision(self, circle):\n raise Exception('--- This methods have not been implemented yet! Use circle_collider instead ---')",
"def circles_collide(x1: float, y1: float, r1: float, x2: float, y2: float, r2: float) -> bool:\n return distance_between_sq(x1, y1, x2, y2) <= (r1 + r2)**2",
"... | [
"0.77753234",
"0.7718585",
"0.72119",
"0.71962464",
"0.71542555",
"0.71298283",
"0.71152836",
"0.70446295",
"0.691543",
"0.6855141",
"0.6847333",
"0.67994976",
"0.6798189",
"0.6795586",
"0.66961086",
"0.66861546",
"0.6671946",
"0.65710783",
"0.6566224",
"0.65465003",
"0.65379... | 0.83668697 | 0 |
Send an order/modif/cancel to the market | def _send_to_market(self, order, is_mine):
ord_type = order[self.col_idx['ordtype']]
if ord_type == "new":
self.mkt.send(is_buy=order[self.col_idx['is_buy']],
qty=order[self.col_idx['qty']],
price=order[self.col_idx['p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_send(self, symbol, style, volume, price_stop_loss, price_take_profit, comment, magic, features=None): # =MarketOrder()\n \n dt = get_datetime()\n price = self.data[symbol].price\n \n log.info(\"bo_blotter: order_send %s %s price=%s SL=%s TP=%s %s\" % (volume, symbol, pr... | [
"0.6762728",
"0.647902",
"0.6422314",
"0.63938046",
"0.6357052",
"0.63393205",
"0.6320198",
"0.62730086",
"0.61724967",
"0.6157658",
"0.61026967",
"0.6090159",
"0.6065455",
"0.6054261",
"0.60485345",
"0.60345185",
"0.6028087",
"0.59672505",
"0.59616095",
"0.5960345",
"0.59487... | 0.7360399 | 0 |
Move the market forward one tick (process next order) If the user has messages (new/cancel/modif) queued, it will decide whether to send a user or historical order based on their theoretical arrival time (timestamp) | def tick(self):
# next historical order to be sent
mktorder = self.hist_orders[self.mkt_idx+1]
# if I have queued orders
if self.my_queue:
# if my order reaches the market before the next historical order
if self.my_queue[0].timestamp < mktorder[self.col_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_tick(self, msg):\n message_type = msg['type']\n if 'sequence' not in msg:\n if message_type == 'subscriptions':\n # request an order book snapshot after the websocket feed is established\n print('Coinbase Subscriptions successful for : %s' % self.sym)\... | [
"0.6234445",
"0.61741984",
"0.6084046",
"0.59530133",
"0.59332037",
"0.5807359",
"0.57960933",
"0.5781202",
"0.57786",
"0.57753426",
"0.5773166",
"0.57452565",
"0.5744463",
"0.56984305",
"0.5681479",
"0.5674377",
"0.56380785",
"0.5613147",
"0.56096065",
"0.55684096",
"0.55490... | 0.79819286 | 0 |
Queue a user new order to be sent to the market when time is due | def queue_my_new(self, is_buy, qty, price):
self.my_last_uid -= 1
message = self.OrdTuple(ordtype="new",
uid=self.my_last_uid,
is_buy=is_buy,
qty=qty,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tick(self):\n \n # next historical order to be sent\n mktorder = self.hist_orders[self.mkt_idx+1]\n # if I have queued orders\n if self.my_queue:\n # if my order reaches the market before the next historical order\n if self.my_queue[0].timestamp < mktord... | [
"0.68102014",
"0.64660317",
"0.64283824",
"0.6401807",
"0.6256527",
"0.6240372",
"0.6207156",
"0.6180311",
"0.61682606",
"0.6147138",
"0.6145767",
"0.6132009",
"0.6068847",
"0.5979409",
"0.5953211",
"0.59475",
"0.5896322",
"0.5896322",
"0.5896322",
"0.58944386",
"0.5879047",
... | 0.679702 | 1 |
Returns the current mkt status of an order identified by its uid. | def ord_status(self, uid):
# TODO: use ticker to select market orderbook
return self.mkt.get(uid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_status(self, order_uuid):\n portfolio = self.get_portfolio_object()\n # only take complete orders\n orders = [order for order in portfolio.orders if order.order_uuid == order_uuid]\n if orders:\n order = orders[-1]\n return order.status\n return None... | [
"0.67004323",
"0.635158",
"0.62932646",
"0.6276117",
"0.6239673",
"0.59735906",
"0.5803745",
"0.56158584",
"0.55416226",
"0.5533915",
"0.55191296",
"0.54236466",
"0.54227835",
"0.52846724",
"0.522806",
"0.5186176",
"0.51838356",
"0.51838356",
"0.51838356",
"0.51725906",
"0.51... | 0.7893943 | 0 |
Compute the pixel error of the corresponding keypoints | def compute_pixel_err(pred_x, pred_y, gt_x, gt_y, imwidth, crop):
canonical_sz = 70
scale = canonical_sz / (imwidth - 2 * crop)
pred_x = pred_x * scale
pred_y = pred_y * scale
gt_x = gt_x * scale
gt_y = gt_y * scale
return np.sqrt((gt_x - pred_x)**2 + (gt_y - pred_y)**2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_square_error(input_img, output_img):\n rse = np.sqrt(np.sum(np.power(output_img - input_img, 2)))\n\n return rse",
"def calc_error_dist(self):\n pass",
"def __error(self, R, P, Q, K, beta):\n e = 0\n for i in xrange(len(R)):\n for j in xrange(len(R[i])):\n ... | [
"0.61242414",
"0.6060558",
"0.6023828",
"0.59681743",
"0.5867764",
"0.5859218",
"0.58545613",
"0.57950455",
"0.57770866",
"0.57720906",
"0.5771524",
"0.57699007",
"0.5763964",
"0.5750326",
"0.573165",
"0.57013786",
"0.56941974",
"0.56742144",
"0.5662502",
"0.5633745",
"0.5598... | 0.67416435 | 0 |
parameter sweep names/values in compact form | def labels(self):
param=self
l=len(param)
sweep_label=[]
for index,name in enumerate(param.names):
sweep_label.append((\
''.join([c for c in name if c.isupper()]))\
.replace("IDT","")\
.replace("S","")\
.replace("M",""))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameter_names(self) -> List[str]:",
"def flatten_parameters(self):",
"def paramDetails(cls):\n return {\n 'dim': (10, 20, 2, 20),\n 'nIter': (1, 10, 2, 5),\n 'lamb': (.1, 1., .1, .05),\n 'alph': (30, 50, 5, 40)\n }",
"def _cls_repr(self):\n ... | [
"0.5911144",
"0.57292724",
"0.5718404",
"0.5714987",
"0.5709971",
"0.5680104",
"0.56399965",
"0.56001055",
"0.5525521",
"0.54950786",
"0.54378587",
"0.5428696",
"0.5421627",
"0.54177386",
"0.54092795",
"0.5373104",
"0.5367285",
"0.5366399",
"0.5350676",
"0.53308094",
"0.53251... | 0.62087077 | 0 |
Combine two SweepParam. The parameters are combined with another SweepParam instance to generate a new SweepParam. If the instance has a length M and the parameter has a length N , resulting SweepParam will have length MxN. | def combine(self,sweep2):
sweep1=self
if not isinstance(sweep2,SweepParam):
raise ValueError("the parameter needs to be a SweepParam")
init_names=sweep1.names
new_names=sweep2.names
init_values=[]
for x in sweep1.values:
if isinstance(x,np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __add__(self, other: 'ModelParameters') -> 'ModelParameters':\n return ModelParameters([self[idx] + other[idx] for idx in range(len(self))])",
"def __radd__(self, other: 'ModelParameters') -> 'ModelParameters':\n return self.__add__(other)",
"def extend(self, other):\n overlap = [key f... | [
"0.5873824",
"0.56465286",
"0.5540291",
"0.5447841",
"0.5389237",
"0.5358258",
"0.5308901",
"0.52810967",
"0.5273042",
"0.5264155",
"0.5264155",
"0.51643217",
"0.5134226",
"0.5092758",
"0.50632066",
"0.50562054",
"0.5029355",
"0.4981182",
"0.49767885",
"0.49306467",
"0.492022... | 0.76385486 | 0 |
A pandas.DataFrame that represent all the parameters in PArray.device | def table(self):
param=self.x_param
device=self.device
base_params=device.get_params()
data_tot=DataFrame()
for i in range(len(param)):
print_index=1
for name in param.names:
device._set_params(param(i))
device.draw()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pandas(self):\n names,prior,posterior = [],[],[]\n for iname,name in enumerate(self.posterior_parameter.row_names):\n names.append(name)\n posterior.append(np.sqrt(float(\n self.posterior_parameter[iname, iname]. x)))\n iprior = self.parcov.row_name... | [
"0.6849395",
"0.64293045",
"0.6400187",
"0.63682944",
"0.6342038",
"0.6328716",
"0.6227246",
"0.6214504",
"0.6160134",
"0.61536926",
"0.61372817",
"0.6065142",
"0.6061857",
"0.60402805",
"0.60186565",
"0.60112226",
"0.5987733",
"0.59752315",
"0.59647155",
"0.5960611",
"0.5909... | 0.6891203 | 0 |
Generate automatically labels to attach to array cells. resulting labels are stored in "labels_top" and "labels_bottom" attributes. | def auto_labels(self,top=True,bottom=True,top_label='',bottom_label='',\
col_index=0,row_index=0):
param=self.x_param
top_label=[top_label+" "+ x for x in param.labels]
bottom_label=[bottom_label+"{:02d} x {:02d}".format(col_index,y) for y in range(row_index,row_index+len(param))]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autolabel(rects,array,axis,dist):\n ctr = 0\n label_array = [EM.truncate(v*100,1) for v in array]\n for entry in range(len(label_array)):\n if(label_array[entry]>=0) and (label_array[entry]<=1):\n label_array[entry] = EM.truncate(array[entry]*100,2)\n\n\n f... | [
"0.69725925",
"0.6728825",
"0.66664743",
"0.66598105",
"0.65748835",
"0.65733373",
"0.6559446",
"0.65413666",
"0.6500541",
"0.6498696",
"0.64960986",
"0.64840364",
"0.647242",
"0.6454908",
"0.6419941",
"0.641354",
"0.64103264",
"0.63884693",
"0.63884693",
"0.63884693",
"0.638... | 0.72019595 | 0 |
check if layer with index L_i is a layer lower than v's dependent index if true, L_i is not a valid layer for course v. | def has_dependent(self, L_i):
return self.dependentIndex==None or self.dependentIndex >= L_i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_cl_constraints(vector):\n\tglobal __cl_constraints\n\n\tfor con in __cl_constraints:\n\t\t# a vector is not allowed to hold for both\n\t\tif vector[con[0]] == 1 and vector[con[1]] == 1:\n\t\t\treturn False\n\treturn True",
"def component_piece_lower(index):\n i, t, k = index\n xmin = comp... | [
"0.55143213",
"0.5481485",
"0.5404945",
"0.53278077",
"0.5310819",
"0.53015536",
"0.5235135",
"0.521915",
"0.5146539",
"0.51066667",
"0.509961",
"0.5069351",
"0.50506",
"0.5031631",
"0.5015915",
"0.50061643",
"0.4986805",
"0.49610192",
"0.49486637",
"0.49297816",
"0.49165577"... | 0.63930285 | 0 |
tag that course with id 'cid' satisfy v's prereq OR set with index Bi | def tag_prereq(self, Bi, cid):
if Bi >= len(self.prereq) or cid not in self.prereq[Bi]:
raise Exception(
"Course {cid} not exists in OR set with index {Bi}".format(cid=cid, Bi=Bi))
self.prereqBool[Bi] = cid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_matching_course_indexes(self, query):\r\n return self.course_index.find(query)",
"def T(v,securite):\n to_return = {} #renvoie le dictionnaire {indice du contact (0 -> direct / sinon -> plus ou moins direct) : set({disque})} \n Cv = set(C(v,securite))\n Tv = set(Cv)\n i=0\n xv,... | [
"0.51670814",
"0.5086646",
"0.49947807",
"0.48174822",
"0.47873774",
"0.47358462",
"0.46620637",
"0.46118984",
"0.45816174",
"0.4563327",
"0.45620036",
"0.45105565",
"0.44940156",
"0.4493605",
"0.44824594",
"0.44758672",
"0.44754773",
"0.44749555",
"0.44587547",
"0.44321156",
... | 0.6560112 | 0 |
List all code readings, or create a new reading. | def reading_list(request):
if request.method == 'GET':
readings = Reading.objects.all()
serializer = ReadingSerializer(readings, many=True)
return Response(serializer.data)
elif request.method == 'POST':
serializer = ReadingSerializer(data=request.data)
if serializer.is_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_reads(cls) -> list:\n return [cls.FWREAD, cls.RVREAD];",
"def read_all(self):\r\n pass",
"def get_readings(self):\n\n return Readings(\n arduino=self.inputs.get_arduino_reading(),\n tapo=self.inputs.get_tapo_plug_reading(),\n garden=self.inputs.get... | [
"0.63985664",
"0.5793882",
"0.5761688",
"0.5644271",
"0.5628969",
"0.54702663",
"0.54576665",
"0.53569704",
"0.5144443",
"0.51227206",
"0.5087292",
"0.5066277",
"0.50593466",
"0.50306433",
"0.5030192",
"0.5014886",
"0.50122917",
"0.50112325",
"0.49763814",
"0.49056098",
"0.49... | 0.6159648 | 1 |
Test exceptions at pipeline level | def test_pipeline_error(time):
# test fit
df = _test_df()
def _func(df):
return df["num1"] == df["num3"]
pipeline = PdPipeline([ColByFrameFunc("Equality", _func), ColDrop("B")])
with pytest.raises(PipelineApplicationError):
pipeline.fit(df, verbose=True, time=time)
# test app... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invoke_processor_errors():\n\n def processor(app, documents):\n raise ValueError(\"something bad happened\")\n yield\n\n testapp = holocron.Application()\n testapp.add_processor(\"processor\", processor)\n testapp.add_pipe(\"test\", [{\"name\": \"processor\"}])\n\n stream = te... | [
"0.696629",
"0.6821481",
"0.66784084",
"0.6626683",
"0.6564704",
"0.6535647",
"0.6510281",
"0.64824855",
"0.6480367",
"0.6412341",
"0.6411471",
"0.6390847",
"0.63784766",
"0.6375952",
"0.63289636",
"0.6295979",
"0.6271767",
"0.62533396",
"0.62444544",
"0.62271756",
"0.6218167... | 0.7224575 | 0 |
Prints a separator to standart output. Optional length parameter defines how many characters the separator will consist of. Comes with an extra newline for increased readability. | def printSeparator(length=40):
logging.info(formatText("-" * length + "\n", True)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_section_delimiter(length=DEFAULT_LENGTH) -> None:\n print('='*length)",
"def _print_separator():\n print(\n \"───── ──────────────── ──────────────────────────────────────────────────────────────────────────────── ──────── ───────── ───── ──────── ──── ──── ──── ──── ... | [
"0.75847524",
"0.7112995",
"0.69336325",
"0.6724393",
"0.6669018",
"0.63386697",
"0.6214024",
"0.6116022",
"0.601394",
"0.5993874",
"0.5971108",
"0.5948834",
"0.59433085",
"0.59402794",
"0.58452433",
"0.58447677",
"0.5812377",
"0.5800336",
"0.5783507",
"0.5782023",
"0.5737818... | 0.85090715 | 0 |
Set the color of string s to the CLOSEST MATCH to color c. c is expected to be a list like with 3 integers as its items. | def colorText(s, c):
if not FORMATTING_AVAILABLE:
return s
HEAD = "\033["
TAIL = "m"
color = "39;49"
lastDifference = 800
for i in COLORS:
diff = abs(i[0] - c[0]) + abs(i[1] - c[1]) + abs(i[2] - c[2]) #calculates difference to stock color
if diff < lastDifference:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _color(self,c):\n return self.colorlist[c%len(self.colorlist)]",
"def mircColor(self, s, fg=None, bg=None):\n if fg is None and bg is None:\n return s\n elif bg is None:\n fg = self.mircColors[str(fg)]\n return '\\x03%s%s\\x03' % (fg.zfill(2), s)\n ... | [
"0.6247449",
"0.5833682",
"0.5591282",
"0.55455554",
"0.5502045",
"0.5501849",
"0.54304963",
"0.5416966",
"0.5401237",
"0.5394844",
"0.5387507",
"0.53824794",
"0.5380216",
"0.53772527",
"0.5364747",
"0.53561676",
"0.5346845",
"0.53449506",
"0.53247803",
"0.5321496",
"0.526581... | 0.6658775 | 0 |
Format the string s to be displayed as bold, underlined, negative or any combination of these. This function will automatically append a reset sequence after the text. Manually resetting the formatting is not necessary. | def formatText(s, bold=False, underlined=False, negative=False):
if not FORMATTING_AVAILABLE:
return s
head = ""
if bold: head += "\033[1m"
if underlined: head += "\033[4m"
if negative: head += "\033[7m"
return head + s + "\033[0m" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bold(string):\n return BOLD + string + RESETFORMAT",
"def bold(self, s):\n return '\\x02%s\\x02' % s",
"def bold(string):\n return BOLD + string + END",
"def bold(self, string):\n return self.wrap(bold(string))",
"def bold(msg):\n return '\\033[1m%s\\033[0m' % msg",
"def embold... | [
"0.74200016",
"0.73931444",
"0.65095335",
"0.64862657",
"0.62759024",
"0.62598115",
"0.6205859",
"0.6177458",
"0.61253005",
"0.59057105",
"0.5868853",
"0.58566475",
"0.5785357",
"0.5782194",
"0.5779407",
"0.576035",
"0.5745407",
"0.57070243",
"0.56860864",
"0.5685168",
"0.564... | 0.7816094 | 0 |
Deletes a User Object from the userList. Returns list | def deleteUser(self, userList, index):
if(self.adminAccess):
ret = userList.pop(index)
print("User has been deleted")
return userList | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_user(self):\n User.user_list.remove(self)",
"def delete_user(self):\n User.user_list.remove(self)",
"def delete_user(self):\n User.user_list.remove(self)",
"def delete_user(self):\n\n User.user_list.remove(self)",
"def delete_user():",
"def delete(self):\n\n ... | [
"0.7945344",
"0.7945344",
"0.7945344",
"0.7874968",
"0.73239255",
"0.72655916",
"0.71796215",
"0.70598745",
"0.6910753",
"0.6903936",
"0.68606716",
"0.6858181",
"0.6844352",
"0.6788512",
"0.67843497",
"0.6771759",
"0.67586803",
"0.6744388",
"0.671837",
"0.6703052",
"0.6680883... | 0.82633924 | 0 |
Imports mods List from disk Looks for mods.txt file and creates a list of Class objects Returns a list of Mods class objects if mods.txt exists else returns None | def importMods():
try:
with open("mods.txt", "r") as fp:
ModsList = []
for line in fp:
#expload string on comma
lineArray = line.split(",")
#Split each var up
name = lineArray[0].split(":")[1]
email = lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_modules(self, data: dict):\n\n v = Validator([(data[\"modules\"], list)])\n for module in data[\"modules\"]:\n mod_data = load_configuration(module)\n mod_path = Path(mod_data[\"path\"])\n self.__cache[mod_path.stem] = (\n load_class(\n ... | [
"0.59589136",
"0.5919964",
"0.57883304",
"0.5713228",
"0.5680105",
"0.56653875",
"0.56545734",
"0.5643083",
"0.559432",
"0.5591948",
"0.55810237",
"0.55806607",
"0.54854405",
"0.5479954",
"0.5475797",
"0.5451154",
"0.54316515",
"0.5427745",
"0.5424476",
"0.5419658",
"0.541910... | 0.7338112 | 0 |
Return the instructions for this Game. | def get_instructions(self) -> str:
instructions = "Players take turns to occupy available positions " \
"on the " \
"board. Once half or more of a ley-line has been " \
"occupied" \
"one player, that ley-line is entirely... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_instructions(self):\n return \"A non-negative whole number is chosen as the starting \\n\" \\\n \"valueby some neutral entity. In our case, a player will \\n\" \\\n \"choose it (i.e. through the use of input. The player whose \\n\" \\\n \"turn it is chooses ... | [
"0.7537964",
"0.7404567",
"0.6759493",
"0.66712695",
"0.66122705",
"0.63154495",
"0.5985097",
"0.5833046",
"0.58077806",
"0.57885665",
"0.5745979",
"0.5728191",
"0.56949335",
"0.56795263",
"0.5595347",
"0.5581683",
"0.55724883",
"0.547264",
"0.5459932",
"0.5457961",
"0.545093... | 0.7712404 | 0 |
Return whether player is the winner of the game. | def is_winner(self, player) -> bool:
return (self.current_state.get_current_player_name() != player
and self.is_over(self.current_state)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_winner(self, player):\n return (self.current_state.get_current_player_name() != player\n and self.is_over(self.current_state))",
"def is_winner(self):\n return self.winner",
"def winner(self):\n return self._fetch_element('winner') == 'true'",
"def is_winner(self):\... | [
"0.8397136",
"0.8132984",
"0.8101946",
"0.8044826",
"0.7906446",
"0.7795879",
"0.7764098",
"0.773107",
"0.76601756",
"0.76403075",
"0.76173764",
"0.7454074",
"0.74401104",
"0.743083",
"0.73032343",
"0.72994506",
"0.72927463",
"0.7289262",
"0.7287912",
"0.7260246",
"0.72597",
... | 0.8399962 | 0 |
Return the move that string represents. If string is not a move, return an invalid move. | def str_to_move(self, string):
if not string.strip().isalpha():
return -1
return string.strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str_to_move(self, string):\n if not string.strip().isdigit():\n return -1\n\n return int(string.strip())",
"def get_move() -> str:\n msg = 'Enter a move for that section (C to check, S to swap, R to rotate): '\n move = input(msg)\n while not wf.is_valid_move(move):\n ... | [
"0.7085393",
"0.6925762",
"0.677684",
"0.646239",
"0.6434038",
"0.64127743",
"0.6365554",
"0.63283306",
"0.63080925",
"0.62785333",
"0.6193179",
"0.6175988",
"0.6075098",
"0.6073601",
"0.6036474",
"0.59770846",
"0.59690195",
"0.5934326",
"0.59339803",
"0.59236306",
"0.5923513... | 0.7044586 | 1 |
Return an estimate in interval [LOSE, WIN] of best outcome the current player can guarantee from state self. | def rough_outcome(self) -> float:
if is_win(self):
return 1
elif is_lose(self):
return -1
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rough_outcome(self) -> float:\n # HUYNH YOU PRICK WHY THE FUCK DO YOU MAKE US WRITE THIS SHIT EVEN IT'S NOT USED ANYWHERE\n # pick move based on this may not be optimal but better than random\n # return 1 if win immediately\n # return -1 if all states reachable will result the other... | [
"0.73625016",
"0.7059583",
"0.7059583",
"0.7059583",
"0.7020939",
"0.6829376",
"0.6702647",
"0.6694379",
"0.66560304",
"0.6624065",
"0.6616302",
"0.6588654",
"0.6566183",
"0.6555869",
"0.6547012",
"0.6531186",
"0.6518109",
"0.6501664",
"0.6488798",
"0.6458663",
"0.6427033",
... | 0.7338502 | 1 |
Return a dash definition of an HTML table for a Pandas dataframe | def make_dash_table(df):
table = []
for index, row in df.iterrows():
html_row = []
for i in range(len(row)):
html_row.append(html.Td([row[i]]))
table.append(html.Tr(html_row))
return table | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dash_table(selection, df):\n\n df_subset = df.loc[df[\"NAME\"].isin(selection)]\n table = []\n\n for index, row in df_subset.iterrows():\n rows = []\n rows.append(html.Td([row[\"NAME\"]]))\n rows.append(html.Td([html.Img(src=row[\"IMG_URL\"])]))\n rows.append(html.Td([... | [
"0.7303146",
"0.7150178",
"0.71465176",
"0.7117627",
"0.68682384",
"0.6780832",
"0.6762202",
"0.67041314",
"0.6699682",
"0.6674215",
"0.66341263",
"0.6611604",
"0.6597323",
"0.64610684",
"0.64565516",
"0.64484704",
"0.64449763",
"0.64157796",
"0.6381783",
"0.63720167",
"0.636... | 0.76284516 | 0 |
Initialises the attributes and properties of the AsyncTabata. | async def init_device(self):
await Device.init_device(self)
# PROTECTED REGION ID(AsyncTabata.init_device) ENABLED START #
self.logger = logging.getLogger(__name__)
self._lock = threading.Lock()
self._dev_factory = DevFactory()
self._prepare = 10
self._work = 20
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _init(self, **kwargs):",
"async def init(self) -> None:",
"async def init(self) -> None:",
"def read_tabatas(self):\n # PROTECTED REGION ID(AsyncTabata.tabatas_read) ENABLED START #\n return self._tabatas\n # PROTECTED REGION END # // AsyncTabata.tabatas_read",
"async def... | [
"0.6283458",
"0.62262726",
"0.62262726",
"0.6223375",
"0.6218252",
"0.6105574",
"0.60600656",
"0.5998838",
"0.5786528",
"0.5765079",
"0.576342",
"0.57501346",
"0.5742235",
"0.5742235",
"0.5742235",
"0.5742235",
"0.5742235",
"0.5742235",
"0.5742235",
"0.5742235",
"0.5742235",
... | 0.65999895 | 0 |
Set the rest attribute. | def write_rest(self, value):
# PROTECTED REGION ID(AsyncTabata.rest_write) ENABLED START #
if value < 1:
raise Exception("only positive value!")
if self.get_state() == DevState.ON:
raise Exception("cannot change values when device is running!")
with self._lock:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, rest=AuthenticatingRestProxy(RestRequests())):\n self._rest = rest",
"def rest(self):\n\t\tpass",
"def apply_restoffset(armature, hipbone, restoffset):\r\n # apply rest offset to restpose\r\n bpy.context.scene.objects.active = armature\r\n bpy.ops.object.mode_set(mode='EDIT')... | [
"0.5630176",
"0.5530816",
"0.5378598",
"0.533996",
"0.53326255",
"0.5315345",
"0.5179512",
"0.50836456",
"0.5040169",
"0.4995078",
"0.49613616",
"0.49500024",
"0.4906609",
"0.49053308",
"0.4878314",
"0.48509192",
"0.48429102",
"0.48362812",
"0.48314637",
"0.4826485",
"0.48165... | 0.614358 | 0 |
Set the tabatas attribute. | def write_tabatas(self, value):
# PROTECTED REGION ID(AsyncTabata.tabatas_write) ENABLED START #
if value < 1:
raise Exception("only positive value!")
if self.get_state() == DevState.ON:
raise Exception("cannot change values when device is running!")
with self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetTrSet(self,value):\n self.ds = value",
"def set_table_attributes(self, attributes):\n self._dirty = True\n if attributes is not None:\n for k, v in attributes.iteritems():\n _key_guard(k, 'Attribute name')\n _str_guard(v, 'Attribute value')\n ... | [
"0.5949225",
"0.58843",
"0.58466774",
"0.57466394",
"0.5741959",
"0.5723373",
"0.5706781",
"0.56966734",
"0.564866",
"0.564174",
"0.564174",
"0.56349164",
"0.56261563",
"0.5615866",
"0.5553884",
"0.5537831",
"0.55232215",
"0.54708886",
"0.54633045",
"0.5443665",
"0.54405147",... | 0.6633607 | 0 |
Return the running_state attribute. | async def read_running_state(self):
# PROTECTED REGION ID(AsyncTabata.running_state_read) ENABLED START #
return self._running_state
# PROTECTED REGION END # // AsyncTabata.running_state_read | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running_state(self) -> int | None:\n return self.cluster.get(\"running_state\")",
"def state(self) -> RunState:\n return self._async_scheduler.state",
"def running(self): # type: () -> bool\n return self.state['Running']",
"def get_state(self):\n return self.state",
"def ge... | [
"0.82891697",
"0.762371",
"0.7526244",
"0.7523861",
"0.7523861",
"0.7504188",
"0.75040936",
"0.75001734",
"0.75001734",
"0.74893653",
"0.74893653",
"0.74893653",
"0.74893653",
"0.74893653",
"0.74570817",
"0.74570817",
"0.74570817",
"0.7450113",
"0.7433477",
"0.7433477",
"0.74... | 0.8102592 | 1 |
Main function of the AsyncTabata module. | def main(args=None, **kwargs):
# PROTECTED REGION ID(AsyncTabata.main) ENABLED START #
debugpy.listen(5678)
kwargs.setdefault("green_mode", GreenMode.Asyncio)
return run((AsyncTabata,), args=args, **kwargs)
# AsyncTabata.run_server()
# PROTECTED REGION END # // AsyncTabata.main | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n tng.api.runner()",
"def main():\n # Get credentials.\n logging.info('Obtaining Mega login credentials.')\n credentials = {}\n if os.path.exists(CREDENTIALS_FILE):\n credentials = json.load(open(CREDENTIALS_FILE))\n else:\n credentials['user'] = raw_input('User: ')\n ... | [
"0.62526685",
"0.5965609",
"0.5924747",
"0.59186465",
"0.5900263",
"0.5821848",
"0.58118916",
"0.58106273",
"0.5798",
"0.5766722",
"0.57555044",
"0.5747025",
"0.57421297",
"0.5733062",
"0.5727855",
"0.5694739",
"0.56915116",
"0.56727445",
"0.56583554",
"0.56498504",
"0.563463... | 0.83177817 | 0 |
Iterator for subsample annealing, yielding (action, arg) pairs. This generates a subsample annealing schedule starting from an empty assignment state (no rows are assigned). It then interleaves 'add_row' and 'remove_row' actions so as to gradually increase the number of assigned rows. The increase rate is linear. | def make_annealing_schedule(num_rows, epochs, sample_tree_rate):
assert epochs >= 1.0
assert sample_tree_rate >= 1.0
# Randomly shuffle rows.
row_ids = list(range(num_rows))
np.random.shuffle(row_ids)
row_to_add = itertools.cycle(row_ids)
row_to_remove = itertools.cycle(row_ids)
# Use a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_agent(bandit, iterations):\n\n for i in range(iterations):\n a = random.choice(bandit.actions)\n r = bandit.sample(a)\n yield a, r",
"def initial_explore_agent(bandit, iterations, initial_rounds = 10):\n pay_offs = dict()\n best_action = -1\n\n for i in range(iteration... | [
"0.5455643",
"0.5289078",
"0.5249597",
"0.5138517",
"0.5060755",
"0.5059422",
"0.5056093",
"0.50501776",
"0.5032908",
"0.49953273",
"0.4981477",
"0.49236384",
"0.49223185",
"0.49203786",
"0.49098432",
"0.49025986",
"0.48921928",
"0.4862368",
"0.4837989",
"0.4807904",
"0.48005... | 0.6056993 | 0 |
Remove a given row from the current subsample. | def remove_row(self, row_id): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteRow(self, row):\n if (row >= self._height or row <= -self.height):\n raise IndexError('Invalid index, row %d does not exist' % row)\n self._height -= 1\n return self._value.pop(row)",
"def delete_sample(self, rows):\n if not isinstance(rows, (list, tuple)):\n ... | [
"0.76017517",
"0.75120515",
"0.74128586",
"0.7357161",
"0.7258305",
"0.7201727",
"0.72012454",
"0.69447654",
"0.693629",
"0.6813859",
"0.6812815",
"0.6581558",
"0.6556254",
"0.6554288",
"0.635864",
"0.6341568",
"0.63035554",
"0.62991357",
"0.62884134",
"0.62074757",
"0.616514... | 0.7742161 | 0 |
Compute edge log probabilities on the complete graph. | def compute_edge_logits(self): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_edge_logits(self):\n V, E, K, M = self._VEKM\n vert_logits = logprob_dc(self._vert_ss, self._vert_prior, axis=1)\n if len(self._added_rows) == V:\n assignments = self._assignments\n else:\n assignments = self._assignments[sorted(self._added_rows), :]\n ... | [
"0.7335508",
"0.71378374",
"0.7127644",
"0.7103969",
"0.70094013",
"0.67944485",
"0.6733487",
"0.6730886",
"0.63937724",
"0.6335503",
"0.6307681",
"0.62550616",
"0.62338877",
"0.6196325",
"0.6193061",
"0.6187027",
"0.6134781",
"0.61287415",
"0.6126551",
"0.6121182",
"0.612118... | 0.78942937 | 0 |
Set edges of the latent structure and update statistics. | def set_edges(self, edges):
self._tree.set_edges(edges)
self._program = make_propagation_program(self._tree.tree_grid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_edges(self, edges):\n assert len(edges) == self._num_edges\n self._tree_grid = make_tree(edges)",
"def edges(self, edges):\n\n self._edges = edges",
"def edges(self, e):\n self._edges = e",
"def refresh_metadata(self):\n #self.node_index = None\n #self.edge_i... | [
"0.65527594",
"0.6314186",
"0.6303436",
"0.6144085",
"0.609869",
"0.59172857",
"0.58231676",
"0.580853",
"0.580853",
"0.58068633",
"0.5789417",
"0.5767009",
"0.5761213",
"0.57139456",
"0.5707714",
"0.5707328",
"0.5633258",
"0.5617545",
"0.56172055",
"0.55140746",
"0.54579234"... | 0.6691929 | 0 |
Train a TreeCat model using subsampleannealed MCMC. Let N be the number of data rows and V be the number of features. | def train_model(table, tree_prior, config):
assert isinstance(table, Table)
M = config['model_num_clusters']
D = config['model_latent_dim']
assert M >= 1
assert D >= 0
if D == 0:
Trainer = TreeCatTrainer
elif M == 1:
Trainer = TreeGaussTrainer
else:
Trainer = Tree... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self, X, T, *args, **kwargs):\n\n assert len(self.neurons) > 0, \"Add neurons to ELM before training it\"\n X, T = self._checkdata(X, T)\n args = [a.upper() for a in args] # make all arguments upper case\n\n # kind of \"enumerators\", try to use only inside that script\n ... | [
"0.5764085",
"0.5691527",
"0.5678574",
"0.56131625",
"0.56115055",
"0.55656296",
"0.55542564",
"0.54764485",
"0.5473188",
"0.54617053",
"0.545335",
"0.5446527",
"0.5414085",
"0.5401629",
"0.5398226",
"0.5394197",
"0.53737515",
"0.5329471",
"0.5315939",
"0.5309096",
"0.5297996... | 0.57309794 | 1 |
Train a TreeCat ensemble model using subsampleannealed MCMC. The ensemble size is controlled by config['model_ensemble_size']. Let N be the number of data rows and V be the number of features. | def train_ensemble(table, tree_prior, config):
tasks = []
for sub_seed in range(config['model_ensemble_size']):
sub_config = config.copy()
sub_config['seed'] += sub_seed
tasks.append((table, tree_prior, sub_config))
return parallel_map(_train_model, tasks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_model(table, tree_prior, config):\n assert isinstance(table, Table)\n M = config['model_num_clusters']\n D = config['model_latent_dim']\n assert M >= 1\n assert D >= 0\n if D == 0:\n Trainer = TreeCatTrainer\n elif M == 1:\n Trainer = TreeGaussTrainer\n else:\n ... | [
"0.5890479",
"0.5852123",
"0.5740387",
"0.56975913",
"0.5632382",
"0.5611414",
"0.5605243",
"0.559962",
"0.5548124",
"0.5522018",
"0.54916924",
"0.5475484",
"0.54413205",
"0.5394088",
"0.53637904",
"0.5348193",
"0.53204775",
"0.53113496",
"0.5287788",
"0.5278241",
"0.5258622"... | 0.6676452 | 0 |
Prepare mock axis device. | def setup_mock_axis_device(mock_device):
def mock_constructor(host, username, password, port, web_proto):
"""Fake the controller constructor."""
mock_device.host = host
mock_device.username = username
mock_device.password = password
mock_device.port = port
return moc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n serial_number = os.environ.get(\"ANDROID_SERIAL\", \"\")\n self.assertTrue(serial_number, \"$ANDROID_SERIAL is empty\")\n self._dut = utils.AndroidDevice(serial_number)\n self._temp_dir = tempfile.mkdtemp()",
"def setUp(self):\n # Initialize runtime and MDK:\... | [
"0.6203854",
"0.6130477",
"0.61156213",
"0.6057996",
"0.60288376",
"0.5934885",
"0.5909151",
"0.5903352",
"0.5903352",
"0.5896112",
"0.5729406",
"0.572272",
"0.5654188",
"0.56205124",
"0.56069463",
"0.55872035",
"0.5541387",
"0.55159056",
"0.55146474",
"0.5496942",
"0.548481"... | 0.7789957 | 0 |
Test that config flow fails on already configured device. | async def test_flow_fails_already_configured(hass):
await setup_axis_integration(hass)
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, context={"source": "user"}
)
assert result["type"] == "form"
assert result["step_id"] == "user"
mock_device = Mock()
mock_device.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_flow_fails_device_unavailable(hass):\n result = await hass.config_entries.flow.async_init(\n AXIS_DOMAIN, context={\"source\": \"user\"}\n )\n\n assert result[\"type\"] == \"form\"\n assert result[\"step_id\"] == \"user\"\n\n with patch(\n \"homeassistant.components.axis... | [
"0.74356383",
"0.73405707",
"0.72267395",
"0.71680635",
"0.71155447",
"0.70965385",
"0.7008849",
"0.6952568",
"0.6942624",
"0.68808776",
"0.681458",
"0.6776411",
"0.67762613",
"0.67712814",
"0.67666835",
"0.6760448",
"0.6755732",
"0.6752877",
"0.6749037",
"0.67176473",
"0.671... | 0.7511206 | 0 |
Test that config flow fails on faulty credentials. | async def test_flow_fails_faulty_credentials(hass):
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, context={"source": "user"}
)
assert result["type"] == "form"
assert result["step_id"] == "user"
with patch(
"homeassistant.components.axis.config_flow.get_device",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_wrong_credentials(hass: HomeAssistant, auth_error) -> None:\n\n result = await hass.config_entries.flow.async_init(\n DOMAIN, context={\"source\": config_entries.SOURCE_USER}\n )\n result = await hass.config_entries.flow.async_configure(\n result[\"flow_id\"], user_input=DEMO_... | [
"0.7291825",
"0.7233659",
"0.72253406",
"0.713346",
"0.698576",
"0.69655895",
"0.6949671",
"0.6947241",
"0.6866848",
"0.68621117",
"0.67381537",
"0.6731365",
"0.67082274",
"0.67070335",
"0.6667081",
"0.66505986",
"0.6649751",
"0.66385955",
"0.66336507",
"0.6627732",
"0.661768... | 0.75161356 | 0 |
Test that config flow fails on device unavailable. | async def test_flow_fails_device_unavailable(hass):
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, context={"source": "user"}
)
assert result["type"] == "form"
assert result["step_id"] == "user"
with patch(
"homeassistant.components.axis.config_flow.get_device",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_discovery_cannot_connect(hass: HomeAssistant) -> None:\n\n result = await hass.config_entries.flow.async_init(\n DOMAIN, context={\"source\": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY\n )\n\n with patch(\n \"homeassistant.components.volumio.config_flow.Volumio.get_s... | [
"0.75799346",
"0.72134066",
"0.7075894",
"0.7028792",
"0.69954795",
"0.69336754",
"0.6879549",
"0.6869652",
"0.68623453",
"0.67691606",
"0.6765397",
"0.6748087",
"0.6701084",
"0.6691128",
"0.6680153",
"0.666488",
"0.6664693",
"0.66570556",
"0.66200376",
"0.66153383",
"0.66106... | 0.7890586 | 0 |
Test that zeroconf doesn't setup already configured devices. | async def test_zeroconf_flow_already_configured(hass):
device = await setup_axis_integration(hass)
assert device.host == "1.2.3.4"
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN,
data={
CONF_HOST: "1.2.3.4",
CONF_PORT: 80,
"hostname": "na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_zeroconf_flow_ignore_non_axis_device(hass):\n result = await hass.config_entries.flow.async_init(\n AXIS_DOMAIN,\n data={CONF_HOST: \"169.254.3.4\", \"properties\": {\"macaddress\": \"01234567890\"}},\n context={\"source\": \"zeroconf\"},\n )\n\n assert result[\"type\"]... | [
"0.73716295",
"0.67429394",
"0.6723391",
"0.6692479",
"0.66662824",
"0.6579568",
"0.6536504",
"0.6461837",
"0.6448547",
"0.6438222",
"0.640726",
"0.63816595",
"0.6362343",
"0.63232577",
"0.6290591",
"0.62892056",
"0.62886274",
"0.6288221",
"0.62845814",
"0.6267767",
"0.625843... | 0.70707625 | 1 |
Test that zeroconf update configuration with new parameters. | async def test_zeroconf_flow_updated_configuration(hass):
device = await setup_axis_integration(hass)
assert device.host == "1.2.3.4"
assert device.config_entry.data == {
CONF_HOST: "1.2.3.4",
CONF_PORT: 80,
CONF_USERNAME: "username",
CONF_PASSWORD: "password",
CONF_M... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_config_change():\n clean_tables()\n config = set_configuration()\n assert config['age']['value'] == \"72\"\n assert config['retainUnsent']['value'] == \"False\" \n\n config = update_configuration(age=0, retain_unsent=True) \n assert config['age']['value'] == \"0\" \n assert config['re... | [
"0.74773693",
"0.68819016",
"0.68549144",
"0.67588663",
"0.6580001",
"0.6533839",
"0.65206283",
"0.6513456",
"0.6498106",
"0.64885044",
"0.6440535",
"0.63835275",
"0.6379493",
"0.6356896",
"0.63532597",
"0.6345493",
"0.6337596",
"0.63324106",
"0.6322648",
"0.6310894",
"0.6289... | 0.75051427 | 0 |
Test that zeroconf doesn't setup devices with link local addresses. | async def test_zeroconf_flow_ignore_non_axis_device(hass):
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN,
data={CONF_HOST: "169.254.3.4", "properties": {"macaddress": "01234567890"}},
context={"source": "zeroconf"},
)
assert result["type"] == "abort"
assert res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_zeroconf_flow_ignore_link_local_address(hass):\n result = await hass.config_entries.flow.async_init(\n AXIS_DOMAIN,\n data={CONF_HOST: \"169.254.3.4\", \"properties\": {\"macaddress\": MAC}},\n context={\"source\": \"zeroconf\"},\n )\n\n assert result[\"type\"] == \"abo... | [
"0.78429693",
"0.6549009",
"0.6358573",
"0.6343826",
"0.6260517",
"0.61632603",
"0.6110315",
"0.60799307",
"0.60784996",
"0.6070055",
"0.60690004",
"0.60521615",
"0.60289437",
"0.6003446",
"0.6001084",
"0.5969774",
"0.59526634",
"0.5932165",
"0.5916638",
"0.5881482",
"0.58779... | 0.67138004 | 1 |
Test that zeroconf doesn't setup devices with link local addresses. | async def test_zeroconf_flow_ignore_link_local_address(hass):
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN,
data={CONF_HOST: "169.254.3.4", "properties": {"macaddress": MAC}},
context={"source": "zeroconf"},
)
assert result["type"] == "abort"
assert result["re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_zeroconf_flow_ignore_non_axis_device(hass):\n result = await hass.config_entries.flow.async_init(\n AXIS_DOMAIN,\n data={CONF_HOST: \"169.254.3.4\", \"properties\": {\"macaddress\": \"01234567890\"}},\n context={\"source\": \"zeroconf\"},\n )\n\n assert result[\"type\"]... | [
"0.67150563",
"0.65487766",
"0.6360014",
"0.63443345",
"0.62614197",
"0.61634874",
"0.6111507",
"0.6079837",
"0.6078594",
"0.6070826",
"0.60689676",
"0.6052472",
"0.60288805",
"0.6003452",
"0.6002379",
"0.59703135",
"0.5953911",
"0.5933855",
"0.5916576",
"0.58817863",
"0.5877... | 0.7843846 | 0 |
Creates a request for get trading balance. Requires the "Orderbook, History, Trading balance" API key Access Right. | def create_get_trading_balance_request(self) -> Request:
method = "GET"
path = "/trading/balance"
url = URL(self._create_url(path))
params: Params = {}
url = url.with_query(params)
headers = self._auth.sign(
method=method, url_path=url.path, url_query=url.qu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_balance(self, custom_id=None, **params):\n self.conn.send('getTradingBalance', custom_id=custom_id, **params)",
"def get_balance(self):\n r = requests.get(build_api_call(self.base_url, None, 'balance', ''), auth=HTTPBasicAuth(KEY, SECRET))\n if r.status_code == 200:\n ... | [
"0.7478715",
"0.646901",
"0.63921934",
"0.6359884",
"0.62434274",
"0.6177274",
"0.59944075",
"0.5980043",
"0.59507793",
"0.5931746",
"0.58371425",
"0.5812701",
"0.581053",
"0.5784304",
"0.57724154",
"0.5724659",
"0.57242286",
"0.56600153",
"0.56398743",
"0.5591215",
"0.558944... | 0.80611444 | 0 |
Creates a request for get active orders. Requires the "Place/cancel orders" API key Access Right. | def create_get_active_orders_request(self, symbol: Optional[Symbol] = None) -> Request:
method = "GET"
path = "/order"
params: Params = {}
if symbol is not None:
params["symbol"] = symbol
url = URL(self._create_url(path))
url = url.with_query(params)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_active_orders(self, custom_id=None, **params):\n self.conn.send('getOrders', custom_id=custom_id, **params)",
"def request_orders(self):\r\n if self.use_http():\r\n self.enqueue_http_request(\"money/orders\", {}, \"orders\")\r\n else:\r\n self.send_signed_ca... | [
"0.7395109",
"0.70004517",
"0.6780944",
"0.6571053",
"0.6547748",
"0.6519316",
"0.6504723",
"0.64073473",
"0.63162017",
"0.6253162",
"0.6105293",
"0.6073689",
"0.6062765",
"0.5981852",
"0.59570843",
"0.5870386",
"0.5839957",
"0.58313495",
"0.5808574",
"0.58009",
"0.5772646",
... | 0.7347726 | 1 |
Creates a request for cancel orders endpoint. Requires the "Place/cancel orders" API key Access Right. | def create_cancel_orders_request(self, symbol: Optional[Symbol] = None) -> Request:
method = "DELETE"
path = f"/order"
url = URL(self._create_url(path))
params: Params = {}
if symbol is not None:
params["symbol"] = symbol
url = url.with_query(params)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_cancel_order_request(self, client_order_id: str) -> Request:\n\n method = \"DELETE\"\n path = f\"/order/{client_order_id}\"\n url = URL(self._create_url(path))\n\n params: Params = {}\n url = url.with_query(params)\n\n headers = self._auth.sign(\n met... | [
"0.6977676",
"0.6641356",
"0.6572583",
"0.6490388",
"0.6354798",
"0.6248779",
"0.6243973",
"0.6240855",
"0.6232378",
"0.62219054",
"0.6180212",
"0.61791486",
"0.61666495",
"0.61602354",
"0.6125321",
"0.6097856",
"0.60727555",
"0.60603887",
"0.60504097",
"0.60332423",
"0.60234... | 0.74875134 | 0 |
Creates a request for cancel order endpoint. Requires the "Place/cancel orders" API key Access Right. | def create_cancel_order_request(self, client_order_id: str) -> Request:
method = "DELETE"
path = f"/order/{client_order_id}"
url = URL(self._create_url(path))
params: Params = {}
url = url.with_query(params)
headers = self._auth.sign(
method=method, url_pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_cancel_orders_request(self, symbol: Optional[Symbol] = None) -> Request:\n\n method = \"DELETE\"\n path = f\"/order\"\n url = URL(self._create_url(path))\n\n params: Params = {}\n if symbol is not None:\n params[\"symbol\"] = symbol\n url = url.with_q... | [
"0.74667805",
"0.6814739",
"0.65435386",
"0.64910775",
"0.63818395",
"0.6327267",
"0.63135856",
"0.63040006",
"0.63021636",
"0.62851006",
"0.6268942",
"0.6267777",
"0.62616944",
"0.62519264",
"0.62420887",
"0.62206006",
"0.622041",
"0.62126046",
"0.62126046",
"0.62126046",
"0... | 0.71531564 | 1 |
Container to configure 3D plot, i.e colormapping | def plot_config_3d(view, trace, marker_names):
if view == "3D Plot":
with st.expander("3D Plot Configuration", expanded=True):
col_plot_type, col_grid_res, col_fill, col_interp = st.columns(4)
col_col_type, col_choice, col_preview, col_overlay = st.columns(4)
trace["Char... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_plot():\n fig = plt.figure(constrained_layout=True, figsize=(7,9), dpi=130)\n gs = fig.add_gridspec(5, 1)\n ax2 = fig.add_subplot(gs[:1, :])\n ax1 = fig.add_subplot(gs[1:, :], projection='3d')\n\n tick_color = (0.2, 0.2, 0.2, 1.0)\n pane_color = (0.12, 0.12, 0.12, 1.0)\n ax1.w_xaxis.s... | [
"0.70101243",
"0.6881151",
"0.6811236",
"0.67459273",
"0.66721",
"0.6604098",
"0.6516716",
"0.64925385",
"0.6487245",
"0.64215606",
"0.6397657",
"0.636553",
"0.63541204",
"0.63450056",
"0.6343613",
"0.62795347",
"0.6222476",
"0.6220117",
"0.62002784",
"0.6191841",
"0.6178734"... | 0.6949409 | 1 |
Returns True if there's a repeat in column n | def col_repeat(self, board, n):
this_col = []
for i, x in enumerate(board):
if i % 12 == n:
this_col.append(x)
# println("col "+str(n))
# println(this_col)
for letter in 'abcdef':
if this_col.count(letter) > 1:
# pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_col(sudoku):\r\n for col in range(9):\r\n for row in range(8):\r\n test = sudoku[row][col]\r\n for i in range(row+1,9):\r\n if sudoku[i][col] == test:\r\n return True #returns True is there is more than two of the same numbers in a column\... | [
"0.7043869",
"0.6976969",
"0.6894629",
"0.6694764",
"0.661783",
"0.6513339",
"0.64967775",
"0.64636016",
"0.6400933",
"0.6364203",
"0.6359629",
"0.6325058",
"0.63167566",
"0.6282769",
"0.62749267",
"0.62481886",
"0.62461656",
"0.624436",
"0.619371",
"0.618974",
"0.6165413",
... | 0.7761181 | 0 |
REturns True if there's a repeat in 3x3 block n | def block_repeat(self, board, n):
this_block = []
row_start = 3 * (n // 4)
col_start = 3 * (n % 4)
for r in range(3):
this_row = board[(12 * (row_start + r) + col_start):(12 * (row_start + r) + col_start + 3)]
for x in this_row:
this_block.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_fivefold_repetition(self) -> bool:\n return self.is_repetition(3)",
"def answer_ok(a):\n (rightly_positioned, permutated) = a\n if (rightly_positioned + permutated > number_of_positions) \\\n or (rightly_positioned + permutated < len(colours) - number_of_positions):\n return False\n ... | [
"0.660592",
"0.6549456",
"0.6492034",
"0.6472273",
"0.64570206",
"0.64001465",
"0.6373682",
"0.6357246",
"0.63565445",
"0.6317953",
"0.6310353",
"0.63013834",
"0.62700784",
"0.62675667",
"0.62305206",
"0.6215564",
"0.6173477",
"0.61486995",
"0.6148334",
"0.61291665",
"0.61206... | 0.7840495 | 0 |
Test number of records in Department table | def test_department_model(self):
self.assertEqual(Department.query.count(), 3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_count(self):\r\n assert self.table.objects.count() == 12\r\n\r\n q = self.table.objects(test_id=0)\r\n assert q.count() == 4",
"def test_number_of_records_for_spell(self):\n records = self.admitgen.data.findall('record')\n self.assertEqual(9, len(records),\n ... | [
"0.62203896",
"0.5982845",
"0.59480697",
"0.5862384",
"0.58320177",
"0.5715334",
"0.56990075",
"0.5692022",
"0.566264",
"0.5654501",
"0.56526834",
"0.5624333",
"0.5583349",
"0.55637956",
"0.5535726",
"0.5500543",
"0.5476498",
"0.5445695",
"0.5443733",
"0.5439879",
"0.5430316"... | 0.7332401 | 0 |
Test number of records in Employee table | def test_employee_model(self):
self.assertEqual(Employee.query.count(), 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testGetEmpCount(self):\n\tself.assertEqual(Employee.getEmpCount(),1) # test getEmpCount() whether return correct answer",
"def employees_count(self, obj):\n return obj.employees_count()",
"def test_count(self):\r\n assert self.table.objects.count() == 12\r\n\r\n q = self.table.objec... | [
"0.6884496",
"0.68361723",
"0.6434314",
"0.6396647",
"0.63903815",
"0.6369274",
"0.61661106",
"0.6060245",
"0.5996377",
"0.5972735",
"0.58855087",
"0.58750457",
"0.5851834",
"0.58493793",
"0.5823841",
"0.57912415",
"0.5771921",
"0.57699734",
"0.57473636",
"0.5741941",
"0.5711... | 0.72737366 | 0 |
Test API can create a department (POST request) | def test_department_creation(self):
res = self.client().post(service_url, json={"dep_name": "test dep 4", "description": "testing department 4"})
self.assertEqual(res.status_code, 201)
self.assertIn('dep 4', str(res.data)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post():\n\n logger.debug('Catch POST request by URL /api/departments.')\n args = department_args.parse_args()\n try:\n id_ = ds.add(name=args['name'], email=args['email'])\n created_department = ds.get(id_)\n except IntegrityError:\n return {'message... | [
"0.801832",
"0.7346861",
"0.7263449",
"0.7247853",
"0.7096167",
"0.70810187",
"0.6990688",
"0.68851185",
"0.68181944",
"0.6713173",
"0.6675945",
"0.6634122",
"0.66043496",
"0.65878016",
"0.6573157",
"0.6558932",
"0.65565145",
"0.6529389",
"0.65058947",
"0.6498868",
"0.6477474... | 0.8781946 | 0 |
Test API can get a list of all departments(GET request) | def test_api_can_get_all_departments(self):
res = self.client().get(service_url)
self.assertEqual(res.status_code, 200)
self.assertIn('dep 1', str(res.data))
self.assertIn('dep 2', str(res.data))
self.assertIn('dep 3', str(res.data)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def getDepartments(self, ):\n payload = {}\n \n\n # Parameter validation\n schema = CatalogValidator.getDepartments()\n schema.dump(schema.load(payload))\n \n\n url_with_params = await create_url_with_params(self._conf.domain, f\"/service/platform/catalog/v1.0... | [
"0.7658562",
"0.76109993",
"0.7608823",
"0.7466871",
"0.72229016",
"0.7188552",
"0.71461266",
"0.7073292",
"0.7052737",
"0.6924505",
"0.68709964",
"0.6787654",
"0.67171353",
"0.6716329",
"0.6634516",
"0.64955044",
"0.6487888",
"0.64635545",
"0.64385515",
"0.641409",
"0.640511... | 0.880523 | 0 |
Test API can get a single department by it's id | def test_api_can_get_department_by_id(self):
res = self.client().get(service_url+'/1')
self.assertEqual(res.status_code, 200)
self.assertIn('dep 1', str(res.data)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(id_):\n\n logger.debug('Catch GET request by URL /api/departments/%i.', id_)\n try:\n department = ds.get(id_)\n if not department.id:\n raise Exception\n except Exception:\n logger.error('There is no department with id %i', id_)\n ... | [
"0.78734773",
"0.7596805",
"0.7467394",
"0.73101795",
"0.72399706",
"0.7006971",
"0.69550437",
"0.6916523",
"0.677674",
"0.67633426",
"0.6730946",
"0.660801",
"0.6550366",
"0.6519978",
"0.6404605",
"0.6393788",
"0.6373831",
"0.63526964",
"0.6323746",
"0.6293206",
"0.62138426"... | 0.8889061 | 0 |
Test API can edit an existing department (PUT request) | def test_department_can_be_edited(self):
res = self.client().put(service_url, json={"id_dep": 1, "dep_name": "", "description": "this is a new description"})
self.assertEqual(res.status_code, 204)
results = self.client().get(service_url+'/1')
self.assertIn('is a new', str(results.data))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(id_=None):\n\n logger.debug('Catch PUT request by URL /api/departments/%i.', id_)\n try:\n args = department_args.parse_args()\n ds.update(id_, name=args['name'], email=args['email'])\n except Exception:\n return {'message': \"Can't update department.\"... | [
"0.7635879",
"0.75541437",
"0.7310086",
"0.71458596",
"0.7124142",
"0.682343",
"0.6818235",
"0.6771202",
"0.6658555",
"0.66222185",
"0.6613502",
"0.6584068",
"0.6572079",
"0.65327775",
"0.6495819",
"0.6454379",
"0.6428005",
"0.64252895",
"0.6404784",
"0.639821",
"0.63961864",... | 0.86693555 | 0 |
Test API can delete an existing department. (DELETE request) | def test_department_deletion(self):
res = self.client().delete(service_url, json={"id_dep": 1})
self.assertEqual(res.status_code, 204)
# Test to see if it exists, should return a 400
result = self.client().get(service_url+'/1')
self.assertEqual(result.status_code, 400) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(id_=None):\n\n logger.debug('Catch DELETE request by URL /api/departments/%i.', id_)\n ds.delete(id_)\n return '', 204",
"def delete(self, department_id):\n department = get_department_by_id(department_id)\n db.session.delete(department)\n db.session.commit()\... | [
"0.7808423",
"0.7420233",
"0.73379195",
"0.7330726",
"0.7278499",
"0.7205929",
"0.72051007",
"0.71552616",
"0.71247154",
"0.70944077",
"0.7052728",
"0.7027502",
"0.6964331",
"0.6899749",
"0.6838181",
"0.6759945",
"0.67122805",
"0.66914827",
"0.66903144",
"0.6680656",
"0.66458... | 0.8739359 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.