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 |
|---|---|---|---|---|---|---|
Return path to directory containing the static libraries of cudatoolkit. | def get_nvidia_static_cudalib_ctk():
nvvm_ctk = get_nvidia_nvvm_ctk()
if not nvvm_ctk:
return
env_dir = os.path.dirname(os.path.dirname(nvvm_ctk))
dirs = ('Lib', 'x64') if IS_WIN32 else ('lib',)
return os.path.join(env_dir, *dirs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_swagger_static_root():\n return os.path.join(CURDIR, \"static\")",
"def path_static():\n return os.path.abspath(os.path.dirname(__file__))+'/_static'",
"def get_library_dir():\n return os.path.join(get_script_path(), 'library')",
"def get_data_dir():\n rootdir = os.path.dirname(__file__)\... | [
"0.68122315",
"0.6640086",
"0.6551922",
"0.6528072",
"0.6446887",
"0.6348904",
"0.62596214",
"0.62104714",
"0.6146851",
"0.60442674",
"0.6012978",
"0.5958986",
"0.58856815",
"0.5839555",
"0.5814734",
"0.5752032",
"0.57089937",
"0.57079685",
"0.5699956",
"0.5696561",
"0.568550... | 0.70178443 | 0 |
Get paths of CUDA_HOME. If subdirs are the subdirectory name to be appended in the resulting path. | def get_cuda_home(*subdirs):
cuda_home = os.environ.get('CUDA_HOME')
if cuda_home is None:
# Try Windows CUDA installation without Anaconda
cuda_home = os.environ.get('CUDA_PATH')
if cuda_home is not None:
return os.path.join(cuda_home, *subdirs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_system_ctk(*subdirs):\n # Linux?\n if sys.platform.startswith('linux'):\n # Is cuda alias to /usr/local/cuda?\n # We are intentionally not getting versioned cuda installation.\n base = '/usr/local/cuda'\n if os.path.exists(base):\n return os.path.join(base, *sub... | [
"0.6631727",
"0.660277",
"0.6211807",
"0.5938572",
"0.5802841",
"0.5646154",
"0.56272364",
"0.55098796",
"0.55086154",
"0.54313904",
"0.53629893",
"0.53459567",
"0.5328437",
"0.5316581",
"0.5296917",
"0.52891093",
"0.52883",
"0.5284483",
"0.5277568",
"0.5274543",
"0.52417517"... | 0.79967487 | 0 |
Return the Debian NVIDIA Maintainerspackaged libdevice location, if it exists. | def get_debian_pkg_libdevice():
pkg_libdevice_location = '/usr/lib/nvidia-cuda-toolkit/libdevice'
if not os.path.exists(pkg_libdevice_location):
return None
return pkg_libdevice_location | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nvidia_libdevice_ctk():\n nvvm_ctk = get_nvidia_nvvm_ctk()\n if not nvvm_ctk:\n return\n nvvm_dir = os.path.dirname(nvvm_ctk)\n return os.path.join(nvvm_dir, 'libdevice')",
"def finddevice():\n\n return next((device for device in [\"xpu\"] if hasattr(torch, device) and getattr(t... | [
"0.69542927",
"0.60962075",
"0.59574044",
"0.5941244",
"0.59393704",
"0.5874612",
"0.58455604",
"0.57421875",
"0.5704779",
"0.5700641",
"0.5694083",
"0.5667781",
"0.5665686",
"0.5621846",
"0.55642825",
"0.55642825",
"0.55642825",
"0.55642825",
"0.5561773",
"0.55524904",
"0.55... | 0.8734438 | 0 |
Retorna un objeto de tipo Perfil del usuario que hace el pedido. Levanta excepcion Http404. | def get_object(self):
ActualUser = get_object_or_404(User, username=self.request.user)
return get_object_or_404(Perfil, usuario=ActualUser) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perfil(request):\n\n\n usuario=Usuario.objects.get(user_id=request.user.id)\n user = request.user\n auth0user = user.social_auth.filter(provider='auth0')[0]\n userdata = {\n 'user_id': auth0user.uid,\n 'name': user.first_name,\n 'estado': usuario.esta_aprobado,\n 'pictur... | [
"0.59300363",
"0.5834477",
"0.5834477",
"0.57052726",
"0.5685975",
"0.5679189",
"0.56763816",
"0.5658511",
"0.56567883",
"0.55985427",
"0.5584687",
"0.55678153",
"0.5555965",
"0.5523174",
"0.55191237",
"0.54652345",
"0.5457059",
"0.5433404",
"0.5433404",
"0.5426084",
"0.54190... | 0.75379956 | 0 |
Devuelve un objeto Perfil del usuario que hace el pedido Levanta excepcion Http404. | def get_object(self):
ActualUser = get_object_or_404(User, username=self.request.user)
return get_object_or_404(Perfil, usuario=ActualUser) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perfil(request):\n\n\n usuario=Usuario.objects.get(user_id=request.user.id)\n user = request.user\n auth0user = user.social_auth.filter(provider='auth0')[0]\n userdata = {\n 'user_id': auth0user.uid,\n 'name': user.first_name,\n 'estado': usuario.esta_aprobado,\n 'pictur... | [
"0.5768488",
"0.56627667",
"0.5527393",
"0.5505769",
"0.5443154",
"0.5356577",
"0.5303021",
"0.5287225",
"0.5275608",
"0.52565485",
"0.52489245",
"0.5232378",
"0.52033603",
"0.51964396",
"0.5178504",
"0.51627845",
"0.5162637",
"0.5137739",
"0.5114813",
"0.51119506",
"0.510457... | 0.67363834 | 0 |
Valida un formulario y guarda el registro recibido como parametro sobre el usuario logueado. | def form_valid(self, form):
usuario = form.save(commit=False)
usuario.usuario = User.objects.get(username=self.request.user)
usuario.save()
return HttpResponseRedirect(self.get_success_url()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_valid(self, form):\n user = form.save(commit=False)\n # print(user)\n messages.success(self.request, 'Successfully registered')\n user.save()\n login(self.request, user)\n return redirect('post:home')\n\n return kwargs",
"def form_valid(self, form, reques... | [
"0.62538505",
"0.61824876",
"0.6098952",
"0.6082391",
"0.60504246",
"0.6027836",
"0.60194594",
"0.6015788",
"0.58970803",
"0.5882522",
"0.583535",
"0.5812228",
"0.5778608",
"0.5759698",
"0.57482415",
"0.57266486",
"0.57169074",
"0.5695455",
"0.5663172",
"0.5626599",
"0.561353... | 0.65077573 | 0 |
Adds column header and scrollbars and combines them with the current table adding all to the master frame provided in constructor. Table is then redrawn. | def createTableFrame(self, callback=None):
# Add the table and header to the frame
self.tablerowheader = LargeRowHeader(self.parentframe, self)
self.tablecolheader = LargeColumnHeader(self.parentframe, self)
self.Yscrollbar = AutoScrollbar(self.parentframe, orient=VERTICAL, command=self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __place_table(self):\n\n base_x = self.__table_coords[\"x\"]\n base_y = self.__table_coords[\"y\"]\n base_height = self.__table_coords[\"height\"]\n base_width = self.__table_coords[\"width\"]\n headlines = [\" \"] + [str(x) for x in range(1, self.find_table_length() + 1)]\n ... | [
"0.6681995",
"0.6490527",
"0.61884373",
"0.60915476",
"0.60003984",
"0.5993402",
"0.5982692",
"0.5957703",
"0.5950346",
"0.5943269",
"0.59133244",
"0.59017205",
"0.587218",
"0.5831047",
"0.5782067",
"0.57106423",
"0.56948686",
"0.56909436",
"0.56567526",
"0.56553906",
"0.5651... | 0.74151075 | 0 |
Get the visible column range | def getVisibleCols(self, x1, x2):
start = self.getColPosition(x1)
end = self.getColPosition(x2) + 1
if end > self.cols:
end = self.cols
return start, end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_visible_cells(self):\r\n ux, uy = self.GetScrollPixelsPerUnit()\r\n sx, sy = self.GetViewStart()\r\n w, h = self.GetGridWindow().GetClientSize().Get()\r\n sx *= ux\r\n sy *= uy\r\n start_col = self.XToCol(sx)\r\n start_row = self.YToRow(sy)\r\n end_co... | [
"0.707298",
"0.6902809",
"0.6700858",
"0.6595008",
"0.650634",
"0.6288859",
"0.6270333",
"0.6256797",
"0.6243233",
"0.6127051",
"0.60789394",
"0.60119057",
"0.59667975",
"0.5964401",
"0.5956471",
"0.5939211",
"0.59348154",
"0.5904628",
"0.58691394",
"0.5851135",
"0.58139575",... | 0.72647125 | 0 |
Set the xview of table and col header | def set_xviews(self, *args):
self.xview(*args)
self.tablecolheader.xview(*args)
self.redrawVisible()
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_headers(self,executer, tree, cursor, table, columns_size):\n\n # Getting headers\n headers = executer.get_columns(table, cursor)\n tree[\"columns\"] = headers\n\n # Setting width to all column headers basing on columns amount.\n set_width = int(self.column_length_configur... | [
"0.6379965",
"0.62530154",
"0.6203541",
"0.6203541",
"0.6136738",
"0.60498506",
"0.59871495",
"0.59727997",
"0.5825335",
"0.5825335",
"0.5818333",
"0.5799224",
"0.578857",
"0.5781992",
"0.5777474",
"0.57380813",
"0.57033813",
"0.5697453",
"0.56715167",
"0.56708723",
"0.566634... | 0.79994017 | 0 |
Set function to be executed every time this window is toggled hidden/shown. | def set_on_toggle_hidden(self, on_toggle_hidden):
self.on_toggle_hidden = on_toggle_hidden | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ToggleVisible(self, event):\n pass",
"def toggle(self):",
"def toggle(self) -> None:\n ...",
"def toggleWindowVisibility(*args, **kwargs)->None:\n pass",
"def toggle(self) -> None:",
"def toggle(self) -> None:",
"def toggle_hidden(self):\n self.show_hidden = not self.show_hidd... | [
"0.6417303",
"0.60684586",
"0.6023648",
"0.6016456",
"0.60106647",
"0.60106647",
"0.6010533",
"0.5866378",
"0.5774059",
"0.5747065",
"0.57233655",
"0.5721329",
"0.5703353",
"0.56998634",
"0.56814325",
"0.5621253",
"0.56201285",
"0.5618225",
"0.556665",
"0.55503136",
"0.552018... | 0.65579814 | 0 |
Overriding update method to also update login window. | def update(self):
if not self.login is None:
if self.login.isAlive:
self.login.update()
else: # Login window was just closed
self.accFrame.update_values()
self.login = None
AbstractChild.update(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evt_login(self, event):\n if self.pair_correct(self.wgt_txt_login_user.GetValue(), self.wgt_txt_login_pass.GetValue()):\n self.parent.Hide()\n self.pane_landing.Show()\n self.parent.parent.SetSizer(self.szr_landing)\n self.parent.parent.Layout()\n else:... | [
"0.6385321",
"0.6359693",
"0.6340787",
"0.626191",
"0.625842",
"0.6205188",
"0.6185125",
"0.6001173",
"0.59811103",
"0.5976306",
"0.5903719",
"0.5897709",
"0.58765024",
"0.5859574",
"0.5857817",
"0.58435374",
"0.58405894",
"0.5815477",
"0.5792914",
"0.578056",
"0.57775563",
... | 0.80019075 | 0 |
Overriding toggle hidden function to also update values of this window's frames. | def toggle_hidden(self):
AbstractChild.toggle_hidden(self)
self.accFrame.update_values()
self.botFrame.update_values()
# On toggle hidden
self.on_toggle_hidden() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toggle_hidden(self):\n if self.hidden:\n self.show()\n else:\n self.hide()",
"def toggle_hidden(self):\n self.show_hidden = not self.show_hidden\n self.reload('.')",
"def do_hf_unhide(self, arg):\n self.show_hidden_frames = True\n self.refresh... | [
"0.7399713",
"0.72405815",
"0.7088366",
"0.69343615",
"0.68650293",
"0.66577417",
"0.6634899",
"0.6634899",
"0.66049457",
"0.66049457",
"0.65987873",
"0.657263",
"0.6546351",
"0.65328175",
"0.6531905",
"0.6456644",
"0.6416586",
"0.6407047",
"0.64038384",
"0.6393051",
"0.63799... | 0.7843108 | 0 |
Update `durations`, a dict of dict of lists of pull requests. | def get_duration_data(durations, owner_repo="edx/edx-platform", since=None):
open_issues_generator = itertools.izip(
get_pulls(owner_repo, state="open", org=True),
itertools.repeat("open")
)
closed_issues_generator = itertools.izip(
get_pulls(owner_repo, state="closed", since=since, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_timers(self, delta):\n new_timers = {}\n for t in self._timers.keys():\n new_timers[t + delta] = self._timers[t]\n self._timers.clear()\n self._timers = new_timers",
"def __update_current_measure_durations(self, duration: int) -> None:\n total_duration = s... | [
"0.53073287",
"0.5146095",
"0.51271504",
"0.4886934",
"0.48314863",
"0.4814732",
"0.48069423",
"0.47682565",
"0.4729387",
"0.46937558",
"0.46904564",
"0.46614078",
"0.46457514",
"0.4609241",
"0.459688",
"0.45498896",
"0.45457125",
"0.45383173",
"0.4523992",
"0.45236656",
"0.4... | 0.64028376 | 0 |
Add a protein with a PDB, code and | def add_prot(code, target, xtal_path, xtal, input_dict):
# Split code by : before the get or create operation and use the first part of the name (split[0])
# code is normally the xtal directory in the aligned folder, but this may have been modified to have
# an alternate name added to it - in the form 'dir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_protein( self, protein ):\n v = get_vertex( protein )\n if v: return v # already added",
"def dna_to_protein(seq):\n\n # Verify a convertible sequence\n if len(seq) % 3 != 0:\n raise RuntimeError('Total number of bases must be a multiple of 3')\n\n # Iterate through adding t... | [
"0.64399016",
"0.5670033",
"0.54493546",
"0.54008293",
"0.5362843",
"0.5350154",
"0.53209007",
"0.5317977",
"0.53175825",
"0.5303215",
"0.52984405",
"0.5288228",
"0.52671784",
"0.5254593",
"0.522837",
"0.5211319",
"0.5210247",
"0.5205723",
"0.5200957",
"0.5194791",
"0.5192633... | 0.6883254 | 0 |
Refresh the users for a given project by deleting all of them. Redundant if using iSpyB. | def delete_users(project):
for user_id in project.user_id.all():
project.user_id.remove(user_id.pk)
project.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_all_users(request):\n id_project = request.POST.get(\"project_id\")\n project = UtilsData.get_object_by_type_and_id(\"project\", id_project)\n if request.user.can_delete(project):\n roles = project.affecteds_set.all()\n for role in roles:\n if role.role not in (Affected... | [
"0.7266119",
"0.6693988",
"0.66053855",
"0.6487059",
"0.63297355",
"0.63088167",
"0.62710536",
"0.61194533",
"0.6093415",
"0.6081486",
"0.6009706",
"0.59416425",
"0.59289557",
"0.5863758",
"0.58465534",
"0.58461785",
"0.58394694",
"0.5836747",
"0.5823315",
"0.58197975",
"0.58... | 0.7483515 | 0 |
Add proposals and visits as projects for a given target. | def get_create_projects(target, proposal_ref, proposal_code='lb'):
# Note that in the loader this is based on information in the PROPOSALS and VISITS files
# TODO Multiple Visits can be defined in a file apparently - future improvement.
# TODO NB LIne above in delete_users - redundant if using ISPYB??.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_pp(self, arg):\n self.do_projects(arg)",
"def select_proposals(self):\r\n print \"Selecting proposals... \"\r\n global MAX_NUMBER_PROJECTS\r\n proposals_sorted = sorted(self.proposals, key=lambda project:project.likes, reverse=True)\r\n for i in range(MAX_NUMBER_PROJECTS... | [
"0.5410881",
"0.5407288",
"0.52270865",
"0.52270865",
"0.52270865",
"0.5210586",
"0.5194947",
"0.50674295",
"0.505153",
"0.50186455",
"0.49581373",
"0.48688206",
"0.48253044",
"0.48119506",
"0.4789279",
"0.47891718",
"0.47839138",
"0.4761073",
"0.4760999",
"0.4760814",
"0.475... | 0.6467684 | 0 |
Get the vectors for a given molecule | def get_vectors(mols):
vect_types = VectTypes()
for mol in mols:
if "." in mol.smiles:
logger.debug("SKIPPING - FRAGMENT: %s", mol.smiles)
continue
vectors = get_3d_vects_for_mol(mol.sdf_info)
for vect_type in vectors:
vect_choice = vect_types.translat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vectors(self):\n return self.vecs[:]",
"def vector(molec, dihed, nonH, energy):\n #Torison\n if dihed:\n pass\n #XYZ\n else:\n coords = ()\n if nonH:\n for atom in molec.atoms:\n coords += atom.coords\n else:\n for atom i... | [
"0.7083323",
"0.7006027",
"0.6598478",
"0.6481406",
"0.6439225",
"0.6435624",
"0.6397429",
"0.6388611",
"0.6374452",
"0.6355553",
"0.63145626",
"0.6299127",
"0.6278399",
"0.6161161",
"0.61597615",
"0.6104503",
"0.60972047",
"0.6094927",
"0.60678005",
"0.60490125",
"0.60312015... | 0.7255804 | 0 |
search for a molgroup by list of coordinates | def search_for_molgroup_by_coords(coords, target):
x = coords[0]
y = coords[1]
z = coords[2]
limit_list = []
for coord in x, y, z:
lower, upper = get_coord_limits(coord)
limit_list.append([lower, upper])
search = MolGroup.objects.filter(target_id__title=target, x_com__gte=lim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_groups_from_ctypes(self, mesh, ctypes):\n raise NotImplementedError",
"def find_exact_match(row, groups, match_cols):\n index = tuple(row[t] for t in match_cols)\n try:\n group = groups.get_group(index)\n except KeyError:\n return []\n clus = list(set(group.hotel_cluster... | [
"0.59095055",
"0.57509834",
"0.56964475",
"0.5656222",
"0.5626549",
"0.5608268",
"0.559361",
"0.5469414",
"0.54517496",
"0.54517496",
"0.5378664",
"0.5353408",
"0.5333075",
"0.53231955",
"0.5305053",
"0.5302384",
"0.5295839",
"0.5273223",
"0.526449",
"0.5255169",
"0.52304506"... | 0.7494911 | 0 |
Calculate the centre of the site's molecules based on the centre of mass | def calc_site_centre(rd_mols):
coms = [centre_of_mass(mol) for mol in rd_mols]
centre = centre_of_points(coms)
logger.debug('CENTRE: %s', centre)
return centre | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_molecule_center_of_mass(self):\n center_of_mass = np.zeros([3], dtype=float)\n masses = self._prmtop[\"MASS\"]\n for atom_ind in range(len(self._crd)):\n center_of_mass += masses[atom_ind] * self._crd[atom_ind]\n total_mass = masses.sum()\n if total_mass == 0:... | [
"0.769952",
"0.7631538",
"0.73653996",
"0.7218101",
"0.7181016",
"0.71449685",
"0.7141054",
"0.7112312",
"0.71018285",
"0.6969243",
"0.6898578",
"0.6887456",
"0.6861607",
"0.67939705",
"0.6758411",
"0.67555857",
"0.66412055",
"0.6636503",
"0.6582574",
"0.6568094",
"0.656536",... | 0.77714396 | 0 |
search for a molgroup by description | def search_for_molgroup_by_description(description, target):
search = MolGroup.objects.filter(target_id__title=target, description=description)
logger.debug("len(search)=%d", len(search))
if len(search) == 1:
mol_group = search[0]
elif len(search) > 1:
# Note that this will also set th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_020_query_groups(self):\n\n testflow.step(\"Querying for groups\")\n assert self.query_cli.run(\n what='group'\n )[0], \"Failed to search for groups\"",
"def group_describe(self, group):\n mapped = self.map_vects(datanorm)\n mappednp= np.array(mapped)\n ... | [
"0.5843368",
"0.56135756",
"0.5463794",
"0.54140854",
"0.53698933",
"0.5358017",
"0.5354256",
"0.5297383",
"0.5297368",
"0.51956767",
"0.5153298",
"0.51520944",
"0.51520944",
"0.5145656",
"0.5145108",
"0.51268834",
"0.51226366",
"0.5122467",
"0.5106349",
"0.5106155",
"0.50882... | 0.74397874 | 0 |
Update/Create mol_groups and molecule_tags with site information | def specifc_site(rd_mols, mols, target, site_description=None):
# look for molgroup with same target and description
mol_group = search_for_molgroup_by_description(target=target.title,
description=site_description)
if not mol_group:
mol_group = Mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_site_in_gme(self, projectNode, countryNodes, site, i):\n core = self.core\n siteNode = core.create_child(projectNode, self.META[\"Site\"])\n position_item = core.get_registry(projectNode, \"position\")\n position_item[\"y\"] = position_item[\"y\"] + 50 * i\n core.set_registry(siteNode, \"... | [
"0.55544835",
"0.506571",
"0.50160784",
"0.49909645",
"0.49212745",
"0.48970407",
"0.48649988",
"0.48467103",
"0.48318732",
"0.4804414",
"0.48017174",
"0.4796993",
"0.4781652",
"0.47556576",
"0.4721774",
"0.4715594",
"0.4668902",
"0.46504635",
"0.46460664",
"0.46218956",
"0.4... | 0.7153863 | 0 |
Check if molecules belong to a cluster or a specific site for a given target | def analyse_mols(mols, target, specified_site=False, site_description=None):
rd_mols = [Chem.MolFromMolBlock(x.sdf_info) for x in mols]
if not specified_site:
cluster_mols(rd_mols, mols, target)
else:
specifc_site(rd_mols, mols, target, site_description)
get_vectors(mols) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has(self, target):\n return target in self.by_target",
"def has(self, target):\r\n return target in self.by_target",
"def slaves_found(self):\n return not (len(self.topology) and self.topology[0][1] == [])",
"def specifc_site(rd_mols, mols, target, site_description=None):\n\n # look f... | [
"0.59099114",
"0.59013397",
"0.5811146",
"0.57644814",
"0.55539036",
"0.55014306",
"0.5476966",
"0.5355946",
"0.52600724",
"0.52568936",
"0.5252862",
"0.5233927",
"0.5230229",
"0.5219712",
"0.52128905",
"0.52125585",
"0.52089524",
"0.5197318",
"0.5186475",
"0.51463217",
"0.51... | 0.62854075 | 0 |
rename proteins based on the contents of alternatenames.csv (which has been created from metdata.csv | def rename_proteins(names_csv):
names_frame = pd.read_csv(names_csv)
for _, row in names_frame.iterrows():
mol_target = row['name']
alternate_name = row['alternate_name']
# Remove the replacement of '_0' - this was inconsistently applied as some folders are '_1'
# The Protein c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def final_rename(understat_no_similar, fpl_no_similar, join = 'inner'): \n name_mapper = {'Adrián':'Adrián Bernabé', # Contains both seasons corrections\n 'Alisson':'Alisson Ramses Becker',\n 'Allan':'Allan Marques Loureiro',\n 'André Gomes':'André Filipe... | [
"0.6262149",
"0.620358",
"0.59225214",
"0.58795476",
"0.5855679",
"0.5780732",
"0.57562983",
"0.57562983",
"0.5748717",
"0.56989646",
"0.56971043",
"0.56632984",
"0.5603336",
"0.5593263",
"0.55612004",
"0.5544447",
"0.55431473",
"0.5540265",
"0.5526973",
"0.55224794",
"0.5517... | 0.80773854 | 0 |
Calculate a relative path from the file path to the media root | def relative_to_media_root(filepath, media_root=settings.MEDIA_ROOT):
relative_path = os.path.relpath(filepath, media_root)
return relative_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_media_path(self, filename):\n return join(settings.CMS_PAGE_MEDIA_PATH, \"%d\" % self.id, filename)",
"def media_path(self):\n return self._path",
"def get_relative_pathname(self):\n return os.path.join(Exam.EXAM_FILES_LOCATION,\n str(self.unique_id)[0:2]... | [
"0.716648",
"0.7072237",
"0.7070012",
"0.70034564",
"0.6960707",
"0.69439507",
"0.694342",
"0.6929604",
"0.6818353",
"0.67295825",
"0.67267865",
"0.67257935",
"0.6722937",
"0.6715708",
"0.6683894",
"0.66819495",
"0.66751665",
"0.6658907",
"0.66423994",
"0.66352",
"0.6609155",... | 0.8047508 | 0 |
Analyse all the molecules for a particular target. | def analyse_target(target, aligned_path):
# Get Target from database
target.root_data_directory = relative_to_media_root(aligned_path)
target.save()
mols = list(Molecule.objects.filter(prot_id__target_id=target))
# This can probably be improved to count molecules as they are processed when the co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyse_mols(mols, target, specified_site=False, site_description=None):\n rd_mols = [Chem.MolFromMolBlock(x.sdf_info) for x in mols]\n if not specified_site:\n cluster_mols(rd_mols, mols, target)\n else:\n specifc_site(rd_mols, mols, target, site_description)\n\n get_vectors(mols)",
... | [
"0.62864506",
"0.55273044",
"0.53461725",
"0.53085685",
"0.52310586",
"0.515455",
"0.51431394",
"0.51272136",
"0.50833684",
"0.505777",
"0.4997364",
"0.49457228",
"0.49457228",
"0.4943795",
"0.49298733",
"0.48836672",
"0.48811308",
"0.4876747",
"0.4860567",
"0.48581758",
"0.4... | 0.65034586 | 0 |
Validate the metadata.csv file to check basic formatting is correct | def check_metadata(metadata_file, input_validate_dict):
validated = True
# Metedata.csv has the following columns:
# crystal_name: must not be spaces or null and should contain the RealCrystalName
# RealCrystalName: must not be spaces or null
# smiles: must not be null
# new_smiles: no specific ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_valid_csvformat(self, csv_path):\n with open(self.csv_path, \"rb+\") as file_obj:\n reader = csv.reader(file_obj, delimiter=',') # CSV DictReader object\n self.check_valid_csv_header(reader.next())\n self.check_valid_csv_data(reader.next())",
"def test_is_valid_... | [
"0.7094834",
"0.693815",
"0.68971455",
"0.68674195",
"0.6756951",
"0.67441386",
"0.67386234",
"0.67116493",
"0.66961503",
"0.6681226",
"0.66213435",
"0.6540441",
"0.6507407",
"0.6489792",
"0.6473728",
"0.63925356",
"0.63877565",
"0.63724947",
"0.6351833",
"0.63142306",
"0.630... | 0.7302781 | 0 |
Evaluate force and energy in python for Periodic. | def _evaluate_periodic(snapshot, params):
box = hoomd.Box(*snapshot.configuration.box)
positions = snapshot.particles.position
A = params['A']
i = params['i']
w = params['w']
p = params['p']
a1, a2, a3 = box.to_matrix().T
V = np.dot(a1, np.cross(a2, a3))
b1 = 2 * np.pi / V * np.cross... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_ttw_energy(self) -> None:\n\n self.energy = self.ecm.motive_energy_per_km(\n driving_mass=self[\"driving mass\"],\n rr_coef=self[\"rolling resistance coefficient\"],\n drag_coef=self[\"aerodynamic drag coefficient\"],\n frontal_area=self[\"frontal ar... | [
"0.6137717",
"0.6044311",
"0.59760916",
"0.5962495",
"0.5909589",
"0.582551",
"0.57956237",
"0.5791442",
"0.57832485",
"0.5759966",
"0.5754337",
"0.5751843",
"0.57382846",
"0.57323146",
"0.57047796",
"0.56934625",
"0.56874776",
"0.5665626",
"0.5659576",
"0.56581616",
"0.56119... | 0.6097572 | 1 |
Evaluate force and energy in python for ElectricField. | def _evaluate_electric(snapshot, params):
positions = snapshot.particles.position
charges = snapshot.particles.charge
E_field = params
energies = -charges * np.dot(positions, E_field)
forces = np.outer(charges, E_field)
return forces, energies | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_electric_field(self):\n self.set_grid()\n rho = self.grid.distribute(self.bunch.positions)\n rho *= self.bunch.line_charge_density * 4 # unknown origin\n phi = self.solver.get_potential(rho, self.bunch.line_charge_density)\n Ex, Ey = self.grid.gradient(-phi)\n ... | [
"0.6979177",
"0.6731371",
"0.6482822",
"0.64128745",
"0.6365258",
"0.6362616",
"0.63293177",
"0.62808794",
"0.6273513",
"0.62004024",
"0.6196962",
"0.6111015",
"0.60516304",
"0.60275024",
"0.60095674",
"0.59755975",
"0.596262",
"0.59490305",
"0.59482163",
"0.59235406",
"0.588... | 0.72647285 | 0 |
Assert the params of the external object match whats in the dict. | def _assert_correct_params(external_obj, param_attr, params):
if type(params) == dict:
for param in params.keys():
npt.assert_allclose(
getattr(external_obj, param_attr)['A'][param], params[param])
if type(params) == tuple:
npt.assert_allclose(getattr(external_obj, pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _assert_params_equals(self, url, param_dict):\n url_params = url_get_params(url)\n assert_equals(url_params, param_dict)",
"def test_validate_params(mocker, params):\n validate_params(**params)",
"def _assertParams(self) -> None:\n params = parse_qs(self.http_client.request.call_arg... | [
"0.7194935",
"0.7190007",
"0.6861588",
"0.6417681",
"0.6358602",
"0.6349058",
"0.6329792",
"0.63230383",
"0.6288156",
"0.62793636",
"0.6263622",
"0.6222141",
"0.61963415",
"0.61763614",
"0.61737525",
"0.61573094",
"0.6152412",
"0.61353236",
"0.6125796",
"0.6115335",
"0.610322... | 0.7591457 | 0 |
Get documentation string for this configuration | def get_doc_string(self) -> str:
r = "Undocumented"
if self.doc is not None: r = self.doc
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def documentation(self) -> str:\n return pulumi.get(self, \"documentation\")",
"def doc(self):\n doc = self.get('doc')\n if doc:\n from .config import defaults\n return defaults.types.doc(doc)",
"def documentation(self):\n return self.handle.__doc__",
"def ge... | [
"0.8267782",
"0.7552703",
"0.7545474",
"0.7456952",
"0.73271036",
"0.7129974",
"0.7098139",
"0.7057664",
"0.7055784",
"0.70394516",
"0.68911743",
"0.684487",
"0.68445027",
"0.6841313",
"0.68265826",
"0.67644143",
"0.6692945",
"0.66825646",
"0.6674594",
"0.6660667",
"0.6659072... | 0.7629708 | 1 |
Resolve the strings in the repo description and its stages, using the repo configuration's environment If resolve_fully is True then all the environment must resolve If resolve_fully is False then the URL, path and branch must resolve | def resolve(self, env:GripEnv, resolve_fully:bool=True, error_handler:ErrorHandler=None) -> None:
self.grip_repo_desc.base.add_log_string("Resolve repo '%s' in config '%s'"%(self.name, self.grip_config.name))
self.env = GripEnv(name="repo %s"%self.name, parent=env)
self.env.build_from_values(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve_ref(ref):\n if ref == DIRTY:\n return ref\n try:\n return git_rev_parse(ref)\n except CommandFailure:\n for remote in git_remote():\n try:\n return git_rev_parse('{remote}/{ref}'.format(**locals()))\n except CommandFailure:\n ... | [
"0.54447615",
"0.5355276",
"0.5341811",
"0.52984947",
"0.52957577",
"0.5100457",
"0.4885221",
"0.4863801",
"0.48408106",
"0.47952473",
"0.4756272",
"0.46724224",
"0.46047822",
"0.45708436",
"0.45521674",
"0.45461917",
"0.45224598",
"0.4522276",
"0.45165187",
"0.45096165",
"0.... | 0.75666535 | 0 |
Resolve relative (and those using environment variables?) git urls | def resolve_git_url(self, grip_git_url:GitUrl) -> None:
assert self._is_resolved
if self.git_url.is_leaf():
self.git_url.make_relative_to(abs_url=grip_git_url)
pass
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fix_repo_url():\n repo_url_git = 'git://github.com/Tinche/bower-cache'\n repo_url_https = 'https://github.com/Tinche/bower-cache'\n fixed_url_https = 'https://:@github.com/Tinche/bower-cache'\n assert repo_url_git == gitwrapper._fix_repo_url(repo_url_git)\n assert fixed_url_https == gitwrap... | [
"0.6905865",
"0.6465272",
"0.63995284",
"0.63346756",
"0.63076055",
"0.6199112",
"0.61906636",
"0.6154257",
"0.61487776",
"0.61288077",
"0.61084867",
"0.609824",
"0.6035324",
"0.6018412",
"0.6003314",
"0.5865326",
"0.583461",
"0.5826739",
"0.5811917",
"0.5784114",
"0.57677877... | 0.6919627 | 0 |
password The password. iterations The number of iterations of PBKDF2 (default=100000). returns a key | def make_key(password, iterations=ITERATIONS):
key = PBKDF2(password, SALT, dkLen=KEY_LENGTH_BYTES, count=iterations)
return key | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pbkdf2(password, salt, iterations, dklen=0, digest=None):\n if digest is None:\n digest = hashlib.sha256\n dklen = dklen or None\n password = force_bytes(password)\n salt = force_bytes(salt)\n return hashlib.pbkdf2_hmac(digest().name, password, salt, iterations, dklen)",
"def pbkdf2(pas... | [
"0.7508836",
"0.7408228",
"0.72142005",
"0.6800081",
"0.67509955",
"0.67296535",
"0.669605",
"0.6585402",
"0.6559936",
"0.6557969",
"0.6481103",
"0.6474474",
"0.6468353",
"0.6362947",
"0.6215115",
"0.6179237",
"0.6177522",
"0.6165302",
"0.6124966",
"0.608187",
"0.6069272",
... | 0.8685448 | 0 |
Creates an HMAC from the given message, using the given key. Uses HMACMD5. message The message to create an HMAC of. key The key to use for the HMAC (at least 16 bytes). returns A hex string of the HMAC. | def make_hmac(message, key):
h = HMAC.new(key)
h.update(message)
return h.hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_hmac(self, msg):\r\n return hmac.new(self.hmacKey, msg, sha256).digest()",
"def get_hmac(secret, message):\n return hmac.new(\n secret, message.encode('ascii'), digestmod=hashlib.sha256\n ).hexdigest()",
"def _hmac(self, key, msg):\n return hmac.new(key, msg, digestmod=self.hash... | [
"0.7477667",
"0.72997296",
"0.71323496",
"0.6831234",
"0.6760007",
"0.6723533",
"0.67172796",
"0.66682434",
"0.66546047",
"0.65924144",
"0.6565024",
"0.64207625",
"0.6401138",
"0.6389563",
"0.6375475",
"0.63350046",
"0.6037575",
"0.60342425",
"0.5973662",
"0.59505445",
"0.593... | 0.8378977 | 0 |
Decrypts a given ciphertext with the given key, using AESCFB. message The ciphertext to decrypt (byte string). key The AES key (16 bytes). iv The original IV used for encryption. returns The cleartext (byte string) | def decrypt(ciphertext, key, iv):
cipher = AES.new(key, AES.MODE_CFB, iv)
msg = cipher.decrypt(ciphertext)
return msg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt_cbc(key, ciphertext):\n\tmessage = ''\n\tfor i in range(0, len(ciphertext)/16 - 1):\n\t\tiv = ciphertext[i*16:(i+1)*16]\n\t\tinputblock = ciphertext[(i+1)*16:(i+2)*16]\n\t\tcipher = AES.new(key, AES.MODE_CBC, iv)\n\t\tmessage +=cipher.decrypt(inputblock)\n\tif ord(message[-1]) <=16:\n\t\tmessage = mess... | [
"0.77688974",
"0.7527659",
"0.748",
"0.74041873",
"0.7396227",
"0.7378443",
"0.7366361",
"0.7350202",
"0.7348135",
"0.7346627",
"0.723203",
"0.71131873",
"0.7042764",
"0.70285034",
"0.69840527",
"0.6957698",
"0.69559014",
"0.68933415",
"0.68483377",
"0.68203044",
"0.6804833",... | 0.87284034 | 0 |
Creates a preprocessing graph for a batch given a function that processes a single image. | def preprocess_batch(images_batch, preproc_func=None):
if preproc_func is None:
return images_batch
with tf.variable_scope('preprocess'):
images_list = tf.split(images_batch, int(images_batch.shape[0]))
result_list = []
for img in images_list:
reshaped_img = tf.reshape(img, img.shape[1:])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_tracking_preprocessing(input_shape):\n\n def preprocessing(input_img, **kwargs):\n\n to_normalize = False if np.percentile(input_img, 98) > 1.0 else True\n\n if len(input_img.shape) == 4:\n print(\n \"Only preprocessing single image, we will consider the first ... | [
"0.6597117",
"0.6509189",
"0.6342552",
"0.6341532",
"0.63325167",
"0.6088182",
"0.6045632",
"0.60382193",
"0.6022813",
"0.60152334",
"0.5975242",
"0.59513503",
"0.59479606",
"0.58793926",
"0.58744824",
"0.58571494",
"0.58446604",
"0.5805253",
"0.5803639",
"0.58029455",
"0.574... | 0.69064957 | 0 |
it flushes the queue containing the processed and chosen pages on the csv output file | def save(self):
if len(self.queue):
#logging.info('Saving %d pages' % len(self.queue))
for q in self.queue:
if q and q != '':
if self.output:
print >> self.output, q
else:
print q
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __csv_flush_record(self, all=False):\n data_file_name = self.data_file_name\n if all is True:\n data_file_name = data_file_name.split('all')[0] + 'csv'\n\n with io.open(data_file_name, 'a', encoding='utf-8') as data_file:\n if sys.version_info[0] < 3:\n ... | [
"0.62164724",
"0.61966234",
"0.61901706",
"0.60896474",
"0.60148954",
"0.6007137",
"0.59981954",
"0.5972252",
"0.5877508",
"0.5872668",
"0.58681136",
"0.5849548",
"0.5849548",
"0.5849548",
"0.5849548",
"0.5849548",
"0.5849548",
"0.5731122",
"0.57085747",
"0.5690632",
"0.56453... | 0.6936618 | 0 |
fp = Some derivative function of x and y x0 = Current x value y0 = Current y value ts = time step Returns y1 using RungeKutta method | def rk45(fp, x0, y0, ts):
k1 = fp(x0, y0)
k2 = fp(x0 +ts/2, y0+ts/2*k1)
k3 = fp(x0 +ts/2, y0+ts/2*k2)
k4 = fp(x0 +ts, y0+ts*k3)
return y0 + ts/6*(k1+2*k2+2*k3+k4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ret_f(t,y):\n\n f = np.zeros(3)\n f[0] = 77.27*(y(1) - y(0)*y(1)+ y(0)-8.375e-6*y(0)*y(0))\n f[1] = (1.0/77.27)*(-y(1)-y(0)*y(1)+y(2))\n f[2] = 0.161*(y(0)-y(2))\n\n return f",
"def runge_kutta(func, x0, time):\n dt = time[1] - time[0]\n x = np.array(x0)\n val = []\n\n for t in tim... | [
"0.6522133",
"0.64265984",
"0.6275279",
"0.62596136",
"0.62343985",
"0.61961025",
"0.61825293",
"0.61632925",
"0.6147124",
"0.6130278",
"0.6122552",
"0.6110482",
"0.61021954",
"0.6073846",
"0.60545695",
"0.6047062",
"0.6024261",
"0.6020555",
"0.6002816",
"0.59823495",
"0.5972... | 0.66746724 | 0 |
x = list of x values y = list of y values Returns integral of y over x. Assumes full lists / ran post simulation | def trapezoidalPost(x,y):
integral = 0
for ndx in range(1,len(x)):
integral+= (y[ndx]+y[ndx-1])/2 * (x[ndx]-x[ndx-1])
return integral | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def integrate(x, y, xmin, xmax):\n indexes = get_interval(x, xmin, xmax)\n integral = np.trapz(y[indexes], x[indexes])\n\n return integral",
"def integral(requestContext, seriesList):\n results = []\n for series in seriesList:\n newValues = []\n current = 0.0\n for val in series:\n if va... | [
"0.6894297",
"0.6820419",
"0.66159004",
"0.65011495",
"0.646472",
"0.63715506",
"0.636244",
"0.63209325",
"0.6220988",
"0.614587",
"0.6096252",
"0.60424936",
"0.59458",
"0.59325993",
"0.59302056",
"0.5927584",
"0.5856488",
"0.58477163",
"0.5845826",
"0.58155376",
"0.57960236"... | 0.6857058 | 1 |
Filter out url extracted locations with desired country | def locationFilter(locList, filterList, set_Country): # filter out location out of certain region
print('start filter location')
filteredLoc = []
for loc in locList:
print(loc[0])
if len(loc) > 0:
for l in loc[1]:
country = l.split(',')[2]
if set_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locFromText(set_Country, textList, filterList):\n loc = []\n print('Start extracting locations from texts')\n for t in textList:\n # print(row)\n text = t[1]\n if len(text) > 0:\n text = re.sub(r'[^\\w]', ' ', text) # remove symbol\n\n places = geograpy.get_... | [
"0.64201874",
"0.61067545",
"0.57039845",
"0.56817716",
"0.561799",
"0.5469821",
"0.5450577",
"0.5419892",
"0.53635603",
"0.53333396",
"0.5332225",
"0.5315806",
"0.530927",
"0.53071046",
"0.5266682",
"0.5266216",
"0.5244607",
"0.52394813",
"0.5220792",
"0.52131206",
"0.520778... | 0.66518736 | 0 |
Geocoding, assign road name to place name | def placeToRoad(placeName):
# sleep(2)
g = gmaps.geocode(placeName)
roadNo, roadName = '', ''
zipCode, coor_Lat, coor_Lng = None, None, None
if len(g) > 0:
for ac in g[0]['address_components']:
if ac['types'] and len(ac['types']) > 0:
if ac['types'][0] == 'street_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geo_coder(house_number, boro_code, street_name, zip_code): \r\n wa1 = '1B{}{}{}{}{}C{}{}'.format(rightpad(house_number, 16), rightpad('', 38), boro_code, rightpad('', 10), rightpad(street_name, 32), rightpad('', 113), rightpad(zip_code, 5))\r\n wa1 = rightpad(wa1, 1200)\r\n wa2 = rightpad('', 4300... | [
"0.6341097",
"0.6231902",
"0.6192851",
"0.61891156",
"0.6175963",
"0.6076743",
"0.6004888",
"0.5973303",
"0.594348",
"0.59281343",
"0.5834192",
"0.5829032",
"0.57439303",
"0.5721165",
"0.5709383",
"0.5661697",
"0.5651798",
"0.56299216",
"0.56124854",
"0.5551279",
"0.5521964",... | 0.7276688 | 0 |
Raises Brightness of the lights | def high_bri(self):
for light in self.lights:
bri = self.b.get_light(light,'bri')
bri = bri + 50
if bri > 255:
bri = 255
self.b.set_light(light,'bri',bri) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_brightness(image, value):\n\n return change_light(image, value, \"v\")",
"def set_brightness(self, value):\n self.parent.backlight.set_brightness(value)",
"def _update_brightness(self):\n while self.current_brightness != self.brightness:\n next_color = RGB(r=int(self.colo... | [
"0.71973896",
"0.705513",
"0.70402426",
"0.70310324",
"0.701834",
"0.69162804",
"0.6844577",
"0.6786708",
"0.6758496",
"0.67494047",
"0.6733191",
"0.6731852",
"0.67068326",
"0.6687837",
"0.66576874",
"0.664437",
"0.6625247",
"0.66169715",
"0.66129184",
"0.6609615",
"0.6609511... | 0.72851527 | 0 |
sets the output channel(s) | async def setoutput(self, ctx, chan: discord.Channel):
server = ctx.message.server
if server.id not in self.settings:
self.initial_config(server.id)
if server != chan.server:
return await self.bot.say("Stop trying to break this")
if chan.type != discord.ChannelTyp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_channels(self, input_channels):\n pass",
"def setDescriptorChannels(self, dch): # real signature unknown; restored from __doc__\n pass",
"def setup_channels():\n\n # Setup channel encoders\n for c in channels:\n channels[c].setup()\n print()",
"def setOutput(self):\n ... | [
"0.72299033",
"0.64462674",
"0.64258164",
"0.63945687",
"0.6370218",
"0.63673383",
"0.62871987",
"0.62329954",
"0.62027675",
"0.6178937",
"0.617732",
"0.61016273",
"0.6085347",
"0.5988352",
"0.59880155",
"0.5981772",
"0.5967146",
"0.59572315",
"0.59504193",
"0.59496784",
"0.5... | 0.75566965 | 0 |
Toggles whether the suggestion box is enabled or not | async def suggest_toggle(self, ctx):
server = ctx.message.server
if server.id not in self.settings:
self.initial_config(server.id)
self.settings[server.id]['inactive'] = \
not self.settings[server.id]['inactive']
self.save_json()
if self.settings[server.id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_searchEdit_textChanged(self, txt):\n self.searchButton.setEnabled(bool(txt))",
"def on_regex_search_toggle(self, event):\r\n\r\n if self.m_regex_search_checkbox.GetValue():\r\n update_autocomplete(self.m_searchfor_textbox, \"regex_search\")\r\n else:\r\n update_a... | [
"0.66412807",
"0.63028073",
"0.6129605",
"0.6072069",
"0.6049684",
"0.6030341",
"0.59515285",
"0.59128994",
"0.58037853",
"0.576306",
"0.5755912",
"0.5748368",
"0.5699508",
"0.56507903",
"0.5613166",
"0.56094223",
"0.5581917",
"0.5581336",
"0.55632037",
"0.554556",
"0.554556"... | 0.7504121 | 0 |
Get the request and client address from the socket, and wraps the connection in an SSL stream. | def get_request(
self,
) -> typing.Tuple[ssl.SSLSocket, typing.Tuple[str, int]]:
socket, addr = self.socket.accept()
stream = ssl.wrap_socket(
socket,
server_side=True,
keyfile=self.keyfile,
certfile=self.certfile,
ssl_version=self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssl_wrap_socket(socket, ssl_options, server_hostname=..., **kwargs):\n ...",
"def get_request(self):\n client_socket, address = self.socket.accept()\n if self.ssl_context:\n client_socket = self.ssl_context.wrap_socket(client_socket,\n ... | [
"0.71356076",
"0.68475354",
"0.6733499",
"0.6656914",
"0.6618129",
"0.62812626",
"0.6249632",
"0.61929065",
"0.6149828",
"0.6121964",
"0.6121661",
"0.6115878",
"0.6056641",
"0.5964749",
"0.5959794",
"0.5909478",
"0.5882002",
"0.5877713",
"0.5869282",
"0.5824944",
"0.58152556"... | 0.7671109 | 0 |
Combine script files basted on the path of the request. For a request for ``/gist.github.com.js``, tries to load ``gist.github.com.js`` as well as ``github.com.js`` and ``com.js``, in addition to the global ``default.js``. Returns the combined contents of the scripts found. | def build_body(self) -> str:
# Always include default.js
files = [os.path.join(self.directory, "default.js")]
# Find increasingly less specific files based on the request path.
paths = self.path.replace("/", "").split(".")
while paths:
files.append(os.path.join(self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_script(self,\n script_path,\n domain=\"raw.githubusercontent.com\",\n urlpath=_GITHUB_URLPATH):\n info = self.script_path(script_path)\n _fetch_script(info, script_path, domain, urlpath)\n return info",
"def get_source_fil... | [
"0.54122865",
"0.53973025",
"0.5321434",
"0.53174424",
"0.5260792",
"0.5172825",
"0.5163565",
"0.5132076",
"0.5092393",
"0.50862974",
"0.5047552",
"0.50348",
"0.4977795",
"0.49442473",
"0.49381855",
"0.4916476",
"0.49147418",
"0.489088",
"0.4888798",
"0.4885273",
"0.48759082"... | 0.5625085 | 0 |
Inspect the Origin header to see if it matches the path. | def detect_origin(self) -> typing.Optional[str]:
origin: typing.Optional[str] = self.headers.get("Origin")
if not origin or "://" not in origin:
return None
_, origin_host = origin.split("://", 1)
if ":" in origin_host:
origin_host, _ = origin_host.split(":")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_origin(self, origin):\n return True",
"def check_origin(self, origin):\n return True",
"def check_origin(self, origin):\n return True",
"def check_origin(self, origin):\n return True",
"def check_origin(self, origin):\n # import re\n # bool(re.match(r'^.*... | [
"0.6808445",
"0.6808445",
"0.6808445",
"0.6808445",
"0.64415884",
"0.6320489",
"0.6320489",
"0.6283557",
"0.62806875",
"0.6209452",
"0.60481757",
"0.60423523",
"0.5956921",
"0.5909411",
"0.5816535",
"0.5712817",
"0.5611696",
"0.5599866",
"0.5599866",
"0.5544079",
"0.5511452",... | 0.75541246 | 0 |
Return angles, axis pair that corresponds to rotation matrix m. The case where ``m`` is the identity matrix corresponds to a singularity where any rotation axis is valid. In that case, ``Vector([1, 0, 0])``, is returned. | def m2rotaxis(m):
eps = 1e-5
# Check for singularities a la http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/
if (
abs(m[0, 1] - m[1, 0]) < eps
and abs(m[0, 2] - m[2, 0]) < eps
and abs(m[1, 2] - m[2, 1]) < eps
):
# Singularity encountered.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rotate_(self, x: np.array, m: np.array) -> (np.array, np.array):\n # get a random angle\n angle = np.random.randint(0, self.rotate)\n # get a random sign for the angle\n sign = np.random.randint(0, 2)\n x = rotate(x, -sign * angle, reshape=False)\n m = rotate(m, -sign... | [
"0.663678",
"0.62896967",
"0.6157976",
"0.6006294",
"0.59815663",
"0.5924986",
"0.5909249",
"0.58380806",
"0.58301306",
"0.5824258",
"0.57651687",
"0.57651037",
"0.5755777",
"0.57331914",
"0.57147455",
"0.5714623",
"0.5711759",
"0.57107013",
"0.5710682",
"0.5695341",
"0.5695"... | 0.8007706 | 0 |
Vector to axis method. Return the vector between a point and the closest point on a line (ie. the perpendicular projection of the point on the line). | def vector_to_axis(line, point):
line = line.normalized()
np = point.norm()
angle = line.angle(point)
return point - line ** (np * numpy.cos(angle)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_direction_vector(line):\n pt1, pt2 = line\n pt1 = np.array(pt1).reshape(2,)\n pt2 = np.array(pt2).reshape(2,)\n direct = pt2 - pt1\n direct_norm = normalize(direct)\n return direct_norm",
"def project_point_line(point, line):\n a, b = line\n ab = subtract_vectors(b, a)\n ap = ... | [
"0.7509544",
"0.7091944",
"0.701979",
"0.6911473",
"0.68514013",
"0.67952347",
"0.6784686",
"0.66677094",
"0.65612835",
"0.64763176",
"0.64715296",
"0.64650273",
"0.6458402",
"0.6456651",
"0.6448089",
"0.642346",
"0.6413407",
"0.6406169",
"0.63755524",
"0.6344475",
"0.6296930... | 0.8516493 | 0 |
Return a (left multiplying) matrix that rotates p onto q. | def rotmat(p, q):
rot = numpy.dot(refmat(q, -p), refmat(p, -p))
return rot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quat_rotate(X, q):\n # repeat q along 2nd dim\n ones_x = X[[0], :, :][:, :, [0]] * 0 + 1\n q = torch.unsqueeze(q, 1) * ones_x\n\n q_conj = torch.cat([q[:, :, [0]], -1 * q[:, :, 1:4]], dim=-1)\n X = torch.cat([X[:, :, [0]] * 0, X], dim=-1)\n\n X_rot = hamilton_product(q, hamilton_product(X, q_... | [
"0.7235314",
"0.7235314",
"0.6990883",
"0.69877553",
"0.69679874",
"0.6881361",
"0.6804596",
"0.6750322",
"0.6703256",
"0.6547457",
"0.6546621",
"0.6531093",
"0.6472698",
"0.63746524",
"0.6359099",
"0.6341709",
"0.63394356",
"0.6274029",
"0.624419",
"0.6177997",
"0.61512566",... | 0.8370842 | 0 |
Calculate angle method. Calculate the angle between 3 vectors representing 3 connected points. | def calc_angle(v1, v2, v3):
v1 = v1 - v2
v3 = v3 - v2
return v1.angle(v3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcul_angle(point1, point2, point3):\n \n x1,y1,z1=point1\n x2,y2,z2=point2\n x3,y3,z3=point3\n \n vec1=[x1-x2, y1-y2, z1-z2]\n vec2=[x3-x2, y3-y2, z3-z2]\n\n return calcul_angle_vector(vec1, vec2)",
"def get_angle(pt1,pt2,pt3):\r\n a = float(get_distance(pt1,pt2))\r\n b = ... | [
"0.7981472",
"0.7753118",
"0.76024896",
"0.7592898",
"0.7543423",
"0.74118024",
"0.73399997",
"0.7231473",
"0.7139338",
"0.7095912",
"0.70290226",
"0.6875393",
"0.68628615",
"0.6811979",
"0.6781552",
"0.67007625",
"0.66819406",
"0.66541386",
"0.6647638",
"0.6644245",
"0.66415... | 0.79181033 | 1 |
Calculate dihedral angle method. Calculate the dihedral angle between 4 vectors representing 4 connected points. The angle is in ]pi, pi]. | def calc_dihedral(v1, v2, v3, v4):
ab = v1 - v2
cb = v3 - v2
db = v4 - v3
u = ab ** cb
v = db ** cb
w = u ** v
angle = u.angle(v)
# Determine sign of angle
try:
if cb.angle(w) > 0.001:
angle = -angle
except ZeroDivisionError:
# dihedral=pi
pass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dihedral_calculator():\n\n\t# Prime with first 3 points\n\tp1 = Vector3((yield None))\n\tp2 = Vector3((yield None))\n\tp3 = Vector3((yield None))\n\n\t# Set up for first angle\n\tlastpoint = p3\n\tlastdisp = p3 - p2\n\tlastnormal = ((p2 - p1) @ lastdisp).normalize()\n\n\tangle = None\n\n\t# For each point star... | [
"0.8227105",
"0.7010041",
"0.6948374",
"0.66514385",
"0.6404093",
"0.6321645",
"0.6247588",
"0.6223799",
"0.6211882",
"0.61957514",
"0.61255556",
"0.60270005",
"0.598636",
"0.5953265",
"0.5933423",
"0.59146756",
"0.5819998",
"0.58028436",
"0.57949847",
"0.5760357",
"0.574049"... | 0.8613842 | 0 |
Return value of array index i. | def __getitem__(self, i):
return self._ar[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, i):\n\t\tif i < self.n:\n\t\t\treturn self.v[i]",
"def __getitem__(self, i):\n return self.get(i, i + 1)",
"def __getitem__(self, i):\n return self.data[i]",
"def __getitem__(self, i):\n return self.__x[i]",
"def xval(self, i):\n return self.x[i]",
"def _... | [
"0.7630643",
"0.7395586",
"0.73718834",
"0.7324915",
"0.727493",
"0.7198595",
"0.71864104",
"0.6988594",
"0.6973699",
"0.69633764",
"0.6930768",
"0.6863983",
"0.6862375",
"0.68333304",
"0.67888004",
"0.67888004",
"0.6754036",
"0.67357033",
"0.6730818",
"0.6709809",
"0.6709809... | 0.7823676 | 0 |
Assign values to array index i. | def __setitem__(self, i, value):
self._ar[i] = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setitem__(self, i, val):\n\t\tif i < self.n:\n\t\t\tself.v[i] = val",
"def assignMoreVectors(self, i):\n return",
"def __setitem__(self, inds, value):\n i, j = inds\n self.array[i][j] = value",
"def __setitem__(self,i,v):\n _items[i] = v",
"def i(self, i):\n\n self.... | [
"0.73695976",
"0.68885285",
"0.686191",
"0.67810804",
"0.67465854",
"0.6717178",
"0.6495393",
"0.6471185",
"0.6410022",
"0.638259",
"0.6255025",
"0.62211835",
"0.61497325",
"0.6143243",
"0.6138627",
"0.6102501",
"0.60960704",
"0.60622686",
"0.60607976",
"0.60226876",
"0.60167... | 0.7562142 | 0 |
Validate if i is in array. | def __contains__(self, i):
return i in self._ar | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkElementInArray(element,array):\n\t\n\texists = False\n\t\n\tfor i in array:\n\t\n\t\tif i == element:\n\t\t\texists = True\n\n\treturn exists",
"def arrayContains(arr, item):\n\tcontains = True\n\ttry:\n\t\tarr.index(item)\n\texcept ValueError:\n\t\tcontains = False\n\treturn contains",
"def in_array(... | [
"0.6500306",
"0.64386773",
"0.62485456",
"0.62156224",
"0.6165227",
"0.6158595",
"0.60294133",
"0.58980155",
"0.5880824",
"0.58586836",
"0.58278084",
"0.5720893",
"0.5711022",
"0.5681861",
"0.566563",
"0.5652514",
"0.5647837",
"0.5602884",
"0.5552213",
"0.55297995",
"0.549852... | 0.70314944 | 0 |
Return a deep copy of the Vector. | def copy(self):
return Vector(self._ar) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone(self):\n v = self.mV[:]\n return Vector.fromSequence(v)",
"def copy(self):\n return Vector(self.x, self.y)",
"def Copy(self) -> BaseVector:",
"def deepcopy(self):\n return self.copy()",
"def deepcopy(self):\n return copy.deepcopy(self)",
"def copy(self):\n\t\t... | [
"0.83562434",
"0.8350245",
"0.8067865",
"0.7411623",
"0.7331414",
"0.73207086",
"0.7280997",
"0.72413135",
"0.72351533",
"0.7163208",
"0.7163208",
"0.7163208",
"0.7163208",
"0.7163208",
"0.7163208",
"0.7163208",
"0.7163208",
"0.7163208",
"0.7163208",
"0.7163208",
"0.7163208",... | 0.8383834 | 0 |
Compute spherical coordinates (r, azimuth, polar_angle) for X,Y,Z point. | def get_spherical_coordinates(xyz: numpy.array) -> Tuple[float, float, float]:
r = numpy.linalg.norm(xyz)
if 0 == r:
return (0, 0, 0)
azimuth = _get_azimuth(xyz[0], xyz[1])
polar_angle = numpy.arccos(xyz[2] / r)
return (r, azimuth, polar_angle) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cartesianToSpherical(x=0, y=0, z=0):\n\n hxy = np.hypot(x, y)\n radius = np.hypot(hxy, z)\n altitude = np.arctan2(z, hxy)\n azimuth = np.arctan2(y, x)\n return altitude, azimuth, radius",
"def cartesian_to_spherical(x, y, z):\n import math\n\n xsq = x ** 2\n ysq = y ** 2\n zsq = z ... | [
"0.8174543",
"0.74399215",
"0.73569125",
"0.73225564",
"0.70352703",
"0.701186",
"0.6950183",
"0.69103575",
"0.69003415",
"0.68811667",
"0.68668544",
"0.6825777",
"0.68175334",
"0.68068254",
"0.6771065",
"0.6755179",
"0.67518723",
"0.6618703",
"0.65975374",
"0.655547",
"0.654... | 0.7569556 | 1 |
Create [entries] numpy Z rotation matrices for [entries] angles. | def multi_rot_Z(angle_rads: numpy.ndarray) -> numpy.ndarray:
rz = numpy.empty((angle_rads.shape[0], 4, 4))
rz[...] = numpy.identity(4)
rz[:, 0, 0] = rz[:, 1, 1] = numpy.cos(angle_rads)
rz[:, 1, 0] = numpy.sin(angle_rads)
rz[:, 0, 1] = -rz[:, 1, 0]
return rz | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_rotation_matrix(x_angle, y_angle, z_angle):\n return np.array([\n [1, 0, 0],\n [0, np.cos(x_angle), -np.sin(x_angle)],\n [0, np.sin(x_angle), np.cos(x_angle)],\n ]).dot([\n [np.cos(y_angle), 0, np.sin(y_angle)],\n [0, 1, 0],\n ... | [
"0.68653584",
"0.6794344",
"0.6746414",
"0.66585994",
"0.6635431",
"0.6586524",
"0.6530783",
"0.651046",
"0.64896053",
"0.6478563",
"0.6458148",
"0.6396228",
"0.6392338",
"0.6383424",
"0.6383424",
"0.6374706",
"0.6374706",
"0.6374706",
"0.6250182",
"0.62475044",
"0.62475044",... | 0.71370095 | 0 |
Create [entries] numpy Y rotation matrices for [entries] angles. | def multi_rot_Y(angle_rads: numpy.ndarray) -> numpy.ndarray:
ry = numpy.empty((angle_rads.shape[0], 4, 4))
ry[...] = numpy.identity(4)
ry[:, 0, 0] = ry[:, 2, 2] = numpy.cos(angle_rads)
ry[:, 0, 2] = numpy.sin(angle_rads)
ry[:, 2, 0] = -ry[:, 0, 2]
return ry | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_sample_rot_matrix(self, angles):\n (phi, chi, omega) = angles[0:3]\n return numpy_utils.rotation_matrix(phi, chi, omega)",
"def make_sample_rot_matrix(self, angles):\n (phi, chi) = angles[0:2]\n omega = np.deg2rad(self.omega)\n return numpy_utils.rotation_matrix(phi, c... | [
"0.6704496",
"0.66379946",
"0.6614366",
"0.6525721",
"0.6497145",
"0.6497145",
"0.6497145",
"0.6494217",
"0.6494217",
"0.63507354",
"0.63133836",
"0.6302495",
"0.62334675",
"0.61759055",
"0.61702144",
"0.6167026",
"0.6162391",
"0.6145289",
"0.6126853",
"0.6108908",
"0.6088657... | 0.6921952 | 0 |
2 ways of defining set | def define_set():
set_1 = set([1, 2, 3])
print type(set_1)
print set_1
set_2 = {2, 3, 2}
print type(set_2)
# <type 'set'>
print set_2
# set([2, 3])
a = set((1, 2, 3, 4))
b = set([3, 4, 5, 6])
print a | b # Union
# {1, 2, 3, 4, 5, 6}
print a & b # Intersection
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set():",
"def set():\n pass",
"def set(x):\n pass",
"def test_set_creation():\r\n test_list = [1, 2, 1, 3] # it is alist\r\n set1 = set(test_list)\r\n assert {1,2,3} == set1 # randomly arranged and don't allow duplicates\r\n\r\n test_string = \"apple\"\r\n set2 = set(test_string)\r\n... | [
"0.80757755",
"0.7471948",
"0.7425762",
"0.70587444",
"0.6936791",
"0.6936791",
"0.6876868",
"0.6673173",
"0.6640021",
"0.663485",
"0.6614221",
"0.6581556",
"0.65792",
"0.6541001",
"0.6405655",
"0.63981545",
"0.6355021",
"0.6317065",
"0.63162047",
"0.6313064",
"0.62325305",
... | 0.7948503 | 1 |
Tests that the process method invokes the correct GRR API calls. | def testProcess(self):
self.grr_hunt_file_collector.PreProcess()
self.grr_hunt_file_collector.Process()
# extract call kwargs
call_kwargs = self.mock_grr_api.CreateHunt.call_args[1]
self.assertEqual(call_kwargs['flow_args'].paths,
['/etc/passwd', '/etc/shadow', '/etc/hosts'])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testProcess(self):\n self.grr_hunt_osquery_collector.Process()\n # extract call kwargs\n call_kwargs = self.mock_grr_api.CreateHunt.call_args[1]\n self.assertEqual(call_kwargs['flow_args'].query,\n 'SELECT * FROM processes')\n self.assertEqual(call_kwargs['flow_args'].timeout... | [
"0.7084944",
"0.6597489",
"0.6498858",
"0.6480054",
"0.6472296",
"0.63703793",
"0.63314945",
"0.6231056",
"0.621261",
"0.6134163",
"0.6015268",
"0.6010355",
"0.59589803",
"0.5906601",
"0.5904283",
"0.5899668",
"0.5875687",
"0.5854556",
"0.58414304",
"0.58292466",
"0.5740823",... | 0.66623306 | 1 |
Tests that the process method invokes the correct GRR API calls. | def testProcess(self):
self.grr_hunt_osquery_collector.Process()
# extract call kwargs
call_kwargs = self.mock_grr_api.CreateHunt.call_args[1]
self.assertEqual(call_kwargs['flow_args'].query,
'SELECT * FROM processes')
self.assertEqual(call_kwargs['flow_args'].timeout_millis,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testProcess(self):\n self.grr_hunt_file_collector.PreProcess()\n self.grr_hunt_file_collector.Process()\n # extract call kwargs\n call_kwargs = self.mock_grr_api.CreateHunt.call_args[1]\n self.assertEqual(call_kwargs['flow_args'].paths,\n ['/etc/passwd', '/etc/shadow', '/etc/... | [
"0.66623306",
"0.6597489",
"0.6498858",
"0.6480054",
"0.6472296",
"0.63703793",
"0.63314945",
"0.6231056",
"0.621261",
"0.6134163",
"0.6015268",
"0.6010355",
"0.59589803",
"0.5906601",
"0.5904283",
"0.5899668",
"0.5875687",
"0.5854556",
"0.58414304",
"0.58292466",
"0.5740823"... | 0.7084944 | 0 |
Tests that hunt results are correctly extracted. | def testExtractHuntResults(self, _, mock_remove):
self.grr_hunt_downloader.output_path = '/directory'
expected = sorted([
('greendale-student04.c.greendale.internal',
'/directory/hunt_H_A43ABF9D/C.4c4223a2ea9cf6f1'),
('greendale-admin.c.greendale.internal',
'/directory/hunt_H_A... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testCollectHuntResults(self,\n mock_get_write_archive,\n mock_ExtractHuntResults):\n self.mock_grr_api.Hunt.return_value.Get.return_value = \\\n mock_grr_hosts.MOCK_HUNT\n self.grr_hunt_downloader.Process()\n mock_get_write_archive.assert_... | [
"0.6822283",
"0.66746986",
"0.6442038",
"0.6374539",
"0.62894946",
"0.62524617",
"0.6248636",
"0.6225992",
"0.62244165",
"0.61812615",
"0.6111694",
"0.60976326",
"0.6070672",
"0.6062699",
"0.6052158",
"0.603377",
"0.5992978",
"0.59575725",
"0.5954192",
"0.5941559",
"0.5938896... | 0.741359 | 0 |
Test the negative sampling self adversarial loss function. | def test_negative_sampling_self_adversarial_loss(self):
loss_fct = NSSALoss(margin=1.0, adversarial_temperature=1.0)
self.assertIs(loss_fct._reduction_method, torch.mean)
pos_scores = torch.tensor([0.0, 0.0, -0.5, -0.5])
neg_scores = torch.tensor([0.0, 0.0, -1.0, -1.0])
# ≈ res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_non_zero_loss(self):\n # Reset models.\n self.model.load_state_dict(self.initial_model_dict)\n self.actor_model.load_state_dict(self.initial_actor_model_dict)\n\n polybeast.learn(*self.learn_args)\n\n self.assertNotEqual(self.stats[\"total_loss\"], 0.0)\n self.ass... | [
"0.6969207",
"0.69518435",
"0.6858083",
"0.6652001",
"0.6562485",
"0.6560385",
"0.6536775",
"0.6470992",
"0.6404801",
"0.63875115",
"0.6325799",
"0.6324553",
"0.63079697",
"0.6183252",
"0.61738074",
"0.6160125",
"0.615615",
"0.61495835",
"0.6144141",
"0.6114965",
"0.61058164"... | 0.7992889 | 0 |
Test the pipeline on RotatE with negative sampling self adversarial loss and nations. | def test_pipeline(self):
loss = NSSALoss
loss_kwargs = {"margin": 1.0, "adversarial_temperature": 1.0}
pipeline_results = pipeline(
model="RotatE",
dataset="nations",
loss=loss,
loss_kwargs=loss_kwargs,
training_kwargs=dict(use_tqdm=Fal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test(self):\n # Load the trained models.\n self.train_ev_ea()\n self.restore_model(self.test_iters)\n self.encoder_v.eval()\n # Set data loader.\n data_loader = self.data_loader\n empty = torch.FloatTensor(1, 3,self.image_size,self.image_size).to(self.device) \n... | [
"0.65215564",
"0.6213105",
"0.6165407",
"0.613751",
"0.6076847",
"0.5993722",
"0.59619707",
"0.5953103",
"0.594722",
"0.59443706",
"0.59269637",
"0.59047973",
"0.5888924",
"0.586419",
"0.58521694",
"0.58508056",
"0.5788468",
"0.57867897",
"0.57517517",
"0.57516396",
"0.574104... | 0.7003118 | 0 |
Assert that the refund request event works. | async def test_refund_request(app, session, stan_server, event_loop, client_id, events_stan, future):
# Call back for the subscription
from account_mailer.worker import cb_subscription_handler
# vars
invoice_id = '1'
events_subject = 'test_subject'
events_queue = 'test_queue'
events_durable... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_refund_request(app, session, stan_server, event_loop, client_id, events_stan, future):\n # Call back for the subscription\n from account_mailer.worker import cb_subscription_handler\n\n # vars\n invoice_id = '1'\n\n events_subject = 'test_subject'\n events_queue = 'test_queue'\n ... | [
"0.7186693",
"0.661709",
"0.6575661",
"0.6517174",
"0.64606166",
"0.6411402",
"0.63819194",
"0.634786",
"0.6343884",
"0.62957674",
"0.62583494",
"0.6201193",
"0.6201193",
"0.61731523",
"0.61508113",
"0.61438215",
"0.6119798",
"0.611924",
"0.6054042",
"0.60197675",
"0.5991011"... | 0.7257154 | 0 |
Tell if a process is running. The proc object is cached so it doesn't need to be looked up every time. | def is_process_running(name):
if not hasattr(is_process_running, "proc"):
is_process_running.proc = None # it doesn't exist yet, so init it
if is_process_running.proc:
if is_process_running.proc.is_running():
return True
else:
is_process_running.proc = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_proc_running(name):\n\n for p in psutil.process_iter(['name']):\n if p.info['name'] == name:\n return True\n\n return False",
"def is_running(self):\r\n if self._gone:\r\n return False\r\n try:\r\n # Checking if pid is alive is not enough as the ... | [
"0.7895711",
"0.7814375",
"0.7768379",
"0.77449167",
"0.7729471",
"0.7717063",
"0.77083045",
"0.77081454",
"0.7664434",
"0.7623029",
"0.75754946",
"0.75263417",
"0.742384",
"0.7372659",
"0.7331689",
"0.72935724",
"0.7286316",
"0.72350216",
"0.7228423",
"0.7215268",
"0.7159771... | 0.8501636 | 0 |
Processing for the endpoint /content which handles the content form | def content_index():
form = ContentForm()
# POST - Following block executes to handle submission of ContentForm
if form.validate_on_submit():
# content type choice is extracted from the form
choice = form.content_type.data # content type choice by user
choices = dict(ContentForm.S... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getContent(self) -> object:\n ...",
"def get_content(self) -> Content:\n pass",
"def content(request):\n if not request.method in ('GET', 'POST'):\n raise Http404(\"Invalid method: {}\".format(request.method))\n\n if not authuser_is_user(request.user):\n raise Http404(\"Us... | [
"0.68734026",
"0.65634793",
"0.6559953",
"0.65355384",
"0.64136237",
"0.6392098",
"0.62899566",
"0.6207141",
"0.61433744",
"0.6108671",
"0.6087179",
"0.60673165",
"0.606479",
"0.60591775",
"0.60088414",
"0.60057867",
"0.59966636",
"0.5988125",
"0.5975663",
"0.5925643",
"0.590... | 0.7183763 | 0 |
Processing for the endpoint /content/edit?content_id= | def handle_content_edit(content_id):
# instance of ContentForm is available to both GET and POST requests
form = ContentForm()
# content will be None if it cannot be found
content = Content.find_by_id(content_id)
# POST - for handling the edit content form
if form.validate_on_submit():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit(id):\n r = requests.get(API_ROUTE + '/' + str(id), headers={'Auth': _auth()})\n if r.status_code != requests.codes.ok:\n return r.text, r.status_code\n\n return render_template('editor.html', article=r.json())",
"def edit(self, new_content: object, reason: str = \"\") -> None:\n r... | [
"0.7016044",
"0.6976376",
"0.6733984",
"0.6700269",
"0.66533476",
"0.6566476",
"0.648935",
"0.6471998",
"0.64241326",
"0.64086014",
"0.6263412",
"0.6224103",
"0.6202934",
"0.6191035",
"0.6189695",
"0.6159472",
"0.6140995",
"0.61282784",
"0.61214674",
"0.61054313",
"0.6101587"... | 0.7805241 | 0 |
Processing for the endpoint /content/delete to delete a content | def handle_content_delete(content_id):
content = Content.find_by_id(content_id)
# flash error message if content does not exist
if not content:
flash(f'Content does not exist!', 'danger')
return 'not deleted', 404
# content is deleted and user is redirected (redirect code in content.js... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(request, content_type, object_id):\n user = request.user\n content_type_object = ContentType.objects.get(id = content_type)\n node = content_type_object.model_class().objects.get(id = object_id)\n community_wiki.delete_content(node)\n \n redirect_url = reverse('content-list-redirect', ... | [
"0.76685023",
"0.72205293",
"0.7062801",
"0.70419425",
"0.70234096",
"0.7012189",
"0.69226223",
"0.69223297",
"0.6868076",
"0.6860735",
"0.68212754",
"0.68212754",
"0.6745534",
"0.6732339",
"0.67283106",
"0.66764003",
"0.6665684",
"0.6665189",
"0.66566366",
"0.6643468",
"0.66... | 0.7722003 | 0 |
Reads the licence from the specified fileName. | def Read(self, fileName: str) -> None:
try:
if os.path.isfile(os.path.join(os.getcwd(), 'Licences', fileName)) and (fileName.endswith('.nls1')):
self.m_Licence1 = ElementTree.parse(os.path.join(os.getcwd(), 'Licences', fileName)).getroot()
except FileNotFoundError:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def license(p):\n # Input file\n f = '/'.join([p, 'collector.stats'])\n check_path(f)\n\n # Open file with universal newline support\n with open(f, 'rU') as fh:\n for line in fh.readlines():\n if 'License key' in line:\n license = line.split(':')[1].strip()\n ... | [
"0.6428396",
"0.6019847",
"0.59947544",
"0.58736926",
"0.5851565",
"0.58470494",
"0.58166087",
"0.58135986",
"0.5810444",
"0.5810444",
"0.5779063",
"0.5741028",
"0.5730347",
"0.5701212",
"0.5701118",
"0.5668183",
"0.56602037",
"0.5650262",
"0.5648893",
"0.5632953",
"0.5631807... | 0.7940669 | 0 |
Verifies the licence by comparing it to the signature computed for the licence using the specified public key. | def Verify(self, publicKey: str) -> bool:
if not publicKey:
raise ValueError(str(publicKey))
isValid = False
if self.m_Licence1:
signature = self.m_Licence1.find('Code').text
self.m_Licence1.find('Code').text = ''
try:
isVal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def VerifyWithFile(publicKey: str, value: ElementTree.Element) -> bool:\r\n lr = LicenceReader()\r\n lr.m_Licence1 = value\r\n return lr.Verify(publicKey)",
"def can_verify(self, public_key):\n result = self._lib_vscf_ecc.vscf_ecc_can_verify(self.ctx, public_key.c_impl)\n retur... | [
"0.6605417",
"0.640331",
"0.6185872",
"0.6178675",
"0.608803",
"0.59822845",
"0.5972749",
"0.5925845",
"0.5922927",
"0.58927023",
"0.58635825",
"0.586296",
"0.58162904",
"0.578368",
"0.5780162",
"0.57581234",
"0.5755524",
"0.570118",
"0.56900156",
"0.56470275",
"0.5636996",
... | 0.7127445 | 0 |
Verifies the specified licence by comparing it to the signature computed for the licence using the specified public key. | def VerifyWithFile(publicKey: str, value: ElementTree.Element) -> bool:
lr = LicenceReader()
lr.m_Licence1 = value
return lr.Verify(publicKey) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Verify(self, publicKey: str) -> bool:\r\n if not publicKey:\r\n raise ValueError(str(publicKey))\r\n isValid = False\r\n if self.m_Licence1:\r\n signature = self.m_Licence1.find('Code').text\r\n self.m_Licence1.find('Code').text = ''\r\n try:\r\n... | [
"0.699972",
"0.60788673",
"0.60085154",
"0.5997743",
"0.5859552",
"0.5776492",
"0.5746808",
"0.5743002",
"0.57144624",
"0.5711558",
"0.56908786",
"0.5650581",
"0.56451046",
"0.56195503",
"0.5615559",
"0.5570306",
"0.5556296",
"0.5545048",
"0.5536732",
"0.5535945",
"0.55258125... | 0.64155024 | 1 |
Parse a string with a size into a number of bytes. I.e. parses "10m", "10MB", "10 M" and other variations into the number of bytes in ten megabytes. Floatingpoint numbers are rounded to the nearest byte. | def _size_to_bytes(size):
units = 'KMGTPEZY' # note that position of letter is same as power - 1
match = re.search(r'^\s*([-+]?\s*[0-9]*\.?[0-9]*)\s*([' + units + r']?\s*B?\s*S?)\s*', size, re.IGNORECASE)
if match is None or match.group(1) == '':
raise ValueError("size string not in proper format 'number [kmgtpez... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_bytes_size(size_str):\n\n m = BYTES_REGEX.fullmatch(size_str.lower())\n if m:\n number = int(m.group(1))\n\n if m.group(2) is not None:\n unit = m.group(2)\n conversion = SIZE_UNITS.get(unit)\n if conversion:\n return conversion * numb... | [
"0.80750585",
"0.7943071",
"0.7917191",
"0.7679579",
"0.74983126",
"0.74863803",
"0.7467127",
"0.74435073",
"0.74435073",
"0.7316791",
"0.72532624",
"0.72482127",
"0.7226874",
"0.7199668",
"0.7170066",
"0.7089149",
"0.7017551",
"0.6896638",
"0.684901",
"0.6813656",
"0.6801743... | 0.8139478 | 0 |
Resample audio files in ${task_dir}/48000/ to ${task_dir}/${target_sr}/ | def resample_hear_corpus(task_dir: str, target_sr: int = 16000, num_workers: int = 6):
task_dir: Path = Path(task_dir)
target_audio_dir: Path = task_dir / f"{target_sr}"
if target_audio_dir.is_dir():
logger.info(f"{target_audio_dir} already exist. Do not need to resample")
return
defau... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audio_resample(self, data):\n\n data = np.asarray(data)\n if data.ndim <= 1:\n logging.log_first_n(logging.INFO,\n 'Converting %s sound from shape %s to 2-D' %\n (self._name, data.shape), 5)\n data = np.reshape(data, (-1, 1))\n if data.shape[... | [
"0.6366487",
"0.63232714",
"0.6174829",
"0.61593074",
"0.60996795",
"0.608292",
"0.6074825",
"0.60149586",
"0.5962723",
"0.59391665",
"0.5921867",
"0.58278805",
"0.5824111",
"0.5806314",
"0.56739146",
"0.56591153",
"0.56460583",
"0.5642763",
"0.56418234",
"0.56304383",
"0.562... | 0.76220435 | 0 |
Reads a option from input from a list of options, with message, default option and help message. | def read_option(message, options=[], default=None, help=None):
while True:
option = raw_input(message)
if option:
if option == "?":
if help:
print(help)
print("Possible options: {}".format(options))
elif options and option i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_input_choices(self, msg, *options):\n choices = ['%s %s' % (self.prefix, msg)]\n choices += [\n \"%s. %s\" % (num, opt) for num, opt in enumerate(options, 1)]\n try:\n input_str = int(\n vim.eval('inputlist(%s)' % self.prepare_value(choices)))\n ... | [
"0.64677876",
"0.6426644",
"0.6143929",
"0.6095286",
"0.6019173",
"0.5975163",
"0.5952457",
"0.59263563",
"0.5890711",
"0.5865748",
"0.5855209",
"0.584225",
"0.5817843",
"0.5789897",
"0.5786976",
"0.5770645",
"0.5755894",
"0.5755527",
"0.57514435",
"0.5748384",
"0.57481533",
... | 0.843761 | 0 |
Reads a float from input, with message, default option and help message. | def read_float(message, default=None, help=None):
while True:
option = raw_input(message)
if not option:
if default is not None:
return default
else:
print("Please provide a value.")
elif option == "?":
if help:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_float(self, prompt=\"> \"):\n\t\twhile True:\n\t\t\tans = raw_input(prompt)\n\t\t\ttry: \t\n\t\t\t\tans = float(ans)\n\t\t\t\treturn ans\n\t\t\texcept ValueError:\n\t\t\t\tif ans == \"quit\": quit()\n\t\t\t\telse: print \"Please enter a number using decimal notation.\"",
"def prompt_float_input(prompt_na... | [
"0.7123461",
"0.6892407",
"0.6582036",
"0.6527858",
"0.63909686",
"0.63844645",
"0.6292312",
"0.62777096",
"0.6268448",
"0.61232615",
"0.6026712",
"0.59781504",
"0.59341896",
"0.5892403",
"0.58726865",
"0.58607256",
"0.584479",
"0.5762863",
"0.5747006",
"0.5698778",
"0.568604... | 0.8742288 | 0 |
writing the dict in self.data to the yaml file. | def write(self):
self.f.write(yaml.safe_dump(self.data, default_flow_style=False, indent=4)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, file=sys.stdout):\n d = self.to_dict()\n if d:\n yaml.dump([d], file, default_flow_style=False)",
"def save(self, filename=None):\n name = filename or self.filename\n with open(name, \"w\") as stream:\n yaml.dump(self.data, stream, default_flow_st... | [
"0.7988538",
"0.75797796",
"0.7365184",
"0.7365184",
"0.7156229",
"0.6999356",
"0.6944983",
"0.6942563",
"0.69258875",
"0.68983555",
"0.6881225",
"0.6877785",
"0.68321437",
"0.68181944",
"0.67738885",
"0.6756965",
"0.6753976",
"0.67452943",
"0.6742652",
"0.67258483",
"0.67258... | 0.8466246 | 0 |
add a box to the shape | def add_box(self, l, w, h, x, y, z, comment=""):
self.data['shape']['compound'].append({'box': {'#': comment, 'pose': {'x': x, 'y': y, 'z': z},
'size': {'x': l, 'y': w, 'z': h}}}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_box(self):\n self.scenes[self.current_scene].add_object(Box())\n self.redraw()",
"def add_box(self, box):\n mz_from = box.from_mz\n mz_to = box.to_mz\n rt_from = box.from_rt\n rt_to = box.to_rt\n self.boxes_mz.addi(mz_from, mz_to, box)\n self.boxes_... | [
"0.7877751",
"0.7707694",
"0.76889735",
"0.70273536",
"0.6995231",
"0.6946092",
"0.69300044",
"0.6853376",
"0.6805851",
"0.67583156",
"0.6678382",
"0.6639419",
"0.65904963",
"0.6526012",
"0.64928424",
"0.64728737",
"0.6445446",
"0.64276713",
"0.64276713",
"0.64217186",
"0.638... | 0.8421367 | 0 |
add an 'in_front_of' area to an object. It takes into account the size of the object | def add_in_front_of(self, depth, width, side_clearance=DEFAULT_IN_FRONT_SIDE_CLEARANCE,
distance=DEFAULT_IN_FRONT_DISTANCE,
size=DEFAULT_IN_FRONT_SIZE):
boxmin = {'x': round(depth/2 + distance, ROUND_LEVEL),
'y': round(-width/2 + side_clearance,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_on_top_of(self, name=\"\", bottom_clearance=DEFAULT_BOTTOM_CLEARANCE,\n side_clearance=DEFAULT_SIDE_CLEARANCE, front_clearence=DEFAULT_FRONT_CLEARANCE,\n back_clearence=DEFAULT_BACK_CLEARANCE, height=ON_TOP_OFF_HEIGHT):\n\n if not name:\n name = '... | [
"0.59779716",
"0.56933",
"0.5566353",
"0.55477345",
"0.5506981",
"0.5493056",
"0.5481022",
"0.54144007",
"0.5384035",
"0.5383211",
"0.5361351",
"0.5339586",
"0.531687",
"0.5316715",
"0.53058517",
"0.5301703",
"0.52933913",
"0.52611434",
"0.5226817",
"0.51790226",
"0.5167534",... | 0.7426306 | 0 |
Adds an on_top_off_area to the model. This must be called right after the element w.r.t. which the on_top_off is specified (e.g., the table top) has been added. | def add_on_top_of(self, name="", bottom_clearance=DEFAULT_BOTTOM_CLEARANCE,
side_clearance=DEFAULT_SIDE_CLEARANCE, front_clearence=DEFAULT_FRONT_CLEARANCE,
back_clearence=DEFAULT_BACK_CLEARANCE, height=ON_TOP_OFF_HEIGHT):
if not name:
name = 'on_top_of'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bb_top(self, bb_top: float):\n\n self._bb_top = bb_top",
"def add_card(self, card_, on_top=True):\n card_.unclick()\n if on_top:\n pos_ = self.pos\n if len(self.cards) is not 0:\n length = len(self.cards)\n pos_ = (self.pos[0] + length ... | [
"0.49048257",
"0.46711868",
"0.46110424",
"0.4565928",
"0.45465842",
"0.45465842",
"0.45445573",
"0.44879434",
"0.4483955",
"0.4483955",
"0.44211143",
"0.44092962",
"0.43391472",
"0.4334049",
"0.43188763",
"0.43176568",
"0.43120137",
"0.43120137",
"0.42938113",
"0.4287915",
"... | 0.67451435 | 0 |
Adds an 'near' area to the model with given offset | def add_near(self, offset=0.7):
self.add_area("near", "offset", offset) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setNear(self, near):\n self.light.node().getLens().setNear(near)",
"def set_near(self, value):\n scene = self.scenes[self.current_scene]\n scene.set_perspective(near=value)\n self.redraw()",
"def offset(self, offset):\n if self.da > 0:\n radius = self.r + offset\n ... | [
"0.6061911",
"0.58462834",
"0.5605604",
"0.5502686",
"0.5402498",
"0.53371626",
"0.52448463",
"0.51996297",
"0.51567805",
"0.51047224",
"0.5097213",
"0.50725985",
"0.5062398",
"0.50562",
"0.50494885",
"0.503145",
"0.50292754",
"0.50055283",
"0.50039315",
"0.49986252",
"0.4995... | 0.86550325 | 0 |
file.managed, existing file with replace=True, change permissions | def test_managed_file_mode_file_exists_replace(
file, tmp_path, grail_scene33_file, mode, replace
):
name = tmp_path / "grail_scene33"
# Set the mode on the state tree file to 0600
grail_scene33_file.chmod(0o600)
# The file should exist, copy it
shutil.copyfile(str(grail_scene33_file), str(name)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_file_permission(request, app=None, priv=None):\n pass",
"def chmod_file ( self, fspath ):\n return",
"def test_provider_system_hook_file_chmod(change_dir, fix_file_perms):\n tackle(context_file='chmod.yaml', no_input=True)\n assert oct(os.stat('tackle.yaml').st_mode)[-3:] == \"600\"",
"d... | [
"0.69003147",
"0.6608834",
"0.64237905",
"0.61870056",
"0.6163651",
"0.61197066",
"0.6103727",
"0.6009532",
"0.5986581",
"0.5952005",
"0.5944114",
"0.5904253",
"0.58546925",
"0.5817923",
"0.5791194",
"0.5735725",
"0.5721977",
"0.56830996",
"0.5677009",
"0.5665991",
"0.5662682... | 0.69366336 | 0 |
Test to ensure we can render grains data into a managed file. | def test_managed_file_with_grains_data(file, tmp_path, state_tree, minion_id):
name = tmp_path / "grains-get-contents.txt"
tmpl_contents = """
{{ salt['grains.get']('id') }}
"""
with pytest.helpers.temp_file("grainsget.tmpl", tmpl_contents, state_tree):
ret = file.managed(
name=s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_visualisations_get_visualisation_render_data(self):\n pass",
"def test_import_snapshot_mapped(self, status):\n object_generator = ObjectGenerator()\n _, user = object_generator.generate_person(user_role=\"Creator\")\n with factories.single_commit():\n assessment = factories.Assessme... | [
"0.59791505",
"0.5967556",
"0.572201",
"0.56537753",
"0.56120425",
"0.56058466",
"0.5579406",
"0.5568751",
"0.55665904",
"0.55644566",
"0.5499739",
"0.5443593",
"0.54322785",
"0.54284906",
"0.53880054",
"0.5371322",
"0.53619367",
"0.5352588",
"0.5329219",
"0.53169596",
"0.531... | 0.62238955 | 0 |
Tests to ensure that file.managed creates directories with the permissions requested with the dir_mode argument | def test_managed_dir_mode(file, tmp_path, grail_scene33_file):
desired_mode = 0o777
name = tmp_path / "a" / "managed_dir_mode_test_file"
ret = file.managed(
name=str(name),
source="salt://grail/scene33",
mode="600",
makedirs=True,
dir_mode=oct(desired_mode), # 0777
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mkdir(self, client, remote_temp_dir):\n\n dir_path = posixpath.join(remote_temp_dir, \"subdir\")\n assert not client.exists(dir_path)\n\n with HdfsHook() as hook:\n hook.mkdir(dir_path, mode=0o750)\n\n assert client.exists(dir_path)\n assert client.info(dir_pa... | [
"0.6981194",
"0.6887613",
"0.66907316",
"0.6682905",
"0.66455567",
"0.6617674",
"0.6571031",
"0.6519029",
"0.64940614",
"0.6311934",
"0.6296809",
"0.6276639",
"0.62766325",
"0.62750995",
"0.6265781",
"0.6251389",
"0.6222987",
"0.6193035",
"0.617428",
"0.6125918",
"0.6120425",... | 0.7481688 | 0 |
test file.managed with contents by using the default contents_newline flag. | def test_managed_contents_with_contents_newline(file, tmp_path, contents):
name = tmp_path / "foo"
# Create a file named foo with contents as above but with a \n at EOF
ret = file.managed(name=str(name), contents=contents, contents_newline=True)
assert ret.result is True
assert name.exists()
ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_managed_contents(file, tmp_path, name, contents):\n name = tmp_path / \"managed-{}\".format(name)\n ret = file.managed(name=str(name), contents=contents)\n assert ret.result is True\n assert \"diff\" in ret.changes\n assert name.exists()",
"def test_onePerLine(self):\n fp = FilePat... | [
"0.74482167",
"0.7001798",
"0.66213626",
"0.6138996",
"0.61203164",
"0.60954994",
"0.59349686",
"0.5887044",
"0.58578086",
"0.5821733",
"0.57995737",
"0.57658714",
"0.57202387",
"0.5709132",
"0.57070374",
"0.56630605",
"0.56137776",
"0.5599135",
"0.55946815",
"0.55778825",
"0... | 0.8399223 | 0 |
Test file.managed passing a basic check_cmd kwarg. See Issue 38111. | def test_managed_check_cmd(file, tmp_path):
name = tmp_path / "sudoers"
ret = file.managed(name=str(name), mode="0440", check_cmd="test -f")
assert ret.result is True
assert "Empty file" in ret.comment
assert ret.changes == {
"new": "file {} created".format(name),
"mode": "0440",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check(self):\n\n self.assertTrue(Naive().check(self.file_gitignore))\n self.assertTrue(Naive().check(self.file_tests))\n self.assertTrue(Naive().check(self.file_bin))\n self.assertTrue(Naive().check(self.file_py))\n self.assertTrue(Naive().check(self.file_authors))",
"... | [
"0.70263505",
"0.64792174",
"0.63982093",
"0.6309626",
"0.6207292",
"0.6155844",
"0.6115211",
"0.5992373",
"0.5972797",
"0.58782244",
"0.5864632",
"0.58565617",
"0.58358836",
"0.58291245",
"0.5792029",
"0.5778755",
"0.57755667",
"0.57724106",
"0.5764978",
"0.57585824",
"0.574... | 0.7401335 | 0 |
Make sure that we enforce the source_hash even with local files | def test_managed_local_source_with_source_hash(
file, tmp_path, grail_scene33_file, grail_scene33_file_hash, proto, dest_file_exists
):
name = tmp_path / "local_source_with_source_hash"
if dest_file_exists:
name.touch()
# Test with wrong hash
bad_hash = grail_scene33_file_hash[::-1]
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_managed_source_hash_indifferent_case(file, tmp_path, state_tree, test):\n name = tmp_path / \"source_hash_indifferent_case\"\n hello_world_contents = \"Hello, World!\"\n with pytest.helpers.temp_file(\n \"hello_world.txt\", hello_world_contents, state_tree\n ) as local_path:\n ac... | [
"0.674267",
"0.6463627",
"0.6416464",
"0.6111717",
"0.6101362",
"0.6064013",
"0.6063095",
"0.6057598",
"0.604401",
"0.5989828",
"0.5935335",
"0.5933105",
"0.59134775",
"0.5907258",
"0.5866222",
"0.5835483",
"0.5811649",
"0.5794201",
"0.57568145",
"0.57567805",
"0.5734459",
... | 0.728525 | 0 |
Make sure that we exit gracefully when a local source doesn't exist | def test_managed_local_source_does_not_exist(file, tmp_path, grail_scene33_file, proto):
name = tmp_path / "local_source_does_not_exist"
ret = file.managed(
name=str(name),
source=proto + str(grail_scene33_file.with_name("scene99")),
)
assert ret.result is False
assert not ret.chang... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_source (fileurl, path_unzip, outfile) :\n if outfile is not None and os.path.splitext (outfile)[1].lower () == os.path.splitext (fileurl)[1].lower () :\n file = _check_url_file (fileurl, path_download = path_unzip, outfile = outfile)\n return file\n else :\n file = _check... | [
"0.6148552",
"0.6142079",
"0.6057",
"0.60119665",
"0.6005793",
"0.5938739",
"0.5919889",
"0.5904504",
"0.58742243",
"0.5834198",
"0.5833697",
"0.58021307",
"0.5729534",
"0.57105595",
"0.5685573",
"0.5681292",
"0.5681117",
"0.566238",
"0.56549567",
"0.56549567",
"0.565292",
... | 0.6278259 | 0 |
Using {{ varname }} with a list or dictionary which contains unicode types on Python 2 will result in Jinja rendering the "u" prefix on each string. This tests that using the "tojson" jinja filter will dump them to a format which can be successfully loaded by our YAML loader. The two lines that should end up being rend... | def test_managed_unicode_jinja_with_tojson_filter(file, tmp_path, state_tree, modules):
if salt.utils.platform.is_windows() and os.environ.get("PYTHONUTF8", "0") == "0":
pytest.skip("Test will fail if PYTHONUTF8=1 is not set on windows")
test_file = tmp_path / "test-tojson.txt"
jinja_template_conten... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_jinja2(device_inventory):\n\n test_template = \"\"\"\n interface Ethernet{{ intf_id }}\n ip address {{ intf_ip }}\n \"\"\"\n\n test_result = \"\"\"\n interface Ethernet1\n ip address 1.2.3.4/24\n \"\"\"\n\n template = Template(test_template)\n result = template.render(intf_... | [
"0.6214987",
"0.6041898",
"0.603948",
"0.5966153",
"0.581613",
"0.58153105",
"0.5790855",
"0.54614735",
"0.5438323",
"0.5436494",
"0.5423317",
"0.5416245",
"0.53863925",
"0.53596425",
"0.5354983",
"0.53020763",
"0.525357",
"0.52472496",
"0.52264094",
"0.52087677",
"0.52049106... | 0.7061903 | 0 |
Test passing a source_hash as an uppercase hash. This is a regression test for Issue 38914 and Issue 48230 (test=true use). | def test_managed_source_hash_indifferent_case(file, tmp_path, state_tree, test):
name = tmp_path / "source_hash_indifferent_case"
hello_world_contents = "Hello, World!"
with pytest.helpers.temp_file(
"hello_world.txt", hello_world_contents, state_tree
) as local_path:
actual_hash = hashl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basic(self):\n self.assertEqual(hash_str(\"world!\", salt=\"hello, \").hex()[:6], \"68e656\")",
"def test_hash(self):\r\n self.assertEqual(processor_hash('test'), 'GqNJWF7X7L07nEhqMAZ+OVyks1Y=')\r\n self.assertEqual(processor_hash('edx '), '/KowheysqM2PFYuxVKg0P8Flfk4=')",
"def te... | [
"0.63565356",
"0.62671137",
"0.6251786",
"0.60924065",
"0.6028704",
"0.5976406",
"0.595482",
"0.5913875",
"0.581719",
"0.5811794",
"0.5763702",
"0.5737824",
"0.5670293",
"0.5666691",
"0.56441087",
"0.5638604",
"0.56131727",
"0.5600814",
"0.5588752",
"0.5580525",
"0.555203",
... | 0.6330392 | 1 |
Tests that latin1 file contents are represented properly in the diff | def test_managed_latin1_diff(file, tmp_path, state_tree):
contents = "<html>\n<body>\n{}</body>\n</html>\n"
testfile = tmp_path / "issue-48777.html"
testfile.write_text(contents.format(""))
# Replace it with the new file and check the diff
with pytest.helpers.temp_file("issue-48777.html", "", state... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_diff_with_unicode(self):\n diff = (\n 'diff --git a/cfg/téstcase.ini b/cfg/téstcase.ini\\n'\n 'index cc18ec8..5e70b73 100644\\n'\n '--- a/cfg/téstcase.ini\\n'\n '+++ b/cfg/téstcase.ini\\n'\n '@@ -1,6 +1,7 @@\\n'\n '+blah blah blah\\n... | [
"0.74459535",
"0.6566833",
"0.65601534",
"0.65575856",
"0.6530268",
"0.6500336",
"0.646092",
"0.6412934",
"0.63905233",
"0.6347647",
"0.628505",
"0.6277089",
"0.62725306",
"0.6255228",
"0.62516564",
"0.62102413",
"0.62016076",
"0.6180023",
"0.6168055",
"0.61065865",
"0.609685... | 0.7496446 | 0 |
Test file.managed state with onchanges | def test_file_managed_requisites(modules, tmp_path, state_tree, requisite):
file1 = tmp_path / "file1"
file2 = tmp_path / "file2"
sls_contents = """
one:
file.managed:
- name: {file1}
- source: salt://testfile
# This should run because there were changes
two:
test.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_inotify(self):\n self.fail(\"write a test\")",
"def testDirtyRefresh(self):\n \n pass",
"def tests_ti_file_update(self):\n super().indicator_update()",
"def on_file_changed(self, path):\n\t\tpass",
"def test_managed_contents(file, tmp_path, name, contents):\n name = tmp_... | [
"0.69554883",
"0.64876914",
"0.63309187",
"0.6319913",
"0.6254663",
"0.62185377",
"0.61961335",
"0.6126965",
"0.61166674",
"0.60585064",
"0.60108006",
"0.6001106",
"0.59958",
"0.5961527",
"0.59245294",
"0.5922512",
"0.58627933",
"0.5855503",
"0.58362347",
"0.5827941",
"0.5825... | 0.67222685 | 1 |
This test ensures that after a binary file is created, salt can confirm that the file is in the correct state. | def test_binary_contents_twice(file, tmp_path):
name = tmp_path / "1px.gif"
# First run state ensures file is created
ret = file.managed(name=str(name), contents=BINARY_FILE)
assert ret.result is True
# Second run of state ensures file is in correct state
ret = file.managed(name=str(name), con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upload_binary(self):\n uploadFile = os.path.join(testdatadir, \"upload.data.gz\")\n r = gracedb.writeFile(eventId, uploadFile)\n self.assertEqual(r.status, 201) # CREATED",
"def test_binary_contents(file, tmp_path):\n name = tmp_path / \"1px.gif\"\n ret = file.managed(name=str... | [
"0.7036948",
"0.6847068",
"0.6809927",
"0.66636294",
"0.6653442",
"0.66411066",
"0.6630125",
"0.64702857",
"0.63453937",
"0.6294835",
"0.6271192",
"0.62590516",
"0.62253207",
"0.62044054",
"0.6157578",
"0.6143613",
"0.61369556",
"0.6123887",
"0.6103147",
"0.60813063",
"0.6081... | 0.7719376 | 0 |
Test to check file user/group after setting setuid or setgid. Because Python os.chown() does reset the setuid/setgid to 0. | def test_owner_after_setuid(file, modules, tmp_path, state_file_account):
# Desired configuration.
desired_file = tmp_path / "file_with_setuid"
mode = "4750"
# Run the state.
ret = file.managed(
name=str(desired_file),
user=state_file_account.username,
group=state_file_acco... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_file_owner(host, fqpath, user):\n command = \"chown %s %s\" % (user, fqpath)\n rcode, _, rerr = g.run(host, command)\n\n if rcode == 0:\n return True\n\n g.log.error('chown failed: %s' % rerr)\n return False",
"def testChAttrs(self):\n def _check(results):\n self.f... | [
"0.72370446",
"0.7138705",
"0.70169157",
"0.67163527",
"0.6711687",
"0.66944087",
"0.6687051",
"0.6519431",
"0.6500234",
"0.64717335",
"0.64700246",
"0.64388907",
"0.643171",
"0.63576084",
"0.63489926",
"0.6337333",
"0.6331592",
"0.6297125",
"0.6230173",
"0.6204743",
"0.61873... | 0.7603757 | 0 |
Test a remote file with no hash | def test_file_managed_http_source_no_hash(file, tmp_path, remote_grail_scene33):
name = str(tmp_path / "testfile")
ret = file.managed(name=name, source=remote_grail_scene33.url, skip_verify=False)
# This should fail because no hash was provided
assert ret.result is False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_file_managed_http_source_skip_verify(file, tmp_path, remote_grail_scene33):\n name = str(tmp_path / \"testfile\")\n ret = file.managed(name=name, source=remote_grail_scene33.url, skip_verify=True)\n assert ret.result is True",
"def testRemote(self):\n try:\n remoteLocator = se... | [
"0.72236395",
"0.7172954",
"0.71605164",
"0.6851394",
"0.6806955",
"0.67788607",
"0.6724458",
"0.67171365",
"0.66721904",
"0.6553629",
"0.6403871",
"0.64003515",
"0.6344764",
"0.63181955",
"0.63075525",
"0.6287276",
"0.6229529",
"0.6194949",
"0.61841774",
"0.61640656",
"0.614... | 0.77850294 | 0 |
Test a remote file using skip_verify | def test_file_managed_http_source_skip_verify(file, tmp_path, remote_grail_scene33):
name = str(tmp_path / "testfile")
ret = file.managed(name=name, source=remote_grail_scene33.url, skip_verify=True)
assert ret.result is True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testRemote(self):\n try:\n remoteLocator = self.__httpsFileUrl\n ok = self.__fileU.isLocal(remoteLocator)\n self.assertFalse(ok)\n #\n ok = self.__fileU.exists(remoteLocator)\n self.assertTrue(ok)\n size = self.__fileU.size(rem... | [
"0.7251301",
"0.7052198",
"0.6622951",
"0.6618357",
"0.6608947",
"0.6568611",
"0.6540163",
"0.6483996",
"0.6450933",
"0.6418295",
"0.64047265",
"0.6379879",
"0.6374588",
"0.6258586",
"0.62566084",
"0.6240293",
"0.6215035",
"0.62099105",
"0.6209236",
"0.6159993",
"0.615858",
... | 0.78441286 | 0 |
test verify_ssl when its False and True when managing a file with an https source and skip_verify is false. | def test_verify_ssl_https_source(file, tmp_path, ssl_webserver, verify_ssl):
name = tmp_path / "test_verify_ssl_true.txt"
source = ssl_webserver.url("this.txt")
source_hash = f"{source}.sha256"
ret = file.managed(
str(name),
source=source,
source_hash=source_hash,
verify... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ssl_default(self):\n assert security.security_settings.ssl_verify()",
"def test_ssl_default(self):\n e = ErrataConnector()\n assert e.ssl_verify",
"def test_use_certificate_file_missing(self, tmpfile):\n ctx = Context(SSLv23_METHOD)\n with pytest.raises(Error):\n ... | [
"0.73158944",
"0.6783668",
"0.67815685",
"0.63655317",
"0.63652956",
"0.63621306",
"0.6331079",
"0.6180326",
"0.6170911",
"0.612429",
"0.6118464",
"0.6111109",
"0.6038211",
"0.6006704",
"0.59966445",
"0.59884673",
"0.59882975",
"0.5967463",
"0.595505",
"0.5917905",
"0.5915687... | 0.8198307 | 0 |
Given a series, series length, a, b, g, and number of preds, return a series of...smoothed numbers. | def triple_exponential_smoothing(series: [int], slen: int, alpha: float, beta: float, gamma: float, n_preds: int) -> [int]:
result = []
seasonals = initial_seasonal_components(series, slen)
for i in range(len(series)+n_preds):
if i == 0: # initial values
smooth = series[0]
tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def smooth_series(y,p = 6.25):\n cycle, trend = sm.tsa.filters.hpfilter(y, p)\n return trend",
"def clean_series(y,smooth = False,p = 6.25,logsmooth = True):\n\n # Remove null values in the middle of the series using interpolate\n # First null values are not interpolated but later filled by 0.0\n ... | [
"0.6874529",
"0.61065215",
"0.60670906",
"0.6025021",
"0.58545476",
"0.5738396",
"0.5616307",
"0.5581053",
"0.5547493",
"0.55354017",
"0.5523303",
"0.55053633",
"0.54205126",
"0.54196185",
"0.54133016",
"0.5408546",
"0.54081184",
"0.539662",
"0.53922886",
"0.53792864",
"0.534... | 0.65945506 | 1 |
Register details of an extension's reports | def register_reports(self):
from ckanext.qa import reports
return [reports.openness_report_info] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gReport(self, event):\n \n reports.createReports()",
"def register(ext_id, name, display_admin=False, superuser=False, version=None):\n if ext_id in extensions.keys():\n raise ExtensionExists(\n 'An extension with id %s has already been registered' % ext_id\n )\n\n ... | [
"0.60241216",
"0.5790581",
"0.5619827",
"0.5555276",
"0.5469413",
"0.5383979",
"0.5313093",
"0.5309887",
"0.52991444",
"0.5272507",
"0.5268033",
"0.5226153",
"0.5188942",
"0.51880896",
"0.5184478",
"0.5159821",
"0.51484185",
"0.5145538",
"0.5137522",
"0.512625",
"0.51222086",... | 0.6834808 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.