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 |
|---|---|---|---|---|---|---|
Format a FASTA filename of the form "otu.isolate.sequence_id.fa". | def format_fasta_filename(*args):
if len(args) > 3:
raise ValueError("Unexpected number of filename parts")
if len(args) == 0:
raise ValueError("At least one filename part required")
filename = ".".join(args).replace(" ", "_") + ".fa"
return filename.lower() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_filename(prefix, suffix, seq_len, uncased):\n seq_str = \"seq-{}\".format(seq_len)\n if uncased:\n case_str = \"uncased\"\n else:\n case_str = \"cased\"\n\n file_name = \"{}.{}.{}.{}\".format(prefix, seq_str, case_str, suffix)\n\n return file_name",
"def format_filename(self, s):\n v... | [
"0.7300104",
"0.67765343",
"0.6772814",
"0.6697145",
"0.6529021",
"0.6502655",
"0.6502655",
"0.6502655",
"0.64751655",
"0.6464903",
"0.64495075",
"0.6445141",
"0.6358297",
"0.62694526",
"0.62530184",
"0.62435997",
"0.6228077",
"0.6186597",
"0.61775064",
"0.6148595",
"0.614143... | 0.8101146 | 0 |
Generate a FASTA filename and body for the sequences associated with the isolate identified by the passed ``otu_id`` and ``isolate_id``. | async def generate_isolate_fasta(db, otu_id, isolate_id):
_, isolate_name = await get_otu_and_isolate_names(db, otu_id, isolate_id)
otu = await db.otus.find_one({"_id": otu_id, "isolates.id": isolate_id}, ["name", "isolates"])
fasta = list()
async for sequence in db.sequences.find({"otu_id": otu_id, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def generate_sequence_fasta(db, sequence_id):\n sequence = await db.sequences.find_one(sequence_id, [\"sequence\", \"otu_id\", \"isolate_id\"])\n\n if not sequence:\n raise virtool.errors.DatabaseError(\"Sequence does not exist\")\n\n otu_name, isolate_name = await get_otu_and_isolate_names(d... | [
"0.69245267",
"0.6894119",
"0.5912291",
"0.5337424",
"0.51358384",
"0.5091706",
"0.5017148",
"0.49292922",
"0.490532",
"0.4845423",
"0.47710133",
"0.47625893",
"0.47573465",
"0.4747771",
"0.47446316",
"0.47379455",
"0.47282097",
"0.47108236",
"0.470876",
"0.47039667",
"0.4700... | 0.8190999 | 0 |
Generate a FASTA filename and body for the sequence associated with the passed ``sequence_id``. | async def generate_sequence_fasta(db, sequence_id):
sequence = await db.sequences.find_one(sequence_id, ["sequence", "otu_id", "isolate_id"])
if not sequence:
raise virtool.errors.DatabaseError("Sequence does not exist")
otu_name, isolate_name = await get_otu_and_isolate_names(db, sequence["otu_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_seq_file(seq_id, sequence, directory):\n f_fasta = open(directory + '/'+ seq_id + '.fasta', 'w')\n f_fasta.write(str(sequence))\n f_fasta.close()",
"def generate_fasta(sequences, fasta_path):\n\n with open(fasta_path, 'w+') as f:\n for i in range(len(sequences)):\n f.write(... | [
"0.6654648",
"0.5991678",
"0.5893759",
"0.55443513",
"0.55410385",
"0.5519095",
"0.54996574",
"0.5497378",
"0.546989",
"0.5423846",
"0.54024166",
"0.5382011",
"0.5371277",
"0.53569347",
"0.53467464",
"0.53463346",
"0.52885425",
"0.5284846",
"0.52747065",
"0.52720994",
"0.5260... | 0.7679342 | 0 |
Generate a FASTA filename and body for the sequences associated with the otu identified by the passed ``otu_id``. | async def generate_otu_fasta(db, otu_id):
otu = await db.otus.find_one(otu_id, ["name", "isolates"])
if not otu:
raise virtool.errors.DatabaseError("OTU does not exist")
fasta = list()
for isolate in otu["isolates"]:
async for sequence in db.sequences.find({"otu_id": otu_id, "isolate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def generate_sequence_fasta(db, sequence_id):\n sequence = await db.sequences.find_one(sequence_id, [\"sequence\", \"otu_id\", \"isolate_id\"])\n\n if not sequence:\n raise virtool.errors.DatabaseError(\"Sequence does not exist\")\n\n otu_name, isolate_name = await get_otu_and_isolate_names(d... | [
"0.683279",
"0.6485399",
"0.5569074",
"0.5483403",
"0.54582524",
"0.54195255",
"0.5392835",
"0.53337544",
"0.5320824",
"0.5282094",
"0.5202332",
"0.51656145",
"0.5165108",
"0.51585346",
"0.5126089",
"0.5122553",
"0.51130253",
"0.50874543",
"0.5049329",
"0.49892703",
"0.496523... | 0.7690048 | 0 |
This function checks if a given number is a Nigerian phone number. | def is_Nigerian(args1):
if len(args1) == 0:
return "Invalid input!, input must not be empty."
if (args1.isalnum() and not(args1.isnumeric())) or args1.isalpha():
return "Invalid Input!, input must be a string of numbers."
#creating a matching pattern for nigerian numbers by making use of reg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ni_number_check(number):\n ni_nuber = re.match(r\"^\\s*[a-zA-Z]{2}(?:\\s*\\d\\s*){6}[a-zA-Z]?\\s*$\", number)\n if ni_nuber:\n return True\n return False",
"def is_phonenumber(number):\n\n phonenum = re.compile(r'^(\\d{3})-(\\d{3})-(\\d{4})$')\n if phonenum.match(number)... | [
"0.774606",
"0.74679166",
"0.69906837",
"0.6815787",
"0.65633965",
"0.65529764",
"0.64875734",
"0.64522296",
"0.6425909",
"0.64103776",
"0.63558793",
"0.63498324",
"0.6343741",
"0.6288755",
"0.6271888",
"0.62652934",
"0.6176938",
"0.6169064",
"0.61534375",
"0.6152027",
"0.612... | 0.7525907 | 1 |
Should call the .use method on used with user as the argument. | def test_call(self):
user = object()
used = Fake()
called = []
used.use = lambda u: called.append(u)
a = Use(user, used)
a()
self.assertEqual(called, [user], "Should have called used.use(user)") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_serve_user(self):\n pass",
"def execute(self, user):\n pass",
"def use(target, name):",
"def use(self, target, name):\n return self.usable.use(target, name)",
"def test_user(self):\n return True",
"def test_func(self, user, **kwargs):\n return self.get_object()... | [
"0.65986025",
"0.6208207",
"0.6177418",
"0.6163876",
"0.6136552",
"0.6130325",
"0.6091194",
"0.6085136",
"0.6056721",
"0.60412604",
"0.6028056",
"0.5941651",
"0.58077157",
"0.5778681",
"0.57705474",
"0.5755981",
"0.5677145",
"0.56585205",
"0.5647163",
"0.5641119",
"0.56390595... | 0.74292713 | 0 |
Test gradients of singleargument scalar functions. | def test_grad_unary(func, motion, optimized, preserve_result, a):
utils.test_reverse_array(func, motion, optimized, preserve_result, a) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testNestedFunctionGradientCall(self):\n check_numerics_callback.enable_check_numerics()\n\n x = constant_op.constant(1.0 - 1e-8, dtype=dtypes.float32)\n\n @def_function.function\n def asinp1(x):\n # asin()'s gradient overflows at the value close to 1.0.\n return math_ops.asin(x) + 1.0\n\n... | [
"0.69838196",
"0.62551624",
"0.6240577",
"0.6208231",
"0.61972624",
"0.61963433",
"0.6193286",
"0.6189036",
"0.6149409",
"0.60993594",
"0.60622007",
"0.6057781",
"0.60543615",
"0.6035959",
"0.60253406",
"0.6017511",
"0.60147274",
"0.5983582",
"0.5977976",
"0.59656",
"0.595884... | 0.64167225 | 1 |
Test gradients of vector functions. | def test_grad_vector(func, motion, optimized, preserve_result, x):
utils.test_reverse_array(func, motion, optimized, preserve_result, x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_numerical_gradient_vectorized(self):\n W, X, b, Y, expected_grad_W, expected_grad_b = vectorized_test_data()\n\n fn_to_optimize = lambda W: vectorized_loss(\n X, Y, W, b)\n grad_W = numerical_gradient(fn_to_optimize, W)\n np.testing.assert_allclose(grad_W, expected_g... | [
"0.70717275",
"0.70420396",
"0.6982868",
"0.68923724",
"0.6890963",
"0.6879641",
"0.6844028",
"0.65803635",
"0.6568304",
"0.6504972",
"0.6501379",
"0.64940745",
"0.64732254",
"0.63941187",
"0.63763016",
"0.6368085",
"0.6366209",
"0.63571703",
"0.6356648",
"0.63120234",
"0.630... | 0.7636104 | 0 |
Test gradients of square matrix functions. | def test_grad_square_matrix(func, motion, optimized, preserve_result, sqm):
utils.test_reverse_array(func, motion, optimized, preserve_result, sqm) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_grad(self):\r\n for shp0, shp1 in [((1,), (2,)),\r\n ((3,), (1,)),\r\n ((1,), (1,)),\r\n ((3,), (2,)),\r\n ((3, 2), (1, 1)),\r\n ((3, 2), (1, 4)),\r\n ... | [
"0.71215576",
"0.6692214",
"0.65100783",
"0.6492603",
"0.64668906",
"0.6455008",
"0.6402786",
"0.64009535",
"0.6388172",
"0.6335372",
"0.6319555",
"0.6312385",
"0.6283996",
"0.62804395",
"0.61972606",
"0.6187361",
"0.61780065",
"0.61689115",
"0.6151857",
"0.613323",
"0.613008... | 0.77920055 | 0 |
Test gradients of functions with binary tensor inputs. | def test_grad_binary_tensor(func, motion, optimized, preserve_result, t1, t2):
tfe_utils.test_rev_tensor(func, motion, optimized, preserve_result, (0, 1),
t1, t2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testNestedFunctionGradientCall(self):\n check_numerics_callback.enable_check_numerics()\n\n x = constant_op.constant(1.0 - 1e-8, dtype=dtypes.float32)\n\n @def_function.function\n def asinp1(x):\n # asin()'s gradient overflows at the value close to 1.0.\n return math_ops.asin(x) + 1.0\n\n... | [
"0.7174986",
"0.69963866",
"0.6909422",
"0.6872271",
"0.6760931",
"0.6759554",
"0.67556065",
"0.6745516",
"0.6740587",
"0.67286974",
"0.66507494",
"0.6592925",
"0.65785694",
"0.65090275",
"0.65043676",
"0.6460004",
"0.6445297",
"0.64399576",
"0.6439512",
"0.6423145",
"0.63291... | 0.7402149 | 0 |
Test gradients of image functions. | def test_grad_image(func, motion, optimized, preserve_result, timage, tkernel,
conv2dstrides):
# TODO: Upgrade utils.py to allow simultaneous testing of uneven args.
tfe_utils.test_rev_tensor(func, motion, optimized, preserve_result, (0,),
timage, tkernel, conv2dstrid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_gradient_convergence(self):\n pass",
"def test_gradients(self):\n # Load from files.\n flow_ab = read_flow_file('pwcnet/warp/test_data/flow_ab.flo')\n img_b = read_image('pwcnet/warp/test_data/image_b.png', as_float=True)\n\n H = img_b.shape[0]\n W = img_b.shape... | [
"0.71023715",
"0.6835922",
"0.6640372",
"0.6603771",
"0.6524708",
"0.65058905",
"0.6494919",
"0.63947445",
"0.63629365",
"0.63115203",
"0.62794995",
"0.6276175",
"0.62534803",
"0.62271285",
"0.6223386",
"0.6205185",
"0.62044686",
"0.6195168",
"0.61621594",
"0.6155193",
"0.613... | 0.7155387 | 0 |
Drop Quasi Zero Features Returns a passed pandas DataFrame without columns containing too few nonzero values. | def drop_quasi_zero(df, thresh=0.05):
drop_list = []
for el in df.columns.values:
non_zero = df[el][df[el] != 0].shape[0] / df.shape[0]
if non_zero < thresh:
drop_list.append(el)
print('Dropping column: {} | Non-zero values ratio: {}%'.format(
el, round(10... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_zero_features(df,no_zeros = 1):\n thing = df.astype(bool).sum(axis=0) # number of nonzeros in each column\n idx = pd.Index(thing) #Index format\n location = idx.get_loc(no_zeros) # Set all elements that are 1.0 to True, rest to False.\n loc_of_one = np.asarray(np.nonzero(location)) #Array of... | [
"0.8001528",
"0.6879542",
"0.685985",
"0.6835183",
"0.6821461",
"0.68055904",
"0.67482245",
"0.67280966",
"0.6656785",
"0.66356796",
"0.6563634",
"0.65300715",
"0.6447803",
"0.64278233",
"0.64013696",
"0.63996434",
"0.6344614",
"0.63372946",
"0.63230413",
"0.6318931",
"0.6315... | 0.77936864 | 1 |
Drop Outliers by ZScore Deletes observations classified as outliers. The classification method analyzes if the observation is out of the established zscore bounds. | def drop_outliers_z_score(df, z=3):
n_initial_rows = df.shape[0]
drop_list = set()
print('-' * 25)
print('OUTLIERS DELETION: Z-SCORE METHOD\n')
for el in df.columns.values:
drop_list = drop_list | \
set(df[el][np.abs(df[el]-df[el].mean()) >=
(z*df[el].std... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_outliers(self, data, sd_val):\n data = data.dropna()\n data = data[(np.abs(stats.zscore(data)) < float(sd_val)).all(axis=1)]\n return data",
"def identify_and_handel_outliers(self):\n col_list = [] # This will hold the column names created for the administration of the modi... | [
"0.7309114",
"0.7176904",
"0.71419543",
"0.7014585",
"0.66157347",
"0.66115505",
"0.6607007",
"0.6549644",
"0.643559",
"0.6377236",
"0.6328624",
"0.630123",
"0.62695014",
"0.6264223",
"0.62510294",
"0.6243806",
"0.62305784",
"0.6151706",
"0.61425245",
"0.61235154",
"0.6117694... | 0.7543709 | 0 |
Drop Outliers by Quantiles Deletes observations classified as outliers. The classification method analyzes if the observation is out of the established quantile bounds. | def drop_outliers_quantile(df, upper=0.99, lower=0):
n_initial_rows = df.shape[0]
drop_list = set()
quant_upper = df.quantile(upper)
quant_lower = df.quantile(lower)
print('-' * 25)
print('OUTLIERS DELETION: QUANTILE METHOD\n')
for el in df.columns.values:
drop_list = drop_list | \... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_outliers(data):\n upper_boundary = np.quantile(data, 0.992)\n lower_boundary = np.quantile(data, 0.008)\n selection = data[(data > lower_boundary) & (data < upper_boundary)]\n standard_dev = np.std(selection)\n median = np.median(selection)\n data[(median + 4.5 * standard_dev < data) |... | [
"0.7241458",
"0.6982997",
"0.6830516",
"0.6804271",
"0.6767851",
"0.67002904",
"0.6677959",
"0.66053724",
"0.65986574",
"0.6532611",
"0.65269667",
"0.651718",
"0.65114",
"0.650066",
"0.6455752",
"0.6363624",
"0.62836605",
"0.62783426",
"0.6254968",
"0.61966586",
"0.6195618",
... | 0.73276263 | 0 |
Perform Automated Downsampling Returns a set of balanced x_train and y_train datasets for classification. As of now, it only works for binary classifications. | def downsampling(x_train, y_train, random_state=42):
sampling = pd.concat([x_train, y_train], axis=1)
big = sampling[y_train == y_train.value_counts().index[0]]
small = sampling[y_train == y_train.value_counts().index[1]]
downsampled = resample(big,
replace=False,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_data(self, x_data, y_data, max_seq_len, digits, seq_len,\n n_samples, use_one_hot, class_partition,\n upsample_control):\n # modify seq_len in case we do upsampling control\n if upsample_control:\n upsample_factor = seq_len\n ... | [
"0.64318675",
"0.6423297",
"0.6305304",
"0.6246317",
"0.6061455",
"0.60597426",
"0.6001533",
"0.59941304",
"0.596125",
"0.59551734",
"0.59408695",
"0.5918505",
"0.59173226",
"0.5902152",
"0.58708876",
"0.5862264",
"0.57767594",
"0.5743646",
"0.5723611",
"0.5707372",
"0.570502... | 0.7455317 | 0 |
Check categorical cardinality Checks the cardinality of categorical features of a given dataset. Returns two dictionaries, one for features with low cardinality and another for features with high cardinality. The low/high cardinality criteria can be tunned with the `threshold` parameter. | def check_cardinality(df, cat_cols, threshold=8):
high_card = {}
low_card = {}
for col in cat_cols:
rank = len(Counter(df[col]))
if rank <= threshold:
low_card[col] = rank
else:
high_card[col] = rank
return low_card, high_card | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_counts(self, X: np.ndarray) -> Dict[int, np.ndarray]:\n return {f: np.bincount(X[:, f].astype(int), minlength=n_cat) for f, n_cat in\n self.categories_per_feature.items()}",
"def test_cardinality(self):\n space = Space()\n probs = (0.1, 0.2, 0.3, 0.4)\n categor... | [
"0.60110897",
"0.59391886",
"0.58878255",
"0.55651134",
"0.5557575",
"0.5502532",
"0.5467048",
"0.5462119",
"0.5437828",
"0.5422825",
"0.540756",
"0.53921795",
"0.5321203",
"0.530417",
"0.5298471",
"0.529479",
"0.526825",
"0.5265717",
"0.52566886",
"0.5253142",
"0.52381426",
... | 0.7394644 | 0 |
Perform Bniary Encoding Wrapper for perfoming Binary Encoding on a set of categorical columns from a given DataFrame. The original categorical columns are dropped. Good for encoding categorical features with high cardinality. | def binary_encoding(df, bin_cols):
for col in bin_cols:
enc = BinaryEncoder(cols=col)
bin_enc = enc.fit_transform(df[col])
df = pd.concat([df, bin_enc], axis=1)
df.drop(col, axis=1, inplace=True)
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encoding_df(df, cols):\n import pandas as pd\n df = df[cols]\n obj_df = df.select_dtypes(include=['object']).copy()\n num_var = df.select_dtypes(include=['int','float']).copy()\n cat_var = pd.get_dummies(obj_df, columns = obj_df.columns)\n encoded_df = pd.concat([num_var, cat_var], axis=1, so... | [
"0.7325643",
"0.7214714",
"0.71435875",
"0.69621587",
"0.6918023",
"0.69116336",
"0.6879287",
"0.6841618",
"0.68229026",
"0.68160236",
"0.6795417",
"0.67443526",
"0.6730028",
"0.67107",
"0.6649362",
"0.65972847",
"0.6576219",
"0.65755546",
"0.6571882",
"0.6562026",
"0.6538636... | 0.7727909 | 0 |
Get sparse matrix of scores Returns a sparse score matrix of implicit Client > Product interactions. The scores are wightened by the correlation of each feature with the target feature. It is also possible to filter the values from the target feature we want to be considered in the building of the sparse matrix. | def get_corr_sparse_df(df, client_id, product_id, tgt_feature,
tgt_filter=True, tgt_val=1):
# Auxiliary tables declaration
df_keys = df[[client_id, product_id, tgt_feature]]
df_score = df.drop([client_id, product_id, tgt_feature], axis=1)
# Calculating the score weight matrix, us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_sparse(self):\n from divisi2.sparse import SparseMatrix\n return SparseMatrix(self, self.row_labels, self.col_labels)",
"def analyze_sensitivity_sparse_grid(sparse_grid,max_order=2):\n from pyapprox.multivariate_polynomials import \\\n define_poly_options_from_variable_transformati... | [
"0.6489858",
"0.63272566",
"0.6297267",
"0.61061746",
"0.6096833",
"0.5966724",
"0.5915552",
"0.58811307",
"0.5846046",
"0.5798666",
"0.57851624",
"0.5760531",
"0.57405245",
"0.5736884",
"0.573338",
"0.57287127",
"0.5685769",
"0.56659234",
"0.56512487",
"0.5630169",
"0.561970... | 0.7354125 | 0 |
Returns object id for given address or None when unknown source | def lookup_object(self, address):
obj_id = self.source_map.get(address)
if not obj_id:
# Register invalid event source
if self.source_map:
self.invalid_sources[address] += 1
return None
return obj_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grab_external_id(stix_object, source_name):\n for external_reference in stix_object.get(\"external_references\", []):\n if external_reference.get(\"source_name\") == source_name:\n return external_reference[\"external_id\"]",
"def getSourceForId(context, identifier):\n nearest = getat... | [
"0.66619503",
"0.6295734",
"0.62073255",
"0.6147287",
"0.6119063",
"0.6066387",
"0.600836",
"0.6007095",
"0.5943731",
"0.58872235",
"0.58872235",
"0.58104545",
"0.57378054",
"0.57162756",
"0.57081634",
"0.57081634",
"0.57081634",
"0.568439",
"0.568439",
"0.568439",
"0.568439"... | 0.81914216 | 0 |
Periodic task to send collected messages to fmwriter | def send_messages(self):
if self.messages:
messages, self.messages = self.messages, []
self.mpub("events.%s" % config.pool, messages) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n while True:\n try:\n sleep(influx_settings.write_freq)\n self._redis2influx()\n except InterruptExceptions as ex:\n raise ex",
"def trigger_update(self):\n update_thread = Thread(target=self.process_queued_msg)\n ... | [
"0.613982",
"0.61360604",
"0.6054681",
"0.6047653",
"0.60263085",
"0.6020203",
"0.6016649",
"0.5977986",
"0.59506196",
"0.5898428",
"0.58631",
"0.58552927",
"0.5847367",
"0.58328557",
"0.5831154",
"0.58268714",
"0.5758967",
"0.5752461",
"0.5745754",
"0.569751",
"0.5676762",
... | 0.6156687 | 0 |
Report invalid event sources | def report_invalid_sources(self):
if not self.invalid_sources:
return
total = sum(self.invalid_sources[s] for s in self.invalid_sources)
self.logger.info(
"Dropping %d messages with invalid sources: %s",
total,
", ".join("%s: %s" % (s, self.invalid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sources_not_ok_on_connection_error(self):\n measurement = self.measurement(\n self.metric(),\n sources=[\n {\n \"source_uuid\": SOURCE_ID,\n \"value\": None,\n \"total\": None,\n \"parse... | [
"0.65968525",
"0.64882016",
"0.6418916",
"0.6381476",
"0.62577367",
"0.5951416",
"0.58868337",
"0.57699937",
"0.57269937",
"0.56809556",
"0.56666833",
"0.5643618",
"0.56132454",
"0.55951136",
"0.55816895",
"0.5566584",
"0.55154705",
"0.5508068",
"0.5502415",
"0.5494327",
"0.5... | 0.758512 | 0 |
Add a list of items to the list of all library items | def add_items(self, library_items):
for item in library_items:
self._all_items.append(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_items(self, items):\n for item in items:\n self.add(item)",
"def add_items(self, items):\n for item in items:\n self.addItem(item)\n # end for item in items",
"def addItems(*args):",
"def extend(self, items):\n\t\tfor item in items:\n\t\t\tself.append(item)"... | [
"0.76198214",
"0.7341822",
"0.7276178",
"0.7267924",
"0.71445847",
"0.70814025",
"0.706996",
"0.70159686",
"0.6767956",
"0.6730525",
"0.66963893",
"0.66547024",
"0.6601904",
"0.65674746",
"0.6306901",
"0.6306901",
"0.6306901",
"0.6264611",
"0.6227412",
"0.62267005",
"0.621254... | 0.8472733 | 0 |
Initialize a new book object | def __init__(self, name, isbn, author, tags=None):
super().__init__(name, isbn, tags)
self.author = author
self.resource_type = "Book" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self._book = Library.functions.new_()",
"def __init__(self, bookAuthor, ISBN, numPurchased, bookTitle, numCheckedOut = 0, retailPrice = 0):\n\n self.bookAuthor = bookAuthor\n self.bookISBN = ISBN\n self.numberPurchased = numPurchased\n self.numberCheckedOu... | [
"0.7738984",
"0.7383594",
"0.73780483",
"0.70157796",
"0.69490784",
"0.6875649",
"0.68458223",
"0.6771472",
"0.6601914",
"0.6483411",
"0.6417341",
"0.63756514",
"0.6345037",
"0.63199055",
"0.626232",
"0.62504995",
"0.6247069",
"0.6246545",
"0.6223746",
"0.62212014",
"0.618638... | 0.7439095 | 1 |
An extension of the match function in the base LibraryItem class. Also searches for the filter text in the author variable. | def match(self, filter_text):
return filter_text.lower() in self.author.lower() or \
super().match(filter_text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(self, filter_text):\n\n return filter_text.lower() in self.artist.lower() or \\\n super().match(filter_text)",
"def match(self, filter_text):\n return filter_text.lower() in self.name.lower() or \\\n filter_text.lower() == self.isbn.lower() or \\\n filter_... | [
"0.682007",
"0.6550258",
"0.6416015",
"0.63797086",
"0.6266647",
"0.59596294",
"0.58739334",
"0.58389205",
"0.58080375",
"0.5803565",
"0.56252295",
"0.5614221",
"0.5611868",
"0.5611807",
"0.5606387",
"0.5595165",
"0.5577767",
"0.5544993",
"0.54778427",
"0.5456448",
"0.5431750... | 0.7305958 | 0 |
An extension of the LibraryItem's match method. Also searches for filter text in the director and actor fields. | def match(self, filter_text):
return filter_text.lower() in self.director.lower() or \
filter_text.lower() in self.actor.lower() or \
super().match(filter_text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(self, item):",
"def match(self, filter_text):\n\n return filter_text.lower() in self.artist.lower() or \\\n super().match(filter_text)",
"def match(self, filter_text):\n\n return filter_text.lower() in self.author.lower() or \\\n super().match(filter_text)",
"def... | [
"0.66584975",
"0.66140664",
"0.6375227",
"0.62277186",
"0.60852814",
"0.5842212",
"0.5810459",
"0.58054554",
"0.56884336",
"0.56876177",
"0.5668758",
"0.5642446",
"0.56119794",
"0.56106514",
"0.55795777",
"0.55734146",
"0.5569108",
"0.5545362",
"0.5492105",
"0.5452527",
"0.54... | 0.7091767 | 0 |
Initialize a MusicCD item. | def __init__(self, name, isbn, artist, num_discs, tags=None):
super().__init__(name, isbn, tags)
self.artist = artist
self.num_discs = num_discs
self.resource_type = "Music CD" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **kwargs):\n self.item = Item(**kwargs)\n self._working_dir = None",
"def __init__(self):\n # Item Dictionary (key: call number, value: Item object)\n self.item_list = {}\n\n # Add some items manually for testing purposes.\n book1 = Book(\"In praise of... | [
"0.6313415",
"0.62220263",
"0.5928097",
"0.58955693",
"0.5831417",
"0.5831417",
"0.5783373",
"0.5757864",
"0.5751746",
"0.5706846",
"0.5677021",
"0.5675513",
"0.56697357",
"0.56654",
"0.5658594",
"0.56570214",
"0.56510967",
"0.5628711",
"0.5588841",
"0.55882436",
"0.55713534"... | 0.6329616 | 0 |
An extension of the Library Item's match method. Also searches for the filter text in the artist variable | def match(self, filter_text):
return filter_text.lower() in self.artist.lower() or \
super().match(filter_text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(self, item):",
"def find_artist(self):\n item = self.clementine_artists.currentItem()\n if not item:\n return\n self.artist_buffer = item\n search = item.text(0)\n self._parent.current_data = search\n if self.artist_map[item.text(0)]:\n ok... | [
"0.69125444",
"0.6398688",
"0.6256071",
"0.6176387",
"0.6136926",
"0.61072534",
"0.6032576",
"0.6002995",
"0.5977466",
"0.59103507",
"0.59099007",
"0.58667594",
"0.58499247",
"0.58097106",
"0.5808899",
"0.5755709",
"0.569537",
"0.5620561",
"0.5617918",
"0.5600141",
"0.5568909... | 0.74232924 | 0 |
Convert the abfss path to https path style | def convert_abfss_path_to_https(abfss_path: str) -> str:
pattern = r'abfss:\/\/([^@]+)@([^.]+)[^\/]+\/(.+)'
regex = re.compile(pattern)
match = regex.search(abfss_path)
if not match:
raise ValueError(f"Invalid abfss path {abfss_path}")
container = match.group(1)
storage_account = match.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def https(url):\n if url[:8] == 'https://':\n return url\n if url[:7] != 'http://':\n return False\n return 'https://' + url[7:]",
"def path_ssl(self):\n return HOMEASSISTANT_SSL.format(HASSIO_SHARE_INT)",
"def convertToURL( cPathname ):\n if len( cPathname ) > 1:\n if c... | [
"0.62642324",
"0.61140555",
"0.61136925",
"0.6104507",
"0.609913",
"0.6059806",
"0.6051831",
"0.6046826",
"0.60012305",
"0.59881335",
"0.5960421",
"0.5948716",
"0.59205675",
"0.59025985",
"0.5899939",
"0.5899413",
"0.5885915",
"0.5857693",
"0.584945",
"0.5841724",
"0.57719195... | 0.73538405 | 0 |
Generate queue messages from Databricks ouutput metadata file content | def generate_metadata_queue_messages(event_time: str, metadata_file_content: str) -> List[str]:
ingest_queue_msg_list = []
current_part_num = 100000 #Max part number
global MAX_COMPACT_FILE_RECORDS
for line in reversed(metadata_file_content.splitlines()):
logging.info(f"{HEADER} Processing meta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_metadata_msg_enqueue_tasks(queue_msg_list: List[str],\n queue_client_list: List[QueueClient],\n tc: TelemetryClient) -> None:\n\n tasks = []\n for idx, queue_msg in enumerate(queue_msg_list):\n output_obj = json.loads(queue_ms... | [
"0.64029324",
"0.59525144",
"0.5745095",
"0.55602175",
"0.5504239",
"0.54586256",
"0.5446348",
"0.5404002",
"0.5401268",
"0.5355826",
"0.53395224",
"0.52417713",
"0.5229069",
"0.52107525",
"0.51790047",
"0.51555395",
"0.5095745",
"0.5088324",
"0.50780344",
"0.50593895",
"0.50... | 0.7086968 | 0 |
limit the concurrent tasks with semaphore | async def gather_with_concurrency(n, tasks):
semaphore = asyncio.Semaphore(n)
async def sem_task(task):
async with semaphore:
await task
await asyncio.gather(*(sem_task(task) for task in tasks)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_ripe_request_tokens(sema: mp.Semaphore, limit: int, finish_event: threading.Event):\n logger.debug('generate thread started')\n while not finish_event.is_set():\n time.sleep(2 / limit)\n try:\n sema.release()\n sema.release()\n except ValueError:\n ... | [
"0.6282102",
"0.6080879",
"0.60440874",
"0.59983575",
"0.59436536",
"0.5899353",
"0.5844908",
"0.5839281",
"0.5807662",
"0.573292",
"0.571161",
"0.566539",
"0.5640771",
"0.55995965",
"0.5567172",
"0.55225784",
"0.5494984",
"0.5481205",
"0.54737425",
"0.539674",
"0.53499925",
... | 0.6391296 | 0 |
Close queue clients connection | def close_queue_clients(queue_client_list: List[QueueClient], loop: asyncio.AbstractEventLoop):
client_close_tasks = []
for client in queue_client_list:
close_task = asyncio.ensure_future(client.close())
client_close_tasks.append(close_task)
loop.run_until_complete(gather_with_concurrency(1,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _close_clients(self):\n for client in self.clients:\n client.close()",
"def closeConnecetion(self):\n client.close()",
"def close(self):\n for conn in self._conns:\n conn.send((self.CLOSE,()))",
"def __close_connection_with_clients(self):\n for current_client in self._... | [
"0.74559975",
"0.74452204",
"0.7294628",
"0.7047551",
"0.6944966",
"0.677886",
"0.6763271",
"0.6743381",
"0.67432",
"0.67000616",
"0.6695658",
"0.6674143",
"0.66615736",
"0.66608673",
"0.6640044",
"0.6629691",
"0.66181344",
"0.6616973",
"0.66131306",
"0.6568658",
"0.6536984",... | 0.74610734 | 0 |
Main function, triggered by Azure Storage Queue, parsed queue content and try to download the databricks output metadata file to get each succefully processed file location. Then enqueue to ingest queue for ingestion to ADX on later Azure function. If the file is checkpoint compact file, the code will shrink the file s... | def main(msg: func.QueueMessage) -> None:
code_start_time = time.time()
logging.info('Python queue trigger function processed a queue item: %s',
msg.get_body().decode('utf-8'))
# modify the log level of azure sdk requests
logging.getLogger('azure').setLevel(logging.WARNING)
init_con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_metadata_queue_messages(event_time: str, metadata_file_content: str) -> List[str]:\n ingest_queue_msg_list = []\n current_part_num = 100000 #Max part number\n global MAX_COMPACT_FILE_RECORDS\n\n for line in reversed(metadata_file_content.splitlines()):\n logging.info(f\"{HEADER} Pro... | [
"0.6682282",
"0.6162708",
"0.6032964",
"0.5799686",
"0.5781316",
"0.5746755",
"0.5729667",
"0.57098687",
"0.5676677",
"0.5572735",
"0.5548825",
"0.5534193",
"0.55331063",
"0.55202967",
"0.55051416",
"0.5490857",
"0.5485531",
"0.54404837",
"0.54099286",
"0.5386266",
"0.5369767... | 0.7072427 | 0 |
Parse Text file and yield 1 line at a time. | def parse_text_file(file_path):
with open(file_path, 'r') as f:
for line in f:
line = line.rstrip()
if not line:
continue
yield line | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def txt_line_iterator(path):\n with tf.io.gfile.GFile(path) as f:\n for line in f:\n yield line.strip()",
"def parse(self, f):\n \n for line in f:\n self.parse_line(line)",
"def _gen_txt_data(self, f):\n\t\treader = iter(f)\n\n\t\tfor line_num, line in enumerate(reader):\n\t\t... | [
"0.7017607",
"0.66851646",
"0.6601368",
"0.6538029",
"0.64616096",
"0.64355737",
"0.64092755",
"0.6401797",
"0.63687634",
"0.6289389",
"0.6269863",
"0.62646693",
"0.6264008",
"0.6262496",
"0.6234503",
"0.62180173",
"0.6187032",
"0.6181076",
"0.6180821",
"0.6168177",
"0.616333... | 0.75814044 | 0 |
Run the c++ unit tests. This runs a subprocess because the HDF5 used by h5py clashed with the HDF5 linked to the c++ unit tests on some systems. h5py is used by some XDMF tests. | def run_cpp_unit_tests():
# We set cwd in case the script is run from another directory. This is needed
# when testing from the core.
out_bytes = subprocess.check_output(
['python3', 'run_cpp_unit_tests.py'], cwd=abspath(dirname(__file__)))
return out_bytes.decode('utf-8') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __main() :\n launchTests()",
"def test(c, index=0):\n exec_path = f'{ROOT_DIR}/gem5/build/GCN3_X86/gem5.opt' \n conf_path = f'{ROOT_DIR}/gem5/configs/example/apu_se.py'\n test_dir = TEST_PATHS[index]\n print(f'Testing {test_dir}...')\n \n # Try to find executable\n try_paths = [os.pat... | [
"0.6613631",
"0.6581835",
"0.6549095",
"0.64722",
"0.6412084",
"0.63910145",
"0.6268595",
"0.62387437",
"0.618074",
"0.6167369",
"0.61670023",
"0.6159595",
"0.61505693",
"0.61311626",
"0.61168665",
"0.60939276",
"0.6077586",
"0.6045904",
"0.60249716",
"0.6006832",
"0.6001748"... | 0.67698425 | 0 |
Initialize first name, last name, age, and gender attributes. | def __init__(self, first_name, last_name, age, gender):
self.first_name = first_name
self.last_name = last_name
self.age = age
self.gender = gender | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, f_name, l_name, age, gender, m_number):\n self.f_name = f_name\n self.l_name = l_name\n self.age = age\n self.gender = gender\n self.m_number = m_number",
"def __init__(self, first_name, last_name, age):\n\n self.first_name = first_name\n self.l... | [
"0.7688818",
"0.75608855",
"0.7557712",
"0.7557712",
"0.7557712",
"0.7557712",
"0.7557712",
"0.7557712",
"0.7557712",
"0.7557712",
"0.72796017",
"0.71924347",
"0.6994145",
"0.6983084",
"0.69552344",
"0.6938817",
"0.6919511",
"0.6853096",
"0.684336",
"0.6801357",
"0.67757064",... | 0.8197995 | 0 |
Prints the priveleges granted to this type of User(Admin). | def show_priveleges(self):
print("This user:")
for privelege in self.priveleges:
print(privelege) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showprivelages(self):\r\n\t\tprint (\"An administrator has the following abilities: \")\r\n\t\tfor power in self.powers:\r\n\t\t\tprint (\"- \" + power)",
"def show_privileges(self):\n print(\"This admin user has the following privileges:\")\n for item in self.privileges:\n print(f\"... | [
"0.77525014",
"0.76014477",
"0.7597725",
"0.7547358",
"0.7508543",
"0.74574864",
"0.73488426",
"0.7288568",
"0.5971587",
"0.586329",
"0.5682209",
"0.56727153",
"0.56551707",
"0.547195",
"0.54604584",
"0.54411626",
"0.5435521",
"0.5409437",
"0.53908664",
"0.5389564",
"0.538702... | 0.7839699 | 0 |
Passes the HTML file to the Markdown parser. Gets the resulting md and stores it in its own property | def parse(self, htmlFile):
htmlToMdParser = HtmlToMarkdown()
htmlToMdParser.readFile(htmlFile)
self.__setMarkdownOutput(htmlToMdParser.getMarkdown()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __html__(self, file_path:str) -> str:\n with open(f\"{file_path}\", \"r\") as mdfile: # Parse markdown file\n text = mdfile.read()\n html = self.md.convert(text) # Convert the markdown content text to hmtl\n return html",
"def parse(self, htmlfile):\r\n title_el, summary_el... | [
"0.7806094",
"0.75215423",
"0.72866136",
"0.7171097",
"0.71067405",
"0.69807774",
"0.68494374",
"0.6752766",
"0.6671119",
"0.6567304",
"0.6497255",
"0.64291793",
"0.63721174",
"0.6348815",
"0.6338439",
"0.6311875",
"0.6305898",
"0.6284648",
"0.62832975",
"0.6280578",
"0.62183... | 0.8087815 | 0 |
Write selfs markdown data to file | def __writeToFile(self, mdFile):
with open(mdFile, 'a') as writer:
for line in self.__markdownOutput:
writer.write(line) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_markdown_report(self, **kwargs):\n save_dir = os.path.dirname(self.file_paths[0])\n timestamp = datetime.datetime.utcnow().strftime(\"%Y-%j-%Hh%Mm%Ss\")\n markdown_file_name = \"report_{}.md\".format(timestamp)\n markdown_file_path = os.path.join(save_dir, markdown_file_name)\n... | [
"0.70040005",
"0.65243876",
"0.6442088",
"0.6366318",
"0.6351913",
"0.63268805",
"0.6305234",
"0.62839085",
"0.62771386",
"0.62156075",
"0.61913127",
"0.6144183",
"0.61168224",
"0.6007978",
"0.60004336",
"0.60001224",
"0.5982156",
"0.59446424",
"0.59380436",
"0.59365654",
"0.... | 0.7303364 | 0 |
Generate a Bert wordpiece vocabulary from a `tf.data.Dataset` of texts. ``` import tensorflow_text as text vocab = bert_vocab_from_dataset(dataset, vocab_size, reserved_tokens, bert_tokenizer_params, learn_params) bert_tokenizer = text.BertTokenizer(vocab, bert_tokenizer_params) token_ids = bert_tokenizer.tokenize(text... | def bert_vocab_from_dataset(dataset,
vocab_size: int,
reserved_tokens: List[str],
bert_tokenizer_params=None,
learn_params=None) -> List[str]:
if bert_tokenizer_params is None:
bert_tokenizer_params = {... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dataset(cls, dataset, col_names, vocab_size, character_coverage, model_type, params):\n\n vocab = SentencePieceVocab()\n root = copy.deepcopy(dataset).build_sentencepiece_vocab(vocab, col_names, vocab_size, character_coverage,\n ... | [
"0.6695434",
"0.59435654",
"0.57949984",
"0.56768864",
"0.56709015",
"0.5485758",
"0.5482027",
"0.543974",
"0.5393621",
"0.5373836",
"0.53656673",
"0.53424793",
"0.53227395",
"0.5320037",
"0.5311882",
"0.5262313",
"0.52581626",
"0.5236028",
"0.5179154",
"0.51750255",
"0.51681... | 0.72508216 | 0 |
save all the FLAG values in a config file / xml file | def save_config(FLAGS, logfolder, file_name = "configuration"):
print("Save configuration to: {}".format(logfolder))
root = ET.Element("conf")
flg = ET.SubElement(root, "flags")
flags_dict=FLAGS.__dict__
for f in sorted(flags_dict.keys()):
# print f, flags_dict[f]
e = ET.SubElement(flg, f, name=f) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_config(logfolder, file_name = \"configuration\"):\n print(\"Save configuration to: \", logfolder)\n root = ET.Element(\"conf\")\n flg = ET.SubElement(root, \"flags\")\n \n flags_dict = FLAGS.__dict__['__flags']\n for f in flags_dict:\n #print f, flags_dict[f]\n ET.SubElement(flg, f, name=f).te... | [
"0.758127",
"0.7308489",
"0.67504543",
"0.67352724",
"0.6585914",
"0.62659514",
"0.62000674",
"0.61799616",
"0.6170416",
"0.6162446",
"0.61308473",
"0.61104065",
"0.61041206",
"0.60973454",
"0.60634506",
"0.60334367",
"0.599318",
"0.59699816",
"0.5965832",
"0.59636515",
"0.59... | 0.76940143 | 0 |
Map natural position to machine code postion | def map_position(pos):
posiction_dict = dict(zip(range(1, 17), [i for i in range(30, 62) if i % 2]))
return posiction_dict[pos] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_pos_tag(pos):\n\n\tmappings = {'NN': wn.NOUN, 'JJ': wn.ADJ, 'VB': wn.VERB, 'RB': wn.ADV}\n\tpos = pos[:2]\n\tif pos in mappings:\n\t\tpos = mappings[pos]\n\telse:\n\t\tpos = wn.NOUN\n\treturn pos",
"def compute_offset_pos(seq, pos):\n \n nogap_seq = transform_seq(seq)\n assert(pos >= 0 and pos <... | [
"0.5799386",
"0.56906056",
"0.5584939",
"0.5500977",
"0.54784864",
"0.5363552",
"0.5348209",
"0.525057",
"0.52384615",
"0.5234695",
"0.51939845",
"0.5183469",
"0.5177587",
"0.51565945",
"0.51374286",
"0.51320094",
"0.51159453",
"0.51113105",
"0.5074599",
"0.50590044",
"0.5052... | 0.6337538 | 0 |
Move cam to given preset position. pos must be within 1 to 16. | def move(self, pos):
try:
payload = {"address":self.address, "user": self.user, "pwd": self.pswd, "pos": map_position(pos)}
resp = requests.get(
"http://{address}/decoder_control.cgi?command={pos}&user={user}&pwd={pwd}".format(**payload)
)
except ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPos(self, pos):\n self.cameraNode.setPos(pos)",
"def set_position(self, pos, debug=False):\n pos = max(pos, 0)\n pos = min(pos, 1)\n posrange = pos * self.range\n pos = posrange + self.min\n if debug:\n print('Setting Dynamixel {} with posrange {} to po... | [
"0.7138918",
"0.64176524",
"0.6216379",
"0.6157313",
"0.60971105",
"0.6046289",
"0.60182077",
"0.59599185",
"0.5955653",
"0.5935965",
"0.5924134",
"0.58532727",
"0.5846093",
"0.5841225",
"0.5791711",
"0.5789152",
"0.5782726",
"0.5772265",
"0.57623875",
"0.57590634",
"0.573229... | 0.69712156 | 1 |
Return empty array if nothing found, else return array of sequence id. | def user_created_id_array(self, uid):
result = self.find({ pair_data.STATISTICS + '.' + pair_data.CREATOR: self._uid2ref(uid) },
{ pair_data.SEQUENCE: True } ).sort(pair_data.SEQUENCE, pymongo.ASCENDING)
if result is not None:
return [data[pair_data.SEQUENCE] for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ids(self) -> List[str]:",
"def _id_seq(self):\n return list(self.keys())",
"def subseqs_ids(subsequences, sequence):\n return [1 if subsequence in sequence else 0 for subsequence in subsequences]",
"def get_seq(self): # -> list[Unknown]:\n ...",
"def getIDs():",
"def get_seq_ids(... | [
"0.63351494",
"0.63165605",
"0.6204257",
"0.6197235",
"0.6129571",
"0.6069571",
"0.59799623",
"0.5919414",
"0.5913466",
"0.5878638",
"0.5865883",
"0.5837098",
"0.58289546",
"0.57959354",
"0.5780037",
"0.5777107",
"0.57456404",
"0.5724617",
"0.571826",
"0.571826",
"0.5714811",... | 0.6340417 | 0 |
Returns all subclasses of this base class. The dictionary poses as Backend registry. | def get_subclasses(cls) -> dict:
return dict(cls._subclasses) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_all(cls):\r\n # BaseProvider does so have __subclassess__. pylint: disable-msg=no-member\r\n return {klass.NAME: klass for klass in BaseProvider.__subclasses__()}",
"def get_all_object_classes(cls) -> Dict[str, Type[objects.BaseObject]]:\n cls._refresh_registry()\n return cop... | [
"0.7478175",
"0.715127",
"0.70746803",
"0.70010734",
"0.66492534",
"0.6618857",
"0.6606922",
"0.6604169",
"0.65711075",
"0.65670526",
"0.6564629",
"0.6552424",
"0.6425689",
"0.6420186",
"0.638971",
"0.6376375",
"0.6374097",
"0.6343866",
"0.6304094",
"0.62940854",
"0.6286731",... | 0.7372407 | 1 |
Minimum brightness, 0, that is, totally dark, read only | def min_brightness(self):
return .0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_max_brightness(self) -> float:\n return max(self._color)",
"def brightness(value):\n value = int(value)\n if value < 1 or value > 254:\n raise ValueError('Minimum brightness is 1, to the maximum 254')\n return value",
"def brightness(self) -> float:\n # http://alienryderfl... | [
"0.67517716",
"0.66309625",
"0.6602429",
"0.6565702",
"0.65619093",
"0.65543157",
"0.6543305",
"0.64708745",
"0.6433429",
"0.64129823",
"0.6346434",
"0.6346434",
"0.6346434",
"0.6346434",
"0.6346434",
"0.6346434",
"0.6346434",
"0.6346434",
"0.6346434",
"0.6346434",
"0.6346434... | 0.8576602 | 0 |
Put items randomly on the map and check if it's possible | def put_items(self,*maplist):
self.position_x = random.randint(0, (len(maplist) - 1))
self.position_y = random.randint(1, (len(maplist[0]) - 2))
while maplist[self.position_y][self.position_x] == "x":
self.position_x = random.randint(0, (len(maplist) - 1))
self.position_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sample_mapped_keys(self):\r\n\r\n # With num_coverage=1 only the keys will be sampled\r\n actual = sample_mapped_keys(self.test_map, 1)\r\n self.assertEqual(actual, {'1': ['1'], '2': ['2']})\r\n\r\n actual = sample_mapped_keys(self.test_map, 3)\r\n for key in actual.keys... | [
"0.6235295",
"0.6196126",
"0.61928105",
"0.6118452",
"0.60727566",
"0.6048035",
"0.6003166",
"0.5947445",
"0.5936345",
"0.59303933",
"0.58924127",
"0.586839",
"0.58570385",
"0.58383924",
"0.5817358",
"0.5806295",
"0.58048785",
"0.57672346",
"0.5725036",
"0.5725036",
"0.572503... | 0.6995374 | 0 |
Returns the initial location of this object. | def getInitialLocation(self):
return self._location | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_alt_loc(self):\n return self.default_alt_loc",
"def get_initial_point(self):\r\n return self._studio.get_initial_point()",
"def get_origin(self):\n return self.zero",
"def start_loc(self) -> str:\n return self._start_loc",
"def get_origin(self):\n return s... | [
"0.7558399",
"0.73375237",
"0.73054683",
"0.7235104",
"0.71608335",
"0.7137725",
"0.7113328",
"0.7026934",
"0.6992983",
"0.6913296",
"0.68974197",
"0.6893482",
"0.6890375",
"0.6888621",
"0.68663657",
"0.68411374",
"0.68411374",
"0.68146896",
"0.6788716",
"0.6781255",
"0.67809... | 0.8698698 | 0 |
Reads the energy. returns energies found in the diracoutput files in filelist. | def readenergy(self, filelist):
energy=[]
tmpenergy=[]
for filename in filelist:
if not(os.path.exists(filename)):
if self._resultfile: self._resultfile.write('Output file: "'+filename+'" does not exist. Restart your calculation. \n')
else: print 'Output file: "'+filename+'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_energy(self, fname):\n outfile = open(fname)\n lines = outfile.readlines()\n outfile.close()\n\n energy = None\n for line in lines:\n if line.find('HEAT OF FORMATION') != -1:\n words = line.split()\n energy = float(words[5])\n ... | [
"0.7086508",
"0.708285",
"0.6795043",
"0.6768917",
"0.6695373",
"0.6663242",
"0.65436995",
"0.652793",
"0.6472127",
"0.6311504",
"0.6298959",
"0.6152937",
"0.61389047",
"0.61037445",
"0.60946065",
"0.59737444",
"0.5941638",
"0.5932472",
"0.5913029",
"0.5901953",
"0.58484244",... | 0.7640516 | 0 |
Makes a dictonary with how to read the output files. Returns nothing. For the easy to use character strings in keys the function reads the datafile. With this information a list of dictonaries is built and put into the variable _keydict. The useable names can be listed with the function keynames() | def set_keys(self, keys):
self._keydict=[]
self._keys=[]
# Connect userfriendly keywords to the characters that indicates the energy in Dirac.
for key in keys:
tmpdat=[]
infile=open(self._datafile, 'r')
if not infile:
if self._resultfile:
self._result... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DataLoad(filename,path,keys_to_search=['dstr','ORT'],text_file = False):\n\n OUTPUT_DICT = {}\n\n if not text_file:\n\n rdr = EafReader(filename, path, text_file=False)\n\n for key in keys_to_search:\n\n annot, annot_df = rdr.parser(key)\n DF = rdr.dataframe_creator(an... | [
"0.6992537",
"0.63537943",
"0.63483447",
"0.63251376",
"0.6192821",
"0.60494673",
"0.6024493",
"0.59666574",
"0.59539443",
"0.5948677",
"0.5942385",
"0.59367585",
"0.59194607",
"0.59025496",
"0.5849234",
"0.5810317",
"0.5801417",
"0.5754932",
"0.5750282",
"0.573261",
"0.56992... | 0.69034344 | 1 |
Writes the names of the keys that could be used to STDOUT or to _resultfile. Returns nothing | def keynames(self):
infile=open(self._datafile, 'r')
if self._resultfile: self._resultfile.write("Keys in datafile: "+self._datafile+'\n')
else: print ("Keys in datafile: "+self._datafile+'\n')
for tmpc in infile:
for i in range(0, len(tmpc)):
if tmpc[i:i+1]=='#': break
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _write_keypoint_results(keypoint_results, gt_folder, pred_folder):",
"def export_file(self):\n if self.args.keyfilter:\n self.filter_keys()\n if self.args.datafilter:\n self.filter_values()\n json.dump(self.outputdata, self.outfile, indent=self.args.indent)\n ... | [
"0.672782",
"0.62190783",
"0.59323156",
"0.58724725",
"0.58682984",
"0.57954323",
"0.5761679",
"0.5730018",
"0.57159007",
"0.5712536",
"0.5676965",
"0.56695795",
"0.5650905",
"0.564897",
"0.5632195",
"0.56272215",
"0.560844",
"0.55824125",
"0.55570793",
"0.5553363",
"0.553443... | 0.6835899 | 0 |
Set the list of files to be read Accessed through .files. Returns nothing. | def setfiles(self, filelist):
self._filelist=filelist
self._energy=self.readenergy(filelist) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_files(self, files: list = None):\n if not is_empty_arr(files):\n self._files = files",
"def listFiles(self):\n pass",
"def fileset(self):\n pass",
"def update(self):\n if os.path.isdir(self.full_path):\n self.file_list = os.listdir(self.full_path)\... | [
"0.7024085",
"0.68313926",
"0.6823761",
"0.6700469",
"0.6691884",
"0.6609458",
"0.6593145",
"0.65463704",
"0.65022755",
"0.64708245",
"0.63540703",
"0.63521343",
"0.6350075",
"0.62795043",
"0.6271418",
"0.62625027",
"0.624582",
"0.6244804",
"0.6167253",
"0.61467445",
"0.61424... | 0.708177 | 0 |
Add files to the end of the filelist. Returns their read energies. | def addfiles(self, filelist):
for tmpc in filelist:
self._filelist.append(tmpc)
tmp_energy=self.readenergy(filelist)
for tmpdat in tmp_energy:
self._energy.append(tmpdat)
return tmp_energy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertfiles(self, pos, filelist):\r\n for i in range(0, len(filelist)):\r\n self._filelist.insert(pos+i, filelist[i])\r\n tmp_energy=self.readenergy(filelist)\r\n for i in range(0, len(tmp_energy)):\r\n self._energy.insert(pos+i, tmp_energy[i])\r\n return tmp_energy",
"def add_files(sel... | [
"0.6711196",
"0.6418432",
"0.62716985",
"0.6196659",
"0.6169911",
"0.6086327",
"0.59367085",
"0.58788455",
"0.58760184",
"0.57898587",
"0.5785641",
"0.57034767",
"0.57004327",
"0.5663165",
"0.56618965",
"0.5629544",
"0.56114274",
"0.56029123",
"0.55897784",
"0.55780524",
"0.5... | 0.8065469 | 0 |
Insert file at position pos in the file list. Returns it's energies/ | def insertfile(self, pos, file):
self._filelist.insert(pos, file)
tmp_energy=self.readenergy([file])
for i in range(0, len(tmp_energy)):
self._energy.insert(pos+i, tmp_energy[i])
return tmp_energy[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertfiles(self, pos, filelist):\r\n for i in range(0, len(filelist)):\r\n self._filelist.insert(pos+i, filelist[i])\r\n tmp_energy=self.readenergy(filelist)\r\n for i in range(0, len(tmp_energy)):\r\n self._energy.insert(pos+i, tmp_energy[i])\r\n return tmp_energy",
"def addfiles(self... | [
"0.8262362",
"0.5946468",
"0.5841547",
"0.5443106",
"0.519077",
"0.5129954",
"0.5110636",
"0.50919867",
"0.5073317",
"0.5017984",
"0.49988976",
"0.49755192",
"0.49303234",
"0.49288973",
"0.49170265",
"0.48991424",
"0.4895956",
"0.48913643",
"0.48766756",
"0.48552522",
"0.4853... | 0.81386596 | 1 |
Insert a list of files at position pos in the file list. Returns their energies. | def insertfiles(self, pos, filelist):
for i in range(0, len(filelist)):
self._filelist.insert(pos+i, filelist[i])
tmp_energy=self.readenergy(filelist)
for i in range(0, len(tmp_energy)):
self._energy.insert(pos+i, tmp_energy[i])
return tmp_energy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertfile(self, pos, file):\r\n self._filelist.insert(pos, file)\r\n tmp_energy=self.readenergy([file])\r\n for i in range(0, len(tmp_energy)):\r\n self._energy.insert(pos+i, tmp_energy[i])\r\n return tmp_energy[0]",
"def addfiles(self, filelist):\r\n for tmpc in filelist:\r\n self.... | [
"0.7297772",
"0.62299746",
"0.54402405",
"0.5370709",
"0.53008914",
"0.5247944",
"0.52219343",
"0.51347685",
"0.5120666",
"0.50602365",
"0.50350565",
"0.4997518",
"0.49373466",
"0.48963982",
"0.4895969",
"0.48752096",
"0.48604277",
"0.48215386",
"0.48195642",
"0.47813186",
"0... | 0.8478526 | 0 |
Delete all files between max and min from the _filelist. | def delfiles(self, max=0, min=0):
# Removes the files from min up to max
for i in range(max-1, min-1, -1):
if i<len(self._filelist):
del self._filelist[i]
if i<len(self._energy):
del self._energy[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_files(file_list):\n###############################################################################\n for fpath in file_list:\n if os.path.exists(fpath):\n os.remove(fpath)\n # End if\n # End for",
"def DeleteFiles(self, min_size=0):\n\n ndeleted = 0\n for f... | [
"0.6221175",
"0.6209422",
"0.60798913",
"0.6001565",
"0.59255946",
"0.5850927",
"0.5819805",
"0.58054554",
"0.579091",
"0.5698838",
"0.5651804",
"0.5651673",
"0.56408966",
"0.5640656",
"0.56275594",
"0.5618696",
"0.5604296",
"0.55829805",
"0.5527234",
"0.547274",
"0.546802",
... | 0.78210205 | 0 |
Returns the current _filelist. Accessed through .files | def get_files(self):
return self._filelist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listFiles(self):\n pass",
"def get_file_list(self):\n try:\n for filename in os.listdir(SHARED_DIR):\n self.file_list.append(filename)\n except Exception as e:\n print \"Error: retriving file list, %s\" % e",
"def __init__(self):\n self.filel... | [
"0.7358803",
"0.734229",
"0.71822",
"0.70319045",
"0.702763",
"0.70001733",
"0.69906056",
"0.69851583",
"0.68934256",
"0.68574464",
"0.6807691",
"0.6791865",
"0.67466885",
"0.6745575",
"0.66323113",
"0.6553671",
"0.65483415",
"0.6502841",
"0.64942795",
"0.6484744",
"0.6462570... | 0.8797185 | 0 |
Change the resultfile. Accessed through .resultfile | def set_resultfile(self, file):
self._resultfile=file | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_result(self, file_name):\n f = file(file_name, \"w\")\n f.write(self.m_result)\n f.close()",
"def set_result_file(self, file_name):\n if file_name is not None:\n self.opts[\"result_file_name\"] = file_name\n else:\n self.opts[\"result_file_name\"... | [
"0.72395635",
"0.70098424",
"0.6764218",
"0.66742396",
"0.6625944",
"0.6565123",
"0.6525431",
"0.64383346",
"0.63236547",
"0.6314388",
"0.62754613",
"0.62360525",
"0.61103517",
"0.61034817",
"0.59743166",
"0.5973691",
"0.59708005",
"0.5964662",
"0.592152",
"0.58801514",
"0.58... | 0.7958902 | 0 |
Return the current resultfile. Accessed through .resultfile | def get_resultfile(self):
return self._resultfile | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetResultFile(self):\n\n file_path = self.configfile.map['ResultFilePath']\n\n # Check if several entrie\n if file_path is not None:\n if len(file_path) > 1:\n warning(\n 'Many path for the result file are setted ({}), I will take the first one'... | [
"0.7389495",
"0.68382645",
"0.6615491",
"0.64539397",
"0.6348082",
"0.63120145",
"0.6282585",
"0.62605387",
"0.6229086",
"0.6192739",
"0.61694807",
"0.6115375",
"0.60991883",
"0.6087382",
"0.6084712",
"0.60831773",
"0.6068043",
"0.6031894",
"0.60297304",
"0.6025069",
"0.60184... | 0.88122743 | 0 |
Ensures that the provided object path conforms to the DBus standard. Throws a L{error.MarshallingError} if nonconformant | def validateObjectPath(p):
if not p.startswith('/'):
raise MarshallingError('Object paths must begin with a "/"')
if len(p) > 1 and p[-1] == '/':
raise MarshallingError('Object paths may not end with "/"')
if '//' in p:
raise MarshallingError('"//" is not allowed in object paths"')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pathlib_obj(self):\n \"\"\"\n We do this because pygame functions internally use pg_EncodeString\n to decode the filenames passed to them. So if we test that here, we\n can safely assume that all those functions do not have any issues\n with pathlib objects\n \"\"... | [
"0.54732823",
"0.5256893",
"0.5144109",
"0.4995298",
"0.49384198",
"0.4835352",
"0.478868",
"0.47768828",
"0.4728277",
"0.47244215",
"0.471736",
"0.47147894",
"0.46644646",
"0.4659947",
"0.465669",
"0.4590839",
"0.45773673",
"0.45689",
"0.45658988",
"0.45398143",
"0.4528572",... | 0.59882015 | 0 |
Verifies that the supplied name is a valid DBus Interface name. Throws an L{error.MarshallingError} if the format is invalid | def validateInterfaceName(n):
try:
if '.' not in n:
raise Exception('At least two components required')
if '..' in n:
raise Exception('".." not allowed in interface names')
if len(n) > 255:
raise Exception('Name exceeds maximum length of 255')
if n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateBusName(n):\n try:\n if '.' not in n:\n raise Exception('At least two components required')\n if '..' in n:\n raise Exception('\"..\" not allowed in bus names')\n if len(n) > 255:\n raise Exception('Name exceeds maximum length of 255')\n i... | [
"0.6249034",
"0.6138677",
"0.5944746",
"0.5854724",
"0.5783322",
"0.5767728",
"0.5706411",
"0.5702007",
"0.5684922",
"0.5588679",
"0.55774987",
"0.5547274",
"0.5466605",
"0.5456653",
"0.544468",
"0.54201376",
"0.5366448",
"0.5361167",
"0.5352273",
"0.534587",
"0.5299094",
"... | 0.7287379 | 0 |
Verifies that the supplied name is a valid DBus Bus name. Throws an L{error.MarshallingError} if the format is invalid | def validateBusName(n):
try:
if '.' not in n:
raise Exception('At least two components required')
if '..' in n:
raise Exception('".." not allowed in bus names')
if len(n) > 255:
raise Exception('Name exceeds maximum length of 255')
if n[0] == '.':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _verify_name(name):\n if isinstance(name, str):\n name = name.encode(\"utf-8\")\n\n if not isinstance(name, bytes):\n raise TypeError(\n \"Name {!r} is not a string or byte string\".format(name)\n )\n\n if b\".\" in name:\n raise V... | [
"0.6328239",
"0.60769504",
"0.6054338",
"0.6011703",
"0.5934793",
"0.5782472",
"0.57623523",
"0.574703",
"0.57247126",
"0.5692703",
"0.5543336",
"0.55390483",
"0.5524516",
"0.5497659",
"0.54381436",
"0.543146",
"0.539284",
"0.5378268",
"0.53725094",
"0.53675413",
"0.5350507",... | 0.7423474 | 0 |
Verifies that the supplied name is a valid DBus member name. Throws an L{error.MarshallingError} if the format is invalid | def validateMemberName(n):
try:
if len(n) < 1:
raise Exception('Name must be at least one byte in length')
if len(n) > 255:
raise Exception('Name exceeds maximum length of 255')
if n[0].isdigit():
raise Exception('Names may not begin with a digit')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidDataTypeName(name: unicode) -> bool:\n ...",
"def validateBusName(n):\n try:\n if '.' not in n:\n raise Exception('At least two components required')\n if '..' in n:\n raise Exception('\"..\" not allowed in bus names')\n if len(n) > 255:\n ... | [
"0.6429723",
"0.62362033",
"0.6177577",
"0.6054941",
"0.6011524",
"0.58804786",
"0.58333224",
"0.58264023",
"0.57906777",
"0.57682234",
"0.5758976",
"0.57252425",
"0.57006663",
"0.5695194",
"0.5691282",
"0.56714183",
"0.56466067",
"0.56451",
"0.564391",
"0.560903",
"0.5603861... | 0.77475756 | 0 |
Returns the DBus signature type for the argument. If the argument is an instance of one of the type wrapper classes, the exact type signature corresponding to the wrapper class will be used. If the object has a variable named 'dbusSignature', the value of that variable will be used. Otherwise, a generic type will be us... | def sigFromPy(pobj):
sig = getattr(pobj, 'dbusSignature', None)
if sig is not None:
return sig
elif isinstance(pobj, bool):
return 'b'
elif isinstance(pobj, int):
return 'i'
elif isinstance(pobj, int):
return 'x'
elif isinstance(pobj, float):
return 'd'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_type ( self, object ):\n return self.type",
"def get_type ( self, object ):\n return self.type",
"def type_signature(self) -> computation_types.Type:\n raise NotImplementedError",
"def serialize_to_signature(value):\n serialization_cls = _get_serializer_for_value(value, serializin... | [
"0.5474694",
"0.5474694",
"0.5409444",
"0.5328905",
"0.52887535",
"0.521691",
"0.51724213",
"0.5155565",
"0.51536465",
"0.51384646",
"0.50888366",
"0.50765437",
"0.5045696",
"0.49954993",
"0.49776474",
"0.49498105",
"0.49469578",
"0.49323153",
"0.49192646",
"0.4914251",
"0.49... | 0.629868 | 0 |
Encodes the Python objects in variableList into the DBus wireformat matching the supplied compoundSignature. This function retuns a list of binary strings is rather than a single string to simplify the recursive marshalling algorithm. A single string may be easily obtained from the | def marshal(compoundSignature, variableList,
startByte=0, lendian=True, oobFDs=None):
chunks = []
bstart = startByte
if hasattr(variableList, 'dbusOrder'):
order = variableList.dbusOrder
variableList = [getattr(variableList, attr_name)
for attr_name in or... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_list(list_raw):\n list_serialized = []\n for value in list_raw:\n if isinstance(value, list):\n list_serialized.append(serialize_list(value))\n elif isinstance(value, dict):\n list_serialized.append(serialize_dict(value))\n else:\n list_seri... | [
"0.5918284",
"0.5918284",
"0.5766241",
"0.550993",
"0.54382807",
"0.5433743",
"0.53844094",
"0.5381437",
"0.53691435",
"0.5350298",
"0.52913684",
"0.52551824",
"0.5226429",
"0.5210715",
"0.52086335",
"0.51800555",
"0.51722974",
"0.51387507",
"0.512357",
"0.51076096",
"0.50836... | 0.7213802 | 0 |
The method returns dictionary contains degree each vertex in graph. | def vertice_degree(self):
if(self.is_empty()):
raise ValueError("Graph is empty.")
else:
if(self.__directed):
degrees = {}
l = list(self.__graph_dict.values())
flatter = []
for x in l:
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_degrees_dictionary(edges):\n dd = {} # degrees dictionary for vertexes\n\n def append_vertex(vertex, edge_index):\n if vertex not in dd.keys():\n dd[vertex] = [1, edge_index]\n else:\n dd[vertex][0] += 1\n dd[vertex].append(edge_index)\n\n e = edges\... | [
"0.7764501",
"0.75081825",
"0.74249536",
"0.73860043",
"0.7194386",
"0.7127516",
"0.70553905",
"0.70345974",
"0.70215124",
"0.6976104",
"0.6976104",
"0.6976104",
"0.69607127",
"0.6951132",
"0.69395113",
"0.69182175",
"0.6895664",
"0.68444467",
"0.6802162",
"0.6783748",
"0.673... | 0.81927633 | 0 |
This function returns dictionary of vertices and their color, the function uses SL algorithm and greedily coloring. The Result visualization uses the networkx and matplotlib libraries. | def vertex_coloring(self, display = False):
stack = self.SL_algorithm()
color_of_vertex = self.greedily_coloring(stack)
if(display):
self.display_graph(color_of_vertex)
return color_of_vertex
else:
return color_of_vertex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_colors(vertex):\n\n def calculate_colors(v):\n \"\"\"\n Calculate the color for name of the given vertex v.\n :param v: Name of vertex to be hashed.\n :return: Tuple of (hue, saturation, lightness) values.\n \"\"\"\n\n # Define constant color values\n li... | [
"0.62638813",
"0.6236624",
"0.6217388",
"0.61086094",
"0.60408974",
"0.6028744",
"0.601162",
"0.58705133",
"0.5859937",
"0.58007324",
"0.57782114",
"0.57776314",
"0.5769344",
"0.5746869",
"0.57331896",
"0.573234",
"0.57293206",
"0.57200795",
"0.5713795",
"0.5711248",
"0.56534... | 0.6867616 | 0 |
Removes tags from post title and adds them to a set. Any tags such as [FRESH], (feat. JBobby), etc. will be removed from the title and placed in a set (without surrounding punctuation). Titles are also lowercased and any dashes/extra white space are removed. | def filter_tags(title):
tags = set()
filtered_title = []
# separate tags from title
# assumes there are no erroneous parentheses/brackets
# ex. [FRESH] Lil Pump - Nice 2 Yeet ya [prod. by D4NNY]
# there may be issues if song name contains parentheses
tag = []
last_pun = None
add_to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_title(self):\n # split into tokens by white space\n tokens = self.title.split(\" \")\n # remove punctuation from each token\n table = str.maketrans('', '', punctuation)\n tokens = [w.translate(table) for w in tokens] # type: List[Any]\n # remove remaining tokens... | [
"0.6937355",
"0.66450447",
"0.64621973",
"0.6377635",
"0.6275683",
"0.6235725",
"0.6164819",
"0.61293006",
"0.60720676",
"0.6012441",
"0.5995282",
"0.59429306",
"0.59248",
"0.5892935",
"0.5872065",
"0.58714795",
"0.58687013",
"0.58097196",
"0.5798257",
"0.5796392",
"0.5791276... | 0.7703674 | 0 |
Get the first Spotify track url from a given search. Extended description of function. | def extract_track_url(search):
if 'tracks' in search:
tracks = search['tracks']
if 'items' in tracks:
items = tracks['items']
# take the first url we can find
for item in items:
if 'external_urls' in item:
external_urls = item[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_song(title, artist):\n\ttitle = quote(title, safe='')\n\tartist = quote(artist, safe='')\n\tbase_url = SPOTIFY_API_HOST + 'search/' + '?q=track:{0}+artist:{1}&type=track&limit=1'\n\turl = base_url.format(title, artist)\n\tresults = requests.get(url).json()\n\n\ttry:\n\t\tif results['tracks']['total'] ==... | [
"0.6630882",
"0.61365277",
"0.6100608",
"0.60191",
"0.59961325",
"0.5867838",
"0.58076715",
"0.5792723",
"0.5750998",
"0.568006",
"0.56769896",
"0.567169",
"0.5664377",
"0.560161",
"0.55912936",
"0.5582274",
"0.5577718",
"0.5554772",
"0.55373526",
"0.553512",
"0.5527581",
"... | 0.81856936 | 0 |
Extracts and formats data in dictionnaries from Our World in Data CSV files | def Extract_data():
chdir(Datafiles_directory) # Empty the datafiles directory
File_list = listdir()
for File in File_list:
remove(File)
COVID_data_path = Datafiles_directory + '\\OWID COVID data %s.csv' % (date.today().isoformat()) # String with path of COVID data (wher... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_trick_ascii(csv_file):\n data_file = csv.DictReader(open(csv_file))\n single_run_data_dict = {'altitude' : [0.0],\n 'latitude' : [0.0],\n 'longitude' : [0.0]}\n # Your code here\n # ...\n # return the dict\n return single_run_data_di... | [
"0.65972245",
"0.65949285",
"0.657538",
"0.6556348",
"0.65216136",
"0.639683",
"0.6318729",
"0.62956554",
"0.62589234",
"0.62322074",
"0.61776733",
"0.61724085",
"0.615015",
"0.6124557",
"0.6119837",
"0.61124694",
"0.6111998",
"0.61089385",
"0.6104878",
"0.61042136",
"0.61000... | 0.6641062 | 0 |
Exports the raw and reconstructed data in seperate files | def Export_in_files(COVID_data, COVID_data_reconstructed):
F_data_file = open(Datafiles_directory + '\\OWID COVID data %s formatted.csv' % (date.today().isoformat()), 'w')
FR_data_file = open(Datafiles_directory + '\\OWID COVID data %s formatted reconstructed.csv' % (date.today().isoformat()), 'w')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_file(self):\n if self.args.keyfilter:\n self.filter_keys()\n if self.args.datafilter:\n self.filter_values()\n json.dump(self.outputdata, self.outfile, indent=self.args.indent)\n self.outfile.write('\\n')",
"def write_data_files(self):\n # build our... | [
"0.6854881",
"0.65517116",
"0.64988494",
"0.6373401",
"0.6348319",
"0.633782",
"0.62861234",
"0.6257868",
"0.6209314",
"0.61787605",
"0.6174007",
"0.6167421",
"0.61625797",
"0.6160978",
"0.6130941",
"0.6127147",
"0.6127147",
"0.6126146",
"0.60960144",
"0.6093455",
"0.6092773"... | 0.66929203 | 1 |
Extract data from recontructed COVID data in order to only keep data that will be plotted | def Extract_data_for_plotting(COVID_data, X_Axis_inc, Y_Axis_inc, Z_Axis_inc, Date_start, Date_end, Keep_no_PR = True):
Date_start_obj = datetime.strptime(Date_start, '%Y-%m-%d') # Create a list of all the dates to extract
Date_end_obj = datetime.strptime(Date_end, '%Y-%m-%d')
Date_difference = (Date_end... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_data():\n raw_data = pd.read_csv(\"../../../resource/DataVisualization/vaccinations.csv\")\n raw_data = raw_data[[\"location\", \"date\", \"people_fully_vaccinated_per_hundred\"]]\n raw_data.date = pd.to_datetime(raw_data.date, format=\"%Y-%m-%d\")\n min_date = raw_data.date.min()\n raw_... | [
"0.57332987",
"0.55896175",
"0.5566017",
"0.5560256",
"0.5542593",
"0.5458466",
"0.5445852",
"0.5408674",
"0.5361703",
"0.53353846",
"0.5209567",
"0.5194203",
"0.5185767",
"0.5149763",
"0.5145616",
"0.5144321",
"0.51424706",
"0.5139271",
"0.512649",
"0.5118692",
"0.5095719",
... | 0.58592325 | 0 |
Tells which countries to annotate and which not to. Since the lists in parameters are sorted by descending order of positivity rate, the countries with higher positivity rates will be examined first and thus annotatd with more priority | def Annotations_frame(Points_to_display, Countries_displayed, Frame_limits):
X_list_frame, Y_list_frame = zip(*Points_to_display) # Transform tuples of (X, Y) into 2 distinct lists of X and Y coordinates
Frame_limits_log = list(map(np.log10, Frame_limits))
X_min_log, X_max_log, Y_min_log, Y_max_log... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def country_hint(self, value):\n return None",
"def SuggestGeoTargetConstants(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.set_details('Method not implemented!')\n raise NotImplementedError('Method not implemented!')",
"def annotate(self, op_list=None):\n... | [
"0.5223514",
"0.47812617",
"0.47808456",
"0.47056314",
"0.46838796",
"0.46759918",
"0.4672632",
"0.466754",
"0.4616049",
"0.46070912",
"0.46006083",
"0.45805907",
"0.4577782",
"0.45505515",
"0.45467195",
"0.45305893",
"0.45272925",
"0.45201805",
"0.45035627",
"0.44953334",
"0... | 0.48259857 | 1 |
Selects the given stream ID for output. | def select(self, stream):
if stream not in self._selectedStreams:
self._selectedStreams.append(stream) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select(self, stream):\n\n # TODO: Ensure section 10.2.4, so that while stream 1 is selected,\n # the only text printed to it is that of the player's commands and\n # keypresses (as read by read_char). Not sure where this logic\n # will ultimately go, however.\n\n self._selectedStream = stream",
... | [
"0.6556641",
"0.57983565",
"0.57682925",
"0.5695478",
"0.5601869",
"0.5586684",
"0.5173582",
"0.5119291",
"0.50920683",
"0.5044393",
"0.50269234",
"0.50198567",
"0.5000961",
"0.4981254",
"0.4974197",
"0.49709654",
"0.49602035",
"0.49532992",
"0.49346712",
"0.49329248",
"0.490... | 0.625652 | 1 |
Unselects the given stream ID for output. | def unselect(self, stream):
if stream in self._selectedStreams:
self._selectedStreams.remove(stream) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsetId(self):\n return _libsbml.Output_unsetId(self)",
"def unsetId(self):\n return _libsbml.Port_unsetId(self)",
"def unsetId(self):\n return _libsbml.Input_unsetId(self)",
"def unsubscribe(id, userId):\n db = core.connect()\n theUser = db[userId]\n if id in theUser[\"stre... | [
"0.617944",
"0.5672837",
"0.55219626",
"0.54870343",
"0.5482912",
"0.5464178",
"0.53850687",
"0.5304198",
"0.52740335",
"0.5231818",
"0.52296126",
"0.5224535",
"0.51276076",
"0.51187307",
"0.50885695",
"0.5000303",
"0.5000303",
"0.49989292",
"0.49881366",
"0.49865478",
"0.497... | 0.71225864 | 0 |
Writes the given unicode string to all currently selected output streams. | def write(self, string):
# TODO: Implement section 7.1.2.2 of the Z-Machine Standards
# Document, so that while stream 3 is selected, no text is
# sent to any other output streams which are selected. (However,
# they remain selected.).
# TODO: Implement section 7.1.2.2.1, so that newlines are writ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, ucs, encoding='ascii'):\n self.lock.acquire()\n self.oqueue.send(('output', (ucs, encoding)))\n self.lock.release()",
"def write(self, string):\n\n if not self.enabled:\n return\n\n try:\n print(string, end=\"\", file=self.fp)\n exce... | [
"0.6019549",
"0.58811754",
"0.5840764",
"0.58179307",
"0.56729674",
"0.55562913",
"0.54668236",
"0.546056",
"0.54414606",
"0.5426918",
"0.5381758",
"0.53490806",
"0.53453517",
"0.5334099",
"0.52888536",
"0.5281868",
"0.52776235",
"0.5273485",
"0.5263722",
"0.52095383",
"0.520... | 0.67882425 | 0 |
Selects the given stream ID as the currently active input stream. | def select(self, stream):
# TODO: Ensure section 10.2.4, so that while stream 1 is selected,
# the only text printed to it is that of the player's commands and
# keypresses (as read by read_char). Not sure where this logic
# will ultimately go, however.
self._selectedStream = stream | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select(self, stream):\n\n if stream not in self._selectedStreams:\n self._selectedStreams.append(stream)",
"def getSelected(self):\n\n return self._streams[self._selectedStream]",
"def select_stream(self, index=None, name=None, raw_name=None, update=True):\r\n stream = None\r\n try... | [
"0.7090956",
"0.63077545",
"0.5944891",
"0.56851655",
"0.5507112",
"0.5483096",
"0.53433263",
"0.53100574",
"0.52421796",
"0.52342975",
"0.5193063",
"0.517651",
"0.5166759",
"0.5165178",
"0.51437676",
"0.5016381",
"0.50112075",
"0.4981479",
"0.49758804",
"0.49596596",
"0.4958... | 0.7003565 | 1 |
Converts all occurrences of Complexes (resp. sub trees named agent) with its vector representation. These are directly replaced within the tree expression. Moreover, in the process parameters are replaces with their values (if given). | def vectorize(self, ordering: SortedList, definitions: dict) -> list:
vec = Vectorizer(ordering, definitions)
self.expression = vec.transform(self.expression)
return vec.visited | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def express(expr, system, system2=None, variables=False):\n\n if expr in (0, Vector.zero):\n return expr\n\n if not isinstance(system, CoordSys3D):\n raise TypeError(\"system should be a CoordSys3D \\\n instance\")\n\n if isinstance(expr, Vector):\n if system2 i... | [
"0.5212036",
"0.52045906",
"0.51515454",
"0.5148588",
"0.51139396",
"0.50830597",
"0.50787544",
"0.5040814",
"0.50208473",
"0.50208473",
"0.50208473",
"0.50208473",
"0.50208473",
"0.50208473",
"0.50208473",
"0.4996494",
"0.4929204",
"0.48569438",
"0.4855723",
"0.48394084",
"0... | 0.52657586 | 0 |
Evaluates all occurrences of States to a float using Evaluater. It is done as intersection of particular state with given state and sum of resulting elements. If the result is nan, None is returned instead. | def evaluate(self, state) -> float:
evaluater = Evaluater(state)
result = evaluater.transform(self.expression)
try:
value = sympy.sympify("".join(tree_to_string(result)), locals=evaluater.locals)
if value == sympy.nan:
return None
return value... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, state):\n\n fitness = np.sum(state)\n self.num_evals += 1\n #print(self.num_evals)\n return fitness",
"def evaluate(self, state):\n\n if self.is_coords and len(state) != len(self.coords):\n raise Exception(\"\"\"state must have the same length as c... | [
"0.63039607",
"0.6107048",
"0.6043089",
"0.59678954",
"0.59345084",
"0.59076506",
"0.5898974",
"0.5843427",
"0.5723326",
"0.5705815",
"0.5685411",
"0.5680647",
"0.5665845",
"0.56275225",
"0.55861384",
"0.5577219",
"0.5554043",
"0.554357",
"0.55327356",
"0.55058116",
"0.550581... | 0.670078 | 0 |
Extracts all agents (Complex objects) and params (strings) used in the rate expression. | def get_params_and_agents(self):
transformer = Extractor()
transformer.transform(self.expression)
return transformer.agents, transformer.params | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_params(self, fluents):\n objects_all = set()\n for fluent in fluents:\n objects = fluent.replace(\"(\",\"\").replace(\")\",\"\").split(\" \")[1:]\n objects_all.update(objects)\n\n return objects_all",
"def agency_parse(sents):\r\n agency_list = []\r\n for... | [
"0.5253063",
"0.5249049",
"0.51650333",
"0.51618207",
"0.5152103",
"0.5011535",
"0.4967004",
"0.4956623",
"0.49522108",
"0.4817477",
"0.4795467",
"0.47801977",
"0.4771185",
"0.47636265",
"0.47541422",
"0.47347352",
"0.47026265",
"0.46918315",
"0.46914902",
"0.46741778",
"0.46... | 0.6133339 | 0 |
Create mathML representation of the formula. | def to_mathML(self):
transformer = MathMLtransformer()
expression = transformer.transform(self.expression)
return "".join(tree_to_string(expression)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test4():\r\n xmlstr = u\"\"\"\r\n<math xmlns=\"http://www.w3.org/1998/Math/MathML\">\r\n <mstyle displaystyle=\"true\">\r\n <mn>1</mn>\r\n <mo>+</mo>\r\n <mfrac>\r\n <mn>2</mn>\r\n <mi>α</mi>\r\n </mfrac>\r\n </mstyle>\r\n</math>\r\n\"\"\"\r\n return formula(xmlstr)",
"def test6... | [
"0.7040604",
"0.68138045",
"0.65808046",
"0.6574732",
"0.65385926",
"0.6472483",
"0.6285012",
"0.62663835",
"0.624848",
"0.62187535",
"0.6161438",
"0.61542505",
"0.6119849",
"0.61086386",
"0.60873944",
"0.60085154",
"0.60085154",
"0.59776056",
"0.5968168",
"0.5900165",
"0.588... | 0.7725084 | 0 |
Create list representation of the formula. | def get_formula_in_list(self):
return tree_to_string(self.expression) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formula(self):\n terms = []\n for ff in self.formulae:\n terms += list(ff.terms)\n return Formula(terms)",
"def list_formulae():\n return _list_tindyb_unique_values(\"formula\", dbpath=__dbpath__)",
"def _calculate_loss_formula(self) -> List[List[List[Tuple]]]:\n s... | [
"0.70437",
"0.6676098",
"0.6222351",
"0.60658044",
"0.60172814",
"0.6002962",
"0.5927992",
"0.58624697",
"0.5815177",
"0.5806504",
"0.5780762",
"0.57806325",
"0.57665807",
"0.57629836",
"0.57332253",
"0.5726223",
"0.5720341",
"0.5717428",
"0.56982076",
"0.56982076",
"0.569368... | 0.69195604 | 1 |
initialize a bullet at the ship position | def __init__(self, ai_settings, screen, ship):
super().__init__()
self.screen = screen
# create a bullet and set its position
self.rect = pygame.Rect(0, 0, ai_settings.bullet_width,
ai_settings.bullet_height)
self.rect.centerx = ship.rect.centerx
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, screen, ship):\n\n super().__init__()\n self.__screen = screen\n self.__ship = ship\n\n # bullet settings | may need to add to settings.py if each bullet makes a new bullet object. This will save memory by making less variables.\n self.__speed = 10.0\n s... | [
"0.77932",
"0.77842873",
"0.7643124",
"0.7577425",
"0.738928",
"0.7282866",
"0.7248737",
"0.72338456",
"0.713622",
"0.7041886",
"0.70413834",
"0.69640034",
"0.69577575",
"0.6927438",
"0.69020337",
"0.6869925",
"0.6840654",
"0.68373877",
"0.6827241",
"0.67168593",
"0.67021334"... | 0.7887299 | 0 |
We set the adapted methods in the object's dict | def __init__(self, obj, **adapted_methods):
self.obj = obj
self.__dict__.update(adapted_methods) # 将传入的实例属性作为适配器实例的属性 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, obj, adapted_methods):\n self.obj = obj\n self.__dict__.update(adapted_methods)",
"def __methodDict(cls, _dict):\n baseList = list(cls.__bases__)\n baseList.reverse()\n for _super in baseList:\n __methodDict(_super, _dict)\n for key, value in cls.__dict__.items... | [
"0.83028156",
"0.6736908",
"0.650515",
"0.64653665",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
"0.6337329",
... | 0.7568555 | 1 |
reads table 3 (the header table) Word Name Type Description 1 ACODE(C) I Device code + 10Approach code 2 TCODE(C) I Table code 92 3 UNDEF(3) None 6 DCYCLE I Design cycle number 7 ROBJ RS Objective value 8 RCON RS Critical constraint value 9 UNDEF None 10 NUMWDE I Number of words per entry in DATA record (always 2) 11 U... | def _read_onmd_3(self, data: bytes, ndata: int):
op2 = self.op2
op2.to_nx('; found ONMD (normalized mass density) table')
#self.log.info('OUG table 3')
#self.show_data(data, types='ifs')
#self.log.info('----------------------------')
#self.show_ndata(400, types='if')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_onr1_3(self, data: bytes, ndata: int):\n op2 = self.op2\n op2._analysis_code_fmt = b'i'\n op2.words = [\n 'aCode', 'tCode', 'eTotal', 'isubcase',\n '???', '???', 'element_name', 'load_set',\n 'format_code', 'num_wide', 'cva... | [
"0.6097406",
"0.6090162",
"0.58685327",
"0.58382773",
"0.57640666",
"0.57008547",
"0.5666904",
"0.5664526",
"0.5606233",
"0.56033313",
"0.5600495",
"0.55739087",
"0.5550053",
"0.55278754",
"0.5525435",
"0.54984826",
"0.54799986",
"0.54679996",
"0.5458644",
"0.5425266",
"0.540... | 0.6139688 | 0 |
False means that gps is already enabled | def enable_gps(self):
# No need to use as I have enabled GPS on start
self.pass_command(b"AT+CGPS=1")
return self.read_output() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_gps(self):\n row_type = self.get_type()\n is_gps = row_type in ('hidden geopoint', 'geopoint')\n return is_gps",
"def is_opgepakt(self) -> bool:\n return not GPIO.input(self._afstandsensor_input_pin)",
"def is_on(self):\n return False",
"def disable_gps(self):\n ... | [
"0.66482323",
"0.6637851",
"0.65072066",
"0.6449804",
"0.6438032",
"0.6392123",
"0.6270508",
"0.6245589",
"0.6098313",
"0.608869",
"0.60436463",
"0.6031218",
"0.60095996",
"0.5978279",
"0.5975354",
"0.5967209",
"0.5967209",
"0.5895945",
"0.5873593",
"0.5867402",
"0.58629614",... | 0.70518 | 0 |
False means that gps is already disabled | def disable_gps(self):
self.pass_command(b"AT+CGPS=0,1")
return self.read_output() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _isdisable(self):\n return self.dp.state()==PyTango.DevState.DISABLE",
"def is_opgepakt(self) -> bool:\n return not GPIO.input(self._afstandsensor_input_pin)",
"def enable_gps(self):\n # No need to use as I have enabled GPS on start\n self.pass_command(b\"AT+CGPS=1\")\n r... | [
"0.6694648",
"0.6677886",
"0.66372824",
"0.6571751",
"0.65400213",
"0.649015",
"0.6470005",
"0.63290757",
"0.6236902",
"0.62049824",
"0.62049824",
"0.619324",
"0.6179001",
"0.6176285",
"0.6136987",
"0.6122205",
"0.60925853",
"0.6070729",
"0.60671014",
"0.604607",
"0.6012523",... | 0.69180495 | 0 |
Takes in RGB channels in range 0255 and outputs L or AB channels in range 1 to 1 | def rgb_to_lab(img, l=False, ab=False):
img = img / 255
l_chan = color.rgb2lab(img)[:, :, 0]
l_chan = l_chan / 50 - 1
l_chan = l_chan[..., np.newaxis]
ab_chan = color.rgb2lab(img)[:, :, 1:]
ab_chan = (ab_chan + 128) / 255 * 2 - 1
if l:
return l_chan
else:
return ab_chan | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lab_to_rgb(img_l, img_ab):\n lab = np.empty([*img_l.shape[0:2], 3])\n lab[:, :, 0] = np.squeeze(((img_l + 1) * 50))\n lab[:, :, 1:] = img_ab * 127\n return color.lab2rgb(lab)",
"def convert_rgb_cmyk(rcol, gcol, bcol):\n if (rcol == 0) and (gcol == 0) and (bcol == 0):\n # black\n ... | [
"0.67191994",
"0.67153925",
"0.66415703",
"0.65657836",
"0.6533678",
"0.6436578",
"0.6332531",
"0.63095754",
"0.6278812",
"0.62779766",
"0.6174344",
"0.6166381",
"0.6164907",
"0.6087721",
"0.6085063",
"0.60826355",
"0.60440445",
"0.6035109",
"0.6034019",
"0.6017981",
"0.59934... | 0.716853 | 0 |
Determine the compression suffix | def infer_compression_suffix(compression="gzip"):
assert (
compression in compress_options
), "{} is not supported, select one of {}".format(
compression, list(compress_options.keys())
)
return compress_options[compression] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suffix(self):\n return self[\"suffix\"]",
"def suffix(self):\n return self[\"suffix\"]",
"def suffix(self):\n return self._suffix",
"def suffix(self):\n return self._suffix",
"def suffix(self):\n return self._suffix",
"def suffix ( self ) :\n return self.__su... | [
"0.6995122",
"0.6995122",
"0.6859668",
"0.6859668",
"0.6859668",
"0.67904246",
"0.67904246",
"0.6689125",
"0.66733366",
"0.66489536",
"0.6596177",
"0.65468204",
"0.6513631",
"0.64851665",
"0.6457852",
"0.6457852",
"0.6415643",
"0.63191026",
"0.6309062",
"0.62950456",
"0.61675... | 0.78440577 | 0 |
Creates tables for Landslide Risk Knowledge Base in PostgreSQL/PostGIS. | def create_tables():
pk_contraint = "CONSTRAINT {}_pk PRIMARY KEY ({})"
uq_contraint = "CONSTRAINT {}_uq UNIQUE ({})"
fk_query = """CONSTRAINT {}_fk_{}
FOREIGN KEY ({})
REFERENCES {}({})
ON UPDATE CASCADE
O... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_tables(self):\n try:\n self.cursor.execute('CREATE SCHEMA sandbox')\n self.cursor.execute(\"DROP TABLE sandbox.dvds_rdbhdb_super;\")\n except (db.ProgrammingError, db.OperationalError), e:\n # sandbox may not exist\n pass #raise\n\n try:\n ... | [
"0.69526476",
"0.69389075",
"0.6879835",
"0.67891175",
"0.6712477",
"0.6712477",
"0.6628316",
"0.6614976",
"0.65785325",
"0.65687066",
"0.6565796",
"0.65031064",
"0.6483932",
"0.6443893",
"0.64278096",
"0.6412687",
"0.6409078",
"0.63635635",
"0.6348073",
"0.628319",
"0.628109... | 0.70119447 | 0 |
Given a directory, find the heterodyned data files and sort them into a dictionary keyed on the source name with each value being a subdictionary keyed by detector name and pointing to the heterodyned file. This assumes | def find_heterodyned_files(hetdir, ext="hdf5"):
if not isinstance(hetdir, (str, Path)):
raise TypeError("hetdir must be a string or Path object")
hetpath = Path(hetdir)
if not hetpath.is_dir():
raise ValueError(f"{hetdir} is not a directory")
# get all files with correct extension
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_file_dict():\n import os\n file_dict = {}\n for root, dirs, files in os.walk('.'):\n dirs[:] = [ # add any extra dirs to ignore #\n d for d in dirs\n if '.' not in d\n and 'ENV' not in d\n and '__' not in d\n and 'build' not in d\n ... | [
"0.6215566",
"0.6135195",
"0.6096218",
"0.60056674",
"0.5989737",
"0.5972656",
"0.5945372",
"0.5938925",
"0.5867696",
"0.585495",
"0.58186024",
"0.57985175",
"0.5786209",
"0.577147",
"0.57117325",
"0.56910574",
"0.56901246",
"0.56848365",
"0.5684253",
"0.56584734",
"0.5646487... | 0.6336369 | 0 |
Plot the signaltonoise ratio for a set of sources versus their Bayesian odds. The inputs can either be a dictionary of SNRs, keyed on source name, and a dictionary of odds values, also keyed on source name, or it can be a directory path containing a set of cwinpy_pe parameter estimation results and a directory containi... | def plot_snr_vs_odds(S, R, **kwargs):
if isinstance(S, (str, Path)) and isinstance(R, (str, Path)):
# calculate SNRs and odds values
try:
snrs = optimal_snr(
R,
S,
which=kwargs.pop("which", "posterior"),
remove_outliers=kwa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_ratios(path='/Volumes/OptiHDD/data/pylith/3d/agu2014/output',\n\t\t\t\tsteps=['step01','step02'],\n\t\t\t\t#labels='',\n\t\t\t\tshow=True,\n\t\t\t\txscale=1e3,\n\t\t\t\tyscale=1e-2):\n\tplt.figure()\n\t#path = '/Users/scott/Desktop/elastic'\n\n\t# Deep source\n\t#labels = ['no APMB', 'APMB']\n\t#if labels... | [
"0.6201664",
"0.58766454",
"0.58370477",
"0.57312804",
"0.56986564",
"0.5673041",
"0.5670444",
"0.56263053",
"0.56102556",
"0.55182964",
"0.54761904",
"0.547028",
"0.5460293",
"0.5450966",
"0.54439896",
"0.5438146",
"0.5412085",
"0.539946",
"0.53983545",
"0.5386303",
"0.53858... | 0.6297812 | 0 |
Split zi in querys and write in the disk. | def zi_spliting(info_list, path, mode='train'):
new_info_list = list()
for infos in info_list:
if mode == 'train':
[user, age, gender, education, querys] = infos
elif mode == 'test':
[user, querys] = infos
new_querys = list()
for query in querys:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flush_to_disk(self):\n logger.info(\"Flushing %s queries from in-memory cache to disk\", len(self.batch_writes))\n rows = self.memory_connection.execute(f\"\"\"\n SELECT hash_id, query, raw_query, domain, intent FROM queries\n WHERE rowid IN ({\",\".join(self.batch_writes)});\n ... | [
"0.6057693",
"0.5790732",
"0.574135",
"0.5588527",
"0.5553472",
"0.55255365",
"0.5473328",
"0.53616834",
"0.5243696",
"0.5214998",
"0.5193215",
"0.5192265",
"0.51885676",
"0.51661223",
"0.51618826",
"0.51062745",
"0.50930005",
"0.50851786",
"0.5072133",
"0.50682193",
"0.50611... | 0.66669464 | 0 |
Construct zi_dict with train and test. | def construct_zi_dict(train_info_list, test_info_list):
zi_dict, train_dataset_list, test_dataset_list = dict(), list(), list()
for user, age, gender, education, querys in train_info_list:
for query in querys:
for zi in query:
if zi not in zi_dict:
z... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_test(s_test, s_train):\n #2048/16=128\n m = 8\n x = random.randint(0,m) * s_train\n y = random.randint(0,m) * s_train\n z = random.randint(0,m) * s_train\n #print(x,y,z)\n return {'x':[x,x + s_test], 'y':[y,y + s_test], 'z':[z,z + s_test]}",
"def _data_zip(train_data, eval_data, t... | [
"0.63030636",
"0.62033963",
"0.5901863",
"0.58987844",
"0.58168197",
"0.5787425",
"0.572789",
"0.56477004",
"0.55487585",
"0.5511268",
"0.54987353",
"0.5493017",
"0.5458069",
"0.54230857",
"0.54230857",
"0.54230857",
"0.54230857",
"0.54230857",
"0.53769624",
"0.5376408",
"0.5... | 0.7252616 | 0 |
Compute the effective redshift of a CatalogSource. | def compute_effective_redshift(cat):
# the total weight
total_weight = cat['Weight']*cat['FKPWeight']
# effective redshift
zeff = (total_weight*cat['Z']).sum() / total_weight.sum()
return cat.compute(zeff) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeSourceCat(self, distortedWcs):\n loadRes = self.refObjLoader.loadPixelBox(bbox=self.bbox, wcs=distortedWcs, filterName=\"r\")\n refCat = loadRes.refCat\n refCentroidKey = afwTable.Point2DKey(refCat.schema[\"centroid\"])\n refFluxRKey = refCat.schema[\"r_flux\"].asKey()\n\n ... | [
"0.52597326",
"0.51466864",
"0.5131956",
"0.50191694",
"0.49740767",
"0.4853845",
"0.48141217",
"0.4778028",
"0.4736358",
"0.47122192",
"0.4694604",
"0.46868613",
"0.46714836",
"0.46576115",
"0.46568698",
"0.46133813",
"0.46009",
"0.4544731",
"0.45407397",
"0.4538425",
"0.449... | 0.692623 | 0 |
Trim the redshift range of a CatalogSource. | def trim_redshift_range(s, zmin=None, zmax=None):
# trim the redshift range
if zmin is None:
zmin = 0.
if zmax is None:
zmax = 10.0
return s[(s['Z'] > zmin) & (s['Z'] < zmax)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trim(self, start, end):",
"def trim(self, start, stop=None):\n if stop is None:\n stop = self.data.shape[0]\n\n start = max(start, 0)\n stop = min(stop, self.data.shape[0])\n self.data = self.data.iloc[start:stop,:]",
"def trim_region(self, start, stop):\n if s... | [
"0.65085673",
"0.59823054",
"0.5902807",
"0.55606157",
"0.5462624",
"0.53439903",
"0.5193237",
"0.51859903",
"0.5061092",
"0.5031417",
"0.50258857",
"0.50171834",
"0.5016415",
"0.5004839",
"0.49636784",
"0.4956522",
"0.49534982",
"0.4952949",
"0.493497",
"0.4923749",
"0.49187... | 0.66857666 | 0 |
Return a unique hash string for the subset of ``attrs`` specified by ``usekeys``. | def make_hash(attrs, usekeys=None, N=10):
if usekeys is None:
d = attrs
else:
d = {k: attrs.get(k, None) for k in usekeys}
s = json.dumps(d, sort_keys=True, cls=JSONEncoder).encode()
return hashlib.sha1(s).hexdigest()[:N] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_hash(only_letters=False):\n\n if only_letters:\n return ''.join((chr(int(x) + 97) if x.isdigit() else x)\n for x in uuid.uuid4().hex)\n return uuid.uuid4().hex",
"def generate_key(*args, **kwargs):\n return hashlib.md5(generate_str_key(**kwargs).encode()).hexdiges... | [
"0.6116779",
"0.5941026",
"0.5929928",
"0.58604497",
"0.583291",
"0.5820026",
"0.5805001",
"0.5777121",
"0.57417",
"0.56319386",
"0.5608807",
"0.5590001",
"0.5494286",
"0.54475236",
"0.54418105",
"0.54005814",
"0.53855014",
"0.53316027",
"0.53258616",
"0.5296983",
"0.5287548"... | 0.75536317 | 0 |
Return a dict of key/values that generated a filename with a unique hash ID | def get_hashkeys(filename, cls):
from nbodykit import lab
# filename is a directory --> FIT result
if os.path.isdir(filename):
filename = os.path.join(os.path.abspath(filename), 'hashinfo.json')
if not os.path.exists(filename):
return
import json
# use json to l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file(self) -> tuple:\r\n hash_md5 = hashlib.md5()\r\n with open(self.yara_base_file, \"rb\") as f:\r\n file_map = f.read()\r\n get_file_dict = get_matches(self, file_map)\r\n hash_md5.update(file_map)\r\n return hash_md5.hexdigest(), get_file_dict",
"def hashFiles(direct... | [
"0.6731944",
"0.6602148",
"0.65610206",
"0.6545702",
"0.6483463",
"0.6435844",
"0.6379447",
"0.6327119",
"0.6283103",
"0.62700856",
"0.6226224",
"0.62206787",
"0.6216478",
"0.61988825",
"0.6169493",
"0.6165634",
"0.6083418",
"0.60667855",
"0.6039825",
"0.6023578",
"0.601291",... | 0.6668095 | 1 |
Echo the key/values that generated the hash in the input filename | def echo_hash():
import argparse
desc = 'echo the key/values that generated the hash in the input filename'
parser = argparse.ArgumentParser(description=desc)
h = 'the input file name'
parser.add_argument('filenames', type=str, nargs='+', help=h)
h = 'the result class'
parser.add_argument(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_hash(self, fname, args):\n fobj = self._open_file(fname, args.binary)\n hash_value = self._calculate_hash(fobj)\n\n line = '{0} {1}{2}\\n'.format(hash_value, '*' if args.binary else ' ',\n fname)\n\n if '//' in line:\n line = '... | [
"0.6701367",
"0.6636175",
"0.6627226",
"0.65526426",
"0.653198",
"0.6508728",
"0.62754333",
"0.61778194",
"0.6140872",
"0.6134116",
"0.60154223",
"0.59322345",
"0.59317064",
"0.59183043",
"0.5915798",
"0.5910977",
"0.5874824",
"0.58745474",
"0.58403486",
"0.5829077",
"0.58126... | 0.7862639 | 0 |
save an [1.0, 1.0] image | def imwrite(image, path):
if image.ndim == 3 and image.shape[2] == 1: # for gray image
image = np.array(image, copy=True)
image.shape = image.shape[0:2]
imgarray=((image+1.0)*127.5).astype(np.uint8)
img=Image.fromarray(imgarray)
img.save(path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_image(image, image_path):\n image = ((image[0] + 1) * 127.5).astype(np.uint8) # convert from [-1, 1] to [0, 255]\n img = Image.fromarray(image)\n img.save(os.path.expanduser(image_path))",
"def img_save(name,img):\n cv2.imwrite(name,img)",
"def test_save_jpg():\n img = Image.new('RGB',... | [
"0.7184405",
"0.7058263",
"0.70391816",
"0.70101696",
"0.70036274",
"0.6940388",
"0.6931688",
"0.69289064",
"0.69088125",
"0.6889043",
"0.68391377",
"0.6816189",
"0.680161",
"0.6763353",
"0.67472714",
"0.6711842",
"0.6688862",
"0.6683679",
"0.6676861",
"0.6668132",
"0.6633004... | 0.7254879 | 0 |
Generate a pool name. This function takes keyword arguments, usually the connection arguments and tries to generate a name for the pool. | def generate_pool_name(**kwargs):
parts = []
for key in ("host", "port", "user", "database", "client_id"):
try:
parts.append(str(kwargs[key]))
except KeyError:
pass
if not parts:
raise PoolError("Failed generating pool name; specify pool_name")
return "_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def NodePoolName(name: str) -> str:\n # GKE (or k8s?) requires nodepools use alphanumerics and hyphens\n # AKS requires full alphanumeric\n # PKB likes to use underscores strip them out.\n return name.replace('_', '')",
"def _get_unique_name(self, name: str, prefix: str):\n if name is None:\n ... | [
"0.6692671",
"0.64188457",
"0.5920847",
"0.58881325",
"0.588302",
"0.58691883",
"0.5826616",
"0.58163804",
"0.5768133",
"0.57644916",
"0.57572246",
"0.573129",
"0.56918794",
"0.56799304",
"0.56768924",
"0.5658768",
"0.5649311",
"0.55965006",
"0.5596221",
"0.5574093",
"0.55608... | 0.8913228 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.