query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Check that the template was rendered | def rendered(template):
def was_rendered(client, response, testcase):
testcase.assertTemplateUsed(response, template)
return was_rendered | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _validate_template(self, template):\n try:\n templater.Template(template, self.hass).async_render()\n return True\n except Exception as exception: # pylint: disable=broad-except\n _LOGGER.error(exception)\n pass\n return False",
"def tes... | [
"0.72408986",
"0.65604",
"0.647206",
"0.63943523",
"0.6388394",
"0.6358663",
"0.63448054",
"0.6297637",
"0.6297637",
"0.6272517",
"0.6264347",
"0.6259718",
"0.6252725",
"0.6245319",
"0.62295973",
"0.6227864",
"0.6227864",
"0.6158289",
"0.61369985",
"0.6132051",
"0.6128815",
... | 0.7561209 | 0 |
Check that the email.outbox contains n items | def outbox_len(count):
def outbox_len_is(client, response, testcase):
testcase.assertEqual(
len(mail.outbox),
count
)
return outbox_len_is | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_not_empty(self, wait_time):\n for i in range(3):\n self.refresh_emailbox(wait_time)\n if not self._device(resourceId='com.tct.email:id/empty_view').exists:\n self._logger.debug('The box is not empty')\n return True\n self._logger.debug('Th... | [
"0.6196226",
"0.61041015",
"0.57169133",
"0.5665311",
"0.5621528",
"0.55776346",
"0.55671704",
"0.5560721",
"0.55464005",
"0.5522656",
"0.5504371",
"0.546202",
"0.54347897",
"0.54145616",
"0.53828126",
"0.5365601",
"0.53643",
"0.53439236",
"0.5324718",
"0.5317421",
"0.531184"... | 0.662837 | 0 |
Set the pool of servers used by this client. | def set_servers(self, servers):
self.servers = []
self.buckets = []
for server_desc in servers:
if type(server_desc) == tuple:
server_addr, weight = server_desc
else:
server_addr, weight = server_desc, 1
server = _ServerConnection(server_addr, weight, self._debuglog)
self.servers.append(se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_pool(self, server_pool):\n\n self._server_pool = server_pool",
"def set_servers(self, servers):\r\n self.servers = [_Host(s, self.debug, dead_retry=self.dead_retry,\r\n socket_timeout=self.socket_timeout)\r\n for s in servers]\r\n ... | [
"0.7319679",
"0.680685",
"0.6783699",
"0.6467647",
"0.6271275",
"0.615868",
"0.60961",
"0.60128826",
"0.5960502",
"0.5913157",
"0.58820456",
"0.5873742",
"0.5798574",
"0.5772111",
"0.5718808",
"0.5644137",
"0.55850923",
"0.55629134",
"0.5554513",
"0.55439126",
"0.55362344",
... | 0.7087884 | 1 |
Get statistics from each of the servers. | def get_stats(self):
data = []
for server in self.servers:
stats = yield server.get_stats()
data.append(stats)
raise StopIteration(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getServerStats():\n return _xmlUrlToDict(serverString + \"/rest/stats\", int)",
"def get_stats(self):\n\n\t\tserver_data = {}\n\n\t\tyield self.sendall(\"stats\\r\\n\")\n\n\t\twhile True:\n\t\t\tline = yield self.read_line()\n\n\t\t\tif not line or line.strip() == \"END\":\n\t\t\t\tbreak\n\n\t\t\t_stat, n... | [
"0.7074891",
"0.699148",
"0.69702584",
"0.67387414",
"0.67188823",
"0.6682422",
"0.6670441",
"0.6586258",
"0.6582014",
"0.65445226",
"0.6522328",
"0.65184695",
"0.65160424",
"0.6503475",
"0.64788616",
"0.64288133",
"0.6426006",
"0.6406493",
"0.64061654",
"0.6395011",
"0.63823... | 0.7845391 | 0 |
Sends a command to the server to atomically increment the value for ``key`` by ``delta``, or by 1 if ``delta`` is unspecified. Returns None if ``key`` doesn't exist on server, otherwise it returns the new value after incrementing. Note that the value for ``key`` must already exist in the memcache, and it must be the st... | def incr(self, key, delta=1):
return self._incrdecr("incr", key, delta) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incr(self, key, delta=1, callback=None):\n self._incrdecr(\"incr\", key, delta, callback=callback)",
"def incr(self, key, delta=1):\r\n if delta < 0:\r\n return self._incrdecr(\"decr\", key, -delta)\r\n else:\r\n return self._incrdecr(\"incr\", key, delta)",
"def ... | [
"0.77754945",
"0.77449256",
"0.76950294",
"0.7513234",
"0.6945156",
"0.6858105",
"0.6754959",
"0.66525286",
"0.63007706",
"0.6083981",
"0.599613",
"0.59376466",
"0.59372324",
"0.5911901",
"0.5840948",
"0.5809797",
"0.57680327",
"0.5759166",
"0.56261635",
"0.5539868",
"0.54871... | 0.77985793 | 0 |
For each key in data, determine which server that key should be mapped to. Returns a dict. Keys are `_ServerConnection` instances; for each server, the value is a list of (prefixed_key, original_key) tuples for all values which belong on that server. | def _map_keys_to_servers(self, key_iterable, key_prefix):
# Only check the prefix once
key_extra_len = len(key_prefix)
if key_prefix:
check_key(key_prefix)
# server -> list of (prefixed_key, value)
server_keys = {}
deprefix = {}
# build up a list for each server of all the keys we want.
for orig_k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _map_and_prefix_keys(self, key_iterable, key_prefix):\r\n # Check it just once ...\r\n key_extra_len=len(key_prefix)\r\n #changed by steve\r\n #if key_prefix:\r\n #self.check_key(key_prefix)\r\n\r\n # server (_Host) -> list of unprefixed server keys in mapping\r\n ... | [
"0.671543",
"0.57453936",
"0.5713001",
"0.57047987",
"0.5527355",
"0.53337836",
"0.5226764",
"0.5178444",
"0.517593",
"0.50799996",
"0.50652796",
"0.50172985",
"0.4971343",
"0.49088967",
"0.49088296",
"0.48994195",
"0.48865232",
"0.4877507",
"0.48635",
"0.48313108",
"0.482054... | 0.69429505 | 0 |
Transform value to a storable representation, returning a tuple of the flags and the new value. | def _value_to_stored(value, min_compress_len):
flags = 0
if isinstance(value, str):
pass
elif isinstance(value, int):
flags |= Client._FLAG_INTEGER
value = "%d" % value
# Don't try to compress it
min_compress_len = 0
elif isinstance(value, long):
flags |= Client._FLAG_LONG
value = "%d" % v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _val_to_store_info(self, val, min_compress_len):\r\n flags = 0\r\n if isinstance(val, str):\r\n pass\r\n elif isinstance(val, int):\r\n flags |= Client._FLAG_INTEGER\r\n val = \"%d\" % val\r\n # force no attempt to compress this silly string.\r\n... | [
"0.59164286",
"0.5815009",
"0.57775044",
"0.5704896",
"0.554912",
"0.5429599",
"0.5235166",
"0.52273405",
"0.5196163",
"0.5105681",
"0.508569",
"0.5038232",
"0.50112695",
"0.5006383",
"0.49907935",
"0.49732548",
"0.49670067",
"0.4964211",
"0.49320275",
"0.4927446",
"0.490499"... | 0.6581007 | 0 |
Test incr and decr functions | def test_incrdecr(self):
yield self.conn.set("an_integer", 42)
self.assertEqual((yield self.conn.incr("an_integer", 1)), 43)
self.assertEqual((yield self.conn.decr("an_integer", 1)), 42) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testIncrementDecrement(self):\n\n memcache.incr('unknown_key')\n assert memcache.get('unknown_key') == None\n memcache.set('counter', 0)\n assert memcache.get('counter') == 0\n memcache.incr('counter')\n assert memcache.get('counter') == 1\n memcache.incr('count... | [
"0.7287375",
"0.6329485",
"0.63262177",
"0.62672204",
"0.6183841",
"0.6032318",
"0.6031581",
"0.5853862",
"0.5818598",
"0.5796555",
"0.57911915",
"0.57771933",
"0.57524484",
"0.56881315",
"0.56778234",
"0.56689155",
"0.566017",
"0.5618242",
"0.5608999",
"0.55975217",
"0.55819... | 0.7240594 | 1 |
Check that invalid keys raise the appropriate exception | def test_invalid_keys(self):
try:
yield self.conn.set("this has spaces", 1)
except ValueError:
pass
else:
self.fail("key with spaces did not raise ValueError")
try:
yield self.conn.set("\x10control\x02characters\x11", 1)
except ValueError:
pass
else:
self.fail("key with control character... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_keyerror(self):\n try:\n self.db['foo']\n except KeyError, e:\n assert \"no key 'foo' in database <SequenceFileDB\" in str(e), str(e)",
"def _check_key(self, key):\n raise NotImplementedError",
"def validate_key_throw(*args):\n validation_result = validate... | [
"0.74442935",
"0.74044627",
"0.73613185",
"0.72661304",
"0.7248212",
"0.72250146",
"0.7207309",
"0.72047716",
"0.7202045",
"0.71926993",
"0.71520114",
"0.7141901",
"0.7126506",
"0.7093022",
"0.7073858",
"0.7037861",
"0.70023704",
"0.6989978",
"0.6964261",
"0.69501865",
"0.692... | 0.7550915 | 0 |
Check that get_multi works as expected | def test_get_multi(self):
yield self.conn.set("an_integer", 42)
yield self.conn.set("a_string", "hello")
res = yield self.conn.get_multi([ "a_string", "an_integer" ])
self.assertEquals(res, { "a_string": "hello", "an_integer": 42 }) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_multi(self):\n self.assertEqual(6, foo.multi(2, 3))",
"def test_multi(self):\n self.assertEqual(6, multi(2, 3))",
"def test_get_multi_argument(self):\n models.storage.close()\n models.storage = models.engine.db_storage.DBStorage()\n models.storage.reload()\n o... | [
"0.7208365",
"0.7107856",
"0.66856176",
"0.64896005",
"0.6420742",
"0.6312199",
"0.6270394",
"0.6264926",
"0.62275136",
"0.621508",
"0.62059",
"0.6088066",
"0.60627234",
"0.60491973",
"0.6030645",
"0.5929987",
"0.5928162",
"0.59056866",
"0.58726704",
"0.5856411",
"0.5839454",... | 0.7426123 | 0 |
Inserts the interval into the tree. | def insert(self, interval):
if self.root == None:
self.root = Node(interval)
return self.root
(start, end) = interval
node = self.root
while True:
if node.key <= start:
path = 'right'
else:
path = 'left'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, interval):\n\t\tif not self.head and not self.tail:\n\t\t\tself.head = interval\n\t\t\tself.tail = interval\n\t\telif interval.start <= (self.tail.end + 1):\n\t\t\tself.tail.end = interval.end\n\t\telse:\n\t\t\tself.tail.next = interval\n\t\t\tself.tail = interval",
"def insert(self, item):\n ... | [
"0.7717948",
"0.6542942",
"0.6509033",
"0.6505067",
"0.64955026",
"0.64484197",
"0.64471847",
"0.644557",
"0.6391438",
"0.6373396",
"0.6361766",
"0.63453394",
"0.6314026",
"0.62809587",
"0.62677604",
"0.62472606",
"0.624186",
"0.62068784",
"0.61892736",
"0.61792856",
"0.61694... | 0.7850783 | 0 |
raises the given exception type in the context of this thread | def raise_exc(self, exctype):
_async_raise(self._get_my_tid(), exctype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raise_exc(self, exctype):\n _async_raise(self._get_my_tid(), exctype)",
"def raise_exc(self, exctype):\n _async_raise(self._get_my_tid(), exctype)",
"def exception(self, *args, **kwargs):",
"def throw(self, type, value=None, traceback=None):\n pass",
"def exception(self, e):\n ... | [
"0.754653",
"0.754653",
"0.73001415",
"0.72129756",
"0.71473205",
"0.7090101",
"0.70805275",
"0.7043147",
"0.6917533",
"0.6837347",
"0.6776692",
"0.67522043",
"0.6658733",
"0.66576314",
"0.6646157",
"0.6635256",
"0.6635256",
"0.6628891",
"0.6615626",
"0.6608355",
"0.66057897"... | 0.76775926 | 0 |
Add VM to db Return True if this is new. | def add_cloudyvent_vm(self, runname, iaasid, nodeid, hostname, service_type, parent, runlogdir, vmlogdir):
cyvm = self.get_by_iaasid(iaasid)
if not cyvm:
cyvm = _CYVM(runname, iaasid, nodeid, hostname, service_type, parent, runlogdir, vmlogdir)
self.session.add(cyvm)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, database):\n id = database.session.query(Workout.id) \\\n .filter(Workout.external_id == self.external_id) \\\n .filter(Workout.source == self.source) \\\n .first()\n if id:\n # don't add if this workout has already been added\n ret... | [
"0.6002193",
"0.58125263",
"0.57646483",
"0.5651389",
"0.54877454",
"0.5483257",
"0.5449598",
"0.5449598",
"0.5433799",
"0.5397175",
"0.53970116",
"0.53811187",
"0.53527033",
"0.5349176",
"0.53205526",
"0.53083843",
"0.52993494",
"0.52819586",
"0.52705383",
"0.52662474",
"0.5... | 0.628304 | 0 |
Parse ingredients The ingredients come in from the form as normal key value pairs. This needs to be changed so that the ingredients can be stored as the following data structure. [ { | def _parse_ingredients(recipe):
ingredients = []
group_counter = 1
counter = 0
filtered_dict = {k: v for k, v in recipe.items() if "ingredient" in k}
ingredient = {}
for key, value in filtered_dict.items():
if not value:
continue
elif key == f"ingredient{group_coun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipe_parser(form_data, user):\n\n # The way the ingredients and steps data is structured in the form data is not the\n # structure required for the database so additional processing is required. The\n # `ingredients` and `steps` lists will be created and added to the recipe\n recipe[\"ingredients... | [
"0.70173126",
"0.69355285",
"0.65697306",
"0.62525654",
"0.6195944",
"0.6152212",
"0.6131279",
"0.598573",
"0.59830916",
"0.5981633",
"0.5865807",
"0.58411986",
"0.58324665",
"0.580999",
"0.56558895",
"0.5591535",
"0.5525932",
"0.5497969",
"0.54900944",
"0.5484163",
"0.541782... | 0.79610616 | 0 |
Parse steps The steps come in from the form as normal key value pairs. This needs to be changed so that the ingredients can be stored as the following data structure. [ "Dice chicken", "Cook chicken until brown" ] | def _parse_steps(recipe):
steps = []
filtered_dict = {k: v for k, v in recipe.items() if "step" in k}
for key, value in filtered_dict.items():
if value:
steps.append(value)
return steps | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_ingredients(recipe):\n ingredients = []\n group_counter = 1\n counter = 0\n\n filtered_dict = {k: v for k, v in recipe.items() if \"ingredient\" in k}\n ingredient = {}\n\n for key, value in filtered_dict.items():\n if not value:\n continue\n\n elif key == f\"i... | [
"0.61660594",
"0.61499614",
"0.5814299",
"0.5728871",
"0.5694139",
"0.56098646",
"0.556041",
"0.5349966",
"0.5326637",
"0.5303917",
"0.52398884",
"0.52076477",
"0.5195352",
"0.51346636",
"0.5120102",
"0.5115197",
"0.50925595",
"0.501864",
"0.50049645",
"0.4997988",
"0.4988191... | 0.71416456 | 0 |
Strip excess data Remove any references to the old data structure from the initial form data. This will be old `ingredients` and `steps` keys | def _strip_excess_data(recipe):
for key in list(recipe.keys()):
if key == "ingredients" or key == "steps":
continue
elif "ingredient" in key or "step" in key:
del recipe[key]
return recipe | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanStep(idict):\n for step in ['input', 'output']:\n data = idict.get(step, {})\n for key, values in data.items():\n for elem in values:\n for skip in ['pfn', 'InputPFN', 'OutputPFN', 'inputpfns']:\n if skip in elem:\n del e... | [
"0.6569909",
"0.61799103",
"0.6013431",
"0.59730214",
"0.59530836",
"0.5908101",
"0.5787217",
"0.5767013",
"0.5740882",
"0.57120657",
"0.5707393",
"0.56738675",
"0.5667914",
"0.5654368",
"0.55943626",
"0.55742645",
"0.5562125",
"0.5559802",
"0.55534947",
"0.555338",
"0.555300... | 0.8121244 | 0 |
Recipe parser Bundles up the information retrieved from the request, parses it and strips away the excess information. | def recipe_parser(form_data, user):
# The way the ingredients and steps data is structured in the form data is not the
# structure required for the database so additional processing is required. The
# `ingredients` and `steps` lists will be created and added to the recipe
recipe["ingredients"] = _parse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_request(self, request):\n request.process_inputs()",
"def parseRemainingVariables(json_response, recipe):\n ready_in_minutes = json_response.get(\"readyInMinutes\")\n recipe.ready_in_minutes = int(ready_in_minutes)\n\n servings = json_response.get(\"servings\")\n recipe.servings = in... | [
"0.6257471",
"0.62344533",
"0.5686614",
"0.56802547",
"0.5585636",
"0.5573089",
"0.5454585",
"0.53896827",
"0.5322964",
"0.530237",
"0.5281328",
"0.5248121",
"0.5238918",
"0.52310014",
"0.52302814",
"0.51896566",
"0.5145601",
"0.511923",
"0.51176846",
"0.51045305",
"0.5035898... | 0.64149237 | 0 |
This function will return a boolean if a user with specific username exits in the database, it will support later tests of user with assertion Function, will search for a user id that has matching username from the arguments | def userExists(self, username):
data = db.session.query(User.id).filter_by(username = username).first()
if data is None:
return False
else:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_exists(username):\n sql = \"SELECT username \" \\\n \"FROM users \" \\\n \"WHERE username=:username\"\n result = db.session.execute(sql, {\"username\": username})\n user = result.fetchone()\n if user is None:\n return False\n else:\n return True",
"def is_u... | [
"0.7592645",
"0.75204927",
"0.7509843",
"0.74982107",
"0.7488085",
"0.7488085",
"0.74790424",
"0.74468815",
"0.7440057",
"0.7429507",
"0.74283344",
"0.7402009",
"0.73424625",
"0.7338444",
"0.73368734",
"0.7325905",
"0.7322203",
"0.73187786",
"0.7275225",
"0.7264799",
"0.72493... | 0.7744443 | 0 |
This function will search the booking of specific user id and car id then tell whether it exists or not | def bookingExists(self, user_id, car_id):
data = db.session.query(Booking).filter_by(user_id = user_id, car_id = car_id).first()
if data is None:
return False
else:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_bookings(bookingid, username, car_id):\n\n # get booking object for bookingid\n booking = Booking.query.get(bookingid)\n print(\"Booking:::\")\n print(booking)\n\n user = booking.customer\n print(\"User:::\")\n print(user)\n \n print(\"Params:::\"+bookingid+\"--\"+username+\... | [
"0.6837736",
"0.6354792",
"0.61274904",
"0.6110173",
"0.58761245",
"0.58010334",
"0.5644561",
"0.5604423",
"0.5591727",
"0.5572659",
"0.5558989",
"0.5531499",
"0.54869264",
"0.5457973",
"0.53667784",
"0.5342457",
"0.53367656",
"0.5316068",
"0.52929175",
"0.5258301",
"0.519973... | 0.79800326 | 0 |
This function will search the history of specific user id and car id then tell whether it exists or not | def historyExists(self, user_id, car_id):
data = db.session.query(History).filter_by(user_id = user_id, car_id = car_id).first()
if data is None:
return False
else:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_history(self, user):\n\n header = connect(self.__path)\n curs = header.cursor()\n encrypted_id = md5((str(user.id) + \"typicaluser\").encode()).hexdigest()\n curs.execute(\"SELECT * FROM users WHERE id = (?)\", (encrypted_id,))\n data = curs.fetchall()\n return len... | [
"0.6492603",
"0.59272593",
"0.58328664",
"0.5809773",
"0.5701043",
"0.5635138",
"0.5616981",
"0.53315604",
"0.5285922",
"0.5251379",
"0.5230105",
"0.5202547",
"0.5191416",
"0.51679724",
"0.51483643",
"0.51421005",
"0.5132743",
"0.51297987",
"0.5099777",
"0.5097889",
"0.509201... | 0.7956357 | 0 |
This test will test the login credentials by query the database to see if that username and password do exist | def test_login(self):
username = "user1"
password = "pw1"
userID = 1
data = db.session.query(User.id).filter_by(username = username, password = password).first()
self.assertTrue(data is not None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_db(args):\n # Open connection to the registered users db\n base_path = \"pypackage\"\n users_db = \"openaq_users.db\"\n conn = sqlite3.connect(os.path.join(base_path, users_db))\n cursor = conn.cursor()\n\n # Check for username\n row = cursor.execute(\"SELECT * FROM user_database WHE... | [
"0.7468209",
"0.7456986",
"0.7269804",
"0.72061574",
"0.7067546",
"0.70660067",
"0.70542073",
"0.7041604",
"0.69754773",
"0.6974427",
"0.6931147",
"0.69266355",
"0.6925161",
"0.6922705",
"0.69079673",
"0.6888839",
"0.68805784",
"0.68792796",
"0.68628114",
"0.68610346",
"0.684... | 0.759397 | 0 |
This function will be the getter for dummy user id we created in the test abow | def get_test_id(self):
test_username = "testusername"
test_user_id = db.session.query(User.id).filter_by(username = test_username).first()
print(test_user_id)
return test_user_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_id_get(self):\n pass",
"def get_user_id(self):\n raise NotImplementedError",
"def test_get_user_id(self):\n print('(' + self.test_get_user_id.__name__+')',\n self.test_get_user_id.__doc__)\n # for patient\n self.assertEqual(\n PATIENT_ID,... | [
"0.82884496",
"0.7636512",
"0.7501366",
"0.74051195",
"0.7372923",
"0.7365709",
"0.73336416",
"0.7273932",
"0.722477",
"0.72180974",
"0.72082794",
"0.7208228",
"0.717936",
"0.70351905",
"0.70351905",
"0.70351905",
"0.7012597",
"0.700154",
"0.6981743",
"0.6961412",
"0.6958782"... | 0.76873684 | 1 |
This test will user history by query the database to see if any row with matching user id (in this case 12) exists | def test_userHistories(self):
user_id = 12
histories = History.query.filter_by(user_id = user_id).all()
self.assertTrue((histories is not None)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_history(self, user):\n\n header = connect(self.__path)\n curs = header.cursor()\n encrypted_id = md5((str(user.id) + \"typicaluser\").encode()).hexdigest()\n curs.execute(\"SELECT * FROM users WHERE id = (?)\", (encrypted_id,))\n data = curs.fetchall()\n return len... | [
"0.7834494",
"0.6747436",
"0.6676087",
"0.6339552",
"0.6306387",
"0.6265124",
"0.62559104",
"0.6212702",
"0.6148387",
"0.6148346",
"0.6137069",
"0.6118635",
"0.61039686",
"0.60899067",
"0.60179096",
"0.5970495",
"0.59647316",
"0.5952292",
"0.5942389",
"0.59386134",
"0.5935210... | 0.76068485 | 1 |
This test will test the car search by query the database to see if any car with specific make, body type, etc do exist | def test_searchCar(self):
make = "Toyota"
body_type = "Seden"
colour = "Black"
seats = "5"
cost_per_hour = "10.5"
booked = True
cars = db.session.query(Car).filter(or_(Car.make == make,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_a_car_make(car_make):\n car_makes = models.CarMake.objects.all()\n\n assert car_make\n assert car_make.name == \"Volkswagen\"\n assert len(car_makes) == 1",
"def test_filter_make_and_model(self):\n request = self.factory.get('/api/v1/cars', {'make': 'BMW',\n ... | [
"0.7030627",
"0.6953",
"0.6661251",
"0.64787984",
"0.6447302",
"0.6376898",
"0.63212156",
"0.62511206",
"0.6214951",
"0.6190375",
"0.6076356",
"0.60682404",
"0.5993362",
"0.5983236",
"0.5946412",
"0.590402",
"0.59029984",
"0.5900849",
"0.5812821",
"0.58114743",
"0.5802515",
... | 0.8014443 | 0 |
This test will create a booking in the database | def test_bookCar(self):
user_id = "12"
car_id = "6"
begin_date = "2020-05-21"
begin_time = "12:00:00"
return_date = "2020-05-23"
return_time = "12:00:00"
begin_datetime = "{} {}".format(begin_date, begin_time)
return_datetime = "{} {}".forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_bookings(self):\n baker.make_recipe('booking.user', _quantity=3)\n baker.make_recipe('booking.future_EV', _quantity=2)\n self.assertEqual(Booking.objects.all().count(), 0)\n management.call_command('create_bookings')\n self.assertEqual(Booking.objects.all().count(... | [
"0.75097334",
"0.73627186",
"0.7205623",
"0.7142108",
"0.7126723",
"0.7043033",
"0.6995864",
"0.69878817",
"0.69494665",
"0.6936681",
"0.6909777",
"0.68665344",
"0.6819778",
"0.6799046",
"0.6789994",
"0.6734838",
"0.6725396",
"0.66904336",
"0.6687076",
"0.66357887",
"0.661393... | 0.7655829 | 0 |
This test will delete a booking in the database | def test_cancelBooking(self):
user_id = "12"
car_id = "6"
begin_date = "2020-05-21"
begin_time = "12:00:00"
begin_datetime = "{} {}".format(begin_date, begin_time)
booking = db.session.query(Booking).filter( Booking.user_id == user_id,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_meeting_delete(self):\n pass",
"def test_delete_book(self):\n response = self.client.delete(self.book.get_absolute_url()) \n self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)\n self.assertEqual(Book.objects.count(), 0)",
"def booking_delete(id):\n ... | [
"0.7421814",
"0.7413696",
"0.7400403",
"0.7325648",
"0.7278549",
"0.71134543",
"0.7106417",
"0.70954233",
"0.7064444",
"0.6992723",
"0.69602615",
"0.6913653",
"0.6905339",
"0.6885712",
"0.68804866",
"0.68193513",
"0.6801034",
"0.6797192",
"0.6784873",
"0.6738316",
"0.673257",... | 0.7573865 | 0 |
This test will create a booking in the database, then will run the unlockCar function | def test_unlockCar(self):
user_id = "12"
car_id = "7"
begin_date = "2020-05-21"
begin_time = "12:00:00"
return_date = "2020-05-23"
return_time = "12:00:00"
begin_datetime = "{} {}".format(begin_date, begin_time)
return_datetime = "{} {}".for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bookCar(self):\n user_id = \"12\"\n car_id = \"6\"\n begin_date = \"2020-05-21\" \n begin_time = \"12:00:00\"\n return_date = \"2020-05-23\"\n return_time = \"12:00:00\"\n\n begin_datetime = \"{} {}\".format(begin_date, begin_time) \n ret... | [
"0.7627322",
"0.75792533",
"0.7312907",
"0.6784527",
"0.6369919",
"0.63560116",
"0.62711424",
"0.61127406",
"0.60388106",
"0.60270816",
"0.5990947",
"0.59749573",
"0.5928764",
"0.5898136",
"0.588764",
"0.5835248",
"0.57947266",
"0.5779943",
"0.5769861",
"0.5748892",
"0.574845... | 0.8361254 | 0 |
Test loading a python2generated whoosh index under python3. This test passes only because of the monkeypatching of whoosh.compat.loads with knowhow.util.pickle_loads. | def test_index_load_python2(monkeypatch):
expected = {
"id": ("02a7cefe1189668fa85b56b52ee1e769" "1ee1821913f2031c8117263c07526468"),
"content": "Hello, from Python2",
"tag": ["python2"],
"updated": datetime.datetime(2017, 9, 15, 14, 58, 12, 441405, tzinfo=UTC),
}
import know... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_read_index_swift(self):\n\n indexfile = tempfile.mktemp()\n self.addCleanup(os.unlink, indexfile)\n\n TroveSwiftIndexBuilder(\"short.dat\", out=indexfile)\n\n index = TroveSwiftIndex()\n index.reload(indexfile)\n\n docs = sorted([doc for doc in index.documents])\n... | [
"0.6131236",
"0.6047128",
"0.5761075",
"0.5666576",
"0.55717415",
"0.5535717",
"0.55165625",
"0.54906267",
"0.5470208",
"0.5432962",
"0.5362086",
"0.53338885",
"0.5318798",
"0.5301677",
"0.52784836",
"0.5248858",
"0.5231386",
"0.5221514",
"0.52198315",
"0.5207653",
"0.5195849... | 0.83080643 | 0 |
Takes in array of predicted values and verifies that each prediction has the correct label. If any of the predictions are wrong, the test fails. Returns | def CheckWrong(predicted, correct):
for prediction in predicted:
if prediction != correct:
print("Expected: ", correct," recieved: ", prediction)
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_predictions(model, test_set, val_set):\n \n ## Uses model to predict some amount of images\n predict = model.predict_classes(test_set, batch_size=5, verbose=1)\n \n ## We use the length of these two arrays when we sift through the data to find\n ## the right predictions and wrong predic... | [
"0.6987116",
"0.69262993",
"0.67940277",
"0.6764341",
"0.67562723",
"0.6734727",
"0.67149043",
"0.66110086",
"0.6591573",
"0.65899706",
"0.65859324",
"0.6563824",
"0.65305287",
"0.65157634",
"0.65003157",
"0.64948696",
"0.6471281",
"0.64597934",
"0.64489913",
"0.64332414",
"0... | 0.69688153 | 1 |
Tests the control environment of the system by verifying the execution of the program executes without exceptions | def testControlEnvironment(video1, video2):
try:
control.main(video1, video2, Verbose=True, Testing=True)
return True
except ValueError:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_main_succeeds(app_tester: ApplicationTester) -> None:\n assert app_tester.execute(\"\") == 0",
"def test_script_integrity(capsys):\n script = os.path.abspath(\"examples/scikitlearn-iris/main.py\")\n\n return_code = subprocess.call([\"python\", script, \"0.1\"])\n\n assert return_code != 2, \... | [
"0.6746161",
"0.6714891",
"0.661832",
"0.65914303",
"0.6589559",
"0.6565143",
"0.6559185",
"0.6456731",
"0.64326",
"0.6430399",
"0.6406299",
"0.6397966",
"0.6391126",
"0.6380993",
"0.6365406",
"0.63643396",
"0.6348042",
"0.6301243",
"0.62988365",
"0.6285747",
"0.6282001",
"... | 0.68040043 | 0 |
Function for convertion rainfall depth (in mm) to rainfall intensity (mm/h) | def depth2intensity(depth, interval=300):
return depth * 3600 / interval | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mm_to_inches(rainfall_in_mm):\r\n rainfall_in_inches = rainfall_in_mm * 0.0393701\r\n return rainfall_in_inches",
"def depth_to_ata(depth):\n return (depth / 10.0) + 1.0",
"def intensity2depth(intensity, interval=300):\n return intensity * interval / 3600",
"def _get_depth(self, data): ... | [
"0.65863734",
"0.60612977",
"0.60021347",
"0.5857708",
"0.5759889",
"0.5749766",
"0.552827",
"0.5524878",
"0.5511584",
"0.5501646",
"0.54968464",
"0.5473868",
"0.54733264",
"0.54341406",
"0.5411911",
"0.5402018",
"0.5397092",
"0.53699905",
"0.53681594",
"0.5358648",
"0.535554... | 0.6329385 | 1 |
Function for convertion rainfall intensity (mm/h) to rainfall depth (in mm) | def intensity2depth(intensity, interval=300):
return intensity * interval / 3600 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mm_to_inches(rainfall_in_mm):\r\n rainfall_in_inches = rainfall_in_mm * 0.0393701\r\n return rainfall_in_inches",
"def _get_depth(self, data): \r\n\r\n data = data.astype(np.float32)\r\n\r\n normalized = np.dot(data, [65536.0, 256.0, 1.0]) \r\n normalized /= (256 * 256 * 25... | [
"0.62012035",
"0.62011176",
"0.60868305",
"0.60298705",
"0.5918458",
"0.57394826",
"0.57152945",
"0.56821734",
"0.5576718",
"0.55383277",
"0.5475204",
"0.5465773",
"0.54583997",
"0.5389856",
"0.5378104",
"0.5371326",
"0.5368568",
"0.5361238",
"0.5324265",
"0.53226316",
"0.531... | 0.6237912 | 0 |
Allow a snapshot, a patch, or a list of patches | def _patches(s):
if hasattr(s,'dict'):
pp=s.patches
elif isinstance(s,dispatch._dispatch._patch):
pp=[s]
else:
pp=s
return pp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_patches(\n self, patch_list: List[PatchMetadata], patch_id_digits: int = 4\n ) -> None:\n if not patch_list:\n return\n\n if all(p.present_in_specfile for p in patch_list):\n logger.debug(\n \"All patches are present in the spec file, nothing to ... | [
"0.5694723",
"0.5471057",
"0.546513",
"0.53766376",
"0.5329677",
"0.5255941",
"0.5181168",
"0.51639986",
"0.5138205",
"0.5134213",
"0.5023581",
"0.5022298",
"0.5013435",
"0.5005982",
"0.4865467",
"0.48619777",
"0.48432985",
"0.4824362",
"0.48217645",
"0.4808044",
"0.48046425"... | 0.57809645 | 0 |
Tests all possible keys and returns keys with highest likelihood of bring the encryption key. | def test_possible_keys(ciphertext):
top_keys = []
for num in range(0, 255, 1):
decrypted_str = xor_decrypt(ciphertext, num)
score = count_score(decrypted_str)
if score > 80:
top_keys.append(chr(num))
return top_keys | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keysAll():",
"def get_all_cipher():\n return OpenSSL.cipher_algo.keys()",
"def generate_keys(self):\n self.keys = []\n key = string_to_bit_array(self.passwd)\n key = self.permutation(key, CP_1) # Perform initial permutation on the key\n g, d = split_into_n(key, 28) # Sp... | [
"0.65380496",
"0.6043533",
"0.598087",
"0.5903265",
"0.57908475",
"0.5769569",
"0.5745124",
"0.5694577",
"0.5693339",
"0.5679689",
"0.567391",
"0.5673541",
"0.56516474",
"0.5635523",
"0.56282777",
"0.5624447",
"0.5624447",
"0.5583392",
"0.55720687",
"0.55549103",
"0.5538926",... | 0.68798894 | 0 |
Given a `query_dict`, will attempt to return a xapian.Query | def parse_query(self, query_dict):
if query_dict is None:
return xapian.Query('') # Match everything
elif query_dict == {}:
return xapian.Query() # Match nothing
query_tree = self.build_query_tree(query_dict)
return query_tree.to_query(self.schema, self.databa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _adapt_query(self, translator, query):\n if isinstance(query, dict):\n return self._adapt_dict_query(translator, query)\n else:\n return self._adapt_advancedQuery_query(translator, query)",
"def to_object(cls, query_dict: Dict):\n pass",
"def find_non_default_quer... | [
"0.64505786",
"0.6189991",
"0.60981566",
"0.5994181",
"0.5804566",
"0.5796665",
"0.57583094",
"0.5753702",
"0.5728359",
"0.5705566",
"0.5673714",
"0.56447256",
"0.5644346",
"0.558828",
"0.55776954",
"0.55712634",
"0.5543712",
"0.55340433",
"0.55187654",
"0.550855",
"0.5508064... | 0.798138 | 0 |
A safer version of Xapian.enquire.get_mset Simply wraps the Xapian version and catches any `Xapian.DatabaseModifiedError`, attempting a `database.reopen` as needed. | def _get_enquire_mset(self, database, enquire, start_offset, max_offset):
try:
return enquire.get_mset(start_offset, max_offset)
except xapian.DatabaseModifiedError:
database.reopen()
return enquire.get_mset(start_offset, max_offset) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _memcache_set(*args, **kwargs):\n return ndb.get_context().memcache_set(*args, **kwargs)",
"def testMultiSet3(self):\n data_store.DB.MultiSet(self.test_row,\n {\"aff4:size\": [1],\n \"aff4:stored\": [\"2\"]},\n token=self.toke... | [
"0.4793015",
"0.46737233",
"0.4635927",
"0.46030533",
"0.4529075",
"0.44538745",
"0.44417262",
"0.44326645",
"0.43842188",
"0.4382254",
"0.43772754",
"0.43699858",
"0.43466854",
"0.43008155",
"0.42580876",
"0.42529568",
"0.42522395",
"0.42500696",
"0.42464286",
"0.4227376",
"... | 0.7363788 | 0 |
A safer version of Xapian.document.get_data Simply wraps the Xapian version and catches any `Xapian.DatabaseModifiedError`, attempting a `database.reopen` as needed. | def _get_document_data(self, database, document):
try:
return document.get_data()
except xapian.DatabaseModifiedError:
database.reopen()
return document.get_data() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_document(self, docid):\n try:\n return self.sql_session.query(Document).get(docid)\n except OperationalError:\n raise IOError(\"Sorry, this database is incompatible with the \"\n \"current version of Luminoso. If you want, you can \"\n ... | [
"0.50801295",
"0.4965803",
"0.49481302",
"0.49248785",
"0.48873454",
"0.48322877",
"0.4831373",
"0.4829495",
"0.48187444",
"0.476649",
"0.47422433",
"0.47421846",
"0.47324145",
"0.47252893",
"0.4715714",
"0.4715714",
"0.47152796",
"0.47150412",
"0.46747407",
"0.46602058",
"0.... | 0.74949485 | 0 |
Private method that returns the column value slot in the database for a given field. | def _value_column(self, field):
for field_dict in self.schema['idx_fields']:
if field_dict['field_name'] == field:
return field_dict['column']
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_for_field(self, field):\r\n # iterate in reverse order as columns are registered in order\r\n # of least to most specialised (i.e. Column is registered\r\n # first). This also allows user-registered columns to be\r\n # favoured.\r\n for candidate in reversed(self.colum... | [
"0.73130476",
"0.69992465",
"0.6788504",
"0.6667331",
"0.656862",
"0.6530437",
"0.6353881",
"0.63479865",
"0.6332249",
"0.6313734",
"0.6301725",
"0.62685233",
"0.62561935",
"0.62510896",
"0.62231576",
"0.6219943",
"0.61846817",
"0.6144859",
"0.6125751",
"0.6110693",
"0.610488... | 0.791283 | 0 |
Given a database and enquire instance, returns the estimated number of matches. | def _get_hit_count(self, database, enquire):
return self._get_enquire_mset(
database, enquire, 0, database.get_doccount()
).size() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_matches():\n ALL_FIXED_q = \"all_fixed_queries\" + str(17)\n ALL_FIXED_dbs = \"all_fixed_dbs\" + str(17)\n try:\n with open(\"matches\", \"rb\") as file_h:\n db_length = pickle.load(file_h)\n except:\n print \"reading files..\"\n t = time.time()\n \"\"\... | [
"0.59404796",
"0.56138366",
"0.54407555",
"0.5268415",
"0.526133",
"0.5214657",
"0.51833475",
"0.518211",
"0.5179342",
"0.514233",
"0.51320916",
"0.5122056",
"0.5115935",
"0.51133215",
"0.5101664",
"0.5045524",
"0.50377154",
"0.50153667",
"0.50091594",
"0.50074124",
"0.500450... | 0.60220546 | 0 |
Private utility method that converts Python terms to a string for Xapian terms. | def _marshal_term(term):
if isinstance(term, int):
term = str(term)
return term | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_unicode(terms):\n unicode_terms = []\n for term in terms:\n if (isinstance(term, str)):\n unicode_terms.append(unicode(term, 'utf-8'))\n else:\n unicode_terms.append(term)\n\n return unicode_terms",
"def term_to_tsquery_string(term):\n\n def cleanup(word... | [
"0.6238421",
"0.5838818",
"0.581563",
"0.575069",
"0.575069",
"0.5656662",
"0.56406194",
"0.5446854",
"0.5446854",
"0.5446854",
"0.5446854",
"0.5446854",
"0.5446854",
"0.5446854",
"0.5446854",
"0.5446854",
"0.5298573",
"0.52729565",
"0.5213321",
"0.5181461",
"0.51471734",
"... | 0.5909471 | 1 |
Merges query dicts effectively &ing them together. | def _query_conjunction(self, queries):
query_ops = set()
combined_query = {}
for query in queries:
ops = set(query.keys())
# Make sure that the same operation isn't applied more than once
# to a single field
intersection = ops & query_ops
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_add(*query_params):\n d = {}\n for qp in query_params:\n qp = query_unflatten(qp)\n for name, value in qp.items():\n if name in d:\n d[name].extend(value)\n else:\n d[name] = value\n return d",
"def _merge_by_query(self, obj_dic... | [
"0.674077",
"0.6148979",
"0.61165804",
"0.60930693",
"0.60747015",
"0.6037567",
"0.6035048",
"0.5993466",
"0.59804136",
"0.59125394",
"0.58695716",
"0.58409864",
"0.58023703",
"0.5778066",
"0.5772979",
"0.5770433",
"0.56835896",
"0.56134117",
"0.55566716",
"0.5547177",
"0.554... | 0.6370353 | 1 |
Combine this node with another node into a QCombination object. | def _combine(self, other, operation):
if getattr(other, 'empty'):
return self
if self.empty:
return other
return QCombination(operation, [self, other]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_combination(self, combination):\n return combination",
"def __or__(self, other):\r\n if isinstance(self, Circuit):\r\n if isinstance(other, Circuit):\r\n copy_self = copy(self)\r\n for time_step in other.operations_by_time:\r\n f... | [
"0.5940539",
"0.5787354",
"0.5752724",
"0.57338166",
"0.5704518",
"0.56614375",
"0.56507266",
"0.5551194",
"0.55249304",
"0.5524432",
"0.5481714",
"0.5481714",
"0.5472268",
"0.5448143",
"0.54333144",
"0.5430127",
"0.54202735",
"0.54202735",
"0.5413891",
"0.5394813",
"0.538726... | 0.756413 | 0 |
predicts the popularity of a content from a numpy array of its features returns 'popular' string if output is equal to 1 'unpopular' otherwise | def predict(self,X):
if (int(self.classifier.predict(self.scaler.transform(X)))==-1):
return "popular"
else:
return "unpopular" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postprocess(output):\n text=''\n order = output.argsort()[::-1][:6]\n # print('\\n------- predictions --------')\n for i in range(1):\n # print ('prediction ' + str(i) + ' (probability ' + str(output[order[i]]*100) + '%) is ' + gNetworkCategories[order[i]] + ' label index is: ' + str(order[i]... | [
"0.6040967",
"0.5731728",
"0.57123053",
"0.56998587",
"0.56347734",
"0.5618509",
"0.56034917",
"0.5597564",
"0.5582467",
"0.5563664",
"0.553623",
"0.55235195",
"0.5491753",
"0.5479173",
"0.54705125",
"0.5467261",
"0.5463607",
"0.5447261",
"0.54347146",
"0.5416824",
"0.5407342... | 0.6847979 | 0 |
performs prediction according to self.predict and prints result to standard output | def print_prediction_to_stdout(self,X):
sys.stdout.write(self.predict(X))
sys.stdout.flush() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict():\n import trace\n trace.predict()",
"def run_prediction(self):\r\n self.get_prediction_indices()\r\n self.walk_forward_prediction()",
"def eval(self): \n inputs,enc_input_weights, outputs, dec_input_weights = self.get_batch()\n predicted_ids = self.model.step(self.sess,... | [
"0.76890785",
"0.760489",
"0.73122084",
"0.70064574",
"0.6908278",
"0.69034",
"0.6888294",
"0.68732065",
"0.68638957",
"0.6861249",
"0.6858539",
"0.6853077",
"0.6826687",
"0.68194574",
"0.681267",
"0.6812196",
"0.6808107",
"0.6804206",
"0.6801972",
"0.67959994",
"0.67828244",... | 0.77586794 | 1 |
performs prediction according to self.predict and prints result to standard output | def print_prediction_to_stdout(self,X):
sys.stdout.write(self.predict(X))
sys.stdout.flush() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict():\n import trace\n trace.predict()",
"def run_prediction(self):\r\n self.get_prediction_indices()\r\n self.walk_forward_prediction()",
"def eval(self): \n inputs,enc_input_weights, outputs, dec_input_weights = self.get_batch()\n predicted_ids = self.model.step(self.sess,... | [
"0.76890785",
"0.760489",
"0.73122084",
"0.70064574",
"0.6908278",
"0.69034",
"0.6888294",
"0.68732065",
"0.68638957",
"0.6861249",
"0.6858539",
"0.6853077",
"0.6826687",
"0.68194574",
"0.681267",
"0.6812196",
"0.6808107",
"0.6804206",
"0.6801972",
"0.67959994",
"0.67828244",... | 0.77586794 | 0 |
Preprocess the data further by shuffling inputs and labels randomly | def random_preprocessing(inputs, labels):
indices = range(0, labels.shape[0])
shuffled_indices = tf.random.shuffle(indices)
inputs = tf.gather(inputs, shuffled_indices)
labels = tf.gather(labels, shuffled_indices)
return inputs, labels | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shuffle_train(self):\r\n if self.data_container.task == 'Classify':\r\n id_train_list=[]\r\n for i in self.idx_train_list:\r\n id_train_list.append(self._random_state.choice(i,self.train_parms[0]))\r\n for j in self._random_state.choice(self.unique_value, ... | [
"0.71113944",
"0.70312476",
"0.68610984",
"0.6799098",
"0.67947114",
"0.67875975",
"0.67104065",
"0.669792",
"0.669792",
"0.66785854",
"0.662347",
"0.6609762",
"0.65880877",
"0.6575587",
"0.65448827",
"0.64898324",
"0.6479875",
"0.6458347",
"0.6436497",
"0.63990355",
"0.63954... | 0.7546509 | 0 |
Function to train the inputted model on the provided training states and actions | def train(model, train_states, train_actions, batch_size):
# randomly shuffile input data to increase accuracy
shuffled_states, shuffled_actions = random_preprocessing(train_states, train_actions)
tl = train_states.shape[0] # training inputs length
mod = tl % batch_size # number of batches resul... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_models(self, states, actions, rewards, done):\n # Compute discounted rewards and Advantage (TD. Error)\n discounted_rewards = self.discount(rewards, done, states[-1])\n state_values = self.critic.predict(np.array(states))\n advantages = discounted_rewards - np.reshape(state_va... | [
"0.72539365",
"0.72391033",
"0.7229092",
"0.71589714",
"0.6982884",
"0.6979589",
"0.69229835",
"0.684992",
"0.6848814",
"0.68216443",
"0.6794802",
"0.6790298",
"0.67815095",
"0.6685336",
"0.66696656",
"0.65886027",
"0.6585921",
"0.6581424",
"0.6577335",
"0.6570257",
"0.656492... | 0.77824277 | 0 |
r""" Using parse_frequency_support, determine the mean primary beam size in each observed band | def approximate_primary_beam_sizes(frequency_support_str,
dish_diameter=12 * u.m, first_null=1.220):
freq_ranges = parse_frequency_support(frequency_support_str)
beam_sizes = [(first_null * fr.mean().to(u.m, u.spectral())
/ (dish_diameter)).to(u.arcsec, u.di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DSS28_beamwidth(freq):\n return 0.54/freq",
"def meshsize_avg(self):\n nspans = self.numspans\n support = abs(self.kv[-1] - self.kv[0])\n return support / nspans",
"def get_average(self, s_freq, e_freq):\n s_ind = self.get_bin(s_freq)\n e_ind = self.get_bin(e_freq)\n ... | [
"0.6399699",
"0.6226099",
"0.6138276",
"0.5906671",
"0.5898159",
"0.5684352",
"0.5649585",
"0.5636002",
"0.56263626",
"0.56100583",
"0.55792385",
"0.5576417",
"0.556699",
"0.5537218",
"0.55023855",
"0.5480502",
"0.5477145",
"0.5467537",
"0.54647195",
"0.544937",
"0.5445954",
... | 0.6801699 | 0 |
Gets a color for a node from the color map | def get_color(node, color_map):
if node in color_map:
return color_map[node]
return "black" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_color(self, node: Node) -> str:\n\n idx = hash(node.get_kind_name()) % len(self.colors_)\n return self.colors_[idx]",
"def get_color(key):\n if _with_colors:\n return _color_map.get(key, None)\n return None",
"def which_color(node):\n for i, com in enumerate(communitie... | [
"0.78032285",
"0.73727363",
"0.73418564",
"0.69549704",
"0.68655634",
"0.68655634",
"0.68655634",
"0.68655634",
"0.6771988",
"0.676185",
"0.6759449",
"0.6740052",
"0.66710526",
"0.6658527",
"0.6653712",
"0.66476274",
"0.6644814",
"0.66379815",
"0.6580679",
"0.6572436",
"0.655... | 0.87923455 | 0 |
Obtain a Process Tree representation through GraphViz | def apply(tree, parameters=None):
if parameters is None:
parameters = {}
filename = tempfile.NamedTemporaryFile(suffix='.gv')
viz = Digraph("pt", filename=filename.name, engine='dot', graph_attr={'bgcolor': 'transparent'})
image_format = exec_utils.get_param_value(Parameters.FORMAT, param... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree2gv(tree: TreeNode) -> graphviz.Graph:\n result = graphviz.Graph(\"ni\")\n # result.attr(size='12,0')\n tree2gv_helper(tree, result, \"\")\n return result",
"def tree():\n nobv.visual_tree()",
"def generate_tree(tree, out_file='tree'):\n activities = [\n 'Working at Computer',\... | [
"0.7094322",
"0.6686533",
"0.64426917",
"0.640525",
"0.6387397",
"0.637199",
"0.6317073",
"0.63015395",
"0.62655133",
"0.62164646",
"0.6206735",
"0.6197981",
"0.61905634",
"0.6177722",
"0.6103405",
"0.6046381",
"0.60189193",
"0.59846956",
"0.597069",
"0.5962589",
"0.5962081",... | 0.7527614 | 0 |
Normalize the wieghts of available sentence Data so that they add upto 1 and can be used for processing further. | def normalize(self):
norm_val = self.sum2/self.sum1
self.sum1=0
for sentence in self.data_set:
sentence.weight *= norm_val
self.sum1 += sentence.weight | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(self):\n for key in self.corpus.keys():\n sum_count = 0\n words = []\n counts = []\n for k, v in self.corpus[key].items():\n sum_count += v\n words.append(k)\n counts.append(v)\n prob = [float(c... | [
"0.7035232",
"0.6716962",
"0.6529263",
"0.65186805",
"0.6433806",
"0.63755864",
"0.62821734",
"0.62630904",
"0.6206676",
"0.6193343",
"0.61276984",
"0.6101676",
"0.6050608",
"0.6017587",
"0.601533",
"0.60010767",
"0.5976411",
"0.5958432",
"0.5951639",
"0.59349674",
"0.5925658... | 0.7599852 | 0 |
The function is used to get all tags and tags' num from existing ps log | def getTagsNum(self):
self.gettags() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTags(number=None):",
"def gettotaltags(s,refconvdf): \r\n taglist=[] \r\n for ptag in refconvdf[(refconvdf.convid==s)].tags.values:\r\n if type(ptag)==str or type(ptag)==unicode:\r\n ptag=ptag[1:-1].split(', ') #possible source of error.. added space to cater ... | [
"0.65967417",
"0.63102764",
"0.6142363",
"0.5939912",
"0.5799554",
"0.56801045",
"0.5604655",
"0.560121",
"0.5547236",
"0.55231816",
"0.5501453",
"0.547785",
"0.54671407",
"0.546639",
"0.5457964",
"0.5433481",
"0.54334056",
"0.5421435",
"0.5411407",
"0.54072213",
"0.53912103"... | 0.66558516 | 0 |
Compute an upper bound on monthlength. Even if we haven't identified all the fields needed for checking leapyears yet, we can still prune if value.d is bigger than the month can ever possibly be. | def valid_day_of_month(value):
if value.m == 2:
month_length = 29
if value.y is not None:
if (value.y % 4) != 0:
month_length = 28
elif value.y == 0 and value.C is not None and (value.C % 4) != 0:
month_length = 28
else:
# Odd-numbe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_days(self):\n month_lengths = [31, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29]\n days_years = 365.24 * (self.number // 12)\n days_months = np.sum(month_lengths[:self.number % 12])\n days_frac = days_years + days_months + self.days\n return int(np.ceil(days_frac))",
"def... | [
"0.5886275",
"0.5427668",
"0.5374245",
"0.5331599",
"0.53222615",
"0.53004485",
"0.52571625",
"0.5251135",
"0.5178014",
"0.51442075",
"0.5120376",
"0.51074386",
"0.51074386",
"0.5104363",
"0.5086965",
"0.5083028",
"0.5073267",
"0.50732094",
"0.50614166",
"0.5055513",
"0.50528... | 0.6487694 | 0 |
Are contexts' targets reordered in a consistent way? | def test_context_target_reordering(self):
client = IPythonClient()
orig_targets = client.ids
ctx1 = Context(client, targets=shuffle(orig_targets[:]))
ctx2 = Context(client, targets=shuffle(orig_targets[:]))
self.assertEqual(ctx1.targets, ctx2.targets)
ctx1.close()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exploration_order(targets : [Exp], context : Context, pool : Pool = RUNTIME_POOL):\n\n # current policy (earlier requirements have priority):\n # - visit runtime expressions first\n # - visit low-complexity contexts first\n # - visit small expressions first\n def sort_key(tup):\n e, ct... | [
"0.623471",
"0.5847727",
"0.5639923",
"0.54074484",
"0.5407089",
"0.52525043",
"0.5247879",
"0.52474946",
"0.5243922",
"0.52142984",
"0.50322247",
"0.49951407",
"0.4981515",
"0.49726883",
"0.49717957",
"0.4967289",
"0.49609792",
"0.49517962",
"0.49306974",
"0.49014437",
"0.48... | 0.7536339 | 0 |
Returns True, if both words share a synonym set. | def are_words_synonym(self, word1, word2):
return self.get_intersection((word1, word2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_word_common(self, word):\n if word in self.stopwords:\n return True\n if re.match(r'[a-zA-Z]+[a-zA-Z]$', word):\n word = self.lemmatizer.lemmatize(word, pos='n')\n synset = wn.synsets(word)\n if len(synset) > 0:\n return True\n ... | [
"0.6931332",
"0.67537117",
"0.6713939",
"0.64805406",
"0.6460012",
"0.64492655",
"0.63962036",
"0.63711363",
"0.6323809",
"0.6230787",
"0.62301844",
"0.61946565",
"0.606518",
"0.6061799",
"0.6016105",
"0.6014903",
"0.60109985",
"0.60029316",
"0.5962531",
"0.5943674",
"0.59267... | 0.8643581 | 0 |
Find the best matching word in the candidate sentence. These words can occure in a window of a few index left and right, but any offset will come with a penalty. | def get_word_score_in_window(self, gold, candidate, use_synonyms, index):
best_score = 0
for offset in range(self.pen.word_window_left * -1, self.pen.word_window_right + 1):
new_index = index + offset
# iterate over the window
if new_index >= 0 and new_index < len(gol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_best_fit(self, puzzle):\n\n word = puzzle['answer']\n\n # if first word\n print(len(self.filled_pos))\n if len(self.filled_pos) == 0:\n x = random.randint(0,4)\n y = random.randint(0,4)\n print(\"first_word: {} x:{} y:{}\".format(word, x, y))\n... | [
"0.6923842",
"0.669848",
"0.6694236",
"0.6632936",
"0.6539453",
"0.6518705",
"0.6500288",
"0.64969873",
"0.64787245",
"0.64690685",
"0.638015",
"0.6367746",
"0.6333405",
"0.63233733",
"0.63188654",
"0.63039714",
"0.6299287",
"0.624796",
"0.6207178",
"0.62019473",
"0.61890596"... | 0.69598657 | 0 |
Returns the score of two frame elements by comparing the text and weighting it depending on a name match. | def get_frame_element_score(self, fe1, fe2):
name_match = fe1['name'] == fe2['name']
score = self.get_text_score(fe1['spans'][0]['text'], fe2['spans'][0]['text'])
if not name_match:
score *= self.pen.factor_name_mismatch
return score | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wordSimilarityRatio(sent_1,sent_2):",
"def judge(name):\n score = 0\n for scoreID, scorer, weight in weights:\n subscore = scorer(name)\n score += subscore * weight\n name.scores[scoreID] = subscore\n name.score = score\n return score",
"def match_score(seq1, seq2):\n\n ... | [
"0.6383207",
"0.629914",
"0.6173675",
"0.6157977",
"0.61087143",
"0.6092695",
"0.6014092",
"0.593099",
"0.5915258",
"0.59143925",
"0.5904347",
"0.589253",
"0.5890898",
"0.5858196",
"0.5838747",
"0.58362615",
"0.58156574",
"0.57967263",
"0.5784012",
"0.5770046",
"0.5751338",
... | 0.78827935 | 0 |
Calculate the score for the whole sentence by comparing all frames within them. This will go on recursivly to the frame elements and to the words themselves. | def get_sentence_score(self, gold_sentence, candidate_sentence):
# Collect all frames
gold_frames = gold_sentence['frames']
candidate_frames = candidate_sentence['frames']
# Check first in the actual order
score = 0
length = min(len(gold_frames), len(candidate_frames))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyze(self, text):\n\n score = 0.0;\n\n words = text.split(' ')\n # match each word in either the positives or negatives list adding or subtracting 1 from the score if present\n for word in words:\n for w in self.positives:\n if w == word.lower():\n ... | [
"0.6548635",
"0.63201207",
"0.6306467",
"0.6282123",
"0.6157068",
"0.61255497",
"0.61066025",
"0.6098733",
"0.603776",
"0.60062015",
"0.6001164",
"0.599811",
"0.59679884",
"0.59551257",
"0.5931475",
"0.58964103",
"0.5882361",
"0.58487177",
"0.58317465",
"0.582618",
"0.5774652... | 0.6558668 | 0 |
Testing pack, unpacking and the Frame class. | def testFramepack1(self):
# Check bad frame generation:
frame = stomper.Frame()
def bad():
frame.cmd = 'SOME UNNOWN CMD'
self.assertRaises(stomper.FrameError, bad)
# Generate a MESSAGE frame:
frame = stomper.Frame()
frame.cmd = 'MESSAGE'
fra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testFramepack2(self):\n # Check bad frame generation:\n frame = stomper.Frame()\n frame.cmd = 'DISCONNECT'\n result = frame.pack()\n correct = 'DISCONNECT\\n\\n\\x00\\n'\n self.assertEqual(result, correct)",
"def testFrameUnpack2(self):\n msg = \"\"\"MESSAGE\n... | [
"0.6719955",
"0.6473041",
"0.63044375",
"0.6166511",
"0.57701236",
"0.57502604",
"0.56620747",
"0.55210936",
"0.55098057",
"0.54613936",
"0.54554623",
"0.54554623",
"0.54369926",
"0.5431739",
"0.5402827",
"0.53195024",
"0.5303696",
"0.5282925",
"0.5262848",
"0.5235965",
"0.52... | 0.7690478 | 0 |
Testing pack, unpacking and the Frame class. | def testFramepack2(self):
# Check bad frame generation:
frame = stomper.Frame()
frame.cmd = 'DISCONNECT'
result = frame.pack()
correct = 'DISCONNECT\n\n\x00\n'
self.assertEqual(result, correct) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testFramepack1(self):\n # Check bad frame generation:\n frame = stomper.Frame()\n\n def bad():\n frame.cmd = 'SOME UNNOWN CMD'\n\n self.assertRaises(stomper.FrameError, bad)\n\n # Generate a MESSAGE frame:\n frame = stomper.Frame()\n frame.cmd = 'MESS... | [
"0.769042",
"0.64738643",
"0.6304517",
"0.6169357",
"0.5768204",
"0.57520175",
"0.5662974",
"0.55218434",
"0.55126536",
"0.546263",
"0.5456736",
"0.5456736",
"0.543818",
"0.54336375",
"0.5404497",
"0.5320587",
"0.5302061",
"0.52817917",
"0.5264384",
"0.5235212",
"0.52228606",... | 0.6720689 | 1 |
Testing unpack frame function against MESSAGE | def testFrameUnpack2(self):
msg = """MESSAGE
destination:/queue/a
message-id: card_data
hello queue a"""
result = stomper.unpack_frame(msg)
self.assertEqual(result['cmd'], 'MESSAGE')
self.assertEqual(result['headers']['destination'], '/queue/a')
self.assertEqual(result['header... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testFramepack1(self):\n # Check bad frame generation:\n frame = stomper.Frame()\n\n def bad():\n frame.cmd = 'SOME UNNOWN CMD'\n\n self.assertRaises(stomper.FrameError, bad)\n\n # Generate a MESSAGE frame:\n frame = stomper.Frame()\n frame.cmd = 'MESS... | [
"0.6846625",
"0.67204636",
"0.6646124",
"0.6544158",
"0.6350713",
"0.6292274",
"0.6244153",
"0.62392515",
"0.61773825",
"0.61642474",
"0.6163974",
"0.60963815",
"0.60218555",
"0.5993113",
"0.5992668",
"0.59667337",
"0.59657395",
"0.5963074",
"0.5938992",
"0.59179807",
"0.5871... | 0.7443139 | 0 |
Testing unpack frame function against CONNECTED | def testFrameUnpack3(self):
msg = """CONNECTED
session:ID:snorky.local-49191-1185461799654-3:18
"""
result = stomper.unpack_frame(msg)
self.assertEqual(result['cmd'], 'CONNECTED')
self.assertEqual(result['headers']['session'], 'ID:snorky.local-49191-1185461799654-3:18')
self.ass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testFramepack2(self):\n # Check bad frame generation:\n frame = stomper.Frame()\n frame.cmd = 'DISCONNECT'\n result = frame.pack()\n correct = 'DISCONNECT\\n\\n\\x00\\n'\n self.assertEqual(result, correct)",
"def testFrameUnpack2(self):\n msg = \"\"\"MESSAGE\n... | [
"0.6529449",
"0.62154406",
"0.5931618",
"0.5910129",
"0.5869515",
"0.56991196",
"0.5643126",
"0.5555427",
"0.5497953",
"0.5459658",
"0.5446381",
"0.5324627",
"0.5304809",
"0.52132446",
"0.5212872",
"0.52032244",
"0.5189915",
"0.5188491",
"0.51803774",
"0.5159421",
"0.51445866... | 0.68718064 | 0 |
Returns a diff for field if it's changed and None otherwise. | def get_field_diff(self, field_name):
return self.diff.get(field_name, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_updated_field(self):\n return None",
"def _field_was_changed(self):\n field_map = self._field_map\n for field in field_map.itervalues():\n if field.was_changed():\n return True\n return False",
"def getFieldValue (self, fieldname):\n return s... | [
"0.6489824",
"0.60495067",
"0.5896543",
"0.5798435",
"0.57247734",
"0.5697826",
"0.5696986",
"0.56731516",
"0.55192393",
"0.55002016",
"0.5471943",
"0.547045",
"0.54299885",
"0.535557",
"0.52621925",
"0.52565867",
"0.52482855",
"0.5244059",
"0.52217674",
"0.5214849",
"0.52049... | 0.7749743 | 1 |
Check if default_backend() suport cipher and mode combination | def test_compatibility(cipher, mode):
chiper_obj = cipher_params(cipher, os.urandom(length_by_cipher[cipher]))[0] #need to be object, not interface, to validate_for_algorithm work
if chiper_obj.name == "ChaCha20":
return True
mode_object = None
if mode == 'CBC':
mode_object = modes.CBC... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_encryption_mode():\r\n\r\n msg = 'Do you want to encrypt ({0}) or decrypt ({1})? '.format(\r\n cipher_functions.ENCRYPT, cipher_functions.DECRYPT)\r\n mode = input(msg)\r\n while not (mode == cipher_functions.ENCRYPT or\r\n mode == cipher_functions.DECRYPT):\r\n pri... | [
"0.6207802",
"0.60368025",
"0.5887069",
"0.5850579",
"0.5812958",
"0.5783021",
"0.57796377",
"0.5690944",
"0.5689572",
"0.56412655",
"0.55962986",
"0.5582347",
"0.5557559",
"0.55446714",
"0.55280775",
"0.5516546",
"0.54812735",
"0.54729825",
"0.5470359",
"0.54567057",
"0.5441... | 0.672798 | 0 |
clip(arr,thresh=3.5) Simple sigmaclipping algorithm. Returns avg,std of clipped array. | def clip(arr,thresh=3.5):
a = numpy.array(arr)
avg,std = a.mean(),a.std()
while 1:
avg,std,size = a.mean(),a.std(),a.size
a = a[abs(a-avg)<thresh*std]
if size==a.size:
break
return avg,std | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip(arr,thresh=3.5):\n\ta = arr.copy()\n\n\tavg,std = a.mean(),a.std()\n\twhile 1:\n\t\tsize = a.size\n\t\ta = a[abs(a-avg)<thresh*std]\n\t\tavg,std = a.mean(),a.std()\n\t\tif size==a.size:\n\t\t\tbreak\n\treturn avg,std",
"def sigma_clip(arr,sigma=3):\n\n cliparr = range(len(arr)) # initialize\n arr... | [
"0.88836473",
"0.74306214",
"0.70505095",
"0.70455706",
"0.6405306",
"0.63617873",
"0.63274765",
"0.63037956",
"0.628521",
"0.6187328",
"0.6141885",
"0.6097245",
"0.6067281",
"0.6067228",
"0.60558444",
"0.6035898",
"0.60233146",
"0.600569",
"0.59593225",
"0.5902682",
"0.58220... | 0.8775539 | 1 |
check_star(peaks,data) Determines whether or not a slit looks like it is a starbox. This is done by simply checking the 3pixels bordering each peak and ensuring that none are less than half of the peak (ie that the FWHM>7 pixels). Returns True if more than half of the peaks look like boxes, otherwise returns False. | def check_star(peaks,data):
star = 0
for i in peaks:
max = data[i]
if i<3 or i+4>data.size:
continue
mean = data[i-3:i+4].mean()
if (max-mean)<0.1*max:
star += 1
if star*2>peaks.size:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def measure_stars(data, mod, hmin=5, fmin=1E3, pmax=7E4,\n qmax=.5, cmin=-1., cmax=.1, ncpu=None, focus_only=False):\n\n # Get filtered images to get peak measurements\n filt_image, max_4sum = _filter_images(data, hmin)\n # Find source candidates\n xs, ys = _find_sources(data, filt_ima... | [
"0.58288115",
"0.5654559",
"0.561577",
"0.559006",
"0.5559171",
"0.5494257",
"0.5473655",
"0.5460491",
"0.54178053",
"0.5310197",
"0.52972597",
"0.5219187",
"0.5214601",
"0.5144117",
"0.5144112",
"0.5132752",
"0.5132509",
"0.50744927",
"0.5068108",
"0.505384",
"0.50513923",
... | 0.83904934 | 0 |
findlines(z) Quickly find the peaks of arclines. Returns a list containing the peak locations. | def findlines(z,bgsub=True,SATURATED=57000.):
z = z.copy()
s = z.copy()
""" First identify peaks. """
max = ndimage.maximum_filter(z,9)
p = scipy.where((max==z)&(z<SATURATED)&(max>0))[0]
s = z[p]
""" Reject low peaks. """
bg = ndimage.percentile_filter(s,10,21)
peaks = scipy.where(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_lines(name, num):\n fn = '%s/disp/%s.1d.fits' % (name, num)\n hdulist = pyfits.open(fn)\n data = hdulist[0].data\n header = hdulist[0].header\n locations = []\n for line in LINES:\n line_loc = get_wavelength_location(header, line)\n locations.append(find_line_peak(data, lin... | [
"0.61656934",
"0.60634553",
"0.574901",
"0.5706759",
"0.5654833",
"0.5622347",
"0.5612087",
"0.5597109",
"0.55510885",
"0.55373585",
"0.5508165",
"0.5473418",
"0.5457143",
"0.54282737",
"0.5375191",
"0.53597057",
"0.53382623",
"0.53099495",
"0.52996916",
"0.5296617",
"0.52950... | 0.70562565 | 0 |
id_slits(arc,find_stars=True) Determine the top/bottom of each slit in the 2d ycorrected arc image. If find_stars is True, returns slit,starbox, otherwise returns slit. | def id_slits(arc,find_stars=True,chilimit=2.5,SATURATED=57000.,useLines=True):
arc = arc.copy()
""" Attempt to avoid saturated lines """
w = arc.shape[1]
tmp = arc.copy()
tmp[tmp>SATURATED] = 0.
tmpSorted = scipy.sort(tmp,axis=1)
flux = tmpSorted[:,w*0.97:w*0.98].mean(axis=1)
minflux = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id_slits(flat_data,findstars=True):\n\n\ty_axis = flat_data.shape[0]\n\n\tdata = flat_data.mean(axis=1)\n\td = data.copy()\n\n\t\"\"\"\n\tThe slits tend to be demarcated by when the sorted data begins to\n\t grow at an accelerating rate; the first derivative tends to be an\n\t acceptable proxy, though. The e... | [
"0.65125364",
"0.5271238",
"0.5177924",
"0.5146718",
"0.5063657",
"0.49875027",
"0.49333033",
"0.47619992",
"0.47554895",
"0.47422874",
"0.4738101",
"0.47289777",
"0.46929607",
"0.4634357",
"0.46069604",
"0.45719075",
"0.45473403",
"0.453219",
"0.45096353",
"0.45056877",
"0.4... | 0.77866113 | 0 |
Recursively merge new into base. | def merge_dict(base, new, extend=True):
if isinstance(new, dict):
for key, value in new.items():
if key not in base:
base[key] = value
elif extend and isinstance(value, dict):
base[key] = merge_dict(
base=base.get(key, {}), new=val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(self):\n collapsable = self.findSameSubtrees()\n\n dummy = GraphiusNode(-1, None)\n for i, node in self.nodes.items():\n dummy.addNeighbor(node)\n\n # Perform the merge\n self.mergeHelper(dummy, collapsable)\n\n # Regenerate trees\n newNodes = s... | [
"0.6242751",
"0.61828357",
"0.59670585",
"0.59168214",
"0.5873907",
"0.57541686",
"0.57490855",
"0.5668129",
"0.56648463",
"0.5660273",
"0.5635293",
"0.5633576",
"0.56290585",
"0.560243",
"0.558158",
"0.55591655",
"0.5555937",
"0.55533767",
"0.5547018",
"0.549763",
"0.5479188... | 0.6269359 | 0 |
Return the SHA256 sum of a given object. The object used for generating a SHA256 must be JSON compatible. | def object_sha256(obj):
return hashlib.sha256(json.dumps(obj).encode()).hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash(obj):\n \n import hashlib\n import pickle\n \n sha = hashlib.sha256()\n sha.update(pickle.dumps(obj))\n \n return sha.hexdigest()",
"def SHA256(self) -> _n_0_t_3[_n_0_t_9]:",
"def checksum(item):\n return hashlib.sha256(obj_to_str(item).encode('utf-8')).hexdigest()",
"def ... | [
"0.7034035",
"0.6582454",
"0.6568041",
"0.65337396",
"0.65337396",
"0.6494412",
"0.6442198",
"0.63768536",
"0.62840503",
"0.6225997",
"0.62037086",
"0.6184975",
"0.61726046",
"0.6153254",
"0.613591",
"0.613288",
"0.6131862",
"0.612951",
"0.6064961",
"0.60636646",
"0.6060272",... | 0.80336756 | 0 |
Return the SHA1 sum of a given object. The object used for generating a SHA1 must be JSON compatible. | def object_sha1(obj):
return hashlib.sha1(json.dumps(obj).encode()).hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sha1_hash_json(self, value):\n hash = hashlib.new(\"sha1\")\n binary_value = value.encode(\"ascii\")\n hash.update(binary_value)\n sha1_res = hash.hexdigest()\n return sha1_res",
"def sha1(data):\n\n d = rpki.POW.Digest(rpki.POW.SHA1_DIGEST)\n d.update(data)\n ret... | [
"0.72167873",
"0.66763383",
"0.66553843",
"0.655533",
"0.6483608",
"0.6467267",
"0.6432472",
"0.6383441",
"0.62883264",
"0.628797",
"0.62626314",
"0.6250575",
"0.62494814",
"0.61954755",
"0.6177797",
"0.6159965",
"0.6142139",
"0.6118138",
"0.611029",
"0.5966402",
"0.59195644"... | 0.8017245 | 0 |
Constructor. iReader is the IndexReader object on which the search should be performed | def __init__(self, iReader):
self.ireader = iReader
self.num_of_doc = iReader.getNumberOfDocuments() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, iReader):\n self.__index_reader = iReader",
"def __init__ (self, input) :\r\n ReaderA.__init__(self) # call parent\r\n # print '************************* input = ', input, type(input)\r\n self.buffer_ = input # this is any thing that can be indexed\r\n self... | [
"0.8396916",
"0.650846",
"0.6117651",
"0.610951",
"0.5918099",
"0.58073515",
"0.57342076",
"0.57264924",
"0.5707911",
"0.56755626",
"0.56056577",
"0.56042516",
"0.5564753",
"0.5564753",
"0.55574864",
"0.55394095",
"0.54976076",
"0.54976076",
"0.5472114",
"0.54673475",
"0.5451... | 0.71863604 | 1 |
Sets the nucleus_security_id of this MdHistoryRequestCO. | def nucleus_security_id(self, nucleus_security_id):
self._nucleus_security_id = nucleus_security_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def security_user_id(self, security_user_id):\n\n self._security_user_id = security_user_id",
"def security_user_id(self, security_user_id):\n\n self._security_user_id = security_user_id",
"def security_identities(self, security_identities):\n\n self._security_identities = security_identit... | [
"0.6567464",
"0.6567464",
"0.52219766",
"0.51711905",
"0.5101832",
"0.5018672",
"0.5015538",
"0.4997469",
"0.49538937",
"0.49538937",
"0.4811074",
"0.4785215",
"0.4778403",
"0.4775735",
"0.47065136",
"0.47065136",
"0.46921664",
"0.46891037",
"0.46483314",
"0.45931828",
"0.458... | 0.7827064 | 0 |
Perform experiment on bivariate dataset generated from 3 Gaussians. | def perform_bivariate_3_gaussians_exp(N, pp, mu_1, mu_2, mu_3,
sigma_1, sigma_2, sigma_3,
truncation_bounds, censoring_bounds,
max_iteration=50, seed=100):
# Fix the random state
random.seed(seed)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gauss3(x,a1,c1,w1,a2,c2,w2,a3,c3,w3):\n return gaussian(x,a1,c1,w1)+gaussian(x,a2,c2,w2)+gaussian(x,a3,c3,w3)",
"def make_synthetic_experiment(sample_data, model, make_gibbs_fn, explicit_ub=None):\n rng_key = random.PRNGKey(0)\n\n # Sampling parameters\n n_values = [100, 1000, 10000]\n\n # DPM... | [
"0.58995914",
"0.5848525",
"0.5785762",
"0.56935716",
"0.5683083",
"0.5672991",
"0.5658776",
"0.5653742",
"0.5651552",
"0.5644565",
"0.5640411",
"0.5552061",
"0.54944736",
"0.5456843",
"0.54314345",
"0.5376272",
"0.5372925",
"0.536842",
"0.5357922",
"0.53472793",
"0.5326309",... | 0.6641757 | 0 |
Gets the horizontal and vertical fairlead force in a 2D plane along the straightline line. Must ensure update_states() is called before accessing this function. The function will not solve the forces for a new vessel position if it updated. , otherwise the fairlead forces are not updated with the new | def get_fairlead_force_2d(self, index):
H_ref = c_double(-999.9)
V_ref = c_double(-999.9)
Map.lib.map_get_fairlead_force_2d( pointer(H_ref), pointer(V_ref),self.f_type_d, index, self.status, pointer(self.ierr))
return H_ref.value, V_ref.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_forces(self):\n # get new coeffs\n self._get_coeffs()\n\n # instead of writing many time\n awa = self.awa / 180.0 * np.pi\n\n # lift and drag\n self.lift = 0.5 * self.rho * self.aws ** 2 * self.area * self.cl\n self.drag = 0.5 * self.rho * self.aws ** 2... | [
"0.59395546",
"0.5330673",
"0.5312082",
"0.5219329",
"0.5200467",
"0.5179556",
"0.51686174",
"0.51159114",
"0.51100034",
"0.5095978",
"0.503672",
"0.50160944",
"0.5001314",
"0.49821773",
"0.4980897",
"0.4960312",
"0.49429363",
"0.49155977",
"0.490984",
"0.48997304",
"0.487468... | 0.5961753 | 0 |
Gets the horizontal and vertical fairlead force in a 3D frame along relative referene global axis. Must ensure update_states() is called before accessing this function. The function will not solve the forces for a new vessel position if it updated. , otherwise the fairlead forces are not updated with the new | def get_fairlead_force_3d(self, index):
fx = c_double(-999.9)
fy = c_double(-999.9)
fz = c_double(-999.9)
Map.lib.map_get_fairlead_force_3d( pointer(fx), pointer(fy), pointer(fz), self.f_type_d, index, self.status, pointer(self.ierr))
return fx.value, fy.value, fz.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_force(self):\n # @todo: Probably need to check the state of the landing gear for this (e.g. are they on the track?).\n # Note: you can get the state of the landing gear by going through self.sim \n return 0.0",
"def _compute_forces(self):\n # get new coeffs\n self._get_... | [
"0.6209693",
"0.61231375",
"0.60808545",
"0.5834242",
"0.5751801",
"0.5747734",
"0.5688679",
"0.5622616",
"0.55450886",
"0.55335766",
"0.55251175",
"0.54527116",
"0.5413672",
"0.54064393",
"0.5396999",
"0.5393756",
"0.53756493",
"0.5375087",
"0.53007513",
"0.5273948",
"0.5251... | 0.62398463 | 0 |
US02 Birth should occur before the marriage of an individual | def birthBeforeMarriage(individual):
birthDate = individual.get_birth_data()[0]
marriageDates = gedcom_parser.get_marriages(individual)
if marriageDates and birthDate:
earliestMarriageDate = (min(convertGedcomDate(
date[0]) for date in marriageDates))
birthDate = convertGedcomDa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def marriageBeforeDeath(individual):\n deathDate = individual.get_death_data()[0]\n marriageDates = gedcom_parser.get_marriages(individual)\n\n if marriageDates and deathDate:\n latestMarriageDate = (max(convertGedcomDate(\n date[0]) for date in marriageDates))\n deathDate = conve... | [
"0.7354835",
"0.69403464",
"0.6383716",
"0.606869",
"0.5849964",
"0.5793744",
"0.57224643",
"0.5720761",
"0.57011163",
"0.569727",
"0.56274605",
"0.5543742",
"0.55336505",
"0.545788",
"0.54456013",
"0.5355954",
"0.53553337",
"0.5348341",
"0.5312725",
"0.5301524",
"0.5298418",... | 0.8175209 | 0 |
US03 Birth should occur before death death of an individual | def birthBeforeDeath(individual):
birthdate = individual.get_birth_data()[0]
deathdate = individual.get_death_data()[0]
if birthdate and deathdate:
birthdate = convertGedcomDate(birthdate)
deathdate = convertGedcomDate(deathdate)
if deathdate < birthdate:
print(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_story_3(self):\n for person in self.individuals.values():\n if person.birthday != 'NA' and person.death != 'NA':\n if person.birthday > person.death:\n print(f'US03 - {person.name} birthday after death date on line {person._birthday_line}')",
"def marr... | [
"0.73368835",
"0.7128599",
"0.7022836",
"0.6697646",
"0.658086",
"0.64116395",
"0.6272369",
"0.615616",
"0.6134359",
"0.6054821",
"0.60294044",
"0.5999488",
"0.59691304",
"0.5946575",
"0.5878821",
"0.5743965",
"0.5718721",
"0.5715728",
"0.56893015",
"0.56744665",
"0.5630451",... | 0.7989253 | 0 |
US01 Dates (birth, marriage, divorce, death) should not be after the current date | def datesBeforeCurrentDate(individual):
birthdate = individual.get_birth_data()[0]
deathdate = individual.get_death_data()[0]
marriageDates = gedcom_parser.get_marriages(individual)
fams = gedcom_parser.get_families(individual)
childElements = [(fam.get_child_elements()) for fam in fams]
divor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_birth_date(self):\n\n sent_date = self.cleaned_data['birth_date']\n current_date = localtime(now()).date()\n\n if (sent_date - current_date) > datetime.timedelta(seconds=1):\n raise ValidationError(INVALID_BIRTH_DATE_VALUE)\n else:\n return sent_date",
... | [
"0.6859254",
"0.6827661",
"0.67296493",
"0.6612987",
"0.65961987",
"0.6590323",
"0.65531206",
"0.6381926",
"0.6303823",
"0.626078",
"0.6253482",
"0.62472546",
"0.6229059",
"0.6218926",
"0.62039614",
"0.6194757",
"0.6192037",
"0.6190664",
"0.61717904",
"0.61649835",
"0.6157977... | 0.6945236 | 0 |
US05 Marriage should occur before death of either spouse | def marriageBeforeDeath(individual):
deathDate = individual.get_death_data()[0]
marriageDates = gedcom_parser.get_marriages(individual)
if marriageDates and deathDate:
latestMarriageDate = (max(convertGedcomDate(
date[0]) for date in marriageDates))
deathDate = convertGedcomDate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def birthBeforeMarriage(individual):\n birthDate = individual.get_birth_data()[0]\n marriageDates = gedcom_parser.get_marriages(individual)\n\n if marriageDates and birthDate:\n earliestMarriageDate = (min(convertGedcomDate(\n date[0]) for date in marriageDates))\n birthDate = con... | [
"0.6608855",
"0.6395794",
"0.62768626",
"0.6059355",
"0.5927261",
"0.59164596",
"0.5904102",
"0.5811521",
"0.5769977",
"0.57258",
"0.5644478",
"0.5615973",
"0.5540922",
"0.55232954",
"0.5492104",
"0.5450482",
"0.543772",
"0.5406157",
"0.53945804",
"0.53908473",
"0.53890926",
... | 0.74599016 | 0 |
US11 Marriage should not occur during marriage to another spouse | def noBigamy(individual):
families = gedcom_parser.get_families(individual)
marriageDateRanges = []
for family in families:
marriageDate = None
divorceDate = None
for element in family.get_child_elements():
if element.get_tag() == "MARR":
marriageDate =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def marriageBeforeDeath(individual):\n deathDate = individual.get_death_data()[0]\n marriageDates = gedcom_parser.get_marriages(individual)\n\n if marriageDates and deathDate:\n latestMarriageDate = (max(convertGedcomDate(\n date[0]) for date in marriageDates))\n deathDate = conve... | [
"0.61908466",
"0.5837422",
"0.57115346",
"0.57115346",
"0.5583499",
"0.551999",
"0.5438785",
"0.52849215",
"0.52452075",
"0.5241142",
"0.5138036",
"0.5130192",
"0.5087213",
"0.50658804",
"0.50608194",
"0.50542825",
"0.5035876",
"0.50106514",
"0.49922475",
"0.49858934",
"0.496... | 0.61542344 | 1 |
US14 No more than five siblings should be born at the same time | def multipleBirths(family):
children = gedcom_parser.get_family_members(family, 'FAMILY_MEMBERS_TYPE_CHILDREN')
birthdays = []
for child in children:
birthdays.append(convertGedcomDate(child.get_birth_data()[0]))
if len(birthdays) < 5:
return True
else:
birthdayCounts = dic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_story_13(self):\n for family in self.families.values():\n if family.children != 'NA':\n bday_dict = dict() # { iid1: bday1, iid2: bday1, iid3: bday2 }\n for child in family.children:\n bday_dict[child] = self.individuals[child].birthday\n ... | [
"0.6394935",
"0.589646",
"0.58748806",
"0.57955617",
"0.5716806",
"0.56660855",
"0.55908614",
"0.54490757",
"0.53771",
"0.5303966",
"0.5289085",
"0.52771676",
"0.5269098",
"0.5228261",
"0.52020466",
"0.5188563",
"0.5182026",
"0.51784223",
"0.5177228",
"0.5161102",
"0.51388174... | 0.66829455 | 0 |
US53 Return True if the given individual has any of the individual errors listed in this file | def listErrors(individual): #TODO: add other errors implemented elsewhere
results = [birthBeforeMarriage(individual), birthBeforeDeath(individual), marriageBeforeDeath(individual),
datesBeforeCurrentDate(individual), noBigamy(individual)]
results = [x for x in results if x is not None]
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_errors( self ) :\n for e in self._errlist :\n if e.svr in (starobj.Error.CRIT, starobj.Error.ERR) :\n return True\n return False",
"def checkForErrors(file_to_check, elm_html_dir, protein):\n\n have_error = False\n found_summary_line = False\n tidy_file = ... | [
"0.70126104",
"0.6666234",
"0.6639376",
"0.6567932",
"0.6328549",
"0.6295345",
"0.61865944",
"0.61504483",
"0.61230916",
"0.6091424",
"0.60665655",
"0.6066381",
"0.606468",
"0.5951048",
"0.5904429",
"0.59001625",
"0.5894452",
"0.58898234",
"0.58656865",
"0.5850387",
"0.582022... | 0.67767346 | 1 |
Delete characters from (upperRow, upperCol) up to (lowerRow, lowerCol) using the current selection mode. | def doDelete(self, upperRow, upperCol, lowerRow, lowerCol):
if app.config.strict_debug:
assert isinstance(upperRow, int)
assert isinstance(upperCol, int)
assert isinstance(lowerRow, int)
assert isinstance(lowerCol, int)
assert upperRow <= lowerRow
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doDeleteSelection(self):\n upperRow, upperCol, lowerRow, lowerCol = self.startAndEnd()\n self.doDelete(upperRow, upperCol, lowerRow, lowerCol)",
"def handle_backspace(self, peer, row, col):\n\n # If the peer has selected text, delete that\n \n if peer.hasSelection():\n ... | [
"0.6620042",
"0.57208854",
"0.5691439",
"0.55859524",
"0.55157864",
"0.5507719",
"0.5377565",
"0.5346679",
"0.53402644",
"0.532339",
"0.5315138",
"0.53036845",
"0.5277891",
"0.5264728",
"0.51874375",
"0.5165313",
"0.5142384",
"0.5119983",
"0.510315",
"0.5101102",
"0.5100013",... | 0.7226521 | 0 |
Get the marker and pen pair as the earlier of the two then the later of the two. The result accounts for the current selection mode. | def startAndEnd(self):
upperRow = 0
upperCol = 0
lowerRow = 0
lowerCol = 0
if self.selectionMode == kSelectionNone:
upperRow = self.penRow
upperCol = self.penCol
lowerRow = self.penRow
lowerCol = self.penCol
elif self.select... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extendSelection(self):\n if self.selectionMode == kSelectionNone:\n return (0, 0, -self.markerRow, -self.markerCol, 0)\n elif self.selectionMode == kSelectionAll:\n lowerRow = self.parser.rowCount() - 1\n lowerCol = self.parser.rowWidth(-1)\n return (lo... | [
"0.6011843",
"0.5677164",
"0.5634399",
"0.54283017",
"0.5415784",
"0.5395966",
"0.5371319",
"0.53632814",
"0.52929765",
"0.5262781",
"0.5216849",
"0.52008176",
"0.5173189",
"0.510564",
"0.50992477",
"0.50596124",
"0.50539047",
"0.50408655",
"0.50330716",
"0.502399",
"0.498852... | 0.5908329 | 1 |
Create a new instance of the consumer class, passing in the AMQP URL used to connect to RabbitMQ. | def __init__(self, amqp_url, *handlers):
self._consumer_tags = []
RabbitMQ.__init__(self, amqp_url)
# save our handlers for ruture use
self._handlers = {}
for handle in handlers:
for k, v in handle.handlers().items():
self._handlers[k] = v | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, amqp_url):\n self._connection = None\n self._channel = None\n self._url = amqp_url",
"def __init__(self, bot_id, exchange, callback_func, rabbit_user, rabbit_pw, rabbit_host,\n rabbit_port, consumer_id = 0, internal_error_queue = None, statsd = None):\n\n ... | [
"0.7262911",
"0.69813114",
"0.6856555",
"0.6677581",
"0.6617419",
"0.6605369",
"0.6598709",
"0.6594421",
"0.6551421",
"0.6519944",
"0.64506525",
"0.6445172",
"0.6418586",
"0.6371481",
"0.63316727",
"0.6271886",
"0.6116819",
"0.610504",
"0.60880953",
"0.6048735",
"0.6037678",
... | 0.7203772 | 1 |
This method is used to pass encoded body to a handler and return it's value. Errors are handled and returned via "error" field. | def _wrap_handler(self, handler, body):
try:
decoded_body = json.loads(body)
result = yield handler(decoded_body)
return result
except Exception as e:
return {"error": str(e)} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_body_encoded(self):\r\n return self.encode(self.get_body())",
"def exec_handler(self, body = None):\n h = self.MyTestHandler()\n h.request = Request.blank('/test_rpc/')\n h.response = Response()\n h.request.body = body\n h.post()\n return (h.response._Resp... | [
"0.6089419",
"0.5972001",
"0.5903383",
"0.58262664",
"0.5725833",
"0.56453234",
"0.55684733",
"0.5544198",
"0.54686564",
"0.5420627",
"0.53850895",
"0.5339725",
"0.5323851",
"0.5286423",
"0.52700764",
"0.5258086",
"0.52574533",
"0.5253574",
"0.5234289",
"0.5206247",
"0.519793... | 0.7676827 | 0 |
Get duty score of each category. We don't calculate each post score, we think what a man like can be described on category level. | def get_duty_cate_score(chosen_duty_list: list) -> pmag.MagicDict:
res = pmag.MagicDict()
for w, cate in chosen_duty_list:
freq = MODEL[cate]['duty'][w]['freq']
prob = MODEL[cate]['duty'][w]['prob']
score = prob # freq * prob / DUTY_NF[cate]
if cate in res:
res[cate]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_category_scores(category: Category):\r\n solutions = Solution.objects.filter(challenge__category=category).select_related(\"user\").select_related(\"challenge\")\r\n d = dict()\r\n\r\n for sol in solutions:\r\n d[sol.user] = d.get(sol.user, 0) + sol.get_score()\r\n \r\n return d",
"... | [
"0.613709",
"0.58618087",
"0.5727891",
"0.56878406",
"0.56152403",
"0.56031907",
"0.5602886",
"0.5589381",
"0.55766207",
"0.5559616",
"0.55558634",
"0.551678",
"0.5496905",
"0.5457578",
"0.5345839",
"0.5217769",
"0.5215651",
"0.5173264",
"0.5075885",
"0.50440013",
"0.5034618"... | 0.66597116 | 0 |
Get require score of each post under all categories. | def get_require_post_score(chosen_require_list: list) -> pmag.MagicDict:
res = pmag.MagicDict()
for w, cate in chosen_require_list:
posts = MODEL[cate]['posts']
for post in [*posts]:
if w in posts[post]['require']:
freq = posts[post]['require'][w]['freq']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_category_scores(category: Category):\r\n solutions = Solution.objects.filter(challenge__category=category).select_related(\"user\").select_related(\"challenge\")\r\n d = dict()\r\n\r\n for sol in solutions:\r\n d[sol.user] = d.get(sol.user, 0) + sol.get_score()\r\n \r\n return d",
"... | [
"0.61079204",
"0.5922314",
"0.58088666",
"0.5803367",
"0.57733124",
"0.56357044",
"0.55619234",
"0.5498224",
"0.54960984",
"0.5487963",
"0.5476413",
"0.5473844",
"0.54599303",
"0.5441705",
"0.54069304",
"0.5355828",
"0.53226984",
"0.53197926",
"0.5309574",
"0.5264326",
"0.524... | 0.66950214 | 0 |
Another method to get demand score for each post. It is the same as `get_demand_post_score` | def get_demand_post_score_from_require_res(
require_post_score: dict) -> pmag.MagicDict:
res = pmag.MagicDict()
for cate, posts in require_post_score.items():
for post, _ in posts.items():
demand = MODEL[cate]['posts'][post]['demand']
score = ((demand['continuous_freq'] +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_demand_post_score(chosen_require_list: list) -> pmag.MagicDict:\n res = pmag.MagicDict()\n for w, cate in chosen_require_list:\n posts = MODEL[cate]['posts']\n for post in [*posts]:\n if w in posts[post]['require']:\n demand = posts[post]['demand']\n ... | [
"0.71937186",
"0.62748903",
"0.5551882",
"0.5537667",
"0.55115795",
"0.54713887",
"0.5433023",
"0.53453386",
"0.53175926",
"0.53070366",
"0.5296628",
"0.5283368",
"0.5276864",
"0.5266636",
"0.5229753",
"0.52116245",
"0.5197169",
"0.5197169",
"0.5197169",
"0.5185938",
"0.51754... | 0.72410864 | 0 |
Returns true if num1 and num2 are within a sliver of a floating point m gives the multplier on the floating point precision >>> np.exp(np.log(.1)) == .1 False >>> approx(np.exp(np.log(.1)), .1) True | def approx(num1, num2, m=4, precision=None):
if precision:
return abs(num1-num2) <= 10**precision
else:
return abs(num1-num2) <= m * np.spacing(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isGE(self, a : float, b : float) -> bool:\n return (a >= b - self.tol * max(abs(a), abs(b), 1.0)) #and (a >= b - 0.1)",
"def approx_eq(a, b):\n return abs(a-b) < approx_eq.eps",
"def fp_eq(x: float, y: float) -> bool:\n return fabs(x-y) < 10**-12",
"def feq(x, y, precision=0.0000005):\n x... | [
"0.6546254",
"0.63741624",
"0.628203",
"0.61943084",
"0.6191803",
"0.6149317",
"0.60316664",
"0.60307664",
"0.5971287",
"0.59679186",
"0.5940457",
"0.59363294",
"0.5883913",
"0.5864648",
"0.58641005",
"0.58613974",
"0.5849694",
"0.5804423",
"0.5786198",
"0.57757586",
"0.57513... | 0.7322738 | 0 |
Returns true if every element of l1 and l2 are approximately equivalent >>> l1 = [.1, .2, .3] >>> l2 = [np.exp(np.log(l)) for l in l1] >>> all_approx(l1, l2) True >>> l1[0]==l2[0] False >>> l2 = l2+[.4] >>> all_approx(l1, l2) False >>> all_approx(l2, l1) False >>> l1 = l1+[.4] >>> all_approx(l1, l2) True | def all_approx(l1, l2, m=4):
same = (len(l1) == len(l2))
i = 0
while same and i < len(l1):
same = approx(l1[i], l2[i], m)
i += 1
return same | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_equal_approx(x, y, epsilon=1e-6):\r\n # Check absolute precision.\r\n if -epsilon <= x - y <= epsilon:\r\n return True\r\n\r\n # Is x or y too close to zero?\r\n if -epsilon <= x <= epsilon or -epsilon <= y <= epsilon:\r\n return False\r\n\r\n # Check relative precision.\r\n ... | [
"0.63644165",
"0.6298559",
"0.6149365",
"0.60207367",
"0.6004111",
"0.5972103",
"0.5880449",
"0.5873127",
"0.5866577",
"0.5848705",
"0.58028466",
"0.5766068",
"0.5696672",
"0.5637069",
"0.5629465",
"0.56260514",
"0.56233066",
"0.5610046",
"0.5607236",
"0.5603783",
"0.5598328"... | 0.79060626 | 0 |
Returns the index of the bin that feature belongs in. bin_bounds contains the upper bound on each bin's value, sorted. | def get_bin_index(signal, bins):
# could do this binary search-like at least
index = 0
for v in bin_bounds:
if signal > v:
return index
index += 1
return index - 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bin_index(self, xnorm):\n return _bin_index(xnorm, self.nbins, self.padding)",
"def getBinIndex(self, x):\n\t\tb = -1\n\t\tif x == self._max_val: # final bin is [low, high], where others are [low,high)\n\t\t\tb = len(self._bins)-1\n\t\telse:\n\t\t\tb = math.floor((x-self._min_val)/self._bin_width)\n\t... | [
"0.70552397",
"0.70514095",
"0.700788",
"0.6601049",
"0.6601049",
"0.658574",
"0.64486784",
"0.6374188",
"0.6364163",
"0.63276494",
"0.61857146",
"0.6172362",
"0.615024",
"0.6147497",
"0.61349773",
"0.60643",
"0.5958335",
"0.5958335",
"0.5933699",
"0.59336483",
"0.5922114",
... | 0.7421128 | 0 |
Find the index of the most significant change bit, the bit that will change when t is incremented >>> mscb(0) 0 >>> mscb(1) 1 >>> mscb(7) 3 >>> mscb(8) 0 | def mscb(t):
return int(np.log2(t ^ (t + 1))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_of_least_significant_zero_bit(self, value):\n\n index = 1\n while (value & 1) != 0:\n value >>= 1\n index += 1\n return index",
"def _get_bit(byte, ii):\n return (byte >> (7 - ii)) & 1",
"def get_bit_position(x, k):\n\n return x & (1 << k)",
"def get... | [
"0.631035",
"0.59553164",
"0.5750957",
"0.57216984",
"0.5569518",
"0.5563024",
"0.5544709",
"0.5520244",
"0.55109185",
"0.55054873",
"0.55012137",
"0.5486113",
"0.5483539",
"0.54807216",
"0.54805136",
"0.5454347",
"0.54524463",
"0.54152685",
"0.5410381",
"0.540032",
"0.538250... | 0.73426956 | 0 |
Return the index of the largest value, randomly breaking ties. >>> argmax([0, 1]) 1 >>> argmax([1, 0]) 0 >>> a = argmax([0, 1, 1]) >>> a in (1, 2) True | def argmax(values):
values = np.array(values)
mx = np.max(values)
val = np.where(values==mx)[0]
return np.random.choice(val) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_argmax(x: np.ndarray) -> int:\n indices = all_argmax(x)\n return np.random.choice(indices)",
"def __argmax(l: list, key):\n max = float('-inf')\n max_i = -1\n for i in range(len(l)):\n if key(l[i]) > max:\n max = key(l[i])\n max_i = i\n return max_i",
"... | [
"0.7526515",
"0.7374521",
"0.73375267",
"0.7292933",
"0.7292933",
"0.7292933",
"0.7266164",
"0.7108389",
"0.7082183",
"0.69236606",
"0.6903086",
"0.67438745",
"0.66566026",
"0.6644861",
"0.66012126",
"0.65932435",
"0.64963543",
"0.64745444",
"0.6468216",
"0.6466282",
"0.64662... | 0.77623355 | 0 |
Calculate the numerator such that at t=0, a/(decay+t)=alpha | def calc_alpha_init(alpha, decay):
if not decay or decay <= 0:
return alpha
else:
return float(alpha * decay) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_decay(x0, alpha, T, t):\n if t <= T:\n return x0 - (1 - alpha) * x0 * t / T\n else:\n return alpha * x0",
"def alpha0(self, t):\n return (self.alpha_0 * pow((self.Light(t) / self.I0), self.p));",
"def get_rate(self, t):\n return self.l_0 + \\\n self.alpha * s... | [
"0.69432795",
"0.6660636",
"0.6574897",
"0.63983226",
"0.6329011",
"0.62791234",
"0.6273906",
"0.6231108",
"0.6197118",
"0.61908907",
"0.6139079",
"0.6103482",
"0.60895485",
"0.6089476",
"0.6075572",
"0.6073953",
"0.6066894",
"0.6041462",
"0.6040465",
"0.6033664",
"0.59855026... | 0.6787552 | 1 |
Take a vector a values and a integer window size Return the vector of values that are the mean over n steps. Note that (right now at least) the returned vector will be n1 elements smaller. >>> running_mean([1, 2, 2, 4, 1, 1], 2) array([ 1.5, 2. , 3. , 2.5, 1. ]) >>> running_mean([1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2], 4)... | def running_mean(data, n):
return np.convolve(data, np.ones((n, ))/n)[(n-1):-(n-1)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running_mean(x, N):\n return np.convolve(x, np.ones((N,))/N, mode='valid')",
"def running_mean(x, N):\n cumsum = np.cumsum(np.insert(x, 0, 0)) \n return (cumsum[N:] - cumsum[:-N]) / float(N)",
"def running_mean(x, N):\n cumsum = np.cumsum(np.insert(x, 0, 0))\n return (cumsum[N:] - cu... | [
"0.7720666",
"0.7643432",
"0.7536631",
"0.7211045",
"0.7008733",
"0.6889429",
"0.6789585",
"0.67637384",
"0.67565584",
"0.67500424",
"0.6691265",
"0.66497403",
"0.66207325",
"0.6608271",
"0.6591761",
"0.6547892",
"0.6546986",
"0.6544084",
"0.65184224",
"0.6493564",
"0.6491099... | 0.7728464 | 0 |
Converts a list of items into a string with special characters removed Underscores are left >>> join_items(['a','b','c']) 'abc' >>> join_items(['a[0]','a[1]']) 'a0a1' >>> join_items(['true_value',8]) 'true_value8' >>> join_items(['true_values',.1,.2]) 'true_values0.10.2' >>> join_items(['elbow_joint','wrist_joint','sho... | def join_items(values, sort=False):
if isinstance(values, str):
return clean_string(values)
try:
val = []
for v in values:
val.append(clean_string(v))
if sort:
val.sort()
return "-".join(val)
except TypeError:
return str(values) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_list(items: Iterable[str]) -> str:\n\n return ITEM_SEPARATOR.join(items)",
"def list_join(the_list):\n return ' '.join(the_list)",
"def implode(delim, items):\n return delim.join(items)",
"def space_join(*items):\n valid_items = []\n for item in items:\n if item is None:\n ... | [
"0.7977471",
"0.693271",
"0.669698",
"0.66417265",
"0.6443994",
"0.6382685",
"0.6340171",
"0.63081473",
"0.6274466",
"0.61351764",
"0.60828316",
"0.6071877",
"0.5988854",
"0.5981916",
"0.5970071",
"0.59247893",
"0.58747697",
"0.580866",
"0.5806932",
"0.5757411",
"0.569503",
... | 0.70138764 | 1 |
Splits a string of separated items into its component parts. >>> split_items('true_values0.10.2') ['true_values', 0.1, 0.2] >>> split_items('abc') ['a', 'b', 'c'] >>> split_items('true_value8') ['true_value', 8] >>> split_items('elbow_jointshoulder_jointwrist_joint') ['elbow_joint', 'shoulder_joint', 'wrist_joint'] >>>... | def split_items(item_string):
parts = item_string.split('-')
items = []
# now clean up the types
for v in parts:
if v.isnumeric():
items.append(int(v))
elif v == 'None':
items.append(None)
else:
try:
items.append(float(v))
except:
items.append(v)
return items | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def splitItems(items):\n if isinstance(items, str):\n usable = items.split()\n else:\n usable = items\n\n numItems = len(usable)\n\n vals = [usable[ii] for ii in range(0, numItems, 2)]\n uncs = [usable[ii] for ii in range(1, numItems, 2)]\n\n return vals, uncs",
"def split(items):... | [
"0.6730633",
"0.6239765",
"0.59711105",
"0.5655868",
"0.5633598",
"0.5582001",
"0.55317825",
"0.5411825",
"0.54079276",
"0.5397846",
"0.5320743",
"0.52738994",
"0.5258152",
"0.5238759",
"0.5187398",
"0.5168217",
"0.5111953",
"0.50975215",
"0.50514513",
"0.5047044",
"0.5041988... | 0.71201855 | 0 |
Looks for files in the given directory that have filenames that match required_features (using feature1_feature2.txt naming convention) If no files exist, return the standard filename Otherwise return the file that includes all the required features with the fewest extra features | def get_best_file_match(required_features, base_dir):
best_match = join_items(remove_modifiers(required_features), sort=True)
required = set(split_items(best_match))
best_match = best_match+".txt"
fe = file_exists(os.path.join(base_dir, best_match), check_zip=True)
if fe:
return os.path.split(fe)[1]
options =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_best_features(year, features, sex, age, heavy):\r\n print 'find_best_features(year=%d,features=%s,sex=%s,age=%s,heavy=%s)' % (year, features, sex,\r\n age, heavy)\r\n X, y, keys = getXy_by_features(year, features, sex, age)\r\n title = 'features=%s,sex=%s,age=%s,year=%d' % (features,sex,ag... | [
"0.5663445",
"0.55437386",
"0.54259026",
"0.5389287",
"0.5342964",
"0.5334897",
"0.5313537",
"0.53124535",
"0.5311146",
"0.5280167",
"0.5265178",
"0.52467936",
"0.52369076",
"0.52361584",
"0.5224449",
"0.522216",
"0.5216392",
"0.52127874",
"0.5179615",
"0.5176138",
"0.5149295... | 0.8017204 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.