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 |
|---|---|---|---|---|---|---|
Converts a time string from an slog file into a string DTG string for use in TAML. Have to artificially turn (seconds) into (date), so there's some creativity in the conversion. | def convert_time(slog_time_str):
base_time = datetime.datetime(2007, 1, 1)
delta = datetime.timedelta(0, float(slog_time_str))
timestamp = base_time + delta
taml_dtg = timestamp.strftime('%Y-%m-%dT%H:%M:%S')
return taml_dtg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertTime(string):\n try:\n d = dtparser.parse(string)\n except ValueError:\n try:\n d = datetime.fromtimestamp(float(string))\n except ValueError:\n return string\n\n d.replace(tzinfo=tz.tzlocal())\n return datetime.strftime(d, \"%Y/%m/%d %H:%M:%S\")",
... | [
"0.6709552",
"0.6487091",
"0.6420539",
"0.639823",
"0.6296272",
"0.62832755",
"0.6231348",
"0.62042576",
"0.6168536",
"0.61509234",
"0.61488825",
"0.6141358",
"0.6126549",
"0.6100859",
"0.6069301",
"0.603041",
"0.60138583",
"0.5983436",
"0.59756863",
"0.59745187",
"0.59640115... | 0.7685931 | 0 |
Store fitted results into json file | def save_fit_results(self, save_path: str = "./fit_results.json"):
assert (
self._fit_results
), "There are no fit results to be saved, \
call fit method first or load the results from the file"
assert save_path.endswith(".json"), self.JSON_ASSERTION
with open(save_pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_results(results):\n json.dump(results, open(\"results.json\", \"w\"))",
"def save_fit_results(self, save_path: str = \"./fit_results.json\"):\n assert (\n self._fit_src_dst_results or self._fit_dst_src_results\n ), \"There are no fit results to be saved, \\\n call fit ... | [
"0.7465609",
"0.7382611",
"0.6806038",
"0.6790864",
"0.67722875",
"0.6744859",
"0.66805696",
"0.66547126",
"0.66245914",
"0.65919757",
"0.6576034",
"0.65640616",
"0.6540873",
"0.6520938",
"0.6481845",
"0.64712536",
"0.6405506",
"0.6401357",
"0.63735455",
"0.6363669",
"0.63511... | 0.7513786 | 0 |
load fitted results from json file | def load_fit_results(self, load_path: str = "./fit_results.json"):
assert load_path.endswith(".json"), self.JSON_ASSERTION
with open(load_path, "r") as fjson:
self._fit_results = json.load(fjson) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_fit_results(self, load_path: str = \"./fit_results.json\"):\n assert load_path.endswith(\".json\"), self.JSON_ASSERTION\n with open(load_path, \"r\") as fjson:\n wrapped_results = json.load(fjson)\n assert (\n \"fit_src_dst_results\" in wrapped_results\n ... | [
"0.73352855",
"0.6404458",
"0.63621724",
"0.6311765",
"0.62229115",
"0.6197745",
"0.6123886",
"0.60660917",
"0.60134476",
"0.59846854",
"0.5945812",
"0.592143",
"0.5854745",
"0.5849048",
"0.583823",
"0.5828923",
"0.58042717",
"0.57943183",
"0.5791443",
"0.5774277",
"0.5751769... | 0.7811587 | 0 |
Generates graph with approximately `num_nodes_src_set`/`num_nodes_dst_set` nodes and exactly `num_edges_src_dst`/`num_edges_dst_src` edges from generator | def generate(
self,
num_nodes_src_set: int,
num_nodes_dst_set: int,
num_edges_src_dst: int,
num_edges_dst_src: int,
is_directed: bool,
return_node_ids: bool = False,
transform_graph: bool = True,
*args,
**kwargs,
):
raise NotImp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dfs_edges_generator(graph, source, reverse=...):\n ...",
"def np_batch_generator(n_nodes, n_edges, batch_size, data_subset, epochs=1, shuffle=True):\n\n # we stop accumulating to a batch when one of these numbers is exceeded\n max_nodes = batch_size * n_nodes\n max_edges = batch_size * n_edges\n ... | [
"0.6357381",
"0.61960644",
"0.6187048",
"0.6162786",
"0.61440974",
"0.61100316",
"0.6039733",
"0.59805906",
"0.59549385",
"0.59503865",
"0.5926314",
"0.58999896",
"0.58972",
"0.57888955",
"0.576996",
"0.5767073",
"0.57605594",
"0.5741135",
"0.5737695",
"0.57273066",
"0.570914... | 0.7906923 | 0 |
Loads fitted results from json file | def load_fit_results(self, load_path: str = "./fit_results.json"):
assert load_path.endswith(".json"), self.JSON_ASSERTION
with open(load_path, "r") as fjson:
wrapped_results = json.load(fjson)
assert (
"fit_src_dst_results" in wrapped_results
and "fit_dst_src... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_fit_results(self, load_path: str = \"./fit_results.json\"):\n assert load_path.endswith(\".json\"), self.JSON_ASSERTION\n with open(load_path, \"r\") as fjson:\n self._fit_results = json.load(fjson)",
"def load():\n\n #: the file passed by the user in the post request\n fi... | [
"0.79122615",
"0.65482247",
"0.64179564",
"0.6359414",
"0.6281388",
"0.6250493",
"0.61909735",
"0.61442757",
"0.61417186",
"0.60516894",
"0.59675527",
"0.5951223",
"0.5920149",
"0.5870302",
"0.5859236",
"0.5849556",
"0.5831417",
"0.5825516",
"0.5821571",
"0.5817166",
"0.58045... | 0.7303407 | 1 |
Create plugin manager and defined hooks specification. | def create_plugin_manager():
plugin_manager = PiPluginManager(hookspecs.hookspec.project_name)
plugin_manager.add_hookspecs(hookspecs)
return plugin_manager | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_register_dynamic_plugin_manager(self):\n pass",
"def test_register_dynamic_plugin_manager1(self):\n pass",
"def plugin_manager() -> pluggy.PluginManager:\n _plugin_manager = pluggy.PluginManager(\"rasa\")\n _plugin_manager.add_hookspecs(sys.modules[\"rasa.plugin\"])\n _discover_... | [
"0.7119126",
"0.70899945",
"0.70372623",
"0.69193995",
"0.6870526",
"0.665556",
"0.6444245",
"0.64034927",
"0.6372821",
"0.63320184",
"0.6328381",
"0.6325857",
"0.6302487",
"0.62694174",
"0.6228222",
"0.6221385",
"0.6182159",
"0.6134531",
"0.61034197",
"0.6096832",
"0.6066662... | 0.81805366 | 0 |
Return the friendly name of the given plugin and optionally its version. | def get_friendly_name(self, plugin, version=True):
# List of all setuptools registered plugins
distinfo = dict(self.list_plugin_distinfo())
if plugin in distinfo:
name = distinfo[plugin].project_name
vnumber = distinfo[plugin].version
else:
name = sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_name(self, plugin):\n return plugin.name if isinstance(plugin, BasePlugin) else plugin",
"def get_plugin_name(filename):\n m = PLUGIN_PACKAGE_RE.search(filename or '')\n if m:\n return m.group(1)\n else:\n return None",
"def get_plugin_name(self):\n return self.plu... | [
"0.7386398",
"0.7290012",
"0.7092868",
"0.69911456",
"0.67694056",
"0.67535245",
"0.67400986",
"0.6504187",
"0.6483196",
"0.6451923",
"0.6373576",
"0.63026863",
"0.62797564",
"0.625846",
"0.6180294",
"0.61733705",
"0.609387",
"0.59891397",
"0.5984237",
"0.59653777",
"0.589649... | 0.8702743 | 0 |
Yield a connection pool connected to vial server | def vial_client(
server: str, apikey: str
) -> Iterator[urllib3.connectionpool.ConnectionPool]:
if not server:
raise Exception("Must pass VIAL server to call")
if not apikey:
raise Exception("Must pass VIAL API Key to use")
http_pool = urllib3.PoolManager()
vial_http = http_pool.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_connection(self) -> Iterator[psycopg2.connect]:\n\n conn = self._pool.getconn()\n\n if self.pre_ping:\n for n in range(self.max_reconnects):\n if not self.ping(conn):\n if n > 0:\n time.sleep(self._back_off_time(n - 1))\n ... | [
"0.68395984",
"0.6616775",
"0.6468955",
"0.6466008",
"0.62284225",
"0.6185906",
"0.6179943",
"0.61773294",
"0.6155422",
"0.6123735",
"0.6113533",
"0.61117333",
"0.6077807",
"0.602352",
"0.6014565",
"0.59833854",
"0.5972427",
"0.59647954",
"0.5947133",
"0.59159994",
"0.5907486... | 0.67863506 | 1 |
Start import run and return the id for it | def start_import_run(vial_http: urllib3.connectionpool.ConnectionPool) -> str:
import_resp = vial_http.request("POST", "/api/startImportRun")
if import_resp.status != 200:
raise Exception(f"Failed to start import run {import_resp.data}")
import_data = json.loads(import_resp.data.decode("utf-8"))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_import_task(clientRequestToken=None, name=None, importUrl=None):\n pass",
"def start_import(data_import):\n\tdata_import = frappe.get_doc(\"Data Import Beta\", data_import)\n\ti = Importer(data_import.reference_doctype, data_import=data_import)\n\treturn i.import_data()",
"def importer_process(imp... | [
"0.69069815",
"0.6695886",
"0.66000867",
"0.62952036",
"0.6082602",
"0.60786223",
"0.59738696",
"0.59381676",
"0.59378403",
"0.5874674",
"0.58106",
"0.57830364",
"0.57355547",
"0.5719899",
"0.5697861",
"0.5693284",
"0.5665559",
"0.56556344",
"0.5612762",
"0.56112766",
"0.5574... | 0.76171285 | 0 |
Return the velocity vector of the particle | def get_velocity(self):
return self.momentum/self.mass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getVelocity(self):\n return self.v",
"def getVelocity(self):\n\n return self.vel",
"def velocity(self):\n return self._velocity",
"def velocity(self):\n return self._velocity",
"def velocity_at_pos(self, x, y):\n return scipy.array([float(self._interp_u(x, y)),\n ... | [
"0.7955968",
"0.7745024",
"0.77234554",
"0.77234554",
"0.7688092",
"0.76584786",
"0.76424485",
"0.75447935",
"0.75148714",
"0.7462534",
"0.7457666",
"0.73845005",
"0.72576076",
"0.7106754",
"0.70722777",
"0.7026906",
"0.7010185",
"0.69741774",
"0.6948821",
"0.6877791",
"0.686... | 0.79404175 | 1 |
Check that `VMPool.__iter__` iterates over VM IDs. | def test_iter(self):
for n, pool in enumerate([self.pool0, self.pool1, self.pool2]):
assert list(iter(pool)) in (
list('ab'[:n]),
list('ba'[:n]),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_vpn_id():\n for v in vpns:\n assert len(v.id) > 0",
"def test_iter(self):\n obs = self.tester.__iter__()\n self.assertTrue(isinstance(obs, Iterable))\n self.assertEqual(set(obs), self.exp_sample_ids)",
"def test_iter(self):\n obs = self.tester.__iter__()\n ... | [
"0.5551847",
"0.5502366",
"0.5502366",
"0.499766",
"0.4989234",
"0.49801987",
"0.4952273",
"0.49347952",
"0.49295378",
"0.49100518",
"0.49041685",
"0.4864451",
"0.48494568",
"0.48422536",
"0.48142493",
"0.47784758",
"0.47465125",
"0.4716814",
"0.4716193",
"0.47150078",
"0.470... | 0.5758834 | 0 |
Apply the electron event selection using fastcalo or electron features. The pidname will be a string that can be one or more pidnames algorithms. If there is EFCalo or HLT in pidname, the selection uses fastcalo features. | def ApplyElectronSelection( self, pidname ):
doAnd=False; doOr=False
fc = self.retrieve("FastCalo"); el = self.retrieve("Electron")
# remove spaces if exist
pidname = pidname.replace(' ','')
# Check conditions strings
if '&' in pidname:
pidname = pidname.split('&')
doAnd=True; isPass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(module_name):\n\n global clf_re\n global filter_function\n global remap_pairs\n\n # Get the window date to process events\n (from_date, until_date) = rules_common.window_dates(module_name)\n\n # Get the files to process, lines and mark lines\n (files, total_lines, mark_lines) = \\\... | [
"0.5087484",
"0.50239825",
"0.49709415",
"0.46197402",
"0.4569843",
"0.45122904",
"0.4461218",
"0.4412482",
"0.44032472",
"0.44027945",
"0.43926793",
"0.43906233",
"0.43781617",
"0.4360104",
"0.43565696",
"0.43386114",
"0.43149012",
"0.43059707",
"0.4303484",
"0.4274708",
"0.... | 0.7302416 | 0 |
Add regex filter for list_buckets | def list_buckets(self, regex=".*", verbose=False):
r = re.compile(regex)
if verbose:
return [b for b in self.client.list_buckets()['Buckets'] if r.match(b['Name'])]
else:
return [b['Name'] for b in self.client.list_buckets()['Buckets'] if r.match(b['Name'])] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_buckets():\n pass",
"def lst_and_pattern (filer_lst, pattern):\r\n new_filter_lst=[]\r\n for word in filer_lst:\r\n if word_and_pattern(word,pattern):\r\n new_filter_lst.append(word)\r\n return new_filter_lst",
"def manipulate_bucketlist():\n pass",
"def filter(self,... | [
"0.586817",
"0.55524653",
"0.52830935",
"0.5272527",
"0.52650857",
"0.5254678",
"0.5222747",
"0.52066493",
"0.5205841",
"0.51563156",
"0.5121045",
"0.5078473",
"0.50659263",
"0.5062066",
"0.50272703",
"0.50206465",
"0.49811077",
"0.4968093",
"0.49588022",
"0.49551994",
"0.495... | 0.65801555 | 0 |
fits the list of models to the training data, thereby obtaining in each case an evaluation score after GridSearchCV crossvalidation | def fit(self, train_features, train_actuals):
for name in self.models.keys():
print('-'*shutil.get_terminal_size().columns)
print("evaluating {}".format(name).center(columns))
print('-'*shutil.get_terminal_size().columns)
estimator = self.models[name]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit(train_data, train_target):\r\n for name in models.keys():\r\n est = models[name]\r\n est_params = params2[name]\r\n gscv = GridSearchCV(estimator=est, param_grid=est_params, cv=5)\r\n gscv.fit(train_data, train_target)\r\n print(\"best parameter... | [
"0.7954486",
"0.7731242",
"0.7684677",
"0.7534514",
"0.7332475",
"0.73269665",
"0.724954",
"0.7048197",
"0.7026531",
"0.6991581",
"0.698729",
"0.6975688",
"0.69701505",
"0.6937093",
"0.69133115",
"0.6913214",
"0.69001627",
"0.6897572",
"0.688162",
"0.68772936",
"0.6853344",
... | 0.77692807 | 1 |
Attempts to load all .py files in cogs/ as cog extensions. Returns a dictionary which maps cog names to a boolean value (True = successfully loaded; False = not successfully loaded). | async def load_all_extensions(self, reload=False):
succeeded = {}
for extension in get_extensions():
try:
if reload or extension not in self.cogs_loaded:
self.load_extension(f'cogs.{extension}')
l.info(f"Loaded extension '{extension}'")... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_cogs(self):\n\n path = \"cogs/\" # Should always have a trailing slash\n import_path = path.replace(\"/\", \".\")\n extensions: list[str] = [\n import_path + file.replace(\".py\", \"\")\n for file in os.listdir(path)\n if os.path.isfile(f\"{path}{file... | [
"0.7493008",
"0.6975065",
"0.6765176",
"0.67549616",
"0.6704383",
"0.6446257",
"0.6245783",
"0.6138608",
"0.6025422",
"0.59247637",
"0.58972794",
"0.5765539",
"0.572911",
"0.5679842",
"0.5670242",
"0.5634018",
"0.5585175",
"0.55337536",
"0.54403317",
"0.54370046",
"0.54080385... | 0.71769613 | 1 |
This event triggers when the bot joins a guild. | async def on_guild_join(self, guild):
l.info(f"Joined {guild.name} with {guild.member_count} users!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def on_guild_join(self, guild: discord.Guild) -> None:\n logger.info(f'Added to new guild: {guild.name} ({guild.id})')\n\n with self.get_session() as session:\n _guild: Guild = session.query(Guild).get(guild.id)\n if _guild is None:\n session.add(Guild(id=gu... | [
"0.7710114",
"0.7107106",
"0.6898389",
"0.68539816",
"0.6643167",
"0.66358715",
"0.65689564",
"0.64946175",
"0.6435609",
"0.64033157",
"0.6399424",
"0.6319097",
"0.6283885",
"0.6263786",
"0.6236404",
"0.6235235",
"0.6224685",
"0.6198134",
"0.6194945",
"0.61734843",
"0.6164683... | 0.7720383 | 0 |
This event triggers on every message received by the bot. Including ones that it sent itself. | async def on_message(self, message):
if message.author.bot:
return # Ignore all bots.
await self.process_commands(message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callback_botmessage(self, message):\n pass",
"def callback_botmessage(self, message):\n pass",
"def callback_botmessage(self, message):\n pass",
"async def on_message(self, message: \"steam.Message\") -> None:",
"async def on_message(self, message: discord.Message) -> None:\n\n ... | [
"0.73473126",
"0.73473126",
"0.73473126",
"0.70146674",
"0.69713724",
"0.6857231",
"0.6850092",
"0.6839847",
"0.6813499",
"0.6741119",
"0.6662499",
"0.65737396",
"0.65624034",
"0.6557369",
"0.6556639",
"0.654079",
"0.6522952",
"0.65155643",
"0.64774394",
"0.6470487",
"0.64679... | 0.7366499 | 0 |
Retrieve the SMILES string describing the drug in the parsed HTML document. We get the SMILES string by locating the HTML id "smiles" and then moving to the next html element. This process is slightly complicated by the fact that the SMILES string is confused for an email due to the presence of @ characters, and so we ... | def get_smiles(parsed_drug_doc):
# Source: https://stackoverflow.com/questions/36911296/scraping-of-protected-email
def decode_email(e):
de = ""
k = int(e[:2], 16)
for i in range(2, len(e)-1, 2):
de += chr(int(e[i:i+2], 16)^k)
return de
email_protected_map = {... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_smiles(molecule_etree):\n SMILES_XPATH = 'hunterdb:Structure/hunterdb:CanonicalSmiles/child::text()'\n return molecule_etree.xpath(SMILES_XPATH, namespaces=HUNTER_DB_NAMESPACE_DICT)[0]",
"def to_smiles(rdm):\n smi = _rd_chem.MolToSmiles(rdm)\n return smi",
"def get_smiles(self, canonica... | [
"0.6535551",
"0.57447743",
"0.56670135",
"0.5550063",
"0.54159063",
"0.5406357",
"0.5403899",
"0.54001135",
"0.5337975",
"0.5326419",
"0.5228338",
"0.5192157",
"0.51822424",
"0.5178734",
"0.51761544",
"0.5174183",
"0.51671416",
"0.51321954",
"0.5125165",
"0.50927156",
"0.5081... | 0.79599553 | 0 |
Retrieves the alternative identifiers for other drug info sources. Finds the section using the id "externallinks". | def get_external_links(parsed_drug_doc):
external_link_info = list(parsed_drug_doc.find(id='external-links').next_sibling.dl.children)
external_links = {}
for i in range(0, len(external_link_info), 2):
source = external_link_info[i].text
value = external_link_info[i+1].text
# Ignori... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_possible_ids(self):\n ids = []\n\n dest_data = requests.get(\"https://api.wdpro.disney.go.com/facility-service/destinations/{}\".format(self.__anc_dest_id), headers=getHeaders()).json()\n data = requests.get(dest_data['links']['entertainmentVenues']['href'], headers=getHeaders()).json(... | [
"0.49276513",
"0.4869413",
"0.47767136",
"0.4770535",
"0.46834496",
"0.4679981",
"0.46615496",
"0.4660064",
"0.4631776",
"0.46157798",
"0.4613686",
"0.4605003",
"0.46038538",
"0.45956227",
"0.4586876",
"0.45623347",
"0.4550497",
"0.45440876",
"0.45408326",
"0.4525997",
"0.449... | 0.63020116 | 0 |
Retrieves a set of information for a given Drugbank drug identifier. | def get_info_for_identifier(identifier):
page = requests.get(f"https://www.drugbank.ca/drugs/{identifier}")
parsed_drug_doc = BeautifulSoup(page.text, 'html.parser')
smiles = get_smiles(parsed_drug_doc)
gene_action_pairs = get_gene_action_pairs(parsed_drug_doc)
external_links = get_external_links(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def details(self, identifier):\n return self.client.request_with_method(Methods.GET % (self.name, identifier,))",
"def _get_drug_entry(self,cid):\n result = None\n search_str = \"drugbank:drug/drugbank:drugbank-id/.[@primary='true']/..[drugbank:drugbank-id='%s']\" % (cid) \n result =... | [
"0.61482173",
"0.60460675",
"0.5905877",
"0.5839129",
"0.57571423",
"0.5755548",
"0.559288",
"0.5558541",
"0.55240154",
"0.54870063",
"0.5484556",
"0.5463918",
"0.5458747",
"0.5449955",
"0.5438414",
"0.5438065",
"0.542378",
"0.5415125",
"0.5409009",
"0.5404084",
"0.5365181",
... | 0.7483154 | 0 |
Retrieves the info from Drugbank for the provided identifiers, prepares insert statements for the info and then performs them. | def transact_drug_info(identifiers, user, password, host):
drug_info = []
for identifier in identifiers:
drug_info.append(get_info_for_identifier(identifier))
def xform_for_insert(t):
return str(t).replace('"', "'").replace("None", "NULL")
drugs_txs = []
gene_action_pairs_txs = []... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_into_db(self, database):\n\n # insert person\n keys = \"\"\n values = \"\"\n for key, value in self.person.items():\n # location\n if key == \"location\":\n # ensure location is in table\n database.select(f\"\"\"DO $do$ BEGI... | [
"0.5740032",
"0.544129",
"0.54230183",
"0.53802603",
"0.5290045",
"0.52740854",
"0.524837",
"0.5180443",
"0.5175086",
"0.5168618",
"0.5155777",
"0.51552916",
"0.5112063",
"0.51112425",
"0.5108119",
"0.5073048",
"0.5065976",
"0.50578666",
"0.50480336",
"0.50229603",
"0.5017675... | 0.6826996 | 0 |
determine if madlib function is substituting input values correctly | def test_madlib_substitution():
actual = madlib(input_values)
expected = output_text
assert actual == expected | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_SMEL_args():\n testing_function('sme', bilinear=False)",
"def needs_correction(self, var):\n global matmul_registry\n if var in matmul_registry:\n return True\n else:\n return False",
"def test_value_not_masked(self):\n out = mask_args_value(\"quantum fluctuations\", \"qua... | [
"0.5692555",
"0.5676673",
"0.5592143",
"0.5510311",
"0.5429809",
"0.5424574",
"0.5415874",
"0.5388544",
"0.5388544",
"0.5327953",
"0.53016853",
"0.53009725",
"0.5289353",
"0.5279792",
"0.52717566",
"0.5237211",
"0.52188444",
"0.5212372",
"0.52014846",
"0.5173144",
"0.51723444... | 0.64386356 | 0 |
The servo that was active when the error occurred. | def servo(self) -> Optional[servo.Servo]:
return self._servo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def servo_active(self, *args, **kwargs) -> Any:\n pass",
"def status(self):\n return self._bp.get_motor_status(self._port)",
"def servo_on(self):\n self.logger.info('Setting servo ON')\n self.electronics.move_servo(1)\n self.config['servo']['status'] = 1",
"def controller_s... | [
"0.6637851",
"0.59305996",
"0.57332313",
"0.5726711",
"0.5699285",
"0.56845474",
"0.5684502",
"0.56725603",
"0.56126374",
"0.55574274",
"0.55151606",
"0.54930377",
"0.5473341",
"0.54207635",
"0.5410516",
"0.53283364",
"0.5266262",
"0.5254195",
"0.52259874",
"0.52212095",
"0.5... | 0.6539491 | 1 |
Sets the scope for visualization | def set_scope(self, scope):
self.vis.set_scope(scope) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scope(self, scope):\n self._scope = scope",
"def scope(self, scope):\n\n self._scope = scope",
"def set_scope(self, value):\n self._set_one_attribute(self.AttributeNames.SCOPE, value)\n return self",
"def scope(self, name):\r\n raise NotImplementedError",
"def scope_name(... | [
"0.71557474",
"0.6992773",
"0.64821863",
"0.6437079",
"0.6400237",
"0.62426734",
"0.62259716",
"0.6182546",
"0.6080821",
"0.6059979",
"0.59588253",
"0.5852097",
"0.5847752",
"0.58445555",
"0.5843846",
"0.58180714",
"0.57963246",
"0.57376325",
"0.566702",
"0.5613966",
"0.56080... | 0.8688092 | 0 |
Draws a map in the background | def draw_map(self):
self.vis.draw_map() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _draw_map(screen):\n my_map = HexMap(80, 80, _hex_size=10)\n my_map.generate_with_random_walk(150, iterations=25)\n for tile in my_map:\n # print(tile)\n color = COLORS[tile.type]\n\n tile_color = _modify_color(color)\n pygame.draw.polygon(screen, tile_color, tile.corners)\... | [
"0.7438594",
"0.71875733",
"0.71379495",
"0.71011156",
"0.7013649",
"0.68864465",
"0.68812746",
"0.6869771",
"0.6788096",
"0.6728911",
"0.67023903",
"0.6584422",
"0.65258896",
"0.65181553",
"0.6514239",
"0.6453493",
"0.64481187",
"0.64455163",
"0.6381603",
"0.6366488",
"0.635... | 0.7902193 | 0 |
Draws the routes of the ships | def draw_routes(self):
self.vis.draw_routes() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize_routes(self):\n visualize_tsp.plotTSP([self.best_solution], self.coords)",
"def show_positioned_routes(self, routes):\n print(55*\"-\")\n print(\" Positioned Routes:\")\n print(55*\"-\")\n for elem in routes:\n print(str(elem))",
"def dump(self):\n ... | [
"0.68161446",
"0.63527113",
"0.6300826",
"0.6296435",
"0.6266359",
"0.60612214",
"0.601034",
"0.6004469",
"0.600043",
"0.5953386",
"0.5913259",
"0.5910172",
"0.58955467",
"0.58931464",
"0.5875609",
"0.58717746",
"0.58306396",
"0.58220094",
"0.58145154",
"0.5808135",
"0.579943... | 0.7103001 | 0 |
Draws the predictions of the ships | def draw_predictions(self):
self.vis.draw_predictions() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(self, frame):\n for prediction in self.predictions:\n prediction.draw(frame)",
"def plot_predictions(self):\n\n plt.title(\"Targets vs. Predictions\")\n plt.plot(self.T, label=\"Targets\")\n plt.plot(self.Y, label=\"Predictions\")\n plt.xlabel(\"Sample numbe... | [
"0.626214",
"0.6031829",
"0.59917396",
"0.59532815",
"0.5945221",
"0.59262586",
"0.591139",
"0.5855403",
"0.58285314",
"0.5797049",
"0.5768138",
"0.5755301",
"0.57469463",
"0.5740562",
"0.5700845",
"0.56753343",
"0.56701136",
"0.56557083",
"0.565118",
"0.5646596",
"0.5598298"... | 0.6511887 | 0 |
Zooms to calculated or to user scope | def __button_zoom_clicked(self):
self.zoom_to_calc_scope = not self.zoom_to_calc_scope
self.vis.change_zoom(self.zoom_to_calc_scope)
if self.zoom_to_calc_scope:
self.button_zoom.setText("Zoom to user scope")
else:
self.button_zoom.setText("Zoom to calculated scope... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zoom_to(self):\n # Will seek user feedback. QGIS will\n # Pan to first layer loaded",
"def zoom(self, amount):\n pass",
"def apply_zoom(self):\n self.maparea.setTransform(self.zoom_levels[self.cur_zoom][1])\n self.scene.draw_visible_area()",
"def __zoom(self):\n ... | [
"0.70761585",
"0.69927603",
"0.68108034",
"0.65833044",
"0.65501726",
"0.65094495",
"0.65086645",
"0.64987355",
"0.6489018",
"0.64820343",
"0.6400203",
"0.6360558",
"0.62938553",
"0.6238079",
"0.62361455",
"0.6220067",
"0.62044436",
"0.618074",
"0.61599994",
"0.6158776",
"0.6... | 0.7127061 | 0 |
Changes the color of route lines and route patches | def __button_routes_line_color_clicked(self):
color = QColorDialog.getColor()
if color.isValid():
self.vis.change_route_line_color(color.name()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color_way(graph, way):\n ox.plot_graph_route(graph, way)",
"def __button_routes_marker_color_clicked(self):\n color = QColorDialog.getColor()\n if color.isValid():\n self.vis.change_route_marker_color(color.name())",
"def _set_color(self, r):\n c = COLORS[self.color]\n ... | [
"0.6682972",
"0.6390528",
"0.6147725",
"0.61077327",
"0.60268617",
"0.5987641",
"0.58574235",
"0.58475643",
"0.5789604",
"0.5737006",
"0.5722419",
"0.5721481",
"0.57162046",
"0.5715089",
"0.5713998",
"0.57114846",
"0.5698987",
"0.5686852",
"0.56804526",
"0.56774586",
"0.56742... | 0.67418104 | 0 |
Changes the color of route markers | def __button_routes_marker_color_clicked(self):
color = QColorDialog.getColor()
if color.isValid():
self.vis.change_route_marker_color(color.name()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_markers_color(self, markers_color):\n self.markers_color = markers_color\n self.update_markers(self.markers)",
"def set_markers_color(self, markers_color):\n self._set_markers_color(markers_color, key=\"model\")",
"def _set_markers_color(self, markers_color, key):\n self.mar... | [
"0.7044057",
"0.7002465",
"0.677413",
"0.6731408",
"0.65059507",
"0.61693764",
"0.60807544",
"0.59966314",
"0.59300774",
"0.5908406",
"0.58413565",
"0.58325946",
"0.58061284",
"0.57990813",
"0.5794199",
"0.5764045",
"0.57388026",
"0.5721148",
"0.5715555",
"0.5715183",
"0.5710... | 0.7659686 | 0 |
Changes the color of prediction lines and prediction patches | def __button_prediction_line_color_clicked(self):
color = QColorDialog.getColor()
if color.isValid():
self.vis.change_prediction_line_color(color.name()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_color(self):\n self.plot(update_traces=False, update_waveforms=True)",
"def changeColor(self):\n self.layer.new_colormap()",
"def __button_prediction_marker_color_clicked(self):\n color = QColorDialog.getColor()\n if color.isValid():\n self.vis.change_predictio... | [
"0.62123764",
"0.61652744",
"0.60644865",
"0.5744471",
"0.5587503",
"0.5579864",
"0.54944956",
"0.5475637",
"0.54724866",
"0.54577696",
"0.54441255",
"0.54431957",
"0.5403518",
"0.53859484",
"0.5351867",
"0.53359157",
"0.53151727",
"0.530714",
"0.52710307",
"0.5262313",
"0.52... | 0.62771994 | 0 |
Changes the color of prediction markers | def __button_prediction_marker_color_clicked(self):
color = QColorDialog.getColor()
if color.isValid():
self.vis.change_prediction_marker_color(color.name()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_markers_color(self, markers_color):\n self._set_markers_color(markers_color, key=\"model\")",
"def set_markers_color(self, markers_color):\n self.markers_color = markers_color\n self.update_markers(self.markers)",
"def _set_markers_color(self, markers_color, key):\n self.mar... | [
"0.7043545",
"0.6805905",
"0.65569264",
"0.6435788",
"0.6404955",
"0.63046265",
"0.62484235",
"0.59784675",
"0.59488225",
"0.5729172",
"0.5657184",
"0.5614262",
"0.5593371",
"0.55903167",
"0.55818754",
"0.555754",
"0.55339634",
"0.5522944",
"0.55088085",
"0.5441992",
"0.54185... | 0.7464549 | 0 |
Changes the marker size | def __button_marker_size_clicked(self):
val, okPressed = QInputDialog.getDouble(self, "Set marker size","Value:", self.marker_size, 0, 100, 4)
if okPressed:
self.vis.change_marker_size(val)
self.marker_size = val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_markers_size(self, markers_size):\n self.markers_size = markers_size\n self.update_markers(self.markers)",
"def _set_markers_size(self, markers_size, key):\n self.markers_size[key] = markers_size\n self._update_markers(self.markers, key)",
"def changeSize(self, value):\n ... | [
"0.7957097",
"0.79468244",
"0.7109392",
"0.6834395",
"0.6767795",
"0.66597164",
"0.6571444",
"0.6549198",
"0.65221936",
"0.6460304",
"0.6456009",
"0.64492106",
"0.6431153",
"0.64193666",
"0.641807",
"0.641807",
"0.63952523",
"0.63742155",
"0.6358185",
"0.6348079",
"0.6309966"... | 0.8122282 | 0 |
Shows only nth marker | def __button_mark_every_clicked(self):
val, okPressed = QInputDialog.getInt(self, "Set every n-th marker","Value:", self.mark_every, 1, 1000)
if okPressed:
self.vis.change_mark_every(val)
self.mark_every = val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_markers(num_markers):\n markers = ['^','o','P','X','*', 'd','<', '>', ',','|', '1','2','3','4','s','p','*','h','+']\n if(num_markers>18):\n sys.exit(\"cannot create more than 18 markers, refactor your code; force exiting\")\n\n return markers[0:num_markers]",
"def alert(n):\n f... | [
"0.61066335",
"0.58480793",
"0.58365047",
"0.57498217",
"0.5747987",
"0.5717928",
"0.5526804",
"0.54910606",
"0.54452956",
"0.5429945",
"0.54014564",
"0.53442556",
"0.53102845",
"0.52922887",
"0.52334106",
"0.5230203",
"0.5225732",
"0.52170223",
"0.5191547",
"0.51543796",
"0.... | 0.58969164 | 1 |
Changes the anomaly threshold and redraw the anomaly annotations, if necessary | def __slider_anomaly_threshold_value_changed(self):
val = self.slider_anomaly_threshold.value() / 10000
self.label_anomaly_threshold.setText("Anomaly threshold: %.4f" % round(val, 5))
self.vis.change_anomaly_thresh(val)
self.vis.show_anomalies(self.checkbox_anomalies.isChecked())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anomaly():\n\n #Load anomaly dataset\n anomaly_data = LoadDataset(\"dataset/kaggle_anomalies/\",0)\n anomaly_data, anomaly_label, val, val_label = anomaly_data.load_data()\n for i in range (len(anomaly_label)):\n anomaly_label[i] = anomaly_label[i] + 5\n\n #Concatinate test and anomaly\n ... | [
"0.63055974",
"0.59972256",
"0.5510011",
"0.549272",
"0.5430622",
"0.54203653",
"0.5420277",
"0.53936905",
"0.5356829",
"0.53355956",
"0.52786005",
"0.52670705",
"0.5250499",
"0.5238121",
"0.52195436",
"0.52043974",
"0.5202424",
"0.51902163",
"0.5183443",
"0.51810884",
"0.517... | 0.7162049 | 0 |
takes the parsed color and returns it in matplotlib format | def parse_color(color):
return (color[0], color[1], color[2]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color_val_matplotlib(color):\n color = mmcv.color_val(color)\n color = [color / 255 for color in color[::-1]]\n return tuple(color)",
"def getColor(self, _color):\n c = _color.split()\n \n for n in range(len(c)):\n c[n] = float(c[n])\n \n return c",
"d... | [
"0.6960643",
"0.68371934",
"0.6820142",
"0.66417915",
"0.66331017",
"0.6586802",
"0.657952",
"0.6547312",
"0.6425396",
"0.6418397",
"0.63776857",
"0.63485354",
"0.63365304",
"0.6317147",
"0.6297241",
"0.6231265",
"0.6167969",
"0.6115033",
"0.60773015",
"0.60769904",
"0.603920... | 0.68683803 | 1 |
Receives a matrix of coordinates and transforms it into a list of Locations | def coordinates_to_locations(coordinates):
np_coords = np.array(coordinates)
longs, lats = transform(Proj(init=EPSG_IN), Proj(init=EPSG_OUT), np_coords[:, 0], np_coords[:, 1])
length = len(lats)
result = []
for i in range(length):
loc = Location(lats[i], longs[i])
raw_location = extr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix2list(vertex_matrix): \n flat_array = vertex_matrix.tolist() \n xy_list = [] \n for i in range(0, len(flat_array)): \n xy_list.append( flat_array[i][0] ) \n xy_list.append( flat_array[i][1] ) \n return xy_list",
"def coords_to_positions(self, coords):\n return [self.t... | [
"0.63898116",
"0.63502413",
"0.62159",
"0.6157633",
"0.61507696",
"0.6145018",
"0.6046968",
"0.6008495",
"0.59859973",
"0.59842753",
"0.5973625",
"0.5972133",
"0.5960086",
"0.59585255",
"0.593453",
"0.5930561",
"0.5909759",
"0.59049857",
"0.5903449",
"0.5894739",
"0.5884177",... | 0.6808166 | 0 |
Initialises a new ReadingLoader instance to read and process data from files generated by the RED reading task. Arguments data_dir String. Path to the directory that contains data files that need to be loaded. Keyword Arguments output_path String. Path to the file in which processed data needs to be stored, or None to ... | def __init__(self, data_dir, output_path=None, task_name="ReadingTest", \
answer_file=None):
# Define the default answer_file.
if answer_file is None:
answer_file = os.path.join( \
os.path.dirname(os.path.abspath(__file__)), \
"reading_ans... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data_dir, output_path=None, task_name=\"Q1_Questions\"):\n \n # Remember the task name.\n self._task_name = task_name\n # Load all data.\n self.load_from_directory(data_dir, task_name)\n self.process_raw_data()\n if not (output_path is None):\n ... | [
"0.68810457",
"0.6347282",
"0.63151276",
"0.60448104",
"0.59106815",
"0.5840321",
"0.57810795",
"0.5776484",
"0.5745916",
"0.5745365",
"0.569666",
"0.5693174",
"0.56790227",
"0.5678662",
"0.5673701",
"0.56613",
"0.5648839",
"0.5613989",
"0.5597921",
"0.55950487",
"0.5570015",... | 0.6832593 | 1 |
Loads data from a single file. This function overwrites the parent's load_from_file function to allow for the checking of answers. Arguments file_path String. Path to the file that needs to be loaded. Keyword arguments delimiter String. Delimiter for the data file. Default = "," missing List. List of values that code f... | def load_from_file(self, file_path, delimiter=",", missing=None, \
auto_typing=True, string_vars=None):
# Load the data from a file.
raw = read_behaviour(file_path, delimiter=",", missing=None, \
auto_typing=True, string_vars=["Sentence", "Response"])
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_from_file(self, file_path, delimiter=\",\", missing=None, \\\n auto_typing=True, string_vars=None):\n \n # Load the data from a file.\n raw = read_behaviour(file_path, delimiter=\",\", missing=None, \\\n auto_typing=True, string_vars=[\"Response\"])\n \n ... | [
"0.73351383",
"0.5946088",
"0.5934415",
"0.58590823",
"0.5856287",
"0.5807811",
"0.57449085",
"0.5613772",
"0.5591136",
"0.55231375",
"0.5500807",
"0.5500807",
"0.54131764",
"0.5364186",
"0.5352303",
"0.5316944",
"0.5308802",
"0.53043306",
"0.52103776",
"0.5204313",
"0.517564... | 0.6975702 | 1 |
Computes the variables that need to be computed from this task, and stores them in the self.data dict. This has one key for every variable of interest, and each of these keys points to a NumPy array with shape (N,) where N is the number of participants. The processed data comes from the self.raw dict, so make sure that... | def process_raw_data(self):
# Define some variables of interest.
vor = ["n_sentences", "n_correct", "p_correct", "median_RT", \
"mean_RT", "stdev_RT", "scaled_stdev_RT"]
# Get all participant names, or return straight away if no data was
# loaded yet.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_raw_data(self):\n \n # Get all participant names, or return straight away if no data was\n # loaded yet.\n if hasattr(self, \"raw\"):\n participants = self.raw.keys()\n participants.sort()\n else:\n self.data = None\n return... | [
"0.735433",
"0.6486896",
"0.62451255",
"0.61603683",
"0.6160291",
"0.605454",
"0.58846754",
"0.587648",
"0.587125",
"0.58672607",
"0.5865694",
"0.5862777",
"0.5860213",
"0.5857704",
"0.5793308",
"0.57828593",
"0.5727415",
"0.5701312",
"0.56965584",
"0.5690695",
"0.5669493",
... | 0.77125794 | 0 |
Make a list of all modules installed in this repository Returns a tuple of two lists, one for local modules and one for nfcore modules. The local modules are represented as direct filepaths to the module '.nf' file. Nfcore module are returned as file paths to the module directories. In case the module contains several ... | def get_installed_modules(dir, repo_type="modules"):
# initialize lists
local_modules = []
nfcore_modules = []
local_modules_dir = None
nfcore_modules_dir = os.path.join(dir, "modules", "nf-core")
# Get local modules
if repo_type == "pipeline":
local_modules_dir = os.path.join(dir, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_modules(self) -> Optional[List[str]]:\n module_list: List[str] = []\n for forge_module in self._forge_modules:\n module_list.append(forge_module.name)\n for git_module in self._git_modules:\n module_list.append(git_module.name)\n return module_list",
"de... | [
"0.68389815",
"0.6744586",
"0.6596824",
"0.65812105",
"0.6420615",
"0.6393576",
"0.6108857",
"0.6055035",
"0.60373896",
"0.6012906",
"0.5990414",
"0.5955053",
"0.5934572",
"0.59338784",
"0.5891398",
"0.5880061",
"0.5828444",
"0.5819975",
"0.5815788",
"0.5812122",
"0.58095336"... | 0.7559931 | 0 |
Flags a comment. Confirmation on GET, action on POST. | def flag(request, comment_id):
try:
comment = comments.get_object(pk=comment_id, site__id__exact=SITE_ID)
except comments.CommentDoesNotExist:
raise Http404
if request.POST:
userflags.flag(comment, request.user)
return HttpResponseRedirect('%sdone/' % request.path)
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flag_comment(request, submission_id, comment_id):\n # If not flagged, flag and decrement author's karma.\n # If flagged, undo flag and increment author's karma.\n # If upvoted, undo upvote and decrement author's karma.\n # If downvoted, undo upvote and increment author's karma.\n # No need to d... | [
"0.686533",
"0.67600733",
"0.6324674",
"0.6263772",
"0.6260797",
"0.61571467",
"0.6092327",
"0.6090107",
"0.6030129",
"0.60185254",
"0.59647995",
"0.596228",
"0.5958102",
"0.59516764",
"0.5940332",
"0.5812686",
"0.5787282",
"0.5782282",
"0.5781615",
"0.5746764",
"0.5725129",
... | 0.74663377 | 0 |
Load the pretrained model weights | def load_model_weights(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n if isinstance(self.pretrained, str):\n logger = get_root_logger()\n logger.info(f'load model from: {self.pretrained}')\n load_checkpoint(self, self.pretrained, strict=False, logger=logger)\n elif self.pretrained is None:\n pass\n ... | [
"0.81840134",
"0.80532205",
"0.7929311",
"0.7929236",
"0.78598017",
"0.7832963",
"0.78319764",
"0.777211",
"0.7706451",
"0.76879597",
"0.7657897",
"0.76478493",
"0.76099664",
"0.760729",
"0.7571413",
"0.7569362",
"0.7523776",
"0.75005925",
"0.75003874",
"0.7451586",
"0.741773... | 0.8207032 | 0 |
Set models to eval phase | def set_models_eval(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_eval(self):\n for m in self.models.values():\n m.eval()",
"def set_eval(self):\n self.model.eval()",
"def _set_eval(self):\n\n if self.model.__dict__['training']:\n self.model.eval()",
"def eval(self, logger=None):\n self.model.eval()\n self.mo... | [
"0.8009308",
"0.77162427",
"0.7589191",
"0.7418761",
"0.7214322",
"0.7055874",
"0.66177076",
"0.6542605",
"0.63525766",
"0.63517594",
"0.63286924",
"0.6325084",
"0.6280866",
"0.6221048",
"0.62003845",
"0.61510843",
"0.61048037",
"0.61048037",
"0.6102818",
"0.6097981",
"0.6087... | 0.7940041 | 1 |
Divides the deck in the argument into different most suitable groups. | def build_groups(self, computer_deck):
computer_deck.sort()
for card in computer_deck:
self.add_card_to_grps(card)
self.grps = sorted(self.grps, key = lambda x: -len(x))
logger.info(f"In computer.py/build_groups: computer: {self}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comp10001go_score_group(cards):\n \n # Put int a dictionary for each card which is scored based on its value\n # For example, J is 11, Q is 12 and K is 13, Ace is 20\n \n values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, \n '0': 10, 'J': 11, 'Q': 12, 'K': 13, ... | [
"0.5854269",
"0.58211976",
"0.57251054",
"0.5717913",
"0.5682591",
"0.56796926",
"0.5642106",
"0.5632018",
"0.5632018",
"0.5628769",
"0.5623917",
"0.5568811",
"0.5563554",
"0.5456946",
"0.5428732",
"0.5418285",
"0.54075015",
"0.5389676",
"0.5361663",
"0.5338872",
"0.53152716"... | 0.6242387 | 0 |
Adds the card in the argument to most suitable group in self.grps | def add_card_to_grps(self, card):
if card.val == self.card_joker.val or card.val == 0:
self.jokers.append(card)
else:
new_grp = True
for grp in self.grps[::-1]:
if len(grp) >= 4:
continue
is_a_set = True
val = grp[0].val
for grp_card in grp:
if grp_card.val != val:
is_a_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addCard(self,card:Card):\r\n self.cards.append(card)",
"def add_card(self, card):\n self.get_cards().append(card)",
"def add_card(self, card):\r\n self.hand.append(card)",
"def add(self, card):\n if card != None:\n self.cards.append(card)",
"def add_card(self, car... | [
"0.6217423",
"0.61076695",
"0.6085147",
"0.6068018",
"0.60551304",
"0.60551304",
"0.60551304",
"0.60551304",
"0.60133755",
"0.6000306",
"0.59344244",
"0.59153795",
"0.5910493",
"0.5905643",
"0.59050494",
"0.5889543",
"0.58820134",
"0.5878261",
"0.5874322",
"0.5856528",
"0.583... | 0.7281589 | 0 |
Makes a decision to choose a card from main deck or the discard pile. Returns True if computer chooses a card from discard_pile. | def make_move(self, dealer, discard_pile_card):
sleep(2)
choose_from_discard = True
# if discard pile is empty, choose from main deck
if discard_pile_card is None:
choose_from_discard = False
else:
# make a list of all the cards that I can use to make sets and lives
cards_needed = []
cards_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_discard(self, inpt):\n \n if inpt.isdigit() == False:\n return 0\n if int(inpt) > len(self.player_hand):\n print(\"\\nNumber of card entered is greater than number of cards\")\n print(\"Please try again \\n\")\n return 0\n if self.p... | [
"0.69175714",
"0.66825265",
"0.65739834",
"0.6558178",
"0.6550377",
"0.65189797",
"0.62760115",
"0.6226463",
"0.60765135",
"0.606275",
"0.5966651",
"0.5925703",
"0.5882706",
"0.5850044",
"0.5840374",
"0.5808426",
"0.57955235",
"0.5780476",
"0.5769852",
"0.57402384",
"0.571717... | 0.73254395 | 0 |
Function returns a dictionary with definitions of input data that are required by the component. | def input_data_definitions(self):
return {
self.key_feature_maps: DataDefinition([-1, self.feature_maps_depth, self.feature_maps_height, self.feature_maps_width], [torch.Tensor], "Batch of feature maps [BATCH_SIZE x FEAT_DEPTH x FEAT_HEIGHT x FEAT_WIDTH]"),
self.key_question_encodings: D... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_inputs(self):\n return {}",
"def get_required_params():\n return {}",
"def input_data_definitions(self):\n return {\n self.key_inputs: DataDefinition(\n [-1]*(self.num_inputs_dims-1) + [self.input_size],\n [list]*(self.num_inputs_dims-1) ... | [
"0.67774713",
"0.67546266",
"0.6709142",
"0.65007764",
"0.6477465",
"0.6333413",
"0.6286046",
"0.6230515",
"0.6222384",
"0.62112576",
"0.6200324",
"0.61986625",
"0.61236846",
"0.60840017",
"0.60487604",
"0.602839",
"0.6024194",
"0.6021029",
"0.6011841",
"0.6009006",
"0.600900... | 0.68205595 | 0 |
Function returns a dictionary with definitions of output data produced the component. | def output_data_definitions(self):
return {
self.key_outputs: DataDefinition([-1, self.output_size], [torch.Tensor], "Batch of outputs [BATCH_SIZE x OUTPUT_SIZE]")
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_data_definitions(self):\n return {}",
"def _get_output_dictionary(self):\n\n return_dictionary = {}\n\n for output_path in self.provided_outputs:\n return_dictionary[output_path.full_path] = self.get_value(output_path)\n\n return return_dictionary",
"def output... | [
"0.79142004",
"0.7396703",
"0.72935414",
"0.714347",
"0.68933153",
"0.67715305",
"0.6712582",
"0.6655782",
"0.6595801",
"0.6583784",
"0.6554832",
"0.65446115",
"0.6532827",
"0.6519101",
"0.65083754",
"0.64225125",
"0.6382813",
"0.6379986",
"0.63664275",
"0.6361891",
"0.635461... | 0.7505002 | 1 |
SEARCHING STRING FOR SUBSTRING | def search(self):
if self.substring in [None, ""]:
print("Invalid Value For Substring")
elif self.string in [None, ""]:
print("Invalid Value For String")
elif len(self.substring) > len(self.string):
print("Length of Substring Less Than String")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_sub_string_index(self, sub):\n try:\n return self.__dna.index(sub)\n except ValueError:\n raise ValueError",
"def kmp_search(full_str, sub_str):\n n, m = len(full_str), len(sub_str)\n result = []\n pi = get_partial_match(sub_str)\n begin, matched = 0, 0\n ... | [
"0.68273073",
"0.67984945",
"0.65509725",
"0.65256196",
"0.64502376",
"0.6448377",
"0.6401995",
"0.633604",
"0.6309308",
"0.6277728",
"0.6256694",
"0.6214137",
"0.61992896",
"0.61225504",
"0.6088924",
"0.60244846",
"0.59980816",
"0.59627664",
"0.5954518",
"0.59534174",
"0.592... | 0.6877445 | 0 |
Return ratio of cpu_dt / gpu_dt, which must be nonnegative numbers. If both arguments are zero, return NaN. If only gpu_dt is zero, return Inf. | def advantage(cpu_dt, gpu_dt):
assert gpu_dt >= 0 and cpu_dt >= 0
if gpu_dt == 0 and cpu_dt == 0:
return numpy.nan
elif gpu_dt == 0:
return numpy.inf
else:
return cpu_dt / gpu_dt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advantage(cpu_dt, gpu_dt):\r\n assert gpu_dt >= 0 and cpu_dt >= 0\r\n if gpu_dt == 0 and cpu_dt == 0:\r\n return numpy.nan\r\n elif gpu_dt == 0:\r\n return numpy.inf\r\n else:\r\n return cpu_dt / gpu_dt",
"def _get_cpu_percent(self):\n cpu_delta = None\n total_d... | [
"0.8289752",
"0.57311285",
"0.56998044",
"0.5637458",
"0.56284297",
"0.56284297",
"0.56284297",
"0.5575685",
"0.5518271",
"0.5502139",
"0.54596716",
"0.5448909",
"0.54423946",
"0.53975004",
"0.5327086",
"0.5315263",
"0.5311589",
"0.5273094",
"0.52623266",
"0.5258038",
"0.5258... | 0.8366045 | 0 |
The fct k_elemwise_unary_rowmajor_copy(used by cuda.copy()) in cuda_ndarray.cu is not well compiled with nvcc 3.0 and 3.1 beta. We found a workaround, so it sould work correctly. Without the workaround, this test fail. | def test_nvcc_bug():
shape = (5, 4)
aa = theano._asarray(numpy.random.rand(*shape), dtype='float32')
a = aa[::, ::-1]
b = cuda_ndarray.CudaNdarray(aa)[::, ::-1]
c = copy.copy(b)
d = copy.deepcopy(b)
assert numpy.allclose(a, numpy.asarray(b))
assert numpy.allclose(a, numpy.asarray(c))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nvcc_bug():\r\n shape = (5, 4)\r\n aa = theano._asarray(numpy.random.rand(*shape), dtype='float32')\r\n a = aa[::, ::-1]\r\n\r\n b = cuda_ndarray.CudaNdarray(aa)[::, ::-1]\r\n c = copy.copy(b)\r\n d = copy.deepcopy(b)\r\n\r\n assert numpy.allclose(a, numpy.asarray(b))\r\n assert nu... | [
"0.72793794",
"0.6675478",
"0.6635744",
"0.6531311",
"0.641663",
"0.6413818",
"0.63276094",
"0.6325242",
"0.63044846",
"0.6269978",
"0.6264248",
"0.6245012",
"0.6241492",
"0.61380696",
"0.6119953",
"0.6025284",
"0.5999566",
"0.59449136",
"0.58952457",
"0.5869716",
"0.58495384... | 0.72629005 | 1 |
This AWS Lambda function is invoked manually or by some other service or APIs. Then this function puts an event to an Amazon EventBridge. | def lambda_handler(event, context):
client = boto3.client('events')
event_to_put = {
"source": "aws-lambda-function"
}
event_to_put.update(**event)
try:
response = client.put_events(
Entries=[
{
'Source': 'learn.eventbridge',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_event(event: dict):\n\n eventbridge.put_events(Entries=[event])",
"def event(event, context):\n# Sample event:\n #\n # _event = { \"Records\":[\n # {\n # \"eventVersion\":\"2.1\",\n # \"eventSource\":\"aws:s3\",\n # \"awsRegion\":\"us-east-1\",\n ... | [
"0.68858373",
"0.6696065",
"0.66646093",
"0.66366494",
"0.6604961",
"0.6559077",
"0.6559077",
"0.6540618",
"0.6514244",
"0.65035176",
"0.64954466",
"0.64871466",
"0.64862555",
"0.6477732",
"0.6477732",
"0.6477732",
"0.6477732",
"0.6477732",
"0.6477732",
"0.6477732",
"0.647773... | 0.7800985 | 0 |
Calculate band according to Stavenga et al (1993). | def stavenga1993_band_calculation(
x: np.ndarray, a: Union[float, np.ndarray], b: Union[float, np.ndarray]
) -> np.ndarray:
return np.exp(-a * x**2 * (1 + b * x + 3 / 8 * (b * x) ** 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_band(value, bands):\n for band in bands:\n if band > value:\n return band",
"def bands(self) -> int:\n ...",
"def calbands( band = 0, tmo = 30 ) :\n optimizeThresholds(band,tmo)\n flattenPhases(band,tmo)\n calibrateSpectra(band=band,tmo=tmo)",
"def DrawBands... | [
"0.6755474",
"0.6549916",
"0.6544884",
"0.62848055",
"0.6246133",
"0.62358135",
"0.62323934",
"0.61631835",
"0.61161864",
"0.6114344",
"0.608871",
"0.60167605",
"0.60042655",
"0.5974235",
"0.5936892",
"0.5935502",
"0.5911872",
"0.5887876",
"0.585313",
"0.58207893",
"0.5817405... | 0.71052694 | 0 |
Set up private and public key into DiffieHellman object. | def setup_keys(self, dh_object, public_key, private_key):
public_numbers = DHPublicNumbers(public_key, dh_object.parameter_numbers)
private_numbers = DHPrivateNumbers(private_key, public_numbers)
dh_object.private_key = private_numbers.private_key(default_backend()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self._keypair = RSA.generate(2048)\n self.public_key = self._keypair.publickey().exportKey()",
"def setUp(self):\n\n self.private_key = self.get_new_key()\n self.public_key = self.private_key.public_key()\n\n self.pem_private_key = self.private_key.private... | [
"0.6717525",
"0.6687376",
"0.6348768",
"0.6244429",
"0.61797005",
"0.6172647",
"0.604477",
"0.59947807",
"0.59289205",
"0.59186375",
"0.59086144",
"0.5873395",
"0.5848099",
"0.5782095",
"0.5766761",
"0.5744683",
"0.5743434",
"0.5717811",
"0.5714252",
"0.56985873",
"0.5693162"... | 0.7158014 | 0 |
Compute weighted UniFrac with or without branch length normalization | def weighted_unifrac(u_counts, v_counts, otu_ids, tree, normalized=False,
validate=True, **kwargs):
if validate:
_validate(u_counts=u_counts, v_counts=v_counts,
otu_ids=otu_ids, tree=tree)
u_obs_otu_counts = _observed_otu_counts(u_counts, otu_ids)
u_total_count... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_weights(self, w):\n n = w.astype(np.float64, copy=True)\n c = float(np.sum(w))\n n /= c\n return n",
"def compute_norm_fac_per_weight(fan_in):\n ksi = 1. / math.sqrt(fan_in)\n return (1 / 3) * ksi ** 2",
"def u(self, k, m, z):\n result = (1. - self.fb) * sel... | [
"0.62866193",
"0.6168332",
"0.60630053",
"0.60494703",
"0.5957002",
"0.59218806",
"0.5918151",
"0.58993274",
"0.58558947",
"0.5850155",
"0.5842917",
"0.5827281",
"0.5779808",
"0.5770108",
"0.5739889",
"0.56738794",
"0.56464136",
"0.56451756",
"0.56447554",
"0.56447554",
"0.56... | 0.61756164 | 1 |
Test a composing expression that has vectors with variable attributes | def test_compose_vectors_with_attrs(self):
oe = expression.OperationalExpression
v1, v2 = map(expression.Variable, ["v1", "v2"])
exp = 1 + V(v1.x, v2.y)
expected_exp = oe('+', 1, V(v1.x, v2.y))
self.assert_equal(exp, expected_exp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_complex_extraction_of_values(self):\n\t\ta = bf.Var(\"a\")\n\t\tb = bf.Var(\"b\")\n\t\tc = bf.Var(\"c\")\n\t\tformula = bf.And([bf.Or([b, a, c]), bf.Or([bf.Not(a), bf.Not(c)]), bf.Not(b)])\n\t\tself.assertEqual([\"a\", \"b\", \"c\"], au.extract_variables(formula), \"Invalid variables extracted, expected [... | [
"0.6213941",
"0.60124946",
"0.58145964",
"0.57848656",
"0.57236844",
"0.57096756",
"0.567647",
"0.56665623",
"0.5648646",
"0.56261915",
"0.5604976",
"0.55950737",
"0.55904126",
"0.55702084",
"0.5555966",
"0.5552883",
"0.5525541",
"0.55212194",
"0.54941386",
"0.5478895",
"0.54... | 0.78425336 | 0 |
Function to start the process of saving the commands to xml. | def Write_XML(gui):
# lock buttons
gui.action_lock('Lock', gui.save_button)
# clear output
gui.output_clear()
# get the desired delay from the gui.
delay_time = gui.get_delay()
# get the desired ascii delay from the gui.
ascii_time = gui.get_ascii_delay()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _send_xml_cli(self, commands, no_end=False):\n if isinstance(commands, str):\n commands = [commands]\n if not no_end:\n commands.append(\"end\")\n self.logger.debug(\"Sending commands {} to {}\".format(str(commands), self.host))\n try:\n self._ncc.nx... | [
"0.6063771",
"0.5795947",
"0.5710056",
"0.5695167",
"0.5617394",
"0.5534581",
"0.5529304",
"0.551602",
"0.5449832",
"0.54495037",
"0.5444347",
"0.5399038",
"0.53412414",
"0.53403497",
"0.530564",
"0.5292865",
"0.529165",
"0.52267593",
"0.52267593",
"0.52267593",
"0.52267593",... | 0.5952237 | 1 |
Function to load a command set, delays and address from a saved xml file | def Load_XML(gui):
# lock the buttons
gui.action_lock('Lock', gui.xml_button)
# prepare to open a window to load a file through
file_opt = options = {}
options['defaultextension'] = '.xml'
options['filetypes'] = [('xml files', '.xml')]
options['initialdir'] = os.getcwd() + '/xml... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadData(self,filepath):\r\n self.removeCheckbuttons()\r\n self.tree = ET.parse(filepath)# Parse xml Tree\r\n self.data = self.tree.getroot().find(\"data\")# Find Data\r\n self.sensors = [i.text for i in self.tree.getroot().find('columns')]# Get Sensor Names\r\n for s in self... | [
"0.6020558",
"0.55900437",
"0.547431",
"0.5467832",
"0.54143196",
"0.54053646",
"0.5335379",
"0.5326394",
"0.5290998",
"0.5274877",
"0.5269875",
"0.526416",
"0.52612525",
"0.52557683",
"0.5247965",
"0.52428174",
"0.52398396",
"0.52201504",
"0.52079225",
"0.52027446",
"0.51986... | 0.6403766 | 0 |
Function to read in the default values for GUI parameters from XML | def update_gui_defaults(GUI_defaults):
# failure flag
config_import_error = False
# xml source directory
src_dir = os.getcwd() + '\\src'
# attempt to parse the xml file and get it's root
try:
tree = ET.parse(src_dir + '\\pySCPI_config.xml')
root = tree.getroot()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initDefaults(self):\n return _libsbml.Parameter_initDefaults(self)",
"def _read_custom_pars(self):\n if self.use_defaults:\n param_set = \"default_values\"\n else:\n param_set = \"parameters\"\n self.outpars = self.input_cfg_json_data[param_set][self.step_tit... | [
"0.60259306",
"0.5917316",
"0.5879052",
"0.58556134",
"0.5806529",
"0.5773313",
"0.57520735",
"0.5735366",
"0.5723001",
"0.5692128",
"0.5658283",
"0.56419754",
"0.5638085",
"0.5636669",
"0.5633002",
"0.5620782",
"0.55702066",
"0.55439883",
"0.55336916",
"0.5531336",
"0.552916... | 0.6818052 | 0 |
Write an Aardvark compatible .xml file that can be used with the Total phase system or loaded back into pySCPI | def create_XML(directives, gui):
# unpack the directives
commands = directives.command_list
Delay = directives.delay_time
Ascii_delay = directives.ascii_time
addr = directives.addr
# Start XML
aardvark = ET.Element('aardvark')
# starup comment for historical reasons
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saving_file(xml):\r\n\r\n xml_string = etree.tostring(xml)\r\n parsed = minidom.parseString(xml_string)\r\n with open(self.app_path + \"\\\\temp_\\\\\" + file_name + \".xml\", \"w\") as file:\r\n file.write(parsed.toprettyxml(indent=\" \"))",
"def export... | [
"0.6515338",
"0.63872993",
"0.6364386",
"0.6297682",
"0.62434924",
"0.6230958",
"0.621191",
"0.60897154",
"0.60321975",
"0.6010241",
"0.5969192",
"0.5957748",
"0.59319156",
"0.59156126",
"0.58857924",
"0.5852645",
"0.58315367",
"0.57871634",
"0.5785052",
"0.5784642",
"0.57793... | 0.644834 | 1 |
Function to improve the readability of the xml file produced. | def beautify_xml(XML):
# convert XML file to modifiable string to beautify it
text_string = ET.tostring(XML, encoding='UTF-8', method='xml')
# insert line breaks before end of file tag
file_string = text_string.replace('</aardvark>', '\n\n</aardvark>')
# insert double new line before comme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml(self):\n raise NotImplementedError('must be implemented by all subclasses')",
"def writeXml(self):\n text = u' type=\"%s\"' % self.typeName\n if self.format:\n text += u' format=\"%s\"' % escape(self.format, treedoc.escDict)\n if self.prefix:\n text += u'... | [
"0.65539247",
"0.63723135",
"0.63601106",
"0.633199",
"0.63063323",
"0.63027126",
"0.6289212",
"0.6213498",
"0.62073106",
"0.6194992",
"0.6152282",
"0.6151681",
"0.6146073",
"0.6137961",
"0.61245584",
"0.609112",
"0.6061833",
"0.606017",
"0.60590106",
"0.6041505",
"0.6037666"... | 0.676322 | 0 |
Generate the set of instructions to install the runtime specific components from a build in a previous stage. Examples ```python a = arm_allinea_compiler(...) Stage0 += a Stage1 += a.runtime() ``` | def runtime(self, _from='0'):
instructions = []
instructions.append(comment('Arm Allinea Studio'))
gcc_path = posixpath.join(
self.__prefix,
'gcc-{0}_Generic-AArch64_{1}_aarch64-linux'.format(
self.__gcc_version, self.__directory_string))
llvm_pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_runtime(self):\n s0 = Stage()\n s0 += gnu()\n s0 += shell(commands=['gcc -o hello hello.c'])\n s1 = Stage()\n s1 += s0.runtime()\n self.assertEqual(str(s1),\nr'''# GNU compiler runtime\nRUN yum install -y \\\n libgfortran \\\n libgomp && \\\n rm -... | [
"0.6434725",
"0.620022",
"0.61711156",
"0.5887484",
"0.5721989",
"0.5680253",
"0.5664536",
"0.550372",
"0.5462016",
"0.53730744",
"0.5336362",
"0.5336342",
"0.53230923",
"0.5300937",
"0.52958727",
"0.5276965",
"0.52585906",
"0.52580607",
"0.5237822",
"0.51931524",
"0.51877236... | 0.68220097 | 0 |
load stock time and price data for two stocks The return values (d1,p1,d2,p2) are the trade time (in days) and prices for stocks 1 and 2 (intc and aapl) | def get_two_stock_data():
ticker1, ticker2 = 'INTC', 'AAPL'
file1 = cbook.get_sample_data('INTC.dat.gz')
file2 = cbook.get_sample_data('AAPL.dat.gz')
M1 = fromstring(file1.read(), '<d')
M1 = resize(M1, (M1.shape[0]//2, 2))
M2 = fromstring(file2.read(), '<d')
M2 = resize(M2, (M2.shape[0]//... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(pair, other):\n days_ago = 7\n endtime = int(time())\n starttime = endtime - 60 * 60 * 24 * days_ago\n\n geckourl = '%s/markets?vs_currency=%s&ids=%s' % (API, pair[\"currency\"],\n pair[\"coin\"])\n liveprice = requests.get(geckourl).j... | [
"0.6660464",
"0.6615989",
"0.64531744",
"0.6355358",
"0.6307623",
"0.6276847",
"0.6220814",
"0.61832434",
"0.60175335",
"0.60079485",
"0.5918773",
"0.585842",
"0.5851734",
"0.5843024",
"0.5840139",
"0.5792696",
"0.5774242",
"0.57644534",
"0.574364",
"0.57333547",
"0.57249",
... | 0.78072286 | 0 |
dm the dimensionality of the model h the number of heads hidden the number of hidden units in the fully connected layer drop_rate the dropout rate | def __init__(self, dm, h, hidden, drop_rate=0.1):
super().__init__()
self.mha = MultiHeadAttention(dm, h)
self.ffn = point_wise_feed_forward_network(dm, hidden)
self.layernorm1 = tf.keras.layers.LayerNormalization(epsilon=1e-6)
self.layernorm2 = tf.keras.layers.LayerNormalizatio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dm, h, hidden, drop_rate=0.1):\n super().__init__()\n\n self.mha1 = MultiHeadAttention(dm, h)\n self.mha2 = MultiHeadAttention(dm, h)\n\n self.ffn = point_wise_feed_forward_network(dm, hidden)\n\n self.layernorm1 = tf.keras.layers.LayerNormalization(epsilon=1e-... | [
"0.6785643",
"0.67229116",
"0.6380261",
"0.6364374",
"0.6323939",
"0.63031614",
"0.625298",
"0.6168952",
"0.61116683",
"0.603366",
"0.60317063",
"0.59837466",
"0.5970474",
"0.5934955",
"0.5934622",
"0.590435",
"0.5896029",
"0.5895661",
"0.5886991",
"0.5885217",
"0.58829165",
... | 0.69252604 | 0 |
dm the dimensionality of the model h the number of heads hidden the number of hidden units in the fully connected layer drop_rate the dropout rate | def __init__(self, dm, h, hidden, drop_rate=0.1):
super().__init__()
self.mha1 = MultiHeadAttention(dm, h)
self.mha2 = MultiHeadAttention(dm, h)
self.ffn = point_wise_feed_forward_network(dm, hidden)
self.layernorm1 = tf.keras.layers.LayerNormalization(epsilon=1e-6)
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dm, h, hidden, drop_rate=0.1):\n super().__init__()\n self.mha = MultiHeadAttention(dm, h)\n self.ffn = point_wise_feed_forward_network(dm, hidden)\n\n self.layernorm1 = tf.keras.layers.LayerNormalization(epsilon=1e-6)\n self.layernorm2 = tf.keras.layers.LayerN... | [
"0.6926322",
"0.67232263",
"0.6377668",
"0.63622075",
"0.63210016",
"0.6301156",
"0.62541866",
"0.6165916",
"0.61140305",
"0.6033471",
"0.60285664",
"0.5983597",
"0.59702533",
"0.5933133",
"0.5933072",
"0.5901348",
"0.5895014",
"0.58933127",
"0.588453",
"0.5882685",
"0.588206... | 0.6786822 | 1 |
x a tensor of shape (batch, target_seq_len, dm)containing the input to the decoder encoder_output a tensor of shape (batch, input_seq_len, dm) containing the output of the encoder training a boolean to determine if the model is training look_ahead_mask the mask to be applied to the first multi head attention layer padd... | def call(self, x, encoder_output, training,
look_ahead_mask, padding_mask):
seq_len = tf.shape(x)[1]
attention_weights = {}
x = self.embedding(x)
x *= tf.math.sqrt(tf.cast(self.dm, tf.float32))
x += self.positional_encoding[:, :seq_len, :]
x = self.dropout(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, state, encoder_padding_mask):\n residual = state.clone()\n\n '''\n ___QUESTION-6-DESCRIBE-D-START___\n What is the purpose of encoder_padding_mask? What will the output shape of `state' Tensor \n be after multi-head attention? HINT: formulate your answer in ter... | [
"0.68980443",
"0.6785151",
"0.672374",
"0.666072",
"0.6574727",
"0.649962",
"0.64837235",
"0.6482765",
"0.6397254",
"0.63569766",
"0.634568",
"0.6323986",
"0.63232094",
"0.62556964",
"0.62244546",
"0.6217759",
"0.6191466",
"0.6188659",
"0.61652607",
"0.6162906",
"0.6146513",
... | 0.72239923 | 0 |
N the number of blocks in the encoder and decoder dm the dimensionality of the model h the number of heads hidden the number of hidden units in the fully connected layers input_vocab the size of the input vocabulary target_vocab the size of the target vocabulary max_seq_input the maximum sequence length possible for th... | def __init__(self, N, dm, h, hidden, input_vocab, target_vocab,
max_seq_input, max_seq_target, drop_rate=0.1):
super().__init__()
self.encoder = Encoder(N, dm, h, hidden, input_vocab,
max_seq_input, drop_rate)
self.decoder = Decoder(N, dm, h, hidde... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n super(Decoder_1m, self).__init__()\n self.lconvtwos = nn.ModuleList(\n [\n nn.Sequential(\n nn.Dropout(p=0.1),\n nn.Conv2d(128, 32, kernel_size=(3, 3), padding=1),\n nn.BatchNorm2d(32),\n ... | [
"0.6649107",
"0.6574562",
"0.6515605",
"0.64855504",
"0.6468661",
"0.64408153",
"0.64387065",
"0.64374036",
"0.6415218",
"0.63973427",
"0.6371662",
"0.6340037",
"0.62952334",
"0.6289063",
"0.62647885",
"0.62570995",
"0.6251119",
"0.6237663",
"0.6213453",
"0.61888",
"0.6172886... | 0.7143646 | 0 |
Aggregate metric value across towers. | def _aggregate_across_towers(metrics_collections, metric_value_fn, *args):
def fn(distribution, *a):
"""Call `metric_value_fn` in the correct control flow context."""
if hasattr(distribution, '_outer_control_flow_context'):
# If there was an outer context captured before this method was ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _aggregate_across_towers(metrics_collections, metric_value_fn, *args):\n def fn(distribution, *a):\n \"\"\"Call `metric_value_fn` in the correct control flow context.\"\"\"\n if hasattr(distribution, '_outer_control_flow_context'):\n # If there was an outer context captured before this method was c... | [
"0.6474678",
"0.61006385",
"0.60297525",
"0.59245074",
"0.584058",
"0.5800489",
"0.56997293",
"0.56921005",
"0.56350535",
"0.5630873",
"0.56030244",
"0.5590685",
"0.5583606",
"0.55782723",
"0.5570165",
"0.5558878",
"0.55482966",
"0.5541951",
"0.5541951",
"0.55373263",
"0.5535... | 0.6526208 | 0 |
Call `metric_value_fn` in the correct control flow context. | def fn(distribution, *a):
if hasattr(distribution, '_outer_control_flow_context'):
# If there was an outer context captured before this method was called,
# then we enter that context to create the metric value op. If the
# caputred context is `None`, ops.control_dependencies... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fn(distribution, *a):\n if hasattr(distribution, '_outer_control_flow_context'):\n # If there was an outer context captured before this method was called,\n # then we enter that context to create the metric value op. If the\n # caputred context is `None`, ops.control_dependencies(None) gives ... | [
"0.6464017",
"0.58839256",
"0.5767293",
"0.574908",
"0.55788815",
"0.5566902",
"0.548517",
"0.5422161",
"0.537603",
"0.5365945",
"0.52946395",
"0.52842236",
"0.51841676",
"0.5158378",
"0.515165",
"0.51359975",
"0.51274526",
"0.5114945",
"0.5100913",
"0.50856",
"0.5031937",
... | 0.6583132 | 0 |
return True if the ip address exists in the subnet address otherwise return False | def address_exists_in_network(ip_address, net_n_bits):
ip_address = struct.unpack('<L', socket.inet_aton(ip_address))[0]
net, bits = net_n_bits.split('/')
net_address = struct.unpack('<L', socket.inet_aton(net))[0]
net_mask = ((1L << int(bits)) - 1)
return ip_address & net_mask == net_address & net_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ipcalc(self, ipaddr, subnet):\n if IPNetwork(ipaddr) in IPNetwork(subnet):\n return True\n else:\n return False",
"def __contains__(self, address):\n return any([\n ipaddress.ip_address(address) in network\n for network in self.networks... | [
"0.81065077",
"0.73484886",
"0.7259473",
"0.6860128",
"0.66347903",
"0.66137534",
"0.65785533",
"0.6569621",
"0.6553362",
"0.65437984",
"0.6522481",
"0.6495472",
"0.64427274",
"0.6418303",
"0.6388048",
"0.63813025",
"0.6377752",
"0.6375657",
"0.6367962",
"0.6317943",
"0.62854... | 0.74176997 | 1 |
examine a `obj` for given `items`. if all `items` are found in `obj` return True otherwise false. where `obj` is a dictionary and `items` is list of dictionaries | def dict_has_items(obj, items):
has_items = False
if isinstance(obj, basestring):
obj = json.loads(obj)
for item in items:
for lookup_key, lookup_val in item.iteritems():
if lookup_key in obj and obj[lookup_key] == lookup_val:
has_items = True
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self, items):\n if type(items) != list:\n raise PJFInvalidType(items, list)\n ret = 0\n for item in items:\n for key in self.__dict__:\n if isinstance(self.__dict__[key], JsonFactory):\n ret += item in self.__dict__[key]\... | [
"0.7628567",
"0.7596022",
"0.7045878",
"0.7019639",
"0.6952219",
"0.6796098",
"0.6757188",
"0.66694134",
"0.65806514",
"0.65183485",
"0.64792097",
"0.6399194",
"0.63207513",
"0.62711006",
"0.62627935",
"0.6229428",
"0.6218",
"0.61813146",
"0.61776984",
"0.6154515",
"0.6083926... | 0.831852 | 0 |
extracts all query params which starts with data__ | def extract_data_params(request):
data_params = []
for key, val in request.QUERY_PARAMS.iteritems():
if key.startswith('data__'):
data_params.append({key[6:]: val})
return data_params | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_query_from_data(data):\n query_params = {}\n for key, value in data.items():\n if key == 'title':\n Product._set_query_params(query_params, key, value)\n elif isinstance(value, str):\n param_key = f'params.{str(key)}'\n Produc... | [
"0.67417115",
"0.6304133",
"0.6147768",
"0.611534",
"0.61150604",
"0.60223615",
"0.59562993",
"0.59472",
"0.5920123",
"0.5918791",
"0.5805078",
"0.5745934",
"0.5745177",
"0.5745177",
"0.57365286",
"0.57353395",
"0.5715842",
"0.5676375",
"0.56709933",
"0.5644437",
"0.56289977"... | 0.8259755 | 0 |
Get a list of filehandle numbers from logger to be handed to DaemonContext.files_preserve | def getLogFileHandles(logger):
handles = []
for handler in logger.handlers:
handles.append(handler.stream.fileno())
if logger.parent:
handles += getLogFileHandles(logger.parent)
return handles | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fileHandlers(self):\n fileHandlers = list()\n handlers = self.logger.handlers\n for handler in handlers:\n try:\n if handler._name.startswith(\"LogFile-\"):\n fileHandlers.append(handler)\n except:\n pass\n retur... | [
"0.5972954",
"0.5800055",
"0.57424676",
"0.57307327",
"0.56020564",
"0.5504199",
"0.5497882",
"0.5497588",
"0.5413338",
"0.53834784",
"0.5348",
"0.5341512",
"0.5340336",
"0.5339177",
"0.5326712",
"0.5315424",
"0.5308099",
"0.52998996",
"0.52989507",
"0.5291758",
"0.52897704",... | 0.6881586 | 0 |
Expire credentials if it has been too long. | def maybe_expire_credentials(self):
time_since_last_auth = time.time() - self.last_auth
logging.debug("Time since last auth {}.".format(time_since_last_auth))
if time_since_last_auth > CREDENTIALS_LIFETIME:
logging.info("Expiring credentials.")
hashpasslib.forget_master() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_password_expire(self):\n user_dn = \"cn=skip,ou=nerdherd,dc=bonsai,dc=test\"\n cli = LDAPClient(\"ldap://%s\" % self.ipaddr)\n cli.set_password_policy(True)\n cli.set_credentials(\"SIMPLE\", (user_dn, \"p@ssword\"))\n conn, ctrl = cli.connect()\n entry = conn.sear... | [
"0.65905154",
"0.65896976",
"0.63954246",
"0.6326304",
"0.63095117",
"0.62831146",
"0.62369967",
"0.62012815",
"0.6155768",
"0.61305135",
"0.60969484",
"0.6067817",
"0.60407585",
"0.6034622",
"0.60302615",
"0.6014281",
"0.6014172",
"0.59970254",
"0.59674865",
"0.5948415",
"0.... | 0.84588826 | 0 |
Gets the password via pinentry. Calls use_master if it works, otherwise does nothing. | def get_master_gui(use_bcrypt):
try:
pw = pinentry.get_pin(description="Enter hashpass master password:",
prompt="Password:")
while pw is None or not hashpasslib.is_correct_master(pw):
if pw == None:
logging.warn("User canceled password entry... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_password(self):\r\n return self._password",
"def get_password(self):\n mpw = master_pass.MPW(self.user, self.master_password)\n return mpw.password(self.ucs_server)",
"def _get_password(self):\n return self._password",
"def masterPassword(self):\r\n return self... | [
"0.6644678",
"0.66201836",
"0.66150063",
"0.65591604",
"0.65305823",
"0.64333534",
"0.6419651",
"0.63834316",
"0.63571024",
"0.63272214",
"0.63112754",
"0.63109064",
"0.62714154",
"0.6229617",
"0.62100583",
"0.61854845",
"0.617317",
"0.61616355",
"0.6161462",
"0.6152583",
"0.... | 0.7349455 | 0 |
Remove html tags from a string | def remove_html_tags(text):
print('VOU REMOVER AS TAGS DA STRING')
clean = re.compile('<.*?>')
print('',re.sub(clean, '', text))
return re.sub(clean, '', text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_html_tags(self,text):\n #https://medium.com/@jorlugaqui/how-to-strip-html-tags-from-a-string-in-python-7cb81a2bbf44\n clean = re.compile('<.*?>')\n return re.sub(clean, '', text)",
"def remove_html_tags(text):\r\n clean = re.compile('<.*?>')\r\n return re.sub(clean, '', text... | [
"0.8504336",
"0.8412507",
"0.84054434",
"0.83764374",
"0.83524",
"0.83524",
"0.83290035",
"0.8306803",
"0.8299078",
"0.82290506",
"0.82162106",
"0.81617314",
"0.8151329",
"0.8143021",
"0.812958",
"0.80990636",
"0.8071161",
"0.80520815",
"0.80184025",
"0.8011543",
"0.79809445"... | 0.8636281 | 0 |
Plot the grid generated by a flow. The displacement can be too small, so we add a scale factor | def plot_grid(ax, flow, factor=10):
grid = factor * flow[:, ::8, ::8]
lin_range = np.linspace(0, 512, 64)
x, y = np.meshgrid(lin_range, lin_range)
x = x + grid[0, ...]
y = y + grid[1, ...]
y = y
segs1 = np.stack((x, y), axis=2)
segs2 = segs1.transpose(1, 0, 2)
ax.add_collection(Line... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_grid(frame, episode_nr):\n plt.grid('on')\n ax = plt.gca()\n ax.set_xticks(np.arange(0.5, 10, 1))\n ax.set_yticks(np.arange(0.5, 10, 1))\n ax.set_xticklabels([])\n ax.set_yticklabels([])\n ax.imshow(frame, cmap='binary')\n ax.set_title(\"Episode {}\".format(episode_nr))\n plt.pa... | [
"0.64805615",
"0.6395517",
"0.63600767",
"0.6321238",
"0.6193627",
"0.61895263",
"0.6010808",
"0.59778",
"0.5938082",
"0.5934734",
"0.59344804",
"0.592055",
"0.58944136",
"0.5893408",
"0.5877107",
"0.58597356",
"0.58251846",
"0.5823605",
"0.58234686",
"0.58124083",
"0.5784960... | 0.7789411 | 0 |
Gets the gif_fps of this GIFOutput. The frame rate of the GIF. Default is the Video frame rate | def gif_fps(self):
return self._gif_fps | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fps(self):\n return self._num_frames / (datetime.now() - self._start).total_seconds()",
"def get_fps(self):\n # Take difference.\n interframe_intervals = np.diff(self.data[\"t\"])\n\n # Inter-frame interval in milliseconds.\n mean_interval = np.mean(interframe_intervals... | [
"0.7494257",
"0.7355209",
"0.7317423",
"0.71695226",
"0.70986986",
"0.7062496",
"0.70086706",
"0.69287163",
"0.69171",
"0.68915033",
"0.68721455",
"0.6822134",
"0.6741372",
"0.6735853",
"0.67118305",
"0.6672671",
"0.662301",
"0.662301",
"0.6597375",
"0.6547688",
"0.64681935",... | 0.8816731 | 0 |
Sets the gif_fps of this GIFOutput. The frame rate of the GIF. Default is the Video frame rate | def gif_fps(self, gif_fps):
if gif_fps is not None and gif_fps > 30:
raise ValueError("Invalid value for `gif_fps`, must be a value less than or equal to `30`")
self._gif_fps = gif_fps | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gif_fps(self):\n return self._gif_fps",
"def set_fps(self, fps=25):\n raise NotImplementedError(\"set_fps is not implemented\")",
"def set_framerate(self, framerate):\n self._framerate = int(framerate)",
"def set_fps(self, fps=25):\n # self._root.knob('fps').setValue(fp... | [
"0.74496573",
"0.69945496",
"0.6775548",
"0.6714409",
"0.62625706",
"0.6213025",
"0.59868544",
"0.5918831",
"0.5851581",
"0.5825714",
"0.5825714",
"0.5749928",
"0.5744896",
"0.5659933",
"0.5629519",
"0.56099874",
"0.5604374",
"0.5597134",
"0.55247176",
"0.550153",
"0.54935694... | 0.85410434 | 0 |
Gets the color_depth of this GIFOutput. Amount of colors in palette | def color_depth(self):
return self._color_depth | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_explored(self):\n return self.__num_explored",
"def queryNumberOfColors(self):\n self._numColorsInUse = \\\n self._readInt('How many colors are available', 2, len(self._palette))\n return self._numColorsInUse",
"def num_depth(self):\n return len(self._sizes) + len(self._ra... | [
"0.68169844",
"0.65945107",
"0.65047747",
"0.64739394",
"0.6416106",
"0.6415538",
"0.6361293",
"0.63216704",
"0.6281688",
"0.62379676",
"0.622544",
"0.61876786",
"0.6183844",
"0.6128096",
"0.60531795",
"0.60531795",
"0.60180753",
"0.592283",
"0.5902543",
"0.5848112",
"0.58416... | 0.8169639 | 0 |
Sets the color_depth of this GIFOutput. Amount of colors in palette | def color_depth(self, color_depth):
self._color_depth = color_depth | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetDepth(*args, **kwargs):\n return _gdi_.Bitmap_SetDepth(*args, **kwargs)",
"def set_depth(self, depth):\n self._depth = depth\n if self._scaled_image_coordinates is None:\n self._initialise()\n else:\n self._update_depth()",
"def color_depth(self):\n ... | [
"0.6401659",
"0.6380821",
"0.6300926",
"0.62612724",
"0.5997467",
"0.5974511",
"0.5967667",
"0.5931414",
"0.5931148",
"0.59209645",
"0.58476746",
"0.58119255",
"0.57820714",
"0.57815474",
"0.5667481",
"0.5611237",
"0.5600413",
"0.5562935",
"0.5406338",
"0.53640157",
"0.535976... | 0.756508 | 0 |
Gets the gif_loop of this GIFOutput. If to loop the GIF. 1 is no loop, 0 is infinite loops, and other numbers are number of loops. | def gif_loop(self):
return self._gif_loop | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gif_loop(self, gif_loop):\n if gif_loop is not None and gif_loop < -1:\n raise ValueError(\"Invalid value for `gif_loop`, must be a value greater than or equal to `-1`\")\n\n self._gif_loop = gif_loop",
"def get_loop(self):\n\n log(\"Getting loop for {} at {}\".format(self._lo... | [
"0.6869839",
"0.6846498",
"0.622958",
"0.6160181",
"0.5945182",
"0.57386464",
"0.55551046",
"0.554464",
"0.53494954",
"0.5158095",
"0.5133926",
"0.5090462",
"0.50807434",
"0.5023866",
"0.5007544",
"0.4975262",
"0.49709076",
"0.49350947",
"0.4925683",
"0.4912694",
"0.48901445"... | 0.8365495 | 0 |
Sets the gif_loop of this GIFOutput. If to loop the GIF. 1 is no loop, 0 is infinite loops, and other numbers are number of loops. | def gif_loop(self, gif_loop):
if gif_loop is not None and gif_loop < -1:
raise ValueError("Invalid value for `gif_loop`, must be a value greater than or equal to `-1`")
self._gif_loop = gif_loop | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gif_loop(self):\n return self._gif_loop",
"def __loop(self):\n if self.loops is \"inf\":\n self.play()\n else:\n if self.loops > self.current_loop:\n self.current_loop += 1\n self.play()\n else:\n self.stop()",... | [
"0.7291405",
"0.6020012",
"0.59639007",
"0.57001525",
"0.54498154",
"0.54039925",
"0.53877467",
"0.532594",
"0.5293056",
"0.523517",
"0.52066076",
"0.51812136",
"0.51310414",
"0.50876",
"0.50081354",
"0.49736694",
"0.49516755",
"0.4897915",
"0.48965508",
"0.4870012",
"0.48547... | 0.81786376 | 0 |
Gets the overlay of this GIFOutput. | def overlay(self):
return self._overlay | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gif_loop(self):\n return self._gif_loop",
"def layer(self):\n return self.GetLayer()",
"def draw_overlay(self):\n pass",
"def gif(self):\n\n if self._gif is None:\n\n url = self.url.replace('f=fits', 'f=gif')\n\n try:\n url_data = urllib.re... | [
"0.58112276",
"0.5789104",
"0.5632958",
"0.5590468",
"0.55475557",
"0.5475671",
"0.54720825",
"0.54714066",
"0.54669756",
"0.54507834",
"0.54363924",
"0.5428256",
"0.5422926",
"0.54158616",
"0.5394534",
"0.5377252",
"0.5376429",
"0.53099346",
"0.53099346",
"0.53099346",
"0.52... | 0.77030104 | 0 |
Sets the overlay of this GIFOutput. | def overlay(self, overlay):
self._overlay = overlay | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_overlay(self, image_path):\n if not osp.isfile(image_path):\n raise ValueError(\"Invalid background image '{}'\".format(image_path))\n self._overlay_image = image_path\n self._final = None # Force rebuild",
"def draw_overlay(self):\n pass",
"def set_image_overlay... | [
"0.6185808",
"0.6119764",
"0.5662509",
"0.56069213",
"0.54998136",
"0.5440037",
"0.54383683",
"0.53346497",
"0.5262761",
"0.5242616",
"0.5206041",
"0.5164456",
"0.51297665",
"0.5111875",
"0.50731605",
"0.50062686",
"0.4991521",
"0.4922425",
"0.4873345",
"0.48438504",
"0.48411... | 0.71629286 | 0 |
Gets the overlay_alignment of this GIFOutput. Alignment for overlay image in case the image doesn't fit the video perfectly. The first item in the array is X. The second is Y. | def overlay_alignment(self):
return self._overlay_alignment | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overlay_alignment(self, overlay_alignment):\n allowed_values = [\"left\", \"center\", \"right\", \"top\", \"middle\", \"bottom\"]\n if not set(overlay_alignment).issubset(set(allowed_values)):\n raise ValueError(\n \"Invalid values for `overlay_alignment` [{0}], must be ... | [
"0.6082157",
"0.5811847",
"0.57966024",
"0.5563203",
"0.5563203",
"0.5563203",
"0.5542505",
"0.54789925",
"0.5473381",
"0.5473381",
"0.5473381",
"0.54557025",
"0.5414728",
"0.5391308",
"0.53716415",
"0.53711426",
"0.53711426",
"0.5358381",
"0.5308002",
"0.5301803",
"0.5293957... | 0.78458405 | 0 |
Sets the overlay_alignment of this GIFOutput. Alignment for overlay image in case the image doesn't fit the video perfectly. The first item in the array is X. The second is Y. | def overlay_alignment(self, overlay_alignment):
allowed_values = ["left", "center", "right", "top", "middle", "bottom"]
if not set(overlay_alignment).issubset(set(allowed_values)):
raise ValueError(
"Invalid values for `overlay_alignment` [{0}], must be a subset of [{1}]"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overlay_alignment(self):\n return self._overlay_alignment",
"def overlay(self, overlay):\n\n self._overlay = overlay",
"def gonio_axis_align():\n \n # Invert camera image, so dark pin on light image becomes a peak\n cam_7.proc1.scale.put(-1)\n cam_8.proc1.scale.put(-1)\n \n ... | [
"0.6678817",
"0.5036174",
"0.49780422",
"0.49720982",
"0.49529678",
"0.4905251",
"0.48996106",
"0.48916376",
"0.48693442",
"0.4828346",
"0.48276195",
"0.4773495",
"0.46798646",
"0.46748582",
"0.46645558",
"0.46387076",
"0.4636476",
"0.46264026",
"0.46152508",
"0.45992303",
"0... | 0.7055731 | 0 |
Gets the overlay_scale of this GIFOutput. | def overlay_scale(self):
return self._overlay_scale | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_scale(self):\n\n if not hasattr(self, \"scale\"):\n raise NotImplementedError(\"\"\"All end-use subclasses of Color should define\n a get_scale method.\"\"\")\n\n return self.scale",
"def scale(self):\n return self._scale",
"def scaling(self):\n return self... | [
"0.6790271",
"0.6653809",
"0.66482663",
"0.66482663",
"0.65947706",
"0.6566475",
"0.6556108",
"0.6550792",
"0.6483977",
"0.646856",
"0.64394736",
"0.64268297",
"0.6364694",
"0.6363281",
"0.635813",
"0.63503003",
"0.6337674",
"0.63340884",
"0.62737983",
"0.62683964",
"0.626098... | 0.8657468 | 0 |
Sets the overlay_scale of this GIFOutput. | def overlay_scale(self, overlay_scale):
allowed_values = ["fit", "fill", "none"]
if overlay_scale not in allowed_values:
raise ValueError(
"Invalid value for `overlay_scale` ({0}), must be one of {1}"
.format(overlay_scale, allowed_values)
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overlay_scale(self):\n return self._overlay_scale",
"def scale(self, scale):\n\n self._scale = scale",
"def scale(self, scale):\n\n self._scale = scale",
"def overlay(self, overlay):\n\n self._overlay = overlay",
"def with_scale_op(self, scale):\n\t\tself.variables['scale'] ... | [
"0.63258976",
"0.6225319",
"0.6225319",
"0.60859454",
"0.6069903",
"0.599363",
"0.5942604",
"0.59057343",
"0.5672578",
"0.55856156",
"0.55695605",
"0.5541849",
"0.54761684",
"0.54468507",
"0.5435712",
"0.543293",
"0.54186404",
"0.53943425",
"0.5391189",
"0.5248213",
"0.518084... | 0.7558165 | 0 |
Takes a text file of filenames and makes a list of filenames | def files_to_list(filename):
with open(filename, encoding='utf-8') as f:
files = f.readlines()
files = [f.rstrip() for f in files]
return files | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files_to_list(filename):\n curdir = Path(filename).parent\n outs = []\n with open(filename, encoding=\"utf-8\") as fin:\n for line in fin:\n if line.strip():\n fname = Path(line.strip().split(\"\\t\")[0])\n if fname.exists():\n outs.ap... | [
"0.7637841",
"0.7474673",
"0.7343156",
"0.7303888",
"0.7272115",
"0.7217177",
"0.72108996",
"0.720633",
"0.7137104",
"0.70621216",
"0.7039949",
"0.7039732",
"0.70373243",
"0.69536304",
"0.69348955",
"0.6909082",
"0.68814677",
"0.6870362",
"0.6851389",
"0.68349504",
"0.6805668... | 0.7483208 | 1 |
Loads wavdata into torch array | def load_wav_to_torch(full_path):
sampling_rate, data = read(full_path)
return torch.from_numpy(data).float(), sampling_rate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_wav_to_torch(self, full_path):\n data, sampling_rate = load(full_path, sr=self.sampling_rate)\n data = 0.95 * normalize(data)\n\n if self.augment:\n amplitude = np.random.uniform(low=0.3, high=1.0)\n data = data * amplitude\n\n return torch.from_numpy(data... | [
"0.71620315",
"0.66123015",
"0.63704735",
"0.6138623",
"0.61151135",
"0.6111932",
"0.6079597",
"0.6057111",
"0.6023101",
"0.6000103",
"0.5971272",
"0.594401",
"0.59429103",
"0.5886555",
"0.58604324",
"0.5857195",
"0.58190787",
"0.58040625",
"0.5787966",
"0.57829833",
"0.57731... | 0.7503719 | 0 |
Drops indexes from all of the tables that will be populated | def drop_indexes(cursor):
try:
cursor.execute("DROP INDEX Review_Business_id_index ON review")
cursor.execute("DROP INDEX Review_date_index ON review")
cursor.execute("DROP INDEX Review_stars_index ON review")
cursor.execute("DROP INDEX Review_user_id_index ON review")
cursor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_non_unique_indexes(self):\n for idx in self.droppable_indexes:\n log.info(\"Dropping index '{}' on intermediate table\".format(idx.name))\n self.ddl_guard()\n self.execute_sql(sql.drop_index(idx.name, self.new_table_name))",
"def setup():\n with get_session() a... | [
"0.75803274",
"0.7347539",
"0.72600216",
"0.72363985",
"0.7221425",
"0.7056768",
"0.70466244",
"0.68622136",
"0.68118054",
"0.6661401",
"0.6569707",
"0.656742",
"0.6566741",
"0.6531738",
"0.6496841",
"0.64940965",
"0.6480109",
"0.6465053",
"0.64434534",
"0.6427655",
"0.639116... | 0.74130267 | 1 |
This function persists a list of YelpReview objects. Original implementations persisted each one individually, which performed slowly. This one accepts a collection and takes advantage of parameterized queries to persist in batches | def persist_list_o_review_objects(list_o_yros, cursor):
review_data = []
review_set_count = 0
review_votes_data = []
review_votes_set_count = 0
for yro in list_o_yros:
review_data += [yro.review_id, yro.business_id, yro.user_id, yro.stars, yro.review_text, yro.review_date]
review_se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_all(self, obj_list):\n\n for obj in obj_list:\n self.save(obj)",
"def save_many(self, values, expires_in=None):\n raise NotImplementedError()",
"def save_all(self):\r\n for index in range(self.count()):\r\n self.save(index)",
"def save_all(objs: List[ModelB... | [
"0.6075593",
"0.584283",
"0.5832359",
"0.58084935",
"0.5804483",
"0.57376075",
"0.5726918",
"0.5712181",
"0.56696975",
"0.55989873",
"0.55971265",
"0.557263",
"0.54924774",
"0.5456378",
"0.5439148",
"0.5396648",
"0.5394186",
"0.53573656",
"0.53533447",
"0.53365165",
"0.528779... | 0.69471145 | 0 |
Saves a single YelpReview object to database. This is the original implementation but it turns out that this was poorly performing, so I scrapped it in favor of persist_list_o_business_objects | def persist_review_object(yro, cursor):
try:
# Review
sql = " INSERT INTO Review " \
" (review_id, business_id, user_id, stars, review_text, review_date) " \
" VALUES " \
" (%s, %s, %s, %s, %s, %s) "
cursor.execute(sql, [yro.review_id, yro.business_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def persist_list_o_review_objects(list_o_yros, cursor):\n\n review_data = []\n review_set_count = 0\n review_votes_data = []\n review_votes_set_count = 0\n for yro in list_o_yros:\n review_data += [yro.review_id, yro.business_id, yro.user_id, yro.stars, yro.review_text, yro.review_date]\n ... | [
"0.62934196",
"0.57796127",
"0.5716861",
"0.553972",
"0.54539156",
"0.5425099",
"0.5403932",
"0.5344349",
"0.52043295",
"0.52019465",
"0.5195939",
"0.51627856",
"0.5155536",
"0.5154143",
"0.5138815",
"0.5138815",
"0.5138815",
"0.5138815",
"0.5138815",
"0.5138815",
"0.5138815"... | 0.674485 | 0 |
Draw a twodimensional heatmap fused with the original image. | def draw_2d_heatmaps(self, heatmap_2d):
np_heatmap = ToPILImage()(heatmap_2d).convert('RGB')
cv_img = cv.cvtColor(np.asarray(np_heatmap), cv.COLOR_RGB2BGR)
map_2d = cv.applyColorMap(cv_img, cv.COLORMAP_JET)
return map_2d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_heat_map(image, heat_map):\n return image",
"def heat_map(path):\r\n x, y= np.loadtxt(fname=path, delimiter='\\t',dtype=int,\r\n usecols = (1,2), skiprows=100, unpack = True)\r\n\r\n fig, (ax,ax2) = plt.subplots(nrows=2, sharex=True, figsize=(20,10))\r\n\r\n extent = [x[0... | [
"0.74944293",
"0.6625564",
"0.6494976",
"0.6417634",
"0.6353444",
"0.60608757",
"0.6025617",
"0.59894353",
"0.59773195",
"0.59464633",
"0.5894591",
"0.58209354",
"0.581542",
"0.58102053",
"0.580214",
"0.580186",
"0.5799282",
"0.57984924",
"0.5793625",
"0.57743084",
"0.5765347... | 0.7041537 | 1 |
Paste onedimensional heatmaps onto the background in turn. | def add_1d_heatmaps(self,
maps: dict,
background: np.ndarray,
map2d_size: Union[tuple, list],
K: int,
interval: int = 10):
y_startpoint, x_startpoint = [int(1.1*map2d_size[1]),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cmd_heatmap(args):\n cnarrs = []\n for fname in args.filenames:\n cnarr = read_cna(fname)\n if args.adjust_xy:\n is_sample_female = verify_sample_sex(\n cnarr, args.sample_sex, args.male_reference, args.diploid_parx_genome\n )\n cnarr = cnarr... | [
"0.6045487",
"0.59562194",
"0.58167315",
"0.57513165",
"0.56921065",
"0.5689646",
"0.5628119",
"0.5594635",
"0.5566843",
"0.5559819",
"0.5533765",
"0.55296916",
"0.5498906",
"0.5494224",
"0.5464383",
"0.5461347",
"0.54449046",
"0.5444866",
"0.54397726",
"0.54291356",
"0.54224... | 0.68941486 | 0 |
Wrapper of the command line tool sed to change variable values. Please note that some characters like / must be escaped to work. | def changeConfVar(varName, varValue, file="config/scipion.conf", escapeSlash=False):
if escapeSlash:
varValue = varValue.replace('/', '\/')
command = ['bash', '-c', 'sed -i -e '
'"s/%s = .*/%s = %s/" '
'%s' % (varName, varName, varValue, file)]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sed_like_thing(pattern, repl, path):\n\n with codecs.open(path, 'rb', 'utf8') as inf:\n data = inf.read()\n\n data = re.sub(pattern, repl, data)\n\n with codecs.open(path, 'wb+', 'utf8') as outf:\n outf.write(data)",
"def bs_set(self, cmd, arg):\n\t\tif arg:\n\t\t\tfor x in self.split(... | [
"0.56367666",
"0.56140023",
"0.56025064",
"0.55010325",
"0.5443878",
"0.5441514",
"0.5424399",
"0.52970827",
"0.5294301",
"0.52636224",
"0.52600396",
"0.5246227",
"0.52333087",
"0.52145934",
"0.52100545",
"0.51816446",
"0.5165895",
"0.5081385",
"0.50499505",
"0.5047105",
"0.5... | 0.6695324 | 0 |
Takes masked softmax over given dimension of logits. | def masked_softmax(logits, mask, dim):
exp_mask = (1 - tf.cast(mask, 'float')) * (-1e30) # -large where there's padding, 0 elsewhere
masked_logits = tf.add(logits, exp_mask) # where there's padding, set logits to -large
prob_dist = tf.nn.softmax(masked_logits, dim)
return masked_logits, prob_dist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def masked_softmax(logits, mask, dim=-1, log_softmax=False):\n mask = mask.type(torch.float32)\n masked_logits = mask * logits + (1 - mask) * -1e30\n softmax_fn = F.log_softmax if log_softmax else F.softmax\n probs = softmax_fn(masked_logits, dim)\n\n return probs",
"def masked_softmax(tensor, mas... | [
"0.80401665",
"0.7654991",
"0.761089",
"0.75716364",
"0.7517807",
"0.74387515",
"0.7438501",
"0.7347286",
"0.7323559",
"0.73165834",
"0.7309688",
"0.73022497",
"0.7278672",
"0.72193605",
"0.7214303",
"0.71653897",
"0.7160705",
"0.7139164",
"0.70996326",
"0.70656717",
"0.70488... | 0.8118963 | 1 |
create a kdtree on data X. | def create(self, X, dimensions=None):
n_samples, n_features = X.shape
self.X = X
if not dimensions:
dimensions = n_features
self.root = KdNode(depth=0,
splitting_feature=0,
splitting_value=np.median(X[:, 0]),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_kdtree(self):\n if self.method==2:\n coordinates = self.unassigned_data[0:3,:]\n else:\n coordinates = self.unassigned_data[0:2,:]\n tree = cKDTree(coordinates.T)\n\n return tree",
"def build_kdtree(points, depth=0):\n n = len(points) - 1\n\n if n <= 0:\n retur... | [
"0.76762074",
"0.66742635",
"0.66742635",
"0.665417",
"0.65665555",
"0.6538967",
"0.64309573",
"0.63635075",
"0.6318616",
"0.6176345",
"0.6175313",
"0.60938823",
"0.6080377",
"0.60334706",
"0.59839034",
"0.5976341",
"0.59736675",
"0.59532875",
"0.5938413",
"0.58962005",
"0.58... | 0.694763 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.