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 |
|---|---|---|---|---|---|---|
Create a table for the example_test data | def create_example_test_table(conn):
execute_sql_script(conn, "06_create_example_test_table.sql") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_table(\n table_id: str = typer.Option(..., help=\"The id of the table to be created\"),\n test: bool = typer.Option(False, help=\"Whether it is a test or not\")\n) -> None:\n base_path = Path.cwd().parent\n architecture_file = base_path / f\"extra/architecture/{table_id}.csv\"\n if not ar... | [
"0.7220285",
"0.7129346",
"0.707731",
"0.70759505",
"0.7056779",
"0.69891703",
"0.69740117",
"0.6933229",
"0.6916446",
"0.6874953",
"0.6792691",
"0.6781502",
"0.6639353",
"0.66176784",
"0.65448433",
"0.6538979",
"0.6519175",
"0.65118295",
"0.6496484",
"0.6479034",
"0.64755267... | 0.8160891 | 0 |
Create a table for the census tract to example_sample_submission data | def create_example_sample_submission_table(conn):
execute_sql_script(conn, "07_create_example_sample_submission_table.sql") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_example_test_table(conn):\n execute_sql_script(conn, \"06_create_example_test_table.sql\")",
"def create_train_table(conn):\n execute_sql_script(conn, \"03_create_train_table.sql\")",
"def create_submission(pred_sub, name_of_the_file='submission'):\n\n df_sub = pd.DataFrame(pred_sub, column... | [
"0.603935",
"0.5993586",
"0.5964438",
"0.5935723",
"0.58772194",
"0.5860783",
"0.5800112",
"0.5777341",
"0.5726033",
"0.5690624",
"0.56006396",
"0.5599972",
"0.55904704",
"0.5590239",
"0.5584303",
"0.5566211",
"0.55599475",
"0.55486864",
"0.5546934",
"0.55461943",
"0.5542591"... | 0.75246966 | 0 |
Composite function that copies all CSV files into the database | def copy_csv_files(data_files_dict):
# Depending on your local settings, you may need to specify a user and password, e.g.
# conn = psycopg2.connect(dbname=DBNAME, user="postgres", password="password")
conn = psycopg2.connect(dbname=DBNAME)
for name, files in data_files_dict.items():
csv_file =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_files(conn: Connection, path: Path) -> None:\n sql = \"INSERT OR IGNORE INTO Files (filename) VALUES (?)\"\n run_sql_on_csv(conn, path, sql, (str,))",
"def from_csv_to_database():\r\n for year, path in FileNamePath.items():\r\n # load csv files\r\n with open(path, encoding='cp1... | [
"0.68402326",
"0.6816599",
"0.661251",
"0.6598817",
"0.62749064",
"0.62011576",
"0.6185768",
"0.6172839",
"0.6161306",
"0.61159104",
"0.60363084",
"0.6004497",
"0.59940296",
"0.59888047",
"0.5987941",
"0.59727305",
"0.5962325",
"0.5925651",
"0.5914285",
"0.5898657",
"0.588313... | 0.70384914 | 0 |
Copy the CSV contents of the train data into the table | def copy_csv_to_train_table(conn, csv_file):
COPY_TRAIN = "08_copy_train_to_table.psql"
copy_expert_psql_script(conn, COPY_TRAIN, csv_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_data():\n table = create_new_table()\n filename = '/home/nineleaps/Downloads/covid_info_.csv'\n dataset_ref = client.dataset(table.dataset_id)\n table_ref = dataset_ref.table(table.table_id)\n job_config = bigquery.LoadJobConfig()\n job_config.source_format = bigquery.SourceFormat.CSV\... | [
"0.682733",
"0.6637438",
"0.65697265",
"0.6363471",
"0.6350087",
"0.6322782",
"0.63010466",
"0.61652935",
"0.6139673",
"0.6114018",
"0.6067298",
"0.606431",
"0.6044262",
"0.6012118",
"0.60105383",
"0.6004982",
"0.5983898",
"0.5981103",
"0.59738964",
"0.5959424",
"0.59585667",... | 0.7570099 | 0 |
Copy the csv contents of the lectures data into the table | def copy_csv_to_lectures_table(conn, csv_file):
COPY_LECTURES = "10_copy_lectures_to_table.psql"
copy_expert_psql_script(conn, COPY_LECTURES, csv_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_csv_to_train_table(conn, csv_file):\n COPY_TRAIN = \"08_copy_train_to_table.psql\"\n copy_expert_psql_script(conn, COPY_TRAIN, csv_file)",
"def copy_csv_to_questions_table(conn, csv_file):\n COPY_QUESTIONS = \"09_copy_questions_to_table.psql\"\n copy_expert_psql_script(conn, COPY_QUESTIONS, ... | [
"0.64943576",
"0.6417047",
"0.62275773",
"0.61845875",
"0.6169708",
"0.6109317",
"0.6084161",
"0.6071365",
"0.6028989",
"0.5982964",
"0.5907622",
"0.5895916",
"0.5880129",
"0.58722913",
"0.58722913",
"0.58679646",
"0.5858774",
"0.5850394",
"0.5835062",
"0.5832906",
"0.5829798... | 0.7012755 | 0 |
Copy the csv contents of the example test data into the table | def copy_csv_to_example_test_table(conn, csv_file):
COPY_EXAMPLE_TEST = "11_copy_example_test_to_table.psql"
copy_expert_psql_script(conn, COPY_EXAMPLE_TEST, csv_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_data():\n table = create_new_table()\n filename = '/home/nineleaps/Downloads/covid_info_.csv'\n dataset_ref = client.dataset(table.dataset_id)\n table_ref = dataset_ref.table(table.table_id)\n job_config = bigquery.LoadJobConfig()\n job_config.source_format = bigquery.SourceFormat.CSV\... | [
"0.6870561",
"0.68621397",
"0.68282795",
"0.6661536",
"0.64871234",
"0.63820755",
"0.6304575",
"0.623684",
"0.6180814",
"0.61601466",
"0.6142755",
"0.6124967",
"0.6119393",
"0.60797185",
"0.60796",
"0.6040634",
"0.6039739",
"0.6036316",
"0.6031299",
"0.60189676",
"0.5994174",... | 0.7520836 | 0 |
Copy the csv contents of the census tract to example sample submission data into the table | def copy_csv_to_example_sample_submission_table(conn, csv_file):
COPY_EXAMPLE_SAMPLE_SUBMISSION = "12_copy_example_sample_submission_to_table.psql"
copy_expert_psql_script(conn, COPY_EXAMPLE_SAMPLE_SUBMISSION, csv_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_csv_to_train_table(conn, csv_file):\n COPY_TRAIN = \"08_copy_train_to_table.psql\"\n copy_expert_psql_script(conn, COPY_TRAIN, csv_file)",
"def copy_csv_to_example_test_table(conn, csv_file):\n COPY_EXAMPLE_TEST = \"11_copy_example_test_to_table.psql\"\n copy_expert_psql_script(conn, COPY_EX... | [
"0.68695116",
"0.6782291",
"0.6613778",
"0.6355474",
"0.61145604",
"0.61135346",
"0.59616476",
"0.58550143",
"0.5852218",
"0.58010006",
"0.5678556",
"0.56541306",
"0.564899",
"0.5647298",
"0.5637213",
"0.5631169",
"0.56293553",
"0.5625885",
"0.5548812",
"0.5544546",
"0.551572... | 0.7247699 | 0 |
Given a DB connection and a file path to a SQL script, open up the SQL script and execute it | def execute_sql_script(conn, script_filename):
file_contents = open_sql_script(script_filename)
cursor = conn.cursor()
cursor.execute(file_contents)
conn.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_script(file_name):\n conn = psycopg2.connect(config['SQLALCHEMY_DATABASE_URI'])\n cur = conn.cursor()\n sql_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), file_name)\n cur.execute(open(sql_file, 'r').read())\n conn.commit()\n cur.close()\n conn.close()",
"def exe... | [
"0.80921817",
"0.7998528",
"0.770649",
"0.726337",
"0.7130588",
"0.7008225",
"0.6983888",
"0.6938017",
"0.682747",
"0.6824145",
"0.6633691",
"0.6620906",
"0.66191906",
"0.66088134",
"0.6569327",
"0.64927316",
"0.6413945",
"0.6385292",
"0.6356701",
"0.62582904",
"0.6225003",
... | 0.85166866 | 0 |
Given a file path, open the file and return its contents We assume that the file path is always inside the sql directory | def open_sql_script(script_filename):
dir = os.path.dirname(__file__)
relative_filename = os.path.join(dir, 'sql', script_filename)
file_obj = open(relative_filename, 'r')
file_contents = file_obj.read()
file_obj.close()
return file_contents | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_contents(self):\n with open(self.sql_file, 'r') as sql:\n text = sql.read()\n # text = text.replace('\\n', '\\n\\n')\n # text=sql.read()\n # TODO: fix some text replacement issues here\n # https://github.com/andialbrecht/sqlparse/issues/313... | [
"0.6938102",
"0.68973416",
"0.6869283",
"0.68430454",
"0.68159455",
"0.67649686",
"0.6757924",
"0.67353684",
"0.6700045",
"0.6696577",
"0.66157943",
"0.65953904",
"0.65915734",
"0.6547246",
"0.65232974",
"0.6515384",
"0.6509697",
"0.64971465",
"0.64961016",
"0.64459",
"0.6377... | 0.73147106 | 0 |
Given a DB connection and a file path to a PSQL script, open up the PSQL script and use it to run copy_expert | def copy_expert_psql_script(conn, script_filename, csv_file):
file_contents = open_sql_script(script_filename)
cursor = conn.cursor()
cursor.copy_expert(file_contents, csv_file)
conn.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_sql_script(conn, script_filename):\n file_contents = open_sql_script(script_filename)\n cursor = conn.cursor()\n cursor.execute(file_contents)\n conn.commit()",
"def open_sql_script(script_filename):\n dir = os.path.dirname(__file__)\n relative_filename = os.path.join(dir, 'sql', sc... | [
"0.6780042",
"0.67421824",
"0.6734249",
"0.64080065",
"0.6145905",
"0.59611",
"0.59009856",
"0.58451056",
"0.5779275",
"0.57705617",
"0.57494783",
"0.57482135",
"0.57234544",
"0.5701453",
"0.56711847",
"0.5633896",
"0.5608548",
"0.5586253",
"0.55794865",
"0.55444336",
"0.5508... | 0.80731106 | 0 |
Match the correlation id to get the correct response as part of the requestreply pattern | def on_response(self, ch, method, props, body):
if self.corr_id == props.correlation_id:
self.response = body | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_reply(request, reply):\n assert isinstance(reply, dict) and 'id' in reply\n assert ('result' in reply) != ('error' in reply)\n assert reply['id'] == request['id'] or \\\n reply['id'] == '00' and 'error' in reply",
"def reply(self, msg_id, response):\n return se... | [
"0.6301974",
"0.60582995",
"0.59054214",
"0.57754266",
"0.5729422",
"0.57087106",
"0.5684049",
"0.56805116",
"0.5631793",
"0.5624594",
"0.56170404",
"0.55817276",
"0.5493033",
"0.5485892",
"0.5485892",
"0.5457697",
"0.54559404",
"0.5450454",
"0.54025334",
"0.5382339",
"0.5365... | 0.6833892 | 0 |
returns Kronecker graph tensor product of k copies of graph g Takes a graph g and int k and multiplies g's adjacency matrix by itself k times, returns resulting graph. For some reason graphs gotten this way are nicest when the initial graph has as self edge on every node, so by default this function adds self edges bef... | def kronecker_graph(g, k, add_self_edges=True, strip_self_edges=True):
adj = nx.adjacency_matrix(g).todense()
if add_self_edges:
for i in range(len(adj)):
adj[i, i] = 1
mat = adj
for i in range(k - 1):
mat = np.kron(mat, adj)
if strip_self_edges:
for i in range(l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _kronecker_product(mat1: tf.Tensor, mat2: tf.Tensor) -> tf.Tensor:\n m1, n1 = mat1.get_shape().as_list()\n mat1_rsh = tf.reshape(mat1, [m1, 1, n1, 1])\n m2, n2 = mat2.get_shape().as_list()\n mat2_rsh = tf.reshape(mat2, [1, m2, 1, n2])\n return tf.reshape(mat1_rsh * mat2_rsh, ... | [
"0.6349474",
"0.628217",
"0.6246938",
"0.6221783",
"0.6156086",
"0.6099495",
"0.59082294",
"0.5830467",
"0.5819271",
"0.5718691",
"0.57003087",
"0.5684733",
"0.5603436",
"0.56028265",
"0.5598301",
"0.557988",
"0.5576591",
"0.55397904",
"0.55388963",
"0.5536826",
"0.5524773",
... | 0.8255546 | 0 |
takes two graphs that have some nodes in commmon and This function takes a pair of graphs a, b with some corresponding nodes having the same label. Before running any matching algorithms them, their nodes and edges need to be shuffled because otherwise some algorithms may (inadvertently) match graphs by node label and ... | def permute_graphs(a, b, seed=0):
np.random.seed(seed)
nodes = b.nodes()
permuted_nodes = np.random.permutation(nodes)
# matching of all labels of nodes in graph b to their new values
match = gm.Matching(zip(nodes, permuted_nodes))
new_edges = [(match.get_b(x), match.get_b(y)) for x, y in b.edg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equivalent(kls, first, second):\n if first.empty() and second.empty():\n return True\n elif first.vertices.shape[0] != second.vertices.shape[0]:\n return False\n elif first.edges.shape[0] != second.edges.shape[0]:\n return False\n\n EPSILON = 1e-7\n\n vertex1, ct1 = np.unique(firs... | [
"0.68501484",
"0.6609531",
"0.6550218",
"0.6478293",
"0.64721924",
"0.6455647",
"0.6370949",
"0.6257739",
"0.62525046",
"0.6149024",
"0.6139504",
"0.6138427",
"0.6100626",
"0.5999131",
"0.5935091",
"0.5918132",
"0.5916235",
"0.58819485",
"0.5872874",
"0.58498603",
"0.58483785... | 0.7509719 | 0 |
returns randomly selected anchors and candidate sets Randomly selects a set of pairs of corresponding nodes anchors. For every node that in a that has a counterpart in b (and is not already an anchor) randomly selects a list of candidates, the list always contains true match. Candidate sets need not be disjoint. | def get_anchors_candidates(a, b, match, n_anchors, n_candidates, seed=0):
random.seed(seed)
a_nodes = set(a.nodes())
b_nodes = set(b.nodes())
anchors = random.sample(match.items(), n_anchors)
a_anchors = set([x for x, _ in anchors])
b_anchors = set([y for _, y in anchors])
a_nodes.difference... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randomMatching(self):\n\n # Generate random permutation of vertices\n permutation = range(self.n)\n shuffle(permutation)\n\n # Invert permutation list to get rank\n ranks = range(self.n)\n for idx, v in enumerate(permutation):\n ranks[v] = idx\n\n mat... | [
"0.6388406",
"0.59702134",
"0.5779511",
"0.57395196",
"0.56252724",
"0.5541956",
"0.55121106",
"0.543829",
"0.5397814",
"0.5316234",
"0.5306503",
"0.52857965",
"0.52767396",
"0.5274424",
"0.5258052",
"0.52311355",
"0.5156326",
"0.51288533",
"0.51273835",
"0.51248735",
"0.5106... | 0.8069033 | 0 |
Normalize the data from a series of Azure cloud API calls into a Python dict object containing very specific portions of the original data. | def normalize_data(vms, vm_statuses, nics, public_ips):
normalized_data = {}
for vm_id in vms:
vm_data = vms[vm_id]
name = vm_data['name']
nic_id = vm_data['nic_id']
nic_data = nics[nic_id]
public_ip_id = nic_data['public_ip_id']
public_ip_data = public_ips[public... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_process_raw(raw: dict) -> dict:\n api_data = raw.get(\"data\", {}).get(\"apiList\", [])\n return {api[\"id\"]: api for api in api_data}",
"def parse_api_call(api_resp):\n\n data = {}\n if 'resultSets' in api_resp:\n dictionary_key = 'resultSets'\n elif 'resultSet' in api_res... | [
"0.65975904",
"0.6409738",
"0.6102891",
"0.60573673",
"0.59634995",
"0.566204",
"0.54953855",
"0.5486656",
"0.54791516",
"0.54694664",
"0.54640585",
"0.5420058",
"0.5407419",
"0.5402164",
"0.53785086",
"0.53610575",
"0.53552586",
"0.5355134",
"0.5346608",
"0.533809",
"0.53360... | 0.6871206 | 0 |
Create user with {APR1} password and check that user can login. | def test_auth_with_apr1_stored_password(self):
# Create test user
name = u'Test User'
# generated with "htpasswd -nbm blaze 12345"
password = '{APR1}$apr1$NG3VoiU5$PSpHT6tV0ZMKkSZ71E3qg.' # 12345
self.createUser(name, password, True)
# Try to "login"
theuser = us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user(email, password, f_name, l_name):\n pass",
"def create_user(self):\n User.objects.create_user('test', 'testing@test.com', 'testing')",
"def user_created(self, user, password):\n\n if not self.check_prereqs():\n return False\n\n if self.has_user(user):\n ... | [
"0.73004067",
"0.7224032",
"0.71962816",
"0.70947254",
"0.70152885",
"0.69930893",
"0.6973203",
"0.69717765",
"0.69700277",
"0.69580203",
"0.69015574",
"0.6899521",
"0.6899521",
"0.6899521",
"0.6867215",
"0.68664825",
"0.6848039",
"0.68402165",
"0.6837405",
"0.68344754",
"0.6... | 0.7594792 | 0 |
Create user with {MD5} password and check that user can login. | def test_auth_with_md5_stored_password(self):
# Create test user
name = u'Test User'
password = '{MD5}$1$salt$etVYf53ma13QCiRbQOuRk/' # 12345
self.createUser(name, password, True)
# Try to "login"
theuser = user.User(self.request, name=name, password='12345')
ass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_user(username, hash_password):\n try:\n conn = sqlite3.connect(DATABASE)\n cursor = conn.cursor()\n\n query = '''\n INSERT INTO user\n (Username, Password)\n values\n (?, ?)'''\n cursor.execute(query, (username, hash_password... | [
"0.7318656",
"0.73062855",
"0.7287217",
"0.72614634",
"0.7258231",
"0.72305536",
"0.7217494",
"0.7212634",
"0.7208353",
"0.7205905",
"0.720523",
"0.7198507",
"0.7187735",
"0.7183065",
"0.7181787",
"0.71778566",
"0.71710557",
"0.7155194",
"0.7145005",
"0.7124427",
"0.71208876"... | 0.8022129 | 0 |
Create user with {DES} password and check that user can login. | def test_auth_with_des_stored_password(self):
# Create test user
name = u'Test User'
# generated with "htpasswd -nbd blaze 12345"
password = '{DES}gArsfn7O5Yqfo' # 12345
self.createUser(name, password, True)
try:
import crypt
# Try to "login"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user(username):\n\n password = getpass.getpass('Password for {0}: '.format(username))\n confirm = getpass.getpass('Again: ')\n\n if password != confirm:\n print >> sys.stderr, \"Passwords don't match\"\n\n sys.exit(1)\n\n with transaction.manager:\n Users(username, pass... | [
"0.7343586",
"0.73068523",
"0.72953594",
"0.7279533",
"0.7268812",
"0.7237736",
"0.7235069",
"0.72157264",
"0.72143716",
"0.7140119",
"0.7119481",
"0.71022165",
"0.707469",
"0.7071333",
"0.7054914",
"0.70465577",
"0.7039468",
"0.70377856",
"0.70342153",
"0.7029694",
"0.701669... | 0.746672 | 0 |
create user and then rename user and check if the old username is removed from the cache name2id | def testRenameUser(self):
# Create test user
name = u'__Some Name__'
password = name
self.createUser(name, password)
# Login - this should replace the old password in the user file
theUser = user.User(self.request, name=name)
# Rename user
theUser.name = u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __check_if_username_has_changed(self, input_username):\n\n user_id = get_data.get_id_by_username_from_db(input_username)\n if user_id:\n username = get_data.get_username_by_id(user_id)\n if username:\n if input_username != username:\n update... | [
"0.6498411",
"0.6445537",
"0.64272594",
"0.63668567",
"0.62813914",
"0.6276819",
"0.62515754",
"0.62395614",
"0.6230753",
"0.61900216",
"0.6189337",
"0.6094322",
"0.6059636",
"0.604635",
"0.6021056",
"0.5997202",
"0.5993181",
"0.59726524",
"0.597109",
"0.5961523",
"0.59597486... | 0.7157386 | 0 |
Create user with {SHA} password and check that logging in upgrades to {SSHA}. | def test_upgrade_password_from_sha_to_ssha(self):
name = u'/no such user/'
password = '{SHA}jLIjfQZ5yojbZGTqxg2pY0VROWQ=' # 12345
self.createUser(name, password, True)
# User is not required to be valid
theuser = user.User(self.request, name=name, password='12345')
asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upgrade_password_from_apr1_to_ssha(self):\n # Create test user\n name = u'Test User'\n # generated with \"htpasswd -nbm blaze 12345\"\n password = '{APR1}$apr1$NG3VoiU5$PSpHT6tV0ZMKkSZ71E3qg.' # 12345\n self.createUser(name, password, True)\n\n # User is not requi... | [
"0.73439944",
"0.7333939",
"0.7085419",
"0.7017456",
"0.7014548",
"0.69558007",
"0.67983985",
"0.6787436",
"0.661877",
"0.6514608",
"0.6433441",
"0.6432057",
"0.6385014",
"0.63845205",
"0.63744473",
"0.63245636",
"0.6289351",
"0.62403136",
"0.6240243",
"0.6236771",
"0.6223678... | 0.808385 | 0 |
Create user with {APR1} password and check that logging in upgrades to {SSHA}. | def test_upgrade_password_from_apr1_to_ssha(self):
# Create test user
name = u'Test User'
# generated with "htpasswd -nbm blaze 12345"
password = '{APR1}$apr1$NG3VoiU5$PSpHT6tV0ZMKkSZ71E3qg.' # 12345
self.createUser(name, password, True)
# User is not required to be vali... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createABPPMGRUSER():\n password = globs.props['ABPP_Password'] \n sqlcommand = bytes('@'+globs.props['JDA_HOME']+'\\\\config\\\\database\\\\setup\\\\cr_abpp_user '+password, 'utf-8')\n stdout, stdin = runSQLQuery(sqlcommand, globs.props['System_Username'])\n print(stdout.decode('ascii'))",
"def ... | [
"0.6923646",
"0.6910008",
"0.6903554",
"0.69030684",
"0.67261803",
"0.6656542",
"0.66533566",
"0.663863",
"0.65611124",
"0.65610635",
"0.6528321",
"0.6524464",
"0.6468667",
"0.64476997",
"0.6443924",
"0.643508",
"0.6432209",
"0.6421695",
"0.6406809",
"0.64033985",
"0.6395312"... | 0.74522865 | 0 |
Create user with {MD5} password and check that logging in upgrades to {SSHA}. | def test_upgrade_password_from_md5_to_ssha(self):
# Create test user
name = u'Test User'
password = '{MD5}$1$salt$etVYf53ma13QCiRbQOuRk/' # 12345
self.createUser(name, password, True)
# User is not required to be valid
theuser = user.User(self.request, name=name, passwor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upgrade_password_from_sha_to_ssha(self):\n name = u'/no such user/'\n password = '{SHA}jLIjfQZ5yojbZGTqxg2pY0VROWQ=' # 12345\n self.createUser(name, password, True)\n\n # User is not required to be valid\n theuser = user.User(self.request, name=name, password='12345')\n ... | [
"0.77516174",
"0.73371005",
"0.7249351",
"0.70577127",
"0.7020497",
"0.68880355",
"0.6835192",
"0.6757816",
"0.6754576",
"0.66576886",
"0.6590541",
"0.6556658",
"0.65215313",
"0.6450802",
"0.64421785",
"0.6416691",
"0.64149505",
"0.6387276",
"0.63868517",
"0.63638514",
"0.633... | 0.77814764 | 0 |
Create user with {DES} password and check that logging in upgrades to {SSHA}. | def test_upgrade_password_from_des_to_ssha(self):
# Create test user
name = u'Test User'
# generated with "htpasswd -nbd blaze 12345"
password = '{DES}gArsfn7O5Yqfo' # 12345
self.createUser(name, password, True)
# User is not required to be valid
theuser = user.U... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upgrade_password_from_sha_to_ssha(self):\n name = u'/no such user/'\n password = '{SHA}jLIjfQZ5yojbZGTqxg2pY0VROWQ=' # 12345\n self.createUser(name, password, True)\n\n # User is not required to be valid\n theuser = user.User(self.request, name=name, password='12345')\n ... | [
"0.7500007",
"0.7187628",
"0.7142682",
"0.6940297",
"0.69316804",
"0.69210327",
"0.68815446",
"0.6822661",
"0.6731875",
"0.6687178",
"0.64787775",
"0.64628786",
"0.64233464",
"0.64151156",
"0.6408571",
"0.6375208",
"0.6362141",
"0.6337913",
"0.63170415",
"0.63036406",
"0.6278... | 0.77103466 | 0 |
checks for no access to the email attribute by getting the user object from name | def test_for_email_attribute_by_name(self):
name = u"__TestUser__"
password = u"ekfdweurwerh"
email = "__TestUser__@moinhost"
self.createUser(name, password, email=email)
theuser = user.User(self.request, name=name)
assert theuser.email == "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_email(obj):\r\n return obj.user.email",
"def test_get_user_by_emailuser_email_get(self):\n pass",
"def test_resource_user_resource_get_user_by_email_address_get(self):\n pass",
"def validate_email(self, value):\n if not User.objects.filter(email=value).exists():\n r... | [
"0.69927853",
"0.69904214",
"0.6800825",
"0.6738111",
"0.6738111",
"0.6700649",
"0.6663769",
"0.6641182",
"0.661915",
"0.66068196",
"0.6578889",
"0.652461",
"0.65243393",
"0.6438929",
"0.6421183",
"0.64171404",
"0.641056",
"0.6377576",
"0.6363164",
"0.63273644",
"0.631347",
... | 0.71719223 | 0 |
checks access to the email attribute by getting the user object from the uid | def test_for_email_attribut_by_uid(self):
name = u"__TestUser2__"
password = u"ekERErwerwerh"
email = "__TestUser2__@moinhost"
self.createUser(name, password, email=email)
uid = user.getUserId(self.request, name)
theuser = user.User(self.request, uid)
assert theus... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_email(obj):\r\n return obj.user.email",
"def test_get_user_by_emailuser_email_get(self):\n pass",
"def validate_email(self, value):\n if not User.objects.filter(email=value).exists():\n raise serializers.ValidationError('User with this email does not exist.')\n return... | [
"0.71520734",
"0.69720227",
"0.67924476",
"0.67924476",
"0.6726474",
"0.6698958",
"0.66802007",
"0.66745335",
"0.6655605",
"0.6627979",
"0.6603454",
"0.6574884",
"0.655539",
"0.652709",
"0.6515871",
"0.64560187",
"0.6446277",
"0.6443656",
"0.6422562",
"0.63196146",
"0.6314266... | 0.73147726 | 0 |
Ask the user to choose one running instance | def _choose_among_running_instances(self):
instances = self.compute.get_running_instances_ids()
# No instances
if not instances:
print 'You do not have any running instances!'
return None
# List the name of the instances
print 'Choose an instance:'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _choose_among_stopped_instances(self):\n\n instances = self.compute.get_not_running_instances_ids()\n\n # No instances\n if not instances:\n print 'You do not have any instances!'\n return None\n\n # List the name of the instances\n print 'Choose an inst... | [
"0.73312354",
"0.73238367",
"0.62579465",
"0.61847156",
"0.6181139",
"0.6167246",
"0.5979625",
"0.59451413",
"0.58857286",
"0.5849709",
"0.5801913",
"0.57791424",
"0.5761157",
"0.57333684",
"0.5713015",
"0.5706526",
"0.5663359",
"0.5656504",
"0.55967057",
"0.5560405",
"0.5547... | 0.7763613 | 0 |
Ask the user to choose one stopped instance | def _choose_among_stopped_instances(self):
instances = self.compute.get_not_running_instances_ids()
# No instances
if not instances:
print 'You do not have any instances!'
return None
# List the name of the instances
print 'Choose an instance:'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _choose_among_running_instances(self):\n\n instances = self.compute.get_running_instances_ids()\n\n # No instances\n if not instances:\n print 'You do not have any running instances!'\n return None\n\n # List the name of the instances\n print 'Choose an ... | [
"0.7413727",
"0.7075978",
"0.6265056",
"0.62350225",
"0.6169538",
"0.5851495",
"0.58469385",
"0.5749903",
"0.5716171",
"0.5652272",
"0.5642341",
"0.5590312",
"0.55365413",
"0.5526076",
"0.5525531",
"0.5506383",
"0.5448957",
"0.5398896",
"0.5356763",
"0.52930033",
"0.5262115",... | 0.8161445 | 0 |
Ask the user to choose an available volume | def _choose_among_available_volumes(self):
volumes = self.compute.get_available_volumes_ids()
# No instances
if not volumes:
print 'You do not have any available volumes!'
return None
# List the name of the instances
print 'Choose a volume:'
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _choose_among_used_volumes(self):\n\n volumes = self.compute.get_used_volumes_ids()\n\n # No instances\n if not volumes:\n print 'You do not have any used volumes!'\n return None\n\n # List the name of the instances\n print 'Choose a volume:'\n fo... | [
"0.6655224",
"0.65141517",
"0.63322014",
"0.61468875",
"0.61278677",
"0.6078939",
"0.6045884",
"0.6009745",
"0.59924775",
"0.594599",
"0.59088606",
"0.59042",
"0.5901506",
"0.58802724",
"0.5874152",
"0.5873146",
"0.58494675",
"0.5837534",
"0.5836003",
"0.58232427",
"0.5822905... | 0.6961525 | 0 |
Ask the user to choose an used volume | def _choose_among_used_volumes(self):
volumes = self.compute.get_used_volumes_ids()
# No instances
if not volumes:
print 'You do not have any used volumes!'
return None
# List the name of the instances
print 'Choose a volume:'
for i, v in enumer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _choose_among_available_volumes(self):\n\n volumes = self.compute.get_available_volumes_ids()\n\n # No instances\n if not volumes:\n print 'You do not have any available volumes!'\n return None\n\n # List the name of the instances\n print 'Choose a volum... | [
"0.6707448",
"0.6390336",
"0.6348588",
"0.6309887",
"0.62393486",
"0.61483634",
"0.61318976",
"0.61249876",
"0.6119035",
"0.60851866",
"0.60461193",
"0.6021429",
"0.59837437",
"0.59562814",
"0.5935449",
"0.5935449",
"0.5935449",
"0.59306705",
"0.5927265",
"0.5906751",
"0.5896... | 0.6921604 | 0 |
List (print) the EC2 instances | def list_instances(self):
print '# AWS EC2 instances'
self.compute.list_instances() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_instances():\n print(str_sep)\n print(\"Listing EC2 instances from [{}] region.\".format(SESSION.region_name))\n print(\"{:20s}{:15s}{:10s}{}\".format(\"ID\", \"TYPE\", \"STATE\", \"NAME\"))\n print(str_sep)\n\n try:\n for instance in EC2_MANAGER.list_instances():\n # get ... | [
"0.8685158",
"0.8134876",
"0.7839257",
"0.7732988",
"0.768987",
"0.765721",
"0.7422266",
"0.73837346",
"0.738019",
"0.7235557",
"0.7216362",
"0.7206594",
"0.7197218",
"0.71892095",
"0.71880347",
"0.7167213",
"0.71258837",
"0.7125404",
"0.7103951",
"0.7100956",
"0.708605",
"... | 0.9023498 | 0 |
List (print) the running EC2 instances | def list_running_instances(self):
print '# Running AWS EC2 instances'
self.compute.list_running_instances() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_instances(self):\n print '# AWS EC2 instances'\n self.compute.list_instances()",
"def list_instances():\n print(str_sep)\n print(\"Listing EC2 instances from [{}] region.\".format(SESSION.region_name))\n print(\"{:20s}{:15s}{:10s}{}\".format(\"ID\", \"TYPE\", \"STATE\", \"NAME\"))... | [
"0.8954593",
"0.8475898",
"0.78454655",
"0.7655982",
"0.7580032",
"0.75376797",
"0.741361",
"0.7245549",
"0.7218848",
"0.71418124",
"0.7124448",
"0.7121767",
"0.7078368",
"0.7067451",
"0.7066132",
"0.70264196",
"0.7016414",
"0.69694686",
"0.6958187",
"0.69378376",
"0.69358754... | 0.8686558 | 1 |
Detail a given EC2 running instance The instance id is asked to the user | def detail_running_instance(self):
instance_id = self._choose_among_running_instances()
# Exit option
if not instance_id:
print 'Operation cancelled'
return
# Print the details
print '# Details of the "%s" instance' % instance_id
self.compute.de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def describe_instance(instance_id):\n # Instantiate the service resource object\n ec2_resource = session.resource('ec2', region_name=region)\n try:\n # Describe an instance\n instance = ec2_resource.Instance(instance_id)\n print('\\nInstance Id: ' + instance_id)\n print('I... | [
"0.78466356",
"0.73414147",
"0.7093406",
"0.7090001",
"0.68222576",
"0.6783114",
"0.66420054",
"0.6511005",
"0.649048",
"0.64746976",
"0.64403975",
"0.6409867",
"0.63910794",
"0.63681906",
"0.6364402",
"0.6344418",
"0.6313384",
"0.6279237",
"0.6267937",
"0.62498564",
"0.62101... | 0.7481309 | 1 |
Create an EC2 instance given the OS The user will be asked to choose between Windows or Linux | def create_instance_by_os(self):
print '# Start a new instance based on the OS'
# Choose between linux or windows
is_linux = True
while True:
os = raw_input('Enter the OS (windows/linux or empty to cancel): ')
# Cancel
if not os:
pri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createInstance(ec2,ami,nb_nodes,placement,instance_type,key,sg,user_data=None):\n\n reservation = ec2.run_instances(ami,min_count=nb_nodes,max_count=nb_nodes,placement = placement,key_name=key,security_groups=[sg],instance_type=instance_type,user_data=user_data)\n instance = reservation.instances[0]\n ... | [
"0.7112136",
"0.68605405",
"0.65974665",
"0.656183",
"0.65232134",
"0.65207905",
"0.6295957",
"0.6276715",
"0.62366116",
"0.62254965",
"0.62169397",
"0.6215981",
"0.6160839",
"0.61591357",
"0.61518484",
"0.6142052",
"0.6102039",
"0.6092225",
"0.60879654",
"0.60726446",
"0.604... | 0.803839 | 0 |
Stop all the EC2 instances | def stop_all_instances(self):
print '# Stopping all the instances'
number = self.compute.stop_all_instances()
print '%d instances were stopped' % number | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self, aws_tags: List[Dict]) -> None:\n for instance_arn in self.tag_api.get_resources(\"ec2:instance\", aws_tags):\n instance_id = instance_arn.split(\"/\")[-1]\n try:\n if not self.asg.describe_auto_scaling_instances(\n InstanceIds=[instance_... | [
"0.80661106",
"0.78416044",
"0.7770538",
"0.76056653",
"0.75015163",
"0.7428186",
"0.7423569",
"0.7338515",
"0.7267911",
"0.7160578",
"0.7159199",
"0.7147509",
"0.69454277",
"0.6943702",
"0.6860941",
"0.68560904",
"0.6803914",
"0.67757475",
"0.6771662",
"0.67619",
"0.6760722"... | 0.8161892 | 0 |
Stop a certain instance The instance ID will be asked to the user | def stop_instance(self):
instance_id = self._choose_among_running_instances()
# Cancel
if not instance_id:
print 'Operation cancelled'
return
print '# Stopping the instance "%s"' % instance_id
self.compute.stop_instance(instance_id)
print 'The in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_instance(InstanceId=None, Force=None):\n pass",
"def stop_instance(instance_id):\n # Instantiate the service resource object\n ec2_resource = session.resource('ec2', region_name=region)\n try:\n # Stop an instance\n response = ec2_resource.Instance(instance_id).stop(DryRun=Fals... | [
"0.83348054",
"0.822144",
"0.7949099",
"0.77721786",
"0.7509467",
"0.7411322",
"0.7342773",
"0.73260367",
"0.72915834",
"0.7276886",
"0.72549224",
"0.72458875",
"0.7214738",
"0.7049063",
"0.7026452",
"0.69632554",
"0.69612324",
"0.68873054",
"0.6869498",
"0.6835195",
"0.68159... | 0.83298826 | 1 |
Start an stopped instance The instance id wil be asked to the user | def start_instance(self):
instance_id = self._choose_among_stopped_instances()
# Cancel
if not instance_id:
print 'Operation cancelled'
return
print '# Starting the instance "%s"' % instance_id
if self.compute.start_instance(instance_id):
pri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_instance(InstanceId=None):\n pass",
"def start_instance(instance_id):\n # Instantiate the service resource object\n ec2_resource = session.resource('ec2', region_name=region)\n try:\n # Start an instance\n response = ec2_resource.Instance(instance_id).start(DryRun=False)\n ... | [
"0.77406687",
"0.7394557",
"0.69855464",
"0.69245553",
"0.6719281",
"0.67054856",
"0.67014045",
"0.65921193",
"0.6582727",
"0.65723014",
"0.6555857",
"0.6545913",
"0.651672",
"0.6385068",
"0.6359116",
"0.63164145",
"0.6295009",
"0.6273814",
"0.62709045",
"0.61745346",
"0.6171... | 0.7646898 | 1 |
List (print) all the volumes | def list_volumes(self):
print '# Listing existing volumes'
self.compute.list_volumes() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_asm_volumes(self):\n sql = \"select NAME from v$asm_diskgroup_stat ORDER BY 1\"\n self.cur.execute(sql)\n res = self.cur.fetchall()\n key = ['{#ASMVOLUME}']\n lst = []\n for i in res:\n d = dict(zip(key, i))\n lst.append(d)\n print(jso... | [
"0.80436873",
"0.7764808",
"0.7590659",
"0.75419503",
"0.7517373",
"0.7301277",
"0.72656804",
"0.7239778",
"0.722382",
"0.72186816",
"0.71733505",
"0.7154594",
"0.7012045",
"0.6987291",
"0.69027334",
"0.68525237",
"0.6819813",
"0.6786619",
"0.6753734",
"0.6687461",
"0.6674284... | 0.8437514 | 0 |
Make a dictionary from the star file, key = 'class ', value = list[micrograph ] | def aclass_dict(micrograph_star):
# get the class number as a list
class_list = []
for line in micrograph_star:
if len(line.split()) > 2:
class_list.append(line.split()[6])
class_list = list(set(class_list))
# make the class_dict
class_dict = {}
for aclass in class_lis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_classes_from_file(self, class_file):\n items = []\n with open(class_file) as f:\n for cl in f.readlines():\n # c:code, d:description\n item = [{'value': c, 'text': f'{c}: ' + d.replace('\\n','')} for c, d in [cl.split(',')]]\n items+=it... | [
"0.6050446",
"0.60270834",
"0.56219846",
"0.562041",
"0.55898035",
"0.55807143",
"0.55349976",
"0.5500859",
"0.5495069",
"0.54794693",
"0.54678434",
"0.5459361",
"0.54553705",
"0.5414836",
"0.5407407",
"0.53714395",
"0.53606534",
"0.53194445",
"0.5286147",
"0.5281463",
"0.527... | 0.808465 | 0 |
Returns event intervals for specified `name` and `task` Name here implies `section` or `counter` name. | def event_intervals(self, name=None, task=None,
interval=None, match_exact=True):
if name is None:
intervals = \
IntervalList(sorted_items(self._tmw_intervals_by_name.values()))
elif isinstance(name, string_types):
if match_exact:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frame_intervals(self, task=None, interval=None):\n names = ['animator:'] + UI_THREAD_DRAW_NAMES + RENDER_THREAD_DRAW_NAMES\n return self.event_intervals(name=names, task=task,\n interval=interval, match_exact=False)",
"def get_tasks_ids(self, name=None):\n\n ... | [
"0.5835097",
"0.5724242",
"0.5594315",
"0.54250634",
"0.5367838",
"0.53254664",
"0.52327496",
"0.5148218",
"0.5067933",
"0.49952528",
"0.4971878",
"0.48637992",
"0.48349625",
"0.48186946",
"0.47934702",
"0.4789053",
"0.47088632",
"0.46823967",
"0.46184328",
"0.4609138",
"0.45... | 0.7265889 | 0 |
Returns intervals a frame from render thread was processed. | def render_frame_intervals(self, task=None, interval=None):
return self.event_intervals(name=RENDER_THREAD_DRAW_NAMES, task=task,
interval=interval, match_exact=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frames(self):\n return self._frames",
"def get_frame_time(self):\n return self.get_timings().frame_time",
"def get_frame_clock(self): # real signature unknown; restored from __doc__\n pass",
"def captured_frames(self):\n return self._captured_frames",
"def get_frames(self):\... | [
"0.6350662",
"0.6295398",
"0.6266249",
"0.6143987",
"0.6121702",
"0.6075664",
"0.60559654",
"0.6034855",
"0.59660757",
"0.5928639",
"0.5918026",
"0.5916097",
"0.5895267",
"0.58773875",
"0.5867642",
"0.58481395",
"0.58152115",
"0.5806984",
"0.58036256",
"0.57969207",
"0.576773... | 0.64448464 | 0 |
Returns intervals a frame from UI thread was processed. | def ui_frame_intervals(self, task=None, interval=None):
return self.event_intervals(name=UI_THREAD_DRAW_NAMES, task=task,
interval=interval, match_exact=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frame_intervals(self, task=None, interval=None):\n names = ['animator:'] + UI_THREAD_DRAW_NAMES + RENDER_THREAD_DRAW_NAMES\n return self.event_intervals(name=names, task=task,\n interval=interval, match_exact=False)",
"def render_frame_intervals(self, task=Non... | [
"0.63190186",
"0.6236168",
"0.61133915",
"0.6058052",
"0.5944484",
"0.5941922",
"0.5881279",
"0.58722425",
"0.58456933",
"0.5781916",
"0.5739827",
"0.57152134",
"0.57075226",
"0.56388026",
"0.56256515",
"0.5613554",
"0.56118697",
"0.55820066",
"0.54994404",
"0.5483587",
"0.54... | 0.6766843 | 0 |
Since SurfaceFlinger(SF) in Android updates the framebuffer only when there's work to be done. Measuring FPS in traditional sense as frames / seconds would be incorrect as time might include intervals when no screen updates occurred. To account for this, we use SF Vsync which is set to 0 when SurfaceFlinger has work to... | def framerate(self, interval=None):
total_frames = 0.0
# These are times when SF begins compositing.
vsync_events = self.event_intervals(name='VSYNC-sf', interval=interval)
if not vsync_events:
vsync_events = self.event_intervals(name='VSYNC', interval=interval)
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_fps(self):\n time_difference = self.time_array[-1] - self.time_array[0]\n time_difference_in_seconds = time_difference.to_sec()\n if time_difference_in_seconds == 0:\n pass\n self.fps = self.buffer_size / time_difference_in_seconds\n rospy.loginfo(\"[Eule... | [
"0.6668513",
"0.61614895",
"0.6137861",
"0.60783404",
"0.6046331",
"0.60180646",
"0.6015373",
"0.5965686",
"0.59367114",
"0.59102696",
"0.5899993",
"0.58347744",
"0.5731469",
"0.5689734",
"0.55668485",
"0.55627173",
"0.55482215",
"0.553777",
"0.5526215",
"0.5490262",
"0.53899... | 0.78960985 | 0 |
Returns list of intervals when a jank (missed frame) occurred. | def jank_intervals(self, interval=None):
missedFrames = self.event_intervals('FrameMissed', interval=interval)
return IntervalList(filter(lambda x:x.value==1, missedFrames)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def candle_intervals(self):\n pass",
"def calculate_intervals(tick_times: List[float]) -> List[float]:\n return [tick_times[i] - tick_times[i - 1] for i in range(1, len(tick_times))]",
"def dropped_frames(self):\n # type: () -> int\n return self._dropped_frames",
"def getIntrons(self)... | [
"0.5913416",
"0.5804972",
"0.56494457",
"0.5641811",
"0.5607846",
"0.55438244",
"0.5464397",
"0.5447493",
"0.541252",
"0.54121006",
"0.54103",
"0.53855985",
"0.53515875",
"0.53275687",
"0.5318675",
"0.5315721",
"0.5306424",
"0.5305439",
"0.5303692",
"0.5252823",
"0.520765",
... | 0.79757136 | 0 |
Returns number of janks (missed frame) within interval. | def num_janks(self, interval=None):
return len(self.jank_intervals(interval=interval)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jankrate(self, interval=None):\n try:\n return round(self.num_janks(interval=interval) / self.present_duration(interval=interval), 1)\n except ZeroDivisionError:\n return 0.0",
"def jank_intervals(self, interval=None):\n missedFrames = self.event_intervals('FrameMis... | [
"0.6568541",
"0.61695075",
"0.6039369",
"0.59244394",
"0.59195894",
"0.59130406",
"0.5842135",
"0.5823727",
"0.58052087",
"0.5759005",
"0.5667941",
"0.5667941",
"0.5654426",
"0.5644131",
"0.5642725",
"0.56422305",
"0.5639742",
"0.5639491",
"0.5623889",
"0.56237584",
"0.561066... | 0.7892927 | 0 |
Returns number of janks (missed frame) per second within interval. | def jankrate(self, interval=None):
try:
return round(self.num_janks(interval=interval) / self.present_duration(interval=interval), 1)
except ZeroDivisionError:
return 0.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_janks(self, interval=None):\n return len(self.jank_intervals(interval=interval))",
"def num_frames(self):\n return self._first_rgb.shape[1]",
"def get_total_frames(self) -> int:\n return self.num_frames",
"def times(self) -> int:\n return self._channel_arrays[0].shape[self.tim... | [
"0.7543728",
"0.6045018",
"0.59952563",
"0.5964167",
"0.59383506",
"0.59273905",
"0.58509415",
"0.5850528",
"0.5845461",
"0.58351386",
"0.579948",
"0.57471603",
"0.57294184",
"0.5726754",
"0.5726694",
"0.57095593",
"0.5674112",
"0.5640191",
"0.56383294",
"0.55924916",
"0.5588... | 0.6945059 | 1 |
Start time estimated as first time we ever saw (i.e. scheduled on CPU) the launched task. | def _start_launch_time(self, launched_event):
if launched_event:
interval = Interval(0, launched_event.timestamp)
return self._trace.cpu.task_intervals(task=launched_event.task,
interval = interval)[0].interval.start | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_time(self) -> float:\r\n ...",
"def start_time(self):\n pass",
"def start_time(self) -> float:\n return self._start_time",
"def getStartTime(self):\n assert not self.isWaitingToStart(), \"Too early to tell: %s\" % self\n return \"%s\" % self.__jobInfo.startTime",
"d... | [
"0.7574514",
"0.7435856",
"0.7330056",
"0.72312284",
"0.7228733",
"0.7219493",
"0.7141052",
"0.71377635",
"0.7076516",
"0.7048836",
"0.7000251",
"0.6973097",
"0.6969327",
"0.696228",
"0.696228",
"0.696228",
"0.696228",
"0.696228",
"0.696228",
"0.696228",
"0.696228",
"0.6920... | 0.8108096 | 0 |
Get agent by name | def get(self, name):
validate_inputs({'name': name})
return get_storage_manager().get(models.Agent, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_agent_name(self):\n result = self.runner.invoke(\n cli,\n [*CLI_LOG_OPTION, \"config\", \"get\", \"agent.agent_name\"],\n standalone_mode=False,\n catch_exceptions=False,\n )\n assert result.exit_code == 0\n assert result.output =... | [
"0.7130851",
"0.6230404",
"0.6048167",
"0.6006651",
"0.5870144",
"0.5770241",
"0.57700723",
"0.5706711",
"0.57012594",
"0.56749845",
"0.5654736",
"0.56485707",
"0.5647193",
"0.558511",
"0.5584789",
"0.55810803",
"0.5572171",
"0.55225843",
"0.5484141",
"0.54815894",
"0.5450483... | 0.7586844 | 0 |
Create a new agent or update its state if exists | def put(self, name):
request_dict = get_json_and_verify_params({
'node_instance_id': {'type': unicode},
'state': {'type': unicode}
})
validate_inputs({'name': name})
state = request_dict.get('state')
self._validate_state(state)
try:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _register_agent(self, agent, agent_avatar: AgentBody):\n\n # Random seed for agent between 1 and 10000000, might need to be adjusted still\n agent_seed = self.__rnd_gen.randint(1, 1000000)\n\n # check if the agent can be succesfully placed at that location\n self.__validate_obj_plac... | [
"0.63911676",
"0.634182",
"0.629022",
"0.6076828",
"0.5981401",
"0.59083194",
"0.58926135",
"0.5806879",
"0.5754334",
"0.57336485",
"0.57117426",
"0.56722033",
"0.5655055",
"0.56291324",
"0.5626939",
"0.55930084",
"0.5581793",
"0.5577333",
"0.55368817",
"0.5518555",
"0.551188... | 0.68219554 | 0 |
Add a Handle asset to the adversary. | def add_handle_asset(self, value):
return self.add_asset('HANDLE', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_handle(self, handle):\n\n self.pool.append(handle)",
"def add_handout(self, asset_name):\r\n self._handouts.append(asset_name)",
"def addAsset(self, name, asset):\n self.__assets[name] = asset\n return True",
"def add_tag(self, transaction, media_handle, tag_handle):\n ... | [
"0.72719395",
"0.6265543",
"0.6127872",
"0.60960156",
"0.5908841",
"0.5781675",
"0.5750709",
"0.5716834",
"0.563507",
"0.5635042",
"0.5624101",
"0.5616119",
"0.554554",
"0.55400205",
"0.5443238",
"0.54349756",
"0.5426446",
"0.53440446",
"0.53244644",
"0.52917016",
"0.5271356"... | 0.7584645 | 0 |
Add a phone asset to the adversary. | def add_phone_asset(self, value):
return self.add_asset('PHONE', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_asset(self, asset_name):\r\n self._assets.extend(asset_name)",
"def phone(self, phone):\n\n self._phone = phone",
"def phone(self, phone):\n\n self._phone = phone",
"def phone(self, phone):\n\n self._phone = phone",
"def phone(self, phone):\n\n self._phone = phone... | [
"0.5725073",
"0.55942494",
"0.55942494",
"0.55942494",
"0.55942494",
"0.55942494",
"0.5503296",
"0.5492854",
"0.54826987",
"0.5482024",
"0.5440577",
"0.5427534",
"0.5373172",
"0.5361251",
"0.53341156",
"0.5293473",
"0.5267561",
"0.5259339",
"0.524951",
"0.5226366",
"0.5225728... | 0.7101702 | 0 |
Add a URL asset to the adversary. | def add_url_asset(self, value):
return self.add_asset('URL', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_url(self, url):\n self.queue.put(url)",
"def add_link (self, src, dst):\n raise NotImplementedError",
"async def add(self, ctx, url, name):\n async with aiohttp.ClientSession() as session:\n async with session.get(url) as resp:\n data = await resp.read()\n ... | [
"0.67932934",
"0.652156",
"0.6461821",
"0.64571977",
"0.6455303",
"0.64421105",
"0.633815",
"0.6309748",
"0.6232123",
"0.61788785",
"0.61086047",
"0.6106751",
"0.60589206",
"0.60515255",
"0.59763986",
"0.59452015",
"0.5936189",
"0.58758444",
"0.58670616",
"0.5857115",
"0.5842... | 0.7426201 | 0 |
Get specific Adversary asset type from API | def asset(self, asset_id, asset_type, action='GET'):
if not self.can_update():
self._handle_error(910, [self.type])
asset_methods = {
'handle': self.tc_requests.adversary_handle_asset,
'phone': self.tc_requests.adversary_phone_asset,
'url': self.tc_reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asset_type(self, **kwargs):\n\n return self.api_request(self._get_method_fullname(\"asset_type\"), kwargs)",
"def _get(self) -> json_api.generic.Metadata:\n api_endpoint = ApiEndpoints.assets.fields\n return api_endpoint.perform_request(http=self.auth.http, asset_type=self.parent.ASSET_T... | [
"0.6318828",
"0.63060737",
"0.60831237",
"0.60739774",
"0.6061961",
"0.5915308",
"0.5778964",
"0.5778964",
"0.5712838",
"0.5691071",
"0.55540186",
"0.55070484",
"0.5468222",
"0.5449952",
"0.5360277",
"0.5352107",
"0.5230858",
"0.5218395",
"0.52064335",
"0.519413",
"0.51613396... | 0.6370427 | 0 |
Delete the asset with the provided asset_id. | def delete_asset(self, asset_id, asset_type):
return self.asset(asset_id, asset_type=asset_type, action='DELETE') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_url_asset(self, asset_id):\n return self.delete_asset(asset_id, 'URL')",
"def delete_handle_asset(self, asset_id):\n return self.delete_asset(asset_id, 'HANDLE')",
"def delete_phone_asset(self, asset_id):\n return self.delete_asset(asset_id, 'PHONE')",
"def delete(self, asset_... | [
"0.74729943",
"0.7246753",
"0.69871473",
"0.65593284",
"0.6440845",
"0.62584275",
"0.6234925",
"0.61335707",
"0.6087217",
"0.6081945",
"0.6062495",
"0.6017092",
"0.5817338",
"0.57971597",
"0.57559264",
"0.57495433",
"0.5735357",
"0.57037294",
"0.5631497",
"0.5613766",
"0.5608... | 0.8115228 | 0 |
Delete the handle asset with the passed in id | def delete_handle_asset(self, asset_id):
return self.delete_asset(asset_id, 'HANDLE') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, _id):",
"def delete_url_asset(self, asset_id):\n return self.delete_asset(asset_id, 'URL')",
"def delete(self, req, id):\n context = None\n try:\n db_api.image_destroy(context, id)\n except exception.NotFound:\n return exc.HTTPNotFound()",
"d... | [
"0.69067293",
"0.67395705",
"0.67243016",
"0.667569",
"0.6663656",
"0.66624874",
"0.66511434",
"0.6590958",
"0.65704906",
"0.6553715",
"0.65452945",
"0.6521744",
"0.6521466",
"0.64901394",
"0.6475231",
"0.6463747",
"0.64565384",
"0.64330906",
"0.6426006",
"0.6403002",
"0.6397... | 0.88750905 | 0 |
Delete the phone asset with the passed in id | def delete_phone_asset(self, asset_id):
return self.delete_asset(asset_id, 'PHONE') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, _id):",
"def delete(self, resource, id):\n self.request('/' + resource + '/' + str(id), 'DELETE')\n return True",
"def delete(self, id):\n\n ns.abort(404, 'This API is not supported yet.')",
"def delete(self, id):\n raise NotImplementedError",
"def delete(self) ... | [
"0.70042676",
"0.6886521",
"0.6831829",
"0.67502534",
"0.66984457",
"0.66818535",
"0.66647756",
"0.6660624",
"0.6656917",
"0.65741885",
"0.649827",
"0.6489182",
"0.64801604",
"0.6471101",
"0.64628196",
"0.63978475",
"0.63930076",
"0.6368251",
"0.6368251",
"0.6368251",
"0.6368... | 0.8706615 | 0 |
Delete the url asset with the passed in id | def delete_url_asset(self, asset_id):
return self.delete_asset(asset_id, 'URL') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __Delete(self, url, id = None):\n\n conn = self.__GetConnection()\n if (id != None):\n url += \"/\" + str(id)\n conn.request(\"DELETE\", url, \"\", self.__MakeHeaders(True))\n response = conn.getresponse()\n self.__CheckResponse(response)",
"def delete(self, _id)... | [
"0.7567766",
"0.7203758",
"0.712468",
"0.7097657",
"0.7070156",
"0.70602894",
"0.6884165",
"0.68797266",
"0.68733",
"0.6866615",
"0.68551326",
"0.68472385",
"0.6839838",
"0.6823005",
"0.6816135",
"0.6811832",
"0.68054557",
"0.6770216",
"0.67586267",
"0.6758277",
"0.6753747",
... | 0.84215575 | 0 |
Get the asset with the provided asset_id & asset_type. | def get_asset(self, asset_id, asset_type):
return self.asset(asset_id, asset_type=asset_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_asset(self, asset_id):\n text, code = ApiClient(self._config, 'assets/' + asset_id).get()\n return Asset.deserialize(text)",
"def get_asset(self, asset_id):\n endpoint = '/assets/{}'.format(asset_id)\n return self._api_call('get', endpoint)",
"def asset(self, asset_id, asset_type, a... | [
"0.7914934",
"0.7901728",
"0.75574785",
"0.7353109",
"0.7211423",
"0.70776683",
"0.707332",
"0.6760442",
"0.6684911",
"0.6505347",
"0.6489349",
"0.64671385",
"0.63019156",
"0.62640876",
"0.625495",
"0.625495",
"0.61809045",
"0.61496",
"0.59755635",
"0.5967861",
"0.5857224",
... | 0.91324383 | 0 |
Get the handle asset with the passed in id | def get_handle_asset(self, asset_id):
return self.get_asset(asset_id, 'HANDLE') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_asset(self, asset_id):\n endpoint = '/assets/{}'.format(asset_id)\n return self._api_call('get', endpoint)",
"def _get_image(self, asset_id):\n try:\n return self.app.module_map.uploader.get(asset_id)\n except AssetNotFound:\n return None\n except Exceptio... | [
"0.70908076",
"0.69447607",
"0.6808168",
"0.6650068",
"0.6532557",
"0.6532282",
"0.6431671",
"0.6348124",
"0.6248202",
"0.6170924",
"0.61310107",
"0.6119488",
"0.6116648",
"0.6098846",
"0.60746133",
"0.60710746",
"0.6030209",
"0.6010597",
"0.5991148",
"0.59439325",
"0.5866047... | 0.8778855 | 0 |
Get the phone asset with the passed in id | def get_phone_asset(self, asset_id):
return self.get_asset(asset_id, 'PHONE') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_asset(self, asset_id):\n endpoint = '/assets/{}'.format(asset_id)\n return self._api_call('get', endpoint)",
"def get_asset(self, asset_id):\n text, code = ApiClient(self._config, 'assets/' + asset_id).get()\n return Asset.deserialize(text)",
"def getItem(self, id):\n path = ... | [
"0.6800033",
"0.6385424",
"0.6134431",
"0.61205536",
"0.6080133",
"0.59958726",
"0.5989127",
"0.59726167",
"0.5938593",
"0.589432",
"0.58850074",
"0.58735317",
"0.58695924",
"0.5851934",
"0.5848409",
"0.5826806",
"0.5805052",
"0.57644814",
"0.5744167",
"0.5718924",
"0.5718649... | 0.8484552 | 0 |
Get the url asset with the passed in id | def get_url_asset(self, asset_id):
return self.get_asset(asset_id, 'URL') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_asset(self, asset_id):\n endpoint = '/assets/{}'.format(asset_id)\n return self._api_call('get', endpoint)",
"def get_by_id(id: UUID) -> UrlModel:\n url = UrlModel.query.filter_by(id=id).first_or_404()\n\n return url",
"def get_asset(self, asset_id):\n text, code = ApiClient(... | [
"0.7117298",
"0.6588282",
"0.6444789",
"0.642756",
"0.6422066",
"0.63971066",
"0.63964444",
"0.62739843",
"0.62609327",
"0.62437016",
"0.6228531",
"0.6162225",
"0.6123414",
"0.60973865",
"0.6085558",
"0.60849786",
"0.606551",
"0.6038394",
"0.60178864",
"0.601603",
"0.6014131"... | 0.83747166 | 0 |
Return all of the handle assets | def handle_assets(self):
return self.assets(asset_type='HANDLE') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assets():",
"def returnAllAssets(self):\n return self.__assets",
"def assets():\n pass",
"def getAssets(self):\n return self.assets",
"def assets(self):\n return self._assets.values()",
"def get_all_assets(self):\n return c4d.documents.GetAllAssets(self._document, False, ''... | [
"0.71726817",
"0.68086195",
"0.6718517",
"0.66561484",
"0.6643501",
"0.65299517",
"0.63601494",
"0.6312885",
"0.6121192",
"0.6073097",
"0.6004909",
"0.5978438",
"0.591822",
"0.5915304",
"0.5890802",
"0.5866422",
"0.5828185",
"0.5782407",
"0.5778089",
"0.57529914",
"0.57443565... | 0.84628445 | 0 |
Return all of the phone assets | def phone_assets(self):
return self.assets(asset_type='PHONE') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_assets(self):\n return c4d.documents.GetAllAssets(self._document, False, '')",
"def returnAllAssets(self):\n return self.__assets",
"def getAssets(self):\n return self.assets",
"def get_list_assets():\n headers = {'X-CoinAPI-Key': os.environ.get('COIN_API_KEY', '')}\n r = r... | [
"0.6741875",
"0.66295177",
"0.64593947",
"0.6341789",
"0.6338924",
"0.62795734",
"0.60422313",
"0.6029229",
"0.5980535",
"0.59802115",
"0.58091706",
"0.5757311",
"0.5744994",
"0.57162285",
"0.56765515",
"0.56604904",
"0.564866",
"0.5614903",
"0.5594506",
"0.5583894",
"0.55418... | 0.8454118 | 0 |
Return all of the url assets | def url_assets(self):
return self.assets(asset_type='URL') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getURLs():",
"def get_urls():\r\n return []",
"def assets():",
"def urls(self) -> list[str]:\r\n ...",
"def get_urls(type, assets=\"default\"):\n return [\n default_asset_cache.get_url(asset)\n for asset in StaticAsset.load(type, assets)\n ]",
"def ge... | [
"0.7462337",
"0.7460199",
"0.74512386",
"0.74139196",
"0.73395413",
"0.7084657",
"0.70750874",
"0.69541717",
"0.6926014",
"0.6827585",
"0.68090737",
"0.6759235",
"0.6714712",
"0.66763306",
"0.66452646",
"0.65941185",
"0.65488195",
"0.64891714",
"0.645243",
"0.64495164",
"0.64... | 0.8349477 | 0 |
A function to undistort the distorted images in a folder. | def undistort(basedir, img_extension, output_dir, output_prefix, calibration, distortion, output_image_shape=(640, 480), scaling_param=1):
search = os.path.join(basedir, '*'+img_extension)
img_paths = glob.glob(search)
img_paths.sort()
print("Number of Images: ", len(img_paths))
maxlen = len(img_pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_undistort():\n # read test images\n all_test_images = os.listdir('test_images')\n test_images = []\n for name in all_test_images:\n if name.endswith(\".jpg\"):\n test_images.append(name)\n # apply distortion correction on test images\n undistort_images(test_images, './... | [
"0.8213168",
"0.7284235",
"0.72337604",
"0.7060535",
"0.6990136",
"0.6985227",
"0.6975924",
"0.69152296",
"0.6569945",
"0.62887996",
"0.6255778",
"0.61799085",
"0.61173475",
"0.593172",
"0.5870097",
"0.5704076",
"0.5546572",
"0.55459356",
"0.55330724",
"0.5527427",
"0.5504683... | 0.7427232 | 1 |
Test that no sensors in deconz results in no sensor entities. | async def test_no_binary_sensors(hass, aioclient_mock):
await setup_deconz_integration(hass, aioclient_mock)
assert len(hass.states.async_all()) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_sensor_without_unit(client, sensor_entities) -> None:\n body = await generate_latest_metrics(client)\n\n assert (\n 'sensor_state{domain=\"sensor\",'\n 'entity=\"sensor.trend_gradient\",'\n 'friendly_name=\"Trend Gradient\"} 0.002' in body\n )\n\n assert (\n '... | [
"0.69611347",
"0.6781437",
"0.6709309",
"0.6360453",
"0.63589764",
"0.6296304",
"0.6296304",
"0.62603533",
"0.62527657",
"0.6221658",
"0.62147963",
"0.61684513",
"0.6140223",
"0.6115561",
"0.6073571",
"0.6066095",
"0.60566604",
"0.6052553",
"0.60229397",
"0.59628767",
"0.5941... | 0.7260665 | 0 |
Test that adding a new binary sensor works. | async def test_add_new_binary_sensor(hass, aioclient_mock, mock_deconz_websocket):
event_added_sensor = {
"t": "event",
"e": "added",
"r": "sensors",
"id": "1",
"sensor": {
"id": "Presence sensor id",
"name": "Presence sensor",
"type": "ZHA... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_sensor_defaults_binary(hass: HomeAssistant) -> None:\n assert await async_setup_component(\n hass,\n \"sensor\",\n {\n \"sensor\": [\n {\n \"platform\": \"statistics\",\n \"name\": \"test\",\n ... | [
"0.70032024",
"0.6901163",
"0.68574667",
"0.6848556",
"0.66131777",
"0.6590479",
"0.634464",
"0.6333184",
"0.6317183",
"0.62723935",
"0.6238028",
"0.623732",
"0.623732",
"0.61875206",
"0.61809593",
"0.61583835",
"0.6148876",
"0.61349654",
"0.61256504",
"0.6102588",
"0.6078365... | 0.769578 | 0 |
close the socket and remove the file | def close_client_socket(client_socket, client_socket_file):
client_socket.close()
if os.path.exists(client_socket_file):
os.remove(client_socket_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\r\n self._fileobjclosed = True\r\n self._sockobj.close()",
"def close(self):\r\n self.rfile.close()\r\n self.sock_chan.close()",
"def cleanup(self):\n self._socket.close()\n os.remove(_get_control_socket_path())",
"def __del__(self):\n self.connection... | [
"0.7515783",
"0.73575044",
"0.7349963",
"0.7186087",
"0.7166717",
"0.6988371",
"0.6986388",
"0.6879862",
"0.68531454",
"0.6772425",
"0.6772425",
"0.6772425",
"0.6772425",
"0.6772425",
"0.6772425",
"0.6757314",
"0.6757314",
"0.67505753",
"0.67467415",
"0.6740791",
"0.67257035"... | 0.7450703 | 1 |
Annotates single cell types at each level and adds the result to the object. | def getCellTypes(self):
sc_data = Utils.convertAnnDataToDf(self.sc_data)
try:
self.sc_annot, self.de_dict = Annotate.annotateTree(sc_data, self.refDataset, self.refAnnot)
except:
print("Columns of annotations should be cell type levels. Additionally, higher levels should ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_annotations(annot_tuples, ref_data, annot_type):\n\n for annot in ref_data.annotations.select_type(annot_type):\n annot_begin, annot_end = annot.spans[0]\n annot_tuples.append((annot_begin, annot_end, annot.id))",
"def initTypes(self):\n self.types = [ty.NoneType]*self.numcols()\n for k,row ... | [
"0.53548366",
"0.49283662",
"0.49159172",
"0.48532856",
"0.4844311",
"0.48404062",
"0.48219582",
"0.48180592",
"0.47917625",
"0.47327456",
"0.47157717",
"0.4695715",
"0.46835762",
"0.46732008",
"0.46381748",
"0.4630978",
"0.45994526",
"0.4596766",
"0.4594033",
"0.45796517",
"... | 0.6900952 | 0 |
Finds marker genes and adds the result to the object. | def getMarkerGenes(self):
try:
self.marker_genes = Utils.findMarkers(self.sc_annot, self.de_dict)
except:
print("Please run getCellTypes first to get cell annotations. This step is needed for marker gene finding.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allmarkers(repo):\n for markerdata in repo.obsstore:\n yield marker(repo, markerdata)",
"def collectMarkers(self, ingeno):\n with open(ingeno,'r') as fin:\n for line in fin:\n if line.startswith('#'):\n l = line.strip('#').strip().split()\n ... | [
"0.5793127",
"0.57150245",
"0.5687851",
"0.5483316",
"0.5397726",
"0.5339215",
"0.5312121",
"0.53074116",
"0.5284343",
"0.5267562",
"0.51718825",
"0.51595294",
"0.51243556",
"0.508369",
"0.50633913",
"0.5061443",
"0.5056034",
"0.5050732",
"0.50467813",
"0.5020721",
"0.4991996... | 0.7286202 | 0 |
Writes marker genes to an excel file. Each sheet indicates different levels. | def writeMarkerGenes(self, location):
try:
writer = pd.ExcelWriter(location+"marker_genes.xlsx", engine="xlsxwriter")
for key in self.marker_genes:
self.marker_genes.get(key).to_excel(writer, sheet_name=key)
writer.save()
except:
print("Ple... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_excel(self, filename):\n writer = pd.ExcelWriter(filename)\n self.df_avg.to_excel(writer, 'Simulation')\n self.manager_df.to_excel(writer, 'FleetManagers')\n self.customer_df.to_excel(writer, 'Customers')\n self.transport_df.to_excel(writer, 'Transports')\n write... | [
"0.5928262",
"0.58982015",
"0.58421063",
"0.5730327",
"0.5662606",
"0.5617152",
"0.557254",
"0.5518996",
"0.5494513",
"0.5493021",
"0.5490403",
"0.5479139",
"0.5447389",
"0.5395281",
"0.53894603",
"0.5379124",
"0.53154147",
"0.5310389",
"0.52733517",
"0.5262296",
"0.52478814"... | 0.81966275 | 0 |
Plots tree representation of single cell annotations. | def getTreePlot(self):
try:
Utils.plotTree(self.sc_annot)
except:
print("Please run getCellTypes first to get cell annotations. This step is needed for plotting.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plotTree(self):\n t = self.make(self.tree)\n t.draw()",
"def plot_tree(tree, name):\n graph = pydot.Dot(graph_type='graph')\n tree_graph = pydot.Cluster(\n graph_name=\"Learner Tree\",\n label=\"Learner Tree\",\n fontsize=\"15\",\n )\n graphlegend = pydot.Cluste... | [
"0.68197376",
"0.59498745",
"0.5782144",
"0.5766384",
"0.57036364",
"0.5702009",
"0.5632257",
"0.5629917",
"0.5601988",
"0.5601988",
"0.55770046",
"0.5539725",
"0.55021167",
"0.54975194",
"0.54721516",
"0.5458151",
"0.5425423",
"0.5405625",
"0.5379783",
"0.53536665",
"0.53498... | 0.7746578 | 0 |
Prints Query Results For httpErrors Query | def printError(queryResults):
print (queryResults[1])
# For loop created for the httpErrors array
for results in queryResults[0]:
print (
results[0], "-",
str(results[1]) + "% errors") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_errors():\r\n conn, cur = connect()\r\n query3 = (\"select * from errors where error >1\")\r\n cur.execute(query3)\r\n res3 = cur.fetchall()\r\n conn.close()\r\n print(\"\\nDays with more than 1% of requests lead to errors:\\n\")\r\n for i in range(0, len(res3), 1):\r\n print(... | [
"0.6736217",
"0.64593387",
"0.632152",
"0.63167804",
"0.63110185",
"0.6229107",
"0.6191037",
"0.6138806",
"0.613624",
"0.6113323",
"0.6022598",
"0.5978065",
"0.5972042",
"0.5964749",
"0.59426546",
"0.58535814",
"0.5853011",
"0.5849017",
"0.5840018",
"0.5825729",
"0.5808999",
... | 0.84260356 | 0 |
Override process_record with your mapper | def process_record(self, record):
raise NotImplementedError('Process record needs to be customized') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mapper(record):\n personA = record[0]\n personB = record[1]\n mr.emit_intermediate(personA, personB)",
"def handle_record(self, record):\n raise NotImplementedError",
"def Transform(self, record):\n pass",
"def transform_record(self, pid, record, links_factory=None, **kwargs):\n ... | [
"0.69456196",
"0.6940001",
"0.68277967",
"0.63850415",
"0.6172935",
"0.6161542",
"0.6121411",
"0.61127484",
"0.5994616",
"0.5944488",
"0.5828723",
"0.57904565",
"0.5777248",
"0.5687219",
"0.5642455",
"0.5636709",
"0.5632619",
"0.56293315",
"0.5624392",
"0.5621543",
"0.5617855... | 0.7899032 | 0 |
Copy of qrencode.encode_scaled The original method does not support the standard 4 unit pixel border | def qrcode_scale(qrcode, pixel_size):
version, src_size, im = qrcode
qr_image_size = src_size * pixel_size
padding_size = 4 * pixel_size
final_image_size = (src_size * pixel_size) + (2 * padding_size)
new_img = Image.new("L", (final_image_size, final_image_size), 255)
new_img.pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_scaled(data, size, version=0, level=QR_ECLEVEL_L, hint=QR_MODE_8,\n case_sensitive=True):\n version, src_size, im = encode(data, version, level, hint, case_sensitive)\n if size < src_size:\n size = src_size\n qr_size = (size / src_size) * src_size\n im = im.resize((qr... | [
"0.6628178",
"0.5901082",
"0.5880577",
"0.5856074",
"0.58090234",
"0.56154186",
"0.5561109",
"0.5520228",
"0.55200243",
"0.54664236",
"0.54620045",
"0.544472",
"0.539391",
"0.53541255",
"0.53466356",
"0.53360176",
"0.5328329",
"0.5323346",
"0.52971715",
"0.52537584",
"0.52362... | 0.59873855 | 1 |
Iterate through all the documents. | def iter_documents(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n for this_document in self.documents:\n yield this_document",
"def __iter__(self):\n for document in self.query:\n yield self._to_document(document)",
"def __iter__(self):\n return self.iter_documents()",
"def __iter__(self):\n return self.docs.__i... | [
"0.756131",
"0.7519196",
"0.73756146",
"0.7028327",
"0.6934227",
"0.67785066",
"0.6757482",
"0.6694352",
"0.6692733",
"0.664955",
"0.6616363",
"0.65842587",
"0.65538126",
"0.6528225",
"0.6503124",
"0.6484031",
"0.64438236",
"0.640956",
"0.64088947",
"0.64065766",
"0.6398948",... | 0.8500158 | 0 |
Create a basic search for the value supplied. If fieldname is also supplied, search only for the value in that field. | def query(self, value, fieldname=None, *args, **kwargs):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(field='name', method=IS, value=None):\n def searchPred(db):\n return Result((k, v) for k, v in db.items()\n if field in v and method(v[field], value))\n\n return searchPred",
"def set_search_filter(\n query: BaseQuery,\n obj_model: Model,\n search_fiel... | [
"0.666969",
"0.64892364",
"0.6434192",
"0.6009932",
"0.5974208",
"0.5703867",
"0.56232536",
"0.56202215",
"0.5617161",
"0.5593979",
"0.55536413",
"0.552709",
"0.5507973",
"0.5505467",
"0.54794776",
"0.5471659",
"0.5467763",
"0.5461998",
"0.5449711",
"0.54352003",
"0.542504",
... | 0.66154534 | 1 |
Perform a search. The search should be an instance of multisearch.queries.Search. | def search(self, search):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(self, query):",
"def search(self, search_params):\n\n search_params = search_params._get_params() if isinstance(search_params, SearchParams) else search_params\n\n r = self._create_operation_request(self._url_full, \"search\", method=\"POST\", data=search_params)\n\n return send_s... | [
"0.726705",
"0.72350997",
"0.7127986",
"0.71041954",
"0.69433963",
"0.69397825",
"0.6918522",
"0.68597406",
"0.6766558",
"0.6742335",
"0.67419297",
"0.6725602",
"0.67140645",
"0.67140645",
"0.67140645",
"0.67140645",
"0.67140645",
"0.67140645",
"0.67140645",
"0.6712671",
"0.6... | 0.747983 | 0 |
Create a runner for a script with the contents from a string. Useful for testing short scripts that fit comfortably as an inline string in the test itself, without having to create a separate file for it. | def script_from_string(self, script: str) -> LocalScriptRunner:
hasher = hashlib.md5(bytes(script, "utf-8"))
script_name = hasher.hexdigest()
path = pathlib.Path(self.tmp_script_dir.name, script_name)
aligned_script = textwrap.dedent(script)
path.write_text(aligned_script)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runner():\n return CliRunner()",
"def script_from_filename(self, script_path: str) -> LocalScriptRunner:\n return LocalScriptRunner(str(self.dir_path / script_path))",
"def runner() -> CliRunner:\n return CliRunner()",
"def runner() -> CliRunner:\n return CliRunner()",
"def ez_run(cls, ... | [
"0.6015849",
"0.5901293",
"0.5896176",
"0.5896176",
"0.57842547",
"0.5726609",
"0.5675143",
"0.56670874",
"0.56511617",
"0.5644335",
"0.564341",
"0.5618902",
"0.5618902",
"0.5618902",
"0.5581154",
"0.55600226",
"0.55423313",
"0.5522817",
"0.5454394",
"0.5397374",
"0.53546125"... | 0.6885351 | 0 |
Convert camera state to internal camera state. | def to_camera_state(internal_camera_state):
def to_temperature(internal_temperature):
return CameraState.Temperature(
dmd=internal_temperature.dmd.value,
general=internal_temperature.general.value,
led=internal_temperature.led.value,
lens=internal_temperature... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def camera_to_object_transform(self):\n # form the full object to camera transform\n T_stp_camera = self.stp_to_camera_transform()\n T_obj_stp = self.object_to_stp_transform()\n T_obj_camera = T_stp_camera.dot(T_obj_stp)\n return T_obj_camera",
"def _state_convert(self, raw_sta... | [
"0.5980134",
"0.58976054",
"0.58470523",
"0.5826162",
"0.5741425",
"0.5722831",
"0.57148314",
"0.56743157",
"0.56138504",
"0.5612726",
"0.5576117",
"0.5559552",
"0.5549885",
"0.5537195",
"0.5533225",
"0.5515739",
"0.5493909",
"0.5471352",
"0.5414366",
"0.5413517",
"0.53990895... | 0.76187414 | 0 |
Function to apply fixed constant pressure boundary condition, it returns a transmissibility and a source/sink matrix modified. | def fixed_constant_pressure(self, general_transmissibility):
#print('Setting boundary conditions of local problem {}'.format(self.coarse_volume))
correct_volumes_group_1 = np.array([0,1,2,3])
correct_volumes_group_2 = np.array([12,13,14,15])
transmissibility = copy.deepcopy(general_trans... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBCProjWF_simple(self, discretization='CC'):\n\n if discretization is not 'CC':\n raise NotImplementedError('Boundary conditions only implemented'\n 'for CC discretization.')\n\n def projBC(n):\n ij = ([0, n], [0, 1])\n vals ... | [
"0.5876379",
"0.56467026",
"0.56454414",
"0.557635",
"0.54988295",
"0.5464996",
"0.54629254",
"0.54357946",
"0.54234153",
"0.5325453",
"0.52624094",
"0.5240842",
"0.5230096",
"0.52277684",
"0.52179563",
"0.52156794",
"0.51873976",
"0.5179338",
"0.51686215",
"0.51600015",
"0.5... | 0.73723733 | 0 |
Returns masked epsilon value for the current epoch; Epsilon value = eps_mask eps | def eps(self):
return self.eps_mask*self.eps_scheduler.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_epsilon(self):\n step_size = float(self._eps_begin - self._eps_end) / self._total_steps\n self._epsilon = max(self._eps_end, self._epsilon - step_size)\n return self._epsilon",
"def epsilon():\n return _EPSILON",
"def epsilon(self):\n return self._epsilon",
"def get_epsil... | [
"0.690235",
"0.6759066",
"0.67323434",
"0.67133105",
"0.66764283",
"0.6660499",
"0.64527667",
"0.62959194",
"0.62958694",
"0.6282747",
"0.62823194",
"0.6260531",
"0.6201078",
"0.6074518",
"0.605753",
"0.60512596",
"0.6047877",
"0.6020077",
"0.6009018",
"0.59153366",
"0.584312... | 0.7003138 | 0 |
This function stands for determine the threshold values of given dataframe according to given column name, lower quantile value and upper quantile value. | def outlier_thresholds(dataframe, col_name, low_quantile, up_quantile):
quartile1 = dataframe[col_name].quantile(low_quantile)
quartile3 = dataframe[col_name].quantile(up_quantile)
interquantile_range = quartile3 - quartile1
up_limit = quartile3 + 1.5 * interquantile_range
low_limit = quartile1 - 1.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getquantile(df, low=0.1, high=0.9):\n q1 = df.quantile(low)\n q3 = df.quantile(high)\n print(q1)\n print(q3)\n return df[df<q1],df[df>q3]",
"def replace_with_thresholds(dataframe, col_name, low_threshold, up_threshold):\n low_limit, up_limit = outlier_thresholds(dataframe, col_name,\n ... | [
"0.6829688",
"0.6753499",
"0.66339403",
"0.64233243",
"0.6403971",
"0.62588423",
"0.624364",
"0.6227992",
"0.5958877",
"0.5931864",
"0.59059733",
"0.5899942",
"0.588427",
"0.58527815",
"0.5804863",
"0.5798349",
"0.5789768",
"0.57848287",
"0.56844115",
"0.56844115",
"0.5665437... | 0.74504536 | 0 |
This function stands for checking if a column of a dataframe have outlier or not according to results of outlier_thresholds function. | def check_outlier(dataframe, col_name):
low_limit, up_limit = outlier_thresholds(dataframe, col_name, 0.05, 0.95)
if dataframe[(dataframe[col_name] > up_limit) |
(dataframe[col_name] < low_limit)].any(axis=None):
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_outlier(incoming_data):\r\n outlier_df = \\\r\n incoming_data[incoming_data.apply(\r\n lambda x: np.abs(x - x.mean()) / x.std() > 3).all(axis=1)]\r\n return not outlier_df.empty",
"def flag_outliers_in_col(self, df, col='paciente_idade', threshold=2):\n data = df[col]\n ... | [
"0.7784306",
"0.7516061",
"0.7242404",
"0.7233822",
"0.7036477",
"0.694232",
"0.68730634",
"0.679349",
"0.678132",
"0.6776806",
"0.6770923",
"0.6696206",
"0.6659336",
"0.6577895",
"0.6551978",
"0.6533329",
"0.64901596",
"0.64123476",
"0.6403893",
"0.6348688",
"0.63019955",
... | 0.85974765 | 0 |
This function stands for replacing given columns of dataframe according to given lower threshold and upper threshold values via using outlier_threshold function. | def replace_with_thresholds(dataframe, col_name, low_threshold, up_threshold):
low_limit, up_limit = outlier_thresholds(dataframe, col_name,
low_threshold, up_threshold)
if low_limit > 0:
dataframe.loc[(dataframe[col_name] < low_limit), col_name] = low_limit
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_outliers_by_threshold(tX, threshold, outlier_value):\n\n new_tX = tX\n for j in range(new_tX.shape[1]):\n col = new_tX[:, j]\n values, indices = np.unique(col, return_index=True)\n data = zip(values, indices)\n values_mean = np.mean(values)\n values_std = np.std... | [
"0.7123759",
"0.6695039",
"0.66256833",
"0.65285146",
"0.63990915",
"0.6376331",
"0.6319013",
"0.6014559",
"0.60104",
"0.59987855",
"0.5969919",
"0.5924092",
"0.59177697",
"0.58993465",
"0.58477944",
"0.5838635",
"0.5733036",
"0.5685656",
"0.5676063",
"0.5664337",
"0.56605303... | 0.8196213 | 0 |
This function stands for plotting graphs of 'category_id' and 'price' columns for visual examination. | def plot_columns(dataframe, title):
sns.boxplot(x=dataframe['category_id'], y=dataframe['price'])
plt.title(title)
plt.xlabel('Category ID')
plt.ylabel('Price')
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_cat(df, cat_columns, hue = \"default_payment_next_month\"):\n fig = plt.figure(figsize = (20,(len(cat_columns)/2+1)*8))\n loc = 1\n for col in cat_columns:\n ax = fig.add_subplot(len(cat_columns)/2+1, 2, loc)\n df_plot = df[[col, hue, \"id\"]].groupby([col, hue]).count()\n df... | [
"0.62422293",
"0.5959139",
"0.587027",
"0.58107173",
"0.5709584",
"0.5664822",
"0.56324095",
"0.5617443",
"0.5605391",
"0.5602949",
"0.5583337",
"0.558135",
"0.55679935",
"0.5539779",
"0.55202734",
"0.5518238",
"0.5473018",
"0.5467684",
"0.5465236",
"0.54648185",
"0.5434635",... | 0.6512989 | 0 |
This function stands for testing the target column of given dataframe according to normal distribution is valid on it or not via using shapiro test. | def test_normality(dataframe, iteration_column, target_column):
normals = []
not_normals = []
category_ids = [cat_id for cat_id in dataframe[iteration_column].unique()]
for id_ in category_ids:
ttest, p_value = shapiro(dataframe.
loc[dataframe[iteration_column] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_normality(df, features_to_analyse, p_value_threshold=0.05):\n \n is_normal_threshold = 1 - p_value_threshold\n\n normality_results = pd.DataFrame(data=None, index=['stat','pval'], columns=features_to_analyse)\n for f, feature in enumerate(features_to_analyse):\n try:\n stat,... | [
"0.6389563",
"0.6188177",
"0.6131274",
"0.5834058",
"0.5714856",
"0.56960815",
"0.56791514",
"0.5624745",
"0.5621683",
"0.5608999",
"0.5575569",
"0.5574775",
"0.55731064",
"0.5562695",
"0.5555359",
"0.55408436",
"0.5511444",
"0.5477347",
"0.5473243",
"0.5456144",
"0.5433261",... | 0.71757084 | 0 |
Trim altimeter data when out of water during a deployment and by bin range if specified | def trim_alt(ds, data_vars=["Altitude_m", "Counts", "Temperature_C"]):
if "trim_method" in ds.attrs:
trm_list = ds.attrs["trim_method"]
if not isinstance(trm_list, list): # make sure it is a list before looping
trm_list = [trm_list]
for trm_meth in trm_list:
if tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truncate_data(self, width):\n times_from_mid = self.time - self.midtime\n idxs = np.abs(times_from_mid) < 0.5 * width * self.duration\n self.time = self.time[idxs]\n self.flux = self.flux[idxs]",
"def remove_invalid_values(self, lower_bound=float('-inf'), upper_bound=float('inf'))... | [
"0.59564203",
"0.59462726",
"0.5891383",
"0.5773936",
"0.5772101",
"0.5748919",
"0.57270765",
"0.57121384",
"0.56339175",
"0.5611969",
"0.5601741",
"0.55495125",
"0.55369914",
"0.5513442",
"0.5478489",
"0.54771066",
"0.5410769",
"0.54082984",
"0.53611666",
"0.53212947",
"0.53... | 0.634952 | 0 |
Return gpu(i) if exists, otherwise return cpu(). | def try_gpu(i=0):
if torch.cuda.device_count() >= i + 1:
return torch.device(f'cuda:{i}')
return torch.device('cpu') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def try_gpu(i=0): #@save\n if len(tf.config.experimental.list_physical_devices('GPU')) >= i + 1:\n return tf.device(f'/GPU:{i}')\n return tf.device('/CPU:0')",
"def get_device(i=0):\n if torch.cuda.is_available():\n return torch.device(\"cuda:%d\" % i)\n else:\n return torch.dev... | [
"0.7673299",
"0.7155733",
"0.6743398",
"0.67328984",
"0.6628977",
"0.66274136",
"0.66274136",
"0.65953624",
"0.65533084",
"0.64042103",
"0.6377482",
"0.621364",
"0.6204196",
"0.6093279",
"0.6086354",
"0.60763216",
"0.6047976",
"0.6047976",
"0.60436594",
"0.60353875",
"0.59832... | 0.78513676 | 1 |
Parse input arguments. A config file is required ncdc forces downloading of new NCDC data | def parse_args():
parser = ArgumentParser()
parser.add_argument("config", help="Path to config file")
parser.add_argument("-ncdc", "--download-ncdc", action="store_true", dest="d_ncdc",
help="Download new NCDC data (overwrites existing)")
arguments = parser.parse_args()
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_args():\n parser = argparse.ArgumentParser(description=\"Run NCF..\")\n parser.add_argument(\n \"--config_file\",\n nargs=\"?\",\n type=str,\n default=\"../configs/ncf_default.json\",\n help=\"Specify the config file name. Only accept a file from ../configs/\",\n ... | [
"0.6683603",
"0.6602869",
"0.64225274",
"0.64112264",
"0.64049214",
"0.63174736",
"0.6263098",
"0.6236142",
"0.6228275",
"0.6186609",
"0.6181876",
"0.6176194",
"0.6171366",
"0.6159623",
"0.61590225",
"0.61305803",
"0.6121058",
"0.6115244",
"0.6084246",
"0.60457355",
"0.603711... | 0.78507113 | 0 |
This function takes a segmentation mask as input and fills the inpainted vertebra wherever not filled (i.e. not vertebra_id everywhere inside). | def fill_vert(self, mask):
im_floodfill = np.copy(mask)
im_floodfill[im_floodfill!=self.vertebra_id] = 0
im_floodfill[im_floodfill==self.vertebra_id] = 255
im_floodfill_copy = np.copy(im_floodfill)
# The size needs to be 2 pixels larger than the image.
h, w = im_floodfill... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mask(self):\n mask = np.zeros((self.height, self.width))\n pts = [\n np.array(anno).reshape(-1, 2).round().astype(int)\n for anno in self.segmentation\n ]\n mask = cv2.fillPoly(mask, pts, 1)\n return mask",
"def fill_blind_pores(im):\n holes = find_... | [
"0.62132704",
"0.61124694",
"0.6104057",
"0.59376204",
"0.5899385",
"0.5842893",
"0.5798474",
"0.57937765",
"0.57837266",
"0.577448",
"0.57716745",
"0.57418275",
"0.57412785",
"0.5726708",
"0.57038915",
"0.56873864",
"0.56623226",
"0.5640787",
"0.56124526",
"0.56116915",
"0.5... | 0.6978054 | 0 |
This function inpaints a 2D image and mask | def inpaint(self, img_slice, mask_slice, min_x, max_x, min_y, max_y, views='lateral'):
# create binary mask
mask = np.zeros(img_slice.shape)
mask[min_x:max_x, min_y:max_y] = 1
# keep a copy of original to have background later
img_orig = np.copy(img_slice)
mask_binary = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _draw_mask_on_image(self, mask):\n mask = self.STANDARD_COLORS_ARRAY[mask]\n cv2.addWeighted(mask,self.config.ALPHA,self.image,1.0,0,self.image)",
"def show_mask(image, mask): \n plt.subplot(1,2,1)\n plt.title('image')\n plt.imshow(image)\n plt.subplot(1,2,2)\n plt.title('mask')\n... | [
"0.7301254",
"0.6654888",
"0.6625699",
"0.63060254",
"0.6295693",
"0.62804675",
"0.6265031",
"0.62536275",
"0.6225253",
"0.62194",
"0.6191099",
"0.61354077",
"0.6087833",
"0.6080922",
"0.60753363",
"0.6053279",
"0.603352",
"0.6032018",
"0.6021544",
"0.60159034",
"0.6003691",
... | 0.7023641 | 1 |
The reverse operation of map_vert_to_class. Here the mask includes labels 15 which are mapped back to the original labels in the scan | def map_class_to_vert(self, inpainted_mask):
inpainted_mask[inpainted_mask==1] = self.vertebra_range[0]
inpainted_mask[inpainted_mask==2] = self.vertebra_range[1]
inpainted_mask[inpainted_mask==3] = self.vertebra_range[2]
inpainted_mask[inpainted_mask==4] = self.vertebra_range[3]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_vert_to_class(self, mask_seg):\n mask_seg[mask_seg==self.vertebra_range[0]] = 1\n mask_seg[mask_seg==self.vertebra_range[1]] = 2\n mask_seg[mask_seg==self.vertebra_range[2]] = 3\n mask_seg[mask_seg==self.vertebra_range[3]] = 4\n mask_seg[mask_seg==self.vertebra_range[4]] ... | [
"0.7264654",
"0.66162145",
"0.64050084",
"0.6343444",
"0.6311547",
"0.62583977",
"0.6244545",
"0.6026306",
"0.6009242",
"0.5989441",
"0.5958324",
"0.5925581",
"0.5895624",
"0.5866707",
"0.5849876",
"0.58453006",
"0.5836782",
"0.5834448",
"0.5816841",
"0.5816841",
"0.5812876",... | 0.66599804 | 1 |
This function converts a segmentation mask to a onehot encoded version | def get_one_hot(self, mask_slice):
mask_one_hot = self.map_vert_to_class(mask_slice).reshape(-1, 1)
self.one_hot_encoder.fit(mask_one_hot)
mask_one_hot = self.one_hot_encoder.transform(mask_one_hot).toarray()
# set 1st dim to num classes
mask_one_hot = np.transpose(mask_one_hot, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encoding(mask: typing.Any, classes: typing.List[int]):\n raise TypeError(\"Mask should be either np.ndarray of torch.Tensor\")",
"def binary_to_one_hot(arr: np.ndarray) -> np.ndarray:\n res = np.zeros((arr.shape[0], 2))\n res[np.where(arr == 1)[0], 0] = 1\n res[np.where(arr == 0)[0], 1] =... | [
"0.7464706",
"0.7032775",
"0.70228434",
"0.69899994",
"0.69584465",
"0.6958401",
"0.69303614",
"0.6923459",
"0.6914034",
"0.68933815",
"0.68916476",
"0.68892264",
"0.68866897",
"0.68721896",
"0.6867728",
"0.68463516",
"0.6792192",
"0.67787373",
"0.6777861",
"0.6775648",
"0.67... | 0.7079161 | 1 |
URI for dmapi DB | def dmapi_uri(self):
return self.get_uri(prefix="dmapi") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_uri_for(db_name):\n return '/'.join(_db_uri_parts()[:-1] + [db_name])",
"def get_uri(db_params: Dict[str, str]) -> str:\r\n def format_uri(scheme: str) -> str:\r\n auth = f'''{db_params[Toml.USER]}:{db_params[Toml.PASSWORD]}'''\r\n return f'''{scheme}://{auth}@{db_params[Toml.ADDRESS]}... | [
"0.6400694",
"0.6293949",
"0.6125386",
"0.59341073",
"0.5838207",
"0.5829279",
"0.58105844",
"0.5752424",
"0.5700388",
"0.5589648",
"0.5494501",
"0.5470878",
"0.5438909",
"0.54256606",
"0.5406732",
"0.5402033",
"0.5394537",
"0.5393316",
"0.5385201",
"0.5385201",
"0.53774226",... | 0.72291374 | 0 |
Creates or updates a Ceph keyring file. | def configure_ceph_keyring(self, key, cluster_name=None):
keyring_absolute_path = super().configure_ceph_keyring(
key, cluster_name
)
# TODO: add support for custom permissions into charms.openstack
if os.path.exists(keyring_absolute_path):
# NOTE: triliovault acc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_keyring_from_data(self, filedata: bytes, keyring_name: str) -> None:\n pubkey, keyidv2 = get_pubkey(filedata)\n if pubkey:\n self.add_pubkey_to_keyring(pubkey, keyring_name, keyidv2=keyidv2)",
"def write_key():\n key = fernet.Fernet.generate_key()\n keyfile = open(KEY_PA... | [
"0.5704393",
"0.5466244",
"0.54504627",
"0.5367327",
"0.5365103",
"0.536254",
"0.53573316",
"0.53409374",
"0.5322666",
"0.532163",
"0.52746147",
"0.5234076",
"0.5223036",
"0.519377",
"0.519335",
"0.5180726",
"0.5177008",
"0.5154591",
"0.515178",
"0.51287216",
"0.5128504",
"... | 0.61470187 | 0 |
Test the policy on 100 games and output the wins, losses, and ties for all games. Additionally, display 5 of these games. | def test(policy,env):
wins = 0
losses = 0
ties = 0
num_invalid_moves = 0
game_num = 1
n = 100
while n > 0:
state = env.reset()
done = False
display_game = False
if n % 20 == 0:
display_game = True
print("_____________________________... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_game_stats(games_won=games_won):\r\n for i in games_won: # set loop condition\r\n if games_won[i] != 1: # argument for if games is pluralized\r\n print (i + ' has won ' + str(games_won[i])+ ' games')\r\n else:\r\n print (i + ' has won ' + str(games_won[i])+ '... | [
"0.6959197",
"0.69120795",
"0.6784505",
"0.6746052",
"0.6450407",
"0.63989484",
"0.6303797",
"0.62905324",
"0.6278678",
"0.62770176",
"0.6225944",
"0.6218578",
"0.62119985",
"0.61761725",
"0.61730874",
"0.617251",
"0.61612713",
"0.61560404",
"0.61399037",
"0.61386585",
"0.612... | 0.7144467 | 0 |
Calculate all primes up to limit using the sieve of Eratosthenes method | def eratosthenes(limit):
if isinstance(limit, (int, float)) and limit == int(limit):
limit = int(limit)
else:
raise ValueError
primes = []
mask = [1]*(limit+1)
for i in range(2, limit+1):
if mask[i]:
primes.append(i)
for j in range(i*i, limit+1, i):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sieve(limit):\n primes = []\n\n s = xrange(2, limit + 1)\n while len(s) != 0:\n primes.append(s[0])\n s = [n for n in s if (n % s[0]) != 0]\n\n return primes",
"def eratosthenes_mem(limit):\n if isinstance(limit, (int, float)) and limit == int(limit):\n limit = int(limit)\... | [
"0.83246547",
"0.81167096",
"0.7945687",
"0.76976126",
"0.7671113",
"0.7646691",
"0.7636615",
"0.75908536",
"0.75533134",
"0.75512606",
"0.7477832",
"0.7464496",
"0.7456727",
"0.73623115",
"0.7354597",
"0.733797",
"0.73195255",
"0.7304559",
"0.72923464",
"0.72923464",
"0.7290... | 0.8271184 | 1 |
Calculate all primes up to limit using the sieve of Eratosthenes method while conserving memory | def eratosthenes_mem(limit):
if isinstance(limit, (int, float)) and limit == int(limit):
limit = int(limit)
else:
raise ValueError
primes = [2]
multiples = [2]
limit += 1
for candidate in range(3, limit):
if candidate not in multiples:
primes.append(candidate)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sieve(limit):\n primes = []\n\n s = xrange(2, limit + 1)\n while len(s) != 0:\n primes.append(s[0])\n s = [n for n in s if (n % s[0]) != 0]\n\n return primes",
"def eratosthenes(limit):\n if isinstance(limit, (int, float)) and limit == int(limit):\n limit = int(limit)\n ... | [
"0.8264546",
"0.8237874",
"0.78761345",
"0.768567",
"0.76232296",
"0.76230603",
"0.7604848",
"0.75785387",
"0.7548938",
"0.7480768",
"0.74737644",
"0.7463756",
"0.7346134",
"0.7335119",
"0.7326132",
"0.7315538",
"0.7275974",
"0.7252524",
"0.7247536",
"0.7241287",
"0.7239895",... | 0.8354203 | 0 |
Plots primes up to n using func(n) | def prime_dist(func, n):
x = func(n)
y = list(range(len(x)))
for i in range(len(x)):
y[i] = (i+1)*np.log(x[i])
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_ylabel(r'k $\cdot$ log(p$_k$)')
ax.set_xlabel(r'p$_k$')
plt.suptitle('Distribution of primes', fontsize=15)
ax.pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_sieve(n, x, poly={}, lin={}, label=True, shade=True):\n v = list(range(x + 1)) # integers 0, 1, ..., x\n if n == 0:\n v = prime_range(x)\n else:\n for p in prime_divisors(n):\n v = [k for k in v if k % p != 0 or k == p]\n # eliminate non-prime multiples... | [
"0.71396583",
"0.6347114",
"0.6325962",
"0.62111086",
"0.62088567",
"0.6179862",
"0.61741006",
"0.61727583",
"0.6157313",
"0.615701",
"0.61407703",
"0.6134305",
"0.61313236",
"0.61262596",
"0.61203164",
"0.611937",
"0.611937",
"0.60875714",
"0.5940775",
"0.59295005",
"0.59182... | 0.76307726 | 0 |
This method is in charge of loading the VTK file in order to obtain an unprojected set of particle positions | def loadVTK(self, filename, folder):
import vtk
print('Extracting Dataset')
start = time.time()
reader = vtk.vtkPolyDataReader()
reader.SetFileName(folder + filename)
reader.Update()
polydata = reader.GetOutput()
n = polydata.GetNumberOfPoints()
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_particle_ic(self, file_name):\n \n\n data = np.genfromtxt(file_name, names = True)\n\n self.N_part = np.size(data['x'])\n\n self.pos = np.array([data['x'], data['y'], data['z']])\n self.pos = self.pos.T.reshape(self.N_part,3)\n self.vel = np.array([data['vx'], data['vy... | [
"0.6929919",
"0.62454665",
"0.6166364",
"0.61089855",
"0.6038509",
"0.5972155",
"0.594291",
"0.58736014",
"0.5779551",
"0.5759098",
"0.57093155",
"0.57034266",
"0.57004243",
"0.56888515",
"0.56257796",
"0.5618636",
"0.56165904",
"0.5567601",
"0.5542718",
"0.55128044",
"0.5508... | 0.6832213 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.