query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Return recipe detail url | def detail_url(recipe_id):
return reverse('recipe:recipe-detail', args=[recipe_id]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipe_detail_url(recipe_id):\n return reverse('recipe:recipe-detail', args=[recipe_id])",
"def detail_url(recipe_id):\n return reverse('recipe:recipe-detail', args=[recipe_id])",
"def detail_url(recipe_id):\n return reverse('recipe:recipe-detail', args=[recipe_id])",
"def detail_url(recipe_id):... | [
"0.85224116",
"0.8516094",
"0.8516094",
"0.8516094",
"0.8516094",
"0.8516094",
"0.8516094",
"0.8516094",
"0.8516094",
"0.84500086",
"0.83119076",
"0.78332156",
"0.69384086",
"0.68106294",
"0.6687019",
"0.6650367",
"0.663163",
"0.65686995",
"0.6567431",
"0.6538007",
"0.6534405... | 0.85189116 | 1 |
Test retrieving recipes for user | def test_recipes_limited_to_user(self):
user2 = get_user_model().objects.create_user(
'sth@google.com',
'tetstst'
)
sample_recipe(user=user2)
sample_recipe(user=self.user)
res = self.client.get(RECIPE_URL)
recipes = Recipe.objects.filte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_user_recipes(self):\n\n result = self.get_user_recipes(1)\n self.assertIn(\"Pineapple Fried Rice\", result.data)",
"def test_recipes_limited_to_user(self):\n # Create second user\n user2 = get_user_model().objects.create_user(\n 'testing2@gmail.com',\n ... | [
"0.83616173",
"0.8099139",
"0.8041827",
"0.7975688",
"0.79695445",
"0.7893643",
"0.7774596",
"0.775817",
"0.77503276",
"0.7728501",
"0.77010953",
"0.7691933",
"0.76582503",
"0.7649473",
"0.7463168",
"0.741844",
"0.74133086",
"0.7413148",
"0.7334584",
"0.72711617",
"0.71744436... | 0.79505074 | 5 |
Test viewing a recipe detail | def test_view_recipe_detail(self):
recipe = sample_recipe(user=self.user)
# .add() method to add an item for many to many field
recipe.tags.add(sample_tag(user=self.user))
recipe.ingredients.add(sample_ingredient(user=self.user))
url = detail_url(recipe.id)
res = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_view_recipe_detail(self):\n # Create a sample recipe and populate its tags and ingredients\n recipe = sample_recipe(self.user)\n recipe.tags.add(sample_tag(self.user))\n recipe.ingredients.add(sample_ingredient(self.user))\n\n # Get the detail URL of the recipe to make t... | [
"0.8298181",
"0.82728267",
"0.82642454",
"0.82095134",
"0.81434226",
"0.81433296",
"0.81292063",
"0.8117052",
"0.8054892",
"0.7938673",
"0.7522139",
"0.7445957",
"0.7343366",
"0.7168743",
"0.7148521",
"0.7134456",
"0.7080366",
"0.70603496",
"0.70423007",
"0.7026308",
"0.69993... | 0.8021077 | 9 |
Test updating a recipe with PUT | def test_full_update_recipe(self):
recipe = sample_recipe(user=self.user)
payload = {
'title': 'Speghatti',
'time_minutes': 25,
# cast to avoid data type issues in assertion
'price': Decimal('4.85')
}
url = detail_url(recipe.id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_full_update_recipe(self):\n recipe = sample_recipe(user=self.user, title='soup')\n tag_1 = sample_tag(user=self.user, name='picnic')\n ingredient_1 = sample_ingredient(user=self.user, name='vegetables')\n payload = {\n 'title': 'Ghormeh',\n 'time_minutes':... | [
"0.8335578",
"0.829678",
"0.82136077",
"0.81900334",
"0.8163921",
"0.8041707",
"0.7912887",
"0.7912544",
"0.78333914",
"0.7825955",
"0.78167",
"0.7809303",
"0.77965236",
"0.77715486",
"0.7764162",
"0.77301544",
"0.76887184",
"0.7686009",
"0.7664155",
"0.74331856",
"0.7324164"... | 0.808702 | 5 |
Test retirning recipes with specific ingredients | def test_filter_recipes_by_ingredients(self):
recipe1 = sample_recipe(user=self.user, title='curry')
recipe2 = sample_recipe(user=self.user, title='cake')
ingredient1 = sample_ingredient(user=self.user, name='chili')
ingredient2 = sample_ingredient(user=self.user, name='butter')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_two_given_ingredients(self):\n r = Recipe.objects.get(title=\"Fried Plantains\")\n ingreds = getIngredientsList(\"plantains, oil\")\n matches = getPossibleRecipes( ingreds )\n self.assertIn(r, matches)",
"def test_recipe_with_ingredient(self):\n ingredient1 = sample_ingredient... | [
"0.7877547",
"0.7524865",
"0.7349521",
"0.73289716",
"0.73052806",
"0.73046803",
"0.7258424",
"0.72506595",
"0.72398466",
"0.7237096",
"0.7229893",
"0.72009337",
"0.71974814",
"0.71733207",
"0.71413743",
"0.70658755",
"0.7065093",
"0.7064368",
"0.70417",
"0.69896096",
"0.6899... | 0.7264457 | 6 |
Gets the root element which is at the top of Dom hierarchy. | def root(self):
return self.rootElement | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_root(self):\n he = sciter.dom.HELEMENT()\n ok = _api.SciterGetRootElement(self.hwnd, ctypes.byref(he))\n sciter.dom.Element._throw_if(ok)\n return sciter.dom.Element(he) if he else None",
"def _elem_root(self):\n # type: () -> etree._Element\n return self._tree.g... | [
"0.79894483",
"0.76309216",
"0.75454533",
"0.75454533",
"0.7374533",
"0.7325782",
"0.73220176",
"0.73044574",
"0.7288391",
"0.72782505",
"0.7245521",
"0.7171187",
"0.71599793",
"0.71274906",
"0.70999336",
"0.70999336",
"0.70999336",
"0.70999336",
"0.70999336",
"0.7064279",
"0... | 0.74018 | 4 |
Creates a list of DOM Element instances with the given unlimited parameters. | def createElementsWithTextNodes(self, **kwargs):
return [self.createElementWithTextNode(k, v) for k, v in kwargs.items()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_elements(self) -> None:\n ...",
"def create_elements(self) -> None:\n ...",
"def create_elements(self, **kwargs):\n log.debug(\"Creating elements with {}\".format(kwargs))\n elements = Elements(self.appium_driver, **kwargs)\n return elements",
"def create_element... | [
"0.72521436",
"0.72521436",
"0.7051416",
"0.6828289",
"0.6376183",
"0.63373744",
"0.61170155",
"0.61045504",
"0.59902537",
"0.59381086",
"0.59299165",
"0.58466643",
"0.5826986",
"0.5801557",
"0.57955813",
"0.5790841",
"0.57452375",
"0.57159925",
"0.56431705",
"0.5602231",
"0.... | 0.5767038 | 16 |
Init with boto3 dict | def __init__(self, dict_src, from_cache=False):
self.document = None
super().__init__(dict_src, from_cache=from_cache)
if from_cache:
self._init_policy_from_cache(dict_src)
return
init_options = {
"PolicyId": lambda x, y: self.init_defaul... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **kwargs):\r\n self.client = boto3.client(service_name=\"s3\", **kwargs)\r\n self.resource = boto3.resource(service_name=\"s3\")",
"def __init__(__self__, *,\n s3_bucket: pulumi.Input[str],\n s3_object_key: pulumi.Input[str],\n s3_o... | [
"0.69506335",
"0.68870765",
"0.6743921",
"0.67354345",
"0.66741365",
"0.64735717",
"0.6470885",
"0.6436803",
"0.64202327",
"0.64202327",
"0.64083475",
"0.6406814",
"0.6360972",
"0.63468134",
"0.63171935",
"0.63011765",
"0.6295782",
"0.62825686",
"0.62619436",
"0.626107",
"0.6... | 0.5793885 | 51 |
Init resource. Value received from AWS API. | def init_resource(self, key, value):
if isinstance(value, str):
value = [value]
elif isinstance(value, list):
pass
else:
raise TypeError(type(value))
self.init_default_attr(key, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init(self, resource):\n pass",
"def __init__(self):\n self.resource = None\n self.client = None",
"def __init__(__self__, *,\n resource_name: Optional[pulumi.Input[str]] = None):\n if resource_name is not None:\n pulumi.set(__self__, \"resource_name\",... | [
"0.73743623",
"0.6670851",
"0.65887666",
"0.656927",
"0.65049756",
"0.65020347",
"0.64930934",
"0.6468353",
"0.644673",
"0.6387725",
"0.6381269",
"0.6377213",
"0.6359618",
"0.63547903",
"0.63473636",
"0.6338425",
"0.6334655",
"0.6328142",
"0.62981164",
"0.62813073",
"0.627123... | 0.64239025 | 9 |
Find next node with min weight | def __find_next_node(self, d, used):
# находим лучшую следующую проверяемую точку
# проверяемой точке присваиваем максимальный вес
cur_node = [np.inf, 0]
# текущая позиция проверки
# cur_position = 0
for i in range(self.nodes_count):
if d[i] < cur_nod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_node(nodes):\n min_weight = sys.maxint\n min_weight_node = None\n for node in nodes:\n if node[1] < min_weight:\n min_weight = node[1]\n min_weight_node = node[0]\n return min_weight_node, min_weight",
"def findMinFrom(node):\n minNode = node\n while node is... | [
"0.78628993",
"0.7265572",
"0.684267",
"0.68290895",
"0.6797808",
"0.6680449",
"0.6660841",
"0.6654325",
"0.6650484",
"0.66456616",
"0.6536371",
"0.65167385",
"0.6487438",
"0.6440452",
"0.64110726",
"0.6398378",
"0.6387592",
"0.6381953",
"0.636389",
"0.635785",
"0.63439405",
... | 0.596694 | 59 |
Return the default mocked config entry. | def mock_config_entry() -> MockConfigEntry:
return MockConfigEntry(
domain=DOMAIN,
unique_id="ViCare",
entry_id="1234",
data=ENTRY_CONFIG,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_config_entry() -> MockConfigEntry:\n return MockConfigEntry(\n title=\"Home Sweet Home\",\n domain=DOMAIN,\n data={CONF_LATITUDE: 52.42, CONF_LONGITUDE: 4.44, CONF_API_KEY: \"example\"},\n unique_id=\"unique_thingy\",\n )",
"def mock_config_entry() -> MockConfigEntry:\n... | [
"0.75810003",
"0.75517344",
"0.74951166",
"0.7397836",
"0.7329042",
"0.7218087",
"0.71337163",
"0.70799017",
"0.68593407",
"0.67928785",
"0.6629185",
"0.6627456",
"0.6613023",
"0.6598651",
"0.6593331",
"0.6587032",
"0.65741074",
"0.6532249",
"0.65010494",
"0.6473143",
"0.6463... | 0.7481845 | 3 |
Method that returns the amplitude of a Gaussian Envelope | def GaussianEnvelope(t,V0,T,sigma=T/4):
return V0*(np.exp(-(t-T)**2/(2*sigma**2))-np.exp(-T**2/(2*sigma**2)))/(1-np.exp(-T**2/(2*sigma**2))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian(x, xmean, sigma, amplitude):\r\n return amplitude * util.np.exp(-(x - xmean) ** 2. / (2. * (sigma ** 2.)))",
"def gaussian(x,amp,cen,wid):\n \n z = (x-cen)/wid \n return amp*np.exp(-z**2/2.)",
"def _gaussian(x, *parameters):\n position, sigma, amplitude = parameters\n return a... | [
"0.7591263",
"0.7280968",
"0.71629596",
"0.7129664",
"0.7125049",
"0.7113289",
"0.7079152",
"0.703164",
"0.6923419",
"0.68752944",
"0.68260133",
"0.67597055",
"0.66610867",
"0.6654072",
"0.6628571",
"0.66054374",
"0.65593463",
"0.654582",
"0.65442055",
"0.65383196",
"0.652717... | 0.70839685 | 6 |
The name of the cluster the version is for. | def cluster_name(self) -> pulumi.Input[str]:
return pulumi.get(self, "cluster_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster_name(self):\n node = self.get_node()\n try:\n return node.oget(\"cluster\", \"name\").lower()\n except Exception as exc:\n pass\n name = \"default\"\n from cluster import ClusterSvc\n svc = ClusterSvc()\n svc.set_multi([\"cluster.na... | [
"0.87359357",
"0.8336386",
"0.81578904",
"0.8140043",
"0.80698615",
"0.79764736",
"0.79764736",
"0.79764736",
"0.79764736",
"0.79764736",
"0.79764736",
"0.7780375",
"0.7780375",
"0.7684151",
"0.756796",
"0.7535289",
"0.74498713",
"0.72456294",
"0.72445244",
"0.72445244",
"0.7... | 0.8058383 | 6 |
The name of the cluster the version is for. | def cluster_name(self) -> pulumi.Input[str]:
return pulumi.get(self, "cluster_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster_name(self):\n node = self.get_node()\n try:\n return node.oget(\"cluster\", \"name\").lower()\n except Exception as exc:\n pass\n name = \"default\"\n from cluster import ClusterSvc\n svc = ClusterSvc()\n svc.set_multi([\"cluster.na... | [
"0.8736547",
"0.83362293",
"0.8157735",
"0.8139516",
"0.80700666",
"0.7975447",
"0.7975447",
"0.7975447",
"0.7975447",
"0.7975447",
"0.7975447",
"0.7779217",
"0.7779217",
"0.7684329",
"0.75668955",
"0.7535554",
"0.74480736",
"0.7244832",
"0.72433007",
"0.72433007",
"0.7217999... | 0.8057248 | 5 |
method creates an instance of ContextWindow class | def __init__(self, line, position, start, end):
self.line = line
self.position = position
self.start = start
self.end = end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self) -> None:\n log.debug('instantiating Window...')\n\n self.name = self.__class__.__name__\n self.constants = RESOURCE.cfg('view')['window']\n self.w_px, self.h_px = APP.STATION.resolution\n self.widgets_by_position = dict()\n self.categories = self.categor... | [
"0.7266416",
"0.701076",
"0.68558824",
"0.6705719",
"0.6577683",
"0.6463973",
"0.643851",
"0.63713783",
"0.63713783",
"0.63098764",
"0.6283969",
"0.6263703",
"0.62587416",
"0.6196917",
"0.6164709",
"0.6104593",
"0.60889965",
"0.6065138",
"0.6052871",
"0.60423696",
"0.60317516... | 0.0 | -1 |
Check if two context windows are equal | def __eq__(self, wnd):
return ((self.position == wnd.position) and
(self.line == wnd.line) and
(self.start == wnd.start) and
(self.end == wnd.end)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not isinstance(other, WindowHierarchyChild):\n return False\n\n return self.__dict__ == other.__dict__",
"def __eq__(self, other: 'MessageContextGlobalStateless') -> bool:\n if not isinstance(other, self.__class__):\n return False\n ... | [
"0.6084654",
"0.6048087",
"0.60471827",
"0.6026305",
"0.5903216",
"0.5901395",
"0.5832064",
"0.5704526",
"0.56884015",
"0.56646144",
"0.56631404",
"0.5621608",
"0.5607996",
"0.5601437",
"0.55905026",
"0.5577748",
"0.5566474",
"0.55515873",
"0.5531924",
"0.5523549",
"0.5498404... | 0.5683181 | 9 |
Represents ContextWindow instance to string | def __repr__(self):
return str(self.position)+ ', ' + str(self.start)+ ', ' \
+ str(self.end)+ ', ' + self.line | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % (\n self.dwSize.Y, self.dwSize.X,\n self.dwCursorPosition.Y, self.dwCursorPosition.X,\n self.wAttributes,\n self.srWindow.Top, self.srWindow.Left,\n self.srWindow... | [
"0.6475259",
"0.60359484",
"0.60272837",
"0.59308034",
"0.59053427",
"0.5903576",
"0.5851046",
"0.584693",
"0.58363444",
"0.5812647",
"0.58056474",
"0.5793665",
"0.5775764",
"0.5759574",
"0.5759574",
"0.5759574",
"0.5759574",
"0.5759574",
"0.5759574",
"0.5759574",
"0.5759574"... | 0.0 | -1 |
Return True if the queue is empty, False otherwise (not reliable!). | def empty(self):
self.mutex.acquire()
n = not self._qsize()
self.mutex.release()
return n | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n if self.queue:\n return False\n return True",
"def IsEmpty(self):\r\n return len(self._queue) == 0",
"def empty(self) -> bool:\r\n if self.queue==None or len(self.queue)==0:\r\n return True\r\n else:\r\n return False",
"def... | [
"0.915382",
"0.9145034",
"0.89995027",
"0.89828354",
"0.89349025",
"0.8923372",
"0.8911544",
"0.8911544",
"0.88657355",
"0.8857644",
"0.8847316",
"0.88327235",
"0.87524587",
"0.868179",
"0.86740345",
"0.86549723",
"0.86286455",
"0.8366247",
"0.8322266",
"0.8210385",
"0.818772... | 0.0 | -1 |
Return True if the queue is full, False otherwise (not reliable!). | def full(self):
self.mutex.acquire()
n = 0 < self.maxsize == self._qsize()
self.mutex.release()
return n | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue_is_full(self):\r\n return True if len(self.queue) == self.size else False",
"def is_full(self):\n if self.size == len(self.queue):\n return True\n return False",
"def queue_full(self) -> bool:\n return self._queue_maxlen is not None and len(self.queue()) >= self... | [
"0.9339719",
"0.898546",
"0.8975195",
"0.85658944",
"0.84514254",
"0.8414878",
"0.8333798",
"0.8247538",
"0.81960803",
"0.81896824",
"0.81863415",
"0.81863415",
"0.81493044",
"0.81445503",
"0.8091023",
"0.8078702",
"0.8005316",
"0.79581743",
"0.7937366",
"0.7916049",
"0.79087... | 0.71003467 | 77 |
Yield deep copies of keys and values. | def _copyitems(self):
for k, v in self._items():
yield deepcopy(k), deepcopy(v) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n clone = type(self)()\n clone.store_by_child = self.store_by_child\n\n # Copy everything from this dict into it.\n for dspec in itertools.chain.from_iterable(self.values()):\n clone.add(dspec.copy())\n\n return clone",
"def iteritemsdeep(dct):\n f... | [
"0.6466081",
"0.6351197",
"0.62948585",
"0.6268449",
"0.6154616",
"0.6135238",
"0.6063734",
"0.6030243",
"0.60131335",
"0.6002471",
"0.599865",
"0.5974457",
"0.5953477",
"0.59488875",
"0.5940051",
"0.59306145",
"0.5908204",
"0.590533",
"0.58836937",
"0.58836937",
"0.5872791",... | 0.7866025 | 0 |
Return a queryset of all admin users. | def get_all_administrators():
return User.objects.filter(groups__name="administrators") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_admin_users(self):\n for user in self.get_all_users():\n if user.is_admin:\n yield user",
"def admins(self):\n return User.objects.filter_by_role(role=Roles.GROUP_ADMIN, roles__group=self)",
"def get_all_admins(cls):\r\n try:\r\n # Create a list... | [
"0.8063182",
"0.78639644",
"0.7637005",
"0.74836236",
"0.7275662",
"0.7210721",
"0.7170429",
"0.7103776",
"0.7030467",
"0.69688314",
"0.68905807",
"0.68874276",
"0.6887105",
"0.68492436",
"0.682911",
"0.67784864",
"0.6770611",
"0.6770611",
"0.6770611",
"0.67654467",
"0.674697... | 0.81662685 | 0 |
Accessor to the subprocess.returncode property. None if the process is still running and filled out with the exit status otherwise. | def returncode(self):
return self._proc.returncode | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_retcode(self):\n if self.retcode is None:\n self.retcode = self.process.poll()\n return self.retcode",
"def get_retcode(self):\n if self.retcode is None:\n self.retcode = self.process.poll()\n return self.retcode",
"def exit_code(self):\n return ... | [
"0.80969745",
"0.80969745",
"0.8085287",
"0.79744494",
"0.77670246",
"0.7740377",
"0.76235306",
"0.7509495",
"0.75005627",
"0.7457034",
"0.74119675",
"0.7233719",
"0.7233719",
"0.7167972",
"0.71253294",
"0.70742047",
"0.7043625",
"0.6982103",
"0.6975648",
"0.6740043",
"0.6725... | 0.8166297 | 0 |
Test the magic method str | def test_string_representation(self):
my_model = BaseModel()
my_model.name = "Holberton"
my_model.my_number = 89
id_model = my_model.id
expected = '[BaseModel] ({}) {}'\
.format(id_model, my_model.__dict__)
self.assertEqual(str(my_model), expected) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_str(self):\n self._stringificationTest(str)",
"def test_str_builtin(self):\r\n c = Car(\"red\", \"Ford\", \"Taurus\")\r\n self.assertEqual(\"I am a red Ford Taurus.\", str(c))",
"def test_str(self):\n self.assertEqual('nike', str(self.obj))",
"def test_str_method(self):\n... | [
"0.81325245",
"0.7796137",
"0.7724327",
"0.7718589",
"0.74568063",
"0.74456394",
"0.744077",
"0.7269001",
"0.7209744",
"0.7186163",
"0.717543",
"0.7164084",
"0.7159482",
"0.71282804",
"0.7109001",
"0.70944834",
"0.7064815",
"0.7055163",
"0.70538396",
"0.70456594",
"0.70374364... | 0.0 | -1 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(M3HumanoidCmdRequest, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.chain is None:
self.chain = 0
if self.tq_desired is None:
self.tq_desired = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(BasicSafetyMessage, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.communication_header is ... | [
"0.80618334",
"0.80590624",
"0.7872847",
"0.7872847",
"0.7872847",
"0.7872847",
"0.76028174",
"0.7600841",
"0.7525746",
"0.75020266",
"0.75020266",
"0.74583024",
"0.7450361",
"0.74443597",
"0.74268603",
"0.7391348",
"0.7355693",
"0.73332137",
"0.73259616",
"0.73181987",
"0.72... | 0.66265064 | 92 |
serialize message with numpy array types into buffer | def serialize_numpy(self, buff, numpy):
try:
buff.write(_struct_B.pack(self.chain))
length = len(self.tq_desired)
buff.write(_struct_I.pack(length))
pattern = '<%sf'%length
buff.write(self.tq_desired.tostring())
_x = self.ctrl_mode
length = len(_x)
# - if encoded as a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_numpy(self, buff, numpy):\n self.serialize(buff)",
"def serialize_numpy(self, buff, numpy):\n try:\n pass\n except struct.error as se: self._check_types(struct.error(\"%s: '%s' when writing '%s'\" % (type(se), str(se), str(locals().get('_x', self)))))\n except TypeError as te: ... | [
"0.7951979",
"0.7894134",
"0.78557587",
"0.7778328",
"0.7766659",
"0.77637404",
"0.77593005",
"0.77540714",
"0.77539235",
"0.7737562",
"0.767685",
"0.76748276",
"0.7668616",
"0.7664322",
"0.76045257",
"0.75880057",
"0.7564311",
"0.7557121",
"0.7555019",
"0.7544823",
"0.753995... | 0.7567481 | 16 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(M3HumanoidCmdResponse, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.response is None:
self.response = 0
else:
self.response = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(BasicSafetyMessage, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.communication_header is ... | [
"0.8060485",
"0.8057991",
"0.7871156",
"0.7871156",
"0.7871156",
"0.7871156",
"0.7601324",
"0.75989944",
"0.75244766",
"0.74995005",
"0.74995005",
"0.74557",
"0.74484843",
"0.7443006",
"0.7425603",
"0.739047",
"0.7354955",
"0.7331777",
"0.7323626",
"0.73172283",
"0.72902846",... | 0.0 | -1 |
serialize message with numpy array types into buffer | def serialize_numpy(self, buff, numpy):
try:
buff.write(_struct_i.pack(self.response))
except struct.error as se: self._check_types(se)
except TypeError as te: self._check_types(te) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_numpy(self, buff, numpy):\n self.serialize(buff)",
"def serialize_numpy(self, buff, numpy):\n try:\n pass\n except struct.error as se: self._check_types(struct.error(\"%s: '%s' when writing '%s'\" % (type(se), str(se), str(locals().get('_x', self)))))\n except TypeError as te: ... | [
"0.7951604",
"0.7893127",
"0.7854939",
"0.77776504",
"0.77664244",
"0.7763367",
"0.77588123",
"0.77534735",
"0.7736948",
"0.76762146",
"0.7674103",
"0.76675475",
"0.7663704",
"0.7603496",
"0.7587479",
"0.75675267",
"0.75634706",
"0.75564903",
"0.75546557",
"0.75442994",
"0.75... | 0.77536243 | 7 |
Creates a new BlockChest block | def __init__(self):
super().__init__()
import mcpython.client.gui.InventoryChest as InventoryChest
self.inventory = InventoryChest.InventoryChest(self)
self.loot_table_link = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_block(self, key='test'):\n data = {'body': self.body,\n 'key': key,\n 'site': self.site}\n return SimpleBlock.objects.create(**data)",
"def create_block(block):\n\n block.update(\n position=int(block.position),\n created_at=web.SQLLiteral(\"... | [
"0.7236965",
"0.7119715",
"0.6972197",
"0.6711112",
"0.670958",
"0.6689586",
"0.66273284",
"0.65740526",
"0.65090156",
"0.6508562",
"0.6493302",
"0.6492983",
"0.6472426",
"0.64503276",
"0.644613",
"0.6432295",
"0.6430958",
"0.6369075",
"0.6338821",
"0.63013744",
"0.62918496",... | 0.0 | -1 |
Preprocesses an image for an `Estimator`. | def preprocess_text(text, label):
if IS_DEBUG is True :
print("\n*** preprocess_text() : label shape= {}".format(label.shape))
features = {p8_util_config.FEATURES_KEY: text}
return features, label | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess_images(self, images):\n raise NotImplementedError",
"def image_preprocessing(image):\n # convert to float to allow for division operation\n image = tf.to_float(image)\n # below is the same as `xception.preprocess_input(image)`\n image /= 127.5\n image -= 1.0\n return image",
... | [
"0.68993795",
"0.6885829",
"0.6590506",
"0.6539879",
"0.6488061",
"0.64560705",
"0.64500475",
"0.6427637",
"0.6357097",
"0.63564026",
"0.63554984",
"0.6321461",
"0.62851727",
"0.6203401",
"0.62027496",
"0.62005204",
"0.618516",
"0.616195",
"0.6140701",
"0.6139693",
"0.6129658... | 0.0 | -1 |
Preprocesses an image for an `Estimator`. | def preprocess_color_image(image, label):
if IS_DEBUG is True :
print("\n*** preprocess_color_image() : label shape= {}".format(label.shape))
features = {FEATURES_KEY: image}
return features, label | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess_images(self, images):\n raise NotImplementedError",
"def image_preprocessing(image):\n # convert to float to allow for division operation\n image = tf.to_float(image)\n # below is the same as `xception.preprocess_input(image)`\n image /= 127.5\n image -= 1.0\n return image",
... | [
"0.68993795",
"0.6885829",
"0.6590506",
"0.6539879",
"0.6488061",
"0.64560705",
"0.64500475",
"0.6427637",
"0.6357097",
"0.63564026",
"0.63554984",
"0.6321461",
"0.62851727",
"0.6203401",
"0.62027496",
"0.62005204",
"0.618516",
"0.616195",
"0.6140701",
"0.6139693",
"0.6129658... | 0.0 | -1 |
Preprocesses an image for an `Estimator`. | def preprocess_image(image, label):
if IS_DEBUG is True :
print("\n*** preprocess_image() : image shape= {}".format(image.shape))
features = {FEATURES_KEY: image}
if IS_DEBUG is True :
print("\n*** preprocess_image() : features= {} / label shape= {}".format(features, label.shape... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess_images(self, images):\n raise NotImplementedError",
"def image_preprocessing(image):\n # convert to float to allow for division operation\n image = tf.to_float(image)\n # below is the same as `xception.preprocess_input(image)`\n image /= 127.5\n image -= 1.0\n return image",
... | [
"0.6897504",
"0.6885135",
"0.65892607",
"0.65389526",
"0.64872575",
"0.64545053",
"0.6451201",
"0.6426217",
"0.6357863",
"0.6356115",
"0.6352881",
"0.6319481",
"0.6284375",
"0.62039375",
"0.62030643",
"0.61988425",
"0.61849594",
"0.6161617",
"0.61389875",
"0.6138017",
"0.6130... | 0.54381454 | 97 |
Returns a generator that returns imagelabel pairs. | def generator(images, labels):
def _gen():
for image, label in zip(images, labels):
yield image, label
if IS_DEBUG is True :
print("\n*** generator() : labels shape= {} / label values= {}".format(labels.shape, labels[10]))
return _gen | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __next__(self):\n labels = np.empty([self.batch_size] + self.label_shape)\n if self.timesteps:\n images = np.empty([self.batch_size, self.timesteps] + self.image_shape)\n else:\n images = np.empty([self.batch_size] + self.image_shape)\n\n if self.pctl_sampling:... | [
"0.6932896",
"0.68961734",
"0.6736561",
"0.6675989",
"0.6589826",
"0.6422881",
"0.6299196",
"0.6270336",
"0.62008625",
"0.618626",
"0.6160927",
"0.61570317",
"0.61318874",
"0.6124203",
"0.6081511",
"0.60748565",
"0.6005176",
"0.59696084",
"0.59642607",
"0.59637135",
"0.595915... | 0.79551804 | 0 |
Integer to two bytes | def intToBin(i):
# devide in two parts (bytes)
i1 = i % 256
i2 = int( i/256)
# make string (little endian)
return chr(i1) + chr(i2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodeTwoByteInt(self, numberToEncode):\n twoByteInt = bytearray()\n twoByteInt.append((numberToEncode >> 8) & 0xFF) # B1\n twoByteInt.append((numberToEncode >> 0) & 0xFF) # B2\n return twoByteInt",
"def convert_int(value: int):\n return bytearray(struct.pack(\"i\", value))",... | [
"0.77302",
"0.7311878",
"0.730528",
"0.7265013",
"0.71692425",
"0.71296155",
"0.70967513",
"0.70773625",
"0.7055498",
"0.6975823",
"0.69638526",
"0.6958047",
"0.69497603",
"0.6935107",
"0.69210654",
"0.6912909",
"0.68332803",
"0.68279856",
"0.6759442",
"0.67540145",
"0.674206... | 0.7334 | 1 |
searching for a stock ticker symbol | def searching_stock_ticker(request):
if request.method == 'GET':
try:
symbol = request.GET['symbol']
except KeyError:
return {}
address = 'https://api.iextrading.com/1.0/\
stock/{}/company'.format(symbol)
response = requests.get(address)
response = res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_stocks(company_list):\n print('Search for stocks from localised NASDAQ data, provides ticker symbol for further options')\n symbol = input(\"Please enter company name or ticker symbol: \")\n \n #This enables the search results to include results that aren't exact matches but contain the spec... | [
"0.7073311",
"0.7038938",
"0.68452823",
"0.66679347",
"0.66509295",
"0.6557676",
"0.6420647",
"0.6406381",
"0.6322732",
"0.6273273",
"0.62473065",
"0.62391394",
"0.62391394",
"0.61667717",
"0.6084757",
"0.6082847",
"0.60400355",
"0.6037297",
"0.6035088",
"0.598516",
"0.596550... | 0.6838731 | 3 |
display user's existing stocks | def view_existing_stocks(request):
query = request.dbsession.query(Stock)
all_entries = query.all()
return {'entries': all_entries} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history():\n stocks = db.execute(\"SELECT * FROM stocks WHERE user_id IN(?)\", session[\"user_id\"])\n return render_template(\"history.html\", stocks=stocks)",
"def history():\n allTransactions = db.execute(\"SELECT * FROM Stocks WHERE user_id=:userId\", userId=session['user_id'])\n stocks=[]\n ... | [
"0.7296739",
"0.7210952",
"0.7051141",
"0.7008823",
"0.6932315",
"0.6842705",
"0.68388706",
"0.68117213",
"0.6797619",
"0.67939955",
"0.6759465",
"0.6750706",
"0.6743271",
"0.6716259",
"0.669975",
"0.6685803",
"0.6676149",
"0.6643753",
"0.6597779",
"0.654954",
"0.6546201",
... | 0.7203429 | 2 |
Return a copy of this `Vector` with unit magnitude. | def normalize(self) -> Vector:
return self.copy() / abs(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unitVector(self): \n return self.scale(1/self.vectorLength())",
"def unitize(self):\r\n mag = self.magnitude()\r\n if mag == 0:\r\n raise ZeroDivisionError(\"Illegal operation: Division by zero\")\r\n return Vector(each / mag for each in self)",
"def to_unit(self) -> ... | [
"0.74718636",
"0.738831",
"0.730954",
"0.72354203",
"0.7157902",
"0.71123296",
"0.6840005",
"0.6768019",
"0.67384917",
"0.66800916",
"0.6649927",
"0.6563442",
"0.65183866",
"0.65085685",
"0.6465889",
"0.6440382",
"0.64312863",
"0.64268506",
"0.64238966",
"0.64222646",
"0.6420... | 0.69319975 | 6 |
Reorder and/or negate axes, e.g. `get_as_axes("xzy")`. | def get_as_axes(self, axes: str) -> tp.Union[Vector2, Vector3]:
new_data = []
axes_done = set()
negate = False
for c in axes:
if c == "-":
negate = not negate
elif c in {"x", "y", "z"}:
if c in axes_done:
raise V... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def axes_with_order(x, axes):\n axes = make_axes(axes)\n if x.axes == axes:\n return x\n \"\"\"\n import traceback\n print('axes_with_order:')\n traceback.print_stack()\n \"\"\"\n return ReorderAxes(x, axes)",
"def test_reorder():\n dd = DataDictBase(\n a=dict(values=[4, ... | [
"0.75168616",
"0.65425813",
"0.64028275",
"0.63516253",
"0.6275779",
"0.6101222",
"0.59862435",
"0.5957383",
"0.5915341",
"0.5816366",
"0.57567626",
"0.5715766",
"0.56266356",
"0.5602021",
"0.5573315",
"0.5556109",
"0.55131835",
"0.5456625",
"0.5442468",
"0.5440982",
"0.54308... | 0.54108816 | 21 |
Spherically interpolate between two Quaternions by parameter `t` in interval [0, 1]. | def slerp(q1: Quaternion, q2: Quaternion, t: float):
q1 = q1.normalize()
q2 = q2.normalize()
dot = q1.dot(q2)
if dot < 0.0:
# Quaternions have opposite-handedness, so slerp won't take the shortest path unless one is negated.
q2 = -q2
dot = -dot
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpolate(t1, s1, t2, s2, t):\n\n if (t1 <= t and t <= t2): # we check if 't' is out of bounds (between t1 and t2)\n m = float(s2 - s1) / (t2 - t1)\n b = s1 - m * t1\n return m * t + b\n else:\n return np.nan",
"def interpolateInTime( t1, y1, t2, y2, t ):\n if t == t1:... | [
"0.69023216",
"0.653877",
"0.6496941",
"0.6451564",
"0.6413278",
"0.61570764",
"0.6145202",
"0.6083577",
"0.597834",
"0.5947032",
"0.57925665",
"0.573804",
"0.5693866",
"0.5636274",
"0.55971473",
"0.55665547",
"0.54941833",
"0.5491797",
"0.5466972",
"0.54440016",
"0.5408928",... | 0.7034253 | 0 |
Linearly interpolate translate and scale, and spherically interpolate rotation Quaternion. `t` will be clamped to [0, 1] interval. | def lerp(cls, transform1: QuatTransform, transform2: QuatTransform, t: float):
t = min(1.0, max(0.0, t))
translate = transform1.translate + (transform2.translate - transform1.translate) * t
rotation = Quaternion.slerp(transform1.rotation, transform2.rotation, t)
scale = transform1.scale ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpolate(x, t, t_int):\n\n # vector interpolation\n x_int = np.zeros((t_int.shape[0], x.shape[1]))\n for i in range(x.shape[1]):\n if i in [4, 5, 6, 7]:\n continue\n x_int[:, i] = np.interp(t_int, t, x[:, i])\n # qu... | [
"0.63371193",
"0.6219923",
"0.59820014",
"0.5970613",
"0.5746217",
"0.5716575",
"0.56488234",
"0.5514517",
"0.5415006",
"0.54147977",
"0.53693736",
"0.5341974",
"0.51495117",
"0.51331687",
"0.51291186",
"0.5117626",
"0.50538605",
"0.49816394",
"0.4967365",
"0.49652335",
"0.49... | 0.61857677 | 2 |
Convert a `translate` vector, `q_rotation` quaternion, and `scale` vector to a 4x4 transform matrix. | def to_matrix4(self) -> Matrix4:
q0, q1, q2, q3 = self.rotation
# Rotation sub-matrix.
v00 = 2 * (q0 * q0 + q1 * q1) - 1
v01 = 2 * (q1 * q2 - q0 * q3)
v02 = 2 * (q1 * q3 + q0 * q2)
v10 = 2 * (q1 * q2 + q0 * q3)
v11 = 2 * (q0 * q0 + q2 * q2) - 1
v12 = 2 * ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_4x4_transform(scale_x, scale_y, trans_x, trans_y, trans_z):\r\n transform = [[scale_x, 0.0, 0.0, trans_x],\r\n [0.0, scale_y, 0.0, trans_y],\r\n [0.0, 0.0, 1.0, trans_z],\r\n [0.0, 0.0, 0.0, 1.0]]\r\n return transform",
"def scale_translation(quaterni... | [
"0.7322335",
"0.7209216",
"0.6858053",
"0.6478937",
"0.6399571",
"0.63531244",
"0.61889637",
"0.6110879",
"0.60684943",
"0.6062022",
"0.6061557",
"0.60356706",
"0.6031747",
"0.6031747",
"0.59914935",
"0.59740055",
"0.5968866",
"0.596849",
"0.5900636",
"0.58983797",
"0.5855921... | 0.6441055 | 4 |
Create a mask from an input matrix x, to identify the max entry of x | def create_mask_from_window(x):
mask = (x == np.max(x))
return mask | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_mask_from_window(x):\r\n \r\n ### START CODE HERE ### (≈1 line)\r\n mask = (x == np.max(x))\r\n ### END CODE HERE ###\r\n \r\n return mask",
"def create_mask(self, X):\n mask = X == np.max(X)\n return mask",
"def max_pool(x, mask):\n if mask is not None:\n mask = ... | [
"0.7506861",
"0.7485277",
"0.6988377",
"0.680422",
"0.6706389",
"0.6568426",
"0.6491788",
"0.64807993",
"0.64632505",
"0.63652295",
"0.6311271",
"0.6296526",
"0.6267487",
"0.6239091",
"0.62123305",
"0.6175352",
"0.6047222",
"0.6031677",
"0.6025151",
"0.6008647",
"0.596474",
... | 0.72966903 | 2 |
Computes categorical crossentropy loss for a softmax distribution in a hotencoded 2D array with shape (num_samples, num_classes, dim1, dim2) | def categorical_crossentropy(z_true, z_predicted):
z_true_flatten = K.flatten(z_true)
z_pred_flatten = K.flatten(z_predicted)
z_pred_flatten_log = -K.log(z_pred_flatten + K.epsilon())
num_total_elements = K.sum(z_true_flatten)
cross_entropy = tf.reduce_sum(tf.multiply(z_true_flatten, z_pred_flatten_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categorical_crossentropy(y_true, y_pred):\n # scale preds so that the class probas of each sample sum to 1\n y_pred /= K.sum(y_pred, axis=-1, keepdims=True)\n # manual computation of crossentropy\n y_pred = K.clip(y_pred, K.epsilon(), 1. - K.epsilon())\n loss = y_true * K.log... | [
"0.71203834",
"0.70927984",
"0.7030755",
"0.7009302",
"0.69586325",
"0.69339216",
"0.690363",
"0.6839993",
"0.6820682",
"0.67902637",
"0.6768343",
"0.67517567",
"0.6728448",
"0.66974074",
"0.66484195",
"0.662936",
"0.66191596",
"0.6602487",
"0.6585995",
"0.6572446",
"0.655134... | 0.6625781 | 16 |
Computes weighted categorical crossentropy loss for a softmax distribution in a hotencoded 2D array with shape (num_samples, num_classes, dim0, dim1) | def categorical_crossentropy_weighted(prior_probs, input_shape):
def categorical_crossentropy(y_true, y_predicted):
"""
:param y_true: keras.placeholder [batches, dim0,dim1, num_classes]
Placeholder for data holding the ground-truth labels encoded in a one-hot representation
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weighted_categorical_crossentropy(y_true, y_pred):\n\n # weights = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) # Class one at 0.5, class 2 twice the normal weights, class 3 10x.\n\n # weights = np.array([10, 2, 1, 10, 10, 1, 1, 10, 1, 10, 10, 0]) # Class one at 0.5, class 2 twice the normal weights,... | [
"0.71986824",
"0.715711",
"0.7079862",
"0.7044613",
"0.6995262",
"0.6885359",
"0.6849803",
"0.6849803",
"0.6849803",
"0.68020636",
"0.67277795",
"0.6720888",
"0.67087173",
"0.66774344",
"0.6676676",
"0.66687906",
"0.6654061",
"0.6627136",
"0.661966",
"0.6602986",
"0.65348303"... | 0.6914146 | 5 |
Draw the menu surface and then blit to screen | def draw(self):
# Fill menu surface with background color
self.surface.fill(self.bg_color)
# Draw menu title
font = pygame.font.SysFont(self.font_type, self.title_font_size)
title = font.render(self.title, 1, self.title_color)
render_size = font.size(self.title)
x_offset = render_size[0] / 2
y_offset = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_menu(self, surface):\r\n font_obj = pygame.font.Font(self._fonts_dir + \"OpenSans-Regular.ttf\", 20)\r\n topleft = [self.left + 5, self.top]\r\n self.print_surface(\"Play\", surface, topleft, font_obj)\r\n topleft[1] += self.linespacing\r\n self.print_surface(\"Exit\", surface, topleft, fon... | [
"0.8047872",
"0.78305084",
"0.77957684",
"0.7788965",
"0.75642854",
"0.75554353",
"0.75421655",
"0.74903697",
"0.7331907",
"0.7041951",
"0.69650084",
"0.69650084",
"0.69377786",
"0.6907991",
"0.6892904",
"0.6877213",
"0.68527234",
"0.68244976",
"0.68168765",
"0.6800032",
"0.6... | 0.8207184 | 0 |
Redirect to home view. | def index():
return redirect(url_for('login')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n if get_user():\n return redirect(url_for('profile', username=session['user']))\n\n return render_template('home.html')",
"def main_home(request):\n\n return redirect('accueil')",
"def homepage():\n\n if g.user:\n return redirect('/q')\n\n return render_template('home.... | [
"0.8025594",
"0.7997018",
"0.79869294",
"0.7979555",
"0.79746294",
"0.78538126",
"0.78521234",
"0.7740983",
"0.76626706",
"0.7634899",
"0.75905967",
"0.7519022",
"0.75054693",
"0.7466434",
"0.7409472",
"0.73655325",
"0.73273665",
"0.72209144",
"0.72074497",
"0.70970154",
"0.7... | 0.6813264 | 38 |
Route for the edit single backup page. | def edit_backup(backup_id):
backup_query = Backup.query.filter(Backup.id==backup_id)
if backup_query.first() is None:
return abort(404)
backup = backup_query.first()
if request.method == "POST":
form = BackupForm(request.form)
else:
form = BackupForm(name=backup.name, ser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_url(self):\n return CORE_BASE_URL + \"/{0}/{1}/update/\".format(\n self._meta.db_table, self.pk\n )",
"def get_edit_url(self):\n return CORE_BASE_URL + \"/{0}/{1}/update/\".format(\n self._meta.db_table, self.pk\n )",
"def edit_plan(request, id):\n\tre... | [
"0.65098226",
"0.61581373",
"0.60874027",
"0.60736746",
"0.5973411",
"0.5915542",
"0.57767755",
"0.57767755",
"0.5763822",
"0.57631683",
"0.57623863",
"0.57571065",
"0.5683248",
"0.56828463",
"0.5629442",
"0.5617028",
"0.55914944",
"0.55727637",
"0.55388385",
"0.55365354",
"0... | 0.7051575 | 0 |
Route for the edit account page. | def edit_account():
if request.method == "POST":
form = EditAccountForm(request.form)
else:
form = EditAccountForm(email=g.user.email)
if form.validate_on_submit():
if form.password.data != form.repeat_password.data:
flash("Passwords do not match.", "danger")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_user(request):\n\tpass",
"def url(self):\r\n return reverse(\r\n \"manage_user_edit\", kwargs=dict(user_id=self.user.id))",
"def url(self):\r\n return reverse(\"manage_user_edit\", kwargs={\"user_id\": self.owner.id})",
"def url(self):\r\n return reverse(\r\n ... | [
"0.69243455",
"0.6913812",
"0.6777886",
"0.6736405",
"0.66617256",
"0.6614529",
"0.65314513",
"0.63879067",
"0.6330751",
"0.62521017",
"0.62201285",
"0.6195986",
"0.6165616",
"0.61474276",
"0.6091628",
"0.602656",
"0.5943583",
"0.5932432",
"0.59277713",
"0.5921418",
"0.591882... | 0.6753889 | 3 |
Route for the login page. | def login():
if is_logged_in():
return redirect(url_for('backups'))
login_form = LoginForm(request.form)
if login_form.validate_on_submit():
login_validator = LoginChecker(email=request.form.get('email'),
password=request.form.get('password'))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n self.redirect(\"/login\")",
"def login_url():\n return \"/login/\"",
"def login_page(self):\n self.validate_form(\"/login\", [\"username\", \"password\"])",
"def get(self):\n\n\t\tuser = self.user\n\n\t\tif user:\n\t\t\tself.redirect('/')\n\n\t\tself.render('login.html', use... | [
"0.76649964",
"0.761437",
"0.7376741",
"0.73424125",
"0.7210435",
"0.7161298",
"0.7156456",
"0.71340615",
"0.71103835",
"0.7098884",
"0.7098884",
"0.70903295",
"0.70818615",
"0.7069127",
"0.70685613",
"0.7060088",
"0.7045393",
"0.7042201",
"0.69602907",
"0.69394076",
"0.69304... | 0.0 | -1 |
Returns True if the user is logged in. | def is_logged_in():
if g.user is not None and g.user.is_authenticated():
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_logged_in(self):\n user = self.get_user_from_cookie()\n\n if user:\n return True\n else:\n return False",
"def user_logged_in(self):\n if self.request.user.is_authenticated():\n return True",
"def is_user_logged_in():\n return current_user ... | [
"0.90108186",
"0.8932454",
"0.8848223",
"0.8665481",
"0.86646163",
"0.86168015",
"0.8489824",
"0.8475734",
"0.8453773",
"0.8292155",
"0.8280403",
"0.82229936",
"0.82136977",
"0.81035113",
"0.8017057",
"0.7984127",
"0.7945836",
"0.7943801",
"0.78489816",
"0.7792136",
"0.776818... | 0.8611746 | 6 |
Tests that the od cannot be set below the min_od | def test_bad_od(self):
for (bad_od,testwire) in [(1,.25), (2.75,.375), (3.75,.5)]:
with self.subTest(bad_od = bad_od, testwire = testwire):
self.assertRaisesRegex(ValueError,"Invalid Wire od: od is smaller than Wire's minimum od",
classes.Spring... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_donor_ionization_energy_less_than_zero(self):\n try:\n self.el.donor_ionization_energy = -1.1\n except ValueError:\n # Attempting to set the `donor_ionization_energy` attribute with a negative value raised a ValueError which is exactly what we wanted to do.\n ... | [
"0.63239276",
"0.6294662",
"0.6199596",
"0.6071273",
"0.60576296",
"0.6042609",
"0.5991313",
"0.59300303",
"0.5917935",
"0.58495146",
"0.5814796",
"0.5794318",
"0.57622045",
"0.57550204",
"0.57533336",
"0.5731784",
"0.57219195",
"0.5721627",
"0.5710574",
"0.5691504",
"0.56650... | 0.7204517 | 0 |
Create a folder of random grayscale images | def create_random_imageset(cls, **kwargs):
num_images = kwargs.pop('num_images', 10)
image_width = kwargs.pop('image_width', 32)
image_height = kwargs.pop('image_height', 32)
if not hasattr(cls, 'imageset_folder'):
# create a temporary folder
cls.imageset_folder =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_test_image():\r\n c = np.random.choice(cat_df['category'])\r\n root = testdir + c + '/'\r\n img_path = root + np.random.choice(os.listdir(root))\r\n return img_path",
"def generate_and_save_images(self, num_samples, directory):\n imgs = self.sess.run(self.sampled_tensor)\n fo... | [
"0.70166284",
"0.6795875",
"0.6782813",
"0.67337656",
"0.6662427",
"0.66334474",
"0.66063887",
"0.6536306",
"0.64541906",
"0.640415",
"0.63179976",
"0.62999976",
"0.629499",
"0.6276576",
"0.6266941",
"0.62641615",
"0.6256352",
"0.6239736",
"0.62257105",
"0.6188865",
"0.618801... | 0.65904117 | 7 |
Returns if there is any word in the trie that starts with the given prefix. | def startsWith(self, prefix):
curr_node = self.root
for char in prefix:
if char not in curr_node:
return False
curr_node = curr_node[char]
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def startsWith(self, prefix: str) -> bool:\n node = self.trie\n for w in prefix:\n if w not in node:\n return False\n node = node[w]\n \n return True",
"def startsWith(self, prefix):\n root = self.trie\n for c in prefix:\n ... | [
"0.84252757",
"0.8373269",
"0.83657616",
"0.8358083",
"0.8349312",
"0.8286922",
"0.8126382",
"0.8102869",
"0.8027282",
"0.7957613",
"0.7937967",
"0.7937402",
"0.79320663",
"0.79283863",
"0.7882381",
"0.7868962",
"0.78641963",
"0.7852686",
"0.7843421",
"0.78312224",
"0.7830627... | 0.78250957 | 21 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
path = './'+ city +'.csv'
df = pd.read_csv(path)
f_month = {'january':1, 'february':2, 'march':3, 'april':4, 'may':5, 'june':6}
df['Start Time'] = pd.to_datetime(df['Start Time'])
df['month'] = df['Start Time'].dt.month
df['day'] = df['Start Time'].dt.day_name()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_city_data(city, month, day):\n df = pd.read_csv(CITY_DATA[city])\n #extract month, day, hour from start time\n df['month'] = pd.to_datetime(df['Start Time']).dt.month_name()\n df['day'] = pd.to_datetime(df['Start Time']).dt.weekday\n df['hour'] = pd.to_datetime(df['Start Time']).dt.hour\n\n... | [
"0.8317899",
"0.8226326",
"0.81501013",
"0.8042325",
"0.8017544",
"0.8000768",
"0.79894716",
"0.797885",
"0.7977254",
"0.7971844",
"0.79562634",
"0.79556274",
"0.7948111",
"0.79304653",
"0.79183584",
"0.79123306",
"0.79113525",
"0.7904648",
"0.7902695",
"0.79020023",
"0.79015... | 0.8078786 | 3 |
Displays statistics on the most frequent times of travel. | def time_stats(df, month, day):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
f_month = {1:'january', 2:'february', 3:'march', 4:'april', 5:'may', 6:'june'}
# TO DO: display the most common month
if month != 'all':
print('Displaying data for:', month... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\r\n\r\n print('\\nThese are the statistics of the most frequent times of travel:\\n')\r\n start_time = time.time()\r\n\r\n # Display the most common month\r\n common_month = df['month'].mode()[0]\r\n print(\"- That's the most common month based on your selection: \" +\r\n ... | [
"0.7973481",
"0.7850757",
"0.77994037",
"0.7781465",
"0.7774358",
"0.7761718",
"0.7752516",
"0.77377707",
"0.7725528",
"0.7717532",
"0.7684718",
"0.76827013",
"0.7680481",
"0.76791",
"0.76493955",
"0.76444066",
"0.76435655",
"0.76422024",
"0.76290774",
"0.7623855",
"0.7623656... | 0.71283036 | 96 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# TO DO: display most commonly used start station
st_station = df['Start Station'].mode()[0]
print("most commonly used start station : \n", st_station)
# TO DO: display most commonly ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\033[1m' + 'Calculating the most popular stations and trip...\\n' + '\\033[0m')\n start_time = time.time()\n\n # display the most commonly used start station\n\n start_stn = df['Start Station'].mode()[0]\n print('Most popular start station is {}.'.format(start_stn)... | [
"0.7809938",
"0.76727635",
"0.7538624",
"0.74982685",
"0.7490305",
"0.74887866",
"0.7436869",
"0.7429845",
"0.74274427",
"0.7425571",
"0.74126786",
"0.7404592",
"0.7382532",
"0.7379482",
"0.73747545",
"0.7365935",
"0.73561436",
"0.7351966",
"0.7324152",
"0.7304813",
"0.729985... | 0.72596824 | 33 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# TO DO: display total travel time
total_time_s = df['Trip Duration'].sum() #in seconds
total_time_m = int(total_time_s / 60)
total_time_s %= 60
print('total travel time = {} minuts and {} secon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(df):\r\n\r\n print('\\nThese are the statistics related to the trips durations:\\n')\r\n start_time = time.time()\r\n\r\n # Display total travel time\r\n total_travel_time = df['Trip Duration'].sum()\r\n print(\"\\n- The total travel time based on your selection is: \" +\r\n ... | [
"0.82698804",
"0.81186754",
"0.80481917",
"0.80468994",
"0.79780424",
"0.7962861",
"0.7959512",
"0.7946294",
"0.7936397",
"0.7929802",
"0.79278564",
"0.79269135",
"0.79246616",
"0.79200053",
"0.79158986",
"0.7915428",
"0.7913144",
"0.79076344",
"0.7903745",
"0.79023826",
"0.7... | 0.7714013 | 78 |
Random add gaussian blur to image Arguments | def random_blur(image, prob=.5, size=5):
blur = rand() < prob
if blur:
image = cv2.GaussianBlur(image, (size, size), 0)
return image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_blur(img, kernel_size = 5):\n return cv2.GaussianBlur(img, (kernel_size, kernel_size), 0)",
"def gaussian_blur(img, kernel_size):\r\n return cv2.GaussianBlur(img, (kernel_size, kernel_size), 0)",
"def gaussian_blur(img, kernel_size):\r\n return cv2.GaussianBlur(img, (kernel_size, kernel_s... | [
"0.7176239",
"0.7141123",
"0.7141123",
"0.7134332",
"0.71198636",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
"0.70945054",
... | 0.74194735 | 0 |
Random convert image to grayscale Arguments | def random_grayscale(image, prob=.2):
convert = rand() < prob
if convert:
#convert to grayscale first, and then
#back to 3 channels fake BGR
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = cv2.cvtColor(image, cv2.COLOR_GRAY2BGR)
return image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_gray_image(width = 100, height = 100):\n\n return (np.random.rand(width, height) * 256).astype(np.uint8)",
"def rgb2gray(image):\n return np.dot(image[..., :3], [0.299, 0.587, 0.114])",
"def generate_gray(self):\n\t\treturn cv2.cvtColor(self.image, cv2.COLOR_BGR2GRAY)",
"def grayscale(imag... | [
"0.70339316",
"0.6769607",
"0.6753246",
"0.67059416",
"0.6682948",
"0.6680781",
"0.66745496",
"0.66281205",
"0.66281205",
"0.66281205",
"0.66267246",
"0.66144603",
"0.66144603",
"0.66144603",
"0.66144603",
"0.6613307",
"0.65919155",
"0.658477",
"0.65830797",
"0.6579814",
"0.6... | 0.7720391 | 0 |
Random adjust sharpness for image Arguments | def random_sharpness(image, jitter=.5):
img = Image.fromarray(image)
enh_sha = ImageEnhance.Sharpness(img)
sharpness = rand(jitter, 1/jitter)
new_img = enh_sha.enhance(sharpness)
image = np.asarray(new_img)
return image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self,\n image,\n label=None):\n\n if random.randint(2):\n image[:, :, 1] *= random.uniform(self.lower, self.upper)\n\n # limits the value of the saturation channel to 1.0\n image[:, :, 1] = np.clip(image[:, :, 1], a_min=0.0, a_max... | [
"0.6841667",
"0.6827379",
"0.6702511",
"0.630429",
"0.62934244",
"0.625402",
"0.6229479",
"0.62253433",
"0.62225133",
"0.6212846",
"0.61988235",
"0.61853474",
"0.61853474",
"0.6136574",
"0.6082717",
"0.6050786",
"0.602881",
"0.6027008",
"0.60037863",
"0.59468615",
"0.5904938"... | 0.6935145 | 0 |
Generates random data sampled from i.i.d. normal distribution. | def _generate_normal_data(num_sample, num_dim, loc):
return np.random.normal(
size=(num_sample, num_dim), loc=loc, scale=1. / np.sqrt(num_dim)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Random_normal(*args):\n return _yarp.Random_normal(*args)",
"def normal(*args):\n return _yarp.Random_normal(*args)",
"def noise_normal():\n return scale * rng.normal(size=shape)",
"def generateNormalDraws(mu, sigma, N, seed):\n\n # Set up the RNG\n RNG = np.random.RandomState(se... | [
"0.73585945",
"0.7313451",
"0.70090866",
"0.6849865",
"0.6779849",
"0.6725723",
"0.66823244",
"0.6664469",
"0.6663253",
"0.6654554",
"0.66453296",
"0.66020507",
"0.6572783",
"0.65488034",
"0.6533855",
"0.6521462",
"0.65146214",
"0.64996153",
"0.6495347",
"0.6494726",
"0.64915... | 0.73498917 | 1 |
Gets a connection to the openstack service handled by this object. | def get_connection(self):
return connection.Connection(auth_url=self._auth_url,
project_name=self._project_name,
username=self._username,
password=self._password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conn(self):\n return os_conn.Connection(**self.os_auth_args)",
"def get_connection(self):\n \n return self.connection",
"def _openstack_connect(self):\n openstack_connector = OpenStackConnector(self.os_url, self.os_user, self.os_password, self.os_project_name,\n ... | [
"0.73552954",
"0.7266258",
"0.7223667",
"0.7201568",
"0.71829635",
"0.7072523",
"0.7072523",
"0.69985604",
"0.6981365",
"0.69428736",
"0.694103",
"0.6929386",
"0.6898398",
"0.68424034",
"0.68424034",
"0.68424034",
"0.6838334",
"0.67556304",
"0.6719687",
"0.66806626",
"0.66725... | 0.6472313 | 27 |
Get list of lines of a file | def getFileLines(filename, filepath=None):
with open(filepath and os.path.join(filepath, filename) or filename, 'r') as f:
return(f.readlines()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lines(f):\r\n try:\r\n fr = open(f)\r\n except:\r\n sys.stderr.write(\"can not open file {}\\n\".format(f))\r\n sys.exit(1)\r\n lines = fr.readlines()\r\n fr.close()\r\n return lines",
"def list_lines(file):\n f = open(file, 'r')\n tmp_list = f.readlines(... | [
"0.8358394",
"0.8272008",
"0.8208779",
"0.81824434",
"0.8160764",
"0.8098732",
"0.8053867",
"0.8018648",
"0.798158",
"0.79776525",
"0.796459",
"0.79011655",
"0.78380835",
"0.78281814",
"0.7798302",
"0.77554965",
"0.77345157",
"0.7692127",
"0.768268",
"0.7641929",
"0.7640512",... | 0.78074354 | 14 |
Initialises a solution vector randomly. | def _random(self, lower, upper):
self.vector = []
for i in range(len(lower)):
#self.vector.append(lower[i] + random.random() * (upper[i] - lower[i]))
self._genes.append(lower[i] + random.random() * (upper[i] - lower[i])) #giái trị bộ genes là ngầu nhiên | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_vect():\n rand_vector = np.random.rand(3)\n rand_vector /= np.linalg.norm(rand_vector)\n return rand_vector*0.282",
"def get_random_solution(self):\n ind_length = self.solution_length()\n return JspSolution(self, numpy.random.rand(ind_length))",
"def vec_init():\n return np... | [
"0.6804733",
"0.6687156",
"0.66452134",
"0.6460912",
"0.63900834",
"0.63881195",
"0.63103724",
"0.62466544",
"0.6217967",
"0.6200986",
"0.6188124",
"0.61688185",
"0.6141804",
"0.61329174",
"0.61307305",
"0.61208034",
"0.6095292",
"0.6081178",
"0.6034314",
"0.60070926",
"0.599... | 0.55947274 | 69 |
Given a mask array (list where masked elements are evaluated as True and unmasked elements are evaluated as False), return spans of unmasked list items. | def get_indices_unmasked_spans(mask):
spans = []
start = 0
while start < len(mask):
if mask[start]:
start += 1
continue
end = start
for i in range(start+1, len(mask)):
if mask[i]:
break
else:
end = i
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ezclump(mask):\n #def clump_masked(a):\n if mask.ndim > 1:\n mask = mask.ravel()\n idx = (mask[1:] - mask[:-1]).nonzero()\n idx = idx[0] + 1\n slices = [slice(left, right)\n for (left, right) in zip(itertools.chain([0], idx),\n itertools... | [
"0.6322516",
"0.6143212",
"0.5957384",
"0.5949529",
"0.5937182",
"0.58402705",
"0.58223253",
"0.57950306",
"0.5793569",
"0.5756423",
"0.57454306",
"0.5745066",
"0.5730671",
"0.57190424",
"0.57182413",
"0.57091194",
"0.564929",
"0.56377906",
"0.5608",
"0.5605491",
"0.55896264"... | 0.8073106 | 0 |
Check if the given node is an actual elif This is a problem we're having with the builtin ast module, which splits `elif` branches into a separate if statement. Unfortunately we need to know the exact type in certain cases. | def _is_actual_elif(self, node):
if isinstance(node.parent, astroid.If):
orelse = node.parent.orelse
# current if node must directly follow an "else"
if orelse and orelse == [node]:
if (node.lineno, node.col_offset) in self._elifs:
return T... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _node_is_test_condition(node):\n return isinstance(node, (astroid.If, astroid.While, astroid.Assert, astroid.IfExp))",
"def check_node_type( node, type ):\n \n if type == \"Literal\": type = NodeType.Literal\n elif type == \"Identifier\": type = NodeType.Identifier\n elif type == \"Operato... | [
"0.6012127",
"0.5947841",
"0.57938856",
"0.5522095",
"0.54348844",
"0.537608",
"0.5280825",
"0.5181435",
"0.5100073",
"0.5072605",
"0.5068145",
"0.50574076",
"0.4973254",
"0.49664274",
"0.4960981",
"0.49579325",
"0.49393392",
"0.49363297",
"0.49156407",
"0.4878969",
"0.486847... | 0.7444083 | 0 |
Check if the given if node can be simplified. The if statement can be reduced to a boolean expression in some cases. For instance, if there are two branches and both of them return a boolean value that depends on the result of the statement's test, then this can be reduced to `bool(test)` without losing any functionali... | def _check_simplifiable_if(self, node):
if self._is_actual_elif(node):
# Not interested in if statements with multiple branches.
return
if len(node.orelse) != 1 or len(node.body) != 1:
return
# Check if both branches can be reduced.
first_branch = no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _node_is_test_condition(node):\n return isinstance(node, (astroid.If, astroid.While, astroid.Assert, astroid.IfExp))",
"def to_z3_astIfExp(self, obj):\n condition = self.to_z3(obj.test)\n condition_type = self.resolve_type(obj.test)\n condition_cast = self.cast(condition, condition_ty... | [
"0.69385433",
"0.58333266",
"0.57372177",
"0.54948455",
"0.5447903",
"0.5376024",
"0.53598726",
"0.5349886",
"0.53388554",
"0.5322395",
"0.52803177",
"0.52725035",
"0.5256655",
"0.5238209",
"0.5220539",
"0.51309204",
"0.5120482",
"0.50832564",
"0.50831383",
"0.5082903",
"0.50... | 0.7107427 | 0 |
Function to load single json files | def read_data(file = 'json_file_location.json'):
data_frame = pd.read_json(file,
orient='records',
lines=True,
convert_dates=True,
keep_default_dates=True)
return data_frame | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_json(fname: str):\n\n return json.load(open(fname, 'r'))",
"def json_loader(filepath):\n with open(filepath, \"r\") as file_descriptor:\n data = json.load(file_descriptor)\n return data",
"def import_json(file_name): \n with open(file_name) as f:\n data = json.load(f)\n ... | [
"0.7293267",
"0.7281827",
"0.7261739",
"0.7186878",
"0.71547437",
"0.7146892",
"0.71170765",
"0.7115007",
"0.71062946",
"0.70885044",
"0.7075692",
"0.7063073",
"0.70630676",
"0.70510346",
"0.7050113",
"0.70498246",
"0.7022936",
"0.7008756",
"0.6992116",
"0.6969686",
"0.696305... | 0.0 | -1 |
Maximum input length supported by the encoder. | def max_positions(self):
return self.embed_positions.max_positions() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_length(self) -> int:\n return self._max_length",
"def max_length(self) -> int:\r\n return self._properties.max_len",
"def getMaxLength(self):\n return self._MaxLength",
"def max_sequence_length(self) -> int:\n return 1024",
"def max_length(self):\n return self.pro... | [
"0.81002706",
"0.8060489",
"0.79228634",
"0.77775884",
"0.77631557",
"0.7626666",
"0.741636",
"0.73796636",
"0.73759425",
"0.73526883",
"0.7337078",
"0.7310416",
"0.72743547",
"0.7169308",
"0.7153521",
"0.7069415",
"0.7033666",
"0.70276266",
"0.70172834",
"0.6986353",
"0.6919... | 0.0 | -1 |
Given data, find the top k most frequent words with associated counts | def get_top_freq_words(dat, k):
counts = np.array(dat['C'])
labels = np.array(dat['L'])
# indices of top k
temp1 = np.argpartition(-counts, k)
top_indices = temp1[:k]
# count values
temp2 = np.partition(-counts, k)
top_count_values = -temp2[:k]
# associated labels
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top_k_words(sentences, k):\r\n words = []\r\n for sentence in sentences:\r\n words.extend(sentence.split())\r\n #调用了库文件 Counter\r\n return [word for word, _ in Counter(words).most_common(k)]",
"def get_top_k_words(sentences, k):\r\n words = list()\r\n for sentence in sentence... | [
"0.76451427",
"0.76147795",
"0.76002",
"0.75935435",
"0.75396204",
"0.7468046",
"0.7320731",
"0.7277128",
"0.7080819",
"0.7023006",
"0.70126224",
"0.7011295",
"0.70041573",
"0.69930804",
"0.69636387",
"0.6957998",
"0.694585",
"0.6911243",
"0.6875208",
"0.6830648",
"0.6824501"... | 0.81985074 | 0 |
Attach a text label above each bar in rects, displaying its height. | def autolabel(rects):
for rect in rects:
height = rect.get_height()
if height > 0:
ax.annotate("{:.2e}".format(height),
xy=(rect.get_x() + rect.get_width() / 2, height),
xytext=(0, 3), # 3 points vertical offset
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def label_bar(rects, ax):\n for rect in rects:\n height = rect.get_height()\n ax.text(\n rect.get_x() + rect.get_width() / 2.0,\n height + 0.5,\n \"%.1f\" % height,\n fontsize=6,\n ha=\"center\",\n va=\"bottom\",\n )",
"def... | [
"0.8157239",
"0.7871823",
"0.78399026",
"0.78224117",
"0.78188604",
"0.77929604",
"0.7781746",
"0.7698081",
"0.76922953",
"0.7667911",
"0.7664531",
"0.7661016",
"0.76444286",
"0.76444286",
"0.7638637",
"0.76148486",
"0.7582601",
"0.755",
"0.7542978",
"0.7514687",
"0.74922395"... | 0.74268264 | 31 |
r""" Returns True if the ``.cspace`` attribute is valid (either bgr/rgb/gray/hsv/hls/lab) Returns False, otherwise (usually happens when foreign arrays (like ndarrays) are converted to Caer Tensors). | def is_null(self):
return not self._is_valid_cspace() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid(self):\n return 3 * self.width * self.height == len(self.data)",
"def _is_valid_instance(data_info: Dict) -> bool:\n # crowd annotation\n if 'iscrowd' in data_info and data_info['iscrowd']:\n return False\n # invalid keypoints\n if 'num_keypoints' in dat... | [
"0.6202482",
"0.6101784",
"0.60870373",
"0.6083854",
"0.59779316",
"0.59151244",
"0.5868447",
"0.58459455",
"0.5808744",
"0.57866824",
"0.5777898",
"0.5770825",
"0.57372475",
"0.57005066",
"0.5677731",
"0.5652462",
"0.55963933",
"0.5547108",
"0.55366457",
"0.5525755",
"0.5519... | 0.5961334 | 5 |
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" | def type(self) -> str:
return pulumi.get(self, "type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type(self) -> str:\n if len(self._resource_types) != 1:\n raise TypeError('Type needs to be specified manually, use .set or .add')\n return self._resource_types[0]",
"def resource_type(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"resource_type\")",
"def resource_... | [
"0.80913126",
"0.79661936",
"0.7903308",
"0.78849393",
"0.78658825",
"0.78658825",
"0.78658825",
"0.78658825",
"0.77752215",
"0.76706696",
"0.76589614",
"0.7190541",
"0.7168121",
"0.67498523",
"0.6641723"
] | 0.0 | -1 |
Test time zome field is required | def test_new_user_time_zone_field_is_required(self):
time_zone = 'Turkey'
user = get_test_user(time_zone=time_zone)
self.assertEquals(user.time_zone, time_zone) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_time_validator(self):\n invalid_time = 123\n result = time_validator(time=invalid_time)\n self.assertFalse(result)\n\n invalid_time = '12323fd'\n result = time_validator(time=invalid_time)\n self.assertFalse(result)\n\n invalid_time = '25:61:61'\n re... | [
"0.75487345",
"0.74301237",
"0.73426545",
"0.73013324",
"0.7089582",
"0.7056571",
"0.704261",
"0.7036097",
"0.69384503",
"0.6927563",
"0.6918242",
"0.6880913",
"0.6875269",
"0.68255144",
"0.67826295",
"0.66833234",
"0.66421735",
"0.66300553",
"0.66176885",
"0.66176885",
"0.65... | 0.6750303 | 15 |
Test if new user has invalid time zone field format | def test_new_user_invalid_time_zone_field(self):
time_zone = ''
user = get_test_user(time_zone=time_zone)
self.assertEquals(user.time_zone, pytz.timezone('Europe/Moscow')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_new_user_time_zone_field_is_required(self):\n time_zone = 'Turkey'\n user = get_test_user(time_zone=time_zone)\n\n self.assertEquals(user.time_zone, time_zone)",
"def validate_timezone_field(**kwargs):\n timezones = [timezone.name for timezone in TimeZoneType]\n time_zone = kw... | [
"0.7166154",
"0.6953968",
"0.68537086",
"0.62809",
"0.6238704",
"0.6186745",
"0.61741877",
"0.6158741",
"0.6050568",
"0.6031085",
"0.60169065",
"0.6005749",
"0.5966581",
"0.59589016",
"0.5937638",
"0.5924537",
"0.59159917",
"0.5911446",
"0.59039557",
"0.59001595",
"0.5883928"... | 0.78422016 | 0 |
Test event time zone is correct | def test_new_event_time_zone(self):
current_user = get_test_user()
cu_tz = pytz.timezone(current_user.time_zone)
event = models.Event.objects.create(
user=current_user,
name='New test Event',
date_time=cu_tz.localize(
datetime(2021,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_timezones(self):\n\n def _tz_test(url, tzdata, correct_date, msg):\n with open(self.placeholder) as fp:\n base_data = dict(self.event_base_data,\n title='timezone test', placeholder_img=fp)\n self.client.post(url, dict(base_da... | [
"0.80006254",
"0.7416202",
"0.73368967",
"0.72944486",
"0.7252191",
"0.68928766",
"0.6859745",
"0.67864376",
"0.6725041",
"0.67032546",
"0.66814554",
"0.6678539",
"0.6636833",
"0.6624611",
"0.6563103",
"0.6550318",
"0.6547358",
"0.6533654",
"0.6495414",
"0.64697427",
"0.64629... | 0.77617395 | 1 |
Add an item with a given priority to the queue | def push(self, item, priority):
entry = (priority, self.count, item)
heapq.heappush(self.heap, entry)
self.count += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, item, priority):\n heapq.heappush(self.elements, (priority, item))",
"def put(self, item, priority):\n heapq.heappush(self.elements, (priority, item))",
"def insert(self, priority: int, item: str) -> None:\r\n thing = (item, priority)\r\n self._heap.append(thing)\r\n ... | [
"0.80749923",
"0.80749923",
"0.77647394",
"0.7395661",
"0.7315518",
"0.73018885",
"0.7152065",
"0.7071578",
"0.69328606",
"0.69305295",
"0.6876352",
"0.6860378",
"0.6853653",
"0.68005246",
"0.67870885",
"0.6770501",
"0.676633",
"0.67404",
"0.67400616",
"0.67400616",
"0.673948... | 0.7990636 | 2 |
For each group of map labels, draw the label in text | def countLabels(map):
width = len(map[0])
height = len(map)
labels = labels_dict()
for row in range(height):
for col in range(width):
# assumes it hits the top left corner of a group of labels
#and that the labels are 10x10
label = map[col][row].label
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_label(rects):\n for rect in rects:\n height = rect.get_height()\n ax.annotate('{}'.format(height),\n xy=(rect.get_x() + rect.get_width() / 2, height),\n xytext=(0, 3), # 3 points vertical offset\n textcoords... | [
"0.7163383",
"0.7145834",
"0.7060999",
"0.69885135",
"0.6964637",
"0.6937688",
"0.6935706",
"0.69109154",
"0.69036114",
"0.6827906",
"0.6820551",
"0.68038535",
"0.68038535",
"0.67801535",
"0.67469203",
"0.67447996",
"0.67447996",
"0.6730519",
"0.6716291",
"0.6712363",
"0.6712... | 0.6481545 | 70 |
Helper to validate padding for filtfilt | def _validate_pad(padtype, padlen, x, axis, ntaps):
if padtype not in ["even", "odd", "constant", None]:
raise ValueError(
(
"Unknown value '%s' given to padtype. padtype "
"must be 'even', 'odd', 'constant', or None."
)
% padtype
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_padding_substitution(self, padded, fixed):\n assert fixed == sup.padding_filter(padded)",
"def check_padding(padding, which_pad):\n if type(padding) is not str:\n raise PlayfairError('Padding must be a string.')\n if len(padding) != 1:\n raise PlayfairError('The ' + which_pad ... | [
"0.71892345",
"0.63038504",
"0.6214952",
"0.5990858",
"0.59665954",
"0.5950324",
"0.5701012",
"0.5684682",
"0.56510854",
"0.5637654",
"0.5620104",
"0.560746",
"0.55823284",
"0.5564515",
"0.55378324",
"0.5536203",
"0.54664016",
"0.5462788",
"0.5445075",
"0.5430132",
"0.5429826... | 0.58034253 | 6 |
Remove linear trend along axis from data. | def detrend(data, axis=-1, type="linear", bp=0, overwrite_data=False):
if type not in ["linear", "l", "constant", "c"]:
raise ValueError("Trend type must be 'linear' or 'constant'.")
data = cp.asarray(data)
dtype = data.dtype.char
if dtype not in "dfDF":
dtype = "d"
if type in ["cons... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_detrend_linearx(self, evt):\n self.detrend(axis=0, type='linear')",
"def on_detrend_lineary(self, evt):\n self.detrend(axis=1, type='linear')",
"def _detrend(self,array):\n nSpace = array.shape[1]\n t = np.arange(self.nTimes)\n for space_coord in np.arange(nSpace):\n ... | [
"0.78005004",
"0.7268889",
"0.6974116",
"0.68480337",
"0.68165845",
"0.6667609",
"0.6622821",
"0.63799953",
"0.6343068",
"0.6314447",
"0.61504513",
"0.61294967",
"0.6011586",
"0.59825397",
"0.58122945",
"0.5750571",
"0.57194674",
"0.56937766",
"0.5688541",
"0.5688541",
"0.567... | 0.60681224 | 12 |
Frequency shift signal by freq at fs sample rate | def freq_shift(x, freq, fs):
x = cp.asarray(x)
return _freq_shift_kernel(x, freq, fs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_freq_shift(fq, ft, Np, f0, epsinf, W, Dvv):\n X=Np*pi*(fq-f0)/f0\n Ga0=Ga0_mult[ft]*2*pi*f0*epsinf*W*Dvv*(Np**2)\n C=Ct_mult[ft]*Np*W*epsinf\n Ba=Ga0*(sin(2.0*X)-2.0*X)/(2.0*X**2.0)\n return Ba/C/(2.0*pi)",
"def freq_from_fft(sig, fs):\n # Compute Fourier transform of windowed signal\n... | [
"0.6975678",
"0.6535362",
"0.65197223",
"0.64517295",
"0.64131504",
"0.62271523",
"0.6209057",
"0.618284",
"0.61672306",
"0.61105716",
"0.61072534",
"0.61043566",
"0.6081368",
"0.60773534",
"0.6046225",
"0.60206425",
"0.5990317",
"0.59671384",
"0.5946591",
"0.5944797",
"0.593... | 0.8313815 | 0 |
Gaussian cumulative density function. | def gaussian_cdf(x):
half = tf.constant(0.5, dtype=x.dtype)
one = tf.constant(1.0, dtype=x.dtype)
two = tf.constant(2.0, dtype=x.dtype)
return half * (one + tf.math.erf(x / tf.sqrt(two))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal_cdf(self, x, mu=[0.0], sigma=[1.0]):\n x = self.astensor(x)\n mu = self.astensor(mu)\n sigma = self.astensor(sigma)\n normal = torch.distributions.Normal(mu, sigma)\n return normal.cdf(x)",
"def gg_cdf(x, a, d, p):\n arg1 = a/p\n arg2 = np.power(x/a,p)\n phi... | [
"0.7056958",
"0.70417774",
"0.69852823",
"0.68855083",
"0.6855804",
"0.68492717",
"0.67889416",
"0.6724185",
"0.6719947",
"0.6658291",
"0.6648019",
"0.6621106",
"0.6614487",
"0.66136956",
"0.6601107",
"0.65834945",
"0.6582278",
"0.6575643",
"0.6563248",
"0.6512957",
"0.645386... | 0.7247571 | 0 |
Returns a handle pointing the context global object. Retruns a handle that points the the global object or root object of this context. This is the recommended way to get a handle for interfacing with context. | def objects(self):
return Handle(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_global_(self):\n return self.__global_",
"def _get_global_(self):\n return self.__global_",
"def _get_global_(self):\n return self.__global_",
"def _get_global_(self):\n return self.__global_",
"def _get_global_(self):\n return self.__global_",
"def _get_global_(self):\n return... | [
"0.65462375",
"0.65462375",
"0.65462375",
"0.65462375",
"0.65462375",
"0.65462375",
"0.65462375",
"0.65462375",
"0.6388934",
"0.6283155",
"0.6104299",
"0.60707515",
"0.6021567",
"0.59766966",
"0.59677446",
"0.5859359",
"0.5852086",
"0.5846269",
"0.5846269",
"0.58460426",
"0.5... | 0.51457226 | 76 |
Initialize this object. The input stream is any object that implements next() to return the next line of text input. | def __init__(self):
self._filters = []
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, input_file):\n self.filename = input_file\n self.EOF = False\n self.file_stream = open(self.filename, 'r')\n self.next_line = self.file_stream.readline()",
"def __init__(self, input_file: typing.TextIO) -> None:\n self.lines = input_file.read().splitlines()\n... | [
"0.7488333",
"0.7291219",
"0.688783",
"0.68283707",
"0.6822643",
"0.6655754",
"0.6605438",
"0.6391911",
"0.6379554",
"0.6347538",
"0.6339652",
"0.6328484",
"0.6206849",
"0.62051964",
"0.61865026",
"0.61844647",
"0.61618143",
"0.61419815",
"0.6131842",
"0.61254287",
"0.6108281... | 0.0 | -1 |
Split a line of text into a sequence of tokens. Lines are split based on the specified position of each field. | def _split(self, line):
return tuple(line[field.pos] for field in self._fields) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _split(self, line):\n tokens = line.split(self._delim)\n return tuple(tokens[field.pos] for field in self._fields)",
"def splitline (self, line):\n\t\tfields=[];add=fields.append\n\t\tcurrent_field = \"\"\n\t\twithin_field = 0\n\t\tfor ch in line:\n\t\t\tif ch in ['\\n', '\\t', chr(13)]:\n\t\t\... | [
"0.7224728",
"0.69125617",
"0.6740116",
"0.6579286",
"0.63987994",
"0.61904943",
"0.61153555",
"0.6075407",
"0.5986999",
"0.59554654",
"0.5928486",
"0.59123945",
"0.5900058",
"0.5888369",
"0.5880739",
"0.5800908",
"0.5754111",
"0.5743743",
"0.57307166",
"0.5703449",
"0.569560... | 0.6928344 | 1 |
Load C file into json string representation of ast | def file_to_json(filename, **kwargs):
ast = parse_file(filename, use_cpp=True,
cpp_path='clang',
cpp_args=['-E', r'-Iutils/fake_libc_include'])
return to_json(ast, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_ast(ast_file):\n json_data = json.load(open(contract_dir + ast_file + ast_extension))\n ast = json_data[\"ast\"]\n return ast",
"def evaluate(ast):\n fname = tofile(ast)\n output = check_output([\"nix-instantiate\", \"--eval\", \"--json\", fname])\n return json.loads(output)",
"def... | [
"0.70203817",
"0.6345079",
"0.6267277",
"0.5993948",
"0.5973048",
"0.5942457",
"0.5901561",
"0.5812884",
"0.5712316",
"0.56829953",
"0.56265867",
"0.5608861",
"0.56032026",
"0.5585123",
"0.551778",
"0.5512088",
"0.5437188",
"0.5428536",
"0.5421373",
"0.5392967",
"0.53923523",... | 0.65011257 | 1 |
This method should return a dictionary with the unit_id as the key, and the a list of dialogue_ids as the value | def test_get_unit_dialogue_map(self):
unit_dialogue = [{"unit_id": 1, "dialogue_id": 1},
{"unit_id": 2, "dialogue_id": 1},
{"unit_id": 1, "dialogue_id": 99},
{"unit_id": 2, "dialogue_id": 101}]
expected = {1: [1, 99], 2: [1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compose_unique_units(self):\n units = list(enumerate(list(itertools.product(*self.characteristics))))\n return map(lambda unit: {'uid': unit[0], 'role': unit[1][0], 'attack_type': unit[1][1]}, units)",
"def dialogues(self) -> Dict[DialogueLabel, Dialogue]:\n return self._dialogues_by_di... | [
"0.5934701",
"0.5696139",
"0.5350245",
"0.5235602",
"0.52182096",
"0.52075934",
"0.5185033",
"0.51571447",
"0.5106725",
"0.50907856",
"0.5062823",
"0.505479",
"0.50433666",
"0.50218666",
"0.5017818",
"0.500157",
"0.500157",
"0.49832633",
"0.49823126",
"0.49823126",
"0.4949488... | 0.69932944 | 0 |
Initialize object either from parameters specified or from an existing Resource object. If explicit parameters are specified then they will override values copied from a resource object supplied. | def __init__(self, uri = None, timestamp = None, length = None,
md5 = None, sha1 = None, sha256 = None, type = None,
change = None, path = None,
lastmod = None, resource = None,
capability = None, ln = None):
# Create from a Resource?
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: ReferenceArgs,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def init(self, resource):\n pass",
"def __init__(__self__,\n resource_name: str,\n opts: O... | [
"0.68289024",
"0.6771564",
"0.66897094",
"0.66514814",
"0.6634036",
"0.6631361",
"0.6564324",
"0.6546136",
"0.6519026",
"0.645802",
"0.6457382",
"0.6455975",
"0.64457655",
"0.6416582",
"0.64095885",
"0.64064455",
"0.63837796",
"0.6373908",
"0.63674444",
"0.63593996",
"0.63515... | 0.0 | -1 |
A modified version of http.client.parse_headers. | def parse_headers_stream(fp, _class=http.client.HTTPMessage):
headers = []
while True:
line = fp.readline(http.client._MAXLINE + 1)
if len(line) > http.client._MAXLINE:
raise http.client.LineTooLong("header line")
if line.startswith(b'X-ClickHouse-Progress: ') and trace_hea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_headers(self):\n\n headers = self._buf.strip().split('\\r\\n')\n for header in headers:\n (key, value) = header.split(': ')\n value = value.strip()\n key = key.lower()\n if key in self._headers:\n if isinstance(self._headers[key], ... | [
"0.77428234",
"0.74228334",
"0.73417515",
"0.70974433",
"0.7084986",
"0.7053789",
"0.7030173",
"0.6884369",
"0.6814578",
"0.6766415",
"0.66365033",
"0.66020954",
"0.65416044",
"0.65318173",
"0.65318173",
"0.65311515",
"0.650621",
"0.6477082",
"0.64351153",
"0.639578",
"0.6371... | 0.6141558 | 32 |
Compute whether the given grasp (at contacts with surface normals) can produce the desired_wrench. will be used for gravity resistance. | def contact_forces_exist(contacts, normals, num_facets, mu, gamma, desired_wrench):
grasp_map = get_grasp_map(contacts, normals, num_facets, mu, gamma)
try:
fc, residual = nnls(grasp_map, desired_wrench)
return fc, residual
except:
return None, float('inf') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conformToRestriction(self, graspType):\n if graspType is '1':\n return self.conformToRestrictionFromParallelGrasp()\n if graspType is '2':\n return self.conformToRestrictionFromPlanarPointContact()\n if graspType is '3':\n return self.conformToRestrictionFr... | [
"0.61007494",
"0.58902764",
"0.58694094",
"0.58572084",
"0.57024443",
"0.56195503",
"0.5606096",
"0.558195",
"0.55691653",
"0.55666006",
"0.55485207",
"0.55415094",
"0.55401677",
"0.55096465",
"0.54856676",
"0.5484039",
"0.5448293",
"0.5444744",
"0.5429573",
"0.5429376",
"0.5... | 0.0 | -1 |
Returns an XML string. | def NodeToString(xml_node):
return xml_node.toxml() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_xml_string(self) -> str:\n return etree.tostring(self.xml, method='c14n', exclusive=True).decode('utf-8')",
"def to_xml_string(self):\n xml_string = None\n outfile = StringIO() # this is an in memory file\n try:\n retur_val = self._write_to_stream(outfile, pretty_p... | [
"0.79532325",
"0.788137",
"0.7715354",
"0.7505547",
"0.7380417",
"0.732611",
"0.7234054",
"0.7220579",
"0.7116694",
"0.7114888",
"0.7010993",
"0.69869393",
"0.6984415",
"0.69727767",
"0.69684607",
"0.68857753",
"0.68491906",
"0.6796128",
"0.67866987",
"0.678073",
"0.67783797"... | 0.61924374 | 55 |
Returns the number of units in this layer. | def layer_output_size(self):
return len(self.listPcpt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_of_units(self) -> int:\n return pulumi.get(self, \"num_of_units\")",
"def num_of_units(self) -> int:\n return pulumi.get(self, \"num_of_units\")",
"def num_of_units(self) -> int:\n return pulumi.get(self, \"num_of_units\")",
"def numberOfUnits(self):\n return len(self.unit... | [
"0.85608226",
"0.85608226",
"0.85608226",
"0.8405076",
"0.79605865",
"0.77355707",
"0.77355707",
"0.7618517",
"0.7618517",
"0.7423447",
"0.73553354",
"0.7335407",
"0.7315718",
"0.72809416",
"0.7279034",
"0.7278359",
"0.72149175",
"0.71999824",
"0.7099402",
"0.70631653",
"0.70... | 0.0 | -1 |
Decode the output of a neural network with distributedencoded outputs. >>> listDblOutput = [0.23, 0.4, 0.01, 0.2, 0.3, 0.78, 0.51, 0.15, 0.2, 0.1] >>> distributed_decode_net_output(listDblOutput) 5 | def distributed_decode_net_output(listDblOutput):
# find the maximum number in the list
max_num = max(listDblOutput)
# return its index
return listDblOutput.index(max_num) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_decode_net_output(listDblOutput):\n lst = listDblOutput\n\n #CHANGED: before, it only went to the 4th bit, now it goes to the 5th\n for i in range(0,5):\n \n if (lst[i] < 0.50):\n lst[i] = 0\n else:\n lst[i] = 1 * (2 ** i)\n \n return sum(lst)",
"d... | [
"0.7045195",
"0.5413803",
"0.5276489",
"0.51839",
"0.5170262",
"0.50764114",
"0.50441986",
"0.50169206",
"0.5011963",
"0.5008652",
"0.49972004",
"0.4979113",
"0.4974571",
"0.49711418",
"0.49063587",
"0.48914748",
"0.48698673",
"0.48609623",
"0.4853162",
"0.48139787",
"0.47747... | 0.7998839 | 0 |
Convert a Windows 64 Hex BigEndian value to a date | def from_win_64_hex(dateAndTime):
base10_microseconds = int(dateAndTime, 16) / 10
try:
dateAndTime = datetime(1601, 1, 1) + timedelta(microseconds=base10_microseconds)
except:
dateAndTime = datetime(1601, 1, 1)
return dateAndTime.strftime('%Y-%m-%d %H:%M:%S.%f') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dtol(num):\n return codecs.decode(\"%08x\" % (num & 0xFFFFFFFF), \"hex\")[::-1]",
"def ymd_to_hex(self, year, month, day):\n b_year = format(year, '07b') # 0 is padding, 7 is length, b is for byte.\n b_month = format(month, '04b')\n b_day = format(day, '05b')\n\n return format... | [
"0.59797955",
"0.5701908",
"0.56535596",
"0.55932313",
"0.5528648",
"0.54566324",
"0.5440563",
"0.5363333",
"0.5341902",
"0.5304517",
"0.5291184",
"0.5257141",
"0.5233393",
"0.52249503",
"0.5208208",
"0.5155987",
"0.5152981",
"0.5149758",
"0.5142078",
"0.5133936",
"0.5103188"... | 0.7562497 | 0 |
Returns the type of the current result. | def currentResultType(*args, **kwargs):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_result_type(self):\n return self.result_type",
"def resulttype(self):\n return self._resulttype",
"def result_type(self):\n if not hasattr(self, \"_result_type\"):\n self._result_type = conf.lib.clang_getResultType(self.type)\n\n return self._result_type",
"def ... | [
"0.86414456",
"0.8480184",
"0.8048007",
"0.76176804",
"0.76118934",
"0.76053315",
"0.75596696",
"0.7485765",
"0.73493624",
"0.73493624",
"0.73493624",
"0.73493624",
"0.7330795",
"0.7321612",
"0.7247512",
"0.7243767",
"0.7223045",
"0.7223045",
"0.72194284",
"0.72059584",
"0.72... | 0.0 | -1 |
Returns true if the command's current result is an array of values. | def isCurrentResultArray(*args, **kwargs):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isArray(self):\n\n if self.array is not None:\n return True",
"def is_array(self):\n return not self.is_scalar",
"def isarray(v):\n return hasattr(v, \"__iter__\")",
"def is_array(self, value):\n _items = self._items()\n if _items and len(_items) > 1 and value is... | [
"0.6570073",
"0.63292295",
"0.62247276",
"0.6207103",
"0.61439097",
"0.6080181",
"0.60539997",
"0.6026332",
"0.59796935",
"0.5954267",
"0.5909796",
"0.5894838",
"0.5824907",
"0.58047444",
"0.57956904",
"0.57939875",
"0.578713",
"0.57772696",
"0.57631683",
"0.5741908",
"0.5642... | 0.68664783 | 0 |
Deltes the char befor the caret position. | def backspace_char(self):
if self.caretpos>0:
self.text = self.text[:self.caretpos-1]+self.text[self.caretpos:]
self.caretpos -= 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def del_char(self):\n para_idx, line_idx, char_idx = self.paragraph\n line = list(self.line)\n if line and char_idx < len(line):\n del line[char_idx]\n self.line = \"\".join(line)\n elif char_idx == len(line) and para_idx < len(self.text) - 1:\n nextline... | [
"0.79022",
"0.76753944",
"0.7459232",
"0.7017377",
"0.68971",
"0.67863005",
"0.66189414",
"0.65491617",
"0.6538769",
"0.642851",
"0.6407074",
"0.6390786",
"0.6388705",
"0.63748395",
"0.6346632",
"0.63280976",
"0.6273646",
"0.6269461",
"0.6232561",
"0.6207419",
"0.61526966",
... | 0.700621 | 4 |
Deltes the char after the caret position. | def delete_char(self):
self.text = self.text[:self.caretpos]+self.text[self.caretpos+1:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def del_char(self):\n para_idx, line_idx, char_idx = self.paragraph\n line = list(self.line)\n if line and char_idx < len(line):\n del line[char_idx]\n self.line = \"\".join(line)\n elif char_idx == len(line) and para_idx < len(self.text) - 1:\n nextline... | [
"0.74569666",
"0.7408816",
"0.7069536",
"0.70327973",
"0.70092267",
"0.6632795",
"0.6581389",
"0.6552035",
"0.65154505",
"0.65004236",
"0.6428149",
"0.64236057",
"0.6420798",
"0.6381507",
"0.6377577",
"0.6366387",
"0.6332846",
"0.6307925",
"0.6185797",
"0.6177314",
"0.6094922... | 0.7626287 | 0 |
Return all subclasses for a given class. | def subclasses(cls, and_self=False):
base = [cls] if and_self else []
sub = cls.__subclasses__()
return base + sub + [g for s in sub for g in subclasses(s, False)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subclasses(cls):\n if issubclass(cls, type):\n subclasses = cls.__subclasses__(cls)\n else:\n subclasses = cls.__subclasses__()\n for subclass in subclasses:\n subclasses.extend(get_subclasses(subclass))\n return subclasses",
"def get_all_subclasses(cls):\n\n all_subcl... | [
"0.7911755",
"0.7901086",
"0.78901064",
"0.7864274",
"0.77913785",
"0.7718604",
"0.76949614",
"0.7690115",
"0.7644046",
"0.75959444",
"0.7584839",
"0.7476739",
"0.7426279",
"0.74063843",
"0.7366819",
"0.73207223",
"0.7308443",
"0.7105727",
"0.70977336",
"0.707015",
"0.7059992... | 0.7889287 | 3 |
Get the weights from an array of distances and a parameter ``weights`` | def _get_weights(dist, weights):
if weights in (None, "uniform"):
return None
elif weights == "distance":
# if user attempts to classify a point that was zero distance from one
# or more training points, those training points are weighted as 1.0
# and the other points as 0.0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _weights(self, weights):\n if (self._cmp(list(weights), list(self.conjugateIrrep(weights))) in [-1, 0]) and not (np.all(\n (self.conjugateIrrep(weights)) == weights)):\n return [np.array([-1, 1], dtype=int) * el for el in self._weights(self.conjugateIrrep(weights))]\n ... | [
"0.68911946",
"0.688361",
"0.6749249",
"0.6667454",
"0.64196193",
"0.6419066",
"0.6411521",
"0.6382344",
"0.63398814",
"0.63325775",
"0.6329552",
"0.6251533",
"0.6238486",
"0.6209093",
"0.6203597",
"0.61917394",
"0.61738336",
"0.6168438",
"0.6157318",
"0.6141318",
"0.6130731"... | 0.75348663 | 0 |
r""" Set the radius of overconvergence to be `r`, where `r` is a rational number in the interval `0 < r < \frac{p}{p+1}`. This only makes sense if the base ring contains an element of normalised valuation `\frac{12r}{p1}`. If this valuation is an integer, we use the appropriate power of `p`. Otherwise, we assume the ba... | def _set_radius(self, radius):
p = ZZ(self.prime())
if (radius < 0 or radius > p/(p+1)):
raise ValueError("radius (=%s) must be between 0 and p/(p+1)" % radius)
d = 12/(p-1)*radius
if d.is_integral():
self._const = p ** ZZ(d)
self._radius = radiu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dist_radius(self, Rp):\n\n # if called for the first time, define distribution for albedo\n if self.dist_radius_built is None:\n _, Rgen = self.gen_sma_radius(int(1e6))\n Rpr = self.Rprange.to(\"earthRad\").value\n Rpp, Rpedges = np.histogram(\n Rge... | [
"0.66041785",
"0.6379871",
"0.616353",
"0.6154371",
"0.60290647",
"0.5913588",
"0.5910352",
"0.58439773",
"0.5813401",
"0.5794667",
"0.57680285",
"0.5736492",
"0.5713852",
"0.57058096",
"0.5686155",
"0.56733626",
"0.56695735",
"0.56272715",
"0.56081164",
"0.55664843",
"0.5560... | 0.66647047 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.