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 |
|---|---|---|---|---|---|---|
Computes the elementwise minimum of some matrices. | def sim_min(sim_mats):
return np.array(sim_mats).min(axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix_min(data):\n if is_SparseDataFrame(data):\n data = [np.min(data[col]) for col in data.columns]\n elif is_sparse_dataframe(data):\n data = [sparse_series_min(data[col]) for col in data.columns]\n elif isinstance(data, pd.DataFrame):\n data = np.min(data)\n elif isinstance... | [
"0.6745464",
"0.6651574",
"0.6647899",
"0.64386827",
"0.6284703",
"0.6036429",
"0.6033137",
"0.5970848",
"0.5958427",
"0.5948367",
"0.5947503",
"0.59440386",
"0.59381294",
"0.5921218",
"0.59118783",
"0.5897402",
"0.5858605",
"0.5849506",
"0.58406216",
"0.5815177",
"0.5813334"... | 0.7239349 | 0 |
Computes the elementwise maximum of some matrices. | def sim_max(sim_mats):
return np.array(sim_mats).max(axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def three_array_max(array_list: List[np.ndarray]) -> np.ndarray:\n temp = np.maximum(array_list[0], array_list[1])\n all_maxs = np.maximum(temp, array_list[2])\n\n return all_maxs",
"def d_max(x, y):\n axis = np.argmax(x.shape)\n return np.max(np.array([x, y]), axis=axis)",
"def max(x, reduce_in... | [
"0.6566944",
"0.6431522",
"0.63984",
"0.6369676",
"0.6349694",
"0.6326043",
"0.6279134",
"0.6229197",
"0.6208424",
"0.61817044",
"0.61411893",
"0.60957426",
"0.60940033",
"0.6092088",
"0.60329014",
"0.6031537",
"0.60274714",
"0.6022276",
"0.60205376",
"0.6020099",
"0.5998723"... | 0.69111717 | 0 |
Takes in an Image message and identifies the locations of the three dumbbells | def identify_dbs(image):
locations = {"red": Point(), "green": Point(), "blue": Point()}
masks = {"red": [], "green": [], "blue": []}
bridge = cv_bridge.CvBridge()
image = bridge.imgmsg_to_cv2(image, "bgr8")
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
# upper and lower bounds for red
# us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def belt(image):\n\n # Belt Detector\n x, y = circular_detector(image, 70, 80)\n\n return x, y",
"def describe(image):\n needle = cv2.imread(image, 0)\n orb = cv2.ORB()\n keypoints, description = orb.detectAndCompute(needle, None)\n print(keypoints)\n print(description)\n return keypoints, descrip... | [
"0.5904444",
"0.58341223",
"0.5803662",
"0.5694714",
"0.564857",
"0.5638822",
"0.5634845",
"0.5602222",
"0.55758303",
"0.5494642",
"0.5491051",
"0.548308",
"0.5441922",
"0.5413018",
"0.54116",
"0.5403581",
"0.5379999",
"0.53695244",
"0.53540814",
"0.5338005",
"0.53375745",
... | 0.6506251 | 0 |
Takes in a list of Image messages and identifies the block number in each image | def identify_blocks(images):
locations = {1: Point(), 2: Point(), 3: Point()}
blocks = {"left": 0, "middle": 0, "right": 0}
pipeline = keras_ocr.pipeline.Pipeline()
cv2_images = []
for image in images:
bridge = cv_bridge.CvBridge()
cv2_images.append(bridge.imgmsg_to_cv2(image, "bgr8... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBlocks(self):\n blocks = self.getBlocksMsg(b'\\x00')\n last_locator = self.largeMessageControl(blocks, 'inv', 0)\n\n while last_locator[1] < TARGET_BLOCK:\n blocks = self.getBlocksMsg(bytearray.fromhex(convertLittleBig(last_locator[0])))\n last_locator = self.large... | [
"0.5884302",
"0.5805182",
"0.5722689",
"0.5625986",
"0.5602621",
"0.55785567",
"0.5520678",
"0.5473761",
"0.5423533",
"0.53958166",
"0.5387366",
"0.53733194",
"0.537314",
"0.5340807",
"0.5339228",
"0.5338712",
"0.533123",
"0.53037155",
"0.5302177",
"0.52923036",
"0.5285601",
... | 0.6633512 | 0 |
Return inputted mouse position. | def get_mouse_pos(self):
return self.mouse_pos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mouse_position(self):\n raise NotImplementedError",
"def mousePos():\n data = display.Display().screen().root.query_pointer()._data\n return data[\"root_x\"], data[\"root_y\"]",
"def read_current_mouse_position():\n import pyautogui\n pyautogui.FAILSAFE = False\n return pyautogui.... | [
"0.80970645",
"0.79738057",
"0.7952894",
"0.7875623",
"0.7716459",
"0.7669065",
"0.7658517",
"0.7630226",
"0.7630226",
"0.74635327",
"0.7459193",
"0.73358524",
"0.7272576",
"0.7244995",
"0.71246344",
"0.70662653",
"0.70661056",
"0.7031796",
"0.69420946",
"0.6930538",
"0.69280... | 0.8032351 | 1 |
Initialize type and button. | def __init__(self, event_type, button):
self.type = event_type
self.button = button | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.handlers = {}\n self.start_state = None\n self.end_states = []\n self.btn = Button()",
"def _init_ui(self):\r\n\t\t\r\n\t\tself.input_frame = Input(self)\r\n\t\tself.input_frame.pack()\r\n\t\t\r\n\t\tbutton_ok = Button(self, text = \"Ping\", command = self._... | [
"0.6788451",
"0.6683954",
"0.65892327",
"0.6497996",
"0.64862543",
"0.6442674",
"0.6437974",
"0.64198774",
"0.64093477",
"0.63769287",
"0.63739365",
"0.63739365",
"0.6325634",
"0.6292619",
"0.6286793",
"0.62425756",
"0.62415385",
"0.6241002",
"0.6228872",
"0.619486",
"0.61938... | 0.7603971 | 0 |
get final coach for each session coach with more than half the season will be the credited coach for eventual playoff and championship won | def get_final_coach_for_each_season(self):
self.final_coach_for_season = (
self.num_days_coach_for_season
.groupby(['Season','TeamID'])
.agg({"CoachName":"count"})
.reset_index()
.rename(columns={"CoachName":"coach_counts"})
.merge(self.num... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_championship_won_for_each_coach(self):\n self.championship_team = (\n self.raw_data_postseason\n .merge(self.season_max_days,how='left',on=['Season'])\n .query(\"DayNum == season_max_days\")\n .groupby(['Season','WTeamID'])\n .agg({\"NumOT\":\"c... | [
"0.69078004",
"0.66235226",
"0.65739715",
"0.64645517",
"0.54283714",
"0.53823304",
"0.5381159",
"0.5307479",
"0.5282068",
"0.52351725",
"0.51759636",
"0.51322395",
"0.5129283",
"0.50992453",
"0.5090998",
"0.5084592",
"0.5073128",
"0.5072545",
"0.5070027",
"0.50515336",
"0.50... | 0.757074 | 0 |
Get teams who won the championship for each year | def get_championship_won_for_each_coach(self):
self.championship_team = (
self.raw_data_postseason
.merge(self.season_max_days,how='left',on=['Season'])
.query("DayNum == season_max_days")
.groupby(['Season','WTeamID'])
.agg({"NumOT":"count"})
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_player_games(self, year, use_local=True):",
"def collect_teams(year):\n\n team_list = Team.objects.filter(year=year).order_by('location')\n teams = []\n for t in team_list:\n team = {\n 'id': t.abbreviation,\n 'team': t,\n }\n teams.append(team)\n re... | [
"0.70646495",
"0.67921704",
"0.6662633",
"0.6608853",
"0.6473593",
"0.6421649",
"0.6351773",
"0.6312248",
"0.6311487",
"0.63097686",
"0.6242666",
"0.6128153",
"0.6068329",
"0.6029508",
"0.6004093",
"0.59811854",
"0.5938113",
"0.593734",
"0.5913684",
"0.5901109",
"0.58794063",... | 0.6963645 | 1 |
Get win rate for regular season for each coach | def get_win_rate_regular_season_for_each_coach(self):
self.games_won_for_coaches = (
self.raw_data_regularseason
[['Season','DayNum','WTeamID']]
# merge for winning team
.merge(self.num_days_coach_for_season[['Season','TeamID','FirstDayNum','LastDayNum','CoachName... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_win_rate_post_season_for_each_coach(self):\n # get winning games for coaches\n self.post_games_won_for_coaches = (\n self.raw_data_postseason\n [['Season','DayNum','WTeamID']]\n # merge for winning team\n .merge(self.num_days_coach_for_season[['Seas... | [
"0.7728886",
"0.6802758",
"0.66279066",
"0.6522059",
"0.64248955",
"0.6424082",
"0.6392534",
"0.62645185",
"0.6220719",
"0.6031486",
"0.6006317",
"0.5837831",
"0.5770262",
"0.57343024",
"0.57129455",
"0.5707701",
"0.56960624",
"0.5694389",
"0.56909186",
"0.56840575",
"0.56737... | 0.8015784 | 0 |
Get win rate for post season for each coach | def get_win_rate_post_season_for_each_coach(self):
# get winning games for coaches
self.post_games_won_for_coaches = (
self.raw_data_postseason
[['Season','DayNum','WTeamID']]
# merge for winning team
.merge(self.num_days_coach_for_season[['Season','TeamID... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_win_rate_regular_season_for_each_coach(self):\n self.games_won_for_coaches = (\n self.raw_data_regularseason\n [['Season','DayNum','WTeamID']]\n # merge for winning team\n .merge(self.num_days_coach_for_season[['Season','TeamID','FirstDayNum','LastDayNum',... | [
"0.7711851",
"0.6832915",
"0.6480246",
"0.63182116",
"0.6245573",
"0.61112136",
"0.611068",
"0.602987",
"0.59854066",
"0.5965334",
"0.5964837",
"0.57526016",
"0.57137907",
"0.5671769",
"0.5644969",
"0.5635259",
"0.56290424",
"0.5599348",
"0.5596914",
"0.5574907",
"0.5569233",... | 0.8241553 | 0 |
Test that upload Logger Type file without microsite_id will not be inserted to database | def test_logger_type_upload_MicrositeId_None(self):
test_filename = 'server/tests/test_data_files/Test/Test_New_Logger_Type_MicrositeId_None.csv'
with self.app.test_client() as client:
with client.session_transaction() as sess:
sess['logged_in'] = True
response = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upload_wrong_file_type(self):\n file = dict(\n file=(BytesIO(b'my file contents'), \"foto.doc\"),\n )\n response = self.client.post('/upload',\n content_type='multipart/form-data',\n data=file)\n s... | [
"0.676866",
"0.66889274",
"0.65706724",
"0.64305943",
"0.640982",
"0.639273",
"0.6387645",
"0.63190717",
"0.62991345",
"0.6276941",
"0.62692577",
"0.62305576",
"0.6219944",
"0.6209555",
"0.6150867",
"0.61412674",
"0.6103418",
"0.6050772",
"0.602671",
"0.6003001",
"0.5965992",... | 0.81712246 | 0 |
Test that Logger Temperature file with duplicate entry cannot be uploaded | def test_logger_temperature_upload_duplicate(self):
test_type_filename = 'server/tests/test_data_files/Test/Test_New_Logger_Type_Positive.csv'
test_temp_filename = 'server/tests/test_data_files/Test/temp_files/DUMMYID_2000_pgsql_Duplicate.txt'
with self.app.test_client() as client:
w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upload_duplicate(client: FlaskClient):\n file = get_example_file(ExampleFileType.Png)\n response1 = util.upload_file(client, DEFAULT_USER, file)\n response2 = util.upload_file(client, DEFAULT_USER, file)\n\n assert response1.status == \"201 CREATED\"\n assert response2.status == \"200 OK\"\... | [
"0.67010015",
"0.638992",
"0.6376859",
"0.6261966",
"0.624463",
"0.62304544",
"0.62001187",
"0.6198904",
"0.6182989",
"0.61653274",
"0.6137007",
"0.6109847",
"0.6075311",
"0.60572684",
"0.6047644",
"0.60395145",
"0.60256505",
"0.6012684",
"0.5980237",
"0.595728",
"0.5917336",... | 0.7041636 | 0 |
Computes the value of an entry by running its task. Requires that all the task's dependencies are already computed. | def compute(self, context):
# TODO There are a few cases here where we acccess private members on
# self.state; should we clean this up?
state = self.state
task = state.task
protocol = state.desc_metadata.protocol
assert state.is_initialized
assert not state.is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute(self, task_key_logger):\n\n task = self.task\n\n dep_results = [\n dep_state.get_results_assuming_complete(task_key_logger)[\n dep_key.dnode.to_entity_name()\n ]\n for dep_state, dep_key in zip(self.dep_states, task.dep_keys)\n ]\n\n... | [
"0.63904375",
"0.59485996",
"0.57995343",
"0.5572648",
"0.5520435",
"0.55173826",
"0.54368013",
"0.53980225",
"0.53946394",
"0.53903",
"0.53770065",
"0.5371793",
"0.53237903",
"0.53095233",
"0.52732223",
"0.5251898",
"0.52199835",
"0.52119595",
"0.5201217",
"0.51943415",
"0.5... | 0.7053696 | 0 |
Indicates whether the task state's result is cached. | def is_cached(self):
if self.should_persist:
# If our value is persistable, it can be saved either on disk or in memory,
# but only the former counts as being officially "cached".
return self._result_value_hash is not None
else:
return self._result is not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_cached(self):\n return False",
"def is_cached(name, typ=\"pkl\"):\n return os.path.exists(cache_name(name, typ))",
"def _may_cache(self, request, response=None):\n # any successful request may be cached\n return ((HTTPStatus.OK <= response.status_code < HTTPStatus.BAD_REQUEST)\n ... | [
"0.74749434",
"0.68324715",
"0.68149173",
"0.6738329",
"0.6655201",
"0.66187906",
"0.65679663",
"0.6416865",
"0.6415875",
"0.6382452",
"0.6292968",
"0.62685287",
"0.62240446",
"0.6211946",
"0.6159335",
"0.61113095",
"0.60873556",
"0.60792947",
"0.6072414",
"0.6051632",
"0.604... | 0.79039913 | 0 |
Loads the hash of the persisted value for this task, if it exists. If the persisted value is available in the cache, this object's `is_cached` property will become True. Otherwise, nothing will happen. | def attempt_to_access_persistent_cached_value(self):
assert self.is_initialized
assert not self.is_cached
if not self.should_persist:
return
if not self._cache_accessor.can_load():
return
self._load_value_hash() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_value_hash(self):\n\n artifact = self._cache_accessor.load_artifact()\n if artifact is None or artifact.content_hash is None:\n raise AssertionError(\n oneline(\n f\"\"\"\n Failed to load cached value (hash) for descriptor\n ... | [
"0.72252256",
"0.63859934",
"0.5972734",
"0.5886148",
"0.5879905",
"0.5804419",
"0.574814",
"0.5677867",
"0.5613093",
"0.5568389",
"0.5543914",
"0.54435587",
"0.54258996",
"0.5423656",
"0.5395598",
"0.53953743",
"0.5376388",
"0.53689486",
"0.53612226",
"0.53522384",
"0.535086... | 0.71849906 | 1 |
Refreshes all state that depends on the persistent cache. This is useful if the external cache state might have changed since we last worked with this task. | def refresh_all_persistent_cache_state(self, context):
# If this task state is not initialized or not persisted, there's nothing to
# refresh.
if not self.is_initialized or not self.should_persist:
return
self.refresh_cache_accessor(context)
# If we haven't loaded ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flush_local_cache(self):\n self._local_cache = {}",
"def reload_cache(self):\n self.data = self.read_data_cache()",
"def flush_cache(self):\n if self.cache_modified:\n self.cache_manager.write(self.cache_file, self.cache)",
"def sync_after_remote_computation(self):\n\n ... | [
"0.6510259",
"0.63184017",
"0.6079995",
"0.6077812",
"0.60450286",
"0.5920667",
"0.5860059",
"0.58537775",
"0.5784254",
"0.5776172",
"0.5739506",
"0.57234544",
"0.5665114",
"0.56476337",
"0.564716",
"0.56465435",
"0.5620647",
"0.5612728",
"0.55823725",
"0.5579131",
"0.5574888... | 0.75692886 | 0 |
Checks for any versioning errors i.e., any cases where a task's function code was updated but its version annotation was not. | def _check_accessor_for_version_problems(self):
old_prov = self._cache_accessor.load_provenance()
if old_prov is None:
return
new_prov = self._cache_accessor.provenance
if old_prov.exactly_matches(new_prov):
return
if old_prov.nominally_matches(new_prov... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_missing_versioned_tags(module):\n version_table = getattr(module, '__version_table__', {})\n\n # Get all functions from the module.\n functions = inspect.getmembers(module, inspect.isfunction)\n functions_dict = dict(functions)\n function_names = list(functions_dict)\n\n # Get all c... | [
"0.69742507",
"0.61686295",
"0.6032363",
"0.59617966",
"0.58357054",
"0.5830695",
"0.5827717",
"0.5817524",
"0.58131546",
"0.5808405",
"0.58020407",
"0.57866913",
"0.57857144",
"0.57734126",
"0.57588166",
"0.56948197",
"0.5692589",
"0.56653947",
"0.56652933",
"0.56586355",
"0... | 0.6633973 | 1 |
Reads (from disk or cloud) and saves (in memory) this task's value hash. | def _load_value_hash(self):
artifact = self._cache_accessor.load_artifact()
if artifact is None or artifact.content_hash is None:
raise AssertionError(
oneline(
f"""
Failed to load cached value (hash) for descriptor
{self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_digest(self, task: \"TaskView\") -> dict:\n # XXX user definition should be able to exclude inputs from digest\n # XXX might throw AttributeError\n inputs = task._resolved_inputs # type: ignore\n\n # sensitive values are always redacted so no point in including them in the dig... | [
"0.61814857",
"0.5982808",
"0.5848447",
"0.5757408",
"0.5693065",
"0.5498911",
"0.54744655",
"0.5450672",
"0.5423203",
"0.54196274",
"0.5387745",
"0.53874344",
"0.53849286",
"0.5367149",
"0.5363407",
"0.53323734",
"0.5316272",
"0.52829957",
"0.52800924",
"0.5279477",
"0.52739... | 0.65436584 | 0 |
Returns copies of the provided TaskStates with any unnecessary state and ancestors "stripped" off; these copies can be safely transmitted to another process for computation. | def strip_states(self, states):
stripped_states_by_task_key = {}
def strip_state(original_state):
"""Returns a stripped copy of a TaskState."""
task_key = original_state.task_key
if task_key in stripped_states_by_task_key:
return stripped_states_by_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_state(original_state):\n\n task_key = original_state.task_key\n if task_key in stripped_states_by_task_key:\n return stripped_states_by_task_key[task_key]\n\n assert original_state in self.all_states\n assert original_state not in self.non_serial... | [
"0.7007315",
"0.6059291",
"0.57722616",
"0.5648813",
"0.54974157",
"0.54269755",
"0.53582656",
"0.53353125",
"0.52991706",
"0.52278084",
"0.5219097",
"0.5181115",
"0.5153454",
"0.5147667",
"0.5111569",
"0.51057416",
"0.5078182",
"0.5068822",
"0.5066051",
"0.49776638",
"0.4975... | 0.84246093 | 0 |
Returns a stripped copy of a TaskState. | def strip_state(original_state):
task_key = original_state.task_key
if task_key in stripped_states_by_task_key:
return stripped_states_by_task_key[task_key]
assert original_state in self.all_states
assert original_state not in self.non_serializable_state... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_states(self, states):\n\n stripped_states_by_task_key = {}\n\n def strip_state(original_state):\n \"\"\"Returns a stripped copy of a TaskState.\"\"\"\n\n task_key = original_state.task_key\n if task_key in stripped_states_by_task_key:\n return... | [
"0.74558896",
"0.59286696",
"0.5859667",
"0.5805591",
"0.57871336",
"0.5779528",
"0.5778583",
"0.5769516",
"0.5739012",
"0.57232314",
"0.56408906",
"0.5633798",
"0.5573608",
"0.55289465",
"0.5504658",
"0.5491149",
"0.547416",
"0.5440028",
"0.5384897",
"0.5383192",
"0.5378312"... | 0.7607578 | 0 |
View to return all information needed to display the cart, by converting what has been saved to the session into key variables. Protection in place in case a product, size or nic has been deleted while still in the cart, removing from the list before saving back to the cart session variable. | def cart_contents(request):
cart_items = []
total = 0
savings = 0
product_count = 0
points_available = 0
points_earned = 0
discount_applied = request.session.get('discount_applied')
cart = request.session.get('cart', {})
# Create a new dict so that items can be removed if needed
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detail(request):\n # del request.session['cart_id']\n # del request.session['total_in_cart']\n data = {}\n if (cart_id := request.session.get('cart_id', None)):\n cart = Cart.objects.get(pk=cart_id)\n data['products_in_cart'] = cart.cartitems.all()\n data['total_price'] = cart.... | [
"0.74897677",
"0.70164984",
"0.6997387",
"0.68789303",
"0.68103784",
"0.6678317",
"0.66267216",
"0.6622569",
"0.66087735",
"0.6606675",
"0.6523773",
"0.6521631",
"0.6521631",
"0.647599",
"0.647599",
"0.647599",
"0.64378947",
"0.6432149",
"0.63870263",
"0.63262737",
"0.6304301... | 0.76600933 | 0 |
Outputs magnetic field given lat, lon, alt. | def magnetic_field(date: datetime.datetime, lat, lon, alt, output_format='cartesian'):
g = GeoMag()
return g.GeoMag(np.array([lat, lon, alt]), date, location_format='geodetic', output_format=output_format) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magnetization(h):\n if h.has_eh: raise\n if h.has_spin: \n mx = extract.mx(h.intra)\n my = extract.my(h.intra)\n mz = extract.mz(h.intra)\n else: raise\n np.savetxt(\"MAGNETIZATION_X.OUT\",np.matrix([h.geometry.x,h.geometry.y,mx]).T)\n np.savetxt(\"MAGNETIZATION_Y.OUT\",np.matrix([h.geometry.x,h.... | [
"0.6234416",
"0.6036381",
"0.56869453",
"0.5671633",
"0.5600399",
"0.55292517",
"0.55019677",
"0.544296",
"0.53621125",
"0.5302858",
"0.5279656",
"0.51781017",
"0.50963485",
"0.5032904",
"0.500878",
"0.49855933",
"0.49819586",
"0.49788126",
"0.49635312",
"0.49299306",
"0.4889... | 0.79384327 | 0 |
Calculate a checksum for num using the Luhn algorithm. | def luhn_checksum(num: str) -> str:
check = 0
for i, s in enumerate(reversed(num)):
sx = int(s)
if i % 2 == 0:
sx *= 2
if sx > 9:
sx -= 9
check += sx
return str(check * 9 % 10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checksum(n):\n\n # Compute the sum of the non-check digits.\n s = sum(luhn_digits(n * 10))\n\n # Multiply by 9.\n result = s * 9\n\n # The units digit is the check digit\n check_digit = result % 10\n\n m = int(str(n) + str(check_digit))\n assert(verify(m))\n\n return check_digit",
... | [
"0.8084448",
"0.80643237",
"0.78999513",
"0.7894059",
"0.7728619",
"0.75503194",
"0.7511611",
"0.7499676",
"0.74020904",
"0.71649796",
"0.7110696",
"0.6942625",
"0.6888765",
"0.68604416",
"0.6764696",
"0.6605598",
"0.65903616",
"0.6547519",
"0.64829504",
"0.64828515",
"0.6453... | 0.84606624 | 0 |
Romanize a given string. | def romanize(string: str, locale: t.Union[Locale, str]) -> str:
locale = validate_locale(locale)
if locale not in (Locale.RU, Locale.UK, Locale.KK):
raise ValueError(f"Romanization is not available for: {locale}")
table = _get_translation_table(locale)
return string.translate(table) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fromRoman(s):\n pass",
"def toRoman(n):\n pass",
"def romanify(num):\n result = \"\"\n return result",
"def fromRoman(s):\n if not s:\n raise InvalidRomanNumeralError, 'Input can not be blank'\n if not romanNumeralPattern.search(s):\n raise InvalidRomanNumeralError, 'Invalid R... | [
"0.7063574",
"0.689551",
"0.6734362",
"0.64427215",
"0.63702637",
"0.6330791",
"0.6323522",
"0.6299757",
"0.6215566",
"0.6198708",
"0.61629105",
"0.61244214",
"0.6120783",
"0.61043954",
"0.60932904",
"0.60877186",
"0.6060893",
"0.5971338",
"0.5948232",
"0.5926629",
"0.5908616... | 0.7607582 | 0 |
Configure the logging system. If a logpath is provided, entries will also be written to that logfile. | def configure_logger(logpath, loglevel=logging.DEBUG):
handlers = [logging.StreamHandler()]
if logpath:
handlers.append(logging.FileHandler(logpath))
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(name)s - %(message)s',
datefmt='%d-%m-%y %H:%M:%S', level=loglevel, handlers=han... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _configure_logging(self):\n self.log_level = Scaffold.LOG_LEVEL_MAP.get(self.log_level, ERROR)\n formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')\n\n # assign the windmill instance logger\n #logging.basicConfig()\n self.log = logging.getLo... | [
"0.7340265",
"0.7313647",
"0.7286824",
"0.724973",
"0.7248175",
"0.7177587",
"0.7139101",
"0.70546126",
"0.70544195",
"0.7049995",
"0.70458865",
"0.70351976",
"0.70171684",
"0.70139897",
"0.7012062",
"0.7011974",
"0.69839966",
"0.69708276",
"0.69193125",
"0.68887985",
"0.6874... | 0.8009328 | 0 |
Connect two nodes with a channel. Connects node a to node b using the given channel. | def connect(self, channel, a, b):
a.sender.channels.append(channel)
channel.receivers.append(b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connectChannel(sock, chan):\n sock.send(\"JOIN {}\\r\\n\".format(chan).encode(\"utf-8\"))\n\n console.info(\"Successfully connected to {}\".format(chan))",
"def connect(self, node1, node2):\n self.neighbour1 = node1\n self.neighbour2 = node2",
"def connect_two_nodes(left_node: Node, rig... | [
"0.60193217",
"0.58925235",
"0.5827985",
"0.57909036",
"0.57899636",
"0.56818223",
"0.56715274",
"0.5666792",
"0.56497663",
"0.56090224",
"0.5600908",
"0.55008054",
"0.54504013",
"0.5447329",
"0.54283625",
"0.5424262",
"0.54172355",
"0.53959185",
"0.5352588",
"0.53389084",
"0... | 0.73055255 | 0 |
crawl objct and return the result | def crawl_start(crawl_obj):
res = None
if crawl_obj.type in ['user', 'song'] :
res = eval('crawl_' + crawl_obj.type)(crawl_obj)
elif crawl_obj.type in ['artist', 'album'] :
web_data = requests.get(crawl_obj.url, headers = cheat_headers)
soup = bs4.BeautifulSoup(web_data.text, '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _scrape(self):",
"def scrape(self):\n pass",
"def crawl(self, url):\n return None",
"def scrape(self):\n try:\n self.result = urlfetch.fetch(self.url)\n except DownloadError:\n self.result = urlfetch.fetch(self.url) \n if ((self.result.status_code == 200) and\n (s... | [
"0.71161443",
"0.66178185",
"0.6551923",
"0.60435236",
"0.6042226",
"0.6040767",
"0.59387845",
"0.5858021",
"0.5807145",
"0.58034575",
"0.5781588",
"0.5735748",
"0.5689979",
"0.568243",
"0.56674963",
"0.5655977",
"0.56543124",
"0.5643372",
"0.56385326",
"0.5625415",
"0.562377... | 0.6746438 | 1 |
iterates over points on the board | def points_generator(self):
rows, cols = self.game.board.board_size
points = [Point(i, j) for i, j in product(range(rows), range(cols))]
for point in points:
yield point | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_points(self):\n for x in range(self.left, self.right + 1):\n for y in range(self.top, self.bottom + 1):\n yield Point(x, y)",
"def grid_points(self):\n for i in range(self.rows):\n for j in range(self.cols):\n min_lat,max_lat,min_lon,max_... | [
"0.72778916",
"0.68592465",
"0.6857867",
"0.6820964",
"0.663074",
"0.6541899",
"0.64622074",
"0.6450496",
"0.6430873",
"0.6379434",
"0.6351412",
"0.6338828",
"0.62530154",
"0.6235255",
"0.622739",
"0.6218105",
"0.6214263",
"0.6176402",
"0.61315227",
"0.61090213",
"0.60718495"... | 0.6902485 | 1 |
Returns the minimum value of a and b ignoring any negative values. | def _get_min_positive_value(self, a, b):
if a < 0 and b >= 0:
return b
if a >= 0 and b < 0:
return a
return min(a, b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mini(a, b):\n return min(a, b)",
"def _null_min(a, b):\n if a is None:\n return b\n if b is None:\n return a\n return min(a, b)",
"def minimum_inplace(a, b):",
"def minimum(lhs, rhs):\n return _make.minimum(lhs, rhs)",
"def smallest_diff(a, b):\n b.sort()\n smallest_diff = None\n\n... | [
"0.79426205",
"0.7518428",
"0.7121123",
"0.702984",
"0.6997932",
"0.69437057",
"0.68694836",
"0.68295264",
"0.6827028",
"0.6682797",
"0.66441596",
"0.6604545",
"0.6468406",
"0.64508706",
"0.64410925",
"0.64327365",
"0.63909256",
"0.6367581",
"0.6353903",
"0.63516575",
"0.6350... | 0.8785171 | 0 |
Retrieves all flashcards in ascending order (max 250 at a time) or using basic pagination returns `qty` flashcards occuring after `start`. | def retrieve_all_flashcards(start: int=0, qty:int=None):
qty = 250 if qty == None else qty
with sqlite3.connect(current_app.config['DB']) as db:
c = db.cursor()
c.execute("""
SELECT
id,
title,
description,
source,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cards(query_param):\n return _query_scryfall(query_param)",
"def get_all(self, start_at, limit, order=None):",
"def get_cards(shop, redas=None, skip=0, limit=40):\n connection = pymongo.MongoClient(MONGO_URL)\n db = connection[DB]\n\n selector = {'shops.' + shop: {'$exists': 1}}\n if red... | [
"0.5929701",
"0.56348145",
"0.5483227",
"0.52740085",
"0.5245021",
"0.5158718",
"0.51479316",
"0.5110173",
"0.5082926",
"0.5076762",
"0.5074356",
"0.5069807",
"0.50454044",
"0.5042",
"0.50204206",
"0.5005391",
"0.50021154",
"0.50005645",
"0.49998033",
"0.4996675",
"0.49888542... | 0.822305 | 0 |
rightpad a string with zeros to the given length | def _rzfill(string, to_len):
if len(string) > to_len:
raise ValueError("string is already longer than to_len")
return string + '0' * (to_len - len(string)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def r_pad(arg, length):\n if length <= len(arg):\n return arg\n else:\n return arg + \" \" * (length - len(arg))",
"def rightpad(field, length):\r\n field = str(field)\r\n field_length = len(field)\r\n if field_length>length:\r\n field = field[:length]\r\n if field_length<l... | [
"0.8048082",
"0.8042724",
"0.8026424",
"0.78363734",
"0.78341615",
"0.76930463",
"0.7581309",
"0.74894637",
"0.73814124",
"0.7381266",
"0.7312482",
"0.7301371",
"0.72033757",
"0.71582454",
"0.7100653",
"0.70349735",
"0.7018298",
"0.70045847",
"0.6971008",
"0.6954787",
"0.6918... | 0.8118524 | 0 |
Tries to detect a pluggedin YubiKey else alerts user | def detect_yubikey(self):
try:
self.yk = yubico.find_yubikey()
self.version.set("Version:%s" % self.yk.version())
self.serial.set("Serial:%s" % self.yk.serial())
except yubico.yubikey.YubiKeyError:
self.version.set("No YubiKey detected")
self.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_infrared():\n try:\n count = 0\n while True:\n if GPIO.input(PIN_NO) == True:\n count += 1\n print('[+] Detected ' + str(count))\n output_sound()\n send_message()\n time.sleep(2)\n except Exception ... | [
"0.5550443",
"0.54399776",
"0.5384098",
"0.5384029",
"0.535033",
"0.5321742",
"0.5321742",
"0.527354",
"0.5258836",
"0.52223456",
"0.5207884",
"0.5207635",
"0.5153576",
"0.5151934",
"0.5151934",
"0.5151934",
"0.5151934",
"0.5151934",
"0.5151934",
"0.5151934",
"0.5151934",
"... | 0.7784908 | 0 |
Display the Entry text value. | def displayText(self):
if self.entryWidget.get().strip() == "":
tkMessageBox.showerror("Tkinter Entry Widget", "Enter a text value")
else:
self.file_com.write(self.entryWidget.get().strip()+'\n') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_entry(text):\n print \"Text entered: \\n '%s'\" % text",
"def value (self):\r\n return self.entry.get()",
"def display_entry(self, entry):\n border = '-' * 50\n print(border)\n print('Employee: {}'.format(entry.employee_name))\n print('Task Name: {}'.format(entry.... | [
"0.6926207",
"0.6598252",
"0.6590535",
"0.65623057",
"0.6552865",
"0.6468197",
"0.64450836",
"0.64450836",
"0.64450836",
"0.64450836",
"0.64450836",
"0.6352432",
"0.6344944",
"0.6339035",
"0.6331184",
"0.6292854",
"0.62803704",
"0.6258875",
"0.62545305",
"0.62507486",
"0.6148... | 0.76484877 | 0 |
Create and configure connexion app. | def create_app(env):
connexion_app = connexion.App(__name__, specification_dir='openapi/',
options={'swagger_url': '/swagger'})
app = connexion_app.app
env_config_class_map = {
'prod': 'config.Prod',
'testing': 'config.Testing',
'dev': 'config.Dev'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_app(self):\r\n self.app = Flask(__name__, instance_relative_config=True)\r\n\r\n # Init the secret key of the app -it is a must for flask to run\r\n self.app.config.from_mapping(\r\n SECRET_KEY='!ZNeverSayNever116Z!',\r\n MONGODB_SETTINGS= {'host': 'mongodb://l... | [
"0.74086744",
"0.71356195",
"0.71240467",
"0.7108809",
"0.7074317",
"0.7031925",
"0.70253813",
"0.7023434",
"0.7022537",
"0.7013904",
"0.70036703",
"0.69989914",
"0.69644254",
"0.6951114",
"0.69442946",
"0.693363",
"0.6925931",
"0.6923495",
"0.6898156",
"0.68892235",
"0.68874... | 0.7772478 | 0 |
Adds the commit to the commits array if it doesn't already exist, and returns the commit's index in the array. | def add_commit(self, commit):
sha1 = commit.hex
if sha1 in self._commits:
return self._commits[sha1]
title, separator, body = commit.message.partition("\n")
commit = {
'explored': False,
'sha1': sha1,
'name': GitUtils.abbreviate_sha1(sha1),... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_commit(self, commit_id):\n commit = next((\n commit for commit in self.repo.iter_commits()\n if commit.hexsha == commit_id\n ), None)\n if commit is None:\n raise Exception(f'Commit {commit_id} not found!')\n return commit",
"def commit_id(self... | [
"0.6170759",
"0.593805",
"0.5836253",
"0.56688523",
"0.5563604",
"0.5461908",
"0.5457891",
"0.5429918",
"0.5420427",
"0.5400795",
"0.5369754",
"0.5346436",
"0.5341644",
"0.532622",
"0.53205234",
"0.5295877",
"0.5276312",
"0.52377796",
"0.5224023",
"0.52174157",
"0.5216296",
... | 0.64689815 | 0 |
Uniquely abbreviates the given SHA1. | def abbreviate_sha1(cls, sha1):
# For now we invoke git-rev-parse(1), but hopefully eventually
# we will be able to do this via pygit2.
cmd = ['git', 'rev-parse', '--short', sha1]
# cls.logger.debug(" ".join(cmd))
out = subprocess.check_output(cmd).strip()
# cls.logger.d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uniquely_shorten(string, length):\n\n if len(string) <= length and not (len(string) == length and\n string.startswith(SHORTENED_PREFIX)):\n return string\n\n h = hashlib.sha256()\n h.update(\"%s \" % length)\n h.update(string)\n hash_text = h.hexdigest... | [
"0.6464314",
"0.6410942",
"0.6409734",
"0.6156034",
"0.6136031",
"0.60622424",
"0.6015629",
"0.58965665",
"0.58919525",
"0.58904374",
"0.58792883",
"0.5815525",
"0.5790694",
"0.5786428",
"0.5748069",
"0.5668363",
"0.5649841",
"0.5627461",
"0.56117934",
"0.5600008",
"0.5596956... | 0.7369677 | 0 |
Returns all refs pointing to the given SHA1. | def refs_to(cls, sha1, repo):
matching = []
for refname in repo.listall_references():
symref = repo.lookup_reference(refname)
dref = symref.resolve()
oid = dref.target
commit = repo.get(oid)
if commit.hex == sha1:
matching.appen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_refs(self, for_push: bool) -> List[Tuple[str, str]]:\n try:\n loc = posixpath.join(self._path, \"refs\")\n res = self._connection.files_list_folder(loc, recursive=True)\n files = res.entries\n while res.has_more:\n res = self._connection.fil... | [
"0.62746805",
"0.6179788",
"0.6128106",
"0.5900156",
"0.5898155",
"0.5856927",
"0.57434326",
"0.57430595",
"0.56420195",
"0.5639147",
"0.55719423",
"0.55558074",
"0.5515448",
"0.5467317",
"0.5440578",
"0.5412632",
"0.5385987",
"0.5375013",
"0.5368968",
"0.53635335",
"0.535599... | 0.7806024 | 0 |
Find all dependencies of the given revision, recursively traversing the dependency tree if requested. | def find_dependencies(self, dependent_rev, recurse=None):
if recurse is None:
recurse = self.options.recurse
try:
dependent = self.get_commit(dependent_rev)
except InvalidCommitish as e:
abort(e.message())
self.todo.append(dependent)
self.tod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dependencies(self, revision: Dict) -> List[Dict]:\n dependency_ids = revision['auxiliary']['phabricator:depends-on']\n revisions = self.get_revisions(phids=dependency_ids)\n result = []\n for r in revisions:\n result.append(r)\n sub = self.get_dependencies(... | [
"0.73712236",
"0.6699492",
"0.6546439",
"0.6005795",
"0.5999744",
"0.55470836",
"0.55263996",
"0.54850143",
"0.54307467",
"0.5410811",
"0.5379994",
"0.5371398",
"0.53526044",
"0.5317734",
"0.529328",
"0.5279827",
"0.5243155",
"0.52289486",
"0.5216687",
"0.5189272",
"0.5168941... | 0.67338073 | 1 |
Find all dependencies of the given revision caused by the given parent commit. This will be called multiple times for merge commits which have multiple parents. | def find_dependencies_with_parent(self, dependent, parent):
self.logger.debug(" Finding dependencies of %s via parent %s" %
(dependent.hex[:8], parent.hex[:8]))
diff = self.repo.diff(parent, dependent,
context_lines=self.options.context_lines)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dependencies(self, revision: Dict) -> List[Dict]:\n dependency_ids = revision['auxiliary']['phabricator:depends-on']\n revisions = self.get_revisions(phids=dependency_ids)\n result = []\n for r in revisions:\n result.append(r)\n sub = self.get_dependencies(... | [
"0.65092677",
"0.6238572",
"0.6223792",
"0.5911293",
"0.5791384",
"0.56604487",
"0.56449336",
"0.5590153",
"0.55886996",
"0.5547283",
"0.55453926",
"0.5428988",
"0.53039974",
"0.5298665",
"0.52890277",
"0.5216612",
"0.51291275",
"0.51100653",
"0.510938",
"0.5103599",
"0.50664... | 0.6811225 | 0 |
Run git blame on the parts of the hunk which exist in the older commit in the diff. The commits generated by git blame are the commits which the newer commit in the diff depends on, because without the lines from those commits, the hunk would not apply correctly. | def blame_hunk(self, dependent, parent, path, hunk):
first_line_num = hunk.old_start
line_range_before = "-%d,%d" % (hunk.old_start, hunk.old_lines)
line_range_after = "+%d,%d" % (hunk.new_start, hunk.new_lines)
self.logger.debug(" Blaming hunk %s @ %s" %
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_blame(blameoutput):\n lines = blameoutput.split('\\n')\n i = 0\n commits = {}\n\n while i < len(lines):\n # Read a commit line and parse it.\n line = lines[i]\n i += 1\n if not line.strip():\n continue\n commitline = line.split()\n commithash = commitline[0]\n lineno_then = ... | [
"0.6053283",
"0.6032853",
"0.57691056",
"0.5739654",
"0.5558605",
"0.54753315",
"0.54249126",
"0.53682005",
"0.5311587",
"0.52980185",
"0.5267507",
"0.52285916",
"0.5224669",
"0.5176965",
"0.5174912",
"0.51497334",
"0.51410127",
"0.5134518",
"0.5132892",
"0.5132451",
"0.51252... | 0.7433148 | 0 |
Navigate to the tree or blob object pointed to by the given target path for the given commit. This is necessary because each git tree only contains entries for the directory it refers to, not recursively for all subdirectories. | def tree_lookup(self, target_path, commit):
segments = target_path.split("/")
tree_or_blob = commit.tree
path = ''
while segments:
dirent = segments.pop(0)
if isinstance(tree_or_blob, pygit2.Tree):
if dirent in tree_or_blob:
tre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traverse_tree(tree, thisFolder, path, submission):\n\n # Get files directly underneath this folder.\n blobs = tree.blobs\n thisFolderName = tree.name\n\n # Add this folder to the path.\n path = os.path.join(path, thisFolderName)\n print(path)\n\n for blob in blobs:\n filepath = os.p... | [
"0.5894933",
"0.55579513",
"0.5489392",
"0.52907765",
"0.528364",
"0.5157724",
"0.5122504",
"0.51111794",
"0.50728655",
"0.4995954",
"0.49644312",
"0.486692",
"0.4840334",
"0.48367405",
"0.48296806",
"0.4813238",
"0.47609875",
"0.47581476",
"0.472949",
"0.4682747",
"0.4671142... | 0.7929258 | 0 |
Return the matrix square root of a hermitian or symmetric matrix Uses scipy.linalg.eigh() to diagonalize the input efficiently. | def sqrtmh(A, ret_evd=False, evd=None):
if not evd is None:
(ev, EV) = evd
else:
ev, EV = la.eigh(A) #uses LAPACK ***EVR
ev = sp.sqrt(ev) #we don't require positive (semi) definiteness, so we need the scipy sqrt here
#Carry out multiplication with the diagonal matrix of eigenva... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trans_hellinger(m):\n m = asmatrix(m)\n row_sums = sum(m, axis=1)\n result = sqrt(m / row_sums)\n return result",
"def _symmetric_matrix_square_root(mat, eps=1e-10):\n # Unlike numpy, tensorflow's return order is (s, u, v)\n s, u, v = linalg_ops.svd(mat)\n # sqrt is unstable around 0, just use... | [
"0.62265146",
"0.6111763",
"0.60754913",
"0.6025185",
"0.5924092",
"0.57053465",
"0.56531864",
"0.56375873",
"0.56003076",
"0.5589603",
"0.5574254",
"0.55350095",
"0.5526857",
"0.55079013",
"0.5506939",
"0.5501033",
"0.54983324",
"0.5481793",
"0.5479065",
"0.5479065",
"0.5477... | 0.66119474 | 0 |
Create a category for that party. | def create_category(party_id: PartyID, title: str) -> TourneyCategory:
party = DbParty.query.get(party_id)
if party is None:
raise ValueError('Unknown party ID "{}"'.format(party_id))
category = TourneyCategory(party.id, title)
party.tourney_categories.append(category)
db.session.commit()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_category():\n category = Category(name='testcategory', description=\"\", fee=DEFAULT_FEE)\n category.save()\n return category",
"def create_new_wallet_category(self):\n wallet_category_vals = self._build_new_wallet_category_vals()\n return self.env['wallet.category'].create(wall... | [
"0.6914065",
"0.67545795",
"0.6537486",
"0.65007126",
"0.6460365",
"0.62982243",
"0.6271935",
"0.6229216",
"0.6228962",
"0.6087871",
"0.5959873",
"0.59403336",
"0.5935428",
"0.5925022",
"0.5839894",
"0.58252794",
"0.58077806",
"0.57977724",
"0.5763211",
"0.5750037",
"0.573666... | 0.76143277 | 0 |
Move a category upwards by one position. | def move_category_up(category: TourneyCategory) -> None:
category_list = category.party.tourney_categories
if category.position == 1:
raise ValueError('Category already is at the top.')
popped_category = category_list.pop(category.position - 1)
category_list.insert(popped_category.position - 2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_category_down(category: TourneyCategory) -> None:\n category_list = category.party.tourney_categories\n\n if category.position == len(category_list):\n raise ValueError('Category already is at the bottom.')\n\n popped_category = category_list.pop(category.position - 1)\n category_list.i... | [
"0.7810339",
"0.71507776",
"0.70979744",
"0.7040622",
"0.70031214",
"0.700075",
"0.6951428",
"0.6938323",
"0.6885611",
"0.6773141",
"0.67571497",
"0.6626251",
"0.65867424",
"0.65745205",
"0.6459161",
"0.64488965",
"0.6434402",
"0.63261694",
"0.6297202",
"0.6264247",
"0.622065... | 0.8217802 | 0 |
Move a category downwards by one position. | def move_category_down(category: TourneyCategory) -> None:
category_list = category.party.tourney_categories
if category.position == len(category_list):
raise ValueError('Category already is at the bottom.')
popped_category = category_list.pop(category.position - 1)
category_list.insert(popped... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_category_up(category: TourneyCategory) -> None:\n category_list = category.party.tourney_categories\n\n if category.position == 1:\n raise ValueError('Category already is at the top.')\n\n popped_category = category_list.pop(category.position - 1)\n category_list.insert(popped_category.... | [
"0.75041527",
"0.6625059",
"0.65953684",
"0.6541835",
"0.65137774",
"0.6502901",
"0.64917004",
"0.6411511",
"0.63754165",
"0.63680816",
"0.63534594",
"0.634604",
"0.6333525",
"0.6307063",
"0.6192082",
"0.6185564",
"0.6164168",
"0.6129639",
"0.60469884",
"0.6000192",
"0.600018... | 0.80289805 | 0 |
Set up an interceptor so all grpc calls will have the apikey added on the header, in order to authenticate. | def set_interceptor(self, apikey):
self.header_interceptor = \
interceptor.header_adder_interceptor(
'lc-api-key', apikey
)
try:
self.intercept_channel = grpc.intercept_channel(
self.channel, self.header_interceptor)
except ValueError as e:
raise Exception("Attempted to connect on termninated cli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate(self, api_key):\n self.headers['x-rapidapi-key'] = api_key",
"def __init__(self, api_key):\n self._api_key = api_key\n self.headers = {\n \"hibp-api-key\": api_key,\n \"user-agent\": \"haveibeenpywned.py\",\n }\n \"\"\"Dict of additional h... | [
"0.6686443",
"0.63640404",
"0.59382933",
"0.5867886",
"0.5780181",
"0.5739476",
"0.57209116",
"0.57013947",
"0.56940454",
"0.569231",
"0.56693566",
"0.56687033",
"0.5631621",
"0.56137",
"0.5556618",
"0.55513924",
"0.5533995",
"0.5528315",
"0.55266106",
"0.5516029",
"0.5476392... | 0.79679054 | 0 |
returning all elements names from ``ImmunizationRecommendation`` according specification, with preserving original sequence order. | def elements_sequence(cls):
return [
"id",
"meta",
"implicitRules",
"language",
"text",
"contained",
"extension",
"modifierExtension",
"identifier",
"patient",
"date",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def itemnames():\n g = ['KIS_NA_39', 'VII_57', 'MX_48', 'MX_56', 'KIS_NA_42', 'VII_54',\n 'MX_S_48', 'MX_S_52', 'MX_52', 'KIS_NA_45', 'KIS_NA_51', 'MIP_45',\n 'MIP_49', 'MIP_52', 'MIP_plus_48', 'MIP_plus_51', 'MX_42', 'MX_45',\n 'MIP_G_42', 'KIS_42', 'KIS_NA_48']\n return(g)",
"def elemen... | [
"0.56782556",
"0.56028837",
"0.5595492",
"0.5593947",
"0.55300343",
"0.5521369",
"0.55187535",
"0.55180925",
"0.5463728",
"0.54546034",
"0.54065096",
"0.538096",
"0.538058",
"0.5376563",
"0.5376563",
"0.53717583",
"0.5366831",
"0.53619134",
"0.5345186",
"0.53447956",
"0.53373... | 0.56116945 | 1 |
Callback when front server is connected. | def OnFrontConnected(self) -> None:
self.gateway.write_log("行情服务器连接成功")
self.login() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_connect(self):\n print('Client connected!')",
"def on_connect():\n print(\"User connected!\")",
"def connected(self):\n manager = self.manager()\n self.log().debug(\"Register [%s] callbacks\", self.name())\n\n manager.subscribeServerCallbacks(self, self.cfg().chatimg.serve... | [
"0.7463222",
"0.69432336",
"0.686189",
"0.6838079",
"0.67208254",
"0.66620857",
"0.66216904",
"0.658405",
"0.6554587",
"0.6540486",
"0.64954203",
"0.6479373",
"0.64791733",
"0.6423165",
"0.64106476",
"0.6404848",
"0.64022064",
"0.6392826",
"0.63813555",
"0.63813555",
"0.63813... | 0.74887276 | 1 |
Factory to make list of HeadingProduct objects from a list of Product objs. Works the same way as award.awards_list.make_list() | def make_list(products):
heading_products = []
genres = set([p.genre for p in products])
for genre in genres:
this_heading_product = HeadingProduct(genre, products)
if len(this_heading_product.products):
heading_products.append(this_heading_product)
return heading_products | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_list(cls, *args):\n return _create_list(cls, *args)",
"def create_list(cls, *args):\n return _create_list(cls, *args)",
"def test_createGlossaryByList(self):\n li = []\n li.append(['term', 'tags', 'value'])\n li.append(['foo', 'a', '1'])\n li.append(['bar', ... | [
"0.56937706",
"0.56937706",
"0.561895",
"0.5307927",
"0.52138203",
"0.5196834",
"0.51320314",
"0.5119527",
"0.50780755",
"0.5066703",
"0.50650996",
"0.5048959",
"0.5017417",
"0.49839976",
"0.49739638",
"0.49701428",
"0.4967386",
"0.49507985",
"0.48988718",
"0.4894856",
"0.489... | 0.7035925 | 0 |
same approach as the to_markup_dict() method on Product | def to_markup_dict(self, markup):
ret = self.to_dict()
ret["markup"] = markup.make(self.to_dict())
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _format_product(self, product):\n formatted = {}\n variants = []\n formatted['id'] = product.get('id')\n formatted['name'] = product.get('name')\n formatted['in_stock'] = True if product.get('stock_status') == 'instock' else False\n # Variants (Includes prices here sin... | [
"0.64752793",
"0.605072",
"0.60264534",
"0.6015541",
"0.5958979",
"0.5930521",
"0.59252644",
"0.591506",
"0.5822085",
"0.5803746",
"0.58024323",
"0.5743002",
"0.57425123",
"0.57264364",
"0.57172954",
"0.5709384",
"0.5706299",
"0.5706014",
"0.5695772",
"0.5667667",
"0.5665223"... | 0.63571995 | 1 |
Calculates the number of frames o file | def __calculate_number_of_frames(self):
# Save current position
current_pos = self.__file_object.tell()
# Go to start of first frame
self.__file_object.seek(self.__first_frame_raw_data_position)
self.number_of_frames = 0
while True:
if not self.__file_object... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFileCount(self) -> int:\n ...",
"def fileCount(self):\n pass",
"def num_frames(length, fsize, fshift):\n pad = (fsize - fshift)\n if length % fshift == 0:\n M = (length + pad * 2 - fsize) // fshift + 1\n else:\n M = (length + pad * 2 - fsize) // fshift + 2\n retur... | [
"0.74542373",
"0.7406315",
"0.7370555",
"0.72805226",
"0.7188262",
"0.7104647",
"0.7006017",
"0.69780296",
"0.6961714",
"0.69169277",
"0.6900665",
"0.68425745",
"0.68258554",
"0.6812102",
"0.678976",
"0.6787598",
"0.67869854",
"0.6778575",
"0.6771477",
"0.67232835",
"0.670670... | 0.81756157 | 0 |
Interprets the header of the YUV file | def __read_header(self):
header = self.__file_object.readline()
header_string = header.decode('utf-8')
print(header_string)
# Ignore first letter
self.frame_width = int(re.findall('W\d+', header_string)[0][1:])
self.frame_height = int(re.findall('H\d+', header_string)[0][... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _decode_header(self):\n #header = self.file_content[0:6]\n log_screen_descr = self.file_content[6:13]\n self.canvas_width = log_screen_descr[0] + (log_screen_descr[1]<<8)\n self.canvas_height = log_screen_descr[2] + (log_screen_descr[3]<<8)\n # is there a global color table? ... | [
"0.7273211",
"0.6998706",
"0.6676672",
"0.66659373",
"0.66317815",
"0.6631482",
"0.65219945",
"0.65159136",
"0.64302945",
"0.6422038",
"0.6355497",
"0.6351281",
"0.6338665",
"0.63145584",
"0.6309015",
"0.6292449",
"0.629189",
"0.62856424",
"0.62795275",
"0.62275565",
"0.61913... | 0.74078685 | 0 |
Returns a buffer containing the next frame in the file | def __get_next_yuv_frame(self):
raw_frame_buffer = self.__file_object.read(self.__frame_raw_data_size)
# Ignore FRAME header
self.__file_object.readline()
return raw_frame_buffer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_frame(self):\n try:\n return self.framegen.next()\n except StopIteration:\n return None",
"def __readNext(self, f) -> bytes:\n try:\n fBuffer = f.read(Rudp.Packet.payloadMax)\n except Exception as e:\n print(\"Exception when rea... | [
"0.658763",
"0.6512409",
"0.64798796",
"0.63112426",
"0.6304167",
"0.6280922",
"0.62393665",
"0.6209724",
"0.6112247",
"0.6055701",
"0.5982976",
"0.5950312",
"0.5921946",
"0.59020406",
"0.5859815",
"0.58452123",
"0.5819238",
"0.5807083",
"0.57893544",
"0.5751586",
"0.5741709"... | 0.7203122 | 0 |
Builds a YUV frame from the 3 planes | def __concatenate_planes_to_444yuv_frame(self, y_plane, u_plane, v_plane):
np.set_printoptions(formatter={'int': hex})
y_plane.shape = (self.frame_height, self.frame_width, 1)
u_plane.shape = (self.frame_height, self.frame_width, 1)
v_plane.shape = (self.frame_height, self.frame_width, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytes_to_yuv(data, resolution):\n width, height = resolution\n fwidth, fheight = raw_resolution(resolution)\n y_len = fwidth * fheight\n uv_len = (fwidth // 2) * (fheight // 2)\n if len(data) != (y_len + 2 * uv_len):\n raise PiCameraValueError(\n 'Incorrect buffer length for re... | [
"0.6178987",
"0.6112994",
"0.60437536",
"0.60061175",
"0.5818813",
"0.5782524",
"0.5594121",
"0.5592523",
"0.55896294",
"0.5515905",
"0.54654443",
"0.54456806",
"0.5360084",
"0.5344593",
"0.5332781",
"0.5281292",
"0.52807987",
"0.5253911",
"0.5192978",
"0.51899076",
"0.517477... | 0.70961094 | 0 |
Class to train and evaluate a Base Cluster Class with Number of Clusters Specified evaluate_by = column name to use to compare across the clusters eventually | def __init__(self,
X,
n_clusters=2,
evaluate_by=None,
scaled=True,
random_state=101,
space=None,
const_params=None,
loss_fun=None):
self.evaluate_by = evaluate_by
if (... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self):\n results = dict()\n for metric in self.metrics:\n print('Evaluating clustering with metric %s' % metric)\n if metric in LABEL_METRICS.keys():\n results[metric] = LABEL_METRICS[metric](self.X, self.model.labels_)\n results['adjusted_rand... | [
"0.6347601",
"0.6259447",
"0.6242199",
"0.619887",
"0.6134004",
"0.6122757",
"0.6117709",
"0.6106118",
"0.61054987",
"0.6089926",
"0.60873955",
"0.6071255",
"0.60541445",
"0.6051448",
"0.60498863",
"0.6030983",
"0.60236627",
"0.60101587",
"0.5973187",
"0.5970434",
"0.5955364"... | 0.7258767 | 0 |
Gives the number of observations in each cluster | def cluster_obs_count(self):
return(self.merged_data.groupby(
'labels').count().transpose().iloc[0, :]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cluster_count(self) -> int:\n return len(self.get_all_cluster_ids())",
"def cluster_count(self) -> int:\n cluster_count = max(1, round(16**3 * (self.vein.purity / 100.0) / self.cluster_size))\n return self.distribution.scale_cluster_count(cluster_count)",
"def analysis_function_num... | [
"0.7697342",
"0.7521841",
"0.74846464",
"0.745221",
"0.73620665",
"0.7293663",
"0.7275436",
"0.7197757",
"0.7003787",
"0.6995928",
"0.6992263",
"0.69813204",
"0.68972546",
"0.67149794",
"0.6631092",
"0.66106117",
"0.6603212",
"0.65768135",
"0.65458935",
"0.65229785",
"0.64970... | 0.8255985 | 0 |
Provides the means of the cluster features for each cluster If evaluate_by is set, then clusters will be sorted by the mean value of the "evaluate_by" column | def cluster_means(self):
if self.evaluate_by is not None:
return(self.merged_data.groupby(
'labels').mean().sort_values(self.evaluate_by).transpose())
else:
return(self.merged_data.groupby('labels').mean().transpose()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster_means_scaled(self):\n if self.evaluate_by is not None:\n return(self.merged_scaled_data.groupby(\n 'labels').mean().sort_values(self.evaluate_by).transpose())\n else:\n return(self.merged_scaled_data.groupby(\n 'labels').mean().transpose... | [
"0.74477243",
"0.64676",
"0.630643",
"0.61944944",
"0.6128539",
"0.6070738",
"0.604014",
"0.58796227",
"0.58664966",
"0.5865818",
"0.584644",
"0.5843564",
"0.57876366",
"0.5773927",
"0.5773633",
"0.5760417",
"0.57511604",
"0.57441485",
"0.57324463",
"0.5730679",
"0.5674215",
... | 0.8206238 | 0 |
Provides the means (scaled) of the cluster features for each cluster If evaluate_by is set, then clusters will be sorted by the mean value of the "evaluate_by" column | def cluster_means_scaled(self):
if self.evaluate_by is not None:
return(self.merged_scaled_data.groupby(
'labels').mean().sort_values(self.evaluate_by).transpose())
else:
return(self.merged_scaled_data.groupby(
'labels').mean().transpose()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster_means(self):\n if self.evaluate_by is not None:\n return(self.merged_data.groupby(\n 'labels').mean().sort_values(self.evaluate_by).transpose())\n else:\n return(self.merged_data.groupby('labels').mean().transpose())",
"def _compute_cluster_averages(... | [
"0.8101285",
"0.63563937",
"0.6221742",
"0.6118103",
"0.6082124",
"0.60302347",
"0.5986253",
"0.59648865",
"0.5944979",
"0.58651084",
"0.5829008",
"0.582223",
"0.58143276",
"0.5798003",
"0.5790433",
"0.57677114",
"0.5756863",
"0.5707412",
"0.5699087",
"0.56949383",
"0.5688631... | 0.8028111 | 1 |
Concatenates all arrays with duplicated IDs. Arrays with the same ids are stacked in chronological order. Caveat This method is not guaranteed to preserve the order of the list. | def concat_duplicate_ids(self) -> None:
# Rebuilt list instead of removing duplicated one at a time at the cost of O(n).
self.data.clear()
# This implementation takes advantage of the ordering of the duplicated in the __init__ method
has_external_ids = set()
for ext_id, items i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_ids(ids):\r\n return hash_all(sorted(ids)) # We sort so that the id isn't sensitive to order.\r",
"def flat_unique(ls):\n return list(unique(chain.from_iterable(ls), key=id))",
"def remove_duplicates_array(self, array: List) -> List:\n seen = set()\n seen_add = seen.add\n ... | [
"0.6108058",
"0.6034065",
"0.56852865",
"0.5684234",
"0.5662172",
"0.5658944",
"0.5629316",
"0.5507034",
"0.5439302",
"0.54389274",
"0.5396021",
"0.53948885",
"0.53855747",
"0.538059",
"0.53791827",
"0.53729856",
"0.5346434",
"0.53187525",
"0.52948135",
"0.5288018",
"0.527519... | 0.7894388 | 0 |
Get a specific DatapointsArray from this list by id or exernal_id. | def get( # type: ignore [override]
self,
id: Optional[int] = None,
external_id: Optional[str] = None,
) -> Union[None, DatapointsArray, List[DatapointsArray]]:
# TODO: Question, can we type annotate without specifying the function?
return super().get(id, external_id) # type... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get( # type: ignore [override]\n self,\n id: Optional[int] = None,\n external_id: Optional[str] = None,\n ) -> Union[None, Datapoints, List[Datapoints]]:\n # TODO: Question, can we type annotate without specifying the function?\n return super().get(id, external_id) # typ... | [
"0.6054171",
"0.5667537",
"0.54831964",
"0.54567707",
"0.53983647",
"0.5365511",
"0.5321282",
"0.51933724",
"0.5130589",
"0.5129982",
"0.5032065",
"0.50203216",
"0.5008644",
"0.49614123",
"0.4957775",
"0.49143854",
"0.48843566",
"0.48525918",
"0.4837254",
"0.48273316",
"0.482... | 0.6824546 | 0 |
Get a specific Datapoints from this list by id or exernal_id. | def get( # type: ignore [override]
self,
id: Optional[int] = None,
external_id: Optional[str] = None,
) -> Union[None, Datapoints, List[Datapoints]]:
# TODO: Question, can we type annotate without specifying the function?
return super().get(id, external_id) # type: ignore [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get( # type: ignore [override]\n self,\n id: Optional[int] = None,\n external_id: Optional[str] = None,\n ) -> Union[None, DatapointsArray, List[DatapointsArray]]:\n # TODO: Question, can we type annotate without specifying the function?\n return super().get(id, external_... | [
"0.61743337",
"0.59749645",
"0.5939584",
"0.58991456",
"0.57974106",
"0.5651259",
"0.55687577",
"0.55102324",
"0.54533166",
"0.5403147",
"0.53751576",
"0.53591925",
"0.53410923",
"0.53159577",
"0.52451044",
"0.5237156",
"0.5236404",
"0.52126646",
"0.516919",
"0.5158489",
"0.5... | 0.6380494 | 0 |
Paillier encryption of an Int64 plaintext. Paillier homomorphic addition only directly adds positive values, however, we would like to add both positive and negative values (i.e. int64 is signed). To achieve this, we will represent negative values with twos complement representation. Also, in order to detect overflow a... | def EncryptInt64(self, plaintext, r_value=None):
if not isinstance(plaintext, int) and not isinstance(plaintext, long):
raise ValueError('Expected int or long plaintext but got: %s' %
type(plaintext))
if plaintext < MIN_INT64 or plaintext > MAX_INT64:
raise ValueError('Int64 v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _raw_mul(self, plaintext):\n if not isinstance(plaintext, int) and not isinstance(plaintext, type(mpz(1))) and not isinstance(plaintext, numpy.int64):\n raise TypeError('Expected ciphertext to be int, not %s' %\n type(plaintext))\n\n if plaintext < 0 or plaintext >= self... | [
"0.5790192",
"0.576911",
"0.56213176",
"0.54513925",
"0.5386436",
"0.53785866",
"0.5376329",
"0.5372119",
"0.5359393",
"0.53206307",
"0.5317017",
"0.53136617",
"0.5303635",
"0.5297727",
"0.52348304",
"0.52161306",
"0.51484716",
"0.51110023",
"0.508157",
"0.50726026",
"0.50640... | 0.652218 | 0 |
Paillier encryption of multiple 64 bit integers into a single payload. | def EncryptMultipleInt64s(self, numberlist, r_value=None):
plaintext = 0
number_counter = 0
if len(numberlist) > PACKING_LIMIT:
raise ValueError('The number of entries in the input list cannot be'
+ ' more than %d' % (PACKING_LIMIT))
for entry in numberlist:
if not isi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pack_uint64s(data: List[int]) -> bytes:\n result = b\"\"\n for i in data:\n result += pack_uint64(i)\n return result",
"def rop64(*args):\n\tpacked = \"\"\n\tfor x in args:\n\t\tif type(x) == int or type(x) == long:\n\t\t\tpacked += pack64(x)\n\t\telse:\n\t\t\tpacked += x\n\treturn packed",
... | [
"0.6469461",
"0.62068796",
"0.61395895",
"0.5897477",
"0.5856876",
"0.5820442",
"0.57950085",
"0.5781007",
"0.57714444",
"0.57406914",
"0.57406914",
"0.57341266",
"0.5697893",
"0.5689338",
"0.5596759",
"0.5524",
"0.5515085",
"0.5504577",
"0.5504514",
"0.5503515",
"0.54212505"... | 0.7172408 | 0 |
Paillier decryption of ciphertext into multiple int64 values. | def DecryptMultipleInt64s(self, ciphertext):
if not isinstance(ciphertext, int) and not isinstance(ciphertext, long):
raise ValueError('Expected int or long type ciphertext but got: %s' %
type(ciphertext))
plaintext = self.Decrypt(ciphertext)
decrypted_numbers = []
for unuse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DecryptInt64(self, ciphertext):\n if not isinstance(ciphertext, int) and not isinstance(ciphertext, long):\n raise ValueError('Expected int or long type ciphertext but got: %s' %\n type(ciphertext))\n plaintext = self.Decrypt(ciphertext)\n return self._Unwrap96bitTo64bit(pla... | [
"0.6999377",
"0.68856674",
"0.67466295",
"0.67262083",
"0.6428826",
"0.6360104",
"0.6349768",
"0.6308733",
"0.6303354",
"0.6211624",
"0.61085457",
"0.60960937",
"0.60612965",
"0.60026455",
"0.5953625",
"0.5937819",
"0.59188956",
"0.5888119",
"0.58588505",
"0.5841659",
"0.5826... | 0.7780901 | 0 |
Paillier decryption of ciphertext into a int64 value. | def DecryptInt64(self, ciphertext):
if not isinstance(ciphertext, int) and not isinstance(ciphertext, long):
raise ValueError('Expected int or long type ciphertext but got: %s' %
type(ciphertext))
plaintext = self.Decrypt(ciphertext)
return self._Unwrap96bitTo64bit(plaintext) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Decrypt(self, ciphertext):\n if not isinstance(ciphertext, int) and not isinstance(ciphertext, long):\n raise ValueError('Expected int or long type ciphertext but got: %s' %\n type(ciphertext))\n u = ModExp(ciphertext, self.__lambda, self.nsquare)\n l_of_u = (u - 1) // self.... | [
"0.76950616",
"0.751412",
"0.7208298",
"0.6586208",
"0.6520382",
"0.6476167",
"0.6406717",
"0.6404868",
"0.63836175",
"0.6361718",
"0.6336824",
"0.6297889",
"0.6279345",
"0.6242041",
"0.62175155",
"0.6204211",
"0.6166816",
"0.61604214",
"0.61572933",
"0.61452925",
"0.6128287"... | 0.7853171 | 0 |
Encrypt float (IEEE754 binary64bit) values with limited exponents. Paillier homomorphic addition only directly adds positive binary values, however, we would like to add both positive and negative float values | def EncryptFloat(self, plaintext, r_value=None):
if not isinstance(plaintext, float):
raise ValueError('Expected float plaintext but got: %s' % type(plaintext))
input_as_long = struct.unpack('Q', struct.pack('d', plaintext))[0]
mantissa = (input_as_long & 0xfffffffffffff) | 0x10000000000000
expon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _enc(x: int) -> float:\n return 2 + x + (29 / (x ** 2 + (1 - x) ** 2))",
"def _raw_add(self, e_a, e_b):\n return e_a * e_b % self.public_key.nsquare",
"async def test_floating_point_encoding(self, r):\n await r.flushdb()\n timestamp = 1349673917.939762\n await r.zadd('a', tim... | [
"0.5811039",
"0.57055616",
"0.5681594",
"0.5667057",
"0.55601025",
"0.5532706",
"0.5469459",
"0.5463289",
"0.54342914",
"0.5426036",
"0.53601795",
"0.5341179",
"0.5299423",
"0.52942103",
"0.52717775",
"0.5256707",
"0.52175176",
"0.5214884",
"0.5214496",
"0.51952034",
"0.51585... | 0.73143375 | 0 |
Paillier decryption of ciphertext into a IEEE754 binary64 float value. | def DecryptFloat(self, ciphertext):
original_plaintext = self.Decrypt(ciphertext)
plaintext = original_plaintext
mantissa_and_exponent = plaintext & _ONES_FLOAT_SIGN_LOW_LSB
plaintext >>= FLOAT_SIGN_LOW_LSB # >>= 831
sign_low32 = plaintext & 0xffffffff
plaintext >>= 32
sign_high32 = plainte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def EncryptFloat(self, plaintext, r_value=None):\n if not isinstance(plaintext, float):\n raise ValueError('Expected float plaintext but got: %s' % type(plaintext))\n\n input_as_long = struct.unpack('Q', struct.pack('d', plaintext))[0]\n mantissa = (input_as_long & 0xfffffffffffff) | 0x10000000000000... | [
"0.6348259",
"0.6295682",
"0.6129",
"0.60495037",
"0.6032528",
"0.6025274",
"0.5985032",
"0.5756852",
"0.5723989",
"0.5710238",
"0.5611292",
"0.5578155",
"0.55487376",
"0.55423474",
"0.5519347",
"0.5498408",
"0.54967207",
"0.5486184",
"0.54766923",
"0.5475583",
"0.54647607",
... | 0.7470246 | 0 |
Returns the number of bytes in the Bignum. | def _NumBytesBn(bn):
if not _FOUND_SSL:
raise RuntimeError('Cannot evaluate _NumBytesBn because ssl library was '
'not found')
size_in_bits = ssl.BN_num_bits(bn)
return int(math.ceil(size_in_bits / 8.0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_bytes(self) -> str:\n return pulumi.get(self, \"num_bytes\")",
"def size_bytes(self) -> int:\n return pulumi.get(self, \"size_bytes\")",
"def _get_nr_of_bits(self):\n return sum(self._size_var)",
"def lenb(self) -> int:\n return self._core.lenb()",
"def size_bytes(self):... | [
"0.76290935",
"0.7256088",
"0.7226742",
"0.7202238",
"0.69278276",
"0.69196373",
"0.684339",
"0.6731235",
"0.6718147",
"0.6697299",
"0.66349",
"0.6583386",
"0.65817887",
"0.65500563",
"0.65500563",
"0.6529792",
"0.6513275",
"0.6505297",
"0.64666075",
"0.64448845",
"0.64410853... | 0.7820821 | 0 |
Uses openssl, if available, to do a^b mod c where a,b,c are longs. | def ModExp(a, b, c):
if not _FOUND_SSL:
return pow(a, b, c)
# convert arbitrary long args to bytes
bytes_a = number.LongToBytes(a)
bytes_b = number.LongToBytes(b)
bytes_c = number.LongToBytes(c)
# convert bytes to (pointer to) Bignums.
bn_a = ssl.BN_bin2bn(bytes_a, len(bytes_a), 0)
bn_b = ssl.BN_bi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def powMod(a,b,c):\n if GMPY:\n return(gmpy2.powmod(a,b,c))\n else:\n return pow(a,b,c)",
"def TestSslRegression():\n if not _FOUND_SSL:\n return\n a = 13237154333272387305 # random\n b = 14222796656191241573 # random\n c = 14335739297692523692 # random\n expect_m = 106592315454997... | [
"0.6681694",
"0.64587593",
"0.6410224",
"0.6405954",
"0.62579936",
"0.62428784",
"0.6195865",
"0.61904657",
"0.6125475",
"0.6122947",
"0.6103147",
"0.6046036",
"0.6010627",
"0.60101646",
"0.5995779",
"0.5965606",
"0.5963928",
"0.5952755",
"0.59174013",
"0.5871228",
"0.5864174... | 0.7635855 | 0 |
Test openssl BN functions ctypes setup for regressions. | def TestSslRegression():
if not _FOUND_SSL:
return
a = 13237154333272387305 # random
b = 14222796656191241573 # random
c = 14335739297692523692 # random
expect_m = 10659231545499717801 # pow(a, b, c)
m = ModExp(a, b, c)
assert m == expect_m, 'TestSslRegression: unexpected ModExp result' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ssl_default(self):\n e = ErrataConnector()\n assert e.ssl_verify",
"def test_ssl_default(self):\n assert security.security_settings.ssl_verify()",
"def test_alpn_call_failure(self):\n context = Context(SSLv23_METHOD)\n with pytest.raises(ValueError):\n con... | [
"0.58895886",
"0.54251087",
"0.5340569",
"0.52410597",
"0.51989615",
"0.5001536",
"0.4908221",
"0.48994425",
"0.4890942",
"0.4880682",
"0.48786157",
"0.48503911",
"0.4837446",
"0.4806173",
"0.48055226",
"0.47952127",
"0.479222",
"0.47784704",
"0.47668955",
"0.47659346",
"0.47... | 0.5731037 | 1 |
Overwrite the biothings query handler to add graphml format (&format=graphml) added &download=True to download .graphml file automatically, can disable (&download=False) | def write(self, chunk):
try:
if self.format == "graphml":
chunk = edges2graphml(chunk, self.request.uri, self.request.protocol, self.request.host, edge_default="directed")
self.set_header("Content-Type", "text/graphml; charset=utf-8")
if self.args.down... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(self, outputfile:str, **format_options) -> str:\n return self.connection.download(self.graph, outputfile, format_options)",
"def download(self, outputfile:str, **format_options) -> str:\n return self.session.download(self.graph, outputfile, format_options)",
"def ExportMetaGraph(pref... | [
"0.5644568",
"0.5576068",
"0.52066654",
"0.5030416",
"0.49787995",
"0.4950677",
"0.4896912",
"0.48899424",
"0.48656175",
"0.48630908",
"0.48574403",
"0.48385876",
"0.47709388",
"0.47572508",
"0.47426155",
"0.47091573",
"0.46963683",
"0.46870074",
"0.46818873",
"0.46762022",
"... | 0.62148756 | 0 |
Tests if NAPI deny an IPv4 manually creation in a full network. Refactor to allow create the ip. | def test_try_create_ip_in_full_network(self):
name_file = 'api_ip/tests/sanity/ipv4/json/post/ipv4_10_0_4_1_net_8.json'
response = self.client.post(
'/api/v3/ipv4/',
data=json.dumps(self.load_json_file(name_file)),
content_type='application/json')
self.compa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_try_create_auto_ip(self):\n\n name_file = 'api_ip/tests/sanity/ipv4/json/post/ipv4_auto_net_free.json'\n\n # Does get request\n response = self.client.post(\n '/api/v3/ipv4/',\n data=json.dumps(self.load_json_file(name_file)),\n content_type='applicati... | [
"0.72138643",
"0.7143597",
"0.7103163",
"0.69434977",
"0.6816763",
"0.6809881",
"0.6664153",
"0.65963924",
"0.6582416",
"0.6578206",
"0.65741384",
"0.6565793",
"0.65070087",
"0.64682233",
"0.6466719",
"0.6372231",
"0.6264613",
"0.62450415",
"0.6238998",
"0.61737835",
"0.61651... | 0.7489132 | 0 |
Tests if NAPI deny out of range network IPv4 manually creation. | def test_try_create_out_of_range_ip_in_network(self):
name_file = 'api_ip/tests/sanity/ipv4/json/post/out_of_range_ipv4_172_0_0_5_net_5.json'
response = self.client.post(
'/api/v3/ipv4/',
data=json.dumps(self.load_json_file(name_file)),
content_type='application/json... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ipv4_in_range(self):\n\n test_ip = ip_address.IPAddress(\"192.168.178.4\", force_v4=True)\n \n assert test_ip.in_range(\"191.167.0.0\",\"193.169.0.0\")\n assert test_ip.in_range(\"192.167.0.0\",\"192.169.0.0\")\n assert test_ip.in_range(\"192.168.0.0\",\"192.168.255.0\")... | [
"0.73434836",
"0.6952464",
"0.6907861",
"0.67323136",
"0.67003703",
"0.65595746",
"0.65477157",
"0.6545432",
"0.64953184",
"0.6441315",
"0.6403229",
"0.6263367",
"0.62485737",
"0.6163018",
"0.6136902",
"0.6079953",
"0.5962481",
"0.5961101",
"0.5927232",
"0.5911758",
"0.590265... | 0.76985526 | 0 |
Function implements sieve of Eratosthenes (for all numbers uptil N). Returns array erat_sieve If erat_sieve[i] is True, then 2i + 3 is a prime. | def sieve_of_erat(N):
erat_sieve = [True]*int(N/2)
prime_list = []
prime_list.append(2)
for i in range(int((math.sqrt(N)-3)/2)+1): # Only need to run till sqrt(n)
if erat_sieve[i] == True:
j = i + (2*i+3)
while j < int(N/2):
erat_sieve[j] = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primeSieve(n):\n result = []\n sieve = array.array('i', (True for i in range(0, n+1)))\n for k in range(2, n+1):\n if sieve[k]:\n result.append(k)\n i = k * k\n while i <= n:\n sieve[i] = False\n i += k\n return result",
"def e... | [
"0.7732913",
"0.7636703",
"0.7548963",
"0.7507189",
"0.7439305",
"0.7436849",
"0.7405845",
"0.73973405",
"0.73973405",
"0.7349964",
"0.73457396",
"0.7325795",
"0.7229576",
"0.72279704",
"0.7197789",
"0.7099972",
"0.7085385",
"0.70812255",
"0.7055499",
"0.70475835",
"0.7027430... | 0.77103347 | 1 |
Handle file(s) arguments from command line This method takes the string(s) which were passed to the cli which indicate the files on which to operate. It expands the path arguments and creates a list of `pathlib.Path` objects which unambiguously point to the files indicated by the cli arguments. | def handle_files_args(*paths_args):
paths = []
for paths_arg in paths_args:
# Handle paths implicitly rooted at user home dir
paths_arg = os.path.expanduser(paths_arg)
# Expand wildcards
paths_arg = glob.glob(paths_arg)
# Create list of pathlib.Path objects
pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parser():\n \n \n parser = ap.ArgumentParser(description='Parsing some file names in various forms')\n group = parser.add_mutually_exclusive_group()\n group.add_argument('-f','--filepaths',dest='filepaths',metavar='PATH1,PATH2,...',type=str,\n help='Input a string or list ... | [
"0.6453815",
"0.6248218",
"0.6234054",
"0.6233103",
"0.6151754",
"0.60948",
"0.59932786",
"0.59910625",
"0.594788",
"0.5934068",
"0.5930487",
"0.5909474",
"0.58889955",
"0.587302",
"0.585867",
"0.58419037",
"0.58233815",
"0.5807165",
"0.57825506",
"0.5780803",
"0.5777409",
... | 0.6813794 | 0 |
Factory method to return child of RefFile This method returns either a BibFile or NonbibFile object depending on which is appropriate based on if the `path` arg points to a file containing valid BibTeX or invalid BibTeX, respectively. | def reffile_factory(path):
try:
b = BibFile(path)
except UnparseableBibtexError:
b = NonbibFile(path)
return b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fileobj(path_or_file, mode='r'):\n if isinstance(path_or_file, basestring):\n try:\n return open(path_or_file, mode)\n except:\n return closing(StringIO())\n else:\n return closing(path_or_file)",
"def get(self, path, content=True, type=None, format=None):\n ... | [
"0.5633376",
"0.5386271",
"0.5277653",
"0.5108195",
"0.5107922",
"0.50593334",
"0.5048385",
"0.49720398",
"0.49453267",
"0.49376675",
"0.49356878",
"0.49261934",
"0.49225807",
"0.49225807",
"0.48910007",
"0.48887247",
"0.48831517",
"0.4878487",
"0.4875914",
"0.4871508",
"0.48... | 0.79184014 | 0 |
List of data corresponding to individual bib files | def construct_bibfile_data(*paths):
bibs = [reffile_factory(path) for path in paths]
return bibs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _FindBibEntries(self):\n bibs = \" \".join(glob.glob(\"*.bib\"))\n cat_process = subprocess.Popen(shlex.split(\"cat %s\" % bibs),\n stdout=subprocess.PIPE)\n grep_process = subprocess.Popen(shlex.split(\"grep ^@\"),\n ... | [
"0.7137384",
"0.6268261",
"0.6240238",
"0.6198332",
"0.61708087",
"0.61559683",
"0.61306244",
"0.60698205",
"0.6049318",
"0.5935787",
"0.5895451",
"0.5891294",
"0.58823615",
"0.58217996",
"0.58115286",
"0.57741606",
"0.5756594",
"0.57499486",
"0.5724294",
"0.57221454",
"0.572... | 0.71239555 | 1 |
Sublist of bibfile_data whos elements are val_type This method examines each bib_dict element of a bibfile_data list and returns the subset which can be classified according to val_type. | def bib_sublist(bibfile_data, val_type):
sublist = [bibfile for bibfile in bibfile_data if isinstance(bibfile.bib, val_type)]
return sublist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getvartypelist(self,subj,vartype): # 3\n num_ = None\n if num_ is None:\n num_ = len(subj)\n elif num_ != len(subj):\n raise IndexError(\"Inconsistent length of array subj\")\n if num_ is None: num_ = 0\n if subj is None: raise TypeError(\"Invalid type for argument subj\"... | [
"0.5007208",
"0.49767375",
"0.49480826",
"0.46832088",
"0.46792015",
"0.4644492",
"0.46313435",
"0.46113947",
"0.45949426",
"0.45826903",
"0.45621505",
"0.45417857",
"0.4523038",
"0.45103496",
"0.4509286",
"0.4508049",
"0.4495507",
"0.4486568",
"0.44805893",
"0.44530094",
"0.... | 0.82294893 | 0 |
Generate appropriate message for STDOUT This method creates the string to be printed to STDOUT from the items of the `bibfile_data` list argument. It generates either a terse or verbose message based on the state of the `verbose` argument. | def gen_stdout_test_msg(bibfile_data, verbose=False):
msg_list = [bibfile.test_msg(verbose) for bibfile in bibfile_data]
msg = "\n".join(msg_list)
return msg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_verbose(message:str):\n if params['verbose']:\n print(message)\n return",
"def print_verbose(args, msg):\n if args.verbose:\n print(msg)",
"def print_info(message: str):\n global verbose\n if verbose:\n print(\"%s%s%s\" % (KYEL, message, KNRM))",
"def print_warni... | [
"0.55090094",
"0.5451742",
"0.5423902",
"0.5419448",
"0.5378487",
"0.53770965",
"0.5367469",
"0.53551465",
"0.53439623",
"0.53236914",
"0.53030246",
"0.52971905",
"0.52728134",
"0.52330023",
"0.5109582",
"0.5108932",
"0.5082648",
"0.50546724",
"0.5050566",
"0.50337845",
"0.50... | 0.7657903 | 0 |
This function determines if the user input is a valid player. If input is 'Q', exits program. | def is_valid_player(user_input):
i = user_input.upper()
if i in Board.player_decoder:
return True
elif i == 'Q':
exit("\nExiting program. Thanks for using Clue Detective!\n")
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_input(self):\n inp = input()\n if inp.upper() == \"Q\":\n return False\n if inp == \"\" \\\n \"\":\n return True\n return self.end_input",
"def validate_input(user_input: str) -> bool:\n\n if not user_input.islower():\n return F... | [
"0.7061746",
"0.7001091",
"0.6993307",
"0.685947",
"0.679399",
"0.6632149",
"0.6587232",
"0.6581674",
"0.6562173",
"0.65193605",
"0.65072095",
"0.6485321",
"0.6314308",
"0.6312182",
"0.6304966",
"0.63033706",
"0.62971884",
"0.62611985",
"0.62489146",
"0.6245538",
"0.6236307",... | 0.8541527 | 0 |
This function determines if the user input is a valid card. If skip = True, also allows 'X' as a valid input. If input is 'Q', exits program. | def is_valid(user_input, card_type=None, skip=False):
i = user_input.upper()
if i == 'Q':
exit("\nExiting program. Thanks for using Clue Detective!\n")
if skip:
if i == 'X':
return True
if card_type:
key_list = [key for key in Board.input_decoder
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_player(user_input):\n \n i = user_input.upper()\n if i in Board.player_decoder:\n return True\n elif i == 'Q':\n exit(\"\\nExiting program. Thanks for using Clue Detective!\\n\")\n else:\n return False",
"def player_discard(self, inpt):\n \n if inpt.... | [
"0.6342533",
"0.59396064",
"0.58468616",
"0.58279556",
"0.5803147",
"0.5801814",
"0.5795636",
"0.5759419",
"0.57581276",
"0.5757214",
"0.57171595",
"0.5706514",
"0.5694613",
"0.5655004",
"0.5642363",
"0.5630517",
"0.5617309",
"0.5616001",
"0.55874807",
"0.55715656",
"0.556892... | 0.8009378 | 0 |
This function collects a list user inputs for players and suspects and decodes them. | def collect_players_and_suspects_list():
players_list = []
while (players_input := input("Enter player: ")) != '#':
i = players_input.upper()
if not is_valid_player(i):
print("Please enter a valid Suspect.")
continue
if i not in players_list:
play... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_players_list():\n \n players_list = []\n while (players_input := input(\"Enter player: \")) != '#':\n i = players_input.upper()\n if not is_valid_player(i):\n print(\"Please enter a valid Suspect.\")\n continue\n if i not in players_list:\n ... | [
"0.7785427",
"0.5724351",
"0.5629555",
"0.5615475",
"0.5556688",
"0.54903173",
"0.53061044",
"0.5302518",
"0.5204586",
"0.51927483",
"0.5189104",
"0.515343",
"0.51155186",
"0.5102323",
"0.50311154",
"0.50235236",
"0.5017103",
"0.49988022",
"0.49984848",
"0.4991658",
"0.499021... | 0.8002285 | 0 |
This function collects a list user inputs for players and decodes them. | def collect_players_list():
players_list = []
while (players_input := input("Enter player: ")) != '#':
i = players_input.upper()
if not is_valid_player(i):
print("Please enter a valid Suspect.")
continue
if i not in players_list:
players_list.appe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_players_and_suspects_list():\n \n players_list = []\n while (players_input := input(\"Enter player: \")) != '#':\n i = players_input.upper()\n if not is_valid_player(i):\n print(\"Please enter a valid Suspect.\")\n continue\n if i not in players_list:... | [
"0.7349576",
"0.5860871",
"0.5805779",
"0.57845634",
"0.5769686",
"0.57296795",
"0.56243366",
"0.5612682",
"0.5509435",
"0.5483779",
"0.54824257",
"0.54214525",
"0.54100615",
"0.54100615",
"0.5393822",
"0.5390574",
"0.53871775",
"0.5355974",
"0.5330425",
"0.531194",
"0.530722... | 0.7726118 | 0 |
This function collects a list user inputs for cards and decodes them. | def collect_cards():
cards_list = []
while (cards_input := input("Enter card: ")) != '#':
i = cards_input.upper()
if not is_valid(i):
print(f"Please enter a valid card.")
continue
cards_list.append(i)
cards_decoded = [Board.translate(card) for card in car... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_players_list():\n \n players_list = []\n while (players_input := input(\"Enter player: \")) != '#':\n i = players_input.upper()\n if not is_valid_player(i):\n print(\"Please enter a valid Suspect.\")\n continue\n if i not in players_list:\n ... | [
"0.6567946",
"0.63332915",
"0.5622721",
"0.5523507",
"0.5515353",
"0.5509751",
"0.54955375",
"0.54447144",
"0.53823245",
"0.53788084",
"0.5369966",
"0.5357542",
"0.5334989",
"0.5311229",
"0.5299947",
"0.52394986",
"0.52083004",
"0.52079797",
"0.5192435",
"0.5192203",
"0.51900... | 0.7617722 | 0 |
Return tuple with name and symbol order of symbol table node gdbval | def get_symbol_name_order(gdbval):
return (symtab_node_name (gdbval), int(gdbval["order"])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_gdb_symbol_table():\n\n tab = Symtab()\n n = gdb.parse_and_eval (\"symtab->nodes\")\n while (long(n)):\n if symtab_node_is_function (n):\n current_symbol = GdbFunction(tab, n)\n tab.all_functions.append (current_symbol)\n elif symtab_node_is_variable (n):\n ... | [
"0.63522923",
"0.5892707",
"0.5717121",
"0.5676088",
"0.5654664",
"0.5606972",
"0.55600977",
"0.55475837",
"0.5519339",
"0.5508528",
"0.54735756",
"0.54546064",
"0.5445889",
"0.5444502",
"0.53737164",
"0.53344953",
"0.531329",
"0.53073454",
"0.52950823",
"0.52532065",
"0.5196... | 0.802892 | 0 |
Return pruned candidates containing only flags that are set in gdbval | def bool_attr_list(gdbval, candidates):
r = []
for i in candidates:
if long (gdbval[i]) != 0:
r.append(i)
pass
pass
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bool_attr_list_1(gdbval, candidates):\n\n r = []\n for i in candidates:\n if long (gdbval[i[0]]) != 0:\n r.append(i[1])\n pass\n pass\n return r",
"def flags(self):\n flags = self.Flags\n return [x for x in self.FLAGS_VALUES if flags & x]",
"def ch... | [
"0.62069196",
"0.58500195",
"0.5761298",
"0.56516194",
"0.54694813",
"0.54386127",
"0.5421935",
"0.5417712",
"0.54035455",
"0.53730446",
"0.53225636",
"0.53167844",
"0.5297252",
"0.529056",
"0.528956",
"0.5206268",
"0.5202388",
"0.5171703",
"0.51404",
"0.51187575",
"0.5093403... | 0.62399405 | 0 |
To be made method. Loads common attributes from symbol base | def load_symtab_base_attrs(self):
sym = self.gdbval
vis = bool_attr_list (sym, ["in_other_partition",
"used_from_other_partition", "force_output",
"forced_by_abi", "externally_visible"])
vis.extend(bool_attr_list_1(sym["decl"]["base"],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _base_attrs(self, service):\n keys = ['name', 'desc', 'url']\n return {name:getattr(service, name, None) for name in keys}",
"def __extract_common_attrs(self, raw_data: Dict) -> None:\n for attr in self.COMMON_ATTRS:\n if attr not in self.ATTRS and attr in raw_data:\n ... | [
"0.61585546",
"0.6084663",
"0.6044661",
"0.5943379",
"0.5886491",
"0.5802792",
"0.57020926",
"0.5637599",
"0.56372637",
"0.56197745",
"0.56000906",
"0.55648845",
"0.5503462",
"0.5496226",
"0.5459958",
"0.5452533",
"0.54436445",
"0.5441584",
"0.54250926",
"0.540444",
"0.539474... | 0.6953629 | 0 |
Return orders of nodes ipa_ref_list references | def gather_references_orders (gdbval):
# TODO: Somehow also note speculative references and attributes in
# general
vec = gdbval["references"]
return [int(i["referred"]["order"]) for i in vec_iter(vec)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gather_referring_orders (gdbval):\n# TODO: Somehow also note speculative references and attributes in\n# general\n vec = gdbval[\"referring\"]\n return [int(i[\"referring\"][\"order\"]) for i in vec_iter(vec)]",
"def angle_sort_adjacent_nodes(self,n,ref_nbr=None):\n nbrs=self.node_to_nodes(n)\n ... | [
"0.731949",
"0.6546845",
"0.6098026",
"0.6095413",
"0.6079038",
"0.5992602",
"0.5936781",
"0.59094507",
"0.58531016",
"0.58507776",
"0.58364546",
"0.58358586",
"0.58252954",
"0.58145785",
"0.5806854",
"0.5802949",
"0.5786999",
"0.5780388",
"0.5758174",
"0.5740272",
"0.5738646... | 0.79086727 | 0 |
Return orders of nodes referring node associated with ipa_ref_list | def gather_referring_orders (gdbval):
# TODO: Somehow also note speculative references and attributes in
# general
vec = gdbval["referring"]
return [int(i["referring"]["order"]) for i in vec_iter(vec)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gather_references_orders (gdbval):\n# TODO: Somehow also note speculative references and attributes in\n# general\n vec = gdbval[\"references\"]\n return [int(i[\"referred\"][\"order\"]) for i in vec_iter(vec)]",
"def angle_sort_adjacent_nodes(self,n,ref_nbr=None):\n nbrs=self.node_to_nodes(n)\n... | [
"0.7483979",
"0.6498939",
"0.60103464",
"0.59589404",
"0.592434",
"0.58175755",
"0.57886195",
"0.57791865",
"0.5778693",
"0.5724725",
"0.5648295",
"0.56302035",
"0.56052834",
"0.56052834",
"0.55912304",
"0.55762887",
"0.55696046",
"0.55564326",
"0.5543322",
"0.55140626",
"0.5... | 0.70957726 | 1 |
Build and return our representation of the symbol table | def build_gdb_symbol_table():
tab = Symtab()
n = gdb.parse_and_eval ("symtab->nodes")
while (long(n)):
if symtab_node_is_function (n):
current_symbol = GdbFunction(tab, n)
tab.all_functions.append (current_symbol)
elif symtab_node_is_variable (n):
current... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n dictt = self.getFullDict()\n return \"SymbolTable(\\n{}\\n)\".format(pprint.pformat(dictt))",
"def symbol_table(self) -> str:\n return self._symbol_table",
"def getSymbolTable(self) -> ghidra.app.util.bin.format.pe.debug.DebugCodeViewSymbolTable:\n ...",
"def ... | [
"0.7142161",
"0.7140003",
"0.7079655",
"0.67236257",
"0.66320723",
"0.65642846",
"0.65429175",
"0.65292776",
"0.64784485",
"0.6340965",
"0.6260409",
"0.62448263",
"0.62234396",
"0.61231375",
"0.60608643",
"0.6057268",
"0.5934887",
"0.58612394",
"0.5844101",
"0.5835696",
"0.57... | 0.7709988 | 0 |
Given a question ID, returns a tuple containing a list of the reference answers, human answers (Answer objects), and the canonical answer id | def __getitem__(self, qid):
ref = []
if qid in self._reference:
ref = self._reference[qid]
hum = []
if qid in self._human:
hum = self._human[qid]
aid = [-1, ""]
if qid in self._id:
aid = self._id[qid]
else:
logger.warning("Answer ID %s missing" % qid)
return r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_answer(self, answer_id):\n return self.answers[answer_id]",
"def get_answers_by_answer_id(self, answer_id):\n return self._answers_by_id.get(answer_id)",
"def get(self, question_id):\n response = Answers.get_all_answers(question_id)\n\n return response",
"def get_question_... | [
"0.63491833",
"0.6239461",
"0.6170823",
"0.59454125",
"0.5801377",
"0.57446605",
"0.5685475",
"0.5676668",
"0.56612366",
"0.565792",
"0.56460077",
"0.5644257",
"0.5625713",
"0.5581985",
"0.5564018",
"0.55500376",
"0.55474454",
"0.5515793",
"0.5485804",
"0.5477037",
"0.5423716... | 0.67215127 | 0 |
Given a question, find where "ftp" occurs. Assumes features have been preprocessed. | def find_ftp(features):
ftp_pos = -1
for ii in xrange(len(features)):
index, word = features[ii]
if word == 'ftp':
ftp_pos = index
return ftp_pos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_question(message, unique_users, q):\n \n line = get_tagged_user(message['text'], unique_users)[1]\n\n if '?' in line:\n return line\n\n START_WORDS = ['can', 'do', 'will', 'how', 'when', 'what', 'where',\n 'why', 'is', 'does', \"doesn't\", 'if', 'for', 'did', 'is']\n\n for word ... | [
"0.5377158",
"0.5220282",
"0.5132496",
"0.50776434",
"0.49986395",
"0.4923811",
"0.48578218",
"0.4798723",
"0.4798723",
"0.4798723",
"0.475099",
"0.46580526",
"0.46575606",
"0.46463495",
"0.46400103",
"0.46125606",
"0.46123046",
"0.46002674",
"0.45936626",
"0.45734656",
"0.45... | 0.7341822 | 0 |
String. WWID of current mpath. | def wwid(self):
return self._uuid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_id(self) -> str:\n return '_'.join(['wavin', self._controller_id, str(self._name), 'battery'])",
"def getPath(self):\n uid = str(self._result.uid)\n if not uid.startswith('/zport/dmd'):\n uid = '/zport/dmd/' + uid\n return uid",
"def device_path(self):\n re... | [
"0.6177691",
"0.60953784",
"0.60286385",
"0.59536564",
"0.59037435",
"0.58918136",
"0.58785886",
"0.58785886",
"0.58731186",
"0.5863684",
"0.58540994",
"0.5815289",
"0.5815289",
"0.5808639",
"0.57726943",
"0.57599044",
"0.5754434",
"0.5745627",
"0.57430816",
"0.57271993",
"0.... | 0.73362756 | 0 |
List of DMMP_path objects | def paths(self):
rc = []
for pg in self.path_groups:
rc.extend(pg.paths)
return rc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self) -> List[Path]:\n return self._path",
"def listPaths():\n try:\n paths = [x[1] for x in parseFstab(FSTAB)]\n return paths\n except DMException:\n return []",
"def _get_path_objs(self, path_list):\n objs = []\n for path in path_list:\n obj... | [
"0.6900828",
"0.6837692",
"0.6773243",
"0.67213434",
"0.6628229",
"0.65846545",
"0.6583305",
"0.65332806",
"0.64887327",
"0.64887327",
"0.64698523",
"0.6450161",
"0.64455634",
"0.64354306",
"0.642966",
"0.6352989",
"0.63092613",
"0.6308861",
"0.6287949",
"0.6274879",
"0.62295... | 0.7038104 | 0 |
The string for DEVNAME used by kernel in uevent. | def kdev_name(self):
return self._sysfs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_device_name(self):\n name = self._device[\"name\"]\n if not name or name == \"--\":\n name = self._mac\n\n return name",
"def name(self):\n return self.devname",
"def name(self):\n return f\"{get_device_name(self._data, 0, self._name)}\"",
"def device_nam... | [
"0.7653964",
"0.7651574",
"0.7606604",
"0.75387293",
"0.75387293",
"0.7465343",
"0.7465343",
"0.7457964",
"0.743613",
"0.73530847",
"0.73530847",
"0.73530847",
"0.727464",
"0.7246561",
"0.7210606",
"0.7110714",
"0.7101008",
"0.70763487",
"0.70535266",
"0.7051693",
"0.7044535"... | 0.77354324 | 0 |
Returns n points evenly spaced along the perimeter of a circle of diameter d centered at the origin, if type = 'int' the coordinates are rounded to the neares integer | def perimeter_points(d,n,type = 'int'):
rimpointsx = np.sin(np.linspace(0,2*np.pi,num=n,endpoint = False)) + 1
rimpointsy = np.cos(np.linspace(0,2*np.pi,num=n,endpoint = False)) + 1
rimpoints = (((d-1)/2))*np.array([rimpointsy,rimpointsx])
if type == 'int':
rimpoints = np.round(rimpoints)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, n):\n perimeter = 2 * math.pi\n return Point(math.cos(n / perimeter), math.sin(n / perimeter))",
"def discretized_circle(radius, n_pts):\n x1 = np.zeros(n_pts)\n y1 = np.zeros(n_pts)\n for i in range(0, n_pts):\n x1[i] = np.cos(2 * np.pi / n_pts * i) * radius\n ... | [
"0.73338",
"0.7235277",
"0.70930624",
"0.697346",
"0.69107336",
"0.6859915",
"0.6700372",
"0.6552774",
"0.64891666",
"0.6395865",
"0.63475925",
"0.6329089",
"0.6323116",
"0.6279683",
"0.6203975",
"0.61838937",
"0.61728275",
"0.617129",
"0.6138173",
"0.6136083",
"0.6120699",
... | 0.81103927 | 0 |
Outputs the matrix with with to adjust the gradient after adding the line between p1 and p2 | def line_contribution(p1,p2,alpha = 1):
adjust = np.zeros((worksize,worksize,2))
x1 = p1[0]
y1 = p1[1]
x2 = p2[0]
y2 = p2[1]
coordinates = coordinate_matrix(worksize)
numerator = np.sum(np.multiply(coordinates,np.reshape(np.array(((y2-y1,-(x2-x1)))),(2,1,1))),axis = 0) + x2*y1 - y2*x1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_gradient(p1, p2):\n # Ensure that the line is not vertical\n if p1[0] == p2[0]:\n return None\n m = (p1[1] - p2[1]) / (p1[0] - p2[0])\n return m",
"def calc_gradu_gradv_p1_partly(topo,x,y):\n ndofs = max(x.shape)\n\n (rows,cols)= la_utils.get_sparsity_pa... | [
"0.64249635",
"0.5964822",
"0.58919156",
"0.5855966",
"0.5814256",
"0.57597506",
"0.57327527",
"0.5700635",
"0.5680193",
"0.5670194",
"0.5667574",
"0.56395584",
"0.56350654",
"0.56335413",
"0.5621072",
"0.5597152",
"0.559362",
"0.55905247",
"0.55903786",
"0.55802053",
"0.5572... | 0.59735805 | 1 |
`clicked on board | || yes No | | selected from where nothing to do | | | | selection_bar Board no selection | | | is clicked on valid position is clicked on valid position(Rajan) clicked on empty slot | | | (it returns pgn) | | | | | | | yes no yes no | | | | | | place it (if his piece) does move contain 'x' (capture)... | def main_board_maintenance(self,x_cor,y_cor):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.display.quit()
pygame.quit()
quit()
if event.type == pygame.MOUSEBUTTONDOWN:
x_adjusted,y_adjusted = Helping_Class.convert_coordinate(x_cor,y_cor,from_where... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def selection_board_maintenance(self,x_cor,y_cor):\t\t\r\n\t\tfor event in pygame.event.get():\r\n\t\t\tif event.type == pygame.QUIT:\r\n\t\t\t\tpygame.display.quit()\r\n\t\t\t\tpygame.quit()\r\n\t\t\t\tquit() \r\n\r\n\t\t\tif event.type == pygame.MOUSEBUTTONDOWN:\r\n\t\t\t\t#print(\"mouse is pressed\")\r\n\t\... | [
"0.7565643",
"0.66341156",
"0.6557111",
"0.6449328",
"0.63517064",
"0.6219487",
"0.61956",
"0.61922944",
"0.6161466",
"0.6128278",
"0.61244667",
"0.6082774",
"0.6044222",
"0.60180783",
"0.5978442",
"0.5978442",
"0.59686",
"0.5960028",
"0.59480584",
"0.5931471",
"0.58620036",
... | 0.6903945 | 1 |
clicked on selection_bar | | | Yes No | | selected from where or not selected is it his piece | | | | | | | selection_bar board nothing selected yes no \ | / | | \ | / blit cover nothing to do \ | / (if clicked piece is his piece == True) else nothing to do and if its availability is their \ / | \ / | \ / | \ / | \/ | ... | def selection_board_maintenance(self,x_cor,y_cor):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.display.quit()
pygame.quit()
quit()
if event.type == pygame.MOUSEBUTTONDOWN:
#print("mouse is pressed")
#everything begins here
x_adjusted,y_adjusted... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_me(self, mouse_pos):\r\n\t\t#self.active = self.rect.collidepoint(mouse_pos)\r\n\t\tself.active = True",
"def menuSelection(self):\n \n self.selection = int(input(\"\\nWhere do you want to go? Make a selection: \"))\n \n while self.selection not in self.menu.index:\n ... | [
"0.65026367",
"0.64400166",
"0.63710815",
"0.63659126",
"0.62468314",
"0.62162787",
"0.62162787",
"0.6215016",
"0.61831117",
"0.61701834",
"0.6158669",
"0.6151914",
"0.6135659",
"0.61340016",
"0.6130133",
"0.61174387",
"0.6027609",
"0.60263383",
"0.60083646",
"0.60067785",
"0... | 0.7832845 | 0 |
Returns the scheduling actions based on highest Qvalues. This requires the model weights to be already saved. | def get_best_schedule(self):
# load the model weights
self.models = [load_model(f'dqn_{task_id}.h5')
for task_id in range(len(self.models))]
actions = []
is_scheduled = [0] * len(self.models)
while (not all(is_scheduled)):
observation = OrderedDict([('is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bestAction(self):\n get_q = self.getQFunction()\n maxq = -5000\n best_actions = []\n for (state, action), q in get_q.items():\n if q > maxq:\n maxq = q\n best_actions = [action]\n elif q == maxq:\n best_actions.appen... | [
"0.767564",
"0.71033466",
"0.69351465",
"0.6854587",
"0.68315357",
"0.6827179",
"0.68225276",
"0.67966247",
"0.67770445",
"0.67721236",
"0.67721236",
"0.67337626",
"0.67147684",
"0.6710782",
"0.66831255",
"0.6642326",
"0.66293216",
"0.6593363",
"0.65867025",
"0.65508795",
"0.... | 0.7105697 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.