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 |
|---|---|---|---|---|---|---|
Get the folder above a Rez package, assuming the path is to a built Rez package. The "packages path" of a Rez package is basically "The path that would be needed in order to make this package discoverable by the rezenv command". For example, a released package like "~/.rez/packages/int/foo/1.0.0" has a packages path li... | def get_packages_path_from_package(package):
root = finder.get_package_root(package)
if is_built_package(package):
package_name_folder = os.path.dirname(root)
return os.path.dirname(package_name_folder)
return os.path.dirname(root) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_package_path(path: Path) -> Optional[Path]:\n for package_path in path.iterdir():\n if is_package_dir(package_path):\n return package_path",
"def pypkgpath(self):\n pkgpath = None\n for parent in self.parts(reverse=True):\n if parent.isdir():\n ... | [
"0.71920997",
"0.6838155",
"0.6807825",
"0.68067145",
"0.6790578",
"0.6790578",
"0.67490464",
"0.67232215",
"0.65178114",
"0.651199",
"0.6466275",
"0.63531727",
"0.6334713",
"0.6315311",
"0.62793267",
"0.6258786",
"0.6246984",
"0.6219219",
"0.6211382",
"0.61962104",
"0.613559... | 0.7395061 | 0 |
Takes a statement string and a list of statement strings. Returns the closest matching statement from the list. | def get(self, input_statement):
statement_list = self.chatbot.storage.get_response_statements(input_statement.text)
print("from adapter: "+ str(len(statement_list)))
if not statement_list:
if self.chatbot.storage.count():
# Use a randomly picked statement
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closest(text, database):\n from fuzzywuzzy import process\n\n # Check if an exact match exists\n if database.find(text):\n return text\n\n # Get the closest matching statement from the database\n return process.extract(text, database.keys(), limit=1)[0][0]",
"def closest_match(\r\n r... | [
"0.6810408",
"0.59246445",
"0.5841984",
"0.535423",
"0.5303888",
"0.5230024",
"0.5214862",
"0.5204742",
"0.51656586",
"0.51357555",
"0.513496",
"0.5132792",
"0.50543165",
"0.5052505",
"0.50511724",
"0.5032725",
"0.50302774",
"0.50203186",
"0.4952436",
"0.49399436",
"0.4928132... | 0.6239972 | 1 |
Check that the chatbot's storage adapter is available to the logic adapter and there is at least ne statement in the database. | def can_process(self, statement):
return self.chatbot.storage.count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check(self):\n # validate contents still to do - for now just check if it exists\n return os.path.exists(self.getDefaultDatabaseConnectionParameter()['path'])",
"def check(self, connection):\n return True",
"def check_connection(self):\n pass",
"def is_available(**kwargs: Any)... | [
"0.5795223",
"0.5549578",
"0.5548149",
"0.55225635",
"0.545574",
"0.54191005",
"0.53849185",
"0.53732127",
"0.53596324",
"0.5316263",
"0.53120834",
"0.53007185",
"0.52840436",
"0.52822834",
"0.5219052",
"0.52115256",
"0.51778877",
"0.5175398",
"0.51726717",
"0.5141932",
"0.51... | 0.55863464 | 1 |
This function adds the task into the file todo.txt | def add():
try:
task = sys.argv[2]
file = open("todo.txt", "a")
file.write(task + "\n")
print('Added todo: "{}"'.format(task))
except IndexError:
print("Error: Missing todo string. Nothing added!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_task():\n\n yourTask = []\n line = input(\"Add your task: \")\n yourTask.append(line)\n taskfile = open('tasks.txt', 'a')\n for line in yourTask:\n taskfile.write(\"%s\\n\" % line)\n taskfile.close()\n\n import menu",
"def add_todo(taskname, deadline, priority, reminder, delet... | [
"0.7847216",
"0.7563006",
"0.74652207",
"0.7382538",
"0.7079825",
"0.6889404",
"0.6856803",
"0.68142754",
"0.6805257",
"0.67913866",
"0.67630345",
"0.6759012",
"0.6645988",
"0.6609657",
"0.66038746",
"0.6500612",
"0.64990604",
"0.6450098",
"0.6450098",
"0.6450098",
"0.6450098... | 0.85057044 | 0 |
This function reads the file from todo.txt and prints it onto the screen | def getTasks():
tasks = open("todo.txt").readlines()
if len(tasks):
for num in range(len(tasks) - 1, -1, -1):
print("[%d] %s" % (num + 1, tasks[num]), end="")
else:
print("There are no pending todos!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_todo_file(self):\n\n todo = []\n in_progress = []\n done = []\n if os.path.exists('TODO.txt'):\n todo_fp = open('TODO.txt', 'r')\n state = 0\n line = todo_fp.readline()\n while line:\n line = line.strip()\n ... | [
"0.729495",
"0.6513712",
"0.6332467",
"0.6318393",
"0.6303612",
"0.62567395",
"0.6108343",
"0.6103777",
"0.60373193",
"0.59762686",
"0.59441334",
"0.58947873",
"0.58890957",
"0.58715385",
"0.5841368",
"0.5791715",
"0.57458115",
"0.57139945",
"0.57078445",
"0.57034403",
"0.569... | 0.70918095 | 1 |
This function stikes off the task which is done and deletes it from todo.txt and adds it to done.txt. | def markOff(isdelete = 0):
try:
taskId = sys.argv[2]
tasks = open("todo.txt").readlines()
file = open("todo.txt", "w")
doneTasks = open("done.txt", "a")
flag = True
for task in range(len(tasks)):
if task + 1 == int(taskId):
flag = False
if isdelete == 1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finish_todo(self, todo):\n self.updated_items.append(todo._replace(done=True))\n print 'completed \"%s\"' % todo.text",
"def save_todo_file(self):\n\n if os.path.exists('TODO.txt'):\n os.remove('TODO.txt')\n todo_fp = open('TODO.txt', 'w')\n todo_items = self.tod... | [
"0.7079181",
"0.69074166",
"0.66847503",
"0.65578055",
"0.6467333",
"0.6457318",
"0.6359015",
"0.6349304",
"0.6338304",
"0.63093024",
"0.6263692",
"0.6259077",
"0.6224326",
"0.6205667",
"0.6193628",
"0.6182642",
"0.6131768",
"0.6124231",
"0.6107879",
"0.60152334",
"0.5980346"... | 0.75782037 | 0 |
This function need is similar to markOff function so calls it by passing isdelete = 1 as argument. | def deleteTask():
markOff(isdelete = 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markOff(isdelete = 0):\n\ttry:\n\t taskId = sys.argv[2]\n\t tasks = open(\"todo.txt\").readlines()\n\t file = open(\"todo.txt\", \"w\")\n\t doneTasks = open(\"done.txt\", \"a\")\n\t flag = True\n\t for task in range(len(tasks)):\n\t if task + 1 == int(taskId):\n\t \tflag = False... | [
"0.6381452",
"0.63253415",
"0.6070844",
"0.6049239",
"0.60067105",
"0.59252304",
"0.5890134",
"0.58599454",
"0.58161026",
"0.5758552",
"0.5754594",
"0.5730884",
"0.5698445",
"0.56965846",
"0.5640858",
"0.5552903",
"0.5552888",
"0.5528425",
"0.5517398",
"0.54960984",
"0.545108... | 0.6508327 | 0 |
This is used by the main method to change the smoothing parameter before training. Do not modify this method. | def setSmoothing(self, k):
self.k = k | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setSmoothing(self, k):\n\tself.k = k",
"def setSmoothing(self, k):\n self.k = k",
"def __init__(self, smoothing=0.1):\n super(LabelSmoothing, self).__init__()\n self.confidence = 1.0 - smoothing\n self.smoothing = smoothing",
"def __init__(self, smoothing=0.0):\n super(... | [
"0.7056522",
"0.66494966",
"0.6458589",
"0.6430003",
"0.6430003",
"0.63708806",
"0.63073367",
"0.614149",
"0.61360747",
"0.6081798",
"0.605832",
"0.595308",
"0.58814126",
"0.5877647",
"0.5857185",
"0.58429444",
"0.5836974",
"0.5836974",
"0.5832468",
"0.5815381",
"0.5812071",
... | 0.7078726 | 0 |
Returns the logjoint distribution over legal labels and the datum. Each logprobability should be stored in the logjoint counter, e.g. logJoint[3] = To get the list of all possible features or labels, use self.features and self.legalLabels. | def calculateLogJointProbabilities(self, datum):
logJoint = util.Counter()
"*** YOUR CODE HERE ***"
#Adds log(P(y)) to calculate P(y|f1,f2...)
for label in self.legalLabels:
logJoint[label] += math.log(self.prior[label])
#Adds log(P(f1|y)), log(P(f2|y))... to calculate P(y|f1, f2...)
for key in datu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateLogJointProbabilities(self, datum):\n\tlogJoint = util.Counter()\n\t#want to calculate log(P(y)) + log(sum(P(fi|y)))\n\t#where y is a label\n\tfor label in self.legalLabels:\n\t\tlogJoint[label] = math.log(self.prior_distribution_prob[label])\n\t\tfor feature, value in datum.items():\n\t\t\tcp = self.... | [
"0.7670301",
"0.7324698",
"0.72858876",
"0.70940316",
"0.66565716",
"0.63166475",
"0.62618005",
"0.61345506",
"0.60189897",
"0.59206444",
"0.58990693",
"0.5837745",
"0.5819782",
"0.58036715",
"0.5777778",
"0.5769963",
"0.573551",
"0.5727573",
"0.5705319",
"0.5704481",
"0.5689... | 0.743221 | 1 |
Extract phrases from CSV and tokenize files. Add duplicate phrases only once. | def extract_phrases(phrase_dict, csv_reader, word_list):
count_row = 0
for row in csv_reader:
phrase = row[3]
count_row += 1
if phrase not in all_phrases:
tokens = tokenizer(phrase)
tokens = list(tokens)
phrase_dict[phrase] = tokens
for t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_process(keyphrases):\n processed_keyphrases = []\n\n # Remove duplicates from the single phrases which are occurring in multi-keyphrases\n multi_phrases = [phrases for phrases in keyphrases if len(phrases[0].split()) > 1]\n single_phrase = [phrases for phrases in keyphrases if ... | [
"0.6272862",
"0.6200871",
"0.5733688",
"0.5680239",
"0.5663839",
"0.563407",
"0.56105554",
"0.5597843",
"0.5545445",
"0.55262184",
"0.55032367",
"0.5449279",
"0.54271376",
"0.53965634",
"0.5390097",
"0.5350434",
"0.533897",
"0.5293532",
"0.5286479",
"0.527831",
"0.5262325",
... | 0.75166154 | 0 |
Moves up to the parent directory | def moveUp():
os.chdir("..") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_to_parent(self, path):\n if path == self.dir_to_check:\n print (' Parent directory out of scope!')\n return path\n else:\n dir_name = os.path.dirname(path)\n return dir_name",
"def _goUp(self) -> None:\n self._openPath(path=self._curr... | [
"0.73682714",
"0.72242",
"0.68628967",
"0.6374753",
"0.62987864",
"0.6281617",
"0.6231118",
"0.6118306",
"0.60952276",
"0.607766",
"0.5977025",
"0.59579486",
"0.59060633",
"0.5898593",
"0.5897268",
"0.58351576",
"0.58234763",
"0.58182573",
"0.57882106",
"0.5750799",
"0.574291... | 0.82439893 | 0 |
Returns the number of files in the cwd and all it's subdirectories | def countFiles(path):
count = 0
lyst = os.listdir(path)
for element in lyst:
if os.path.isfile(element):
count += 1
else:
os.chdir(element)
count += countFiles(os.getcwd())
os.chdir("..")
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_dir(self):\n self.assert_is_dir_and_exists()\n n = 0\n for _ in self.select_dir(recursive=True):\n n += 1\n return n",
"def n_subdir(self):\n self.assert_is_dir_and_exists()\n n = 0\n for _ in self.select_dir(recursive=False):\n n += 1\... | [
"0.7911948",
"0.7740002",
"0.7673589",
"0.75395423",
"0.75390685",
"0.7531299",
"0.7515497",
"0.7512118",
"0.7510764",
"0.75033957",
"0.7492738",
"0.7461917",
"0.7286391",
"0.7270033",
"0.72661525",
"0.71882087",
"0.71850646",
"0.71713626",
"0.7166277",
"0.7139466",
"0.697956... | 0.7854723 | 1 |
Returns the number of bytes in the cwd and all its subdirectories | def countBytes(path):
count = 0
lyst = os.listdir(path)
for element in lyst:
if os.path.isfile(element):
count += os.path.getsize(element)
else:
os.chdir(element)
count += countBytes(os.getcwd())
os.chdir("..")
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dirsize(self):\n total = 0\n for p in self.select_file(recursive=True):\n try:\n total += p.size\n except: # pragma: no cover\n print(\"Unable to get file size of: %s\" % p)\n return total",
"def n_dir(self):\n self.assert_is_di... | [
"0.7495459",
"0.7329888",
"0.73292416",
"0.72654724",
"0.7200473",
"0.7190872",
"0.71110535",
"0.7103087",
"0.70675343",
"0.6952663",
"0.69456893",
"0.6905677",
"0.6905677",
"0.68528646",
"0.6847595",
"0.6846488",
"0.6838742",
"0.6820271",
"0.6784078",
"0.67830443",
"0.675469... | 0.79827064 | 0 |
Returns a list of the filenames that contain the target string in the cwd and all its subdirectories | def findFiles(target, path):
files = []
lyst = os.listdir(path)
for element in lyst:
if os.path.isfile(element):
if target in element:
files.append(path + os.sep + element)
else:
os.chdir(element)
files.extend(findFiles(target, os.getcwd()))
os.chdir("..")
return files | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locate(root = '.', target = 'info'):\n \n matches = []\n \n for root, dirnames, filenames in os.walk(root):\n for dirnames in fnmatch.filter(dirnames, target):\n matches.append(os.path.join(root, dirnames))\n \n return matches",
"def recursive_search(path, target_files):\n... | [
"0.78893167",
"0.70711875",
"0.6743324",
"0.67228645",
"0.67215157",
"0.67116743",
"0.6680939",
"0.66105115",
"0.6609947",
"0.6597764",
"0.6591357",
"0.65083253",
"0.6409782",
"0.6372986",
"0.6369613",
"0.6341358",
"0.6335286",
"0.6334085",
"0.63313586",
"0.6330451",
"0.63302... | 0.74844456 | 1 |
Creates samples from full dataframe using indices and n rows before. Returns a list of [joined texts from n rows before, current sentence]. | def create_sample(df: pd.DataFrame, indices: list, n: int = 2) -> list:
samples = []
for idx in indices:
if idx <= n:
continue
samples.append([
' '.join(df.loc[idx - n:idx - 1, 'article'].to_list()),
df.loc[idx, 'article']
])
return samp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_sample(index_sentences, context_window_size=3):\n for index_sentence in index_sentences:\n for i, center in enumerate(index_sentence):\n for target in index_sentence[max(0, i - context_window_size): i]:\n yield center, target\n for target in index_sentenc... | [
"0.6704123",
"0.62329084",
"0.59288085",
"0.5916634",
"0.59048307",
"0.57954526",
"0.5702059",
"0.5699596",
"0.55778795",
"0.5568846",
"0.5542461",
"0.5522564",
"0.54517615",
"0.54517615",
"0.5437269",
"0.54162866",
"0.53923947",
"0.537376",
"0.5371694",
"0.5367503",
"0.53566... | 0.7631288 | 0 |
Whether nonNone DB settings are set on this instance. | def db_settings_set(self) -> bool:
return self._db_settings is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_settings(self) -> DBSettings:\n if self._db_settings is None:\n raise ValueError(\"No DB settings are set on this instance.\")\n return not_none(self._db_settings)",
"def has_configuration_set():\r\n return getattr(settings, \"MICROSITE_CONFIGURATION\", False)",
"def in_smart... | [
"0.8010844",
"0.6257641",
"0.61342895",
"0.6113809",
"0.6091597",
"0.60814935",
"0.6062348",
"0.60489297",
"0.6039835",
"0.60359865",
"0.5959397",
"0.5921009",
"0.5916373",
"0.5904241",
"0.5895474",
"0.5873816",
"0.5869111",
"0.5860813",
"0.58566284",
"0.5839428",
"0.58338577... | 0.86004394 | 0 |
DB settings set on this instance; guaranteed to be nonNone. | def db_settings(self) -> DBSettings:
if self._db_settings is None:
raise ValueError("No DB settings are set on this instance.")
return not_none(self._db_settings) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_settings_set(self) -> bool:\n return self._db_settings is not None",
"def get_settings():\n return db.get_data()",
"def config_db():",
"def persistent_store_settings(self):\n ps_settings = (\n PersistentStoreDatabaseSetting(\n name='tethys_super',\n ... | [
"0.75341564",
"0.6995988",
"0.67702115",
"0.66987073",
"0.66237766",
"0.6407037",
"0.63871783",
"0.6344887",
"0.6317197",
"0.6317197",
"0.6270409",
"0.62143266",
"0.62112087",
"0.61947787",
"0.6192052",
"0.6192052",
"0.618446",
"0.6180994",
"0.6140911",
"0.60939735",
"0.60773... | 0.8153518 | 0 |
Loads experiment and its corresponding generation strategy from database if DB settings are set on this `WithDBSettingsBase` instance. | def _load_experiment_and_generation_strategy(
self, experiment_name: str
) -> Tuple[Optional[Experiment], Optional[GenerationStrategy]]:
if not self.db_settings_set:
raise ValueError("Cannot load from DB in absence of DB settings.")
try:
return load_experiment_and_gen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_generation_strategy_by_experiment_name(\n experiment_name: str,\n decoder: Decoder,\n experiment: Optional[Experiment] = None,\n reduced_state: bool = False,\n) -> GenerationStrategy:\n gs_id = _get_generation_strategy_id(\n experiment_name=experiment_name, decoder=decoder\n )\n ... | [
"0.606756",
"0.59268576",
"0.5774875",
"0.56967384",
"0.56148547",
"0.560851",
"0.55462694",
"0.5474125",
"0.54704547",
"0.5441102",
"0.5435659",
"0.5381648",
"0.5344024",
"0.52874494",
"0.52411336",
"0.52409303",
"0.5229423",
"0.52244365",
"0.5214454",
"0.51805246",
"0.51445... | 0.75344306 | 0 |
Saves attached experiment and generation strategy if DB settings are set on this `WithDBSettingsBase` instance. | def _save_experiment_to_db_if_possible(
self, experiment: Experiment, suppress_all_errors: bool = False
) -> bool:
if self.db_settings_set:
save_experiment(experiment=experiment, db_settings=self.db_settings)
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _saveExperiment(self, experiment, path):\n Experiment.save(experiment, path);",
"def save_db(self) -> None:",
"def _save_generation_strategy_to_db_if_possible(\n self, generation_strategy: GenerationStrategy, suppress_all_errors: bool = False\n ) -> bool:\n if self.db_settings_set:\... | [
"0.63763595",
"0.6320159",
"0.6281932",
"0.6186798",
"0.61095285",
"0.6107234",
"0.6069167",
"0.6063899",
"0.5993819",
"0.59579563",
"0.59279996",
"0.5842179",
"0.5783171",
"0.5780858",
"0.5776538",
"0.57733697",
"0.5734225",
"0.5729373",
"0.5707211",
"0.569653",
"0.566799",
... | 0.6830284 | 0 |
Saves given trial and generation strategy if DB settings are set on this `WithDBSettingsBase` instance. | def _save_new_trial_to_db_if_possible(
self,
experiment: Experiment,
trial: BaseTrial,
suppress_all_errors: bool = False,
) -> bool:
if self.db_settings_set:
save_new_trial(
experiment=experiment, trial=trial, db_settings=self.db_settings
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _save_generation_strategy_to_db_if_possible(\n self, generation_strategy: GenerationStrategy, suppress_all_errors: bool = False\n ) -> bool:\n if self.db_settings_set:\n save_generation_strategy(\n generation_strategy=generation_strategy, db_settings=self.db_settings\... | [
"0.67361945",
"0.643106",
"0.6275285",
"0.5926923",
"0.57212836",
"0.55074066",
"0.5471723",
"0.538028",
"0.5350232",
"0.5327738",
"0.5318719",
"0.53136206",
"0.5307854",
"0.5285224",
"0.52835673",
"0.52670777",
"0.526356",
"0.5198457",
"0.51904655",
"0.51861244",
"0.518299",... | 0.6784477 | 0 |
register a tag with name txt and with given foreground and background color | def register_tag(self, txt, foreground, background):
# self.tag_config(txt, foreground=foreground, background=background)
self.known_tags.add(txt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addColoredText(self, st, tag, word, fg='black', bg='white'):\n word = word + \" \"\n st.insert('end', word)\n end_index = st.index('end')\n begin_index = \"%s-%sc\" % (end_index, len(word) + 1)\n st.tag_add(tag, begin_index, end_index)\n st.tag_config(tag, foreground=f... | [
"0.67343915",
"0.61832774",
"0.61168456",
"0.60767376",
"0.6007534",
"0.59904003",
"0.5987998",
"0.59658444",
"0.5829146",
"0.5719596",
"0.566779",
"0.5584578",
"0.55843204",
"0.5502387",
"0.5499931",
"0.5490123",
"0.5455171",
"0.5431202",
"0.5430979",
"0.5413367",
"0.5404569... | 0.81564075 | 0 |
Works like builtin 2argument `iter()`, but stops on `exception`. | def iter_except(function, exception):
try:
while True:
yield function()
except exception:
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_except(func, exception):\n try:\n while True:\n yield func()\n except exception:\n pass",
"def iter_except(function, exception):\n try:\n while True:\n yield function()\n except exception:\n return",
"def iter_except(func, exception, first=... | [
"0.7831509",
"0.7759882",
"0.7430991",
"0.7154455",
"0.7069062",
"0.69544894",
"0.68920565",
"0.66940206",
"0.6611821",
"0.6493385",
"0.63608396",
"0.62707305",
"0.62085617",
"0.6189817",
"0.61666644",
"0.61463356",
"0.61463356",
"0.61463356",
"0.61463356",
"0.60950685",
"0.6... | 0.77927095 | 1 |
Read subprocess output and put it into the queue. | def reader_thread(self, q):
try:
with self.process.stdout as pipe:
for line in iter(pipe.readline, b''):
q.put(line)
finally:
q.put(None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _stdout_reader(self):\n self._is_launched.wait()\n stdout_iterator = iter(self._popen.stdout.readline, b\"\")\n for line in stdout_iterator:\n self._log(\"raw\", \"stdout : {0}\".format(line.strip()))\n self.stdout_queue.put_nowait(line.strip())\n self.stdout_q... | [
"0.7643372",
"0.70199263",
"0.6941756",
"0.6892083",
"0.68583477",
"0.667833",
"0.65482545",
"0.65377265",
"0.6516418",
"0.6509647",
"0.6480462",
"0.6398246",
"0.6274676",
"0.62624496",
"0.6258729",
"0.62502366",
"0.62449336",
"0.6241449",
"0.62395567",
"0.62352574",
"0.62204... | 0.7216844 | 1 |
Update GUI with items from the queue. | def update(self, q):
for line in iter_except(q.get_nowait, Empty): # display all content
if line is None:
self.process.kill()
self.process = None
return
else:
result = str(line).replace('\\r', '\r').replace('\\\\', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gui_process(self):\n ti = self.scan_queue.qsize()\n t = TqdmUpTo(total=self.scan_queue.qsize(), unit='Files')\n\n while True:\n try:\n t.update(ti - self.scan_queue.qsize())\n ti = self.scan_queue.qsize()\n if self.message_queue.__len... | [
"0.6706958",
"0.6474775",
"0.63087624",
"0.62826693",
"0.6243645",
"0.62302905",
"0.6202968",
"0.61998534",
"0.612823",
"0.6117151",
"0.611539",
"0.6067368",
"0.606616",
"0.60095227",
"0.5993423",
"0.59805995",
"0.5947106",
"0.5916233",
"0.5896627",
"0.5875889",
"0.58683205",... | 0.6962187 | 0 |
Update the adjusted data for a Band that has already been added using add_plot | def set_adjusted_data(self, data:HistogramPlotData, band:Band):
plots:AdjustableHistogramControl = self.__plots[band]
if plots is not None:
plots.set_adjusted_data(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_plot(self, raw_data:HistogramPlotData, adjusted_data:HistogramPlotData, band:Band):\n plots = AdjustableHistogramControl(band)\n plots.set_raw_data(raw_data)\n plots.set_adjusted_data(adjusted_data)\n plots.limit_changed.connect(self.limit_changed)\n plots.limits_reset.co... | [
"0.68253666",
"0.67685705",
"0.6681961",
"0.64841163",
"0.64281446",
"0.6168467",
"0.6168467",
"0.6168467",
"0.6168467",
"0.6168467",
"0.6162655",
"0.61557037",
"0.61169",
"0.61146575",
"0.6005888",
"0.5998489",
"0.5994703",
"0.5939009",
"0.5906529",
"0.5905252",
"0.58663887"... | 0.70409757 | 0 |
Returns the derivative of output_name with respect to wrt. | def get_derivative(self, output_name, wrt):
return self.gradient[wrt][output_name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_2nd_derivative(self, output_name, wrt):\n \n return self.hessian[wrt[0]][wrt[1]][output_name]",
"def find_derivative(name: str):\n return _derivatives[name]",
"def _derivative_(self, x, diff_param=None):\n return 2*exp(-x**2)/sqrt(pi)",
"def get_gradient(self, output_name=None... | [
"0.794627",
"0.6320714",
"0.6095984",
"0.60070467",
"0.5971002",
"0.5934078",
"0.58912855",
"0.57599115",
"0.5751379",
"0.57422125",
"0.5739002",
"0.57238007",
"0.5716149",
"0.5715266",
"0.5707183",
"0.56966895",
"0.56966895",
"0.56966895",
"0.56966895",
"0.56952906",
"0.5676... | 0.8644599 | 0 |
Returns the 2nd derivative of output_name with respect to both vars in the tuple wrt. | def get_2nd_derivative(self, output_name, wrt):
return self.hessian[wrt[0]][wrt[1]][output_name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_derivative(self, output_name, wrt):\n \n return self.gradient[wrt][output_name]",
"def _numerical_derivative_two_sided (func:typing.Callable[[float],float], x_0:float) -> typing.Tuple[float,float]:\n epsilon = 1.0e-9\n func_x_0 = func(x_0)\n deriv_neg = (func_x_0 - func(x_0-epsilon... | [
"0.7327428",
"0.62851566",
"0.6239669",
"0.622021",
"0.61582315",
"0.610452",
"0.609245",
"0.6030133",
"0.6005503",
"0.600335",
"0.59997815",
"0.594842",
"0.5872099",
"0.58583814",
"0.583254",
"0.5830568",
"0.5830568",
"0.58183813",
"0.58112955",
"0.58069754",
"0.5799643",
... | 0.7861094 | 0 |
Returns the gradient of the given output with respect to all parameters. | def get_gradient(self, output_name=None):
return array([self.gradient[wrt][output_name] for wrt in self.param_names]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradient(self, node, output_grad):\r\n return [auto_sum_op(output_grad, get_shape_op(node.inputs[0]) ), 0-auto_sum_op(output_grad, get_shape_op(node.inputs[1]) )]\r\n #return [auto_sum_op(output_grad, ), 0-output_grad]\r",
"def gradient(self, node, output_grad):\n return [output_grad]",
... | [
"0.76306516",
"0.76022816",
"0.75950354",
"0.75950354",
"0.757593",
"0.7486398",
"0.7485103",
"0.747612",
"0.7423461",
"0.741599",
"0.73761606",
"0.73707384",
"0.7339724",
"0.73261887",
"0.73257333",
"0.7322427",
"0.73202705",
"0.7306291",
"0.7302661",
"0.7257447",
"0.7244565... | 0.77606237 | 0 |
Returns the Hessian matrix of the given output with respect to all parameters. | def get_Hessian(self, output_name=None):
#return array([self.hessian[in1][in2][output_name] for (in1,in2) in product(self.param_names, self.param_names)])
return array([self.hessian[in1][in2][output_name] for (in1,in2) in product(self.param_names, self.param_names)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_hessian(self):\n return self.tc.hessian_func(\n self.pf.XS[:, :, 0].transpose(),\n self.pf.XS[:, :, 1].transpose(),\n self.pf.WS[:].transpose())",
"def _get_hessian(self):\n if not self.sparse:\n hess = numpy.dot(self.jacobian_T, self.jacobian)\n ... | [
"0.7668539",
"0.7445004",
"0.72262585",
"0.71646506",
"0.7061997",
"0.7034577",
"0.6910204",
"0.67564386",
"0.67285246",
"0.6721224",
"0.6684816",
"0.66643095",
"0.6623788",
"0.66084576",
"0.6566024",
"0.65476125",
"0.6538235",
"0.6438131",
"0.64299875",
"0.6404051",
"0.63860... | 0.7849769 | 0 |
In a navigation context, component of an equipment is a point (tag/entity) | def __getitem__(self,key):
# Using [key] syntax on an equipment allows to retrieve a tag directly
# or a point referred to this particular equipment
for each in self.tags:
if key == each:
return self.tags[key]
# if key not found in tags... we probably are sear... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_equipment(self, equipment):",
"def handle_equipment_mouseover(self):\n if self.skill_tree_displaying:\n return\n mouse_pos = pg.mouse.get_pos()\n slot_moused_over = ''\n for slot in self.equipment_tiles:\n if self.equipment_tiles[slot].collidepoint(mous... | [
"0.6163354",
"0.54555136",
"0.5393153",
"0.5236375",
"0.523499",
"0.51858884",
"0.49860734",
"0.48600116",
"0.4857848",
"0.48537073",
"0.485229",
"0.48440015",
"0.48133153",
"0.47727907",
"0.47712675",
"0.47643167",
"0.47142008",
"0.4710021",
"0.46757096",
"0.4671051",
"0.466... | 0.5729084 | 1 |
When iterating over an equipment, we iterate points. | def __iter__(self):
for point in self.points:
yield point | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n pt = (self.x, self.y)\n for i in pt:\n yield i",
"def __iter__(self):\n return self.points.__iter__()",
"def points(self):\n try:\n return self._list_of_points\n except AttributeError:\n print('Reading points for this equ... | [
"0.6738365",
"0.67296696",
"0.65510035",
"0.6479246",
"0.6224848",
"0.6224676",
"0.6217917",
"0.6125468",
"0.61245775",
"0.6047802",
"0.6040413",
"0.60280716",
"0.5998997",
"0.58142966",
"0.5806075",
"0.5755057",
"0.5699067",
"0.56640595",
"0.56099945",
"0.55949754",
"0.55883... | 0.68680793 | 0 |
Retrieve an instance of the equip this entity is linked to. | def get_equip(self, callback=None):
return self._session.get_entity(self.tags['equipRef'],
callback=callback, single=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_equipment(self):\r\n eq = self._pvsr.getEquipmentByName(self._meas[\"equipment\"])\r\n if eq is None:\r\n site = self._pvsr.getSiteByName(self._default_site)\r\n if site is None:\r\n logging.info(\"Creating new default site {0}\".format(self._default_site... | [
"0.6793719",
"0.6646895",
"0.6620147",
"0.61004996",
"0.60058075",
"0.5998487",
"0.5941672",
"0.58856815",
"0.58801144",
"0.5800163",
"0.57987654",
"0.5727742",
"0.568204",
"0.5605969",
"0.55737144",
"0.5561501",
"0.5561501",
"0.5561501",
"0.55327797",
"0.55324954",
"0.552213... | 0.7817165 | 0 |
Get the value of the indexth node in the linked list. If the index is invalid, return 1. | def get(self, index: int) -> int:
node = self.get_node(index)
if node:
return node.val
else:
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, index: int) -> int:\n cnt = 0\n cur = self.head \n while cur != None:\n if(cnt == index):\n return cur.val\n cur = cur.next \n cnt += 1\n return -1",
"def get(self, index):\n cur = self.head\n while cur and in... | [
"0.82228374",
"0.810132",
"0.798225",
"0.797223",
"0.7966857",
"0.7952263",
"0.7949584",
"0.7928148",
"0.79057187",
"0.78002805",
"0.7736932",
"0.77319723",
"0.7650963",
"0.75840414",
"0.7507434",
"0.74747777",
"0.7453931",
"0.7387386",
"0.7387386",
"0.7384746",
"0.73363584",... | 0.83084565 | 0 |
From self ordered list of steps return theirs objects. | def get_steps(self) -> list:
ret_val = []
for step_id in self:
step_body = Steps.cache_step(step_id)
if step_body is not None:
ret_val.append(step_body)
return ret_val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def steps(self):\n for step in self._get_paged(\"steps\", trailing=True):\n yield self.__get_object(step)\n\n return",
"def getSteps():",
"def steps(self):\n for step in self._steps:\n yield step",
"def get_next_steps(self, steps):\n step_list = []\n\n ... | [
"0.7150398",
"0.6517314",
"0.65121204",
"0.65073574",
"0.6322349",
"0.6313758",
"0.62665945",
"0.61052346",
"0.60600114",
"0.5968533",
"0.59455675",
"0.5905528",
"0.5889132",
"0.5881727",
"0.58811265",
"0.5878531",
"0.58683777",
"0.58374953",
"0.58098865",
"0.5809102",
"0.579... | 0.6559559 | 1 |
Create sorted list of steps bound to case in rising order. | def sort_case_steps(self, request):
self.clear()
# todo error with repeated step_id. use record id somehow
for row in range(len(request)):
data_step = request[row]
prev_step_id = str(data_step.get(CaseSteps.PREVIOUS_STEP_ID, 0))
step_id = str(data_step.get(C... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_steps(self) -> List[Coordinate]:\n if self.orientation == Orientation.HORIZONTAL:\n fill = self.start.y\n else:\n fill = self.start.x\n\n if self.end.x < self.start.x:\n x_range = range(self.start.x, self.end.x - 1, -1)\n else:\n x_r... | [
"0.60645884",
"0.5842618",
"0.5752251",
"0.5727292",
"0.57264835",
"0.5698114",
"0.5696493",
"0.5655299",
"0.5610366",
"0.54864746",
"0.54621786",
"0.5460923",
"0.5425928",
"0.5359517",
"0.5358369",
"0.5346567",
"0.5337107",
"0.5318492",
"0.5314977",
"0.5291446",
"0.52641326"... | 0.59152174 | 1 |
Open meeting's calendar view to schedule a meeting on current phonecall. | def action_make_meeting(self):
partner_ids = [
self.env['res.users'].browse(self.env.uid).partner_id.id]
res = {}
for phonecall in self:
if phonecall.partner_id and phonecall.partner_id.email:
partner_ids.append(phonecall.partner_id.id)
res = s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_mwindow_agenda(self) -> None:\n self.mwindow_agenda.show()",
"def meeting(request, meeting_id):\n meeting = get_object_or_404(Meeting, pk=meeting_id)\n context = {'meeting': meeting}\n return render(request, 'sacms/meeting.html', context)",
"def edit_meeting_schedule(request, num=None,... | [
"0.64469135",
"0.60219747",
"0.5896503",
"0.5800959",
"0.5769794",
"0.57033247",
"0.56608593",
"0.5613643",
"0.5602575",
"0.55102795",
"0.55021197",
"0.5475948",
"0.5472367",
"0.54602873",
"0.5457448",
"0.5443587",
"0.54143536",
"0.53765154",
"0.53514504",
"0.53112346",
"0.52... | 0.6283702 | 1 |
Plots a confusion matrix of the model predictions to evaluate accuracy | def plot_confusion_matrix(self):
interp = ClassificationInterpretation.from_learner(self.learn)
interp.plot_confusion_matrix() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(name, trained_predictor, X_test, y_test):\n\n fig, ax = plt.subplots()\n fig.tight_layout()\n cm = confusion_matrix(y_test, trained_predictor.predict(X_test), normalize=\"all\")\n ConfusionMatrixDisplay(cm, display_labels=[\"False\", \"True\"]).plot(\n ax=ax\n )\n ... | [
"0.7954949",
"0.79269266",
"0.7894503",
"0.7827766",
"0.78108096",
"0.7801344",
"0.7790977",
"0.77880204",
"0.7729956",
"0.7723762",
"0.77151185",
"0.76916933",
"0.76525074",
"0.7649402",
"0.7639235",
"0.7628763",
"0.75990075",
"0.7597474",
"0.7595721",
"0.7591373",
"0.758781... | 0.8134829 | 0 |
Classifies the labeled tiles and updates the feature layer with the prediction results with column output_label_field. ==================================== ==================================================================== Argument Description feature_layer Required. Feature Layer for classification. labeled_tiles_di... | def classify_features(self, feature_layer, labeled_tiles_directory, input_label_field, output_label_field, confidence_field=None):
ALLOWED_FILE_FORMATS = ['tif', 'jpg', 'png']
IMAGES_FOLDER = 'images/'
LABELS_FOLDER = 'labels/'
files = []
for ext in ALLOWED_FILE_FORMAT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_labels(filename, num_images, starting_id, context_factor):\n gt_imgs = []\n for i in range(starting_id, num_images+starting_id):\n imageid = \"satImage_%.3d\" % i\n image_filename = filename + imageid + \".png\"\n if os.path.isfile(image_filename):\n print ('Loadin... | [
"0.5979642",
"0.56935304",
"0.56794995",
"0.563562",
"0.56328654",
"0.56254506",
"0.56227946",
"0.5580164",
"0.5480045",
"0.54260916",
"0.53929067",
"0.537351",
"0.5349937",
"0.5343901",
"0.5273858",
"0.5248865",
"0.523017",
"0.5227214",
"0.52092975",
"0.5198775",
"0.517194",... | 0.8608024 | 0 |
Testing when ideal file with different numbers in input and file with equal numbers | def test_ideal_file_and_file_with_zeros(file_name, result):
assert find_maximum_and_minimum(file_name) == result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fail_check(version, num):\n f1 = open(\"replace/outputs/t\" + str(num), 'r')\n f2 = open(\"replace/outputs/v\" + str(version) + \"/t\" + str(num), 'r')\n ret = f1.readlines() != f2.readlines()\n f1.close()\n f2.close()\n return ret",
"def test_big_file_inversions_num():\n\n with open('te... | [
"0.6338274",
"0.630728",
"0.62845033",
"0.62252957",
"0.61770785",
"0.6109089",
"0.605709",
"0.5963395",
"0.58854437",
"0.58828866",
"0.5870365",
"0.58685476",
"0.5863105",
"0.58447826",
"0.5840695",
"0.5825992",
"0.5807981",
"0.57987446",
"0.5746747",
"0.5708142",
"0.5661347... | 0.65065473 | 0 |
Add app messages to context. | def messages(request):
ctx = {}
messages = get_messages(request)
if messages:
ctx['mesgs'] = messages
return ctx | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_app(self):\n \n pass",
"def get_app_message(self):\n return self.messages[\"app\"].get()",
"def init_app(self, app):\n\n if not hasattr(app, 'extensions'):\n app.extensions = {}\n app.extensions['mixconn'] = self\n app.context_processor(lambda: {'mix... | [
"0.6293802",
"0.59380424",
"0.5907387",
"0.5889862",
"0.5763125",
"0.5606945",
"0.56038916",
"0.5568187",
"0.556246",
"0.55386215",
"0.55042225",
"0.54550314",
"0.54425555",
"0.5426857",
"0.54005486",
"0.53776485",
"0.5357521",
"0.5357521",
"0.5357521",
"0.53525347",
"0.53438... | 0.6333382 | 0 |
Combines Excel spreadsheets of quality control data into a single file called a pickle file. This file is unique to Python, and it is very fast to load once created. This function expects a path to a folder of raw data containing .xlsx files. For example, the path | def pickle_data(path=PATH_TO_RAW_DATA):
files = os.listdir(path)
xlsx_files = [path+"./"+f for f in files if f[-4:] == 'xlsx']
print("Beginning to read excel sheets...will take a few minutes")
df_list = [pd.read_excel(f) for f in xlsx_files]
master_df = pd.concat(df_list)
master_df.t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_workbook(path):\n wb = openpyxl.load_workbook(path, read_only=True)\n return wb",
"def save(self):\n\n date = datetime.utcnow().strftime(\"%Y-%m-%d\")\n directory = '%s/xls/%s/' % (PROJECT_DIR, date)\n _file = directory + '/' + self.xls.name\n if not os.path.exists(direc... | [
"0.5912495",
"0.59047276",
"0.58891195",
"0.5707316",
"0.56871253",
"0.5675712",
"0.567314",
"0.5660493",
"0.5642101",
"0.55804497",
"0.55674464",
"0.5544291",
"0.55422443",
"0.55234957",
"0.550397",
"0.54869187",
"0.54769266",
"0.5476461",
"0.5475492",
"0.5408885",
"0.540109... | 0.7810054 | 0 |
Checks rotation matrix for d = 2. | def test_d_2():
rs = 10
d = 2
np.random.seed(rs)
num = 3
theta = np.random.uniform(0, 2 * math.pi)
rotation = np.identity(d)
rotation[0, 0] = math.cos(theta)
rotation[0, 1] = - math.sin(theta)
rotation[1, 0] = math.sin(theta)
rotation[1, 1] = math.cos(theta)
np.random.seed(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_rotation_matrix(self, R):\n Rt = np.transpose(R)\n shouldBeIdentity = np.dot(Rt, R)\n I = np.identity(3, dtype=R.dtype)\n n = np.linalg.norm(I - shouldBeIdentity)\n return n < 1e-6",
"def isRotationMatrix(self, R):\n Rt = np.transpose(R)\n shouldBeIdentity... | [
"0.61965746",
"0.6008818",
"0.5870018",
"0.57924783",
"0.566713",
"0.5649514",
"0.5516805",
"0.543337",
"0.5430252",
"0.5384225",
"0.5358685",
"0.53534156",
"0.53217334",
"0.5318572",
"0.53076136",
"0.5304661",
"0.5281336",
"0.5250107",
"0.5246997",
"0.5241706",
"0.52340746",... | 0.7322308 | 0 |
The decorator for the tag class | def decorator(tag_class):
name = tag_class.__name__
if name.startswith('Tag'):
name = name[3:]
# keep all-uppercase names, they are special tags
# like LITERAL, COMMENT, OUTPUT
if not name.isupper():
name = name.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag(cls):\n pass",
"def register(self, tag_class_or_alias=None, mode='standard'):\n # type: (Union[Type[Tag], str], bool) -> Callable\n # if mode == 'jekyll':\n # from .jekyll.tags import tag_manager as tmgr\n # return tmgr.register(tag_class_or_alias)\n if m... | [
"0.70298386",
"0.67040557",
"0.6418024",
"0.64037263",
"0.6252756",
"0.6243304",
"0.6243304",
"0.6243304",
"0.61472267",
"0.5950456",
"0.59204096",
"0.58158684",
"0.57951266",
"0.5689228",
"0.5688503",
"0.5664444",
"0.5627366",
"0.5609594",
"0.560396",
"0.56025034",
"0.559540... | 0.78976655 | 0 |
given some date like MONTH/DAY/YEAR, make a filename like base_path/YEAR/MONTH/DAY.md | def date_to_filename(base_path, raw_date_string):
raw_date_string = raw_date_string[:-1]
month, day, year = raw_date_string.split("/")
relative_path = "{}/{}/{}.md".format(year, month, day)
return base_path / relative_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_filename_from_date(path,date,autoincrement = True):\n \n fname = date.isoformat().replace(':','.')\n \n if autoincrement:\n\n onlyfiles = [f for f in listdir(path) if isfile(join(path, f)) and f!='.DS_Store']\n \n found_numbers = [int(f.strip('.html').split('_')[1]) for f i... | [
"0.7158393",
"0.6733796",
"0.6622038",
"0.6564581",
"0.6493209",
"0.64796656",
"0.64215696",
"0.6268492",
"0.62443155",
"0.62019366",
"0.6199126",
"0.6181504",
"0.6176599",
"0.6139581",
"0.611637",
"0.6111604",
"0.609463",
"0.60822713",
"0.6059886",
"0.6059355",
"0.60469335",... | 0.8378213 | 0 |
Given chromosome sizes, plot divider lines and labels. Draws black lines between each chromosome, with padding. Labels each chromosome range with the chromosome name, centered in the region, under a tick. Sets the axis limits to the covered range. By default, the dividers are vertical and the labels are on the X axis o... | def plot_chromosome_dividers(axis, chrom_sizes, pad=None, along="x"):
assert isinstance(chrom_sizes, collections.OrderedDict)
if pad is None:
pad = 0.003 * sum(chrom_sizes.values())
dividers = []
centers = []
starts = collections.OrderedDict()
curr_offset = pad
for label, size in lis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_cells(cells, min_y=0.05, max_y=0.95, label_loc=location_ura_bp,\n cen_loc=location_cen5_bp, chr_size=chrv_size_bp,\n label_colors=None, ax=None):\n def chr_coords(s):\n \"\"\"Map from [0, 1] to locaion on plot.\"\"\"\n return max_y - (max_y - min_y)*s\n # re... | [
"0.59855926",
"0.5667719",
"0.53648233",
"0.535239",
"0.53448987",
"0.5336877",
"0.53227484",
"0.53227484",
"0.53227484",
"0.53122205",
"0.53122205",
"0.53122205",
"0.53122205",
"0.53122205",
"0.53122205",
"0.53122205",
"0.53104365",
"0.5308428",
"0.5303463",
"0.5296885",
"0.... | 0.7555898 | 0 |
Create an ordered mapping of chromosome names to sizes. | def chromosome_sizes(probes, to_mb=False):
chrom_sizes = collections.OrderedDict()
for chrom, rows in probes.by_chromosome():
chrom_sizes[chrom] = rows["end"].max()
if to_mb:
chrom_sizes[chrom] *= MB
return chrom_sizes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(map):\n return map['size']",
"def get_chromosome_length(genome):\n \n chr_list = {}\n \n for key in genome:\n chr_list[key] = len(genome[key])\n\n return chr_list",
"def sort_mapping_by_size(cluster_mapping):\r\n\r\n return sorted(cluster_mapping.keys(),\r\n ... | [
"0.6174769",
"0.6040503",
"0.6033447",
"0.59314597",
"0.5925503",
"0.5911833",
"0.5901245",
"0.5816838",
"0.57068896",
"0.5703283",
"0.56478256",
"0.56461716",
"0.558924",
"0.55857843",
"0.54875106",
"0.54366624",
"0.53771925",
"0.5367268",
"0.5364834",
"0.5347153",
"0.534564... | 0.6786019 | 0 |
Convert start/end positions from genomic to binwise coordinates. Instead of chromosomal basepairs, the positions indicate enumerated bins. Revise the start and end values for all GenomicArray instances at once, where the `cnarr` bins are mapped to corresponding `segments`, and `variants` are grouped into `cnarr` bins a... | def update_binwise_positions(cnarr, segments=None, variants=None):
cnarr = cnarr.copy()
if segments:
segments = segments.copy()
seg_chroms = set(segments.chromosome.unique())
if variants:
variants = variants.copy()
var_chroms = set(variants.chromosome.unique())
# ENH: lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid_to_bins(grid, start_bin_val, end_bin_val):\n bin_centers = (grid[1:] + grid[:-1])/2.0\n bins = np.concatenate([[start_bin_val], bin_centers, [end_bin_val]])\n return bins",
"def concat_ranges_nb(a, start_idxs, end_idxs):\n out = np.empty((end_idxs[0] - start_idxs[0], start_idxs.shape[0] * a.... | [
"0.57546645",
"0.5614808",
"0.53776675",
"0.53201085",
"0.52665704",
"0.5239588",
"0.5239492",
"0.5221806",
"0.519594",
"0.5175467",
"0.5016556",
"0.50004125",
"0.4980183",
"0.49787596",
"0.49721554",
"0.49698713",
"0.49678442",
"0.49237615",
"0.49228168",
"0.49226806",
"0.49... | 0.7329581 | 0 |
Find the location and size of each repeat in `values`. | def get_repeat_slices(values):
# ENH: look into pandas groupby innards
offset = 0
for idx, (_val, rpt) in enumerate(itertools.groupby(values)):
size = len(list(rpt))
if size > 1:
i = idx + offset
slc = slice(i, i + size)
yield slc, size
offset ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_repeating_frequency(values):\n frequencies = set([0])\n\n index = 0\n frequency = 0\n while True:\n found = False\n for value in values:\n frequency += value\n index += 1\n if frequency in frequencies:\n found = True\n ... | [
"0.60911363",
"0.5886676",
"0.5794653",
"0.57471794",
"0.5594755",
"0.5532977",
"0.5366681",
"0.53395396",
"0.5300417",
"0.5274737",
"0.5222571",
"0.52221423",
"0.5220522",
"0.5208285",
"0.5179138",
"0.5176746",
"0.5162105",
"0.51443595",
"0.51057637",
"0.5093284",
"0.5086365... | 0.6345479 | 0 |
Find the chromosomal position of each named gene in probes. Returns dict | def gene_coords_by_name(probes, names):
names = list(filter(None, set(names)))
if not names:
return {}
# Create an index of gene names
gene_index = collections.defaultdict(set)
for i, gene in enumerate(probes["gene"]):
for gene_name in gene.split(","):
if gene_name in na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_probes(probeset, entrez_ids): \n entrez_idx = None\n mapping = {}\n with open(probeset) as probes:\n for line in probes:\n if line.startswith('ID'):\n entrez_idx = line.split('\\t').index('ENTREZ_GENE_ID')\n elif entrez_idx:\n # if the index has been defined then we're past t... | [
"0.63751584",
"0.6185006",
"0.59191895",
"0.57846487",
"0.56714374",
"0.56594753",
"0.5627719",
"0.5605826",
"0.5570916",
"0.55197716",
"0.5507233",
"0.5483343",
"0.5474914",
"0.53773415",
"0.537726",
"0.5336808",
"0.5323498",
"0.5316965",
"0.5203386",
"0.5173213",
"0.5168279... | 0.6813666 | 0 |
Find the chromosomal position of all genes in a range. Returns dict | def gene_coords_by_range(probes, chrom, start, end, ignore=params.IGNORE_GENE_NAMES):
ignore += params.ANTITARGET_ALIASES
# Tabulate the genes in the selected region
genes = collections.OrderedDict()
for row in probes.in_range(chrom, start, end):
name = str(row.gene)
if name in genes:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range_dic_(df_):\n range_dic = {}\n for man in df_['maneuver']:\n trial_indx = df_.index[df_['maneuver'] == man].tolist()\n range_ = (min(trial_indx), max(trial_indx))\n range_dic.update({man: range_})\n return range_dic",
"def range_dic_(df_):\n range_dic = {}\n for man i... | [
"0.6318338",
"0.6318338",
"0.5950929",
"0.57985824",
"0.57871836",
"0.5756468",
"0.56780857",
"0.5640793",
"0.56371856",
"0.561185",
"0.55959535",
"0.55764234",
"0.55740255",
"0.557101",
"0.5568913",
"0.55579585",
"0.55578256",
"0.55408716",
"0.5523614",
"0.5481604",
"0.54741... | 0.730751 | 0 |
Prints a random number between 1 and the number of sides of the die | def roll_die(self):
number = randint(1, self.sides)
print(number) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rollDie(self):\n return random.randint(1, self.sides)",
"def roll_die(self, number_of_rolls):\n\t\tfor roll in range(0, number_of_rolls):\n\t\t\tprint(str(randint(1, self.sides)), end = \", \")\n\t\tprint()",
"def die():\n return random.randint(1,6)",
"def roll_dice(self):\r\n return randi... | [
"0.7796977",
"0.7618368",
"0.7407574",
"0.73979664",
"0.72382367",
"0.7182427",
"0.7154115",
"0.7122058",
"0.7122058",
"0.71132416",
"0.71132416",
"0.71132416",
"0.71132416",
"0.7102902",
"0.7035336",
"0.7031503",
"0.7024645",
"0.6955785",
"0.6931022",
"0.68884605",
"0.687529... | 0.84679675 | 0 |
send some data to badash | def send_to_badash(job, data):
data['job'] = job
data['result'] = 0
resp = requests.post(os.environ.get('BADASH_API_URL', ''), json=data, headers={'X-Api-Key': os.environ.get('BADASH_API_KEY')})
print(resp.status_code) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _send_data(self):\n pass",
"def send(self, data):",
"def send_data(self, **kwargs):",
"def send_data(self, data: dict):\n pass",
"def send(self, data):\n pass",
"def send(User,data):\n BufferManagement.append_to_buffer(data,User['ID'],User['GameID'],\"OUT\")",
"def sendData(... | [
"0.6979101",
"0.6899216",
"0.67075515",
"0.66911685",
"0.658712",
"0.64276284",
"0.64261144",
"0.6391734",
"0.6275754",
"0.60917",
"0.6080601",
"0.6060746",
"0.60563254",
"0.5980716",
"0.5978205",
"0.5966177",
"0.59635454",
"0.5939323",
"0.5926442",
"0.5909892",
"0.58855337",... | 0.6981778 | 0 |
Returns True if the input array is zero (smaller than machine precision) everywhere. Useful for determining if tilt angle is zero everywhere (i.e. LFM file is in GSM coordinates). | def __isZeroEverywhere(self, array):
epsilon = numpy.finfo( type(array[0]) ).eps
boolList = numpy.less_equal(numpy.abs(array), epsilon)
for b in boolList:
if not b:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iszero(a: float) -> bool:\n return np.isclose(a, 0.0, atol=1.0e-12, rtol=0.0)",
"def is_zero(self):\n for t in self:\n if t != TRIT_ZERO:\n return False\n return True",
"def is_close_to_zero(value: Union[float, np.ndarray]) -> Union[bool, np.ndarray]:\n ret... | [
"0.7329743",
"0.71980375",
"0.7180356",
"0.6959584",
"0.68835986",
"0.6858602",
"0.6843292",
"0.6754056",
"0.67275715",
"0.6671207",
"0.66645455",
"0.66500664",
"0.6643579",
"0.6640681",
"0.6592677",
"0.6558841",
"0.64952725",
"0.64739907",
"0.6471248",
"0.64580184",
"0.63760... | 0.7982687 | 0 |
Transform all magnetic field B and velocity V values from SM to GSM coordinates. Store results by overwriting dataDict contents. | def __sm2gsm(self, dataDict):
b = (dataDict.getData('bx'),dataDict.getData('by'),dataDict.getData('bz'))
v = (dataDict.getData('vx'),dataDict.getData('vy'),dataDict.getData('vz'))
for i,time in enumerate(dataDict.getData('time_min')):
d = self.startDate + datetime.timedelta(minutes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(self):\n\n mm_magcoord.add_aacgm_coordinates(self)\n mm_magcoord.add_quasi_dipole_coordinates(self)\n mm_sc.calculate_ecef_velocity(self)\n mm_sc.add_ram_pointing_sc_attitude_vectors(self)\n\n return",
"def FL_2_mav_state(self, data):\n\n (data['velocities/phidot-rad_sec_bf']... | [
"0.5918188",
"0.5905822",
"0.5839146",
"0.569138",
"0.56422216",
"0.5492949",
"0.54187244",
"0.54171056",
"0.53424686",
"0.5341912",
"0.5314857",
"0.5298684",
"0.51961774",
"0.5193409",
"0.51925063",
"0.51916564",
"0.51853",
"0.51811767",
"0.51800555",
"0.5175418",
"0.5141496... | 0.8032454 | 0 |
Convert from [year, doy, hour, minte] to datetime object >>> sw = LFM('examples/data/solarWind/LFM_SWSMDAT') >>> sw._LFM__parseDate('1995 80 0 1') datetime.datetime(1995, 3, 21, 0, 1) | def __parseDate(self, dateStr):
fields = [int(s) for s in dateStr.split() ]
date = ( datetime.datetime(year=fields[0], month=1, day=1,
hour=fields[2], minute=fields[3]) +
datetime.timedelta(fields[1] - 1) )
return date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(s):\n m, d, y = s.split('/')\n mo = int(m)\n da = int(d)\n yr = int(y)\n d = datetime.date(yr, mo, da)\n return d",
"def date_parse(date_string) -> datetime:\n return datetime.strptime(date_string, DATE_FMT)",
"def parse_date(date):\n # MediaWiki API dates are always of t... | [
"0.66912717",
"0.6641376",
"0.64530736",
"0.642597",
"0.6422225",
"0.63934094",
"0.6359452",
"0.6354985",
"0.635257",
"0.63273865",
"0.6317693",
"0.62617373",
"0.6170135",
"0.61521035",
"0.61109614",
"0.6102334",
"0.60923606",
"0.6085874",
"0.608139",
"0.6068376",
"0.6065565"... | 0.6771597 | 0 |
Returns the tissue expression as a tabular text file | def tissue_table(self, condition_tissue_id, use_means=True):
table = ExpressionProfile.__profile_to_table(
self.tissue_profile(condition_tissue_id, use_means=use_means)
)
return table | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_table2(df, eval_dir):\n\n out_file = os.path.join(eval_dir, 'table2.txt')\n\n\n with open(out_file, \"w\") as text_file:\n\n for idx, struc_name in enumerate(['LV', 'RV', 'Myo']):\n # new line\n header_string = ' & '\n line_string = '({}) '.format(struc_name)... | [
"0.5715523",
"0.5585215",
"0.5510229",
"0.5483904",
"0.5433547",
"0.539088",
"0.53867865",
"0.5360147",
"0.5359347",
"0.5353965",
"0.5342304",
"0.5327082",
"0.5309732",
"0.5296553",
"0.5263918",
"0.52535033",
"0.52193636",
"0.5209992",
"0.5206868",
"0.5203945",
"0.51973903",
... | 0.5600994 | 1 |
Checks if the mean expression value in any conditions in the plot is higher than the desired cutoff | def low_abundance(self, cutoff=10):
data = json.loads(self.profile)
checks = [mean(v) > cutoff for _, v in data["data"].items()]
return not any(checks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_equivalence_to_filter_output(self):\n error = np.linalg.norm(self.postmean - self.mean[[-1, -10]])/np.linalg.norm(self.mean[-1])\n self.assertLess(error, 1e-12)",
"def test_equivalence_to_filter_output(self):\n error = np.linalg.norm(self.postmean - self.mean[[-1, -10]])/np.linalg.n... | [
"0.63532436",
"0.63532436",
"0.63532436",
"0.6349902",
"0.6218509",
"0.6218509",
"0.6218509",
"0.6137946",
"0.60649145",
"0.6062961",
"0.6055984",
"0.59992933",
"0.5966027",
"0.5953051",
"0.58949625",
"0.5885765",
"0.579604",
"0.5673176",
"0.56725395",
"0.56724554",
"0.566493... | 0.67541367 | 0 |
Applies a conversion to the profile, grouping several condition into one more general feature (e.g. tissue). | def tissue_profile(self, condition_tissue_id, use_means=True):
ct = ConditionTissue.query.get(condition_tissue_id)
condition_to_tissue = json.loads(ct.data)
profile_data = json.loads(self.profile)
output = ExpressionProfile.convert_profile(
condition_to_tissue, profile_data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_profile(condition_to_tissue, profile_data, use_means=True):\n tissues = list(set(condition_to_tissue[\"conversion\"].values()))\n\n output = {}\n\n for t in tissues:\n valid_conditions = [\n k\n for k in profile_data[\"data\"]\n ... | [
"0.66733557",
"0.49194333",
"0.49031988",
"0.4838306",
"0.48149535",
"0.47954047",
"0.478979",
"0.4768422",
"0.47311518",
"0.46969774",
"0.46876988",
"0.4677883",
"0.4670147",
"0.46662682",
"0.4616618",
"0.46068928",
"0.46041748",
"0.45904663",
"0.45898837",
"0.45892733",
"0.... | 0.57825917 | 1 |
Returns a heatmap for a given species (species_id) and a list of probes. It returns a dict with 'order' the order of the experiments and 'heatmap' another dict with the actual data. Data is zlog transformed | def get_heatmap(species_id, probes, zlog=True, raw=False):
profiles = (
ExpressionProfile.query.options(undefer("profile"))
.filter_by(species_id=species_id)
.filter(ExpressionProfile.probe.in_(probes))
.all()
)
order = []
output = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_heatmap(data, labels_dict, file_title, plot_title):\n\n fig = plt.figure()\n ax = sn.heatmap(data,\n linewidths=0.3)\n figure = ax.get_figure()\n\n if labels_dict:\n ax.set_xlabel(labels_dict[\"x\"])\n ax.set_ylabel(labels_dict[\"y\"])\n if plot_title:\n... | [
"0.57747865",
"0.5651769",
"0.56350327",
"0.55808216",
"0.5573853",
"0.5566096",
"0.55594",
"0.5546572",
"0.5511376",
"0.54935324",
"0.5465989",
"0.5449651",
"0.5437825",
"0.5425046",
"0.5419889",
"0.53996754",
"0.53830385",
"0.53745747",
"0.534903",
"0.52979654",
"0.52845615... | 0.7889706 | 0 |
Gets the data for a set of probes (including the full profiles), a limit can be provided to avoid overly long queries | def get_profiles(species_id, probes, limit=1000):
profiles = (
ExpressionProfile.query.options(undefer("profile"))
.filter(ExpressionProfile.probe.in_(probes))
.filter_by(species_id=species_id)
.options(joinedload("sequence").load_only("name").noload("xrefs"))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _retrieve_data(keyw, limit, page=1):\n # Max results per page is 100\n per_page = limit if limit < 100 else 100\n url = BASE_URL + QUALIFIERS % (keyw, per_page, page)\n\n req = requests.get(url)\n r_json = req.json()\n\n if limit > 100:\n r_json['items'].extend(_retrieve_data(keyw, li... | [
"0.60100675",
"0.58483875",
"0.5483683",
"0.5466175",
"0.5350069",
"0.53199553",
"0.5314926",
"0.53077745",
"0.5280295",
"0.52494043",
"0.5166348",
"0.5158148",
"0.51288855",
"0.5115098",
"0.5088638",
"0.50777245",
"0.5070165",
"0.5061214",
"0.50397336",
"0.50375605",
"0.5029... | 0.67031264 | 0 |
Fill all pixels of the surface with color, preserve transparency. | def fill(surface, color):
w, h = surface.get_size()
r, g, b, _ = color
for x in range(w):
for y in range(h):
a = surface.get_at((x, y))[3]
surface.set_at((x, y), pygame.Color(r, g, b, a)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_color(self, _col):\n for x in xrange(0, self.__resolution[0], 1):\n for y in xrange(0, self.__resolution[1], 1):\n self.__framebuffer[(x, y)] = _col",
"def main_background():\n surface.fill(COLOR_GRAY)",
"def fill(self, color):",
"def fill(self, colour: int, /) ->... | [
"0.6754669",
"0.6575468",
"0.6551719",
"0.65116376",
"0.6489565",
"0.6489565",
"0.646568",
"0.64328253",
"0.63633025",
"0.6341166",
"0.6229023",
"0.62250054",
"0.6200527",
"0.619609",
"0.6117054",
"0.6111317",
"0.60966897",
"0.6091011",
"0.6048498",
"0.5998635",
"0.5975528",
... | 0.77070856 | 0 |
Returns the absolute url for this plan_proposal for preview purposes. | def get_absolute_url(self):
return reverse('plan_proposal',
kwargs = {'project_name': self.project.slug,
'proposal_name': self.slug}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute_url(self) -> str:\n return self.proposition.get_absolute_url()",
"def get_absolute_url(self) -> str:\n return self.cagnotte.get_absolute_url()",
"def get_url(self):\n return self.resource.url",
"def get_absolute_url(self) -> str:\n return reverse(\"cv_detail\", kw... | [
"0.7132922",
"0.68332034",
"0.67404026",
"0.6709807",
"0.67093635",
"0.66793925",
"0.6630603",
"0.65069014",
"0.65069014",
"0.65069014",
"0.64967704",
"0.64927083",
"0.649157",
"0.6489108",
"0.6484969",
"0.64831454",
"0.64831454",
"0.6449211",
"0.6449211",
"0.6435623",
"0.639... | 0.819664 | 0 |
Sent by clients when they enter a room. A status message is broadcast to all people in the room. | def joined(message):
#room = session.get('room')
room='abc'
join_room(room)
#emit('status', {'msg': session.get('name') + ' has entered the room.' + message['msg']}, room=room)
emit('status', {'msg': 'Yao has entered the room.'}, room=room)
#emit('status', {'msg': 'Yao has entered the room.'}, r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def joined(message):\n room = session.get('room')\n join_room(room)\n emit('status', {'msg': session.get('name') + ' has entered the room.'}, room=room)",
"def joined(message):\n room = session.get('room')\n join_room(room)\n emit('status', {'msg': session.get('name') + ' has entered the room.'... | [
"0.678886",
"0.678886",
"0.67852986",
"0.64390427",
"0.6437565",
"0.6368543",
"0.6348403",
"0.6347864",
"0.6286434",
"0.621969",
"0.6199029",
"0.61885846",
"0.6173507",
"0.61667264",
"0.61572355",
"0.61443347",
"0.6096311",
"0.6088395",
"0.60681",
"0.6010695",
"0.6003259",
... | 0.6819369 | 0 |
print all customers with the current time and id in CSV format. | def print_customers(self):
output = ''
for i in range(len(self.customers)):
output += f'Customer no. {self.customers[i].id} is in {self.customers[i].state[0]} section\n'
#print(output)
with open('oneday.csv','a') as outfile:
for i in range(len(self.customers)):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_customers(self):\n self.current_time = self.get_time()\n return f'Supermarket(\"{self.customers}\", \"{self.current_time}\")'",
"def table_info(self):\n for customer in self.customers:\n print(customer.get_name())",
"def customerReport(self):\n self._setFormat()... | [
"0.7302453",
"0.6655823",
"0.6353772",
"0.62918216",
"0.6062786",
"0.5880602",
"0.5728009",
"0.572303",
"0.57119894",
"0.5707167",
"0.57021517",
"0.570062",
"0.5667141",
"0.56458884",
"0.55236256",
"0.5516203",
"0.54992557",
"0.54658407",
"0.5455488",
"0.54491806",
"0.5446669... | 0.8107446 | 0 |
removes every customer that is not active any more. | def remove_existing_customers(self):
for i in range(len(self.customers)):
if self.customers[i].is_active() == False:
self.customers[i]= 'out'
self.customers = [item for item in self.customers if item!='out' ] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_existing_customers(self):\n # remove the customers which are not active (.is_active )\n self.to_move = False\n #for cust in self.customers:\n # print(cust.state)\n self.customers = [cust for cust in self.customers if cust.state != 'checkout']\n #if cust.t... | [
"0.82650816",
"0.63835925",
"0.6293173",
"0.6194644",
"0.5925333",
"0.58057535",
"0.57551056",
"0.57542336",
"0.57448226",
"0.5709532",
"0.566901",
"0.5649718",
"0.5645026",
"0.5611124",
"0.55752677",
"0.55348897",
"0.5534544",
"0.55345047",
"0.5498778",
"0.54886633",
"0.5482... | 0.8203715 | 1 |
Helper function for creating new `Item` Elements. This is used until we get to InstanceElement, where we then use that class for all of the elements instead instead. | def _new_item(class_name=None):
class_name = class_name or "Folder"
return ElementTree.Element("Item", attrib={ "class": class_name }) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def NewItems(self) -> _n_1_t_7:",
"def _createItem(self, rpcObject):\n item = ShowWidgetItem(rpcObject, self)\n return item",
"def clone_item(item):\n i = h5Item(item.text(0))\n i.path = item.path\n i.listIndex = item.dataIndex\n i.originalIndex = item.originalIndex\n i.data = item... | [
"0.6591493",
"0.61576575",
"0.58468294",
"0.5836948",
"0.5780297",
"0.5729952",
"0.5715711",
"0.5708954",
"0.5705501",
"0.569519",
"0.5685359",
"0.5655327",
"0.5629177",
"0.5620245",
"0.55971825",
"0.559323",
"0.5592667",
"0.55574316",
"0.55425286",
"0.55268466",
"0.5522246",... | 0.73472065 | 0 |
Right now, comment matching is only done to inline comments for simplicity. If a more sophisticated pattern is implemented to pick up block comments, this test can be removed. | def test_does_not_match_block_comments(self):
comment = dedent("""\
--[[
Hello, World!
--]]""")
script = rbxmx.ScriptElement(source=comment)
first_comment = script.get_first_comment()
assert first_comment is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_like_a_comment(self):\n self.base_test()",
"def test_comments(self):\n\n comment_str = \"# This is a comment\\n# This is another comment\"\n doc = parser.parse(comment_str)\n\n self.assertEqual(len(doc.children()), 2)",
"def test_parse_multiline_comment(self):\n sour... | [
"0.69436723",
"0.6914159",
"0.66925186",
"0.6657935",
"0.6617428",
"0.6434374",
"0.64170176",
"0.6403656",
"0.6363083",
"0.62539417",
"0.6222357",
"0.61914796",
"0.61640805",
"0.6143505",
"0.6138388",
"0.61269903",
"0.61109936",
"0.6103159",
"0.6084948",
"0.60746026",
"0.6070... | 0.7008808 | 0 |
Return a dict with validation rules for a field Used directly in widget templates | def get_validators_for_field(field):
# TODO: Add more validation methods
validators = {}
if v.validation_includes(field.attr.validator, v.Email):
validators['email'] = True
if v.validation_includes(field.attr.validator, v.Number):
validators['number'] = True
if v.validation_inclu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields_validator():\n\n return validator.BrewerySchema()",
"def validate(self):\n for rule in self.get_rules():\n rule.validate(self.get_val())",
"def validation_runner(val_funk, field, value, requires):\n if hasattr(requires, '__iter__') and not isinstance(requires, unicode):\n ... | [
"0.6197543",
"0.6169014",
"0.61174333",
"0.6108308",
"0.599177",
"0.5980837",
"0.5857387",
"0.57794267",
"0.57696426",
"0.5747897",
"0.57409066",
"0.57206804",
"0.56706357",
"0.56206083",
"0.5611332",
"0.5595536",
"0.55856764",
"0.55637115",
"0.5559004",
"0.55411786",
"0.5500... | 0.6690709 | 0 |
Returns selected="selected" if the option value matches field's default Used directly in widget templates | def is_option_selected(option, field):
if field.attr.default and option[0] == field.attr.default: # and option[0] != self.empty:
return ' selected="selected"'
else:
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_SelectChoiceDefault(request):\n schema = schemaish.Structure()\n schema.add('mySelect', schemaish.Integer())\n options = [(1,'a'),(2,'b'),(3,'c')]\n\n form = formish.Form(schema, 'form')\n form['mySelect'].widget = formish.SelectChoice(options)\n form['mySelect'].default = 2\n return ... | [
"0.65975666",
"0.6416188",
"0.6191291",
"0.6049021",
"0.604218",
"0.5977653",
"0.597259",
"0.5937122",
"0.5825413",
"0.5796056",
"0.5770259",
"0.5767324",
"0.5749384",
"0.5735948",
"0.5734999",
"0.57267016",
"0.56422603",
"0.56007797",
"0.5600718",
"0.55645937",
"0.55640537",... | 0.84386253 | 0 |
Helper function to plot results from sampling (neighborhood radii or iterations) | def plot_sampling(fname, df, of="r_neighbor", show=True):
xlabel = r"Neighborhood $r_{c}$"
logx = False
if of == "n_iter":
xlabel = "#Cycles"
logx = True
fig, ax = plt.subplots(figsize=(15, 5))
gb = df.groupby([of])
aggregation = {"stress": [np.mean, np.std], "correlation": [n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plotResults(self):\n\n clusters = self.data[[i for i in range(len(self.data)) if self.vorLabels[i] != 0], :]\n vorLabels = [self.vorLabels[i] for i in range(len(self.data)) if self.vorLabels[i] != 0]\n\n self.plot = voronoiPlot(clusters, self.skel, self.skelLabels, self.isCorrect, vorLabel... | [
"0.62359834",
"0.6225181",
"0.6198315",
"0.6130711",
"0.6028747",
"0.6018309",
"0.60092574",
"0.6005623",
"0.6003807",
"0.5962413",
"0.59510237",
"0.5933299",
"0.5933299",
"0.5864029",
"0.5844357",
"0.5837657",
"0.5837616",
"0.58130574",
"0.5795679",
"0.5788632",
"0.57843834"... | 0.63356423 | 0 |
Post an answer to the given tweets | def answer_to_tweets(api, tweets):
try:
last_tweet_id = 0
for tweet in tweets:
print("Sending an answer to tweet {}: '{}'".format(tweet["id"],
tweet["text"]))
api.statuses.update(status=TARGET_TWEET_ANSWER,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_to_twitter(tweet):\n auth = tweepy.OAuthHandler(\n os.environ['BLADAMADUR_CONSUMER_KEY'],\n os.environ['BLADAMADUR_CONSUMER_SECRET'])\n auth.set_access_token(\n os.environ['BLADAMADUR_ACCESS_TOKEN'],\n os.environ['BLADAMADUR_ACCESS_TOKEN_SECRET'])\n api = tweepy.API(au... | [
"0.7315169",
"0.720348",
"0.70277464",
"0.7026013",
"0.7026013",
"0.7026013",
"0.70143557",
"0.69740754",
"0.6944611",
"0.69140863",
"0.689736",
"0.6822415",
"0.6770704",
"0.6758333",
"0.6744515",
"0.6729099",
"0.66975725",
"0.6697186",
"0.6669573",
"0.6660224",
"0.6641313",
... | 0.76214606 | 0 |
Retrieve the id of the last tweet we answered to | def get_last_tweet_id():
if not os.path.exists(LAST_TWEET_FILE):
return 0
try:
with open(LAST_TWEET_FILE, 'rb') as last_tweet_file:
return pickle.load(last_tweet_file)
except pickle.UnpicklingError:
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maximum_id(tweets):\n try:\n tree = etree.parse(StringIO(tweets), etree.XMLParser())\n statuses = tree.xpath('//statuses')\n id_str = statuses[0].xpath('./status/id/text()')\n ids = []\n for id in id_str:\n ids.append(int(id))\n return str(max(ids))\n\n ... | [
"0.6557923",
"0.65007925",
"0.6485662",
"0.6465227",
"0.64261043",
"0.63394284",
"0.6325243",
"0.63116455",
"0.6201186",
"0.61996835",
"0.61993325",
"0.61968505",
"0.61273897",
"0.6119263",
"0.60918725",
"0.608339",
"0.60476357",
"0.60136485",
"0.6002097",
"0.5997282",
"0.597... | 0.7113535 | 0 |
Update the id of the last tweet the bot considered | def update_last_tweet_id(last_tweet_id):
if last_tweet_id:
with open(LAST_TWEET_FILE, 'wb') as last_tweet_file:
pickle.dump(last_tweet_id, last_tweet_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_tweet(self, twitter) -> None:\n if isinstance(twitter, dict):\n json_data = twitter\n else:\n json_data = json.loads(twitter)\n\n try:\n breakpoint()\n self.db.tweets.find_one_and_update(\n {'id_str': json_data['id_str']},\n ... | [
"0.6783095",
"0.6732734",
"0.671317",
"0.6659954",
"0.65241224",
"0.6519562",
"0.6500197",
"0.6424114",
"0.6419715",
"0.6397454",
"0.6346836",
"0.63047737",
"0.6231078",
"0.62044",
"0.61940396",
"0.61729753",
"0.61687416",
"0.6161052",
"0.6138779",
"0.61345094",
"0.61204773",... | 0.75976545 | 0 |
Calc the global position of every local Obstacle, Returns list | def calcGlobalObstaclePosition(self, obstacles):
global_obstacle_list = []
for obstacle in obstacles:
#Wandeln Winkeldaten für Globalberechnung: -90zu+90 und +90zu-90 0=0
#ScanList[i][0]=degrees(asin(sin(radians(ScanList[i][0])+radians(180))))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_obstacle_loc(self, obstacle_list):\n\n x_obst = []\n y_obst = []\n #x_obst_append = x_obst.append\n #y_obst_append = y_obst.append\n locs = []\n\n for x in obstacle_list:\n if x < self.width:\n x_obst.append(x*self.resolution + self.resol... | [
"0.74064344",
"0.707515",
"0.6628567",
"0.6443536",
"0.6411638",
"0.62849295",
"0.62457395",
"0.62181544",
"0.60758865",
"0.6068896",
"0.6041863",
"0.6032454",
"0.6019976",
"0.5921112",
"0.5918362",
"0.5913744",
"0.58780336",
"0.5858981",
"0.5829376",
"0.58060443",
"0.5805806... | 0.8241253 | 0 |
Pickel Robos Path every Xsec. | def saveRoboPath(self):
if time.time()-self.timeold > 2:
self.RoboPath.append([round(self.RoboPosX,1),round(self.RoboPosY,1)])
self.timeold = time.time() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_path(self, path):\n self.clear_path()\n for coordinate in path:\n self.send_coordinate(coordinate)\n time.sleep(0.05)",
"def change_to_with_delay(_path: str):\n time.sleep(1)",
"def run(self):\n r = rospy.Rate(100)\n while not rospy.is_shutdown():\n... | [
"0.5697258",
"0.54999626",
"0.5414542",
"0.5356699",
"0.53323853",
"0.5246065",
"0.5175965",
"0.5170865",
"0.51637995",
"0.51113075",
"0.51113075",
"0.51113075",
"0.5107844",
"0.51071584",
"0.5102906",
"0.50996655",
"0.50768256",
"0.5040481",
"0.50338733",
"0.5033516",
"0.501... | 0.55648315 | 1 |
Set Robo Position zb bei Start | def setRoboPos(self,x,y):
self.RoboPosX=x
self.RoboPosY=y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_start_position(self) -> None:\n self.cozmo.set_head_angle(degrees(0)).wait_for_completed()\n self.cozmo.set_lift_height(0.0).wait_for_completed()",
"def setPosition(position):",
"def setPosition(self):\n # determine posX, posY for battle\n (x1,y1) = globals.battlemapQuadrant... | [
"0.6879765",
"0.63435316",
"0.63344735",
"0.6325999",
"0.6276773",
"0.61788565",
"0.6124393",
"0.60797316",
"0.5994932",
"0.5965214",
"0.59490186",
"0.5944862",
"0.5942923",
"0.59371793",
"0.5925291",
"0.59103125",
"0.58716786",
"0.5862039",
"0.5848119",
"0.584693",
"0.584570... | 0.7795507 | 0 |
return latest Obstacles and clears obstacles | def getObstacles(self):
ausgabeObstacle = self.globalObstaclesList + self.globalHardObstaclesList
self.globalObstaclesList = []
return(ausgabeObstacle) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_obstacles(self):\n self.obstacles = np.array([])",
"def get_obstacles(self):\n return self.obstacles",
"def updateHardObstacles(self):\r\n global_obs = self.calcGlobalObstaclePosition([[10, 20],[10, 0],[10, -20]])\r\n self.globalHardObstaclesList.extend(global_obs)",
"de... | [
"0.7343851",
"0.73193496",
"0.7129685",
"0.6885037",
"0.6878335",
"0.6839208",
"0.6755548",
"0.66489303",
"0.660735",
"0.64975613",
"0.64508957",
"0.6420063",
"0.62252665",
"0.6134923",
"0.612027",
"0.60872567",
"0.6025011",
"0.5986204",
"0.5968379",
"0.59590596",
"0.59383273... | 0.7682897 | 0 |
Get an existing SSLCertificate resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
certificate: Optional[pulumi.Input[str]] = None,
certificate_id: Optional[pulumi.Input[int]] = None,
creation_timestamp: Optional[pulumi.Input[str]] = None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Optional[pulumi.ResourceOptions] = None,\n certificate: Optional[pulumi.Input[str]] = None,\n certificate_id: Optional[pulumi.Input[str]] = None,\n certificate_name: Optional[pulumi.Input[str]] = Non... | [
"0.6610114",
"0.63369817",
"0.6177877",
"0.6108327",
"0.574682",
"0.5677764",
"0.5492402",
"0.5390177",
"0.5345001",
"0.5200239",
"0.51293224",
"0.5123964",
"0.508775",
"0.50864744",
"0.504956",
"0.5040337",
"0.50251144",
"0.5013605",
"0.49793026",
"0.49746943",
"0.49307314",... | 0.70121515 | 0 |
checks that the user wants to finish or not. Perform some verification of the input. | def check_if_user_has_finished():
ok_to_finish = True
user_input_accepted = False
while not user_input_accepted:
user_input = input("Do you want to finish (y/n): ").lower()
if user_input == 'y':
user_input_accepted = True
elif user_input == 'n':
ok_to_finish =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_or_exit(msg):\n while True:\n user_input = raw_input(\"%s (y/n): \" % msg).lower()\n if user_input in ['y', 'yes']:\n print\n return\n if user_input in ['n', 'no']:\n print\n print_warning(\"Please complete the required steps and then \"... | [
"0.7116285",
"0.6960877",
"0.6919499",
"0.65994936",
"0.65895295",
"0.65874827",
"0.65681756",
"0.65681756",
"0.65681756",
"0.65426457",
"0.6500775",
"0.649839",
"0.6491906",
"0.6482516",
"0.6437172",
"0.64225864",
"0.6373759",
"0.63676196",
"0.63667154",
"0.634533",
"0.62921... | 0.792566 | 0 |
Generate image from Blender scene file (.blend) | def generate_blenderimage(scene_file, output=None, script_file=None, frame=1):
cmd = [BLENDER, "-b", scene_file, "-y"]
previous_wd = os.getcwd()
os.chdir(os.path.dirname(os.path.abspath(scene_file)))
if script_file:
cmd.append("-P")
cmd.append(script_file)
if output:
outbase,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filesToBlender(context, prefix, max_blocks=200):\n # Get reference matrix\n refMatrix = None\n if context.scene.maps_models_importer_is_ref_matrix_valid:\n values = context.scene.maps_models_importer_ref_matrix\n refMatrix = Matrix((values[0:4], values[4:8], values[8:12], values[12:16]))... | [
"0.62464625",
"0.61263806",
"0.5809615",
"0.5739291",
"0.57354367",
"0.57354367",
"0.5628557",
"0.5620815",
"0.5601936",
"0.5595058",
"0.5571719",
"0.55669874",
"0.5565276",
"0.5536535",
"0.54908586",
"0.547654",
"0.5472655",
"0.5457408",
"0.54366314",
"0.54189646",
"0.541758... | 0.77711815 | 0 |
Generate image from blender scene file(.blend) with changed parameters | def generate_img_with_params(scene_file, script_name="tmp.py", xres=800,
yres=600, crop=None, use_compositing=False,
output=None, frame=1):
if crop is None:
crop = [0, 1, 0, 1]
crop_file_src = generate_blender_crop_file([xres, yres], [crop[0], ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_blenderimage(scene_file, output=None, script_file=None, frame=1):\n cmd = [BLENDER, \"-b\", scene_file, \"-y\"]\n previous_wd = os.getcwd()\n os.chdir(os.path.dirname(os.path.abspath(scene_file)))\n if script_file:\n cmd.append(\"-P\")\n cmd.append(script_file)\n if output... | [
"0.77292585",
"0.6207573",
"0.5900598",
"0.57756275",
"0.57517344",
"0.5726966",
"0.5690768",
"0.56802726",
"0.56633824",
"0.5639718",
"0.5580907",
"0.5566535",
"0.55639535",
"0.5551473",
"0.5547673",
"0.55438566",
"0.5523262",
"0.5518169",
"0.551783",
"0.5502739",
"0.5483207... | 0.6494286 | 1 |
The is a bigram collocation finder. | def collocationFinder(document,nbest=4):
chain = lambda x : list(itertools.chain(*pos.tokenize_words(pos.tokenize_sents(x))))
stopset = set(stopwords.words('english'))
filter_stops = lambda w: len(w) < 3 or w in stopset
bcf = BigramCollocationFinder.from_words(chain(document))
bcf.apply_word_filter(filter_stops)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bigram_finder(self):\n return BigramCollocationFinder(self.word_fd, self.bigram_fd)",
"def __init__(self, word_fd, bigram_fd, window_size=2):\n AbstractCollocationFinder.__init__(self, word_fd, bigram_fd)\n self.window_size = window_size",
"def extract_collocations(records, num_colloca... | [
"0.7552091",
"0.55829513",
"0.55793124",
"0.55691856",
"0.54569393",
"0.5451188",
"0.5396927",
"0.5359675",
"0.5291153",
"0.51844424",
"0.51592106",
"0.50812316",
"0.5008657",
"0.4991801",
"0.498291",
"0.49716583",
"0.49510488",
"0.49447197",
"0.49431813",
"0.49225318",
"0.48... | 0.6254757 | 1 |
Given a set of tagger_class and conll2000 training sentences, this function returns a good backoff POS tagger. | def backoff_tagger(train_sents, tagger_classes, backoff=None):
for cls in tagger_classes:
backoff = cls(train_sents,backoff=backoff)
return backoff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_backoff_tagger():\n\n\treturn backoff_tagger(treebank.tagged_sents(), \n\t\t[UnigramTagger, BigramTagger, TrigramTagger],\n\t\tbackoff=DefaultTagger('NN'))",
"def naiveBayes(train_set, train_labels, dev_set, smoothing_parameter, pos_prior):\r\n # TODO: Write your code here\r\n # return predicted l... | [
"0.6735268",
"0.60845643",
"0.5994172",
"0.5816069",
"0.58006746",
"0.5712055",
"0.55743456",
"0.5564887",
"0.54723716",
"0.5455845",
"0.5453202",
"0.54045594",
"0.5381295",
"0.5375442",
"0.5366399",
"0.5317818",
"0.5306032",
"0.52813303",
"0.5279574",
"0.5199976",
"0.5190478... | 0.7153057 | 0 |
Returns a backoff tagger that useses a UnigramTagger, BigramTagger, TrigramTagger, and a Default tagger that returns NN | def make_backoff_tagger():
return backoff_tagger(treebank.tagged_sents(),
[UnigramTagger, BigramTagger, TrigramTagger],
backoff=DefaultTagger('NN')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backoff_tagger(train_sents, tagger_classes, backoff=None):\n\tfor cls in tagger_classes:\n\t\tbackoff = cls(train_sents,backoff=backoff)\n\treturn backoff",
"def create_tagger():\n train_sents = brown.tagged_sents()\n\n # These regexes were lifted from the NLTK book tagger chapter.\n t0 = nltk.Regex... | [
"0.6910925",
"0.6843258",
"0.63026106",
"0.6082636",
"0.5692276",
"0.5538755",
"0.5303569",
"0.5225821",
"0.51950496",
"0.5185843",
"0.5142859",
"0.50902545",
"0.50739115",
"0.50673866",
"0.5044054",
"0.50221866",
"0.49873263",
"0.49494132",
"0.48789895",
"0.48588735",
"0.483... | 0.8340529 | 0 |
should accept a dict or callable as first argument | def test_takes_dict_or_callable(self):
scope1 = Scope({ 'where': 'foo' })
self.assertEqual(scope1.finder_options, { 'where': 'foo' })
call = lambda(cls): cls.where('foo')
scope2 = Scope(call)
self.assertEqual(scope2.callable, call) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callableize(f_or_d):\n return f_or_d.get if isinstance(f_or_d,dict) else f_or_d",
"def fn(*args, **kwargs):\n pass",
"def callFuncBasedOnDict(func, argdict, **kwargs):\n if argdict is None:\n argdict = {}\n seldict = selectArgsFromDict(func, argdict)\n if kwargs is not None:\n... | [
"0.6986333",
"0.6356339",
"0.6322947",
"0.6199034",
"0.59889823",
"0.5970065",
"0.59491587",
"0.5934999",
"0.5909235",
"0.57952887",
"0.57868856",
"0.5782365",
"0.57396305",
"0.5720871",
"0.571165",
"0.57064",
"0.5683914",
"0.56789106",
"0.5671449",
"0.56660324",
"0.5663809",... | 0.66485786 | 1 |
should raise exception on bad arguments | def test_errors_on_bad_argument(self):
self.assertRaises(Exception, Scope, 'foo')
self.assertRaises(Exception, Scope, 1)
self.assertRaises(Exception, Scope, [])
self.assertRaises(Exception, Scope, tuple()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test04(self):\n self.assertRaises(TypeError, robustApply, oneArgument, \"this\", blah=\"that\")",
"def test_badargs(self):\n self.assertRaises(TypeError, isint, [])\n self.assertRaises(TypeError, isint, {})\n self.assertRaises(TypeError, isint, None)\n return",
"def test_... | [
"0.76359093",
"0.74616575",
"0.7447246",
"0.74302024",
"0.7386324",
"0.7267616",
"0.7242593",
"0.7234812",
"0.7199537",
"0.7185044",
"0.7169754",
"0.7130541",
"0.711537",
"0.71062267",
"0.71003824",
"0.70912004",
"0.70899975",
"0.70628417",
"0.7052777",
"0.7041206",
"0.700969... | 0.74869186 | 1 |
should set `model` to owner when instance is None | def test_sets_model_to_owner(self):
self.assertEqual(self.Test.foo.model, self.Test) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_model(self, request, obj, form, change):\n try:\n owner = form.instance.owner\n except models.Application.owner.RelatedObjectDoesNotExist:\n form.instance.owner = request.user\n\n super().save_model(request, obj, form, change)",
"def pre_save(self, obj):\n ... | [
"0.7634998",
"0.67302233",
"0.66623086",
"0.66623086",
"0.66623086",
"0.64856637",
"0.64180213",
"0.64180213",
"0.64180213",
"0.64180213",
"0.63496315",
"0.6301929",
"0.62846565",
"0.62515026",
"0.62515026",
"0.62515026",
"0.62515026",
"0.6190546",
"0.61800027",
"0.6162175",
... | 0.7304472 | 1 |
should delegate to `callable` when present | def test_delegates_callable(self):
foo = self.Test.foo
self.assertEqual(foo(), 123)
foo(1, 2, 3, foo='bar')
self.assertEqual(((1, 2, 3), dict(foo='bar')), self.last_call) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, *args, **kw):\n return self.callable(*args, **kw)",
"def getCallable():",
"def before_call(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None:",
"def callback(self, fun: Callable[[], None] | None) -> None:",
"def func(cls):\n return cls.get_wrapper()(cls.cal... | [
"0.6989672",
"0.6630756",
"0.6587269",
"0.6549553",
"0.65392023",
"0.6454149",
"0.6429809",
"0.63942474",
"0.6285364",
"0.62485355",
"0.6232313",
"0.6214799",
"0.6207219",
"0.62026733",
"0.6182194",
"0.6179252",
"0.6174716",
"0.61691743",
"0.6093075",
"0.60522413",
"0.6027874... | 0.6868197 | 1 |
This function performs a grid search over a set of different learning rates and a number of hidden layer neurons. | def grid_search(verbose):
# Load Ising data.
Ising_Data = prepare_Ising_DNN()
# Perform grid search over learning rate and number of hidden neurons.
N_neurons=np.logspace(0,3,4).astype("int") # Check number of neurons over multiple decades.
learning_rates=np.logspace(-6,-1,6)
# Pre-allocate v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid_search(train_fun, decode_fun, eval_fun, train_set, dev_set, FLAGS):\n FLAGS.create_fresh_params = True\n\n hyperparameters = FLAGS.tuning.split(',')\n num_hps = len(hyperparameters)\n hp_range = hyperparam_range\n\n print(\"======== Grid Search ========\")\n print(\"%d hyperparameter(s):... | [
"0.6940125",
"0.6903616",
"0.678047",
"0.67030805",
"0.6629677",
"0.6530864",
"0.6529506",
"0.6354389",
"0.6334039",
"0.6317028",
"0.6215231",
"0.6210962",
"0.61947966",
"0.61233485",
"0.6083378",
"0.6068833",
"0.6054756",
"0.60233617",
"0.60059977",
"0.5999201",
"0.59955436"... | 0.7779989 | 0 |
Gets the next trash day for a given date | def next_regular_trash_day(date: str) -> str:
parsed_date = parser.parse(date)
day_of_week = parsed_date.weekday()
if day_of_week < TRASH_DAY:
delta = TRASH_DAY - day_of_week
elif day_of_week == TRASH_DAY:
delta = 0
else:
delta = 7 - (day_of_week - TRASH_DAY)
next_trash... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_day(date):\n return date + datetime.timedelta(days=1)",
"def next_day(date):\n return date + datetime.timedelta(days=1)",
"def _next_trading_day(self, day):\n next_day = self._trading_days.shift(-1)[day]\n return next_day if not pd.isnull(next_day) else None",
"def get_next_day(s... | [
"0.76969635",
"0.76969635",
"0.70977765",
"0.704082",
"0.66516757",
"0.6224729",
"0.6222216",
"0.61540645",
"0.6137545",
"0.6133715",
"0.6121568",
"0.59999067",
"0.59967107",
"0.59871405",
"0.59871405",
"0.5984374",
"0.58846253",
"0.58306783",
"0.579761",
"0.57365865",
"0.569... | 0.82727396 | 0 |
gets the next trash day taking holidays into consideration | def next_trash_day(date: str, holidays: list) -> dict:
next_regular = next_regular_trash_day(date)
weekdays = get_weekdays(next_regular)
default_trash_day = {'type': 'default', 'schedule': calendar.day_name[TRASH_DAY]}
if holiday.contains_holiday(weekdays):
holiday_name = holiday.get_holiday(wee... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_day(self):\n pass",
"def next_regular_trash_day(date: str) -> str:\n parsed_date = parser.parse(date)\n day_of_week = parsed_date.weekday()\n\n if day_of_week < TRASH_DAY:\n delta = TRASH_DAY - day_of_week\n elif day_of_week == TRASH_DAY:\n delta = 0\n else:\n ... | [
"0.70619345",
"0.69836265",
"0.69702566",
"0.6622131",
"0.64956003",
"0.6239636",
"0.6239636",
"0.6213379",
"0.61707443",
"0.61419547",
"0.61302257",
"0.61245453",
"0.6110192",
"0.6090458",
"0.6057315",
"0.60220957",
"0.6020746",
"0.60141313",
"0.5966333",
"0.5921652",
"0.590... | 0.7244827 | 0 |
Get `Tokenizer` and `Model` for a model name. | def get_tokenizer_and_model(model_name: str):
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name)
model.output_hidden_states = True
return tokenizer, model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model(model):\n all_models = cmd.get_object_list()\n\n if len(all_models) == 0:\n logging.parser_error('No models are opened.')\n return\n\n model = model.lower()\n\n if model and (model in all_models):\n return model\n\n if len(all_models) > 1:\n logging.parser_e... | [
"0.7199492",
"0.7023352",
"0.6884367",
"0.68522125",
"0.68059415",
"0.679673",
"0.678864",
"0.67526037",
"0.6655757",
"0.6638868",
"0.6599854",
"0.655437",
"0.6554283",
"0.65510416",
"0.6477091",
"0.6466176",
"0.64611083",
"0.64491063",
"0.6438798",
"0.6429388",
"0.64275306",... | 0.7214922 | 0 |
Return a list of all the activation norms. | def get_activation_norms(
parameters: List[Parameter], normalize: bool = True
) -> List[float]:
with torch.no_grad():
all_norms = []
for param in parameters:
if len(param.size()) != 2:
continue
norms = param.norm(dim=1, p=2)
if normali... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_weight_norms(self, sess, matrix_norm_fxn = lambda x: np.linalg.norm(x, ord = 1)):\n model_norms = []\n weights_list = self.get_weights_np(sess)\n for weights in weights_list:\n norm = matrix_norm_fxn(weights)\n model_norms.append(norm)\n return model_norms"... | [
"0.72380096",
"0.634995",
"0.6256386",
"0.6210975",
"0.61363864",
"0.6032762",
"0.6022503",
"0.5840832",
"0.58042806",
"0.570163",
"0.5697164",
"0.568862",
"0.56479114",
"0.56479114",
"0.56430805",
"0.5551576",
"0.5540852",
"0.5531631",
"0.55178106",
"0.5497287",
"0.54775363"... | 0.737135 | 0 |
Get an array of all weight magnitudes in the parameter list. | def get_weight_norms(parameters: List[Parameter]) -> np.ndarray:
with torch.no_grad():
norms = torch.cat([param.abs().flatten() for param in parameters])
return norms.numpy() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMagnitudes(self):\n return self._bmag, self._vmag, self._jmag, self._hmag, self._kmag",
"def get_params_as_list(self):\n\n\t\tparams = [self.shape_slope, self.z_thick, self.thick, self.length]\n\t\treturn params",
"def weights(self):\n return [x.numpy() for x in self.core.w]",
"d... | [
"0.6793161",
"0.6157048",
"0.61102766",
"0.605747",
"0.60502726",
"0.60382026",
"0.6035437",
"0.5940467",
"0.5813786",
"0.5808551",
"0.5779497",
"0.5756466",
"0.57503474",
"0.57503474",
"0.5745381",
"0.5709613",
"0.5707603",
"0.570318",
"0.570047",
"0.570047",
"0.5683576",
... | 0.65364444 | 1 |
Get a list of parameters tied to the embedding layer. | def get_embed_params(model) -> List:
return [param for name, param in model.named_parameters() if "embed" in name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameters(self):\n params = []\n for layer in (self.conv1, self.conv2, self.conv3, self.conv4, self.dense1, self.dense2):\n params += list(layer.parameters)\n return params",
"def get_params(self) -> torch.Tensor:\n params = []\n for pp in list(self.net.paramete... | [
"0.7535987",
"0.7381716",
"0.7132315",
"0.704354",
"0.7043289",
"0.7009622",
"0.7009622",
"0.70040184",
"0.6953776",
"0.691929",
"0.69050103",
"0.68977284",
"0.68977284",
"0.68977284",
"0.68977284",
"0.68977284",
"0.6875893",
"0.68742156",
"0.68739325",
"0.6872487",
"0.684921... | 0.78168494 | 0 |
Get dictionary of parameters partitioned by layer number. | def get_params_by_layer(model) -> Dict:
layers = defaultdict(list)
for name, param in model.named_parameters():
pieces = name.split(".")
if pieces[0] == "encoder" and pieces[1] == "block":
layer = int(pieces[2])
layers[layer].append(param)
return layers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameters_dict(self):\n return dict(zip(self.parameters_names(), self.parameters_list))",
"def get_all_params(layer):\n layers = get_all_layers(layer)\n params = sum([l.get_params() for l in layers], [])\n return utils.unique(params)",
"def get_layer_params(self):\n return self.laye... | [
"0.6692574",
"0.65567654",
"0.64245135",
"0.6398583",
"0.6372712",
"0.6344212",
"0.62882966",
"0.62654275",
"0.62573886",
"0.6213964",
"0.6201111",
"0.619871",
"0.6188635",
"0.61766535",
"0.6173816",
"0.6171546",
"0.61674243",
"0.6164119",
"0.6154546",
"0.6140772",
"0.6101595... | 0.70265716 | 0 |
Look for new photos on the google drive | def main():
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('drive', 'v3', http=http)
i = 0
total = 0
nextPageToken=None
while True:
results = service.files().list(
pageSize=30,
fields="nextPageToken, fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_pics(drive_service):\n pic_q = Queue()\n page_token = None\n while True:\n response = drive_service.files().list(q=\"mimeType='image/jpeg'\",\n spaces='drive',\n fields='nextPageToken, files(id, n... | [
"0.6759736",
"0.63333344",
"0.6305266",
"0.619666",
"0.6082265",
"0.59544337",
"0.58340144",
"0.5815916",
"0.57943195",
"0.5779238",
"0.5751527",
"0.56643534",
"0.5400818",
"0.53769857",
"0.53399146",
"0.52896446",
"0.5244849",
"0.5224103",
"0.5210007",
"0.51904804",
"0.51614... | 0.6790877 | 0 |
Linearly interpolate two setpoints. | def interpolate_setpoints(base_setpoint, other_setpoint, parameter):
time = parameter * base_setpoint.time + (1 - parameter) * other_setpoint.time
position = parameter * base_setpoint.position + (1 - parameter) * other_setpoint.position
velocity = parameter * base_setpoint.velocity + (1 - parame... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpolate(x0, y0, x1, y1, x):\n y = (y0 * (x1 - x) + y1 * (x - x0)) / (x1 - x0)\n\n return y",
"def linear_interpolation(self, pt1, pt2, unknown):\n\n #Write your code for linear interpolation here\n pt1,intensity1=pt1\n pt2,intensity2=pt2\n newPoint=unknown\n inten... | [
"0.7063411",
"0.70630324",
"0.7000477",
"0.6974235",
"0.67129767",
"0.670686",
"0.66866535",
"0.66817236",
"0.6674512",
"0.6645032",
"0.6635487",
"0.6578317",
"0.65730774",
"0.6544798",
"0.64888346",
"0.6453485",
"0.6449922",
"0.6442387",
"0.6439969",
"0.6434852",
"0.6425436"... | 0.71087044 | 0 |
Calculate overlap between two sets. The sets are acquired from data1 and data2 respectively. | def calc_overlap(data1, data2, label1=None, label2=None, index='dice'):
if label1 is not None:
positions1 = np.where(data1 == label1)
data1 = list(zip(*positions1))
if label2 is not None:
positions2 = np.where(data2 == label2)
data2 = list(zip(*positions2))
# calculate over... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cal_overlaps(boxes1, boxes2):\n area1 = (boxes1[:, 0] - boxes1[:, 2]) * (boxes1[:, 1] - boxes1[:, 3]) # (Nsample, 1)\n area2 = (boxes2[:, 0] - boxes2[:, 2]) * (boxes2[:, 1] - boxes2[:, 3]) # (Msample, 1)\n\n overlaps = np.zeros((boxes1.shape[0], boxes2.shape[0])) # (Nsample, Msample)\n\n # calcu... | [
"0.7035773",
"0.68398887",
"0.67753077",
"0.6746841",
"0.6734138",
"0.67296",
"0.6612416",
"0.6612416",
"0.6612416",
"0.6592445",
"0.6574849",
"0.6571463",
"0.6548481",
"0.6531469",
"0.6530407",
"0.64822507",
"0.64153165",
"0.6390756",
"0.6390756",
"0.6390756",
"0.6390756",
... | 0.7206123 | 0 |
Calculate overlaps for leaveoneout cross validation. Each sample has its own region of interest (ROI). For each iteration, overlap between the ROI in the left sample and the ROI in remaining samples | def loocv_overlap(X, prob, metric='dice'):
assert X.ndim == 2, 'The input X must be a 2D array!'
assert X.dtype == np.bool, "The input X's data type must be bool!"
n_samp, _ = X.shape
remain_idx_arr = np.ones((n_samp,), dtype=np.bool)
overlaps = np.zeros((n_samp,))
for left_idx in range(n_samp)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cal_overlaps(boxes1, boxes2):\n area1 = (boxes1[:, 0] - boxes1[:, 2]) * (boxes1[:, 1] - boxes1[:, 3]) # (Nsample, 1)\n area2 = (boxes2[:, 0] - boxes2[:, 2]) * (boxes2[:, 1] - boxes2[:, 3]) # (Msample, 1)\n\n overlaps = np.zeros((boxes1.shape[0], boxes2.shape[0])) # (Nsample, Msample)\n\n # calcu... | [
"0.6413197",
"0.63037324",
"0.5989347",
"0.5989347",
"0.5989347",
"0.58602446",
"0.5807427",
"0.5783705",
"0.5727257",
"0.5725394",
"0.5694002",
"0.5626981",
"0.5622222",
"0.56103057",
"0.56071097",
"0.5575048",
"0.5568868",
"0.55536425",
"0.5539821",
"0.5528622",
"0.552516",... | 0.65459293 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.