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 |
|---|---|---|---|---|---|---|
Fill NaN with mean. | def fill_mean(df):
df = df.fillna(df.mean().fillna(0).to_dict())
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_nan(A):\n dat = np.ma.masked_array(A, np.isnan(A))\n mean = np.mean(dat, axis=0)\n return mean.filled(np.nan)",
"def mean_replace_nan(dataframe, median=False):\n tmp = dataframe\n\n if median:\n tmp_med = tmp[median]\n tmp_med = tmp_med.fillna(tmp_med.median(... | [
"0.7474141",
"0.7430518",
"0.7378109",
"0.72784925",
"0.72598785",
"0.72057146",
"0.7197393",
"0.71652675",
"0.7063929",
"0.6949846",
"0.69423306",
"0.6937608",
"0.6891757",
"0.68859494",
"0.6806733",
"0.67863446",
"0.6710037",
"0.6680773",
"0.6564643",
"0.6529232",
"0.638049... | 0.78398246 | 0 |
Fill NaN with median. | def fill_median(df):
df = df.fillna(df.median().fillna(0).to_dict())
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __fillnan(df):\n\t\tcol_names = ['budget', 'popularity', 'runtime', 'vote_average', 'vote_count']\n\t\tfor col_name in col_names:\n\t\t\tdf[col_name] = df[col_name].fillna(df[col_name].median())\n\t\treturn df",
"def mean_replace_nan(dataframe, median=False):\n tmp = dataframe\n\n if median:\n ... | [
"0.7907557",
"0.74208754",
"0.7412178",
"0.7330724",
"0.72313046",
"0.681601",
"0.6724575",
"0.6692723",
"0.6692723",
"0.66741526",
"0.66479206",
"0.6644379",
"0.6528246",
"0.6447285",
"0.63875216",
"0.63818914",
"0.6361491",
"0.6357454",
"0.6357383",
"0.63172287",
"0.6313194... | 0.8131877 | 0 |
Fill NaN with mean of last window values. | def rolling_mean(df, window: int = 10):
df = fill_forward(df.fillna(df.rolling(window=window, min_periods=1).mean()))
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_mean(df):\n df = df.fillna(df.mean().fillna(0).to_dict())\n return df",
"def get_rolling_mean(df, window):\n # return pd.rolling_mean(values, window=window)\n rolling_df=pd.DataFrame(index=df.index)\n for sym in df.columns:\n df_tmp= pd.Series.rolling(df[sym],window=window).mean().... | [
"0.6829655",
"0.6768716",
"0.6762021",
"0.64044464",
"0.63776046",
"0.63458127",
"0.63238436",
"0.6299279",
"0.6290402",
"0.619226",
"0.6163288",
"0.6151629",
"0.6130924",
"0.61298823",
"0.6113169",
"0.6100956",
"0.60678065",
"0.60142833",
"0.5979221",
"0.5971367",
"0.5932656... | 0.778682 | 0 |
User who created feedback can delete feedback | def delete_feedback(feedback_id):
feedback = Feedback.query.get_or_404(feedback_id)
recipient = feedback.recipient
db.session.delete(feedback)
db.session.commit()
return redirect(f'/users/{recipient}') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_feedback(feedback_id): \n if 'username' in session:\n # Get username \n username = session['username']\n\n # Remove feedback \n Feedback.query.filter_by(id=feedback_id).delete()\n db.session.commit()\n flash('Feedback Deleted!', 'success')\n return red... | [
"0.7613791",
"0.7362932",
"0.7033641",
"0.70097154",
"0.696459",
"0.689633",
"0.67760044",
"0.6774441",
"0.63517535",
"0.6314919",
"0.62838745",
"0.62652075",
"0.6262236",
"0.6248442",
"0.6223859",
"0.61827064",
"0.61401224",
"0.61293507",
"0.6066308",
"0.6059565",
"0.6054390... | 0.739816 | 1 |
shows or hides the histogram controls depending on whether Histogram is currently selected | def showOrHideHistogramControls(graphType:int):
if GRAPHTYPE_CHOICES[graphType] == 'Histogram':
return {'display': 'block'}
return {'display': 'none'} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hide_histogram(key_figure_value):\n if \"Typical Mistakes\" in key_figure_value:\n display_style = {\"display\": \"block\"}\n else:\n display_style = {\"display\": \"none\"}\n return display_style",
"def btn_equalize_hist_callback(self):\n self.show_as_waiting(True)\n sel... | [
"0.6448864",
"0.63466585",
"0.62988853",
"0.61047524",
"0.6007801",
"0.60049903",
"0.5966739",
"0.5959865",
"0.5931388",
"0.5914637",
"0.5816052",
"0.57329005",
"0.56950706",
"0.5610719",
"0.56073725",
"0.5606425",
"0.5590336",
"0.5522246",
"0.5502198",
"0.54997134",
"0.54853... | 0.75229937 | 0 |
updates the graph based on the chosen data fields, data filters, graph type, and bin size (the latter if histogram is selected) | def updateGraph(dataFields:list, filterIndex:int, graphType:int,
binSize:int):
# title of the graph, set to the filename for now
title = CSVPATH_CACHE[:-4]
if len(dataFields) == 0:
return go.Figure(layout=dict(title=title)) # empty graph
if filterIndex is 0:
fList = ['isMale']
elif filterIndex is 1:
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateGraph(dataFields:list, filterIndex:int, graphType:int,\n\t\t\t\tbinSize:int):\n\n\t# title of the graph, set to the filename for now\n\ttitle = 'Without filter'\n\n\tif len(dataFields) == 0:\n\t\treturn go.Figure(layout=dict(title=title)) # empty graph\n\n\tif filterIndex is 0:\n\t\tfList = ['isMale']\n\... | [
"0.7303034",
"0.636973",
"0.619901",
"0.58706427",
"0.5657828",
"0.563207",
"0.5626689",
"0.5575385",
"0.545401",
"0.54433876",
"0.5416432",
"0.5393923",
"0.5356119",
"0.53365725",
"0.52799857",
"0.5274543",
"0.52657014",
"0.5245616",
"0.52406895",
"0.5227057",
"0.5203779",
... | 0.731046 | 0 |
updates the graph based on the chosen data fields, data filters, graph type, and bin size (the latter if histogram is selected) | def updateGraph(dataFields:list, filterIndex:int, graphType:int,
binSize:int):
# title of the graph, set to the filename for now
title = 'Without filter'
if len(dataFields) == 0:
return go.Figure(layout=dict(title=title)) # empty graph
if filterIndex is 0:
fList = ['isMale']
elif filterIndex is 1:
fLi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateGraph(dataFields:list, filterIndex:int, graphType:int,\n\t\t\t\tbinSize:int):\n\n\t# title of the graph, set to the filename for now\n\ttitle = CSVPATH_CACHE[:-4]\n\n\tif len(dataFields) == 0:\n\t\treturn go.Figure(layout=dict(title=title)) # empty graph\n\n\tif filterIndex is 0:\n\t\tfList = ['isMale']\... | [
"0.7309734",
"0.6370505",
"0.61987424",
"0.5872197",
"0.5659268",
"0.56325215",
"0.5627878",
"0.5574451",
"0.545669",
"0.5445275",
"0.5416093",
"0.5395676",
"0.5356527",
"0.53387827",
"0.5278357",
"0.52754843",
"0.5265391",
"0.52464116",
"0.524133",
"0.5227953",
"0.52035224",... | 0.7302468 | 1 |
Remove any type of punctuation and the words and then split on whitespace | def simple_tokenizer(text):
re_tok = re.compile(punctuation_string)
return re_tok.sub(' ', text).split() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def separate_words(text):\n splitter = re.compile('\\\\W*')\n return [s.lower() for s in splitter.split(text) if s != '']",
"def tokenizer(text):\n # remove punctuation from text - remove anything that isn't a word char or a space\n replace_punctuation = str.maketrans(string.punctuation, ' ' * len(st... | [
"0.7764153",
"0.7578712",
"0.74054563",
"0.7397258",
"0.739063",
"0.7379701",
"0.73594034",
"0.7351419",
"0.7346505",
"0.73402655",
"0.73402655",
"0.7331885",
"0.7299199",
"0.72888243",
"0.7285937",
"0.7225834",
"0.7219664",
"0.71976674",
"0.717803",
"0.71773326",
"0.71773326... | 0.7616074 | 1 |
Remove any type of punctuation and the words contained in the global variable common_words and then split on whitespace | def tokenize(text):
common_words_string = " | ".join(common_words)
re_tok = re.compile(punctuation_string + "| " + common_words_string + " ")
words = re_tok.sub(' ',re_tok.sub(' ',text)).split()
tokens = []
for i in range(len(words)-1):
first = words[i]
second = words[i+1]
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(words):\r\n tokens = []\r\n try:\r\n for token in words:\r\n token = re.sub(r'[\\W\\d_]', \" \", token)\r\n tokens.append(token)\r\n except:\r\n token = \"\"\r\n tokens.append(token)\r\n \r\n return tokens",
"def separate_words(text):\n split... | [
"0.6997493",
"0.69969183",
"0.69742167",
"0.6832428",
"0.6822094",
"0.67601043",
"0.67574143",
"0.6756985",
"0.67543316",
"0.6739854",
"0.67051816",
"0.66922736",
"0.6691624",
"0.66914135",
"0.66914135",
"0.66914135",
"0.66914135",
"0.66914135",
"0.66914135",
"0.6681939",
"0.... | 0.70328444 | 0 |
Use a web service to determine whether the sentiment of text is positive | def is_positive(text) :
r = requests.post("http://text-processing.com/api/sentiment/", data={'text': text})
return r.json()['probability']['pos'] > r.json()['probability']['neg'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyze(self, text): #takes the text to be analyzed for sentiment\n #initialize inicial score to 0\n score = 0\n #Create tokenizer instance\n tokenizer = nltk.tokenize.TweetTokenizer()\n #create list of words in a tweets\n tokens = tokenizer.tokenize(text)\n \n ... | [
"0.73122865",
"0.7217557",
"0.7141748",
"0.71153265",
"0.7100969",
"0.7085507",
"0.7063024",
"0.7063024",
"0.704866",
"0.7046262",
"0.6969926",
"0.69328636",
"0.69327456",
"0.69301015",
"0.6917491",
"0.6858072",
"0.6857834",
"0.6790162",
"0.677813",
"0.6758152",
"0.67333317",... | 0.79767376 | 0 |
function is used to generate random int asynchronously | async def getrandom_number() :
# run an infinite loop to continue generating random numbers
while True:
await asyncio.sleep(2) # let this task sleep for a while
yield random.randint(0, sys.maxsize) # yield a random int | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate() -> int:\n return randint(0, 1000000000)",
"def randomNumberGenerator(self):\n #infinite loop of magical random numbers\n print(\"Making random numbers\")\n while not thread_stop_event.isSet():\n number = random.randint(10000,99999)\n print(number)\... | [
"0.7550041",
"0.7340855",
"0.7319073",
"0.7319073",
"0.7158242",
"0.7155945",
"0.7083",
"0.68702585",
"0.6725243",
"0.671939",
"0.66604835",
"0.6660285",
"0.66084623",
"0.6598611",
"0.6597232",
"0.6578658",
"0.6456659",
"0.6428595",
"0.6415611",
"0.6408827",
"0.6397889",
"0... | 0.8043155 | 0 |
main function for the program. It is run asynchronously | async def main():
# provide greetings for the program
# print out program heading (using multi-line statement)
programHeading = "PROGRAM BEGINS BELOW (Python Version {})".format(\
sys.version[0:sys.\
version.index(" ")])
print(programHeading)
print('=' * ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n main()",
"async def _main(self):\n while True:\n time.sleep(1)",
"def _main_helper(self):\n asyncio.create_task(self._main())",
"def main() -> None:\n runner()\n asyncio.get_event_loop().run_forever()",
"def main() -> None:\n runner()\n asyncio.get_event... | [
"0.7998642",
"0.76802796",
"0.76782113",
"0.7616623",
"0.7616623",
"0.75296557",
"0.7524852",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
"0.73724484",
... | 0.7680666 | 1 |
Extract random subvolume from original images. | def get_sub_volume(image, label,
orig_x = 240, orig_y = 240, orig_z = 155,
output_x = 160, output_y = 160, output_z = 16,
num_classes = 4, max_tries = 1000,
background_threshold=0.95):
# Initialize features and labels with `None`
X =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_variation(self, image):\n #Crop\n min_dim = min(image.size)\n scale = random.uniform(*self.size_range)\n size = int(random.random()*min_dim*(1-scale)+min_dim*scale)\n pos = (random.randrange(0, image.size[0]-size), random.randrange(0, image.size[1]-size))\n image =... | [
"0.5887357",
"0.5563515",
"0.555708",
"0.5516861",
"0.54872274",
"0.54644114",
"0.546377",
"0.5454844",
"0.5416031",
"0.539185",
"0.5391111",
"0.53749853",
"0.5368773",
"0.5355604",
"0.5316321",
"0.52910185",
"0.52902794",
"0.5279001",
"0.5266336",
"0.52657074",
"0.5265544",
... | 0.6869342 | 0 |
Compute dice coefficient for single class. | def single_class_dice_coefficient(y_true, y_pred, axis=(0, 1, 2),
epsilon=0.00001):
### START CODE HERE (REPLACE INSTANCES OF 'None' with your code) ###
dice_numerator = 2. * K.sum(y_true * y_pred, axis=axis) + epsilon
dice_denominator = K.sum(y_true, axis=axis) + K.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dice_coeff(self):\n a, c, _, b = self.to_ccw()\n return _div(2 * a, 2 * a + b + c)",
"def dice_coef(y_true, y_pred):\n\n\ty_true_f = K.flatten(y_true)\n\ty_pred_f = K.flatten(y_pred)\n\tintersection = K.sum(y_true_f * y_pred_f)\n\tdice_coef = (2. * intersection + K.epsilon()) / (K.sum(y_true_f)... | [
"0.776917",
"0.69364023",
"0.6925487",
"0.6925487",
"0.68437546",
"0.6782024",
"0.669867",
"0.66785455",
"0.66640896",
"0.65822893",
"0.6503312",
"0.644604",
"0.6422944",
"0.641263",
"0.64060193",
"0.63338006",
"0.6283619",
"0.6266298",
"0.6246371",
"0.622728",
"0.6142096",
... | 0.7424868 | 1 |
Compute mean soft dice loss over all abnormality classes. | def soft_dice_loss(y_true, y_pred, axis=(1, 2, 3),
epsilon=0.00001):
### START CODE HERE (REPLACE INSTANCES OF 'None' with your code) ###
dice_numerator = 2. * K.sum(y_true * y_pred, axis=axis) + epsilon
dice_denominator = K.sum(y_true**2, axis=axis) + K.sum(y_pred**2, axis=axis) + eps... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax_dice_loss(y, t, normalize=True, class_weight=None,\n ignore_label=-1, reduce='mean', eps=1e-08):\n return 1.0 - softmax_dice(y, t, normalize, class_weight,\n ignore_label, reduce, eps)",
"def soft_dice_loss(y_true, y_pred, axis=(1, 2, 3), \r\n ... | [
"0.6581519",
"0.6531289",
"0.6512755",
"0.633723",
"0.6316383",
"0.6277925",
"0.626399",
"0.6261831",
"0.61697376",
"0.6039235",
"0.6027272",
"0.60057956",
"0.6002533",
"0.5982434",
"0.5901123",
"0.58959097",
"0.58702976",
"0.586901",
"0.586901",
"0.58529717",
"0.5850559",
... | 0.65518653 | 1 |
Compute sensitivity and specificity for a particular example for a given class. | def compute_class_sens_spec(pred, label, class_num):
# extract sub-array for specified class
class_pred = pred[class_num]
class_label = label[class_num]
### START CODE HERE (REPLACE INSTANCES OF 'None' with your code) ###
# compute:
# true positives
tp = np.sum((class_pred == 1) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def specificity(self):\n self.overall_specificity = specificity_score(\n self.y_true, self.y_pred, average = self.average_type).round(self.digits_count_fp)\n self.classes_specificity = specificity_score(\n self.y_true, self.y_pred, average = None).round(self.digits_count_fp)",
... | [
"0.64339197",
"0.6422766",
"0.63811517",
"0.63159674",
"0.62423",
"0.6153135",
"0.61234987",
"0.60103244",
"0.59986234",
"0.5976981",
"0.59244215",
"0.59086925",
"0.59016293",
"0.5889593",
"0.58670115",
"0.5840112",
"0.5834752",
"0.58282715",
"0.58245236",
"0.5796109",
"0.578... | 0.7260834 | 0 |
Format an exception so that it prints on a single line. | def formatException(self, exc_info):
result = super(OneLineExceptionFormatter, self).formatException(exc_info)
return repr(result) # or format into one line however you want to | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_exception_only(exc):\r\n exc_type = type(exc)\r\n\r\n stype = exc_type.__qualname__\r\n smod = exc_type.__module__\r\n if smod not in (\"__main__\", \"builtins\"):\r\n stype = smod + '.' + stype\r\n try:\r\n _str = str(exc)\r\n except:\r\n _str = \"<unprintable {} ... | [
"0.8006542",
"0.76260567",
"0.7515975",
"0.7327926",
"0.7199134",
"0.7086562",
"0.699301",
"0.69196373",
"0.6794789",
"0.67890227",
"0.6714278",
"0.671348",
"0.6711042",
"0.669849",
"0.66925454",
"0.6692383",
"0.66321695",
"0.6607565",
"0.6572143",
"0.6571753",
"0.6553505",
... | 0.814359 | 0 |
Converts firestore stream to SearchResult model. | def from_stream(stream):
results = []
for doc in stream:
results.append(from_dict(data_class=SearchEntity, data=doc.to_dict()))
return SearchResult(results) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _stream_search(self, *args, **kwargs):\n for hit in scan(self.elastic, query=kwargs.pop('body', None),\n scroll='10m', **kwargs):\n hit['_source']['_id'] = hit['_id']\n yield hit['_source']",
"def get_search_results(search_query, search_mode):\r\n # TODO... | [
"0.5961352",
"0.5656787",
"0.55286515",
"0.55016017",
"0.54356253",
"0.5373352",
"0.5330576",
"0.52292645",
"0.5185334",
"0.5142347",
"0.5099828",
"0.50351137",
"0.49895245",
"0.4967809",
"0.49511382",
"0.49403188",
"0.49266115",
"0.49041387",
"0.49041113",
"0.48999318",
"0.4... | 0.7344462 | 0 |
This method is responsible for adding a store to the database, if not already existing. | def add_store_to_db(self, connexion):
# initiate a cursor
cursor = connexion.cursor()
# check if the store already exists in database
cursor.execute("""SELECT name FROM Store
WHERE name = %s""", (self.name, ))
rows = cursor.fetchall()
if n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_store(self, product, store):\n self.db.query(\"\"\"\n INSERT IGNORE INTO product_store(product_id, store_id)\n VALUES (:product_id, :store_id)\n \"\"\", product_id=product.id, store_id=store.id)",
"def save(self, store):\n self.db.query(f\"\"\"\n INSE... | [
"0.76298106",
"0.7505021",
"0.68996227",
"0.6689076",
"0.65157914",
"0.64422524",
"0.64129245",
"0.6400829",
"0.6295746",
"0.62792975",
"0.6192796",
"0.61663324",
"0.6116118",
"0.60812485",
"0.60732466",
"0.59604394",
"0.5937278",
"0.5926628",
"0.5918604",
"0.590783",
"0.5887... | 0.8202447 | 0 |
Returns a DoorStatus instance from the last line of logs. | def __read_last_line(self) -> str:
with open(LOGFILE_OPENINGS, "r", encoding="utf-8") as f:
last_line = f.readlines()[-1]
return repr(LogLine.from_line(last_line)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_line(self) -> str:\n self.update_status()\n return self._last_line",
"def read_last_line_in_data_log():\n timestamp = datetime.datetime.utcnow().strftime(\"%Y%m%d\")\n log_file_path = r'C:/Users/kimdu/Documents/ph549/Telemetry_logs'\n log_file_path += os.sep + timestamp\n file_... | [
"0.59090793",
"0.57995594",
"0.57896596",
"0.57828206",
"0.5769948",
"0.5698278",
"0.5669273",
"0.5608563",
"0.5580449",
"0.5555742",
"0.5550632",
"0.55488944",
"0.54812056",
"0.54789263",
"0.5457706",
"0.5429864",
"0.53800774",
"0.53770286",
"0.53342366",
"0.5333933",
"0.532... | 0.674561 | 0 |
Returns a string of DoorStatus instances from the last 10 lines of logs. | def __read_last_lines(self) -> str:
with open(LOGFILE_OPENINGS, "r", encoding="utf-8") as f:
last_lines = f.readlines()[-10:]
return " 🌸 " + "\n🌸 ".join(
map(lambda l: repr(LogLine.from_line(l)), last_lines)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log(self):\n lines = tailer.tail(open('logs/status.log'), 10)\n\n statement = \"\"\n\n for line in lines:\n statement += (line + \"<br />\")\n return statement",
"def log_n(self, n):\n lines = tailer.tail(open('logs/status.log'), n)\n\n statement = \"\"\n\... | [
"0.62255615",
"0.5930768",
"0.5925434",
"0.5925434",
"0.5889693",
"0.5882788",
"0.582968",
"0.57566845",
"0.5725637",
"0.5606027",
"0.55541277",
"0.5544616",
"0.55370015",
"0.5445272",
"0.54114497",
"0.53962976",
"0.53871065",
"0.5369662",
"0.5337163",
"0.5322841",
"0.5311264... | 0.66506803 | 0 |
Update the status of the watched door. Returns True if it was modified. | def update_status(self) -> bool:
last_edit = self.__get_modification_time(LOGFILE_OPENINGS)
if self._last_edit != last_edit:
self._last_edit = last_edit
self._last_line = self.__read_last_line()
self._last_lines = self.__read_last_lines()
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n self._is_on = self._is_on",
"def updateStatus(self, status):\n pass",
"def _update(self, force_update=True):\n with self._wemo_exception_handler(\"update status\"):\n self._state = self.wemo.get_state(force_update)",
"def _update_status(self):\n self... | [
"0.65120125",
"0.6278082",
"0.6252452",
"0.61606616",
"0.6110845",
"0.6078224",
"0.60666496",
"0.601296",
"0.6002203",
"0.5996954",
"0.5949471",
"0.5888865",
"0.5866046",
"0.5857389",
"0.5804676",
"0.58045447",
"0.57629234",
"0.572441",
"0.5718855",
"0.5710009",
"0.5696805",
... | 0.6716564 | 0 |
Returns a formated list of last 20 videos from motion folder. | def last_videos_recorded(self) -> list:
return sorted(glob.glob(VIDEOS_DIR), key=os.path.getmtime)[-20:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_videos_of_folder(folder):\n\n Settings.dev_print(\"getting videos of folder: {}\".format(folder.get_title()))\n if not folder: return []\n videos = []\n files = []\n valid_videos = [\".mp4\",\".mov\"]\n for f in os.listdir(folder.get_path()):\n ext = os.... | [
"0.64877117",
"0.63934535",
"0.6341911",
"0.6327392",
"0.6318843",
"0.62139153",
"0.6178268",
"0.6079026",
"0.6005721",
"0.6002345",
"0.60001993",
"0.59830344",
"0.59812754",
"0.5955391",
"0.5945923",
"0.5929806",
"0.59084743",
"0.59075916",
"0.58944476",
"0.5867142",
"0.5851... | 0.7687061 | 0 |
Set the verbose flag from given context args | def __read_verbose_param(self, context):
self.__verbose = False
if context.args and context.args[0] in "verboseVERBOSE":
self.__verbose = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setVerbose(*args,**kwargs):\n verbose = args[0] if args else True\n if verbose:\n verbositySampleTools = 2\n verbosityPlotTools = 2\n verbosityVariableTools = 2\n verbositySelectionTools = 2\n verbosityWJ = 2",
"def verbose(ctx, msg, *args):\n ... | [
"0.75910324",
"0.7542027",
"0.7482807",
"0.7336278",
"0.732446",
"0.7147361",
"0.70895076",
"0.7029541",
"0.70221394",
"0.70102197",
"0.70014614",
"0.6964788",
"0.68494254",
"0.6821431",
"0.6747149",
"0.6732075",
"0.6703507",
"0.67017037",
"0.66564965",
"0.6605444",
"0.659135... | 0.761643 | 0 |
Extract the filename from a filepath | def filename_from_path(filepath: str) -> str:
return filepath.split("/")[-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getfilename(path):\r\n return path.split('\\\\').pop().split('/').pop().rsplit('.', 1)[0]",
"def get_filename(path):\n return path.split('/')[-1]",
"def get_filename(filepath):\n return os.path.basename(filepath)",
"def getFileName(filepath):\n return os.path.splitext(os.path.basename(filepat... | [
"0.84518707",
"0.8337143",
"0.83284086",
"0.8224103",
"0.8222937",
"0.81388164",
"0.8094482",
"0.8048495",
"0.80400324",
"0.8007061",
"0.7967308",
"0.79470813",
"0.79265684",
"0.78705674",
"0.7804003",
"0.7775022",
"0.77141464",
"0.7710174",
"0.77035666",
"0.75616604",
"0.749... | 0.8680891 | 0 |
Sent the last 10 videos as an inline keyboard. | async def last_vids(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
keyboard = [
[
InlineKeyboardButton(
f"🎬 {self.filename_from_path(video_path)}", callback_data=video_path
)
]
for video_path in self.door_stat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_video_feed(self):\n\n use_screen = True\n # Initialize screen for plotting\n if use_screen:\n screen = curses.initscr()\n height,width = screen.getmaxyx()\n\n # String template used to remove unecessary plotting\n valid = '#.<^v>\\n'\n\n y_max,x_max = map(max, zip(*self.mp.key... | [
"0.5480135",
"0.5448997",
"0.544637",
"0.5435512",
"0.5385356",
"0.53286844",
"0.52983046",
"0.5277598",
"0.526639",
"0.5254268",
"0.5220524",
"0.5217654",
"0.5214832",
"0.5214828",
"0.5206034",
"0.517895",
"0.5176643",
"0.5134986",
"0.5125763",
"0.50994223",
"0.508244",
"0... | 0.62417173 | 0 |
Parses the CallbackQuery and updates the message text. Send the selected video. | async def button(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
query = update.callback_query
# CallbackQueries need to be answered, even if no notification to the user is needed
# Some clients may have trouble otherwise. See https://core.telegram.org/bots/api#callbackquery
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_message(ws, msg):\n data = json.loads(msg)\n if \"results\" in data:\n # This prints out the current fragment that we are working on\n text = data['results'][0]['alternatives'][0]['transcript'].lower()\n print(text)\n # Pass it to the callback\n if CALLBACK(text):\n ... | [
"0.6148326",
"0.60168344",
"0.5996262",
"0.5908595",
"0.5908595",
"0.56625247",
"0.56625247",
"0.56625247",
"0.5651618",
"0.55948675",
"0.554405",
"0.5476916",
"0.5449169",
"0.54340947",
"0.5386417",
"0.5380184",
"0.53669494",
"0.5362969",
"0.5348261",
"0.5274517",
"0.5212089... | 0.689048 | 0 |
Repond with the last lines of the log. | async def last_lines(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
self.door_status.update_status()
await update.message.reply_text(text=self.door_status.last_lines) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keep_last_lines(self, num_lines):\n self.data = self.data[-num_lines:]",
"def __read_last_lines(self) -> str:\n with open(LOGFILE_OPENINGS, \"r\", encoding=\"utf-8\") as f:\n last_lines = f.readlines()[-10:]\n return \" 🌸 \" + \"\\n🌸 \".join(\n map(lambda l: repr(... | [
"0.7052141",
"0.689024",
"0.66751087",
"0.66479367",
"0.6587493",
"0.6437268",
"0.6431228",
"0.6310348",
"0.6273138",
"0.6199248",
"0.6178221",
"0.61578965",
"0.61291844",
"0.6103929",
"0.60763603",
"0.6037578",
"0.5990935",
"0.5989444",
"0.5981663",
"0.5935358",
"0.59245604"... | 0.691306 | 1 |
Respond with the status (running / stopped) of the alarm | async def status(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
msg = "running ✅" if self._running else "stopped 🚫"
await update.message.reply_text(text=f"The alarm is {msg}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _isalarm(self):\n return self.dp.state()==PyTango.DevState.ALARM",
"def is_alarm():\n return _alarm",
"def get_state(self):\r\n alarm = self._alarm()\r\n return alarm.state",
"async def get_status():",
"def status():\n (code, message) = rest_api.status(request)\n if (code ... | [
"0.64018685",
"0.61689067",
"0.6136144",
"0.601642",
"0.5973482",
"0.59457517",
"0.593737",
"0.5874813",
"0.5849597",
"0.5760988",
"0.5731132",
"0.5717715",
"0.5713724",
"0.5710202",
"0.5707529",
"0.5706191",
"0.5703976",
"0.5699192",
"0.5697757",
"0.56976616",
"0.5697038",
... | 0.6963454 | 0 |
Sets the alarm, verbose or not. Send confirmation. Removes all scheduled jobs. Set a scheduled job every `due` seconds. If "verbose" is present in the command, it will spam the user with debugging info every time. Else, it will only send messages when the log is changed. | async def alarm(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
self.__read_verbose_param(context)
chat_id = update.effective_message.chat_id
job_removed = remove_job_if_exists(str(chat_id), context)
due = 1.0
context.job_queue.run_repeating(
self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def __send_alarm(self, context: ContextTypes.DEFAULT_TYPE) -> None:\n if self.door_status.update_status():\n await context.bot.send_message(\n MESKOID,\n text=f\"🐙{self.door_status.last_line}\",\n )\n await context.bot.send_message(\n ... | [
"0.61472505",
"0.5844123",
"0.5652176",
"0.554411",
"0.5535476",
"0.5484469",
"0.54269296",
"0.5336542",
"0.53300744",
"0.5280414",
"0.5186723",
"0.5177701",
"0.5174835",
"0.51646286",
"0.5152675",
"0.51474786",
"0.5090655",
"0.5073706",
"0.5047201",
"0.50391555",
"0.5034432"... | 0.5949268 | 1 |
x is the x coordinate in the image where the user clicked y is the y coordinate in the image where the user clicked | def click_a(self, event, x, y, flags, params):
if event == cv2.EVENT_LBUTTONDOWN:
self.image_a_coordinates = (x, y)
print("ImageA selected coordinates =", self.image_a_coordinates)
return x, y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click_b(self, event, x, y, flags, params):\n if event == cv2.EVENT_LBUTTONDOWN:\n self.image_b_coordinates = (x, y)\n print(\"ImageB selected coordinates =\", self.image_b_coordinates)\n return x, y",
"def Canvas_onclick(event):\n global ix, iy\n ix, iy = event.x... | [
"0.7366799",
"0.73559535",
"0.72321475",
"0.71257913",
"0.69522583",
"0.68671715",
"0.67707705",
"0.6764835",
"0.6734653",
"0.6731091",
"0.6691834",
"0.66884834",
"0.6680461",
"0.6631907",
"0.6574645",
"0.6458342",
"0.6451066",
"0.64350593",
"0.6419848",
"0.6409129",
"0.63743... | 0.7541706 | 0 |
x is the x coordinate in the image where the user clicked y is the y coordinate in the image where the user clicked | def click_b(self, event, x, y, flags, params):
if event == cv2.EVENT_LBUTTONDOWN:
self.image_b_coordinates = (x, y)
print("ImageB selected coordinates =", self.image_b_coordinates)
return x, y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click_a(self, event, x, y, flags, params):\n if event == cv2.EVENT_LBUTTONDOWN:\n self.image_a_coordinates = (x, y)\n print(\"ImageA selected coordinates =\", self.image_a_coordinates)\n return x, y",
"def Canvas_onclick(event):\n global ix, iy\n ix, iy = event.x... | [
"0.7542451",
"0.7355782",
"0.7231453",
"0.71259123",
"0.6952783",
"0.68677145",
"0.6770745",
"0.67645794",
"0.6734816",
"0.6731305",
"0.66925126",
"0.66887987",
"0.6680805",
"0.6632181",
"0.65752274",
"0.6458686",
"0.64524657",
"0.64352155",
"0.64195454",
"0.6409138",
"0.6375... | 0.7367437 | 1 |
Test that the Mp3Controller properly sets the file path of the file it was given. | def test_mp3_controller(file_input, filepath, monkeypatch):
user_input = StringIO(file_input)
test = VideoSynth()
controller = Mp3Controller(test)
monkeypatch.setattr('sys.stdin', user_input)
controller.create_file_path()
assert test.file_path() == filepath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n super().setUp()\n self.file_path = 'file.json'",
"def setUp(self):\n super(LaunchConfigPersonalityTest, self).setUp()\n self.path = '/root/test.txt'",
"def test_load_file(self):\n self.assertTrue(os.path.exists(MEDIA_ROOT+\"/pl_test1_\"+self.loader.version)... | [
"0.70906526",
"0.6494003",
"0.6455835",
"0.64328897",
"0.6398433",
"0.63545924",
"0.6208192",
"0.6112567",
"0.6107966",
"0.60905695",
"0.6057395",
"0.60359764",
"0.60199666",
"0.59997624",
"0.59858906",
"0.59858793",
"0.5971123",
"0.5960962",
"0.5940044",
"0.59066474",
"0.589... | 0.6549427 | 1 |
Check that tags have a valid IOB format. Tags in IOB1 format are converted to IOB2. | def ensure_iob2(tags):
tags = list(tags)
for i, tag in enumerate(tags):
if tag == 'O':
continue
split = tag.split('-')
if len(split) != 2 or split[0] not in ['I', 'B']:
return False
if split[0] == 'B':
continue
elif i == 0 or tags[i - 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iob2(tags):\n for i, tag in enumerate(tags):\n if tag == 'O':\n continue\n split = tag.split('-')\n if len(split) != 2 or split[0] not in ['I', 'B']:\n return False\n if split[0] == 'B':\n continue\n elif i == 0 or tags[i - 1] == 'O': # co... | [
"0.775195",
"0.7740817",
"0.60902363",
"0.58593285",
"0.57538533",
"0.5752643",
"0.5668914",
"0.5628357",
"0.5566951",
"0.55475897",
"0.54800904",
"0.5449656",
"0.52738506",
"0.5226045",
"0.522152",
"0.5214969",
"0.5210512",
"0.5208966",
"0.516465",
"0.5157702",
"0.51482546",... | 0.8206854 | 0 |
Find the least changes to a set of comparisons so that they are consistent (transitive), it returns a topological ranking. comparisons A dictionary with tuple keys in the form of (i, j), values are scalars indicating the probability of i > j. It is assumed that comparisons are symmetric. Use 0 for i j (and any value in... | def find_ranking(comparisons, equal_width=0.2, max_rank=-1, verbose=False):
# remove unnecessary variables
comparisons = {(i, j) if i < j else (j, i): value if i < j else 1 - value
for (i, j), value in comparisons.items()}
nodes = np.unique(
[i for ij in comparisons.keys() for i i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rankPairs (self):\n def key (matrix, pair):\n # majority is positive, we want larger ones first\n major = matrix[pair[0]][pair[1]]\n # minority is negative because we want the smaller ones first\n minor = -1*matrix[pair[1]][pair[0]]\n return (major,minor)\n\n s... | [
"0.51838195",
"0.5091143",
"0.4961545",
"0.49168533",
"0.48941278",
"0.48258108",
"0.48098922",
"0.4805452",
"0.48016915",
"0.47966254",
"0.47940126",
"0.47531202",
"0.4745804",
"0.47409186",
"0.473624",
"0.4713244",
"0.4701844",
"0.46993637",
"0.4696114",
"0.46925405",
"0.46... | 0.78385663 | 0 |
Given a `module_name` name and a `function_name` return the path where to install the correspondent script. The path is relative to "~/.gnome2/nautilusscripts". | def get_new_script_path(module_name, function_name):
return os.path.join(util.get_last_part_of_dotted_name(module_name), function_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getmodulepath(modulename):\n return USERLIBDIR + '\\\\' + modulename + '.sikuli\\\\' + modulename + '.py'",
"def python_script_exists(package=None, module=None):\n assert module is not None\n try:\n if package is None:\n path = imp.find_module(module)[1]\n else:\n ... | [
"0.6253352",
"0.59840125",
"0.5810634",
"0.56375986",
"0.55481976",
"0.5529307",
"0.54558414",
"0.5435752",
"0.54215914",
"0.5394827",
"0.5282806",
"0.5279043",
"0.5275171",
"0.52599895",
"0.5259864",
"0.52353597",
"0.5207061",
"0.5204413",
"0.520294",
"0.51841235",
"0.517281... | 0.7905469 | 0 |
Return a sequence of dicts, one for each console scripts installed by this package, | def get_console_scripts_info():
entry_points_map = pkg_resources.get_entry_map('rbco.nautilusscripts', 'console_scripts')
return [
{
'name': ep.name,
'module': ep.module_name,
'function': ep.attrs[0],
}
for ep in entry_points_map.itervalues()
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _iter_commands(self):\n return {entry_point.name: entry_point for entry_point in\n pkg_resources.iter_entry_points('chanjo.subcommands')}",
"def _extract_commands():\n module_names = [\n module.name for module in pkgutil.iter_modules(projectstarter.commands.__path__)\n ]\n comma... | [
"0.7129376",
"0.67010343",
"0.6217368",
"0.61074805",
"0.5991415",
"0.59463745",
"0.5935463",
"0.58918065",
"0.5865793",
"0.58653975",
"0.58039165",
"0.57590824",
"0.57430816",
"0.5710442",
"0.56914204",
"0.5680355",
"0.56543523",
"0.5653894",
"0.56448203",
"0.56401783",
"0.5... | 0.7155287 | 0 |
Install the Nautilus' scripts for the current user. | def install():
src = None
if len(sys.argv) == 2:
src = sys.argv[1]
elif len(sys.argv) > 2:
print >> sys.stderr, 'USAGE: rbco_nautilusscripts_install [SOURCE_DIR]'
sys.exit(1)
paths = (
'~/.gnome2/nautilus-scripts',
'~/.gnome2/nemo-scripts',
'~/.config/caj... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _install():\n\tprint \"Preparing to install {} script.\".format(SCRIPT_NAME)\n\t\n\t#make sure there is a place to install the script to.\n\tif not \"SCRIPTS\" in os.environ:\n\t\tprint \"Please set SCRIPTS environment variable.\"\n\t\tsys.exit(1)\n\t\n\tscript_dir = os.environ[\"SCRIPTS\"]\n\t\n\t#check to se... | [
"0.6019444",
"0.60132563",
"0.5984834",
"0.58689296",
"0.5784049",
"0.577239",
"0.5581342",
"0.557601",
"0.55751157",
"0.5572636",
"0.5562024",
"0.5561663",
"0.55582947",
"0.5523044",
"0.5504529",
"0.54821223",
"0.54610753",
"0.5442544",
"0.54336953",
"0.5426791",
"0.5425167"... | 0.75311387 | 0 |
Return the .egginfo directory name as created/expected by setuptools | def setuptools_egg_info_dir(path):
filename = basename(path)
name, version = name_version_fn(filename)
return "{0}-{1}.egg-info".format(name, version) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_egg_path(self):\n try:\n _dist = get_distribution('janitoo_nut')\n return _dist.__file__\n except AttributeError:\n return 'src-nut/config'",
"def get_egg_name():\n global eggname\n if not eggname:\n version = local('git describe --abbrev=4', c... | [
"0.71632195",
"0.70793754",
"0.7000544",
"0.67306006",
"0.67111397",
"0.63494396",
"0.63382614",
"0.62092966",
"0.6154888",
"0.61210304",
"0.6118804",
"0.6108436",
"0.60944647",
"0.6094327",
"0.60788274",
"0.60607505",
"0.604199",
"0.60307246",
"0.5993479",
"0.5946837",
"0.59... | 0.80626833 | 0 |
Create an iterator that will remove every installed file. | def remove_iterator(self):
if not self.is_installed:
logger.error("Error: Can't find meta data for: {0!r}".
format(self.cname))
return
if not self.noapp:
remove_app(self.meta_dir, self.prefix)
_run_script(self.meta_dir, 'pre_egguninst... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroyer(): # ;-)\n\n def find_files_to_remove(pyfile):\n for filename in (\"%sc\" % pyfile, \"%so\" % pyfile):\n if exists(filename):\n yield filename\n\n counter = 0\n try:\n while True:\n pyfile = (yield)\n for filename in find_files_t... | [
"0.7256346",
"0.620885",
"0.6170257",
"0.6139884",
"0.6093206",
"0.6043911",
"0.6029516",
"0.60096747",
"0.59970886",
"0.5992837",
"0.59307355",
"0.5905943",
"0.58913827",
"0.58460367",
"0.5826814",
"0.5802044",
"0.57605225",
"0.57549083",
"0.5749984",
"0.57291716",
"0.572898... | 0.8085284 | 0 |
Given the content of the EGGINFO/inst/files_to_install.txt file, create/remove the links listed therein. | def _create_links(self):
for line in self.iter_files_to_install():
arcname, link = line.split()
if link == 'False':
continue
self.files.append(create_link(arcname, link, self.prefix)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_extract(env_name='root'):\n prefix = prefix_env(env_name)\n info_dir = join(prefix, 'info')\n with open(join(info_dir, 'index.json')) as fi:\n meta = json.load(fi)\n dist = '%(name)s-%(version)s-%(build)s' % meta\n if FORCE:\n run_script(prefix, dist, 'pre-unlink')\n link(p... | [
"0.56554204",
"0.55677485",
"0.5512642",
"0.5434684",
"0.54031354",
"0.53205824",
"0.5307699",
"0.52370214",
"0.52063715",
"0.5166861",
"0.5147408",
"0.513928",
"0.5119501",
"0.5096524",
"0.5093218",
"0.5092415",
"0.5089288",
"0.50748575",
"0.5073434",
"0.5063882",
"0.5056448... | 0.7130966 | 0 |
Create an iterator that will iterate over each archive to be extracted. | def install_iterator(self, extra_info=None):
self.pre_extract()
with ZipFile(self.path) as zp:
self.z = zp
arcnames = self.z.namelist()
is_custom_egg = eggmeta.is_custom_egg(self.path)
use_legacy_egg_info_format = has_legacy_egg_info_format(arcnames,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_iterator(self):\n with open(get_test_file('example-iana.org-chunked.warc'), 'rb') as fh:\n with closing(ArchiveIterator(fh)) as a:\n for record in a:\n assert record.rec_type == 'warcinfo'\n break\n\n record = next(a)\n ... | [
"0.63933086",
"0.61701816",
"0.60931313",
"0.5947081",
"0.59378624",
"0.59164816",
"0.5914825",
"0.5908251",
"0.59015465",
"0.5893539",
"0.5890408",
"0.58891773",
"0.5878479",
"0.5877033",
"0.5869342",
"0.5828999",
"0.5824064",
"0.58064514",
"0.5806028",
"0.5792314",
"0.57847... | 0.6767663 | 0 |
Generator returns a sorted list of all installed packages. Each element is the filename of the egg which was used to install the package. | def get_installed(prefix=sys.prefix):
egg_info_dir = join(prefix, 'EGG-INFO')
if not isdir(egg_info_dir):
return
pat = re.compile(r'([a-z0-9_.]+)$')
for fn in sorted(os.listdir(egg_info_dir)):
if not pat.match(fn):
continue
d = read_meta(join(egg_info_dir, fn))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_packages():\n\n shelf_dir = settings.shelf_dir\n\n package_list = os.listdir(shelf_dir)\n\n package_list.sort()\n\n return package_list",
"def list_packages(self):\n\n # First extract loaded module names from sys.modules\n sys_modules = sys.modules.keys()\n\n packages = ... | [
"0.72403914",
"0.7017457",
"0.6939396",
"0.69267774",
"0.69194084",
"0.6780125",
"0.67313737",
"0.67141587",
"0.67108655",
"0.66212547",
"0.6612123",
"0.6606311",
"0.6581613",
"0.6553268",
"0.6523214",
"0.6510894",
"0.65089864",
"0.6491792",
"0.6486826",
"0.6429936",
"0.63801... | 0.73239064 | 0 |
Simple wrapper to install an egg using default egginst progress bar. | def install_egg_cli(path, prefix, noapp=False, extra_info=None):
installer = EggInst(path, prefix, False, None, noapp)
progress = console_progress_manager_factory("installing egg", installer.fn,
size=installer.installed_size)
with progress:
for curren... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install(self, egg, dir_path):",
"def install():\n remote_egg_path = os.path.join(remote_egg_dir, get_egg_name())\n sudo('easy_install -U %s' % remote_egg_path)\n sudo('rm %s' % remote_egg_path)",
"def install_deps():\n click.echo(\"install_deps\")",
"def install_egg(self, egg_name):\n ... | [
"0.70431584",
"0.5815187",
"0.5645753",
"0.5623329",
"0.55615765",
"0.540842",
"0.536465",
"0.53391945",
"0.5316876",
"0.5294202",
"0.5259362",
"0.52347654",
"0.5229792",
"0.51995444",
"0.51150715",
"0.5105964",
"0.51037073",
"0.50978655",
"0.5081637",
"0.5080145",
"0.5061489... | 0.7207947 | 0 |
Simple wrapper to remove an egg using default egginst progress bar. | def remove_egg_cli(path, prefix, noapp=False):
installer = EggInst(path, prefix, False, None, noapp=noapp)
remover = installer._egginst_remover
if not remover.is_installed:
logger.error("Error: can't find meta data for: %r", remover.cname)
return
progress = console_progress_manager_facto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, egg):",
"def removeRenderProgress(call, args=(), kwargs={}, nodeClass='Write'):",
"def remove():\n run('pew rm {0}'.format(package_name()))",
"def uninstall_eggs(reqs):\n # XXX This doesn't do dependencies?\n dists = []\n names = [i.project_name for i in pkg_resources.parse_requi... | [
"0.6536793",
"0.5922131",
"0.5786582",
"0.54950666",
"0.54950666",
"0.5402939",
"0.53144974",
"0.5289059",
"0.52834994",
"0.52587646",
"0.51664484",
"0.5165647",
"0.5141761",
"0.507576",
"0.503838",
"0.50264436",
"0.49929398",
"0.49658763",
"0.49649218",
"0.4957863",
"0.49525... | 0.6788327 | 0 |
Return a 3 column `DataFrame` with every combination of compound, concentration, and mechanismofaction. Includes compounds with unknown MoA. | def moa_df(self) -> pd.DataFrame:
return (
self.image_df[["compound", "concentration", "moa"]]
.drop_duplicates()
.sort_values(["compound", "concentration"])
.reset_index(drop=True)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_compound_df(idx, compound_dict, standard_types):\n\n if standard_types is None or compound_dict['standard_type'] is None:\n is_valid_std_type = False\n else:\n compound_std_type = compound_dict['standard_type'].lower()\n is_valid_std_type =... | [
"0.56743085",
"0.5621436",
"0.5452508",
"0.5372342",
"0.53206503",
"0.5298058",
"0.5236215",
"0.52072287",
"0.5185877",
"0.51701504",
"0.51496804",
"0.513928",
"0.51029074",
"0.508618",
"0.50837684",
"0.50688493",
"0.50614244",
"0.5052746",
"0.50524265",
"0.50257736",
"0.5021... | 0.63617814 | 0 |
Get metadata for the given image at `rel_index`. | def metadata(self, rel_index) -> Metadata:
row = self.image_df.iloc[rel_index]
(
site,
well,
replicate,
plate,
compound,
concentration,
moa,
image_idx,
) = row[
[
"site",... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_meta(self, *, index=None):\n\n return self.metadata(index=index, exclude_applied=False)",
"def get_ch_metadata(self, index):\n\n tag = self.get_ch_tag(index)\n\n return getattr(self, f\"{tag.lower()}_metadata\")",
"def met(r):\n image_url = r.get(\"image\")\n if image_url is ... | [
"0.6210234",
"0.6100118",
"0.6047338",
"0.602929",
"0.59207207",
"0.57643884",
"0.5761522",
"0.56929874",
"0.5562844",
"0.5556255",
"0.55396575",
"0.5486095",
"0.5481895",
"0.5469507",
"0.5466895",
"0.5462773",
"0.54395884",
"0.5432568",
"0.54093903",
"0.5406928",
"0.5406572"... | 0.75697404 | 0 |
Index route handler. Requests sync of archives with YouTube and redirects to videos list view. | def web_index():
try:
auth_check()
except Exception as e:
return flask.redirect(str(e))
db_update_archives()
return flask.redirect('videos') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index():\n seen = set()\n seen_add = seen.add\n videos = []\n all_videos = mythVideo.searchVideos(insertedafter = '1900-01-01 00:00:00')\n\n for video in all_videos:\n path = video.filename.split('/')[0]\n if path not in seen and not seen_add(path):\n video.url = url_for... | [
"0.7194894",
"0.60978895",
"0.6054103",
"0.60335535",
"0.60171473",
"0.6015349",
"0.5889687",
"0.5867927",
"0.58595955",
"0.5856865",
"0.5851333",
"0.5836901",
"0.5762387",
"0.56491524",
"0.5624607",
"0.5580839",
"0.55714077",
"0.55364466",
"0.5510624",
"0.55072117",
"0.54987... | 0.73663384 | 0 |
Filters video list. First loads all tracked videos or videos from selected channel. Then filters those by 'archived' and/or 'played'. | def web_videos_filter(channel, tracks, archived, played):
videos = []
if channel == 'all':
for tracked in tracks:
videos.append(yt_get_channel_videos(tracked['id']))
videos = [
item
for sublist in videos
for item in sublist
]
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_videos(\n files: list\n):\n#cSpell:words webm vchd rmvb gifv xvid vidx\n video_extensions = [\n \"WEBM\",\n \"MPG\",\"MP2\", \"MPEG\", \"MPE\", \"MPV\",\n \"OGV\",\"OGG\",\n \"MP4\", \"M4P\", \"M4V\",\n \"AVI\",\n \"WMV\",\n \"MOV\",\"QT\",\n ... | [
"0.6374802",
"0.6256979",
"0.6111958",
"0.60916644",
"0.5943511",
"0.580283",
"0.57935655",
"0.5772663",
"0.5771047",
"0.5729728",
"0.57167804",
"0.5711858",
"0.5700031",
"0.56852317",
"0.5643084",
"0.5627934",
"0.56240964",
"0.5555672",
"0.55451226",
"0.5540436",
"0.5519386"... | 0.7700686 | 0 |
Play random unplayed video. Chooses random unplayed video from selected channel and redirects to its detail page view. | def web_videos_random_unplayed(channel):
try:
choice = random.choice([
video['snippet']['resourceId']['videoId']
for video in yt_get_channel_videos(channel)
if video['played'] is None
])
except IndexError:
return flask.redirect(flask.url_for('videos',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_random_video(self):\n\n print(\"play_random_video needs implementation\")",
"def web_videos_random_archived(channel):\n\n try:\n choice = random.choice([\n video['snippet']['resourceId']['videoId']\n for video in yt_get_channel_videos(channel)\n if video... | [
"0.7628045",
"0.7584085",
"0.7566698",
"0.75097615",
"0.743202",
"0.73796743",
"0.735591",
"0.722913",
"0.71296513",
"0.6425219",
"0.609854",
"0.6067561",
"0.6033064",
"0.58946383",
"0.58865196",
"0.5769868",
"0.5706612",
"0.56881535",
"0.56763864",
"0.56609184",
"0.55947924"... | 0.8118861 | 0 |
Play next unplayed video. Chooses next (chronologically) unplayed video from selected channel and redirects to its detail page view. | def web_videos_next_unplayed(channel):
try:
choice = sorted([
video
for video in yt_get_channel_videos(channel)
if video['played'] is None
], key = lambda video: video['snippet']['publishedAt'])[0]
except IndexError:
return flask.redirect(flask.url_fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_video(self, video_display_name):\r\n self.course_nav.go_to_sequential(video_display_name)\r\n self.video.wait_for_video_player_render()",
"def web_videos_random_unplayed(channel):\n\n try:\n choice = random.choice([\n video['snippet']['resourceId']['videoId']\n ... | [
"0.64699733",
"0.6392088",
"0.6360304",
"0.6326893",
"0.632032",
"0.6249135",
"0.6244949",
"0.6196304",
"0.61843336",
"0.6168583",
"0.60310626",
"0.6010417",
"0.6008484",
"0.60034865",
"0.5994183",
"0.5978123",
"0.59725094",
"0.59694654",
"0.59217656",
"0.5874249",
"0.5867619... | 0.77754235 | 0 |
Play random archived video. Chooses random archived video from selected channel and redirects to its detail page view. | def web_videos_random_archived(channel):
try:
choice = random.choice([
video['snippet']['resourceId']['videoId']
for video in yt_get_channel_videos(channel)
if video['archived'] is not None
])
except IndexError:
return flask.redirect(flask.url_for('vi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def web_videos_random_all(channel):\n\n try:\n choice = random.choice([\n video['snippet']['resourceId']['videoId']\n for video in yt_get_channel_videos(channel)\n ])\n except IndexError:\n return flask.redirect(flask.url_for('videos',\n channel = channel... | [
"0.7034829",
"0.6931877",
"0.69211984",
"0.6763168",
"0.6711558",
"0.6657283",
"0.6653861",
"0.6491873",
"0.64016736",
"0.5890076",
"0.5764354",
"0.57009566",
"0.56161135",
"0.5602274",
"0.5533277",
"0.55162233",
"0.55014026",
"0.54525715",
"0.53670835",
"0.53624773",
"0.5342... | 0.8072042 | 0 |
Channels track route handler. Renders tracking using connected YouTube account page. | def web_channels_track(user = None, subs = [], tracks = [], tracking = True, error = False):
try:
auth_check()
except Exception as e:
return flask.redirect(str(e))
return flask.render_template('channels.html', user = flask.session['user'],
subs = yt_get_subscriptions(),
tra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def web_channels(user = None, subs = None, tracks = [], tracking = False, error = False):\n\n try:\n auth_check()\n except Exception as e:\n return flask.redirect(str(e))\n\n if 'channels_query_error' in flask.session:\n error = flask.session.pop('channels_query_error')\n\n return ... | [
"0.60828084",
"0.5801575",
"0.577829",
"0.5701024",
"0.5369433",
"0.53576416",
"0.53157717",
"0.52398074",
"0.50842965",
"0.5081952",
"0.5074053",
"0.50718755",
"0.50674623",
"0.50440425",
"0.50022846",
"0.4953611",
"0.49410456",
"0.49345958",
"0.4932482",
"0.49055415",
"0.49... | 0.71484494 | 0 |
Handles channel tracking. Tracks or untracks YouTube channels using connected account or by user query. Then redirects to channels management page. Uses GET query parameters ``tracks`` and ``query``. | def web_channels_update():
try:
auth_check()
except Exception as e:
return flask.redirect(str(e))
tracks = flask.request.args.get('tracks', None)
query = flask.request.args.get('query', None)
if tracks is not None:
web_channels_update_tracks(tracks)
if query is not No... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def web_channels_track(user = None, subs = [], tracks = [], tracking = True, error = False):\n\n try:\n auth_check()\n except Exception as e:\n return flask.redirect(str(e))\n\n return flask.render_template('channels.html', user = flask.session['user'],\n subs = yt_get_subscriptions()... | [
"0.7032316",
"0.62527996",
"0.5573413",
"0.54305166",
"0.52212614",
"0.5210352",
"0.49153656",
"0.48610342",
"0.48336023",
"0.47890598",
"0.4710495",
"0.4682484",
"0.46176368",
"0.46165678",
"0.45394024",
"0.4523942",
"0.44958717",
"0.44796297",
"0.44723505",
"0.44703817",
"0... | 0.65192926 | 1 |
Handles channel subscriptions. Subscribes user to or unsubscribes user from given YouTube channel, then redirects to given page. Time delay is needed, because of YouTube Data API delays. Uses GET query parameter ``update`` (URL encoded JSON data). Its data contain ``id`` (YouTube subscription ID), ``subscribe`` (flag w... | def web_channels_subscriptions():
try:
auth_check()
except Exception as e:
return flask.redirect(str(e))
update = flask.request.args.get('update', None)
if update is not None:
update_data = json.loads(urllib.parse.unquote(update))
if update_data['subscribe']:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def web_channels_update():\n\n try:\n auth_check()\n except Exception as e:\n return flask.redirect(str(e))\n\n tracks = flask.request.args.get('tracks', None)\n query = flask.request.args.get('query', None)\n\n if tracks is not None:\n web_channels_update_tracks(tracks)\n\n ... | [
"0.59215385",
"0.5811833",
"0.57120794",
"0.5692857",
"0.5605875",
"0.556517",
"0.5525361",
"0.5459646",
"0.5434497",
"0.5430186",
"0.52267206",
"0.5187365",
"0.5147507",
"0.51374847",
"0.5111299",
"0.5105663",
"0.50596476",
"0.50518215",
"0.5022464",
"0.5001686",
"0.49997005... | 0.7881722 | 0 |
Archive route handler. Renders archive management view. | def web_archive():
try:
auth_check()
except Exception as e:
return flask.redirect(str(e))
return flask.render_template('archive.html', user = flask.session['user'],
archives = db_get_archives()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def master_archive(f, e):\n template = e.get_template(TEMPLATES['archive'])\n write_file(\"archives.html\", template.render(entries=f))",
"def archive(self, item):\n self._createAction(item, \"archive\")",
"def archives(request):\n template_var = base_template_vals(request)\n try:\n t... | [
"0.6417952",
"0.6239538",
"0.6112447",
"0.58351594",
"0.56548876",
"0.56019753",
"0.5550984",
"0.55282414",
"0.55225253",
"0.5508279",
"0.54446787",
"0.5371877",
"0.5365363",
"0.5353765",
"0.53384596",
"0.5315295",
"0.5309738",
"0.5285254",
"0.52578795",
"0.52272576",
"0.5199... | 0.6905707 | 0 |
Handles archive management. Inserts video to archive, imports entire playlist into archive or renames given archive. Uses GET query parameter ``name`` (new given archive name). | def web_archive_insert_rename(type = None, id = None):
try:
auth_check()
except Exception as e:
return flask.redirect(str(e))
if id is not None:
if type == 'video':
web_archive_insert_video(id)
elif type == 'playlist':
web_archive_import_playlist(id)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_archive(request):\n _logger.info('Starting to update archive event database')\n # if 'clear_all' in request.GET and request.user.is_staff:\n # _logger.info('Deleting all old entries')\n # clear_archive_and_cache()\n archive = requests.get(JSON_ARCHIVE_PATH).json()\n _logger.inf... | [
"0.5911487",
"0.5832514",
"0.56647336",
"0.5621823",
"0.5588441",
"0.5554563",
"0.5435584",
"0.5428717",
"0.5380136",
"0.53510743",
"0.52825946",
"0.52772593",
"0.5271754",
"0.526159",
"0.5169282",
"0.50990504",
"0.50871027",
"0.50739974",
"0.50693035",
"0.5068642",
"0.504210... | 0.5842425 | 1 |
Inserts video to archive. Inserts video to the first available archive. Creates new archive if all are full. | def web_archive_insert_video(id):
db = get_db()
user_id = flask.session['user']['id']
video_id = id
video = yt_get_video(video_id)
channel_id = video['snippet']['channelId']
archive = None
for playlist in db_get_archives():
if playlist['contentDetails']['itemCount'] < 5000:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_video(self, video_ID, username, title): #WORKS\n try:\n view_count = 0\n self.cur.execute(\"INSERT INTO videos VALUES(\\\"{}\\\", \\\"{}\\\", \\\"{}\\\", {}, NULL)\".format(video_ID, title, username, view_count))\n self.db.commit()\n except:\n se... | [
"0.5766349",
"0.5559592",
"0.55235577",
"0.5438006",
"0.53561896",
"0.52941525",
"0.5241105",
"0.52353734",
"0.52142256",
"0.5196818",
"0.5156672",
"0.51102114",
"0.5102395",
"0.50889146",
"0.5086302",
"0.5012913",
"0.49568442",
"0.49426603",
"0.49000892",
"0.4885934",
"0.488... | 0.7296448 | 0 |
Imports playlist to archive. Imports entire playlist to the first available archive. Creates new archive if all are full. | def web_archive_import_playlist(id):
db = get_db()
user_id = flask.session['user']['id']
for item in yt_get_playlist_items(id):
video_id = item['snippet']['resourceId']['videoId']
video = yt_get_video(video_id)
channel_id = video['snippet']['channelId']
archive = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_playlist(self, playlist_contents):\n\n # Just make sure we don't overwrite an existing playlist! Silly python not having do-while..\n while True:\n playlist_uuid = str(uuid4())\n if playlist_uuid not in self.playlists:\n break\n\n try:\n ... | [
"0.5846282",
"0.5743594",
"0.5503416",
"0.5393329",
"0.53303945",
"0.5238224",
"0.52318907",
"0.5171172",
"0.51659745",
"0.5153933",
"0.51347023",
"0.5002603",
"0.49983194",
"0.498852",
"0.49839196",
"0.4960784",
"0.49408525",
"0.49373156",
"0.49325132",
"0.49270764",
"0.4923... | 0.75030786 | 0 |
Renames archive. Renames given archive. Time delay is needed because of YouTube Data API delays. | def web_archive_rename(id, name):
if name is not None:
yt_rename_playlist(id, name)
time.sleep(5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract(self, directory, namemap):\r\n\r\n if self._archive == None:\r\n raise StandardError(\"Archive was not open\")\r\n\r\n\r\n for name in namemap:\r\n new_name = namemap[name]\r\n extension = os.path.splitext(name)[-1]\r\n\r\n if new_name == \"\":\... | [
"0.5949549",
"0.5851801",
"0.57133484",
"0.5678032",
"0.5579086",
"0.5553622",
"0.55382633",
"0.55067796",
"0.550095",
"0.549097",
"0.5475647",
"0.5457561",
"0.5451182",
"0.54365134",
"0.54269975",
"0.5407021",
"0.53848183",
"0.5380051",
"0.5375527",
"0.53590906",
"0.53559846... | 0.73768973 | 0 |
Generates youtubedl batch file. Generates batch file for youtubedl to download archived videos. Optionally uses uploaded youtubedl ``archive`` file to only include videos not yet downloaded. | def web_archive_batch():
try:
auth_check()
except Exception as e:
return flask.redirect(str(e))
batch = set()
if 'archiveFile' in flask.request.files:
file = flask.request.files['archiveFile']
if file.filename != '':
if file and allowed_file(file.filename):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def web_archive_config():\n\n try:\n auth_check()\n except Exception as e:\n return flask.redirect(str(e))\n\n socket_timeout = flask.request.args.get('ytdl-socket-timeout', '120')\n retries = flask.request.args.get('ytdl-retries', 'infinite')\n output = flask.request.args.get('ytdl-ou... | [
"0.5913973",
"0.56746423",
"0.5561277",
"0.54890925",
"0.54811895",
"0.541509",
"0.53035885",
"0.52241164",
"0.5205309",
"0.51469886",
"0.5143829",
"0.5142356",
"0.51281095",
"0.50647676",
"0.5031308",
"0.5017644",
"0.5003084",
"0.49867234",
"0.49685615",
"0.49037257",
"0.490... | 0.57923144 | 1 |
Downloads comments. Downloads archived videos' comments. Places them to subdirectories by YouTube channel ID and generates ZIP archive. | def web_archive_comments():
try:
auth_check()
except Exception as e:
return flask.redirect(str(e))
archive_comments = io.BytesIO()
with zipfile.ZipFile(archive_comments, 'w') as zf:
for video_id in db_get_archived():
video = yt_get_video(video_id)
comme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_videos(download_limit=6):\n videos = []\n for fname in os.listdir('yt_api_data'):\n videos += load_video_data(fname)\n vids_downloaded = 0\n excluded_vids = get_excluded_videos()\n for video_id, title in videos:\n if download_limit != 'all' and vids_downloaded == download_limit:\n brea... | [
"0.6204081",
"0.616626",
"0.6002963",
"0.6001744",
"0.5975271",
"0.5918797",
"0.5836402",
"0.5777342",
"0.5773983",
"0.5770001",
"0.5765609",
"0.57412875",
"0.56668377",
"0.5646026",
"0.56224424",
"0.561471",
"0.5601207",
"0.55846065",
"0.5581369",
"0.55805314",
"0.55797535",... | 0.7093865 | 0 |
Generates youtubedl configuration file. Generates configuration file for youtubedl. Gets values from GET query parameters. | def web_archive_config():
try:
auth_check()
except Exception as e:
return flask.redirect(str(e))
socket_timeout = flask.request.args.get('ytdl-socket-timeout', '120')
retries = flask.request.args.get('ytdl-retries', 'infinite')
output = flask.request.args.get('ytdl-output', '%(uplo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_settings():\r\n conf_file = os.path.join(os.path.dirname(base_settings.__file__),\r\n 'example', 'conf.py')\r\n conf_template = open(conf_file).read()\r\n default_url = 'http://salmon.example.com'\r\n site_url = raw_input(\"What will be the URL for Salmon? [{0}]... | [
"0.5741758",
"0.5687314",
"0.56398255",
"0.5469864",
"0.544449",
"0.544449",
"0.54289025",
"0.53530616",
"0.5291712",
"0.5289553",
"0.5288956",
"0.5249695",
"0.5249338",
"0.521561",
"0.5209517",
"0.518626",
"0.5172639",
"0.51489407",
"0.51292133",
"0.51254535",
"0.5114511",
... | 0.6546752 | 0 |
Return the stringified version of the generated xml | def xml_string(self):
if self._xml_string is not None:
return self._xml_string
return etree.tostring(self._xml_node) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml_string(self):\r\n if self._xml_string is not None:\r\n return self._xml_string\r\n\r\n return etree.tostring(self._xml_node)",
"def get_xml(self):\n return etree.tostring(self.get_etree())",
"def __str__(self):\n result = xml.dom.minidom.parseString(\n xml.etre... | [
"0.753312",
"0.75139797",
"0.7353235",
"0.73077554",
"0.7274747",
"0.7248204",
"0.72342646",
"0.7181866",
"0.69974494",
"0.69351363",
"0.69069105",
"0.6809317",
"0.67827904",
"0.67502034",
"0.6738443",
"0.6717033",
"0.66888523",
"0.66888523",
"0.66042393",
"0.655296",
"0.6550... | 0.7555695 | 0 |
Registers a list of events in vim. name is a string with the name of the plugin. events is a list of tuples, containing the event name, files it should match, the function that should be called and default arguments. | def register_events( register, name, events ):
group_name = '%(name)s_events' % locals()
func_reg = ':py manager.funcs[ %(func_id)s ]'
log.info( 'Register\'s events for %s.', name )
_vim.command( 'augroup %(group_name)s' % locals() )
_vim.command( 'au!' )
for e in events:
event, ftype, func, args = e
func_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(self, events=[]):\n self.events = events\n if not self in manager.handler:\n manager.handler.append(self)",
"def unregister_events( register, name, events ):\n\tgroup_name = '%(name)s_events' % locals()\n\n\tlog.info( 'Register\\'s events for %s.', name )\n\t_vim.command( 'a... | [
"0.61610824",
"0.56460327",
"0.54897934",
"0.52237713",
"0.5213687",
"0.518226",
"0.509555",
"0.5093085",
"0.49891645",
"0.49688333",
"0.4958541",
"0.49257076",
"0.4872273",
"0.48716444",
"0.4841015",
"0.48140547",
"0.48035198",
"0.4797285",
"0.46912763",
"0.469124",
"0.46888... | 0.78629565 | 0 |
Unregisters a list of events in vim. name is a string with the name of the plugin. events is a list of tuples, containing the event name, files it should match, the function that should be called and default arguments. | def unregister_events( register, name, events ):
group_name = '%(name)s_events' % locals()
log.info( 'Register\'s events for %s.', name )
_vim.command( 'augroup %(group_name)s' % locals() )
_vim.command( 'au!' )
_vim.command( 'augroup END' )
for e in events:
event, ftype, func, args = e
func_id = '%s.%s.%s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_events( register, name, events ):\n\tgroup_name = '%(name)s_events' % locals()\n\tfunc_reg = ':py manager.funcs[ %(func_id)s ]'\n\n\tlog.info( 'Register\\'s events for %s.', name )\n\t_vim.command( 'augroup %(group_name)s' % locals() )\n\t_vim.command( 'au!' )\n\n\tfor e in events:\n\t\tevent, ftype, ... | [
"0.6476616",
"0.5372906",
"0.5006933",
"0.49952856",
"0.49949694",
"0.498787",
"0.49829966",
"0.49427179",
"0.489989",
"0.48916665",
"0.48871693",
"0.48702627",
"0.4853779",
"0.48537192",
"0.47757748",
"0.47648826",
"0.47199845",
"0.47168308",
"0.4644181",
"0.46219876",
"0.46... | 0.7792846 | 0 |
Try to merge two fields, based on their field positions and types. | def _merge_fields(a: Field, b: Field) -> Optional[Field]:
# Merge the types:
merged_type: Optional[FieldType] = None
# Constant fields can be merged with any other type. To make type merging easier, swap a and b if b is
# constant.
if b.type is FieldType.CONST:
a, b = b, a
# Constant ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_field(cls, d1, d2, res_d, fields):\n if d1 is None:\n for x in fields:\n res_d[x] = d2[x]\n for x in fields:\n if (not x in d1) or (not x in d2):\n raise DHMLPEError('Need field %s requred' % x)\n if type(d1[x]) != type(d2[x]):\... | [
"0.7128986",
"0.7078132",
"0.6282925",
"0.6104646",
"0.57877904",
"0.57237726",
"0.56824344",
"0.56792694",
"0.5560363",
"0.54973304",
"0.5485922",
"0.54562724",
"0.5415758",
"0.5411737",
"0.5381882",
"0.5360062",
"0.53589773",
"0.5285311",
"0.5269959",
"0.52675396",
"0.52463... | 0.79206604 | 0 |
Either return the value at a certain key, or set the return value of a function to that key, then return that value. | def retrieve_and_set(self, key: Hashable, func: Callable[[], T]) -> T:
if key not in self:
self[key] = func()
return self[key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, key: str, fn=None):\n value = self._redis.get(key)\n if fn is None:\n return value\n return fn(value)",
"def get_or_call(self, key, callback, ttl=None):\n if self.contains(key):\n res = self[key]\n else:\n res = callback()\n ... | [
"0.7099636",
"0.7082751",
"0.70025986",
"0.6898359",
"0.6881354",
"0.6851177",
"0.6766945",
"0.67045116",
"0.66195375",
"0.65820783",
"0.6570675",
"0.64937603",
"0.6475176",
"0.6373491",
"0.6339212",
"0.6327115",
"0.63233894",
"0.6319361",
"0.6315313",
"0.63145745",
"0.629730... | 0.71596175 | 0 |
Converts the inputs to a numpy array. | def _convert_to_np_array(inputs: Union[float, Tuple[float], np.ndarray], dim):
outputs = None
if isinstance(inputs, (tuple, np.ndarray)):
outputs = np.array(inputs)
else:
outputs = np.full(dim, inputs)
if len(outputs) != dim:
raise ValueError("The inputs array has a different dimension {}"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_numpy(self, **kwargs):\n pass",
"def _to_numpy_ndarray(cls, data):\n if isinstance(data, np.ndarray):\n return data\n arr = np.array(data, dtype=np.float)\n if len(arr.shape) == 1:\n arr = np.reshape(arr, newshape=(1, arr.shape[0]))\n return arr",
... | [
"0.7461629",
"0.69847417",
"0.6951733",
"0.6802632",
"0.6798552",
"0.67880565",
"0.67880565",
"0.6777693",
"0.677752",
"0.67513126",
"0.6715467",
"0.670942",
"0.6709284",
"0.6683196",
"0.6638872",
"0.66135097",
"0.6610778",
"0.6585419",
"0.6556312",
"0.65206075",
"0.65094066"... | 0.76538384 | 0 |
Print the MKL interface status if debug mode is on | def print_mkl_debug():
if not MKL.MKL_DEBUG:
return
if get_version_string() is None:
print("mkl-service must be installed to get full debug messaging")
else:
print(get_version_string())
print("MKL linked: {fn}".format(fn=_libmkl._name))
print("MKL interface {np} | {c}".for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug_print(msg):\n\n if not MKL.MKL_DEBUG:\n return\n else:\n print(msg)",
"def set_debug_mode(debug_bool):\n\n MKL.MKL_DEBUG = debug_bool",
"def cli(debug):\n print(f\"Debug mode is {'on' if debug else 'off'}\")",
"def debug():",
"def debug() -> bool:",
"def vv_flag():\n ... | [
"0.7316679",
"0.7071496",
"0.65291965",
"0.6342046",
"0.62836",
"0.6195819",
"0.6077627",
"0.6050338",
"0.59492254",
"0.59452087",
"0.59373975",
"0.592777",
"0.58959675",
"0.5857974",
"0.58322245",
"0.5829775",
"0.5814042",
"0.5799022",
"0.5784965",
"0.57414657",
"0.5733295",... | 0.8008107 | 0 |
Ensure that the sparse matrix indicies are in the correct integer type | def _check_scipy_index_typing(sparse_matrix):
int_max = np.iinfo(MKL.MKL_INT_NUMPY).max
if (sparse_matrix.nnz > int_max) or (max(sparse_matrix.shape) > int_max):
msg = "MKL interface is {t} and cannot hold matrix {m}\n".format(m=repr(sparse_matrix), t=MKL.MKL_INT_NUMPY)
msg += "Try changing MKL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_integer(matrix):\n return numpy.issubdtype(matrix.dtype, numpy.integer)",
"def test_import_type_sparse():\n x = sps.csr_matrix(np.random.rand(7, 11))\n export_data('/tmp/test.sparse', x)\n assert x.dtype == import_data('/tmp/test.sparse').dtype",
"def test_import_sparse_type_mat():\n x = ... | [
"0.6705772",
"0.65772516",
"0.6422952",
"0.6349799",
"0.6263671",
"0.6246733",
"0.6203051",
"0.60799706",
"0.6078183",
"0.60398585",
"0.60077375",
"0.5991347",
"0.59738916",
"0.5944369",
"0.5911568",
"0.58959514",
"0.58302915",
"0.57903874",
"0.5789054",
"0.5766448",
"0.57516... | 0.7917765 | 0 |
Get the array layout code for a dense array in C or F order. Raises a ValueError if the array is not contiguous. | def _get_numpy_layout(numpy_arr, second_arr=None):
# Return the second array order if the first is ambiguous
if numpy_arr.flags.c_contiguous and numpy_arr.flags.f_contiguous and second_arr is not None:
if second_arr.flags.c_contiguous:
return LAYOUT_CODE_C, numpy_arr.shape[1]
elif s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def c_layout_from_shape(shape, dtype):\n dim = c_layout_from_shape(tail(shape), dtype)\n extent = head(shape)\n stride = dim.stride * dim.extent\n return Dimension(dim, extent, stride)",
"def to_ctype(self, array, name_cvalue):\n if not isinstance(array, np.ndarray):\n array = np.asarray(arra... | [
"0.5021277",
"0.50138515",
"0.48118067",
"0.4792349",
"0.4687829",
"0.46823096",
"0.4651778",
"0.45708072",
"0.45583484",
"0.4521126",
"0.4512224",
"0.44986218",
"0.44889227",
"0.44817048",
"0.44649702",
"0.44604322",
"0.44163802",
"0.44158214",
"0.44007537",
"0.44007537",
"0... | 0.65585107 | 0 |
Create MKL internal representation for BSR matrix | def _create_mkl_sparse_bsr(matrix):
double_precision = _is_double(matrix)
handle_func = MKL._mkl_sparse_d_create_bsr if double_precision else MKL._mkl_sparse_s_create_bsr
# Get the blocksize and check that the blocks are square
_blocksize = matrix.blocksize[0]
if _blocksize != matrix.blocksize[1]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _export_mkl_sparse_bsr(bsr_mkl_handle, double_precision):\n\n # Allocate for output\n ordering, nrows, ncols, indptrb, indptren, indices, data = _allocate_for_export(double_precision)\n block_layout = _ctypes.c_int()\n block_size = MKL.MKL_INT()\n\n # Set output\n out_func = MKL._mkl_sparse_d... | [
"0.6805437",
"0.6088575",
"0.57400906",
"0.56996804",
"0.56996804",
"0.56387144",
"0.55869156",
"0.5557554",
"0.55278826",
"0.5502965",
"0.54941803",
"0.54462695",
"0.543815",
"0.54273325",
"0.5332773",
"0.5327472",
"0.53121465",
"0.52871734",
"0.5271434",
"0.5259757",
"0.525... | 0.6881442 | 0 |
Export a MKL sparse handle of CSR or CSC type | def _export_mkl(csr_mkl_handle, double_precision, output_type="csr"):
output_type = output_type.lower()
if output_type == "csr":
out_func = MKL._mkl_sparse_d_export_csr if double_precision else MKL._mkl_sparse_s_export_csr
sp_matrix_constructor = _spsparse.csr_matrix
elif output_type == "c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pass_mkl_handle_csr_csc(data, handle_func):\n\n # Create a pointer for the output matrix\n ref = sparse_matrix_t()\n\n # Load into a MKL data structure and check return\n ret_val = handle_func(_ctypes.byref(ref),\n _ctypes.c_int(SPARSE_INDEX_BASE_ZERO),\n ... | [
"0.7411302",
"0.6970155",
"0.6886332",
"0.67817605",
"0.6760224",
"0.66355133",
"0.6138118",
"0.6106748",
"0.6014569",
"0.5976974",
"0.58949935",
"0.5851029",
"0.5835299",
"0.57619697",
"0.57247114",
"0.57183605",
"0.57070935",
"0.56905633",
"0.5687282",
"0.56796414",
"0.5678... | 0.7782392 | 0 |
Export a BSR matrix from MKL's internal representation to scipy | def _export_mkl_sparse_bsr(bsr_mkl_handle, double_precision):
# Allocate for output
ordering, nrows, ncols, indptrb, indptren, indices, data = _allocate_for_export(double_precision)
block_layout = _ctypes.c_int()
block_size = MKL.MKL_INT()
# Set output
out_func = MKL._mkl_sparse_d_export_bsr i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_mkl_sparse_bsr(matrix):\n\n double_precision = _is_double(matrix)\n handle_func = MKL._mkl_sparse_d_create_bsr if double_precision else MKL._mkl_sparse_s_create_bsr\n\n # Get the blocksize and check that the blocks are square\n _blocksize = matrix.blocksize[0]\n\n if _blocksize != matrix... | [
"0.66632766",
"0.66085476",
"0.579127",
"0.56930315",
"0.5644969",
"0.5552128",
"0.54505527",
"0.54365265",
"0.5429466",
"0.541752",
"0.53509474",
"0.5329866",
"0.53120434",
"0.5304355",
"0.5257802",
"0.52518463",
"0.52253133",
"0.5219141",
"0.5217025",
"0.5202944",
"0.515014... | 0.73820436 | 0 |
Get pointers for output from MKL internal representation | def _allocate_for_export(double_precision):
# Create the pointers for the output data
indptrb = _ctypes.POINTER(MKL.MKL_INT)()
indptren = _ctypes.POINTER(MKL.MKL_INT)()
indices = _ctypes.POINTER(MKL.MKL_INT)()
ordering = _ctypes.c_int()
nrows = MKL.MKL_INT()
ncols = MKL.MKL_INT()
data ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pointers(self, row, col):\n ### FILL IN ###",
"def _export_mkl(csr_mkl_handle, double_precision, output_type=\"csr\"):\n\n output_type = output_type.lower()\n\n if output_type == \"csr\":\n out_func = MKL._mkl_sparse_d_export_csr if double_precision else MKL._mkl_sparse_s_export_csr\n... | [
"0.5583657",
"0.5471018",
"0.53638065",
"0.5277258",
"0.52664226",
"0.5218946",
"0.52022696",
"0.5175506",
"0.5161156",
"0.51242775",
"0.51098394",
"0.51017565",
"0.51009226",
"0.5057951",
"0.50464344",
"0.5039491",
"0.5014644",
"0.49991396",
"0.49957523",
"0.49888894",
"0.49... | 0.5911445 | 0 |
Deallocate a MKL sparse handle | def _destroy_mkl_handle(ref_handle):
ret_val = MKL._mkl_sparse_destroy(ref_handle)
_check_return_value(ret_val, "mkl_sparse_destroy") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pass_mkl_handle_csr_csc(data, handle_func):\n\n # Create a pointer for the output matrix\n ref = sparse_matrix_t()\n\n # Load into a MKL data structure and check return\n ret_val = handle_func(_ctypes.byref(ref),\n _ctypes.c_int(SPARSE_INDEX_BASE_ZERO),\n ... | [
"0.5998003",
"0.58907074",
"0.5808191",
"0.57739156",
"0.5696759",
"0.56805813",
"0.56754106",
"0.56258684",
"0.5611057",
"0.5606743",
"0.56001616",
"0.54918486",
"0.546563",
"0.5457472",
"0.5457472",
"0.5445494",
"0.5444214",
"0.54247576",
"0.5412737",
"0.54036295",
"0.53534... | 0.81308204 | 0 |
Reorder indexes in a MKL sparse handle | def _order_mkl_handle(ref_handle):
ret_val = MKL._mkl_sparse_order(ref_handle)
_check_return_value(ret_val, "mkl_sparse_order") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reorder_indexer(\n self,\n seq: tuple[Scalar | Iterable | AnyArrayLike, ...],\n indexer: npt.NDArray[np.intp],\n ) -> npt.NDArray[np.intp]:\n\n # check if sorting is necessary\n need_sort = False\n for i, k in enumerate(seq):\n if com.is_null_slice(k) or... | [
"0.5794622",
"0.571588",
"0.57091177",
"0.57091177",
"0.56887496",
"0.56382024",
"0.56382024",
"0.5629167",
"0.5615396",
"0.5581556",
"0.55445707",
"0.5530016",
"0.53949004",
"0.5375908",
"0.53753424",
"0.53497434",
"0.5317605",
"0.5299328",
"0.52847916",
"0.52765393",
"0.525... | 0.70113045 | 0 |
Convert a MKL sparse handle to CSR format | def _convert_to_csr(ref_handle, destroy_original=False):
csr_ref = sparse_matrix_t()
ret_val = MKL._mkl_sparse_convert_csr(ref_handle, _ctypes.c_int(10), _ctypes.byref(csr_ref))
try:
_check_return_value(ret_val, "mkl_sparse_convert_csr")
except ValueError:
try:
_destroy_mkl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pass_mkl_handle_csr_csc(data, handle_func):\n\n # Create a pointer for the output matrix\n ref = sparse_matrix_t()\n\n # Load into a MKL data structure and check return\n ret_val = handle_func(_ctypes.byref(ref),\n _ctypes.c_int(SPARSE_INDEX_BASE_ZERO),\n ... | [
"0.7503132",
"0.6884736",
"0.6833039",
"0.6737469",
"0.67181027",
"0.66780216",
"0.66586936",
"0.64889747",
"0.6419341",
"0.6368549",
"0.63611144",
"0.6345656",
"0.6335942",
"0.63115376",
"0.6233469",
"0.6230282",
"0.61900723",
"0.6182203",
"0.61719376",
"0.6149485",
"0.61394... | 0.80026007 | 0 |
Make sure that both matrices are single precision floats or both are double precision floats If not, convert to double precision floats if cast is True, or raise an error if cast is False | def _type_check(matrix_a, matrix_b=None, cast=False):
if matrix_b is None and matrix_a.dtype in NUMPY_FLOAT_DTYPES:
return matrix_a
elif matrix_b is None and cast:
return _cast_to_float64(matrix_a)
elif matrix_b is None:
err_msg = "Matrix data type must be float32 or float64; {a} pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cast_to_float64(matrix):\n return matrix.astype(np.float64) if matrix.dtype != np.float64 else matrix",
"def _cast_floats_tensors(dtype: torch.dtype, *args: Any,\n **kwargs: Any) -> Tuple[Any, Any]:\n\n def fn(t):\n if t.dtype != dtype and torch.is_floating_point(t):\n t ... | [
"0.6832336",
"0.6667693",
"0.6325772",
"0.6165843",
"0.6116096",
"0.61026704",
"0.60815245",
"0.60619795",
"0.60571426",
"0.60053754",
"0.5989271",
"0.59556264",
"0.5892343",
"0.58230317",
"0.5795442",
"0.57754385",
"0.5771388",
"0.57604766",
"0.57517004",
"0.57290393",
"0.57... | 0.77179164 | 0 |
Return true if the array is doubles, false if singles, and raise an error if it's neither. | def _is_double(arr):
# Figure out which dtype for data
if arr.dtype == np.float32:
return False
elif arr.dtype == np.float64:
return True
else:
raise ValueError("Only float32 or float64 dtypes are supported") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _type_check_double(self, data):\n if type(data) not in self._VALID_TYPES:\n return False\n return True",
"def is_double(self, size=None):\n return False",
"def is_double(self):\n answer = self._call('is_double')\n return answer.yes",
"def test_doubles(self):\... | [
"0.747019",
"0.7235874",
"0.71077436",
"0.68799317",
"0.6715272",
"0.64534026",
"0.6342791",
"0.63272387",
"0.63052255",
"0.6244265",
"0.61503935",
"0.61319894",
"0.61143047",
"0.6110175",
"0.610887",
"0.60791916",
"0.60741085",
"0.6068399",
"0.6066847",
"0.60555583",
"0.6041... | 0.8601574 | 0 |
Return True if the matrix is dense or a sparse format we can turn into an MKL object. False otherwise. | def _is_allowed_sparse_format(matrix):
if _spsparse.isspmatrix(matrix):
return _spsparse.isspmatrix_csr(matrix) or _spsparse.isspmatrix_csc(matrix) or _spsparse.isspmatrix_bsr(matrix)
else:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_supported_matrix(data):\n return (\n spsp.isspmatrix_csc(data)\n or spsp.isspmatrix_csr(data)\n or spsp.isspmatrix_bsr(data)\n or spsp.isspmatrix_dia(data)\n )",
"def _supports(self, item):\n if SparseParameter._is_supported_matrix(item):\n... | [
"0.6952465",
"0.66576916",
"0.64244884",
"0.6365767",
"0.6324652",
"0.62777936",
"0.6238086",
"0.6201366",
"0.61812407",
"0.6110858",
"0.6012205",
"0.598834",
"0.59821093",
"0.5854083",
"0.58480424",
"0.58087015",
"0.579887",
"0.57980883",
"0.579131",
"0.5740345",
"0.5668392"... | 0.73378223 | 0 |
Define dtypes empirically Basically just try with int64s and if that doesn't work try with int32s There's a way to do this with intel's mkl helper package but I don't want to add the dependency | def _empirical_set_dtype():
MKL._set_int_type(_ctypes.c_longlong, np.int64)
try:
_validate_dtype()
except ValueError as err:
MKL._set_int_type(_ctypes.c_int, np.int32)
try:
_validate_dtype()
except ValueError:
raise ImportError("Unable to set MKL nu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basic_numpy_dtypes():\n assert np.int != np.int8\n assert np.int != np.int16\n assert np.int != np.int32\n assert np.int != np.int64\n\n assert np.int == int\n assert np.int8 != int\n assert np.int16 != int\n assert np.int32 != int\n assert np.int64 != int\n\n assert np.dtype... | [
"0.69681156",
"0.6631058",
"0.6527441",
"0.6429847",
"0.6308483",
"0.62624705",
"0.6209369",
"0.61716187",
"0.61229116",
"0.60635436",
"0.6042562",
"0.6009509",
"0.5998932",
"0.598397",
"0.59283894",
"0.58461434",
"0.581166",
"0.5777285",
"0.5776625",
"0.57729536",
"0.5738151... | 0.7136101 | 0 |
Add a geometry to the viewer. | def add_geometry(self, name, geometry, **kwargs):
# convert geometry to constructor args
args = rendering.convert_to_vertexlist(geometry, **kwargs)
# create the indexed vertex list
self.vertex_list[name] = self.batch.add_indexed(*args)
# save the MD5 of the geometry
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_geometry(self, selection_name, geometry):",
"def addGeomToLayer(self,geom,layer):\r\n fet = QgsFeature()\r\n fet.setGeometry(geom)\r\n area=geom.area()#/1000000\r\n if self.debug: print \"Area of geom added to layer:\", str(area)\r\n layer.dataProvider().addFeatures([fe... | [
"0.64952105",
"0.62759596",
"0.62081546",
"0.6082611",
"0.60124516",
"0.6008359",
"0.5835078",
"0.58150786",
"0.5782619",
"0.5752478",
"0.57494867",
"0.56827646",
"0.5658055",
"0.55916506",
"0.55764496",
"0.5514922",
"0.54822725",
"0.54443157",
"0.54409635",
"0.5400994",
"0.5... | 0.69834006 | 0 |
Toggle backface culling on or off. It is on by default but if you are dealing with non watertight meshes you probably want to be able to see the back sides. | def toggle_culling(self):
self.view['cull'] = not self.view['cull']
self.update_flags() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flip(self):\n \n if self.faceup:\n self.faceup = False\n else:\n self.faceup = True",
"def flip_faceup(self):\r\n self.faceup = True",
"def toggle_wireframe(self):\n self.view['wireframe'] = not self.view['wireframe']\n self.update_flags()",
... | [
"0.6543422",
"0.6417238",
"0.6304338",
"0.6230726",
"0.6208714",
"0.6206689",
"0.6162966",
"0.6009255",
"0.59964055",
"0.57162297",
"0.56792635",
"0.5663139",
"0.5612897",
"0.5562508",
"0.5553363",
"0.5550044",
"0.5550044",
"0.5491",
"0.54897135",
"0.5467871",
"0.5417624",
... | 0.7487545 | 0 |
Toggle unfilled wireframe mode on or off, good for looking inside meshes. Off by default. | def toggle_wireframe(self):
self.view['wireframe'] = not self.view['wireframe']
self.update_flags() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wireframe_only(self):\n return self._wireframe_only",
"def setSurfaceMeshing(state='off',shading=1):\n sdict = {'off':'OFF','on':'ON'}\n val = sdict[state]\n if not shading:\n val = 'ONLY'\n dislin.surmsh(val)",
"def setDisplayMode(self, mode):\n return \"Wireframe\"",
"d... | [
"0.71556896",
"0.65727925",
"0.6441071",
"0.6383935",
"0.6370791",
"0.6213878",
"0.6103676",
"0.60740423",
"0.60284024",
"0.5979613",
"0.5933176",
"0.592923",
"0.5927584",
"0.5831243",
"0.5792221",
"0.5728866",
"0.56652504",
"0.560257",
"0.5594461",
"0.55748224",
"0.55633944"... | 0.88619846 | 0 |
Toggle between fullscreen and windowed mode. | def toggle_fullscreen(self):
self.view['fullscreen'] = not self.view['fullscreen']
self.update_flags() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toggle_fullscreen(self):\n if self.view is not None:\n self.view.toggle_fullscreen()\n else:\n if self.isFullScreen():\n self.showNormal()\n else:\n self.showFullScreen()",
"def toggle_display_mode(self):\n if self.main_windo... | [
"0.8349788",
"0.82538664",
"0.8245228",
"0.8177107",
"0.79098874",
"0.727449",
"0.71042883",
"0.6883509",
"0.67707205",
"0.6722802",
"0.65643376",
"0.65581906",
"0.6538846",
"0.6444551",
"0.6312274",
"0.6180111",
"0.61613035",
"0.61028606",
"0.6039831",
"0.60196704",
"0.59866... | 0.8460718 | 0 |
Toggle a rendered XYZ/RGB axis marker on, world frame, or every frame. Off by default. | def toggle_axis(self):
# cycle through three axis states
states = [False, 'world', 'all']
# the state after toggling
index = (states.index(self.view['axis']) + 1) % len(states)
# update state to next index
self.view['axis'] = states[index]
# perform gl actions
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toggle_xy(self, x, y):\r\n\t\tself.grid[y, x] = False if self.grid[y,x] else True",
"def toggleDisplacement(*args, **kwargs)->None:\n pass",
"def toggle_draw_axes(self):\n if self.draw_axes:\n self.draw_axes = False\n else:\n self.draw_axes = True\n self.redraw... | [
"0.59986776",
"0.5821835",
"0.57994",
"0.57994",
"0.57516575",
"0.5715698",
"0.5605229",
"0.55470556",
"0.55350065",
"0.5440395",
"0.54163533",
"0.53877056",
"0.53509474",
"0.5303239",
"0.5293348",
"0.5284785",
"0.5272546",
"0.5255113",
"0.52492505",
"0.5240226",
"0.5234818",... | 0.6797696 | 0 |
Check the view flags and call what is needed with gl to handle it correctly. | def update_flags(self):
# view mode, filled vs wirefrom
if self.view['wireframe']:
gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
else:
gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
# set fullscreen or windowed
self.set_fullscreen(fullscreen=self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def appGL(deltaT):#-------------------------------- OpenGL UPDATE\n pass # -> Delete this line if you do something here !",
"def __handle_view_win_condition(self, gamestate_component):",
"def __handle_view_adversary(self, gamestate_component):",
"def __handle_view_door(self, gamestate_component):",
"def... | [
"0.6333015",
"0.61926216",
"0.5962737",
"0.5913055",
"0.57719433",
"0.57710075",
"0.5629424",
"0.5611663",
"0.55999154",
"0.5594215",
"0.55084777",
"0.5442984",
"0.54249173",
"0.5420551",
"0.5391859",
"0.53828853",
"0.5378064",
"0.5367985",
"0.53627723",
"0.53487647",
"0.5344... | 0.6220334 | 1 |
Save the current color buffer to a file object in PNG format. | def save_image(self, file_obj):
manager = pyglet.image.get_buffer_manager()
colorbuffer = manager.get_color_buffer()
# if passed a string save by name
if hasattr(file_obj, 'write'):
colorbuffer.save(file=file_obj)
else:
colorbuffer.save(filename=file_obj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _save_buffer(self):\n img_data = renderer.fbuffer.read(mode='color', alpha=False)\n img = Image.fromarray(img_data)\n img.save(self._save_fname)\n self._save_flag = False",
"def save_to_buffer(self) -> io.BytesIO:\n image = get_screenshot_as_png(self._layout)\n buffe... | [
"0.76338357",
"0.6845675",
"0.6464358",
"0.64415115",
"0.6381428",
"0.6303543",
"0.6299883",
"0.62519944",
"0.61433536",
"0.60814065",
"0.60460943",
"0.60341436",
"0.5978806",
"0.5968448",
"0.5947561",
"0.59450895",
"0.59378713",
"0.59113497",
"0.588933",
"0.5836905",
"0.5797... | 0.79262394 | 0 |
Given a dictionary containing view parameters, calculate a transformation matrix. | def view_to_transform(view):
transform = view['ball'].matrix()
transform[0:3, 3] = view['center']
transform[0:3, 3] -= np.dot(transform[0:3, 0:3], view['center'])
transform[0:3, 3] += view['translation'] * view['scale'] * 5.0
return transform | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_transforms(self, view):\n raise NotImplementedError()\n # Todo: this method can be removed if we somehow enable the shader\n # to specify exactly which transform functions it needs by name. For\n # example:\n #\n # // mapping function is automatically defi... | [
"0.6074161",
"0.59667534",
"0.58879656",
"0.58708775",
"0.58666587",
"0.58450586",
"0.5839513",
"0.580901",
"0.57664406",
"0.5750556",
"0.573642",
"0.5719473",
"0.5676489",
"0.5676489",
"0.56622416",
"0.5610182",
"0.5576211",
"0.5572452",
"0.5564787",
"0.5563543",
"0.55423295... | 0.6559304 | 0 |
Get an MD5 for a geometry object | def geometry_hash(geometry):
if hasattr(geometry, 'md5'):
# for most of our trimesh objects
md5 = geometry.md5()
elif hasattr(geometry, 'tostring'):
# for unwrapped ndarray objects
md5 = str(hash(geometry.tostring()))
if hasattr(geometry, 'visual'):
# if visual prope... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MD5(self) -> _n_0_t_3[_n_0_t_9]:",
"def getmd5(image: Image):\n return hashlib.md5(image.tobytes()).hexdigest()",
"def md5(self):\n md5_properties_all = [\n \"md5_train\",\n \"Z\",\n \"R_desc\",\n \"R_d_desc_alpha\",\n \"sig\",\n \... | [
"0.7097478",
"0.69337004",
"0.6827883",
"0.6730617",
"0.66074306",
"0.66049516",
"0.6511617",
"0.65046865",
"0.65022",
"0.64703137",
"0.64620805",
"0.64414126",
"0.64353293",
"0.64076245",
"0.6403776",
"0.6395555",
"0.6374734",
"0.63517165",
"0.6339644",
"0.63102585",
"0.6292... | 0.8009691 | 0 |
Converts coordinates into pygame coordinates | def to_pygame_coords(self, coords):
coords = Vector(coords)
if Window.FollowPlayer:
# offset coords by screen center
coords = coords + (self.size * .5)
# offset coords by centered_obj
center_point = game.current_level.player.position + Vector(game.current_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_pygame(coords):\r\n return (coords[0], HEIGHT - coords[1])",
"def convert_to_pygame(pos):\n return int(pos.x), int(-pos.y+600)",
"def to_pygame(point):\n return int(point.x), int(-point.y+500)",
"def to_pygame(p):\n return int(p.x), int(-p.y+600)",
"def convert_coords(x, y, conversion):\... | [
"0.78622335",
"0.72635925",
"0.69911623",
"0.68917733",
"0.6883496",
"0.6809415",
"0.66342926",
"0.64818054",
"0.64522743",
"0.64150536",
"0.641057",
"0.63610876",
"0.63509816",
"0.63174504",
"0.62839866",
"0.62688786",
"0.62378883",
"0.62214476",
"0.62022173",
"0.61923206",
... | 0.7307026 | 1 |
Overriding the grandparent's (WebsocketClient) listen method in order to calculate the order depth and copy the data to the shared namespace for the TUI to display | async def _listen(self,sub_params):
async with websockets.connect(self.url) as websocket:
await websocket.send(json.dumps(sub_params))
# self.keepalive.start()
start_time = time.time()
while not self.shutdown_event.is_set():
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wsSubData_nb(self):\n uwsgi.websocket_handshake(self.environ['HTTP_SEC_WEBSOCKET_KEY'], self.environ.get('HTTP_ORIGIN', ''))\n channel = self.r.pubsub()\n channel.subscribe(self.channel)\n channel.parse_response()\n websocket_fd = uwsgi.connection_fd()\n redis_fd = cha... | [
"0.6104709",
"0.58729875",
"0.5837385",
"0.56575114",
"0.5515513",
"0.5515513",
"0.5515513",
"0.5400467",
"0.53684926",
"0.53325236",
"0.5302534",
"0.52094096",
"0.5206881",
"0.51678574",
"0.515088",
"0.5138409",
"0.5137378",
"0.51336306",
"0.511451",
"0.5109486",
"0.50879407... | 0.66192347 | 0 |
Mounts a VP and opens a terminal window into the job's files. Returns a tuple (a, b) where 'a' is the exit code and 'b' a JSON string. | def worker(session, args):
#print("Hello " + args.jobid + "!")
session.login(args.vcnc)
#
# Lookup the grid job on the vcnc
# Exit if you don't find it.
response = grid.get(session, args.jobid)
if (response['status_code'] != 200):
return (1, response)
#
# Extract the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shell(cmd):\n return G.DEVICE.shell(cmd)",
"def openTerminal():\n\n nodes = nuke.selectedNodes()\n if nodes:\n for node in nodes:\n if node.Class() in ['Read', 'Write']:\n if 'views' in node.knobs().keys():\n path = os.path.dirname(node['file'].eva... | [
"0.53975135",
"0.53889275",
"0.536755",
"0.52297354",
"0.5091113",
"0.50775176",
"0.50679195",
"0.5064769",
"0.5033499",
"0.5024935",
"0.5024093",
"0.5023615",
"0.5000715",
"0.49897075",
"0.49711043",
"0.49470192",
"0.48784858",
"0.48648283",
"0.48636717",
"0.48622045",
"0.48... | 0.5931752 | 0 |
Calls the generate function. | def __call__(self):
return self.generate() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate():",
"def generate(self):\n pass",
"def generate(self):",
"def generate(self):\n pass",
"def generate(self):\n pass",
"def generate(self):\n pass",
"def generate(self):\r\n raise NotImplementedError",
"def generate(self):\n return self.gen.generate()",... | [
"0.8184073",
"0.77250504",
"0.7705011",
"0.7610695",
"0.7610695",
"0.7610695",
"0.7456402",
"0.736646",
"0.72722125",
"0.7219787",
"0.72120804",
"0.72120804",
"0.72120804",
"0.69251",
"0.6900884",
"0.6804928",
"0.67774975",
"0.6663211",
"0.66209304",
"0.66115654",
"0.6580314"... | 0.79611397 | 1 |
Clears grid and samples for generating new samples. | def _clear_previous_samples(self):
del self._grid
del self._samples
# --------------------------------
# Grid Parameters
# --------------------------------
self._cell_length = self._radius / np.sqrt(self._dim)
self._grid_shape = np.array([int(np.ceil(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(self):\n self.__indexclusters[:] = []\n self.__sample_size = 0\n self.__samples[:] = []\n self.__simifunc = None",
"def clear(self):\n self._grid = [[None]]",
"def clear(self):\n self.sum_hit_at_one = 0.0\n self.sum_perr = 0.0\n self.sum_loss = 0.0\n sel... | [
"0.73936063",
"0.7380064",
"0.72586673",
"0.722002",
"0.6979965",
"0.6930164",
"0.6902978",
"0.688646",
"0.68786246",
"0.6827424",
"0.68211716",
"0.6809749",
"0.6792506",
"0.6758799",
"0.6752552",
"0.67199963",
"0.6713395",
"0.6699241",
"0.6680809",
"0.6677323",
"0.6671793",
... | 0.8403089 | 0 |
Returns the grid coordinate of the point. | def _get_grid_coord(self, point):
return tuple([int(point[i] / self._cell_length) for i in range(self._dim)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_grid_coordinate(self):\n return (int(self.position.x // (2 * Molecule.radius)),\n int(self.position.y // (2 * Molecule.radius)))",
"def position_grid(self):\n return self.currentLevel.toGridCoord(self.position)",
"def get_xy(self, x, y):\r\n\t\treturn self.grid[y, x]",
"d... | [
"0.8084954",
"0.77093375",
"0.77048784",
"0.7591268",
"0.7481979",
"0.7413597",
"0.73946744",
"0.73341477",
"0.7084965",
"0.7082673",
"0.7018302",
"0.69711274",
"0.69217896",
"0.69217896",
"0.69217896",
"0.68702394",
"0.68702394",
"0.68702394",
"0.68702394",
"0.6868942",
"0.6... | 0.8512691 | 0 |
Attempts to make a random point in proximity of active_point. Attempts to make a random point around the active_point k times. If the new point is too close to another point, it will discard and try. If it fails k times, the function returns None. | def _make_point(self, active_point):
# --------------------------------
# Create Random Parameters
# --------------------------------
for _ in range(self._k):
# Defines radial distance from active_point.
rho = np.random.uniform(self._radius, 2 * self._radius)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_and_near(self):\n if self.prob and random.random() < self.prob:\n x_rand = self.goal_config\n else:\n x_rand = self.planning_env.sample_free()\n x_nearest_id, x_nearest = self.tree.GetNearestVertex(x_rand)\n x_new = self.steer(x_nearest, x_rand)\n # ... | [
"0.6129847",
"0.60467184",
"0.6017969",
"0.58782786",
"0.58636856",
"0.57718354",
"0.57574403",
"0.5638155",
"0.5605466",
"0.55763733",
"0.5571198",
"0.5554454",
"0.55425054",
"0.5489328",
"0.54884344",
"0.5414118",
"0.54004836",
"0.5398938",
"0.5387747",
"0.5385671",
"0.5385... | 0.72618705 | 0 |
Creates distance vectors for calculating all neighbors from a given point. A neighbor can be only so far away from the original point and is dependent on the number of dimensions. We calculate every possible coordinate on the grid that the neighbor can be part of relative to a point and store that information for later... | def _create_neighbor_distances(self):
# --------------------------------
# Create Directions from Point
# --------------------------------
diff = [[0 for _ in range(self._dim)]]
curr = diff[0][:]
for i in range(self._dim):
# Each diff is a unit vector, only ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def point_neighbors_recursion(self, point):\n # Sanity checks\n if point is None:\n raise ValueError(\"Cannot operate on None\")\n\n neighbors = []\n # 1-dimension\n if len(point) == 1:\n neighbors.append([point[0] - 1]) # left\n neighbors.append... | [
"0.65392166",
"0.6530853",
"0.64982176",
"0.647947",
"0.64395267",
"0.6422998",
"0.6371299",
"0.6254602",
"0.620574",
"0.61816",
"0.6145644",
"0.61213267",
"0.6018979",
"0.600562",
"0.5987179",
"0.59797674",
"0.5978277",
"0.5973462",
"0.5934688",
"0.5930248",
"0.5919666",
"... | 0.7678559 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.