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 |
|---|---|---|---|---|---|---|
Test that players who return malformed data give the correction Exception | def test_malformed_player(self):
board = Board()
player1 = MalformedDataPlayer()
player_guard1 = PlayerGuard(player1, timeout=3)
p1id = uuid.uuid4()
player_guard1.set_id(uuid.uuid4())
self.assertRaises(PlayerMalformedData, player_guard1.place_worker, board)
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_match(self):\n log.info('===== START TEST BAD MATCH =====')\n\n # Telemetered\n file_path = os.path.join(RESOURCE_PATH, '11129553_SNA_SNA.txt')\n\n stream_handle = open(file_path, MODE_ASCII_READ)\n\n self.create_parser(stream_handle)\n\n particles = self.pars... | [
"0.6991385",
"0.68578684",
"0.68342507",
"0.66050863",
"0.64829636",
"0.6460214",
"0.6405003",
"0.63200325",
"0.6276188",
"0.6250518",
"0.62475544",
"0.6240708",
"0.6203122",
"0.6147875",
"0.6140294",
"0.6134805",
"0.6119987",
"0.6116309",
"0.6114093",
"0.6097102",
"0.6086972... | 0.7278242 | 0 |
Set the master brightness for the LEDs 0.0 1.0 | def set_master_brightness(self, bright):
if bright > 1.0 or bright < 0.0:
raise ValueError('Brightness must be between 0.0 and 1.0')
self.master_brightness = bright | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_brightness(self, value):\n self.parent.backlight.set_brightness(value)",
"def setBrightness(self, brightness):\n self._logger.debug(\"setBrightness\")",
"def turn_on(self, **kwargs):\n brightness_pct = 100\n if kwargs.get(ATTR_BRIGHTNESS):\n brightness_pct = \\\n ... | [
"0.7249358",
"0.7019495",
"0.6937318",
"0.69261116",
"0.69078296",
"0.684333",
"0.68396944",
"0.6810661",
"0.674868",
"0.67474365",
"0.6722217",
"0.6716365",
"0.67112005",
"0.67012703",
"0.6689771",
"0.667891",
"0.6651563",
"0.6624309",
"0.66210926",
"0.6606793",
"0.6565971",... | 0.78568107 | 0 |
Handles the response from the Spot API. | async def handle_response(self, response: list) -> None:
event: pycot.Event = spotcot.spot_to_cot(response)
if event:
await self._put_event_queue(event)
else:
self._logger.debug("Empty CoT Event for response='%s'", response) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _get_spot_feed(self):\n self._logger.debug(\"Polling Spot API\")\n async with aiohttp.ClientSession() as session:\n response = await session.request(\n method=\"GET\",\n url=self.spot_url,\n params=self.params\n )\n ... | [
"0.63797146",
"0.6222165",
"0.6110388",
"0.6050964",
"0.60438",
"0.60314375",
"0.60314375",
"0.59888417",
"0.59888417",
"0.593117",
"0.5927854",
"0.5902705",
"0.58658016",
"0.58658016",
"0.5813812",
"0.57932097",
"0.5771459",
"0.57557327",
"0.57383317",
"0.572283",
"0.5722300... | 0.65560997 | 0 |
Gets Spot Feed from API. | async def _get_spot_feed(self):
self._logger.debug("Polling Spot API")
async with aiohttp.ClientSession() as session:
response = await session.request(
method="GET",
url=self.spot_url,
params=self.params
)
json_resp = aw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_spot_datafeed_subscription(self):\r\n return self.get_object('DescribeSpotDatafeedSubscription',\r\n None, SpotDatafeedSubscription, verb='POST')",
"def get_feed(request):\n try:\n feed = Feed.objects.get(slug=request.slug)\n details = FeedDetail.obje... | [
"0.62063956",
"0.60406125",
"0.59925675",
"0.5945758",
"0.5931701",
"0.59195614",
"0.5916346",
"0.58610404",
"0.5788365",
"0.5750007",
"0.5743978",
"0.5704419",
"0.5669291",
"0.5666391",
"0.5607322",
"0.557266",
"0.556664",
"0.5564438",
"0.5537319",
"0.5529781",
"0.55205816",... | 0.842844 | 0 |
Moves every bullet and checks collision with enemy | def move_bullets(self, vel, enemies):
self.cooldown(SCREEN)
for bullet in self.bullets:
bullet.move(vel)
if bullet.off_screen(HEIGHT):
self.bullets.remove(bullet)
else:
for enemy in enemies:
if bullet.bullet_collisio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def e_collisions(rect, enemy_list):\r\n for enemy in enemy_list:\r\n if rect.colliderect(enemy[1]) and rect.bottom - 4 < enemy[1].top:\r\n dropped_objects.append([[enemy[1].x, enemy[1].y], heart_img, [0, 0], 45])\r\n enemy_list.remove(enemy)",
"def check_collide_enemy(self):\n ... | [
"0.68499255",
"0.6699276",
"0.6641216",
"0.6632509",
"0.6631075",
"0.6597619",
"0.6576827",
"0.6536081",
"0.65184474",
"0.6454792",
"0.644817",
"0.64457405",
"0.6440626",
"0.6424823",
"0.6412154",
"0.6411753",
"0.6411751",
"0.6408061",
"0.63944864",
"0.6362468",
"0.63506466",... | 0.74962366 | 0 |
Draw player (via super), health bar and bullets that are being shot | def draw(self, window):
super().draw(window)
self.health_bar(window)
for bullet in self.bullets:
bullet.draw(window) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_hud(self):\r\n self.health.draw(self.screen)\r\n self.ammo.draw(self.screen)\r\n self.shield.draw(self.screen)\r\n if self.stats.stage in self.ai_settings.boss_stages:\r\n self.boss_health.draw(self.screen)",
"def _draw(self, screen):\n screen.blit(self.img,... | [
"0.7053339",
"0.7002526",
"0.68953305",
"0.68867",
"0.68360496",
"0.68192565",
"0.68192565",
"0.68100774",
"0.676655",
"0.6763228",
"0.6653929",
"0.6637864",
"0.6623462",
"0.6611356",
"0.6601027",
"0.6574257",
"0.6571267",
"0.65628046",
"0.65411323",
"0.6528637",
"0.6518458",... | 0.7219749 | 0 |
Creates a green and red bar that shows HP under the player | def health_bar(self, window):
pygame.draw.rect(window, (255, 0, 0), (self.x, self.y + self.character_img.get_height() + 10, self.character_img.get_width(), 10))
pygame.draw.rect(window, (0, 255, 0), (self.x, self.y + self.character_img.get_height() + 10, self.character_img.get_width() * (self.health / s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def displayhealthbar(point, HP, big):\n x1 = point[0] - 20*big\n y1 = point[1] - 40*(0.4*big)\n width1 = 10*big*4\n height1 = 30*(0.4*big)\n x2 = point[0] - 20 * big + 4\n y2 = point[1] - 40*(0.4*big) + 4\n width2 = HP * ((10*big*4)-8)\n height2 = 30*(0.4*big)-8\n pygame.draw.rect(win, (... | [
"0.7648837",
"0.7250589",
"0.7049357",
"0.70292926",
"0.6597066",
"0.6574285",
"0.6352186",
"0.6349596",
"0.63452655",
"0.6339884",
"0.63143975",
"0.63016737",
"0.6260875",
"0.6102113",
"0.60938644",
"0.6024261",
"0.601972",
"0.6005384",
"0.59939563",
"0.5979737",
"0.59796715... | 0.7341477 | 1 |
Makes special fire follow the player and draws it on screen | def specialfire_draw(self, window):
self.specialfire_x = self.x + 10
window.blit(self.specialfire_image, (self.specialfire_x, self.specialfire_y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def follow(self):\n\t\tpos = pygame.mouse.get_pos()\n\t\tself.x = pos[0]\n\t\tself.y = pos[1]\n\t\tself.draw()",
"def update_firing(self):\n if (self.fire_idx < len(self.firepoints) and\n self.moving_object.is_at_location(self.firepoints[self.fire_idx])):\n self.fire_at_player()\n ... | [
"0.68945765",
"0.66299134",
"0.66153365",
"0.65888524",
"0.64281243",
"0.6343826",
"0.6340996",
"0.63317066",
"0.6311632",
"0.6309747",
"0.6264146",
"0.62635946",
"0.62573063",
"0.6240162",
"0.62354577",
"0.62217736",
"0.619818",
"0.61923707",
"0.61849177",
"0.6119801",
"0.61... | 0.7281868 | 0 |
Return if a collision between special fire and enemy has happened | def specialfire_collision(self, enemy):
offset_x = enemy.x - self.specialfire_x
offset_y = enemy.y - self.specialfire_y
return self.specialfire_mask.overlap(enemy.mask, (offset_x, offset_y)) != None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collision_check(self):\n return True",
"def test_collisions(self):\n if self.fortress_exists:\n if self.smallhex.collide(self.ship):\n self.gameevents.add(\"collide\", \"small_hex\", \"ship\")\n else:\n self.smallhex.small_hex_flag = False\n ... | [
"0.69510776",
"0.68120366",
"0.6768066",
"0.67449725",
"0.6712405",
"0.6712184",
"0.66976637",
"0.66771513",
"0.66725105",
"0.66551834",
"0.66497964",
"0.6597181",
"0.6577718",
"0.6565197",
"0.6543388",
"0.6530928",
"0.6521814",
"0.6508505",
"0.65020263",
"0.64865917",
"0.647... | 0.8086208 | 0 |
opens the Nodegraph with dockable configuration settings | def open(self):
super(Nodzgraph, self).open(dockable=self.configuration.maya.docked,
area=self.configuration.maya.dock_area,
allowedArea=self.configuration.maya.allowed_dock_areas,
floating=self.configura... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def os_open_graph( self, ):\r\n pass",
"def Open(self,platform_id,default_filename,node_config_filename):\n \n self._platform_id = platform_id\n \n log.debug(\"%r: Open: %s %s\", self._platform_id, default_filename,node_config_filename)\n\n \n \n try:\n default_conf... | [
"0.5930127",
"0.56766725",
"0.5650456",
"0.5621875",
"0.5567428",
"0.5503504",
"0.53853106",
"0.53249294",
"0.5300992",
"0.5279987",
"0.5279987",
"0.52589256",
"0.5227214",
"0.5227214",
"0.5211773",
"0.52026206",
"0.5191812",
"0.51693016",
"0.51345825",
"0.5111162",
"0.509576... | 0.7166937 | 0 |
appends available node types in categories | def append_available_node_categories(self):
available_node_types = self.graph.creation_field.available_items
for types in self.configuration.maya.available_node_categories:
node_types = pmc.listNodeTypes(types)
for node_type in node_types:
if not node_type in avai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_icecat_categories(self, data):\n TreeNode = Pool().get('product.tree_node')\n ProductNodeRelationship = Pool().get(\n 'product.product-product.tree_node'\n )\n\n new_node = TreeNode._get_or_create_icecat_if_not_exists(\n int(data.Product.Category.get('ID')... | [
"0.6340051",
"0.6259589",
"0.5829217",
"0.57792366",
"0.577862",
"0.5708915",
"0.5657999",
"0.56548184",
"0.56378573",
"0.563205",
"0.56264526",
"0.5606866",
"0.5589305",
"0.55826277",
"0.5576237",
"0.55682135",
"0.5540958",
"0.54904276",
"0.5480753",
"0.5448623",
"0.54415137... | 0.7785675 | 0 |
This function receives a 'POST' request method from a client and get it's data | def recieve_information_from_client():
client_data = request.forms.get('json')
client_data_dict = json.loads(client_data)
return client_data_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_data():\n if request.method in ('POST', \"PUT\"):\n return request.get_json(force=True)\n else:\n return request.values",
"def do_POST(self):\r\n self.do_GET()",
"def post(self):",
"def get(self):\n self.post()",
"def http_method_post():\n return 'POST'",
... | [
"0.68918556",
"0.6549099",
"0.64753604",
"0.6453649",
"0.6367501",
"0.6312047",
"0.6308891",
"0.6282414",
"0.6258612",
"0.625582",
"0.625582",
"0.625582",
"0.62416863",
"0.62103575",
"0.6206144",
"0.62047666",
"0.61790305",
"0.61790305",
"0.6147297",
"0.6133374",
"0.6086245",... | 0.7036646 | 0 |
This function finds a file in the 'root' folder with the corresponding name, and reads its content depending on it's type. | def read_file(root, file_name, file_type='t'):
page_dir = handle_path(main_directory + '/' + root + '/' + file_name)
try:
# if type != 'b' and type != 't':
# raise
with open(page_dir, 'r' + file_type) as page_reader:
return str(page_reader.read())
except Fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_contents(base_dir, filename):\n full_path = os.path.join(base_dir, filename)\n if not is_subdir(full_path, base_dir):\n # don't allow breaking away from base_dir\n return None\n\n if os.path.exists(full_path):\n with open(full_path, 'r') as f:\n data = f.read()\n ... | [
"0.631054",
"0.57341194",
"0.5712488",
"0.56762844",
"0.5649599",
"0.5611031",
"0.560397",
"0.55907774",
"0.5530049",
"0.54937893",
"0.54597014",
"0.54306775",
"0.53494537",
"0.5348524",
"0.5308854",
"0.5306033",
"0.53031945",
"0.5277389",
"0.5277245",
"0.525333",
"0.5230534"... | 0.72442055 | 0 |
This function checks if a worker with this id exists in the database. if it doesn't exists, it will send an "Unauthorized" status error, it it does exists, it will return data it has about the worker. The worker will always send its id as the first argument to every route. | def identify(sus_id):
worker_data = Db.find_worker(sus_id)
if worker_data is None:
raise_http_error("Unauthorized")
return worker_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_worker_exists(self, worker_id: str) -> None:\n with self.table_access_condition:\n conn = self._get_connection()\n c = conn.cursor()\n c.execute(\n \"\"\"\n INSERT OR IGNORE INTO workers(\n worker_id,\n ... | [
"0.7034007",
"0.64257145",
"0.625562",
"0.5748211",
"0.5537325",
"0.54742503",
"0.54625136",
"0.5406041",
"0.5383044",
"0.52799463",
"0.52116334",
"0.516417",
"0.5152756",
"0.5078088",
"0.5074629",
"0.5043621",
"0.5029751",
"0.50295347",
"0.5024617",
"0.5019254",
"0.49602935"... | 0.6812386 | 1 |
This function packages data to a Json file to send to the client. | def package_data(data_dict):
return json.dumps(data_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_data_file(self):\n with open(self.files['data'], 'w') as outfile:\n outfile.write(self.to_json())\n outfile.close()",
"def send_data(self, data):\n\n with open(self.file, 'a') as f:\n json.dump(data, f, ensure_ascii=False)\n f.write(\"\\n\")",
... | [
"0.7113503",
"0.7082935",
"0.7065153",
"0.7065153",
"0.7009987",
"0.6877191",
"0.6873971",
"0.68389356",
"0.68354946",
"0.6822422",
"0.67832226",
"0.6778062",
"0.6762506",
"0.6753518",
"0.6740403",
"0.6710166",
"0.6710166",
"0.6705621",
"0.6686311",
"0.66776437",
"0.6677309",... | 0.72229487 | 0 |
This function calculates results for the main server to display on the "task_stats" page. | def get_stats():
stats = {
"progress_precent": 100.0*finished_work_units_amount/work_units_amount,
"results": None if work_status == Db.WorkStatusNames.finished_work.value else Db.collect_results(),
#If it's already finished, then all the results were already sent to the main server.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_statistics(self):",
"def compute_metrics(self, results: list) -> dict:",
"async def get_stats():\n ret = {}\n counter = 0\n counter_error = 0\n counter_completed = 0\n list_duration = list()\n for j in mngr.transcode_requests:\n counter = counter + 1\n task = mngr.tr... | [
"0.66616094",
"0.66459996",
"0.66455036",
"0.657525",
"0.6532148",
"0.64150786",
"0.64120436",
"0.6405113",
"0.63895184",
"0.6386479",
"0.6366236",
"0.6344558",
"0.6327372",
"0.6292202",
"0.62303954",
"0.62280965",
"0.6181305",
"0.61685735",
"0.6156411",
"0.61389965",
"0.6132... | 0.7031592 | 0 |
Define SPARQL query to get a list of ICOS stations If %args is empty, all stations are returned. If %args = 4, we expect a bounding box, [lat1, lat2, lon1, lon2] If %args is >0 and != 4, we revert to return all stations | def icos_stations(*args):
if len(args) != 4:
filterstr = " "
else:
filterstr = """
filter(
?lat >= %s && ?lat <= %s &&
?lon >= %s && ?lon <= %s).""" % (args)
query = """
PREFIX cpst: <http://meta.icos-cp.eu/ontologies/stationentry/>
SEL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update():\n\n # ensure parameters are present\n if not request.args.get(\"sw\"):\n raise RuntimeError(\"missing sw\")\n if not request.args.get(\"ne\"):\n raise RuntimeError(\"missing ne\")\n\n # ensure parameters are in lat,lng format\n if not re.search(\"^-?\\d+(?:\\.\\d+)?,-?\\d... | [
"0.544252",
"0.53771496",
"0.5369455",
"0.53283054",
"0.52022785",
"0.519962",
"0.51935756",
"0.51053905",
"0.5101553",
"0.5085653",
"0.5081488",
"0.5076143",
"0.5073174",
"0.50592345",
"0.5038836",
"0.5012204",
"0.5011193",
"0.50050443",
"0.49936566",
"0.49666077",
"0.492495... | 0.82864314 | 0 |
Make sure that all arguments are less than or equal to 2 31 1. This limitation is introduced because databases stores INT in 4 bytes. If the validation fails for some argument, exception.Invalid is raised with appropriate information. | def _validate_db_int(**kwargs):
max_int = (2 ** 31) - 1
for param_key, param_value in kwargs.items():
if param_value and param_value > max_int:
msg = _("'%(param)s' value out of range, "
"must not exceed %(max)d.") % {"param": param_key,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_command_line_input(args):\n valid = False\n if 0 < len(args) <= 4:\n valid = True\n for arg in args:\n if int(arg) > 4:\n valid = False\n break\n else:\n pass\n if vali... | [
"0.70180744",
"0.6883685",
"0.6882932",
"0.67813575",
"0.6772028",
"0.6761713",
"0.6599308",
"0.6594583",
"0.6570281",
"0.6490215",
"0.6483124",
"0.6472988",
"0.64683133",
"0.64530694",
"0.6439429",
"0.64013773",
"0.63773197",
"0.63634753",
"0.63212645",
"0.63140357",
"0.6289... | 0.6979969 | 1 |
Unset global configuration variables for database. | def clear_db_env():
global _FACADE
_FACADE = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_pgsql_conf(self):\n self.kv.unset(\"pgsql_host\")\n self.kv.unset(\"pgsql_port\")\n self.kv.unset(\"pgsql_db\")\n self.kv.unset(\"pgsql_user\")\n self.kv.unset(\"pgsql_pass\")\n self.kv.flush()",
"def pytest_unconfigure(config):\n db = Graph(DEFAULT_DB)\n ... | [
"0.71788144",
"0.6686507",
"0.65984255",
"0.6457119",
"0.6341494",
"0.6341172",
"0.63168097",
"0.63068455",
"0.626762",
"0.6251894",
"0.62448454",
"0.61375123",
"0.6102033",
"0.6055475",
"0.60545254",
"0.60465336",
"0.60399556",
"0.60362554",
"0.6023218",
"0.60050696",
"0.600... | 0.69616604 | 1 |
Create an subject from the values dictionary. | def subject_create(context, values):
return _subject_update(context, values, None, purge_props=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_property_create(context, values, session=None):\n prop_ref = models.SubjectProperty()\n prop = _subject_property_update(context, prop_ref, values, session=session)\n return prop.to_dict()",
"def subject_member_create(context, values, session=None):\n memb_ref = models.SubjectMember()\n ... | [
"0.6719623",
"0.61484027",
"0.6093333",
"0.56392276",
"0.5612736",
"0.5576184",
"0.5552742",
"0.54739",
"0.5399233",
"0.5387403",
"0.53574824",
"0.53574824",
"0.53574824",
"0.53574824",
"0.53574824",
"0.53174007",
"0.530313",
"0.5256148",
"0.5249234",
"0.52405345",
"0.5212260... | 0.7354736 | 0 |
Destroy the subject or raise if it does not exist. | def subject_destroy(context, subject_id):
session = get_session()
with session.begin():
subject_ref = _subject_get(context, subject_id, session=session)
# Perform authorization check
_check_mutate_authorization(context, subject_ref)
subject_ref.delete(session=session)
d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_destroy(self, arg):\n obj = self.verify(arg, 2)\n if obj:\n del storage.all()[obj]\n storage.save()",
"def delete(self, subject: str, predicate: str, obj: str):\n self._connector.delete(subject, predicate, obj)",
"def unsubscribe(self, subject):\n pass",... | [
"0.6156746",
"0.61152124",
"0.5988543",
"0.5928946",
"0.58855724",
"0.5861149",
"0.58440906",
"0.5830264",
"0.5810692",
"0.5794636",
"0.57881534",
"0.5782498",
"0.5746621",
"0.57124484",
"0.57124484",
"0.57124484",
"0.57124484",
"0.56885844",
"0.56318176",
"0.5607504",
"0.559... | 0.657969 | 0 |
Generate suitable dictionary list for locations field of subject. We don't need to set other data fields of location record which return from subject query. | def _normalize_locations(context, subject, force_show_deleted=False):
if subject['status'] == 'deactivated' and not context.is_admin:
# Locations are not returned for a deactivated subject for non-admin user
subject['locations'] = []
return subject
if force_show_deleted:
locati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations(self):\n return self.data.get(\"locations\", [])",
"def get_all_locations(self):",
"def get_location_dict(self) -> SubDirDict[Optional[str]]:\n location_dict: SubDirDict[Optional[str]] = SubDirDict()\n for directory, location_time in self.camera_placements.items():\n ... | [
"0.6638691",
"0.62572557",
"0.6144795",
"0.61098355",
"0.6100856",
"0.60925585",
"0.6052241",
"0.6052241",
"0.6052241",
"0.6052241",
"0.6052241",
"0.6052241",
"0.6052241",
"0.5975338",
"0.5966309",
"0.59475636",
"0.5932628",
"0.59243464",
"0.5865868",
"0.5816932",
"0.57897043... | 0.6988656 | 0 |
check if the given subject id is valid before executing operations. For now, we only check its length. The original purpose of this method is wrapping the different behaviors between MySql and DB2 when the subject id length is longer than the defined length in database model. | def _check_subject_id(subject_id):
if (subject_id and
len(subject_id) > models.Subject.id.property.columns[
0].type.length):
raise exception.SubjectNotFound() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateID(id):\n\n if re.compile('[0-9]+').match(id) == None:\n output.completeOutputError(InvalidArgumentCount(descape =\"'%s' is not a valid Id. ID should be numeric with Length = '%s' \" \n\t\t\t% (id, lib.constants._ATTR_ID_LENGHT)))\n return -1\n else:\n # Check for the lenght ... | [
"0.6548286",
"0.6513764",
"0.6070739",
"0.60522634",
"0.59779906",
"0.5924684",
"0.5860443",
"0.5835978",
"0.5768098",
"0.5676718",
"0.5619321",
"0.5582842",
"0.5564673",
"0.55504537",
"0.55287606",
"0.5502897",
"0.5496578",
"0.54887575",
"0.54608834",
"0.5433684",
"0.5421568... | 0.82107097 | 0 |
Get an subject or raise if it does not exist. | def _subject_get(context, subject_id, session=None, force_show_deleted=False):
_check_subject_id(subject_id)
session = session or get_session()
try:
query = session.query(models.Subject).options(
sa_orm.joinedload(models.Subject.properties)).options(
sa_orm.joinedload(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_subject(subject_id: SubjectID) -> Optional[Subject]:\n subject = DbSubject.query.get(subject_id)\n\n if subject is None:\n return None\n\n return _db_entity_to_subject(subject)",
"def _get_v2_subject_metadata(self, request, subject_id):\n db_api = subject.db.get_api()\n sub... | [
"0.7166992",
"0.60514516",
"0.60401314",
"0.6003597",
"0.60032964",
"0.598148",
"0.5942868",
"0.578982",
"0.5784934",
"0.574257",
"0.56569445",
"0.5612184",
"0.5577021",
"0.5571173",
"0.5479306",
"0.54013395",
"0.54000425",
"0.5384278",
"0.53687537",
"0.5359544",
"0.5326008",... | 0.68371254 | 1 |
Return True if the subject is mutable in this context. | def is_subject_mutable(context, subject):
# Is admin == subject mutable
if context.is_admin:
return True
# No owner == subject not mutable
if subject['owner'] is None or context.owner is None:
return False
# Subject only mutable by its owner
return subject['owner'] == context.o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_mutable(self):\n return self._mutable",
"def immutable(self) -> bool:\n return self._immutable",
"def has_immutability_policy(self) -> bool:\n return pulumi.get(self, \"has_immutability_policy\")",
"def isImmutable(self):\n if self.isPrimaryKey():\n return True\n... | [
"0.8144064",
"0.7086191",
"0.68287987",
"0.67528945",
"0.65845734",
"0.64509684",
"0.64478505",
"0.6364122",
"0.6176089",
"0.61606026",
"0.6126574",
"0.6097917",
"0.606491",
"0.606491",
"0.6055776",
"0.6055697",
"0.6043553",
"0.60326165",
"0.60317147",
"0.60317147",
"0.602371... | 0.8458999 | 0 |
Return the default value of the columns from DB table In postgreDB case, if no right default values are being set, an psycopg2.DataError will be thrown. | def _get_default_column_value(column_type):
type_schema = {
'datetime': None,
'big_integer': 0,
'integer': 0,
'string': ''
}
if isinstance(column_type, sa_sql.type_api.Variant):
return _get_default_column_value(column_type.impl)
return type_schema[column_type.__... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default(self):\r\n value = self.column.default\r\n if value is None:\r\n value = self.table.default\r\n return value",
"def get_default_columns(request):\n columns = request.user.default_custom_columns\n\n if columns == '{}' or type(columns) == dict:\n initial_col... | [
"0.6730814",
"0.6415978",
"0.64014196",
"0.6092394",
"0.5986135",
"0.5826674",
"0.5749256",
"0.56218797",
"0.5602486",
"0.5560275",
"0.55586016",
"0.54702944",
"0.5464809",
"0.54161936",
"0.5411841",
"0.5328305",
"0.5290214",
"0.5216749",
"0.51667774",
"0.513045",
"0.5130192"... | 0.65836674 | 1 |
Returns a query with sorting / pagination criteria added. Pagination works by requiring a unique sort_key, specified by sort_keys. (If sort_keys is not unique, then we risk looping through values.) We use the last row in the previous page as the 'marker' for pagination. So we must return values that follow the passed m... | def _paginate_query(query, model, limit, sort_keys, marker=None,
sort_dir=None, sort_dirs=None):
if 'id' not in sort_keys:
# TODO(justinsb): If this ever gives a false-positive, check
# the actual primary key, rather than assuming its id
LOG.warn(_LW('Id not in sort_keys... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pagination(self, lastValue=None, sortKey=\"_id\", limit=10, asc=\"ASC\"):\n comparison = \"\"\n if lastValue is not None:\n comparison = sortKey + \" > \" + sanitize_value(lastValue)\n limit = int(limit)\n if asc != \"ASC\" and asc != \"DESC\":\n asc = \"ASC\"\... | [
"0.6671282",
"0.64319795",
"0.570819",
"0.5678227",
"0.5496326",
"0.5489555",
"0.54890734",
"0.5439849",
"0.542222",
"0.5416399",
"0.53959745",
"0.5389482",
"0.53767145",
"0.53093445",
"0.5290743",
"0.52809995",
"0.5277707",
"0.5259282",
"0.5205826",
"0.5192034",
"0.5162529",... | 0.72182333 | 0 |
Removed protected attributes from values dictionary using the models __protected_attributes__ field. | def _drop_protected_attrs(model_class, values):
for attr in model_class.__protected_attributes__:
if attr in values:
del values[attr] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_attributes(self):\n attrs = {}\n\n # Only fetch the fields we need.\n for a in self.attributes.only('name', 'value', 'attribute').iterator():\n if a.attribute.multi:\n if a.name not in attrs:\n attrs[a.name] = []\n attrs[a.n... | [
"0.6295131",
"0.59958804",
"0.59696347",
"0.5935034",
"0.5811424",
"0.568888",
"0.567086",
"0.5664389",
"0.56493944",
"0.5640074",
"0.56233746",
"0.56223124",
"0.5611786",
"0.5591424",
"0.5586236",
"0.5567396",
"0.5558045",
"0.5536151",
"0.5524247",
"0.55179757",
"0.5494092",... | 0.8467441 | 0 |
Delete all subject locations for given subject | def _subject_locations_delete_all(context, subject_id,
delete_time=None, session=None):
session = session or get_session()
location_refs = session.query(models.SubjectLocation).filter_by(
subject_id=subject_id).filter_by(deleted=False).all()
for loc_id in [loc_ref.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_destroy(context, subject_id):\n session = get_session()\n with session.begin():\n subject_ref = _subject_get(context, subject_id, session=session)\n\n # Perform authorization check\n _check_mutate_authorization(context, subject_ref)\n\n subject_ref.delete(session=sessi... | [
"0.6942515",
"0.63338363",
"0.61779135",
"0.6002349",
"0.5999233",
"0.58899516",
"0.5794159",
"0.5787285",
"0.5665877",
"0.5641831",
"0.5588912",
"0.55620843",
"0.5558814",
"0.55396605",
"0.5534111",
"0.5513925",
"0.551166",
"0.5487714",
"0.54498816",
"0.544701",
"0.5436892",... | 0.8108433 | 0 |
Create or update a set of subject_properties for a given subject | def _set_properties_for_subject(context, subject_ref, properties,
purge_props=False, session=None):
orig_properties = {}
for prop_ref in subject_ref.properties:
orig_properties[prop_ref.name] = prop_ref
for name, value in six.iteritems(properties):
prop_value... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _subject_update(context, values, subject_id, purge_props=False,\n from_state=None):\n\n # NOTE(jbresnah) values is altered in this so a copy is needed\n values = values.copy()\n\n session = get_session()\n with session.begin():\n\n # Remove the properties passed in the val... | [
"0.71560746",
"0.7050138",
"0.66241163",
"0.6448725",
"0.629695",
"0.59508616",
"0.59508616",
"0.5884675",
"0.5694142",
"0.564179",
"0.56148976",
"0.56016207",
"0.55981386",
"0.55074966",
"0.54972917",
"0.54522806",
"0.5450589",
"0.5450589",
"0.5450589",
"0.5450589",
"0.54505... | 0.75329506 | 0 |
Deletes all the child entries for the given subject id. Deletes all the child entries of the given child entry ORM model class using the parent subject's id. | def _subject_child_entry_delete_all(child_model_cls, subject_id,
delete_time=None,
session=None):
session = session or get_session()
query = session.query(child_model_cls).filter_by(
subject_id=subject_id).filter_by(deleted=False)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_child(self, model):\n assert isinstance(model, self.model_class) # it's a homogeneous collection\n m_id = str(model.get_id())\n assert m_id != None # needs a real id or cid\n assert m_id in self._models\n model._mark_deleted()\n del self._models[m_id]",
"def ... | [
"0.61903846",
"0.60342854",
"0.5954816",
"0.56658846",
"0.5662066",
"0.56579137",
"0.5624985",
"0.5615249",
"0.5572838",
"0.5506553",
"0.5505168",
"0.5489427",
"0.53991544",
"0.53259915",
"0.53105956",
"0.5259673",
"0.52188885",
"0.5185042",
"0.5156438",
"0.5156438",
"0.51564... | 0.7433899 | 0 |
Create an SubjectProperty object. | def subject_property_create(context, values, session=None):
prop_ref = models.SubjectProperty()
prop = _subject_property_update(context, prop_ref, values, session=session)
return prop.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_create(context, values):\n return _subject_update(context, values, None, purge_props=False)",
"def create(subdomain, subject_type_or_type_name, subject_name, author):\n return Subject(key_name='%s:%s' % (subdomain, subject_name),\n type=get_name(subject_type_or_type_na... | [
"0.6631801",
"0.62869614",
"0.6095638",
"0.6081347",
"0.5995315",
"0.590395",
"0.5835727",
"0.5711087",
"0.57100517",
"0.5705224",
"0.5586757",
"0.5580606",
"0.5508344",
"0.5319301",
"0.5297464",
"0.5199743",
"0.519235",
"0.5189478",
"0.51521313",
"0.51510763",
"0.5131937",
... | 0.76709926 | 0 |
Delete all subject properties for given subject | def _subject_property_delete_all(context, subject_id, delete_time=None,
session=None):
props_updated_count = _subject_child_entry_delete_all(
models.SubjectProperty,
subject_id,
delete_time,
session)
return props_updated_count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_property_delete(context, prop_ref, subject_ref, session=None):\n session = session or get_session()\n prop = session.query(models.SubjectProperty).filter_by(\n subject_id=subject_ref,\n name=prop_ref).one()\n prop.delete(session=session)\n return prop",
"def clear_subjects(d... | [
"0.7102737",
"0.6846818",
"0.67893827",
"0.6510621",
"0.6355884",
"0.6255417",
"0.6255417",
"0.6255417",
"0.6255417",
"0.6207411",
"0.5905474",
"0.5889425",
"0.5845338",
"0.5824589",
"0.5824589",
"0.5824589",
"0.5824589",
"0.5813806",
"0.57848",
"0.5779243",
"0.5770859",
"0... | 0.77443945 | 0 |
Create an SubjectMember object. | def subject_member_create(context, values, session=None):
memb_ref = models.SubjectMember()
_subject_member_update(context, memb_ref, values, session=session)
return _subject_member_format(memb_ref) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(subdomain, subject_type_or_type_name, subject_name, author):\n return Subject(key_name='%s:%s' % (subdomain, subject_name),\n type=get_name(subject_type_or_type_name), author=author)",
"def instantiate_subject(cls, *args, **kwargs) -> Any:\n return cls.subject_type(... | [
"0.7017707",
"0.6773059",
"0.67594355",
"0.6725012",
"0.64071566",
"0.62850463",
"0.6284095",
"0.62414813",
"0.6204804",
"0.604151",
"0.60224396",
"0.59378254",
"0.5831784",
"0.58108497",
"0.5783808",
"0.5783808",
"0.57659405",
"0.57412416",
"0.57275826",
"0.5709465",
"0.5650... | 0.77646625 | 0 |
Format a member ref for consumption outside of this module. | def _subject_member_format(member_ref):
return {
'id': member_ref['id'],
'subject_id': member_ref['subject_id'],
'member': member_ref['member'],
'can_share': member_ref['can_share'],
'status': member_ref['status'],
'created_at': member_ref['created_at'],
'upda... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ref_string(ref):\n\n return colored('(' + ref + ')', 'magenta')",
"def memberName(self, p_int): # real signature unknown; restored from __doc__\n return \"\"",
"def create_field_href(reference: NamedRef,\n env: BuildEnvironment) -> pending_xref:\n\n text = reference.name\n... | [
"0.6082202",
"0.59421515",
"0.5928535",
"0.58438885",
"0.5692432",
"0.5649209",
"0.5611903",
"0.55989116",
"0.5589555",
"0.54693234",
"0.54685086",
"0.5466524",
"0.5436313",
"0.54103905",
"0.53933394",
"0.53390527",
"0.533766",
"0.53224415",
"0.52899224",
"0.5257451",
"0.5253... | 0.6415211 | 0 |
Update an SubjectMember object. | def subject_member_update(context, memb_id, values):
session = get_session()
memb_ref = _subject_member_get(context, memb_id, session)
_subject_member_update(context, memb_ref, values, session)
return _subject_member_format(memb_ref) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, subject: Subject) -> None:\n pass",
"def update(self, subject: Subject) -> None:\n pass",
"def _subject_member_update(context, memb_ref, values, session=None):\n _drop_protected_attrs(models.SubjectMember, values)\n values[\"deleted\"] = False\n values.setdefault('can_sh... | [
"0.7373385",
"0.7373385",
"0.723977",
"0.70292026",
"0.6793908",
"0.6728615",
"0.64198357",
"0.6346916",
"0.60114604",
"0.59385926",
"0.59146076",
"0.59146076",
"0.59146076",
"0.58938694",
"0.5792362",
"0.57671714",
"0.57547987",
"0.57239455",
"0.5708096",
"0.5582887",
"0.555... | 0.7638034 | 0 |
Delete an SubjectMember object. | def subject_member_delete(context, memb_id, session=None):
session = session or get_session()
member_ref = _subject_member_get(context, memb_id, session)
_subject_member_delete(context, member_ref, session) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, subject: str, predicate: str, obj: str):\n self._connector.delete(subject, predicate, obj)",
"def delete_by_id(self, subject_id: str) -> any:\n pass",
"def delete_member():\n client = RequestManager()\n client.set_method(\"DELETE\")\n member_id = STORED_ID[\"... | [
"0.71564585",
"0.71161926",
"0.7112259",
"0.68816674",
"0.6780883",
"0.665503",
"0.6457886",
"0.6414677",
"0.6353341",
"0.61828506",
"0.6176628",
"0.6159955",
"0.6156415",
"0.60077745",
"0.5998203",
"0.5975962",
"0.59206283",
"0.5876538",
"0.5819948",
"0.5788523",
"0.5781712"... | 0.810083 | 0 |
Delete all subject members for given subject | def _subject_member_delete_all(context, subject_id, delete_time=None,
session=None):
members_updated_count = _subject_child_entry_delete_all(
models.SubjectMember,
subject_id,
delete_time,
session)
return members_updated_count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_destroy(context, subject_id):\n session = get_session()\n with session.begin():\n subject_ref = _subject_get(context, subject_id, session=session)\n\n # Perform authorization check\n _check_mutate_authorization(context, subject_ref)\n\n subject_ref.delete(session=sessi... | [
"0.69369745",
"0.6868023",
"0.68533635",
"0.64770865",
"0.6461521",
"0.63830364",
"0.6377651",
"0.6367139",
"0.6197601",
"0.61245626",
"0.60912067",
"0.60664636",
"0.60533625",
"0.5935369",
"0.58480257",
"0.5792046",
"0.5761164",
"0.5740536",
"0.5725094",
"0.57190454",
"0.570... | 0.77759296 | 0 |
Fetch an SubjectMember entity by id. | def _subject_member_get(context, memb_id, session):
query = session.query(models.SubjectMember)
query = query.filter_by(id=memb_id)
return query.one() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_member_find(context, subject_id=None, member=None,\n status=None, include_deleted=False):\n session = get_session()\n members = _subject_member_find(context, session, subject_id,\n member, status, include_deleted)\n return [_subject_memb... | [
"0.6693427",
"0.662903",
"0.6386802",
"0.63256603",
"0.61489797",
"0.61489797",
"0.60977966",
"0.6071499",
"0.60522044",
"0.600489",
"0.6002042",
"0.6000748",
"0.5930929",
"0.5901205",
"0.58869725",
"0.58599263",
"0.5825848",
"0.57864964",
"0.5755701",
"0.57356846",
"0.572461... | 0.76060903 | 0 |
Find all members that meet the given criteria. Note, currently include_deleted should be true only when create a new subject membership, as there may be a deleted subject membership between the same subject and tenant, the membership will be reused in this case. It should be false in other cases. | def subject_member_find(context, subject_id=None, member=None,
status=None, include_deleted=False):
session = get_session()
members = _subject_member_find(context, session, subject_id,
member, status, include_deleted)
return [_subject_member_format(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_members(self, details):\n\n results = []\n\n for member in self.member:\n if details.match(member):\n results.append(member)\n\n return results",
"def members(self):\n return self.find_users_by_rel('member')",
"def list_members(self, **filters):\n\... | [
"0.6023723",
"0.5871611",
"0.55450696",
"0.5510003",
"0.54630554",
"0.5459703",
"0.5459076",
"0.5388014",
"0.53427327",
"0.53270817",
"0.528365",
"0.526831",
"0.5146006",
"0.51447207",
"0.5139166",
"0.513748",
"0.5121739",
"0.5119158",
"0.5099309",
"0.5082931",
"0.5063044",
... | 0.6412017 | 0 |
Return the number of subject members for this subject | def subject_member_count(context, subject_id):
session = get_session()
if not subject_id:
msg = _("Subject id is required.")
raise exception.Invalid(msg)
query = session.query(models.SubjectMember)
query = query.filter_by(deleted=False)
query = query.filter(models.SubjectMember.sub... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def member_count(self):\n return len(self.members)",
"def nb_subjects(self) -> int:\n return 0",
"def getNumMembers(self):\n return _libsbml.Group_getNumMembers(self)",
"def getNumMembers(self):\n return _libsbml.ListOfMembers_getNumMembers(self)",
"def get_members_count(self, *... | [
"0.772104",
"0.74138516",
"0.736991",
"0.72562224",
"0.68163705",
"0.67959434",
"0.6596146",
"0.65303284",
"0.6507669",
"0.6457859",
"0.6423427",
"0.64205056",
"0.640804",
"0.6380624",
"0.6347884",
"0.63121754",
"0.62402576",
"0.6160997",
"0.61510974",
"0.61480117",
"0.614164... | 0.7710199 | 1 |
Create an subject tag. | def subject_tag_create(context, subject_id, value, session=None):
session = session or get_session()
tag_ref = models.SubjectTag(subject_id=subject_id, value=value)
tag_ref.save(session=session)
return tag_ref['value'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_create(context, values):\n return _subject_update(context, values, None, purge_props=False)",
"def create_subject(name=\"Basket Weaving\"):\n subj = Subject(name=name)\n subj.save()\n return subj",
"def create(subdomain, subject_type_or_type_name, subject_name, author):\n return ... | [
"0.6811929",
"0.66324675",
"0.64452636",
"0.62283695",
"0.61825234",
"0.61425",
"0.6058423",
"0.60178465",
"0.5926609",
"0.58753437",
"0.58753437",
"0.58601826",
"0.5715259",
"0.56838137",
"0.5600378",
"0.5591045",
"0.55669475",
"0.55263346",
"0.5451471",
"0.53438646",
"0.531... | 0.73855406 | 0 |
Delete an subject tag. | def subject_tag_delete(context, subject_id, value, session=None):
_check_subject_id(subject_id)
session = session or get_session()
query = session.query(models.SubjectTag).filter_by(
subject_id=subject_id).filter_by(
value=value).filter_by(deleted=False)
try:
tag_ref = query.one(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, tag, params={}, **options):\n path = \"/tags/%s\" % (tag)\n return self.client.delete(path, params, **options)",
"def delete_tag(self, session, tag):\n self._tag(session.delete, key=tag, delete=True, session=session)",
"def delete_by_id(self, subject_id: str) -> any:\n ... | [
"0.709339",
"0.7052322",
"0.693086",
"0.6910266",
"0.6902236",
"0.6717449",
"0.65322006",
"0.6528793",
"0.65088505",
"0.6436326",
"0.64264673",
"0.63981783",
"0.6388653",
"0.63556457",
"0.6322902",
"0.627703",
"0.624736",
"0.6191011",
"0.6181572",
"0.6148288",
"0.614188",
"... | 0.8068629 | 0 |
Delete all subject tags for given subject | def _subject_tag_delete_all(context, subject_id, delete_time=None,
session=None):
tags_updated_count = _subject_child_entry_delete_all(models.SubjectTag,
subject_id,
delete_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_tag_delete(context, subject_id, value, session=None):\n _check_subject_id(subject_id)\n session = session or get_session()\n query = session.query(models.SubjectTag).filter_by(\n subject_id=subject_id).filter_by(\n value=value).filter_by(deleted=False)\n try:\n tag_ref ... | [
"0.6847024",
"0.6431806",
"0.6342323",
"0.62756574",
"0.61179",
"0.6013861",
"0.59882486",
"0.5971582",
"0.59447956",
"0.59051406",
"0.58736604",
"0.58480704",
"0.5802765",
"0.5777592",
"0.5772941",
"0.5767336",
"0.563686",
"0.55940485",
"0.5585156",
"0.5585103",
"0.558213",
... | 0.77127784 | 0 |
Get a list of tags for a specific subject. | def subject_tag_get_all(context, subject_id, session=None):
_check_subject_id(subject_id)
session = session or get_session()
tags = session.query(models.SubjectTag.value).filter_by(
subject_id=subject_id).filter_by(deleted=False).all()
return [tag[0] for tag in tags] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags(self):\n tagexp = re.compile(r\"\\[([^\\]]*)\\]\")\n subject = self['Subject']\n return tagexp.findall(subject)",
"def subject_list():\n items = []\n\n soup = abcradionational.get_soup(URL + \"/podcasts/subjects\")\n \n subject_heading = abcradionational.get_podcast_head... | [
"0.69604874",
"0.66992587",
"0.6330689",
"0.61866695",
"0.61485606",
"0.60778725",
"0.60760117",
"0.6038392",
"0.6011423",
"0.5976113",
"0.5958356",
"0.5890714",
"0.58770794",
"0.58740425",
"0.5859264",
"0.5854765",
"0.5854765",
"0.5819708",
"0.5800912",
"0.57946754",
"0.5784... | 0.8267461 | 0 |
Purges soft deleted rows Deletes rows of table subjects, table tasks and all dependent tables according to given age for relevant models. | def purge_deleted_rows(context, age_in_days, max_rows, session=None):
# check max_rows for its maximum limit
_validate_db_int(max_rows=max_rows)
session = session or get_session()
metadata = MetaData(get_engine())
deleted_age = timeutils.utcnow() - datetime.timedelta(days=age_in_days)
tables =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def purge_deleted_records(context, age_in_days):\n\n if age_in_days < 0:\n msg = _('Must supply a non-negative value for \"age_in_days\".')\n LOG.error(msg)\n raise exception.InvalidParameterValue(msg)\n\n metadata = MetaData()\n metadata.reflect(get_engine())\n deleted_age = timeu... | [
"0.77724546",
"0.6004206",
"0.58406615",
"0.5789192",
"0.57181877",
"0.57077676",
"0.566714",
"0.5518765",
"0.5479598",
"0.5477541",
"0.54358685",
"0.54268956",
"0.54265106",
"0.54061675",
"0.53629476",
"0.5359919",
"0.53596616",
"0.53401965",
"0.5332357",
"0.53110474",
"0.52... | 0.7689614 | 1 |
Format a task info ref for consumption outside of this module | def _task_info_format(task_info_ref):
if task_info_ref is None:
return {}
return {
'task_id': task_info_ref['task_id'],
'input': task_info_ref['input'],
'result': task_info_ref['result'],
'message': task_info_ref['message'],
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _task_format(task_ref, task_info_ref=None):\n task_dict = {\n 'id': task_ref['id'],\n 'type': task_ref['type'],\n 'status': task_ref['status'],\n 'owner': task_ref['owner'],\n 'expires_at': task_ref['expires_at'],\n 'created_at': task_ref['created_at'],\n 'up... | [
"0.7674674",
"0.6899841",
"0.6317636",
"0.61641705",
"0.6054649",
"0.6033362",
"0.5939692",
"0.59149015",
"0.5884836",
"0.5856331",
"0.58062106",
"0.575718",
"0.5754282",
"0.57492846",
"0.5716492",
"0.56746906",
"0.56243306",
"0.5612575",
"0.5611509",
"0.56018454",
"0.5580019... | 0.78405625 | 0 |
Fetch an TaskInfo entity by task_id | def _task_info_get(context, task_id, session=None):
session = session or get_session()
query = session.query(models.TaskInfo)
query = query.filter_by(task_id=task_id)
try:
task_info_ref = query.one()
except sa_orm.exc.NoResultFound:
LOG.debug("TaskInfo was not found for task with id ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, task_id):\n try:\n return self.dal.task.get_by_id(task_id)\n except EntityNotFound:\n raise DoesNotExist()",
"def get_task(self, task_id):\n res = self.conn.cursor().execute(\"SELECT * FROM tasks WHERE id=?\", (task_id,))\n return res.fetchone()",
... | [
"0.7787624",
"0.7614994",
"0.7468545",
"0.73390454",
"0.723455",
"0.7167309",
"0.71258897",
"0.7062043",
"0.70458794",
"0.704292",
"0.7028391",
"0.6967885",
"0.6960173",
"0.6921486",
"0.6910813",
"0.6910813",
"0.6880598",
"0.6816003",
"0.6772159",
"0.67573464",
"0.6750788",
... | 0.79652715 | 0 |
Return True if the task is visible in this context. | def _is_task_visible(context, task):
# Is admin == task visible
if context.is_admin:
return True
# No owner == task visible
if task['owner'] is None:
return True
# Perform tests based on whether we have an owner
if context.owner is not None:
if context.owner == task['ow... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_visible(cls, request):\n if cls.permission_required:\n return request.user.has_perm(cls.permission_uri)\n else:\n return True",
"def is_visible(self):\n return self._visible",
"def is_visible(self):\n return self.container['is_visible']",
"def is_avail... | [
"0.7566281",
"0.75203836",
"0.7445509",
"0.7330846",
"0.71210164",
"0.71210164",
"0.7093695",
"0.70769536",
"0.70677257",
"0.7056802",
"0.70255625",
"0.7022891",
"0.7015922",
"0.69889367",
"0.6980119",
"0.69530725",
"0.6930809",
"0.69113964",
"0.68983215",
"0.6888527",
"0.686... | 0.8430884 | 0 |
Format a task ref for consumption outside of this module | def _task_format(task_ref, task_info_ref=None):
task_dict = {
'id': task_ref['id'],
'type': task_ref['type'],
'status': task_ref['status'],
'owner': task_ref['owner'],
'expires_at': task_ref['expires_at'],
'created_at': task_ref['created_at'],
'updated_at': ta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _format_task(task: \"asyncio.Task[Any]\") -> str:\n coro = _format_coroutine(task.get_coro()).partition(\" \")[0]\n return f\"<Task name={task.get_name()} coro={coro}>\"",
"def _task_info_format(task_info_ref):\n if task_info_ref is None:\n return {}\n return {\n 'task_id': task_inf... | [
"0.70281965",
"0.6806531",
"0.6270676",
"0.6159294",
"0.6107327",
"0.60382444",
"0.59807193",
"0.5914529",
"0.57917243",
"0.57915187",
"0.5732961",
"0.5722596",
"0.571787",
"0.5714517",
"0.57123494",
"0.570763",
"0.5680628",
"0.56582665",
"0.5616886",
"0.56031877",
"0.5557315... | 0.72834486 | 0 |
Moves the numbers in one line according to the rules of 2048. Takes a line (list) as an argument | def move(line):
length = len(line)
pos = 0
global points
global sym
while pos < len(
line):
if (line[pos] == 0):
del line[pos]
else:
pos = pos + 1
if len(line) == 0:
return [0] * length
pos = 0
while line[pos] != 0 and pos + 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numbers_in_line(line):\n ret = []\n pos = 0\n while True:\n loc = find_next_number(line, pos)\n if not loc:\n break\n ret.append(loc)\n pos = loc[1]\n return ret",
"def merge(line):\n # replace with your code\n result = []\n for index in range(len(l... | [
"0.589009",
"0.58604544",
"0.58417785",
"0.5751105",
"0.56166744",
"0.55808437",
"0.55631554",
"0.5478011",
"0.5466192",
"0.54286385",
"0.5406102",
"0.53723663",
"0.53705597",
"0.53621626",
"0.53621626",
"0.5355045",
"0.53497285",
"0.5339156",
"0.53325903",
"0.5329621",
"0.53... | 0.59649575 | 0 |
Decides which direction the numbers should move and which function to use. Takes a field (list) and a direction (string) as arguments | def Transform(field, dir):
if dir == "w":
field = TransformUpMovement(field)
elif dir == "s":
field = TransformDownMovement(field)
elif dir == "a":
field = TransformLeftMovement(field)
elif dir == "d":
field = TransformRightMovement(field)
return field | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def motorsDirection(self, direction):\n\n print (direction)\n if direction == 'r' or direction == 'R':\n self.motorDirection(self.motor1DirectionPin, self.motorReverse)\n self.motorDirection(self.motor2DirectionPin, self.motorReverse)\n print (\"Direction reverse\")\n else:\n self.moto... | [
"0.6022935",
"0.5904038",
"0.58467376",
"0.5798845",
"0.5735596",
"0.5735596",
"0.5720787",
"0.5689735",
"0.5684878",
"0.5579244",
"0.5538586",
"0.5538111",
"0.54772305",
"0.5432082",
"0.5423685",
"0.53911453",
"0.53749377",
"0.53623766",
"0.5355661",
"0.5354094",
"0.5321425"... | 0.65193075 | 0 |
Checks the field if it is full. Takes a field (list) as argument | def FullCheck(field):
temp_list = field[:]
field_copy = field[:]
if temp_list == Transform(field_copy, "w"):
if temp_list == Transform(field_copy, "a"):
if temp_list == Transform(field_copy, "s"):
if temp_list == Transform(field_copy, "d"):
return True... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_field_empty(*args):\n for field in args:\n if field == \"\" or field is None:\n return True\n return False\n return \"NONDETERMINISTIC\"",
"def check_if_full(self):\n pass",
"def hasFlexibleFields(data):\n\n regexp = '_f[0..9]+$'\n\n # XXX GR the 'and' close s... | [
"0.66554433",
"0.6221918",
"0.6166605",
"0.6137325",
"0.6085341",
"0.60369235",
"0.6035399",
"0.59512186",
"0.59295654",
"0.58942074",
"0.58777976",
"0.5861349",
"0.5857683",
"0.58130646",
"0.5796944",
"0.5767664",
"0.57454145",
"0.57401884",
"0.5733064",
"0.5717946",
"0.5710... | 0.63879234 | 1 |
Ask for a row/column size constatly until it is not a valid choice (choice >= 2) | def SizeCheck():
while True:
try:
curses.echo() # Enable echoing of characters
stdscr.addstr(0, 0, "Give a table square row/column size : ")
stdscr.move(0, 38)
size = stdscr.getstr(0, 38, 2)
size = int(size)
curses.noecho()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ask_input(player, row_or_column):\n\n row_or_column_number = ask_input_helper(player, row_or_column)\n while row_or_column_number not in range(board_size):\n print \"Please choose a number within the range.\" \n row_or_column_number = ask_input_helper(player, row_or_column)\n return r... | [
"0.74070376",
"0.6311623",
"0.6182362",
"0.6077857",
"0.6032311",
"0.596216",
"0.58821315",
"0.5825646",
"0.5755316",
"0.57509243",
"0.5743062",
"0.5702003",
"0.5646607",
"0.56385875",
"0.56270397",
"0.558409",
"0.5575573",
"0.5574369",
"0.55727065",
"0.5570435",
"0.55586517"... | 0.702478 | 1 |
Main drawing function that initializes curses | def Init_curses():
curses.noecho()
curses.cbreak()
curses.curs_set(False)
stdscr.keypad(True)
curses.init_pair(1, curses.COLOR_YELLOW, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init():\n unicornhathd.rotation(270)\n unicornhathd.brightness(1.0)\n\n stdscr = curses.initscr()\n curses.cbreak()\n curses.noecho()\n stdscr.nodelay(1)\n stdscr.keypad(1)\n\n return stdscr",
"def __init__(self, y, x, height, width):\n\n self.window = curses.newwin(height, wid... | [
"0.7274357",
"0.716031",
"0.7106765",
"0.70112157",
"0.70013845",
"0.6940732",
"0.6869848",
"0.6845006",
"0.67449564",
"0.67070323",
"0.6689889",
"0.6677951",
"0.6669039",
"0.6647801",
"0.6636719",
"0.66353697",
"0.6634113",
"0.6630191",
"0.65941644",
"0.6593179",
"0.65753996... | 0.7540439 | 0 |
r"""Right matrix division A/B. | def rmdiv(A, B, rcond=None):
A = np.asarray(A)
B = np.asarray(B)
if len(A.shape) == 1:
A = A[..., None]
if len(B.shape) == 1:
B = B[..., None]
return np.linalg.lstsq(B.transpose(), A.transpose(), rcond=rcond)[0].transpose() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __div__(self, other):\r\n T = type(other)\r\n # mat4/scalar\r\n if T==types.FloatType or T==types.IntType or T==types.LongType:\r\n return mat4(map(lambda x,other=other: x/other, self.mlist))\r\n # unsupported\r\n else:\r\n raise TypeError, \"unsupported... | [
"0.62675714",
"0.611473",
"0.6102201",
"0.6009135",
"0.59950954",
"0.5991952",
"0.59662265",
"0.5965083",
"0.5931645",
"0.59230405",
"0.5910507",
"0.5884071",
"0.58263725",
"0.5795326",
"0.5790581",
"0.57295984",
"0.57213384",
"0.5719486",
"0.5708228",
"0.56986713",
"0.569441... | 0.6681732 | 0 |
Check if a list of matrices commmute. | def check_commutative(mats):
mats = np.stack((mat for mat in mats))
nb_matrices = len(mats)
check = np.eye(nb_matrices, dtype=bool)
for i in range(nb_matrices):
for j in range(i, nb_matrices):
check[i, j] = np.allclose(mats[i, ...] @ mats[j, ...],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_mat_list(list_matrices):\n flag = True\n if isinstance(list_matrices, list):\n for matrix in list_matrices:\n if not isinstance(matrix, np.matrix):\n flag = False\n # TODO Check for matrix dimensions?\n else:\n flag = False\n return flag",
... | [
"0.7690081",
"0.6517234",
"0.64013594",
"0.6349729",
"0.62057924",
"0.6183399",
"0.61053455",
"0.6088334",
"0.6077872",
"0.6048047",
"0.60106003",
"0.59638304",
"0.5930711",
"0.59300643",
"0.59250367",
"0.58386123",
"0.58130705",
"0.58031714",
"0.573052",
"0.57295907",
"0.571... | 0.7082987 | 1 |
Check if a list of matrices forms an orthonormal basis. | def check_orthonormal(mats):
mats = np.stack((mat for mat in mats))
nb_matrices = len(mats)
dot = np.eye(nb_matrices, dtype=np.float64)
for i in range(nb_matrices):
for j in range(i, nb_matrices):
dot[i, j] = np.trace(mats[i, ...] @ mats[j, ...].transpose())
dot[j, i] = d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_mat_list(list_matrices):\n flag = True\n if isinstance(list_matrices, list):\n for matrix in list_matrices:\n if not isinstance(matrix, np.matrix):\n flag = False\n # TODO Check for matrix dimensions?\n else:\n flag = False\n return flag",
... | [
"0.68600386",
"0.64700145",
"0.63169473",
"0.5977321",
"0.5859525",
"0.5731614",
"0.5651928",
"0.5617208",
"0.557992",
"0.553658",
"0.55348724",
"0.55106556",
"0.54960275",
"0.5460473",
"0.5455496",
"0.5454142",
"0.54330325",
"0.54206663",
"0.5403764",
"0.54003906",
"0.540005... | 0.72912705 | 0 |
Displays a form for uploading files using jQuery File Upload. A user may use both a custom template or a custom uploadhandling URL name by supplying values for template_name and upload_handler_name respectively. Any additionally supplied positional and keyword arguments are directly forwarded to the named custom upload... | def jfu(
context,
template_name = 'jfu/upload_form.html',
upload_handler_name = 'jfu_upload',
*args, **kwargs
):
context.update( {
'JQ_OPEN' : '{%',
'JQ_CLOSE' : '%}',
'upload_handler_url': reverse(
upload_handler_name, args = args, kwargs = k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jfu(\n context,\n template_name='jfu/upload_form.html',\n upload_handler_name='jfu_upload',\n *args, **kwargs\n):\n context.update({\n 'JQ_OPEN': '{%',\n 'JQ_CLOSE': '%}',\n 'upload_handler_url': reverse(\n upload_handler_name, args=args, kwargs=kwargs\n ),... | [
"0.76479894",
"0.71969444",
"0.6322737",
"0.625024",
"0.6227873",
"0.61773294",
"0.6134288",
"0.59976363",
"0.59345126",
"0.59241974",
"0.5852295",
"0.58488095",
"0.5785617",
"0.5763903",
"0.5763903",
"0.5756614",
"0.5741969",
"0.573444",
"0.5683205",
"0.56479305",
"0.5618458... | 0.7704134 | 0 |
Expect the model to contain at least one biomass reaction. | def test_biomass_presence(store):
store["biomass_ids"] = BIOMASS_IDS
assert len(BIOMASS_IDS) > 0, \
"Could not identify any biomass reaction." \
" Please change the intended reaction ID(s) to contain 'biomass'." | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_in_reactions(self):\n self.compound.add_reactions({\"a\", \"b\", \"c\"})\n self.compound.add_reactions({\"d\"})\n self.assertTrue(self.compound.has_reaction(\"a\"))\n self.assertEqual(self.compound.number_of_reactions(), 4)\n # check that it is a set\n self.compou... | [
"0.60123044",
"0.57809466",
"0.5741142",
"0.5728338",
"0.55911034",
"0.5386695",
"0.5313684",
"0.5303847",
"0.5290454",
"0.5266035",
"0.5193352",
"0.51840216",
"0.517927",
"0.51626575",
"0.5150667",
"0.5135942",
"0.5125161",
"0.5112585",
"0.5104221",
"0.50741816",
"0.50392777... | 0.60033816 | 1 |
Expect biomass components to sum up to 1 g[CDW]. | def test_biomass_consistency(read_only_model, reaction_id, store):
store["biomass_sum"] = store.get("biomass_sum", list())
reaction = read_only_model.reactions.get_by_id(reaction_id)
component_sum = biomass.sum_biomass_weight(reaction)
store["biomass_sum"].append(component_sum)
assert np.isclose(com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate(self, b):\n self.n_steps = self.n_steps + 1\n self.length = b.length\n self.natoms = b.natoms\n for i in range(0,self.natoms-1):\n for j in range(i+1,self.natoms):\n rij = (b.atoms[i].xyz - b.atoms[j].xyz)\n ... | [
"0.60727906",
"0.58930564",
"0.5806721",
"0.5692757",
"0.56836164",
"0.5680561",
"0.5614816",
"0.5600253",
"0.55526364",
"0.55421716",
"0.5518202",
"0.55129",
"0.55041975",
"0.54974073",
"0.54682225",
"0.5421611",
"0.5409716",
"0.54067844",
"0.5400655",
"0.54000163",
"0.53840... | 0.63290334 | 0 |
Expect production of all biomass precursors in default medium. | def test_biomass_precursors_default_production(read_only_model, reaction_id,
store):
store["default_blocked_precursors"] = store.get(
"default_blocked_precursors", list())
reaction = read_only_model.reactions.get_by_id(reaction_id)
blocked = [
m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_biomass_precursors_open_production(model, reaction_id, store):\n store[\"open_blocked_precursors\"] = store.get(\n \"open_blocked_precursors\", list())\n reaction = model.reactions.get_by_id(reaction_id)\n for exchange in model.exchanges:\n exchange.bounds = (-1000, 1000)\n block... | [
"0.6127013",
"0.5610468",
"0.5351247",
"0.5181714",
"0.5181714",
"0.5181714",
"0.5047461",
"0.5044411",
"0.5037517",
"0.4952377",
"0.49410602",
"0.4936966",
"0.4904956",
"0.48789427",
"0.48756292",
"0.48714232",
"0.48601454",
"0.48329782",
"0.48094466",
"0.48075527",
"0.47840... | 0.62075627 | 0 |
Expect precursor production in complete medium. | def test_biomass_precursors_open_production(model, reaction_id, store):
store["open_blocked_precursors"] = store.get(
"open_blocked_precursors", list())
reaction = model.reactions.get_by_id(reaction_id)
for exchange in model.exchanges:
exchange.bounds = (-1000, 1000)
blocked = [
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_change_provisioned_throughput_usual_case():",
"def at_pre_cmd(self):\n pass",
"def pre_execute(self):",
"def setUP(self):\r\n print(\"=====Begin test=====\")",
"def PreExecute(self):\n return True",
"def test_art_from_taste_space(self):",
"def test_vs_pains():\n vs = vi... | [
"0.54682916",
"0.54465544",
"0.5400266",
"0.5370073",
"0.5348555",
"0.5336248",
"0.53160816",
"0.5258326",
"0.522778",
"0.5162642",
"0.51606184",
"0.51552516",
"0.5146635",
"0.51311016",
"0.51311016",
"0.51311016",
"0.51067126",
"0.51067126",
"0.51067126",
"0.51067126",
"0.51... | 0.57989436 | 0 |
This function returns the variance for the Crude Monte Carlo | def get_crude_mc_variance(num_samples=10000):
int_max = 5 # the max of our integration range
# find the average of squares
running_total = 0
for i in range(num_samples):
x = get_random_number(0, int_max)
running_total += f_of_x(x)**2
sum_of_sqs = (int_max*running_total/num_samples)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variance(self):\n return self.k * self.theta ** 2",
"def variance(self):\n return 1 / self.count() * sum((number-self.average())**2 for number in self.numbers)",
"def variance(self):\r\n\t\t_mean = sum(self.sample)/len(self.sample)\r\n\t\treturn sum(map(lambda x: (x - _mean)**2, self.sample))... | [
"0.7041805",
"0.6913964",
"0.6886008",
"0.67074406",
"0.6684147",
"0.66829354",
"0.66406953",
"0.66406953",
"0.66406953",
"0.6596592",
"0.6560949",
"0.6499182",
"0.64896584",
"0.64888066",
"0.64812016",
"0.6474398",
"0.6474398",
"0.6465969",
"0.6454753",
"0.6426472",
"0.64144... | 0.73956496 | 0 |
Tests whether ``.ChannelMetadataGuildMainBase.__repr__`` works as intended. | def test__ChannelMetadataGuildMainBase__repr():
parent_id = 202209170023
name = 'Armelyrics'
permission_overwrites = [
PermissionOverwrite(202209170025, target_type = PermissionOverwriteTargetType.user)
]
position = 7
channel_metadata = ChannelMetadataGuildMainBase(
parent_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_repr(self):\n dummy = DummyCryptographicObject()\n repr(dummy)",
"def allow_repr(cls) -> bool:\n raise NotImplementedError",
"def test_repr(self, r, rep):\n assert repr(r) == rep",
"def test_repr_show(self):\n self.assertEquals(\n repr(self.t['CNNNN']),\... | [
"0.63506854",
"0.6245055",
"0.62005544",
"0.6168843",
"0.61517996",
"0.61296993",
"0.612222",
"0.61058795",
"0.6051924",
"0.6024747",
"0.5952108",
"0.59316134",
"0.59108627",
"0.58596087",
"0.5840409",
"0.5823097",
"0.58201367",
"0.5795877",
"0.57914394",
"0.5768029",
"0.5766... | 0.76693374 | 0 |
Tests whether ``.ChannelMetadataGuildMainBase.__hash__`` works as intended. | def test__ChannelMetadataGuildMainBase__hash():
parent_id = 202209180092
name = 'Armelyrics'
permission_overwrites = [
PermissionOverwrite(202209180093, target_type = PermissionOverwriteTargetType.user)
]
position = 7
channel_metadata = ChannelMetadataGuildMainBase(
parent_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__ChannelMetadataGuildMainBase__eq():\n parent_id = 202209170024\n name = 'Armelyrics'\n permission_overwrites = [\n PermissionOverwrite(202209170026, target_type = PermissionOverwriteTargetType.user)\n ]\n position = 7\n \n keyword_parameters = {\n 'parent_id': parent_id... | [
"0.65775454",
"0.579368",
"0.5793323",
"0.57697403",
"0.5759067",
"0.5738554",
"0.573797",
"0.56774026",
"0.5600858",
"0.5559058",
"0.54417163",
"0.54274994",
"0.5406413",
"0.5403103",
"0.54013276",
"0.5387093",
"0.5383725",
"0.53765965",
"0.53626907",
"0.53563243",
"0.534347... | 0.8193522 | 0 |
Tests whether ``.ChannelMetadataGuildMainBase.__eq__`` works as intended. | def test__ChannelMetadataGuildMainBase__eq():
parent_id = 202209170024
name = 'Armelyrics'
permission_overwrites = [
PermissionOverwrite(202209170026, target_type = PermissionOverwriteTargetType.user)
]
position = 7
keyword_parameters = {
'parent_id': parent_id,
'nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not isinstance(other, WrappedChannel):\n return False\n\n return self.__dict__ == other.__dict__",
"def __eq__(self, other):\n return isinstance(other, type(self)) and set(self.channels) == set(other.channels)",
"def __eq__(self, other: object) -> b... | [
"0.67958033",
"0.65078115",
"0.6484208",
"0.64335704",
"0.6409005",
"0.6355463",
"0.63350314",
"0.6317273",
"0.63166475",
"0.6309817",
"0.6308102",
"0.6306244",
"0.6306244",
"0.6259636",
"0.62531966",
"0.62531966",
"0.62531966",
"0.62531966",
"0.62531966",
"0.62531966",
"0.62... | 0.7348498 | 0 |
Download image from Teams URL using bearer token authorization. | def download_image(url):
request = urllib.request.Request(url, headers={'Authorization': 'Bearer %s' % BOT_TOKEN})
return urllib.request.urlopen(request).read() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_image(url):\n request = urllib.request.Request(\n url, headers={'Authorization': 'Bearer %s' % ACCESS_TOKEN})\n return urllib.request.urlopen(request).read()",
"def get_and_download(api, path, num_tweets=25, profile=\"@hakeemangulu\", admin=False):\n return downloader(get_media(api, ... | [
"0.66527647",
"0.5842607",
"0.5763162",
"0.5761907",
"0.5759188",
"0.57159966",
"0.56891954",
"0.56524795",
"0.563557",
"0.55984384",
"0.55846506",
"0.55733687",
"0.55444",
"0.5537157",
"0.55189043",
"0.54777074",
"0.5452126",
"0.5417165",
"0.5414698",
"0.54130983",
"0.541075... | 0.67777026 | 0 |
Checks image for hotdog label using Amazon Rekoginition's object and scene detection deep learning feature. | def detect_hotdog(image_bytes):
try:
response = rekognition.detect_labels(
Image={
'Bytes': image_bytes,
},
MinConfidence=80.0
)
except Exception as e:
print(e)
print('Unable to detect labels for image.')
raise (e)
l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_detect(filename):\n cv2.ocl.setUseOpenCL(False)\n just_fname = filename.split(\".\")[0]\n image = cv2.imread('./static/uploads/' + filename)\n bbox, label, conf = cv.detect_common_objects(image)\n output_image = draw_bbox(image, bbox, label, conf)\n plt.imshow(output_image)\n plt.sa... | [
"0.6815965",
"0.6388998",
"0.62926686",
"0.6109619",
"0.60816616",
"0.6068272",
"0.60642225",
"0.60371107",
"0.6023844",
"0.59734666",
"0.5958151",
"0.5948561",
"0.59281087",
"0.59219706",
"0.59202826",
"0.5912994",
"0.5887489",
"0.5874421",
"0.58728534",
"0.58576244",
"0.585... | 0.7475597 | 0 |
Logs the message. The message msg is either sent to stdout (self.fileObject is None) or to the file being logged to. Newlines will be added. msg The message to be logged. alwaysPrint Set to True to make sure this message is printed to the screen as well as being logged. | def log(self, msg, alwaysPrint = False):
if self.fileObject is None or alwaysPrint:
print msg
if self.fileObject:
self.fileObject.write( msg + '\n' ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logPre(self, msg, alwaysPrint = False):\n if self.fileObject is None or alwaysPrint:\n print msg,\n if self.fileObject:\n self.fileObject.write( msg )",
"def logIt(self, msg):\n\n if (self.logger): self.logger.logIt(msg)",
"def log_message(self, msg):\n\t\tself.lo... | [
"0.7481471",
"0.64299273",
"0.6390704",
"0.63432825",
"0.63176066",
"0.6261319",
"0.6247798",
"0.62087893",
"0.6201373",
"0.6190925",
"0.61468685",
"0.61368734",
"0.61362296",
"0.61275",
"0.60671586",
"0.6040165",
"0.603992",
"0.6020699",
"0.6012883",
"0.6004764",
"0.59970385... | 0.8293799 | 0 |
Redirects all logging to pathname. pathname should either point to an existing file, which will be appended, or to a nonexisting file that can readily be created. Any current log file will be closed first. pathname The pathname to the file to be logged to | def logToFile(self, pathname):
self.closeLogFile()
if os.path.exists( pathname ) and not os.path.isfile( pathname ):
raise Exception( 'Logging to "{0}" requested, but that already exists and is not a file' )
self.fileObject = open( pathname, 'a', 0 ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _log_to_file(path: str) -> None:\n if path:\n fh = logging.FileHandler(path)\n LOGGER.addHandler(fh)\n LOGGER.setLevel(logging.DEBUG)",
"def open_log(fn):\n\n global log_file\n if fn is not None:\n d = os.path.dirname(fn)\n if d != \"\":\n makedirs(d)\n ... | [
"0.6153083",
"0.60771054",
"0.60501206",
"0.6025648",
"0.5913558",
"0.5886134",
"0.5834929",
"0.5816463",
"0.57577384",
"0.5727059",
"0.57122064",
"0.5704558",
"0.56727153",
"0.5666995",
"0.5648114",
"0.56377965",
"0.56313026",
"0.5620631",
"0.561821",
"0.56134355",
"0.560660... | 0.6878759 | 0 |
Return whether this logger uses a file to log to. True iff a file is being used for logging. | def loggingToFile(self):
return not self.fileObject is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isfile(self):\n return os.path.isfile(self.path)",
"def log_file_exist(self, file_path_name):\n return os.path.isfile(file_path_name)",
"def is_file(self):\n return self.type == \"file\"",
"def _is_file_handler(settings):\n FILE_HANDLERS = [\n \"logging.FileHandler\",\n ... | [
"0.66220945",
"0.65056753",
"0.648707",
"0.64642686",
"0.64354444",
"0.6371633",
"0.6187837",
"0.6144524",
"0.59624916",
"0.5959991",
"0.59356755",
"0.5912241",
"0.5899414",
"0.5841109",
"0.58348304",
"0.58128124",
"0.5811184",
"0.58088493",
"0.5752997",
"0.5746541",
"0.57385... | 0.7469764 | 0 |
Logs the stacktrace of the exception currently being handled. This method should be called from a function currently handling an exception (e.g. in an except block). When no exception is currently being handled, this function does nothing. alwaysPrint Set to True to make sure this message is printed to the screen as we... | def exceptionTraceback(self, alwaysPrint = False):
self.logPre( traceback.format_exc(), alwaysPrint ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def localTraceback(self, alwaysPrint = False):\n self.log( \"DEBUG TRACEBACK: \" )\n for line in traceback.format_stack():\n self.logPre( line, alwaysPrint )",
"async def log_exception(self, message=None):\n\t\tsio = io.StringIO()\n\t\tei = sys.exc_info()\n\t\ttb = ei[2]\n\t\ttraceback.p... | [
"0.64758444",
"0.64472836",
"0.64472836",
"0.61547214",
"0.60838157",
"0.6066748",
"0.6052786",
"0.6018367",
"0.5996901",
"0.59638894",
"0.59539455",
"0.5811691",
"0.57380384",
"0.5685566",
"0.5648089",
"0.5607695",
"0.560029",
"0.560029",
"0.55809206",
"0.55809206",
"0.55809... | 0.77035034 | 0 |
Logs the stacktrace of the current stack (including this call). This method can be called from a function to have the current calling stack logged. Note that this is for debugging purposes only! alwaysPrint Set to True to make sure this message is printed to the screen as well as being logged. | def localTraceback(self, alwaysPrint = False):
self.log( "DEBUG TRACEBACK: " )
for line in traceback.format_stack():
self.logPre( line, alwaysPrint ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exceptionTraceback(self, alwaysPrint = False):\n self.logPre( traceback.format_exc(), alwaysPrint )",
"def log_stack(self, msg):\n\n log(('%s\\n' % msg) + ''.join(traceback.format_list(traceback.extract_stack())))",
"def _print_caller(self):\n import traceback\n print '\\n'.join... | [
"0.7285145",
"0.6926994",
"0.61892635",
"0.5901458",
"0.5856414",
"0.5749565",
"0.57326317",
"0.5687477",
"0.56301194",
"0.5614361",
"0.5603308",
"0.5578548",
"0.55525094",
"0.55500674",
"0.5446957",
"0.5428992",
"0.539396",
"0.53612536",
"0.53575635",
"0.53441447",
"0.533394... | 0.7547841 | 0 |
Connects a new ssh session by saying 'yes' and sendiung the given password | def connect_new_ssh(child, password):
child.sendline('yes');
index = child.expect('password: ');
if index == 0:
child.sendline(password); | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login (self,server,username,password='',terminal_type='ansi',original_prompts=r\"][#$]|~[#$]|bash.*?[#$]|[#$] \",login_timeout=10):\r\n cmd = \"ssh -l %s %s\" % (username, server)\r\n spawn.__init__(self, cmd, timeout=login_timeout)\r\n #, \"(?i)no route to host\"])\r\n i = self.exp... | [
"0.7439972",
"0.7188687",
"0.6969624",
"0.67180043",
"0.6709069",
"0.6635398",
"0.6626326",
"0.6603639",
"0.6516925",
"0.65073144",
"0.64584094",
"0.6439802",
"0.64304763",
"0.6392565",
"0.63836884",
"0.62622535",
"0.62182623",
"0.6183599",
"0.61229265",
"0.60288405",
"0.6014... | 0.8266417 | 0 |
This method will attempt to claim said job and must either succeed at this or throw an exception signaling the job can not be claimed. | def claim(self, job, owner):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def claim(self, owner):\n if self.state != states.UNCLAIMED:\n raise exc.UnclaimableJobException(\"Unable to claim job when job is\"\n \" in state %s\" % (self.state))\n self._claimer.claim(self, owner)\n self._change_state(states.CLAIMED... | [
"0.76414406",
"0.67809224",
"0.6134024",
"0.5882024",
"0.5874933",
"0.58676803",
"0.57816905",
"0.56745833",
"0.5598242",
"0.5561825",
"0.53933036",
"0.5389527",
"0.5332717",
"0.53009933",
"0.5297069",
"0.5290039",
"0.51477283",
"0.5136083",
"0.51340944",
"0.51257825",
"0.510... | 0.8065353 | 0 |
This method will attempt to unclaim said job and must either succeed at this or throw an exception signaling the job can not be unclaimed. | def unclaim(self, job, owner):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def claim(self, owner):\n if self.state != states.UNCLAIMED:\n raise exc.UnclaimableJobException(\"Unable to claim job when job is\"\n \" in state %s\" % (self.state))\n self._claimer.claim(self, owner)\n self._change_state(states.CLAIMED... | [
"0.7144576",
"0.6916502",
"0.68314725",
"0.6746362",
"0.62216836",
"0.6034372",
"0.60341364",
"0.59205747",
"0.5916772",
"0.5783544",
"0.5773681",
"0.5739483",
"0.5690523",
"0.56651515",
"0.56566554",
"0.563167",
"0.56230766",
"0.5615409",
"0.5609779",
"0.56095695",
"0.560661... | 0.85306275 | 0 |
Fetches (or creates) a logbook entry for this job. | def logbook(self):
if self._logbook is None:
self._logbook = self._catalog.create_or_fetch(self)
return self._logbook | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logbook_get(lb_id):\n return IMPL.logbook_get(lb_id)",
"def view(\n id: int = typer.Argument(\n ...,\n help=\"ID of the log entry\"\n )\n):\n manager = LogBookManager()\n log_entry = manager.get(id)\n\n if log_entry:\n log_entry_id = (\n typer.style(\"Log Ent... | [
"0.6216041",
"0.57733",
"0.57405645",
"0.5534309",
"0.55128986",
"0.534162",
"0.530705",
"0.51450557",
"0.5049179",
"0.5026933",
"0.49238828",
"0.48906502",
"0.48839775",
"0.47756025",
"0.47715536",
"0.4752835",
"0.47512",
"0.47397467",
"0.47066182",
"0.46868423",
"0.46636644... | 0.6401991 | 0 |
This can be used to attempt transition this job from unclaimed to claimed. This must be done in a way that likely uses some type of locking or ownership transfer so that only a single entity gets this job to work on. This will avoid multijob ownership, which can lead to inconsistent state. | def claim(self, owner):
if self.state != states.UNCLAIMED:
raise exc.UnclaimableJobException("Unable to claim job when job is"
" in state %s" % (self.state))
self._claimer.claim(self, owner)
self._change_state(states.CLAIMED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unclaim(self, job, owner):\n raise NotImplementedError()",
"def claim(self, job, owner):\n raise NotImplementedError()",
"def rescheduleJob(self, job):\n with self:\n with self.queues.jobsInProgress:\n with self.queues.jobsDone:\n try:\n ... | [
"0.6953937",
"0.6791486",
"0.6007257",
"0.5879965",
"0.5821883",
"0.5744671",
"0.57140595",
"0.5693909",
"0.56915385",
"0.56846416",
"0.56846416",
"0.56846416",
"0.56693417",
"0.55960375",
"0.5566806",
"0.5513871",
"0.54651546",
"0.54282546",
"0.54273343",
"0.53935",
"0.53616... | 0.7047054 | 0 |
Read a .TXT transcript file. | def txtread(path):
try:
with open(path) as fp:
for line in fp:
line = line.rstrip().split()
ns, ne, tr = line[0], line[1], ' '.join(line[2:])
transcrpt = (int(ns), int(ne)), tr
return transcrpt
except FileNotFoundError:
print(f"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_transcript(transcript_id):\n with open(transcript_path_for_id(transcript_id)) as f:\n return transcript_lines(f.read())",
"def read_text_file(file_name):\n target_file = open(file_name)\n lines = target_file.readlines()\n\n target_file.close()\n return lines",
"def read_text_from... | [
"0.71274984",
"0.6924785",
"0.6891849",
"0.67825556",
"0.6768612",
"0.67489684",
"0.6727479",
"0.6669767",
"0.664797",
"0.6642203",
"0.6609315",
"0.6589043",
"0.6584995",
"0.6572044",
"0.6509255",
"0.6509255",
"0.6505264",
"0.6498308",
"0.6487553",
"0.6487553",
"0.64655817",
... | 0.6981559 | 1 |
Check if phone is a vowel (or a semivowel). | def isvowel(phone, semivowels=True):
if semivowels:
return (phone in VOWELS) or (phone in SEMIVOWELS)
return phone in VOWELS | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_vowel(text):\n return text.lower() in AVRO_VOWELS",
"def isPhoneme(s):\n return consonants.isConsonant(s) or vowels.isVowel(s)",
"def is_english_vowel(c):\n # y was included in the vowel set guided by the tests.\n return c in 'aeiouyAEIOUY'",
"def is_vowel(self, letter):\n\n if lett... | [
"0.7472139",
"0.7154466",
"0.70389456",
"0.6986931",
"0.6895742",
"0.680776",
"0.67973226",
"0.67703915",
"0.6630324",
"0.6324958",
"0.6321199",
"0.63142735",
"0.62478244",
"0.6177304",
"0.6078382",
"0.6067396",
"0.6034992",
"0.60303396",
"0.5824293",
"0.5819991",
"0.57330203... | 0.86211634 | 0 |
Check if phone belongs to speech. | def isspeech(phone):
return phone not in OTHERS | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_phone(self):\n return self.name in PHONES",
"def is_incall_playing_dialtone(self) -> bool:",
"def is_playing_dialtone(self) -> bool:",
"def detect_dialtone(self) -> bool:",
"def mic_input():\n try:\n r = sr.Recognizer()\n with sr.Microphone() as source:\n print('Sa... | [
"0.6835281",
"0.6628591",
"0.6294731",
"0.60989076",
"0.59054154",
"0.5757151",
"0.57546085",
"0.5599729",
"0.55810046",
"0.555558",
"0.5546492",
"0.55409366",
"0.5536385",
"0.5521236",
"0.55035865",
"0.5494424",
"0.5486132",
"0.54670894",
"0.5463372",
"0.5463372",
"0.5450083... | 0.67275316 | 1 |
Randomly select a portion of the signal from a sample. | def randselwave(sample, minlen=0, maxlen=None, nosilence=True):
if nosilence:
sig = rmsilence(sample)
else:
sig = sample.signal
sigsize = len(sig)
minoffset = int(minlen * sample.samplerate)
maxoffset = min(int(maxlen*sample.samplerate),
sigsize) if maxlen else s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsample(self, dataset):\n sample_idx = np.random.choice(\n dataset.shape[0], self.sample_size, replace=True)\n sample = dataset[sample_idx,...]\n return sample",
"def sample(self):\n sampleIndices = self.random_state.choice(len(self.X), int(len(self.X)*self.sample_ratio), replace=Fal... | [
"0.6753682",
"0.67438567",
"0.6645368",
"0.6637358",
"0.6594934",
"0.6586979",
"0.655377",
"0.6504",
"0.64871544",
"0.64796585",
"0.6454959",
"0.64449865",
"0.63901305",
"0.63615024",
"0.6347122",
"0.6318081",
"0.6316673",
"0.6282516",
"0.62710613",
"0.6258306",
"0.6257897",
... | 0.72517556 | 0 |
Randomly select the waveform corresponding to a single phone. Keyword Parameters | def randselphon(sample, phonfunc=None):
(ns, ne), ph = sample.phonemeseq[randrange(len(sample.phonemeseq))]
if phonfunc is not None:
while not phonfunc(ph):
(ns, ne), ph = sample.phonemeseq[randrange(len(sample.phonemeseq))]
return sample.signal[ns:ne], ph | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _choose_sample(self):\n\n \t #periodically generate a new reconstruction for the purposes of sampling",
"def randselwave(sample, minlen=0, maxlen=None, nosilence=True):\n if nosilence:\n sig = rmsilence(sample)\n else:\n sig = sample.signal\n\n sigsize = len(sig)\n minoffset = ... | [
"0.6049319",
"0.58599114",
"0.58513093",
"0.58379704",
"0.58343107",
"0.58243644",
"0.57338905",
"0.56680685",
"0.5655739",
"0.5619119",
"0.55863297",
"0.55530244",
"0.5552638",
"0.5540733",
"0.5537465",
"0.55231094",
"0.550721",
"0.54878664",
"0.5435418",
"0.54345113",
"0.54... | 0.6906114 | 0 |
Raise _MaxRunTimeReachedError if time is up. | def __checkTimer(self):
if self.__endTime is None:
raise AssertionError('The end time had not been set.')
if time.time() > self.__endTime:
self._logError('Maximum Run Time Reached !!')
raise _MaxRunTimeReachedError('') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_out_of_time(self):\n self.out_of_time = True",
"def test_max_runtime_exceeded(self):\n cost_func = make_cost_function(minimizers=self.minimizers,\n max_runtime=0.1)\n cost_func.jacobian = Scipy(cost_func.problem)\n cost_func.jacobian.metho... | [
"0.72005606",
"0.6255671",
"0.61671",
"0.60331285",
"0.5950295",
"0.59485376",
"0.5947827",
"0.5940547",
"0.5926055",
"0.5918372",
"0.59089047",
"0.5899146",
"0.5877961",
"0.58729166",
"0.58500904",
"0.58278584",
"0.578191",
"0.5777835",
"0.57642645",
"0.5727944",
"0.5688749"... | 0.7875635 | 0 |
Find sorted oids for prices in the price/price_hst table (determined by the given prcTypInfo) with the given instrument, list of parties, and before_date. | def __prcTyp_queryDateSortedPriceOidList(self, prcTypInfo, insOidList,
ptyOidList=(), strLastDelDate=''):
assert isinstance(prcTypInfo, FDelPriceUtil.PRICE_TYPE_INFO)
qry = ('SELECT prinbr FROM {0} WHERE insaddr IN ({1})'.format(
prcTypInfo.tblName,
','.join([... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __prcTyp_findOidSortedCandidateExpPrcInsOidList(self, prcTypInfo,\n lastTradeIsoDate):\n assert isinstance(prcTypInfo, FDelPriceUtil.PRICE_TYPE_INFO)\n # All instrument oid in the trade table.\n tradeFilter = ''\n if lastTradeIsoDate:\n tradeFilter += (\n ... | [
"0.6085557",
"0.5769451",
"0.51371557",
"0.51347435",
"0.4766373",
"0.4712271",
"0.45802504",
"0.45615697",
"0.45568717",
"0.4519873",
"0.44904566",
"0.44891077",
"0.44539687",
"0.43901536",
"0.4369921",
"0.43696314",
"0.43638957",
"0.43556637",
"0.43386802",
"0.43296987",
"0... | 0.6089002 | 0 |
Return selected mtm markets' oid list. | def __findSelectedMtMMarketOidList(self, specifiedMtMMktNameList):
acmMtMMktList = []
if specifiedMtMMktNameList:
for mtmMktName in specifiedMtMMktNameList:
acmMtMMkt = acm.FMTMMarket[mtmMktName]
if not acmMtMMkt:
self._logError('Unable to ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_markets(self):\n return self.__call__('markets', 'getmarkets')",
"def get_markets(self):\n self.logger.debug(\"Fetching markets.\")\n return self._api_query(\"markets\")['markets']",
"async def get_markets(self):\n uri = \"/v3/markets\"\n success, error = await self.r... | [
"0.6599541",
"0.63440347",
"0.61981744",
"0.6056395",
"0.59153104",
"0.59133285",
"0.5877993",
"0.5846515",
"0.5576189",
"0.55007863",
"0.5432618",
"0.54104376",
"0.529633",
"0.5286762",
"0.5272523",
"0.5260489",
"0.5253744",
"0.52524257",
"0.51953787",
"0.51843894",
"0.51490... | 0.7038202 | 0 |
Return selected markets' and brokers' oid list. | def __findSelectedMarketAndBrokerOidList(self, specifiedMktBkrNameList):
acmMktBkrList = []
if specifiedMktBkrNameList:
for ptyName in specifiedMktBkrNameList:
acmPty = acm.FParty[ptyName]
if acmPty and acmPty.Type() not in ('Market', 'Broker'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_markets(self):\n return self.__call__('markets', 'getmarkets')",
"def get_markets(self):\n self.logger.debug(\"Fetching markets.\")\n return self._api_query(\"markets\")['markets']",
"async def fetch_markets(self, params={}):\n response = await self.publicGetInstrumentActive... | [
"0.63485444",
"0.59877753",
"0.58995676",
"0.5840833",
"0.5784675",
"0.57759666",
"0.5706607",
"0.5702184",
"0.5648349",
"0.5632348",
"0.56303495",
"0.55439466",
"0.54782355",
"0.5372974",
"0.5361976",
"0.5361384",
"0.53522825",
"0.5343561",
"0.5342",
"0.5340727",
"0.5333999"... | 0.7050791 | 0 |
Find instrument oids that are in the price/price_hst table (determined by the given prcTypInfo), but not in the instrument table. Return sorted oids in a list. | def __prcTyp_queryOidSortedDeletedInsOidListOnPrices(self, prcTypInfo):
assert isinstance(prcTypInfo, FDelPriceUtil.PRICE_TYPE_INFO)
delInsOidQry = (
'SELECT p.insaddr '
'FROM (SELECT insaddr '
'FROM {0} '
'GROUP BY insaddr)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __prcTyp_findOidSortedCandidateExpPrcInsOidList(self, prcTypInfo,\n lastTradeIsoDate):\n assert isinstance(prcTypInfo, FDelPriceUtil.PRICE_TYPE_INFO)\n # All instrument oid in the trade table.\n tradeFilter = ''\n if lastTradeIsoDate:\n tradeFilter += (\n ... | [
"0.62244856",
"0.55694354",
"0.5079898",
"0.47905445",
"0.476835",
"0.46912134",
"0.46708074",
"0.4668783",
"0.46211517",
"0.46155512",
"0.46080145",
"0.4595705",
"0.45778537",
"0.4563206",
"0.4531771",
"0.45249516",
"0.45070058",
"0.44943988",
"0.4487933",
"0.44849113",
"0.4... | 0.68675864 | 0 |
Find instruments that (a) it has no trade or last trade occurred after lastTradeIsoDate, (b) it is not a generic instrument, (c) it is not a currency instrument, (d) either it is a combination instruments (which is difficult to determine whether it is expired in a SQL statement) or it is properly expired, and (e) that ... | def __prcTyp_findOidSortedCandidateExpPrcInsOidList(self, prcTypInfo,
lastTradeIsoDate):
assert isinstance(prcTypInfo, FDelPriceUtil.PRICE_TYPE_INFO)
# All instrument oid in the trade table.
tradeFilter = ''
if lastTradeIsoDate:
tradeFilter += (
' OR ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_contract_expire_soon():\n\n contract_expire_soon_list = []\n contract_expired_list = []\n\n # get user contract\n # refactoring techniques: replace temp with query\n user_role = get_user_role()\n contract_list = user_role.user_contracts\n\n for contract in contract_list:\n if ... | [
"0.57924205",
"0.5275997",
"0.5115672",
"0.50814015",
"0.50716925",
"0.49720892",
"0.493483",
"0.4912392",
"0.49118668",
"0.49106112",
"0.4893823",
"0.4886736",
"0.4885335",
"0.48443907",
"0.48328522",
"0.4806988",
"0.48046705",
"0.4796385",
"0.47606522",
"0.47523996",
"0.473... | 0.5764446 | 1 |
Compute mean and standard deviation (diagonal) of a data source batchwise. This means not all the dataset needs to be loaded into memory. | def stats_batchwise(data_source, batch_size=1024):
mean = np.zeros(data_source.dshape, dtype=np.float32)
mean_xs = np.zeros_like(mean, dtype=np.float32)
for x, _ in iterate_batches(data_source, batch_size, expand=False):
corr_fact = float(x.shape[0]) / batch_size
mean += x.mean(axis=0) * co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_std_calc(dataloader):\n mean = 0\n std = 0\n samples = 0\n for data, _, _ in dataloader:\n batch_samples = data.size(0)\n data = data.view(batch_samples, data.size(1), -1)\n mean += data.mean(2).sum(0)\n std += data.std(2).sum(0)\n samples += batch_samples\n\... | [
"0.6821113",
"0.6628702",
"0.65133226",
"0.6366007",
"0.6278951",
"0.6270301",
"0.6215972",
"0.6030763",
"0.59692454",
"0.59538424",
"0.59309304",
"0.56303096",
"0.560768",
"0.560724",
"0.5604017",
"0.5584684",
"0.5583369",
"0.552744",
"0.55225104",
"0.5508419",
"0.54930276",... | 0.6879622 | 0 |
Compute the pointwise maximum of data from a datasource batchwise. This means not all the data needs to be loaded into memory | def max_batchwise(data_source, batch_size=1024):
max_val = np.zeros(data_source.dshape, dtype=np.float32)
for x, _ in iterate_batches(data_source, batch_size, expand=True):
max_val = np.maximum(max_val, np.abs(x).max(axis=0))
return max_val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Max(data):\n return data.max()",
"def structured_maximum(x, y):\r\n # see decorator for function body\r",
"def max(self, axis=0, **kwargs) -> \"Dataset\":\n return self.aggregate(axis=axis, func=np.max, **kwargs)",
"def max():\n valid=result_alpha.F>0\n src_data... | [
"0.6601401",
"0.63217014",
"0.6300085",
"0.617483",
"0.61721987",
"0.6156992",
"0.6123875",
"0.6102782",
"0.6100487",
"0.60941964",
"0.604619",
"0.60426134",
"0.602722",
"0.5987717",
"0.59874827",
"0.5978141",
"0.5959651",
"0.595121",
"0.59499943",
"0.5940414",
"0.59335977",
... | 0.75724 | 0 |
Load mean shift and std. dev. normalisation factor from a pickle file. | def load(self, filename):
with open(filename, 'r') as f:
self.mean, self.std_dev = pickle.load(f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self, filename):\n with open(filename, 'r') as f:\n self.components, self.mean = pickle.load(f)",
"def _load_train_data(self):\n\n self.train_loader = data.Train_loader(self.N_max, self.n_per_conn,\n self.data_path, self.device)\n ... | [
"0.65188164",
"0.5848625",
"0.58163214",
"0.581616",
"0.56548125",
"0.5613081",
"0.56126773",
"0.5608054",
"0.5567768",
"0.5567606",
"0.5557379",
"0.5532053",
"0.5509452",
"0.5494169",
"0.54905057",
"0.54856706",
"0.54688275",
"0.545438",
"0.54415166",
"0.5417773",
"0.5405180... | 0.7402011 | 0 |
Save mean shift and std. dev normalisation factor to a pickle file. | def save(self, filename):
with open(filename, 'w') as f:
pickle.dump((self.mean, self.std_dev), f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_model(self):\n\n print('Save model')\n self.feature_extractor.save_weights(\n self.path_save_model + self.name_model + '.h5')\n\n print('Mean and std')\n np.save(self.path_save_model + 'mean.npy', self.mean)\n np.save(self.path_save_model + 'std.npy', self.std... | [
"0.64140654",
"0.6384976",
"0.59466743",
"0.5914204",
"0.58881104",
"0.5825253",
"0.5825126",
"0.57261455",
"0.5723197",
"0.5697069",
"0.5670001",
"0.5650149",
"0.56400716",
"0.5631516",
"0.5614277",
"0.5604038",
"0.5603471",
"0.56029004",
"0.5567818",
"0.55583596",
"0.553112... | 0.7751082 | 0 |
Load the PCA projection parameters from a pickle file. | def load(self, filename):
with open(filename, 'r') as f:
self.pca.set_params(pickle.load(f))
self.fit = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_pca(self, filepath):\n with open(filepath, 'rb') as f:\n image_shape = np.load(f)\n mean_beam = np.load(f)\n principal_components = np.load(f)\n variances = np.load(f)\n mask = np.load(f)\n\n image_shape = tuple(image_shape)\n if ... | [
"0.64639044",
"0.6394586",
"0.635293",
"0.62758756",
"0.6137785",
"0.6121093",
"0.6079463",
"0.6065179",
"0.58844155",
"0.58518946",
"0.58202195",
"0.57627356",
"0.57607454",
"0.57473344",
"0.5689884",
"0.5680921",
"0.5674365",
"0.5656027",
"0.565067",
"0.562908",
"0.56286395... | 0.76612556 | 0 |
Save the PCA projection parameters to a pickle file. | def save(self, filename):
with open(filename, 'w') as f:
pickle.dump(self.pca.get_params(deep=True), f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_pca(self, filepath):\n mean_beam, principal_components, variances = self.pca()\n image_shape = np.array(self.image_shape)\n with open(filepath, 'wb') as f:\n np.save(f, image_shape)\n np.save(f, mean_beam)\n np.save(f, principal_components)\n ... | [
"0.7063464",
"0.6787205",
"0.66488534",
"0.65194744",
"0.6493804",
"0.6487763",
"0.64617985",
"0.6402068",
"0.62957084",
"0.62605053",
"0.62286663",
"0.6218375",
"0.6202347",
"0.6182708",
"0.61716354",
"0.6157764",
"0.6139115",
"0.6136068",
"0.6080848",
"0.6051759",
"0.604392... | 0.7828974 | 0 |
Given a client function that supports the page_size and page_number keyword arguments for pagination, this generator will yield all results from that function. | def paginate(client_fun, *args, **kwargs):
resp = client_fun(*args, **kwargs)
yield from resp['content']
total_elements = resp['totalElements']
page_size = resp['pageSize']
page_number = resp['pageNumber'] + 1
if 'page_number' in kwargs:
kwargs.pop('page_number')
while page_number * ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _all_pages(self, page_function, **kwargs) -> Iterator[Iterable]:\n\n next_token = None\n is_truncated = True\n while is_truncated:\n page = page_function(token=next_token, **kwargs)\n next_token = page.next_token\n is_truncated = page.is_truncated and next_... | [
"0.7188018",
"0.69058317",
"0.6851234",
"0.6520223",
"0.63227797",
"0.63111836",
"0.62681013",
"0.62586796",
"0.62197423",
"0.62168384",
"0.61602914",
"0.61417675",
"0.6127266",
"0.6088125",
"0.60534865",
"0.5998772",
"0.5971633",
"0.5949552",
"0.5939511",
"0.5933702",
"0.593... | 0.8052127 | 0 |
Formats the output of the response object into the specified format option | def format_output(response, response_format):
if response is not None:
has_printed_columns = False
# Check if the response has model obects
if contains_model_object(response):
response_type = get_response_type(response)
if response_type in column_settings.keys() and r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format(self, response):\n\n res = self._prepare_response(response)\n res.content = self._format_data(res.content, self.charset)\n return self._finalize_response(res)",
"def set_ResponseFormat(self, value):\n super(RetrieveUserDashboardInputSet, self)._set_input('ResponseFormat', v... | [
"0.75064385",
"0.67827934",
"0.6723205",
"0.6642738",
"0.66102195",
"0.6448729",
"0.6381562",
"0.63723475",
"0.6364777",
"0.63310057",
"0.6313266",
"0.6238251",
"0.61908245",
"0.61612916",
"0.6139935",
"0.6137706",
"0.60989606",
"0.60519433",
"0.6040138",
"0.6033145",
"0.6000... | 0.72821623 | 1 |
Show info for tags supplied on stdin. | def show_tags(config, args):
for item in lib.input_json_lines():
yield config.repo.tag(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(ctk, tagger, input):\n # Print a message to the user.\n if input:\n click.echo(tag(tagger, input))\n else:\n # Print usage message to the user.\n click.echo(ctk.get_help())",
"def tags():",
"def tag_cmd(context, json, name):\n store: Store = context.obj[\"store\"]\n ... | [
"0.6387081",
"0.6217433",
"0.5608079",
"0.5607176",
"0.5510677",
"0.5477076",
"0.5473736",
"0.54259425",
"0.54130965",
"0.53941745",
"0.5379633",
"0.53514874",
"0.5342375",
"0.53388333",
"0.53354925",
"0.53149426",
"0.5268948",
"0.5259609",
"0.52451235",
"0.51976585",
"0.5166... | 0.6902614 | 0 |
Show branches supplied on stdin. | def show_branches(config, args):
for item in lib.input_json_lines():
yield config.repo.branch(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch(self, current_path):\n p = subprocess.Popen(\n [\"git\", \"show-ref\"],\n stdout=PIPE,\n stderr=PIPE,\n cwd=os.path.join(self.root_dir, current_path),\n )\n output, error = p.communicate()\n if p.returncode == 0:\n result... | [
"0.6132162",
"0.6097642",
"0.60437906",
"0.6039253",
"0.60184383",
"0.6002146",
"0.58533615",
"0.5677618",
"0.5652464",
"0.5618362",
"0.55661905",
"0.54910105",
"0.5488487",
"0.5475893",
"0.54488194",
"0.54205436",
"0.5359306",
"0.532281",
"0.531495",
"0.53007525",
"0.5299715... | 0.75820833 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.