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 |
|---|---|---|---|---|---|---|
Returns timings for parts, where the video should be kept | def getSectionsOfNewVideo (silences, duration):
return [0.0] + silences + [duration] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def video_time():\r\n # The full time has the form \"0:32 / 3:14\"\r\n full_time = world.css_text('div.vidtime')\r\n\r\n # Split the time at the \" / \", to get [\"0:32\", \"3:14\"]\r\n elapsed_str, duration_str = full_time.split(' / ')\r\n\r\n # Convert each string to seconds\r\n return (parse_t... | [
"0.6023563",
"0.59063125",
"0.56466246",
"0.5624058",
"0.56141603",
"0.560595",
"0.5565088",
"0.5434631",
"0.5414467",
"0.538054",
"0.538054",
"0.538054",
"0.5377151",
"0.5325003",
"0.5311827",
"0.5305418",
"0.5302824",
"0.5241184",
"0.5222898",
"0.5206784",
"0.5206103",
"0... | 0.5964529 | 1 |
Remove implicit resolvers for a particular tag Takes care not to modify resolvers in super classes. We want to load datetimes as strings, not dates, because we go on to serialise as json which doesn't have the advanced types of yaml, and leads to incompatibilities down the track. | def remove_implicit_resolver(cls, tag_to_remove):
if 'yaml_implicit_resolvers' not in cls.__dict__:
cls.yaml_implicit_resolvers = cls.yaml_implicit_resolvers.copy()
for first_letter, mappings in cls.yaml_implicit_resolvers.items():
cls.yaml_implicit_resolvers[first_letter] = [
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_implicit_resolver(cls, tag_to_remove):\n if 'yaml_implicit_resolvers' not in cls.__dict__:\n cls.yaml_implicit_resolvers = cls.yaml_implicit_resolvers.copy()\n\n for first_letter, mappings in cls.yaml_implicit_resolvers.items():\n cls.yaml_implicit_resolvers[first_let... | [
"0.72351325",
"0.4945799",
"0.48895606",
"0.4787134",
"0.47753465",
"0.4747511",
"0.47394142",
"0.47089127",
"0.46628618",
"0.46158558",
"0.46017975",
"0.45002973",
"0.44972196",
"0.4452387",
"0.44437444",
"0.44306776",
"0.43933737",
"0.43895388",
"0.43718284",
"0.43617448",
... | 0.72606164 | 0 |
Try to get consent status for a single email address | def test_get_one(self, requests_mock, accepts_marketing):
matcher = requests_mock.post(
f'{settings.CONSENT_SERVICE_BASE_URL}'
f'{consent.CONSENT_SERVICE_PERSON_PATH_LOOKUP}',
json={
'results': [
{
'email': 'foo@bar.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Get_applicant_status(self, email):\n status = None\n if email in self.Attendees:\n status = ApplicantStatus.Accepted\n elif email in self.Waitlist:\n status = ApplicantStatus.Waitlisted\n else:\n raise MissingAddressException(email)\n return s... | [
"0.66149795",
"0.58070236",
"0.57529634",
"0.57529634",
"0.5640133",
"0.5606867",
"0.55703324",
"0.5566895",
"0.55520564",
"0.5475473",
"0.54483193",
"0.54387474",
"0.541679",
"0.53587914",
"0.5347143",
"0.53188384",
"0.5258927",
"0.525825",
"0.52227",
"0.5204715",
"0.5188246... | 0.60032743 | 1 |
Try to get consent status for a list of email addresses | def test_get_many(self, requests_mock, accepts_marketing, emails):
matcher = requests_mock.post(
f'{settings.CONSENT_SERVICE_BASE_URL}'
f'{consent.CONSENT_SERVICE_PERSON_PATH_LOOKUP}',
json={
'results': [
{
'email': ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Get_applicant_status(self, email):\n status = None\n if email in self.Attendees:\n status = ApplicantStatus.Accepted\n elif email in self.Waitlist:\n status = ApplicantStatus.Waitlisted\n else:\n raise MissingAddressException(email)\n return s... | [
"0.61944306",
"0.6052294",
"0.57121867",
"0.5533557",
"0.54612494",
"0.54612494",
"0.5418097",
"0.52885437",
"0.5284941",
"0.5283386",
"0.5248901",
"0.5231524",
"0.522646",
"0.5220439",
"0.5209896",
"0.520168",
"0.51967436",
"0.5160234",
"0.5155434",
"0.5138707",
"0.51335585"... | 0.6141746 | 1 |
Try to update consent status | def test_update(self, requests_mock, accepts_marketing):
matcher = requests_mock.post(
f'{settings.CONSENT_SERVICE_BASE_URL}'
f'{consent.CONSENT_SERVICE_PERSON_PATH}',
json={
'consents': [
CONSENT_SERVICE_EMAIL_CONSENT_TYPE,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_confirm_add_flow_request_wrong_consent_status(self):\n self.client.login(username='duck', password='duck')\n res = self.client.get(\n '/v1/flow_requests/consents_confirmed/?success=true&consent_confirm_id={}'.format(WRONG_CONFIRM_ID))\n self.assertEqual(res.status_code, 302... | [
"0.6403219",
"0.6326517",
"0.6045587",
"0.5909922",
"0.5812921",
"0.57628024",
"0.5692828",
"0.5603599",
"0.55674136",
"0.5560386",
"0.549486",
"0.5482111",
"0.5482111",
"0.5476812",
"0.544154",
"0.54324704",
"0.5428267",
"0.5428241",
"0.54031616",
"0.5402912",
"0.540165",
... | 0.64573574 | 0 |
This function retrieves all ACISAs | def RetrieveACISA():
db = DBConnector()
cur = db.cursor()
SQLcmd = "SELECT * FROM snaps.SNAPsLocation"
cur.execute(SQLcmd)
returnList = []
count = 0
for item in cur.fetchall():
count += 1
tmplist = [item[1], item[2], count, str(item[0])]
returnList.append(tmplist)
return returnList | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_acls():\n return config.get_cfg_storage(ID_ACL)",
"def getAcdcs(url, requests):\n acdcs = []\n for request in requests:\n name=request['id']\n #if a wrong or weird name\n if len(request['key'])<3:\n print request\n continue\n if 'ACDC' not in nam... | [
"0.6468968",
"0.62329483",
"0.6149895",
"0.6125198",
"0.6006901",
"0.59983075",
"0.59268194",
"0.58295614",
"0.58222836",
"0.58132493",
"0.5776532",
"0.57738966",
"0.5739669",
"0.57129836",
"0.57093567",
"0.5707091",
"0.5696865",
"0.5693562",
"0.5683094",
"0.5662152",
"0.5629... | 0.63769305 | 1 |
Method to calculate a stat over all time steps | def time_stat(self, stat="mean"):
# create cdo command and run it
cdo_command = f"cdo -tim{stat}"
run_this(cdo_command, self, output="ensemble") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_stat_values(self):",
"def compute_stats(self):\n if self.stats is not None:\n return\n self.stats = np.zeros(STEPS_MAX + 1)\n for m in self.missions:\n m.compute_stats()\n self.stats += 100 * m.stats\n self.stats /= len(self.missions)",
"def... | [
"0.7152318",
"0.6610999",
"0.64921373",
"0.6394629",
"0.63097644",
"0.62772894",
"0.6209305",
"0.6110621",
"0.6110621",
"0.6110621",
"0.61086136",
"0.6045909",
"0.596642",
"0.5933937",
"0.5890365",
"0.58721894",
"0.58537525",
"0.5809977",
"0.58057666",
"0.57885444",
"0.573436... | 0.68386406 | 1 |
Calculate the aggregated mean and stds. | def _get_aggregated_mean_std(self, means, stds, n):
mean = means.view(n, -1).sum(0) / n
std = (
stds.view(n, -1).sum(0) / n
+ ((means.view(n, -1) - mean) ** 2).view(n, -1).sum(0) / n
)
return mean.detach(), std.detach() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregate_stats(self):\n if self.split_bn.track_running_stats:\n (\n self.bn.running_mean.data,\n self.bn.running_var.data,\n ) = self._get_aggregated_mean_std(\n self.split_bn.running_mean,\n self.split_bn.running_var,\n ... | [
"0.75994617",
"0.7462015",
"0.73687404",
"0.72231203",
"0.7077105",
"0.6966083",
"0.69622374",
"0.69211644",
"0.691378",
"0.6900489",
"0.6860511",
"0.6856823",
"0.6847475",
"0.6832801",
"0.68259156",
"0.6784394",
"0.67798734",
"0.6750028",
"0.67471087",
"0.6724783",
"0.668773... | 0.75622755 | 1 |
Synchronize running_mean, and running_var. Call this before eval. | def aggregate_stats(self):
if self.split_bn.track_running_stats:
(
self.bn.running_mean.data,
self.bn.running_var.data,
) = self._get_aggregated_mean_std(
self.split_bn.running_mean,
self.split_bn.running_var,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _synchronize_vars_using_mean(new_var: NestedMap,\n old_var: NestedMap) -> NestedMap:\n delta = new_var - old_var\n delta_mean = jax.lax.pmean(delta, axis_name=data_parallel_axis_name)\n updated_var = old_var + delta_mean\n return updated_var",
"def _for... | [
"0.61866266",
"0.59162766",
"0.5869464",
"0.5706126",
"0.5659805",
"0.55348825",
"0.54772735",
"0.54338247",
"0.5433502",
"0.5417435",
"0.5414351",
"0.53781146",
"0.5374504",
"0.53155285",
"0.53055024",
"0.5271861",
"0.5214751",
"0.52096206",
"0.520088",
"0.5198845",
"0.51728... | 0.5927717 | 1 |
Return duration in years | def duration(self):
if self.is_valid:
return relativedelta(self.expiry, datetime.date.today()).years
else:
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def days_to_years(datum):\n return datum/DAYS_PER_YEAR",
"def year(self):\n return self._years",
"def unit_yr(self):\n return ((self.time_base * 60.0) * 24.0) * 365.0",
"def periods_in_a_year(self) -> float:\n return self.length / self.yearfrac",
"def _unit_yr(self):\n return ((se... | [
"0.72326726",
"0.7115902",
"0.70439005",
"0.70209014",
"0.6918941",
"0.68189144",
"0.6782731",
"0.67128307",
"0.66573805",
"0.6547447",
"0.6528867",
"0.6528867",
"0.6477337",
"0.64250714",
"0.6410062",
"0.64020795",
"0.63959104",
"0.6354012",
"0.6353335",
"0.6349158",
"0.6343... | 0.7217856 | 1 |
Transition from iceboot to domapp by uploading 'domappFile', uncompressing it and executing from iceboot. Load domapp FPGA first. | def uploadDomapp2(self, domappFile):
if not os.path.exists(domappFile): raise DomappFileNotFoundException(domappFile)
size = os.stat(domappFile)[ST_SIZE]
if size <= 0: return (False, "size error: %s %d bytes" % (domappFile, size))
# Load domapp FPGA
ok, txt = self.se("s\" domapp.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(app, verbose, replay, exp_config=None):\n if replay:\n exp_config = exp_config or {}\n exp_config[\"replay\"] = True\n log(header, chevrons=False)\n loader = LoaderDeployment(app, Output(), verbose, exp_config)\n loader.run()",
"def software_load(self, filename: str) -> None:\n... | [
"0.55233026",
"0.5206039",
"0.51236546",
"0.50307345",
"0.4985857",
"0.49178445",
"0.48859143",
"0.48607603",
"0.48495775",
"0.48479488",
"0.4829573",
"0.4828603",
"0.48110473",
"0.47907218",
"0.47523627",
"0.4730287",
"0.46991777",
"0.46957707",
"0.46943602",
"0.4688376",
"0... | 0.7968039 | 0 |
Function decorator for unittest test cases to specify test case timeout. | def timeout(time_limit):
class TimeoutException(Exception):
""" Subclass Exception to catch timer expiration during search """
pass
def handler(*args, **kwargs):
""" Generic handler to raise an exception when a timer expires """
raise TimeoutException("Test aborted due to timeo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_timeout(timeout):\n def decor(f):\n @functools.wraps(f)\n def inner(self, *args, **kwargs):\n self.useFixture(fixtures.Timeout(timeout, gentle=True))\n return f(self, *args, **kwargs)\n return inner\n return decor",
"def pytest_timeout_set_timer(item, sett... | [
"0.79690397",
"0.75481164",
"0.7531505",
"0.74053466",
"0.7395922",
"0.7079493",
"0.70790184",
"0.69973075",
"0.69770676",
"0.69770676",
"0.69739807",
"0.6917172",
"0.67718583",
"0.6764333",
"0.67116076",
"0.6696234",
"0.668591",
"0.6672928",
"0.6670006",
"0.6657833",
"0.6647... | 0.7551795 | 1 |
Return counts of (total, unique) nodes visited | def counts(self):
return sum(self.counter.values()), len(self.visited) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_nodes(self):\n\t\treturn self.__count_nodes(self)",
"def count_unvisited(data):\n count = sum(n.count(\"n\") for n in data)\n return count",
"def count(self):\n\t\treturn len(list(self.nodes))",
"def node_count(self) -> int:\n return int(self.graph_tuple_stats.node_count or 0)",
"def get... | [
"0.7426861",
"0.736728",
"0.7362337",
"0.71854764",
"0.7132183",
"0.7039101",
"0.70088387",
"0.6983478",
"0.67954326",
"0.678729",
"0.6775083",
"0.6736858",
"0.6726595",
"0.67247325",
"0.6679473",
"0.66466904",
"0.66429496",
"0.6642772",
"0.6615163",
"0.66069305",
"0.6603299"... | 0.78785557 | 1 |
Get data from an Amarok database. We fetch rating and score as well as Amarok's unique id for the track to have more reliable syncing after the initial import. | def get_amarok_data(item, db):
if hasattr(item, 'amarok_uid') and item.amarok_uid:
condition = "REPLACE(uniqueid, 'amarok-sqltrackuid://', '') = '%s'" % MySQLdb.escape_string(item.amarok_uid)
else:
condition = "REPLACE(CONCAT_WS('/',lastmountpoint, rpath), '/./', '/') = '%s'" % MySQLdb.escape_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_from_db(self):\n pass",
"def fetch_from_db(self):\n self._potential_deals = DBApi.get_instance().potential_records\n self._filters = DBApi.get_instance().filters\n # Add markdown for url\n for data in self._potential_deals:\n data[\"url\"] = f\"[Link]({d... | [
"0.5660886",
"0.54901147",
"0.53773314",
"0.53103805",
"0.5294919",
"0.5287652",
"0.5280436",
"0.5218586",
"0.5123491",
"0.51149195",
"0.50887793",
"0.50697964",
"0.50557685",
"0.50500786",
"0.5047312",
"0.5042681",
"0.50382304",
"0.5036712",
"0.50281346",
"0.5021935",
"0.501... | 0.719275 | 0 |
This is the method to call and analyze text with the supplied features | def analyze(self, features, text=None, url=None, html=None,
clean=True, xpath=None, fallback_to_raw=True,
return_analyzed_text=False, language=None):
body = {
'clean': clean,
'fallback_to_raw': fallback_to_raw,
'return_analyzed_text': return_an... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__extract_features(self):\n text_sample = \"I really really love this movie\"\n feature_sample = ['really','love','good']\n feature_score_type = \"presence\"\n model_sample = Model(feature_sample,feature_score_type)\n result_features = model_sample.extract_features(text_s... | [
"0.65689343",
"0.6477436",
"0.64146715",
"0.6368037",
"0.6330938",
"0.6260085",
"0.6223099",
"0.6171409",
"0.616159",
"0.61302584",
"0.61197525",
"0.6115434",
"0.6103395",
"0.6098626",
"0.60901034",
"0.60735404",
"0.60727555",
"0.6036561",
"0.6018226",
"0.6005281",
"0.6003854... | 0.72335 | 0 |
Remove ``>`` from beginning of a line. | def clean(self, line):
m = self.RE.match(line)
if line.strip() == ">":
return ""
elif m:
return m.group(2)
else:
return line | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(self, line):\r\n m = self.RE.match(line)\r\n if line.strip() == \">\":\r\n return \"\"\r\n elif m:\r\n return m.group(2)\r\n else:\r\n return line",
"def dealFirstLine(line):\n\n print \"%s\" % (line.strip('\\n'))",
"def _remove_beginnin... | [
"0.7322892",
"0.65217817",
"0.6428228",
"0.64100033",
"0.6187956",
"0.61572856",
"0.6113667",
"0.6068053",
"0.6057279",
"0.6052678",
"0.5984401",
"0.59601843",
"0.5782217",
"0.5741116",
"0.5701244",
"0.5687602",
"0.56819564",
"0.5668284",
"0.5666465",
"0.5642651",
"0.5623701"... | 0.7390938 | 0 |
Convert ttyrec files to videos | def main(ctx, ttyrec, encoding, ibm, outfile, size, fps, font_size, font_file,
bold_font_file, info, info_all):
if ibm:
encoding = 'cp437'
fp, def_outfile = open_or_get(ttyrec)
try:
with fp:
updates = list(read_ttyrec(fp, encoding=encoding, errors='replace'))
except ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seqIo_toVid(fName, ext='avi'):\n\n assert fName[-3:]=='seq', 'Not a seq file'\n sr = seqIo_reader(fName)\n N = sr.header['numFrames']\n h = sr.header['height']\n w = sr.header['width']\n fps = sr.header['fps']\n\n out = fName[:-3]+ext\n sw = skvideo.io.FFmpegWriter(out)\n # sw = cv2... | [
"0.67228967",
"0.6123915",
"0.6026224",
"0.6026062",
"0.6018919",
"0.60161096",
"0.5921599",
"0.58913285",
"0.58782333",
"0.58761436",
"0.5870621",
"0.5852439",
"0.58420694",
"0.5806366",
"0.5802016",
"0.57724094",
"0.57724094",
"0.574259",
"0.5720971",
"0.5720353",
"0.570617... | 0.70133644 | 0 |
Set the "entity_class_registry" field | def set_entity_class_registry(self, entity_class_registry):
self.entity_class_registry = entity_class_registry | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_class(self, entity_class):\n key = entity_class.__collection_name__\n\n if key not in self._registered_types:\n self._registered_types[key] = entity_class",
"def _extract_entity_class_registry(self):\n for description in self.sa_query.column_descriptions:\n ... | [
"0.6296474",
"0.6145517",
"0.5784777",
"0.57402545",
"0.5640025",
"0.5552346",
"0.54653853",
"0.52816427",
"0.5269132",
"0.5262372",
"0.5256132",
"0.52219176",
"0.5213515",
"0.5207139",
"0.5203314",
"0.52020997",
"0.52020997",
"0.51808226",
"0.5144154",
"0.51290417",
"0.51211... | 0.8463285 | 0 |
Extract an entity class registry from one of the models of the inner SQLAlchemy query. This result of this function is used by several SQLAlchemy components during the extraction of the SQL query from a SQLAlchemy query. | def _extract_entity_class_registry(self):
for description in self.sa_query.column_descriptions:
if "entity" in description:
declarative_meta = description["entity"]
_class_registry = getattr(
declarative_meta, "_decl_class_registry", None)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_real_object(self):\n query_string = dedent(f\"\"\"\\\n import app.config.models_importer as models_importer\n\n class_ = models_importer.all_models['{self.ref_class}']\n \n class_.query.get({self.ref_id})\"\"\")\n\n return exec(query_string)",
"def _n... | [
"0.5555714",
"0.5259711",
"0.5109347",
"0.50943285",
"0.50772786",
"0.49984002",
"0.4953237",
"0.49206263",
"0.47721955",
"0.47709483",
"0.47572222",
"0.47535753",
"0.47392863",
"0.47341767",
"0.47276932",
"0.46964145",
"0.46887028",
"0.46723166",
"0.4664276",
"0.4661921",
"0... | 0.75623906 | 0 |
Call f on each item in seq, calling inter() in between. | def interleave(inter, f, seq):
seq = iter(seq)
try:
f(next(seq))
except StopIteration:
pass
else:
for x in seq:
inter()
f(x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sequence(f, lst: list) -> list:\n ret = []\n for ele in lst:\n ret.append(f(ele))\n return ret",
"def intersperse(value, seq):\n seq = iter(seq)\n\n try:\n yield next(seq)\n except StopIteration:\n return\n\n for item in seq:\n yield value\n yield item"... | [
"0.61680573",
"0.6034688",
"0.6013112",
"0.5890083",
"0.5763176",
"0.5744706",
"0.5691687",
"0.5686545",
"0.56322396",
"0.5617056",
"0.5564194",
"0.55386853",
"0.55105126",
"0.5491585",
"0.5479231",
"0.5478667",
"0.5475974",
"0.54754245",
"0.5453396",
"0.5437749",
"0.5408432"... | 0.77389354 | 0 |
Gets the device function name by translating a typed Python version to a templated cpp version. Python functions looks like getVariableFloatArray6 and translate to getVariable This function will detect and test against a set of known types and also extract the Array length This function returns None if the string is in... | def _deviceVariableFunctionName(self, tree, permitted_prefixes, allow_lengths = True):
cpp_func_name = ""
py_func = tree.attr
# extract function name start
for prefix in permitted_prefixes:
if py_func.startswith(prefix):
cpp_func_name = prefix
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def function_name_to_string(func):\n if func == statistical_parity_difference:\n return \"Statistical Parity Difference\"\n if func == theil_index:\n return \"Theil Index\"\n if func == equal_opportunity_difference:\n return \"Equal Opportunity Difference\"\n if func == disparate_i... | [
"0.5464446",
"0.5418039",
"0.53736573",
"0.5311592",
"0.53082407",
"0.52509713",
"0.52308387",
"0.52233297",
"0.5139834",
"0.5137596",
"0.5136655",
"0.51061374",
"0.50472605",
"0.50168824",
"0.5014381",
"0.49955937",
"0.4979121",
"0.49771407",
"0.49526176",
"0.4947558",
"0.49... | 0.69010454 | 0 |
Function will handle a getMacroEnvironment function (assuming it is correctly formatted (by checking with _deviceVariableFunctionName first)) | def dispatchMacroEnvFunction(self, tree, tree_parent):
cpp_func_name = "getMacroProperty"
py_func = tree.attr
# extract type from function name
py_type = py_func[len(cpp_func_name):]
if py_type not in self._fgpu_types:
self.RaiseError(tree, f"'{py_type}' is not a vali... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_environment_string(self):\n pass",
"def __MakeEnvironment(self):\n environment= os.environ.copy()\n\n for key, value in self.__context.items():\n if type(value) is str:\n name = \"QMV_\" + key.replace(\".\", \"__\")\n environment[name]= value\n\n return environment... | [
"0.58264863",
"0.5568216",
"0.53334945",
"0.5327967",
"0.51543343",
"0.51488876",
"0.51430243",
"0.5069374",
"0.50373465",
"0.5026348",
"0.50191504",
"0.5002579",
"0.49759382",
"0.49720997",
"0.49513227",
"0.49360543",
"0.4913783",
"0.49026003",
"0.48999316",
"0.4882077",
"0.... | 0.61382043 | 0 |
Handles arguments for a FLAME GPU device function. Arguments must use type hinting to be translated to cpp. | def dispatchFGPUDeviceFunctionArgs(self, tree):
# reset the locals variable stack
self._locals = ["pyflamegpu"]
# input message
first = True
annotation = None
for arg in tree.args.args:
# ensure that there is a type annotation
if not arg.annotation... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _deviceVariableFunctionName(self, tree, permitted_prefixes, allow_lengths = True):\n cpp_func_name = \"\"\n py_func = tree.attr\n # extract function name start\n for prefix in permitted_prefixes:\n if py_func.startswith(prefix):\n cpp_func_name = prefix\n ... | [
"0.6057609",
"0.5804018",
"0.5786905",
"0.5687931",
"0.5632874",
"0.55926454",
"0.55586314",
"0.54775053",
"0.5402661",
"0.53772503",
"0.5370256",
"0.5299433",
"0.5298682",
"0.5296351",
"0.52958226",
"0.52583855",
"0.52490014",
"0.5243063",
"0.52260655",
"0.51923186",
"0.5190... | 0.77259445 | 0 |
Message iterator call maybe a simple one (e.g. message_in(x, y, z)) or a call to a member (e.g. message_in.wrap()) Using this function avoid using the global call one which may accept member function calls to things that are not iterators. | def dispatchMessageIteratorCall(self, tree):
# simple case not a member function just an iterator with arguments
if isinstance(tree.func, ast.Name):
self.write(f"FLAMEGPU->{tree.func.id}")
if isinstance(tree.func, ast.Attribute) :
if isinstance(tree.func.value, ast.Name):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(self, message: Message) -> None:\n self.fn(message)",
"def _call(self, x):\n return x.inner(x)",
"def test_dispatch_inbound(self):\n msg_helper = MessageHelper()\n worker_helper = WorkerHelper()\n broker = self.setup_broker(worker_helper)\n self.assertEqual(br... | [
"0.5965189",
"0.5781531",
"0.5567268",
"0.5560412",
"0.5555918",
"0.5474647",
"0.53749025",
"0.5369496",
"0.5356947",
"0.532416",
"0.53201944",
"0.52734697",
"0.5214312",
"0.51924616",
"0.51724297",
"0.51710767",
"0.51597893",
"0.51278067",
"0.5124339",
"0.5106569",
"0.509719... | 0.73008895 | 0 |
A very limited set of function calls to members are supported so these are fully evaluated here. t_parent is the Call ast object required if the argument need to be modified (i.e. in the case of macro environment properties) Function calls permitted are; pyflamegpu.function a supported function call. e.g. pyflamegpu.ge... | def dispatchMemberFunction(self, t, t_parent):
# it could be possible that the Call object has no value property e.g. a()()
if not hasattr(t, "value"):
self.RaiseError(t, f"Function call is in an unsupported format.")
# Nested member functions (e.g. x.y.z())
if isinstance(t.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _Call(self, t):\n # check calls but let attributes check in their own dispatcher\n funcs = self._device_functions + self.pythonbuiltins + [self._input_message_var] # message_input variable is a valid function name as certain message types have arguments on iterator\n if isinstance(t.func, ... | [
"0.6362595",
"0.58942914",
"0.57930183",
"0.5696235",
"0.56648827",
"0.5555311",
"0.5387862",
"0.52408487",
"0.5235522",
"0.52275836",
"0.51776576",
"0.5120119",
"0.51014704",
"0.509886",
"0.506699",
"0.50667155",
"0.5059268",
"0.50211924",
"0.49914703",
"0.4978251",
"0.49437... | 0.790886 | 0 |
Checks the decorators of the function definition much must be either 'pyflamegpu.agent_function', 'pyflamegpu.agent_function_condition' or 'pyflamegpu.device_function'. Each is then processed in a different way using a specific dispatcher. Function calls are actually checked and only permitted (or user defined) functio... | def _FunctionDef(self, t):
self.write("\n")
# check decorators
if len(t.decorator_list) != 1 or not isinstance(t.decorator_list[0], ast.Attribute):
self.RaiseError(t, "Function definitions require a single pyflamegpu decorator of either 'pyflamegpu.agent_function', 'pyflamegpu.agent_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_FunctionDef(self, node):\n self.functions[node.name] = self._generate_pytest_decorators(node.decorator_list)\n self.generic_visit(node)",
"def isValidFunction(self):\n for token in self.value:\n if token.type == 'defFunction' or token.type == 'callFunction':\n ... | [
"0.6134093",
"0.5936042",
"0.57259756",
"0.56994855",
"0.5666439",
"0.5570822",
"0.5568335",
"0.55557805",
"0.5536746",
"0.55267",
"0.5503715",
"0.55015457",
"0.54883873",
"0.5477766",
"0.5459286",
"0.54585314",
"0.5451225",
"0.543271",
"0.54145896",
"0.5368069",
"0.53297734"... | 0.7230727 | 0 |
Two type for for loop are supported. Either; 1) Message for loop in which case the format requires a iterator using the named pyflamegpu function argument of 'message_in' 2) A range based for loop with 1 to 3 arguments which is converted into a c style loop | def _For(self, t):
# if message loop then process differently
if isinstance(t.iter, ast.Name):
if t.iter.id == self._input_message_var:
self.dispatchMessageLoop(t)
else:
self.RaiseError(t, "Range based for loops only support message iteration using... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dispatchMessageLoop(self, tree):\n self.fill(\"for (const auto& \")\n self.dispatch(tree.target)\n self.write(\" : \")\n # if simple message iterator\n if isinstance(tree.iter, ast.Name):\n if not tree.iter.id == self._input_message_var:\n self.Raise... | [
"0.6300082",
"0.5951897",
"0.5818866",
"0.57553744",
"0.55254656",
"0.55113477",
"0.5369612",
"0.5264706",
"0.51863104",
"0.5155934",
"0.5096092",
"0.50791895",
"0.5068876",
"0.5014519",
"0.49778667",
"0.49353746",
"0.48620737",
"0.48602274",
"0.48535544",
"0.48398575",
"0.48... | 0.6590012 | 0 |
A very limited set of attributes are supported so these are fully evaluated here. Other places where attribute type expressions may occur will also evaluate them fully rather than recursively call this function. Attributes supported are only; pyflamegpu.attribute a supported attribute e.g. pyflamegpu.ALIVE. This will b... | def _Attribute(self,t):
# Only a limited set of globals supported
func_dict = None
# pyflamegpu singleton
if isinstance(t.value, ast.Name):
if t.value.id == "pyflamegpu":
if t.attr in self.fgpu_attrs:
# proceed
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testattributes(self):\n for attr in ('ST', 'DX', 'IQ', 'MA', 'Dam', 'Hit'):\n AttributeAbility([attr,])",
"def check_common_attrs(self, ast):\n declarator = ast.declarator\n attrs = declarator.attrs\n meta = declarator.metaattrs\n ntypemap = ast.typemap\n ... | [
"0.6042245",
"0.5977239",
"0.5950845",
"0.5936985",
"0.59264654",
"0.5886172",
"0.5826526",
"0.5790564",
"0.5755268",
"0.567972",
"0.56774443",
"0.5620047",
"0.553324",
"0.55215055",
"0.54968786",
"0.5450834",
"0.5426266",
"0.5415868",
"0.5412917",
"0.5388492",
"0.53772295",
... | 0.713576 | 0 |
Some basic checks are undertaken on calls to ensure that the function being called is either a builtin or defined device function. A special dispatcher is required | def _Call(self, t):
# check calls but let attributes check in their own dispatcher
funcs = self._device_functions + self.pythonbuiltins + [self._input_message_var] # message_input variable is a valid function name as certain message types have arguments on iterator
if isinstance(t.func, ast.Name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(fun_name):",
"def test_dispatchUnknown(self):\n disp = Dispatcher()\n name = \"missing\"\n args = (1, 2)\n res = disp.dispatch(name, *args)\n self.assertEqual(res, (name,) + args)",
"def validate_universal_calls(cls):\n assert True == cls.universal... | [
"0.5971725",
"0.5816666",
"0.56597704",
"0.565735",
"0.56368434",
"0.56075937",
"0.560516",
"0.5587939",
"0.55403495",
"0.54888415",
"0.542656",
"0.5398054",
"0.53934664",
"0.53790116",
"0.5372327",
"0.53566486",
"0.53564227",
"0.5351131",
"0.53422856",
"0.5330329",
"0.532966... | 0.5911068 | 1 |
A function to visualize pymatgen Structure objects in jupyter notebook using chemview package. | def quick_view(structure, bonds=True, conventional=False, transform=None, show_box=True, bond_tol=0.2, stick_radius=0.1):
s = structure.copy()
if conventional:
s = SpacegroupAnalyzer(s).get_conventional_standard_structure()
if transform:
s.make_supercell(transform)
atom_types = [i.symb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ipython_repr_no_nglview(self):\n molecule = Molecule().from_smiles(\"CCO\")\n molecule._ipython_display_()",
"def jupyter():",
"def test_visualize_openeye(self):\n import IPython\n\n mol = Molecule().from_smiles(\"CCO\")\n\n assert isinstance(mol.visualize(backend=\"... | [
"0.64746124",
"0.6093616",
"0.6001484",
"0.6001484",
"0.5946787",
"0.58996487",
"0.58758247",
"0.5842013",
"0.5826114",
"0.5824589",
"0.5681209",
"0.56638604",
"0.56560427",
"0.5653275",
"0.5592476",
"0.5589071",
"0.5589071",
"0.557641",
"0.5573647",
"0.5561114",
"0.55604887"... | 0.6274498 | 1 |
Remove the sprite from all lists and cancel the update event. | def remove_from_sprite_lists(self):
super().remove_from_sprite_lists()
# It is very important to call this to prevent potential
# issues such as crashes or excess memory use from failed
# garbage collection.
pyglet.clock.unschedule(self.update) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n # delete sprite if fired\n if not self.player.state == 'USE_A':\n self.game.all_sprites.remove(self)",
"def remove_sprites(self, *sprites):\r\n with self.lock:\r\n self.sprites_to_unload.update(sprites)",
"def _remove_texture(self):\n # Retrieve the i... | [
"0.766939",
"0.72574145",
"0.6607035",
"0.65096223",
"0.64890796",
"0.64082247",
"0.63706535",
"0.63706535",
"0.6319077",
"0.6264712",
"0.62010026",
"0.61186045",
"0.60208344",
"0.60023475",
"0.59555334",
"0.59235364",
"0.5921738",
"0.5916878",
"0.5907688",
"0.5894691",
"0.58... | 0.82141757 | 0 |
Creates input data for tests using preprocessed standard star and its calibration files. The raw files will be downloaded and saved inside the path stored in the `$DRAGONS_TEST/raw_inputs` directory. Processed files will be stored inside a new folder called "dragons_test_inputs". The subdirectory structure should refle... | def create_inputs_recipe():
module_name, _ = os.path.splitext(os.path.basename(__file__))
path = os.path.join(CREATED_INPUTS_PATH_FOR_TESTS, module_name)
os.makedirs(path, exist_ok=True)
os.chdir(path)
os.makedirs("inputs/", exist_ok=True)
print('Current working directory:\n {:s}'.format(os.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_test_inputs(input_dir):\n # Prepare input parameters\n parameters = Dict(dict={})\n # example structure: bcc Fe\n structure = StructureData(cell=[[1.42002584, 1.42002584, 1.42002584],\n [1.42002584, -1.42002584, -1.42002584],\n ... | [
"0.6538091",
"0.6146276",
"0.607586",
"0.5977594",
"0.5945953",
"0.59351915",
"0.5910153",
"0.5886085",
"0.5845465",
"0.5794927",
"0.576355",
"0.574656",
"0.57456464",
"0.57011575",
"0.5694419",
"0.569211",
"0.5688554",
"0.5685619",
"0.56332463",
"0.56278634",
"0.5609137",
... | 0.7445018 | 0 |
This function checks that the ordering of the samples matches between the expression file and the metadata file. This ordering is used for calculating DEGs. | def compare_and_reorder_samples(expression_file, metadata_file):
# Check ordering of sample ids is consistent between gene expression data and metadata
metadata = pd.read_csv(metadata_file, sep="\t", header=0, index_col=0)
metadata_sample_ids = metadata.index
expression_data = pd.read_csv(expression_fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_file_sorting(observable_config_path: list[Path]) -> None:\n _names = list(map(lambda f: f.name, observable_config_path))\n _names_sorted = list(\n sorted(_names, key=lambda f: re.findall(r\"(\\d+).bin\", f)[0])\n )\n _is_match = [f0 == f1 for f0, f1 in zip(_names, _names_sorted)]\n ... | [
"0.57153094",
"0.5681696",
"0.56747234",
"0.56506944",
"0.56446517",
"0.5587243",
"0.5585911",
"0.5583389",
"0.5577927",
"0.5573355",
"0.55560887",
"0.55500454",
"0.5520259",
"0.5505986",
"0.5488156",
"0.546695",
"0.5445724",
"0.54166615",
"0.5415728",
"0.54112035",
"0.539252... | 0.8004621 | 0 |
This function reads in pseudomonas pathway data from `pathway_DB_filename` and formats and outputs it to `output_filename` in order to be used in GSEA_analysis.R | def format_pseudomonas_pathway_DB(pathway_DB_filename, local_dir, out_filename):
# Read in pathway data
pa_pathway_DB = pd.read_csv(
pathway_DB_filename,
names=["pathway id", "num genes", "genes"],
sep="\t",
header=None,
)
# Drop extra column
pa_pathway_DB.drop(colum... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_ripser_output(output_path,max_dim,output_name=None):\n # \\todo add persistence by density (columns pers by threshold and column pers by dens) ## only needed if input weighted network\n output_file_path =os.path.join(output_path,'output_ripser.txt')\n data = open(output_file_path,'rb').readlines(... | [
"0.5886894",
"0.5863955",
"0.5786592",
"0.5592899",
"0.558136",
"0.5495973",
"0.5433662",
"0.5431351",
"0.5404583",
"0.53899485",
"0.53796154",
"0.53388137",
"0.5241749",
"0.52406466",
"0.52103275",
"0.5181477",
"0.5170354",
"0.51633763",
"0.5160058",
"0.513753",
"0.5134894",... | 0.78855044 | 0 |
Compute the hash of a parsed JSON value using the given hash object. This function does not hash the JSON value, it hashes the object tree that is the result of parsing a string in JSON format. Hashables (JSON objects) are hashed entry by entry in order of the lexicographical ordering on the keys. Iterables are hashed ... | def hash_json( hash_obj, value ):
try:
items = iter(list(value.items( )))
except AttributeError:
# Must check for string before testing iterability since strings are iterable
if isinstance( value, str ):
_hash_string( hash_obj, value )
else:
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hash_json(self):\n # pre-sorted str object\n self.assertEqual('5348ed1f4cd2f73e576bb66b866f2800', \\\n comparator.hash_json('{\"a_1\": [{\"a_2\": 2, \"f_2\": 3, \"g_2\": 1}], \"c_3\": 1}'))\n # pre-sorted dict object\n self.assertEqual('5348ed1f4cd2f73e576bb66b866f28... | [
"0.65041846",
"0.6385206",
"0.6255319",
"0.62435746",
"0.6187472",
"0.6180679",
"0.6165562",
"0.6159233",
"0.6080034",
"0.5938248",
"0.59185636",
"0.5907186",
"0.5907186",
"0.5907186",
"0.5907186",
"0.5907186",
"0.58739746",
"0.58451295",
"0.58451295",
"0.58178645",
"0.581098... | 0.79588073 | 0 |
Remove selected items from the tree. Because data is stored separately also need to deal with it, but deleting the matching items from the data list and updating all of the data indexes is a bit of a headache, so just make them empty. | def remove_treeItem(browser, tree):
items = tree.selectedItems()
for item in items:
if item.listIndex: # Only dataset items have a listIndex
browser.ui.workingDataTree.dataItems[item.listIndex] = []
sip.delete(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_selected(self):\n if not self.tree_widget.selectedItems():\n self.configuration_widgets.logger.warning('Nothing has been selected. Please select an item and try again.')\n return\n _selected_items = self.tree_widget.selectedItems()\n root = self.tree_widget.inv... | [
"0.72222024",
"0.67945594",
"0.6788877",
"0.6749571",
"0.66043264",
"0.6599819",
"0.65675104",
"0.6546712",
"0.6505644",
"0.634928",
"0.6347942",
"0.6327042",
"0.632324",
"0.63223594",
"0.62746567",
"0.6272785",
"0.6232611",
"0.6196286",
"0.61239",
"0.6118763",
"0.6097092",
... | 0.72647107 | 0 |
Clone h5 item. Useful for Drag & Drop | def clone_item(item):
i = h5Item(item.text(0))
i.path = item.path
i.listIndex = item.dataIndex
i.originalIndex = item.originalIndex
i.data = item.data
return i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone(self):",
"def clone(self):\n raise NotImplementedError",
"def copy(self, h5file=None):\n h5 = qpimage.core.copyh5(self.h5, h5file)\n return FLImage(h5file=h5, h5dtype=self.h5dtype)",
"def copy(self):\n new_h5 = FileHDFio(file_name=self.file_name, h5_path=self.h5_path)\n ... | [
"0.6020959",
"0.58370215",
"0.5827161",
"0.5780741",
"0.57302743",
"0.57141834",
"0.568242",
"0.5659609",
"0.5652022",
"0.56075025",
"0.55323535",
"0.5526989",
"0.5505679",
"0.5489802",
"0.54832345",
"0.5482787",
"0.5463926",
"0.53882384",
"0.5372098",
"0.5372057",
"0.533904"... | 0.74541837 | 0 |
Helper function to convert SPARQL results into a Pandas data frame. | def get_sparql_dataframe(query, service = "https://query.wikidata.org/sparql"):
sparql = SPARQLWrapper(service)
sparql.setQuery(query)
sparql.setReturnFormat(JSON)
result = sparql.query()
processed_results = json.load(result.response)
cols = processed_results['head']['vars']
out = []
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sparql_dataframe(service, query):\n sparql = SPARQLWrapper(service)\n sparql.setQuery(query)\n sparql.setReturnFormat(JSON)\n result = sparql.query()\n\n processed_results = json.load(result.response)\n cols = processed_results['head']['vars']\n\n out = []\n... | [
"0.7584528",
"0.7129623",
"0.7129623",
"0.711426",
"0.7094009",
"0.7050637",
"0.70471936",
"0.6952182",
"0.6945529",
"0.6940668",
"0.6868899",
"0.6827423",
"0.6801506",
"0.6724016",
"0.67137694",
"0.6685681",
"0.6672927",
"0.6663773",
"0.66266656",
"0.6613739",
"0.6602476",
... | 0.7614764 | 0 |
Build a set of resources who are available for a given time. It might make more sense to work based on a given restricted resource set. | def avail(self, time, resource_group):
a = set()
for r in self.resource_group.resources:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter_resources_by_age(self, resources: [], resource_age_minutes: int):\n all_resources = []\n for resource in resources:\n if resource_age_minutes:\n start = self._to_utc_datetime(resource.updated_on)\n end = datetime.utcnow().replace(tzinfo=pytz.UTC)\n... | [
"0.6184426",
"0.60298663",
"0.5953174",
"0.5767035",
"0.5638926",
"0.5493595",
"0.54747224",
"0.5458828",
"0.54446715",
"0.5438135",
"0.53841877",
"0.53665984",
"0.5353068",
"0.53493536",
"0.53424084",
"0.53357965",
"0.53341115",
"0.5326668",
"0.53145623",
"0.5271738",
"0.526... | 0.73468834 | 0 |
Test to see if the mongodb client logger can persist a log entry to the database | def test_mongo_logging_client_persists_log():
error_message = "This is a test message."
logger = LoggingService(console_output=True)
result = logger.log(LogEntry(LogLevel.ERROR, __name__, error_message))
logger.log(LogEntry(LogLevel.WARN, __name__, error_message))
logger.log(LogEntry(LogLevel.INFO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_log(self):\n message = \"Message is {0}\".format(random.random())\n resp = gracedb.writeLog(eventId, message)\n self.assertEqual(resp.status, 201)\n new_log_uri = resp.getheader('Location')\n new_log = resp.json()\n self.assertEqual(new_log_uri, new_log['se... | [
"0.6045933",
"0.586778",
"0.5836898",
"0.5810724",
"0.57567275",
"0.56929016",
"0.56574714",
"0.5656057",
"0.5636488",
"0.5636488",
"0.5576545",
"0.55317235",
"0.5509709",
"0.54728764",
"0.5472665",
"0.5462667",
"0.54399234",
"0.53963417",
"0.53956026",
"0.5391641",
"0.538321... | 0.6278423 | 0 |
All horizontal squares from the piece's point of view. Returns a list of relative movements up to the board's bound. | def horizontals(self):
horizontal_shifts = set(izip_longest(map(
lambda i: i - self.x, range(self.board.length)), [], fillvalue=0))
horizontal_shifts.discard((0, 0))
return horizontal_shifts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spanning_squares(self):\n spanning = []\n for i in range(self.length):\n # Assume ACROSS and DOWN are the only valid directions\n if self.direction == \"ACROSS\":\n spanning.append((self.start_x + i, self.start_y))\n else:\n spanning.... | [
"0.6494722",
"0.64518917",
"0.6354893",
"0.63426304",
"0.63299483",
"0.6264752",
"0.6235491",
"0.6193277",
"0.6177784",
"0.6174575",
"0.61528724",
"0.6148699",
"0.61453056",
"0.6122243",
"0.6096462",
"0.6087461",
"0.60867596",
"0.60618335",
"0.6006694",
"0.59964144",
"0.59660... | 0.7379711 | 0 |
All vertical squares from the piece's point of view. Returns a list of relative movements up to the board's bound. | def verticals(self):
vertical_shifts = set(izip_longest([], map(
lambda i: i - self.y, range(self.board.height)), fillvalue=0))
vertical_shifts.discard((0, 0))
return vertical_shifts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vertical(self, x, y):\n\n return [row[x] for row in self._board]",
"def spanning_squares(self):\n spanning = []\n for i in range(self.length):\n # Assume ACROSS and DOWN are the only valid directions\n if self.direction == \"ACROSS\":\n spanning.a... | [
"0.6549495",
"0.65164524",
"0.6475518",
"0.6370953",
"0.63641816",
"0.63362104",
"0.6315978",
"0.62523115",
"0.6206709",
"0.6104576",
"0.6071588",
"0.60655314",
"0.6062132",
"0.60403407",
"0.60398203",
"0.6025194",
"0.5976983",
"0.5959147",
"0.59579796",
"0.5956464",
"0.59492... | 0.7238823 | 0 |
Return list of relative movements allowed. | def movements(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMovableRange(self, unit):\n CostArr_mod = modifyMovCost(CostArr, ability)\n Obstacles = self.getUnpassable(player) # units that are not passable....\n pos_list, path_list = UCS_solve(unit.pos, CostArr_mod, unit.MovPnt)\n return pos_list, path_list",
"def all_rel_actions(self, p... | [
"0.6335595",
"0.6219791",
"0.61731637",
"0.6113557",
"0.6098801",
"0.6082442",
"0.6076151",
"0.60303247",
"0.59810054",
"0.59727407",
"0.59463936",
"0.59408045",
"0.5901733",
"0.58617115",
"0.58573633",
"0.58515835",
"0.58431864",
"0.58416694",
"0.5836999",
"0.5812548",
"0.58... | 0.6397189 | 0 |
Return the cached territory occupied by the piece. | def territory(self):
cache_key = (
self.board.length, self.board.height, self.uid, self.index)
if cache_key not in self.territory_cache:
vector = self.compute_territory()
self.territory_cache[cache_key] = vector
else:
vector = self.territory_cache[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_territory(self):\n # Initialize the square occupancy vector of the board.\n vector = self.board.new_vector()\n\n # Mark current position as reachable.\n vector[self.index] = True\n\n # List all places reacheable by the piece from its current position.\n for x_s... | [
"0.6026444",
"0.59270763",
"0.5713847",
"0.56876725",
"0.5581824",
"0.5523887",
"0.5491418",
"0.54348814",
"0.54129577",
"0.5392716",
"0.5293671",
"0.5249759",
"0.5236839",
"0.5229331",
"0.5221467",
"0.5203362",
"0.51952547",
"0.5169698",
"0.5168036",
"0.5155035",
"0.51431674... | 0.6969132 | 0 |
Compute territory reachable by the piece from its current position. Returns a list of boolean flags of squares indexed linearly, for which a True means the square is reachable. | def compute_territory(self):
# Initialize the square occupancy vector of the board.
vector = self.board.new_vector()
# Mark current position as reachable.
vector[self.index] = True
# List all places reacheable by the piece from its current position.
for x_shift, y_shift... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_moves(self):\n\n from itertools import product\n free_position = self.find_free()\n return [list(free_position+i) for i in [[0,1],[1,0],[-1,0],[0,-1]] if tuple(i+free_position) in product(range(self.size),repeat=2)]",
"def _get_rules_possibles_moves(cell, board_shape):\n retu... | [
"0.5903241",
"0.5804372",
"0.57658273",
"0.57489616",
"0.5739321",
"0.5720743",
"0.5670181",
"0.5648418",
"0.5639911",
"0.5635544",
"0.5632291",
"0.5622091",
"0.5598855",
"0.559796",
"0.5573405",
"0.55529225",
"0.5552635",
"0.5536598",
"0.55041766",
"0.55024284",
"0.54945725"... | 0.6670306 | 0 |
Generate M3U file for the given software into out_dir | def generate(software, out_dir, suffix, dry_run):
m3u_filename = software.name + (suffix if suffix else '') + '.m3u'
if not dry_run:
m3u_fd = open(os.path.join(out_dir, m3u_filename), 'w')
for i in software.images():
image_rel_path = os.path.relpath(i.path, out_dir)
if not dry_run... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_output_matrix_files(self, year, max_zone_id):\r\n from opus_emme2.travel_model_output import TravelModelOutput\r\n tm_output = TravelModelOutput(self.emme_cmd)\r\n year_config = self.config['travel_model_configuration'][year]\r\n for x in 1,2,3:\r\n if \"bank%i\" %... | [
"0.5642974",
"0.5558042",
"0.5551027",
"0.5361542",
"0.53559524",
"0.5301094",
"0.5252762",
"0.5241855",
"0.5204623",
"0.5158686",
"0.51586396",
"0.5136852",
"0.51365227",
"0.51075536",
"0.50907314",
"0.5074185",
"0.50671935",
"0.50445044",
"0.5027117",
"0.5024382",
"0.502100... | 0.8317543 | 0 |
Generate M3U file for the list of softwares into out_dir | def generate_all(softwares, out_dir, suffix, dry_run):
if not dry_run:
if not out_dir.exists():
out_dir.mkdir(parents=True)
multi_images_softwares = (x for x in softwares if x.nb_images() > 1)
for i in multi_images_softwares:
try:
generate(i, out_dir, suf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(software, out_dir, suffix, dry_run):\n m3u_filename = software.name + (suffix if suffix else '') + '.m3u'\n\n if not dry_run:\n m3u_fd = open(os.path.join(out_dir, m3u_filename), 'w')\n\n for i in software.images():\n image_rel_path = os.path.relpath(i.path, out_dir)\n\n ... | [
"0.7786916",
"0.5748073",
"0.5662895",
"0.5528735",
"0.55101776",
"0.5463695",
"0.5421654",
"0.5380845",
"0.53311723",
"0.5303696",
"0.52977276",
"0.52798694",
"0.5260766",
"0.52486426",
"0.5233821",
"0.51944816",
"0.5123264",
"0.5093341",
"0.5092315",
"0.50845486",
"0.506893... | 0.59200364 | 1 |
Recursively parses XML contents to python dict. We assume that `object` tags are the only ones that can appear multiple times at the same level of a tree. | def recursive_parse_xml_to_dict(xml):
if not xml:
return {xml.tag: xml.text}
result = {}
for child in xml:
child_result = recursive_parse_xml_to_dict(child)
if child.tag != 'object':
result[child.tag] = child_result[child.tag]
else:
if child.tag not in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_parse_xml_to_dict(xml):\n if not xml:\n return {xml.tag: xml.text}\n result = {}\n for child in xml:\n child_result = recursive_parse_xml_to_dict(child)\n if child.tag != 'object':\n result[child.tag] = child_result[child.tag]\n else:\n if child.tag not in result:\n re... | [
"0.76405007",
"0.6487578",
"0.6464231",
"0.6301873",
"0.6218455",
"0.6149198",
"0.6135709",
"0.607625",
"0.60481364",
"0.58940786",
"0.5876097",
"0.5762465",
"0.5756617",
"0.5738174",
"0.5733136",
"0.57227683",
"0.5722584",
"0.56979394",
"0.5683315",
"0.5661643",
"0.5641846",... | 0.7581804 | 1 |
Key to sort hosts / domains alphabetically, by domain name. | def domain_sort_key(domain):
import re
domain_expr = r'(.*\.)?(.*\.)(.*)' # Eg: (www.)(google.)(com)
domain_search = re.search(domain_expr, domain)
if domain_search and domain_search.group(1):
# sort by domain name and then everything left of
# Eg: google, com, www
domain_valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subdomain_sorting_key(hostname):\n parts = hostname.split('.')[::-1]\n if parts[-1] == 'www':\n return parts[:-1], 1\n return parts, 0",
"def list_domain_names(self) -> Dict:\n pass",
"def get_hosts(self):\n\n return sorted(self.host_data.keys())",
"def sort_... | [
"0.77395064",
"0.5994397",
"0.59496844",
"0.5851569",
"0.5843953",
"0.5838",
"0.58089083",
"0.5635496",
"0.56327444",
"0.55446255",
"0.5542909",
"0.5542909",
"0.5528308",
"0.55238223",
"0.5503389",
"0.5494649",
"0.54859453",
"0.5457136",
"0.5452885",
"0.544919",
"0.54136103",... | 0.8291568 | 0 |
draw and label a cube. edges is a list of numbers between 1 and 12, specifying which of the 12 cube edges to draw | def draw_cube(ax, xy, size, depth=0.3,
edges=None, label=None, label_kwargs=None, **kwargs):
if edges is None:
edges = range(1, 13)
x, y = xy
y -= size # set left/up corner as the first (0,0) for one cube
# first plot background edges
if 9 in edges:
ax.plot([x + d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeCube(c) :\n print(\"Edge Length =\",c.getLength())\n print(\"Volume =\",c.volume())\n print(\"Surface Area =\",c.surfaceArea())\n print(\"Face Diagonal =\",c.faceDiagonal())\n print(\"Space Diagonal =\",c.spaceDiagonal())",
"def main() :\n c1 = Cube(5.3) # cube with edge length of 5.3\... | [
"0.6443449",
"0.6413569",
"0.6355094",
"0.63017035",
"0.6130413",
"0.6115143",
"0.60516644",
"0.59508514",
"0.59508514",
"0.59094137",
"0.58450186",
"0.5810668",
"0.5770342",
"0.57679313",
"0.5727801",
"0.5716166",
"0.57069796",
"0.56948054",
"0.5686037",
"0.5677185",
"0.5661... | 0.73245275 | 0 |
Validates the .workflow file. | def validate_syntax(self):
resolves_present = False
uses_present = False
if not self.wf.get('workflow', None):
pu.fail('A workflow block must be present\n')
else:
for _, wf_block in dict(self.wf['workflow']).items():
if wf_block.get('resolves', Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate(self):\n if not self._contents.has_key('type'):\n raise ValidationFailed(\"Metadata file %s contains no type field\" % (self._filename))\n \n if not self._contents.has_key('version'):\n raise ValidationFailed(\"Metadata file %s contains no version field\" %\... | [
"0.6631906",
"0.6614255",
"0.6606154",
"0.6537318",
"0.63448745",
"0.62795186",
"0.62735194",
"0.6186111",
"0.61825204",
"0.6171616",
"0.61469364",
"0.61425644",
"0.61318344",
"0.6077196",
"0.6075853",
"0.6061646",
"0.60611504",
"0.6057122",
"0.60558885",
"0.6055866",
"0.6049... | 0.67150223 | 0 |
normalize the dictionary representation of the workflow | def normalize(self):
# modify from this:
#
# "workflow": {
# "test-and-deploy": {
# "resolves": "deploy"
# }
# }
#
# to this:
#
# "workflow": {
# "name": "test-and-deploy",
# "on": "push"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalise_workflow(workflow_dict):\n normalise_process(workflow_dict)\n if not 'steps' in workflow_dict:\n exit_perm_fail(\"No steps in Workflow\")\n\n if isinstance(workflow_dict['steps'], dict):\n new_steps = []\n for step_id, step in workflow_dict['steps'].items():\n ... | [
"0.7474329",
"0.5918155",
"0.5898275",
"0.58240426",
"0.5808958",
"0.57993853",
"0.57069623",
"0.5687853",
"0.5675693",
"0.559138",
"0.5580299",
"0.5571338",
"0.55547684",
"0.5554434",
"0.55311835",
"0.5512876",
"0.55118704",
"0.549156",
"0.5486343",
"0.54750293",
"0.54630303... | 0.6584143 | 1 |
A GHA workflow is defined by specifying edges that point to the previous nodes they depend on. To make the workflow easier to process, we add forward edges. We also obtains the root nodes. | def complete_graph(self):
root_nodes = set()
for name, a_block in self.wf['action'].items():
a_block['name'] = name
for n in a_block.get('needs', []):
if not self.wf['action'][n].get('next', None):
self.wf['action'][n]['next'] = set()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_graph(self):\n raise NotImplementedError",
"def get_forward_init(node, graph):\n\tedges = []\n\tfor e in node.edges:\n\t\tif node.label <= graph.nodes[e.to].label:\n\t\t\tedges.append(e)\n\treturn edges",
"def _bfs_forward(self, start_node):\n visited = {node: (False) for node in self... | [
"0.68631876",
"0.59310347",
"0.5865252",
"0.57889354",
"0.57486254",
"0.57264847",
"0.56896424",
"0.5673367",
"0.5652373",
"0.5643193",
"0.5587451",
"0.55842507",
"0.55828464",
"0.5574014",
"0.5573729",
"0.55621177",
"0.55612457",
"0.5532347",
"0.5529374",
"0.55181307",
"0.55... | 0.6231825 | 1 |
Factory of ActionRunner instances, one for each action | def instantiate_runners(self):
for _, a in self.wf['action'].items():
if 'docker://' in a['uses']:
a['runner'] = DockerRunner(
a, self.workspace, self.env,
self.quiet, self.debug, self.dry_run)
continue
if 'shub://'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_clients():\n clients = {}\n\n rospy.loginfo(\"Waiting for rubble detector\")\n clients['rubble_detect'] = actionlib.SimpleActionClient('rubble_detect',\n RubbleDetectAction)\n\n rospy.loginfo(\"Waiting for rubble checker\")\n clie... | [
"0.56596607",
"0.56475294",
"0.5616994",
"0.5510894",
"0.54630816",
"0.5457942",
"0.54218817",
"0.5406142",
"0.53818655",
"0.5351243",
"0.53502804",
"0.5345953",
"0.532772",
"0.5279873",
"0.527048",
"0.523934",
"0.521685",
"0.51686555",
"0.515931",
"0.5137021",
"0.5137021",
... | 0.69310266 | 0 |
Generator of stages. A stages is a list of actions that can be executed in parallel. | def get_stages(self):
current_stage = self.wf['root']
while current_stage:
yield current_stage
next_stage = set()
for n in current_stage:
next_stage.update(self.wf['action'][n].get('next', set()))
current_stage = next_stage | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stages(self):\n return StageManager(session=self._session)",
"def stages(self):\r\n return pipelines.Stages(self)",
"def run(stages, maxsize=0):\n\n if isinstance(stages, list) and len(stages) == 0:\n raise ValueError(\"Expected at least 1 stage to run\")\n\n elif isinstance(stag... | [
"0.6442683",
"0.63786435",
"0.6202054",
"0.6113744",
"0.6091911",
"0.60464627",
"0.60097075",
"0.60097075",
"0.5929696",
"0.5866913",
"0.5734935",
"0.56417054",
"0.56399095",
"0.56399095",
"0.56399095",
"0.56128675",
"0.55290216",
"0.5513827",
"0.54971427",
"0.5468624",
"0.54... | 0.71270746 | 0 |
Runs the singularity action | def run(self, reuse=False):
build = True
if 'shub://' in self.action['uses']:
image = self.action['uses']
build = False
elif './' in self.action['uses']:
image = 'action/' + os.path.basename(self.action['uses'])
singularityfile_path = os.path.join(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_smoke(self):\n\t\tinit_state = torch.tensor(0.0)\n\t\ttotal_time = torch.tensor(4.0)\n\t\tprint('Agent state trajectory and actions:')\n\t\tAgent().play(init_state, total_time)\n\t\tpyro.clear_param_store()",
"def singularity_start(self, image):\n env_vars = self.action.get('env', {})\n\n ... | [
"0.5975073",
"0.5935403",
"0.59130096",
"0.57898796",
"0.5710506",
"0.56999266",
"0.56843907",
"0.5681977",
"0.55953836",
"0.55517167",
"0.5515142",
"0.55127794",
"0.5501622",
"0.5477187",
"0.5396195",
"0.53956157",
"0.5391933",
"0.53681904",
"0.53640187",
"0.53324854",
"0.53... | 0.6079829 | 0 |
Generates the image name from the image url. | def generate_image_name(self, image):
return image.replace('shub://', '').replace('/', '-') + '.simg' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_generated_image_name(full_image_url):\r\n\r\n logging.debug('get_generated_image_name({})'.format(full_image_url))\r\n\r\n image_name = datetime.datetime.now().strftime(\"%Y%m%d%H%M%S\")\r\n image_extension = full_image_url.split(\".\")[-1]\r\n image_name = image_name + \".\" + image_extension\... | [
"0.8253151",
"0.7566465",
"0.73151815",
"0.7306501",
"0.72865564",
"0.72370976",
"0.7237034",
"0.7213149",
"0.7112175",
"0.71032536",
"0.7042305",
"0.70135736",
"0.7007883",
"0.6985449",
"0.6945476",
"0.6920966",
"0.68803626",
"0.68720126",
"0.6842178",
"0.68296844",
"0.68112... | 0.8002894 | 1 |
Check whether an instance exists or not. | def singularity_exists(self):
instances = Client.instances(quiet=self.quiet)
for instance in instances:
if self.pid in instance.name:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _Exists(self, instance_only: bool = False) -> bool:\n cmd = util.GcloudCommand(self, 'spanner', 'instances', 'describe',\n self.name)\n\n # Do not log error or warning when checking existence.\n _, _, retcode = cmd.Issue(suppress_warning=True, raise_on_failure=False)\n i... | [
"0.7803968",
"0.76079255",
"0.70579004",
"0.7034308",
"0.7027742",
"0.7027742",
"0.6946009",
"0.689386",
"0.67451686",
"0.6722067",
"0.6699531",
"0.66554385",
"0.6641805",
"0.66386664",
"0.66077375",
"0.6606492",
"0.6554289",
"0.65404296",
"0.6523959",
"0.651226",
"0.6500812"... | 0.77773875 | 1 |
Starts a singularity instance based on the image. | def singularity_start(self, image):
env_vars = self.action.get('env', {})
for s in self.action.get('secrets', []):
env_vars.update({s: os.environ[s]})
for e, v in self.env.items():
env_vars.update({e: v})
env_vars.update({'HOME': os.environ['HOME']})
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def singularity_build(self, path, image):\n Client.build(os.path.join(\n path, 'singularity.def'\n ), self.generate_image_name(image))",
"def start_ssm(self, ssm_image):\n pass",
"def create_instance_by_image(self):\n print '# Start a new instance based on an existing AMI... | [
"0.666752",
"0.6325278",
"0.6263676",
"0.614632",
"0.5845064",
"0.5794984",
"0.5747361",
"0.5733841",
"0.5721612",
"0.56165344",
"0.5603583",
"0.5509438",
"0.54767895",
"0.5428946",
"0.53604615",
"0.53470963",
"0.5332762",
"0.53182864",
"0.53123957",
"0.5296787",
"0.52888715"... | 0.7294491 | 0 |
Load foia sba datasets | def load_sba_datasets(dbm, direc):
foia_504_1991_present = pd.read_excel(direc + 'FOIA - 504 (FY1991-Present).xlsx')
foia_7a_1991_1999 = pd.read_excel(direc + 'FOIA - 7(a) (FY1991-FY1999).xlsx', skiprows=1)
foia_7a_2000_2009 = pd.read_excel(direc + 'FOIA - 7(a)(FY2000-FY2009).xlsx', skiprows=1)
foia_7a_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_kiba_dataset():\n trainn_fold = json.load(\n open(os.path.join('dataset', 'regression', 'benchmark', 'KIBAtest', 'folds', 'train_fold_setting1.txt')))\n train_fold = []\n for e in zip(*trainn_fold):\n for ee in e:\n train_fold.extend(ee)\n #train_fold = [ee for e in tr... | [
"0.629331",
"0.62574154",
"0.61739457",
"0.61300355",
"0.6085598",
"0.6068422",
"0.6059043",
"0.599034",
"0.5854947",
"0.58494705",
"0.58464795",
"0.5826532",
"0.58246195",
"0.58217824",
"0.5821119",
"0.57790554",
"0.5750343",
"0.5750343",
"0.5742792",
"0.57419103",
"0.574190... | 0.76649237 | 0 |
We use the fmi standard to extract the correct set of config_params, inputs, outputs We look into the "causality" attribute for each variable in model description | def _extract_sim_config_from_fmi_std(self):
print("\n---- Looking to see if FMU model description contains required 'causality' type definitions ----")
sim_config_params = []
sim_inputs = []
sim_outputs = []
sim_other_vars = []
for variable in self.model_descrip... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doParametersOfInterest(self):\n \n self.modelBuilder.doVar('expr::cosW(\"0.87681811112\",)')\n self.modelBuilder.doVar('expr::sinW(\"0.48082221247\",)')\n self.modelBuilder.doVar('expr::mZ(\"91.2\",)')\n self.modelBuilder.doVar('expr::Lambda1(\"100.0\",)')\n self.modelBui... | [
"0.6243876",
"0.6197848",
"0.61577994",
"0.6136601",
"0.61252385",
"0.60175735",
"0.5826551",
"0.5813928",
"0.5751767",
"0.5715533",
"0.5710865",
"0.5692011",
"0.56493515",
"0.5560804",
"0.5558627",
"0.55206186",
"0.5514668",
"0.5512474",
"0.5510357",
"0.5506426",
"0.5503846"... | 0.6741056 | 0 |
Dump sim's config_params, inputs, and outputs to YAML file By default, we overwrite to main YAML config file. | def _dump_config_to_yaml_file(self,
sim_config_params = None,
sim_inputs = None,
sim_outputs = None,
sim_other_vars = None,
is_aux_yaml = False):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_config(_config, simulation_dir):\n with open(os.path.join(simulation_dir, 'config.yaml'), 'w') as f:\n yaml.dump(_config, f, default_flow_style=False)",
"def save():\n print(\"Saving config file..\")\n\n res = yaml.round_trip_dump(_conf, indent=2, block_seq_indent=1)\n\n with open(__c... | [
"0.730918",
"0.699196",
"0.68951195",
"0.67941695",
"0.6579302",
"0.6568991",
"0.6554705",
"0.64560366",
"0.64269376",
"0.64144593",
"0.6292432",
"0.6266346",
"0.6234814",
"0.62344337",
"0.62238747",
"0.617985",
"0.6164769",
"0.6161922",
"0.6141542",
"0.6134677",
"0.6123942",... | 0.81717044 | 0 |
Get string with the sim's config_params, inputs, and outputs for the model | def _get_sim_config_str(self):
log = "[FMU Validator] The set of configuration_parameters, inputs, and outputs defined is the following:\n"
log += "\n{}: {}".format("Sim Config Params -- Brain Config ", self.sim_config_params)
log += "\n{}: {}".format("Sim Inputs -- Brain Act... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model_config(model_name, args):\n if model_name == 'Tacotron2':\n model_config = dict(\n # optimization\n mask_padding=args.mask_padding,\n # audio\n n_mel_channels=args.n_mel_channels,\n # symbols\n n_symbols=args.n_symbols,\n ... | [
"0.63613605",
"0.6227064",
"0.6027238",
"0.6021502",
"0.59806687",
"0.59724784",
"0.58838063",
"0.5799649",
"0.5774296",
"0.57192713",
"0.5702105",
"0.57006687",
"0.568292",
"0.56661975",
"0.5660352",
"0.5649805",
"0.56424356",
"0.56185853",
"0.56185603",
"0.5617623",
"0.5615... | 0.737774 | 0 |
Remove nonalphanumeric characters to make them valid with Bonsai interaction. | def _clean_non_alphanumeric_chars(self):
for i,variable in enumerate(self.model_description.modelVariables):
clean_name = re.sub(r'[^a-zA-Z0-9_]', '', variable.name)
if clean_name != variable.name:
log = "Sim variable '{}' has been renamed to '{}' ".format(variable.name,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup_input(data):\n data = re.sub(r'[^0-9A-Za-z ()_,.-:]', '', data)\n return data",
"def clean_unnecessary_characters(self, tweet):\n tweet = tweet.lstrip(\"\\\"\").rstrip(\"\\\"\")\n tweet = re.sub(self.compiledAlphanumericRegex, ' ', tweet)\n tweet = tweet.replace('_', ' ')\n... | [
"0.73747957",
"0.73650575",
"0.73443496",
"0.7294863",
"0.72666633",
"0.72465616",
"0.7158626",
"0.7149394",
"0.713084",
"0.7125717",
"0.71202695",
"0.71086025",
"0.71029955",
"0.70836455",
"0.707941",
"0.70679945",
"0.70411354",
"0.70361745",
"0.70283735",
"0.7028341",
"0.70... | 0.744641 | 0 |
Template for simulating FMU models for Bonsai integration. Note, it calls FMUSimValidation to validate the model when first instanced. | def __init__(
self,
model_filepath: str,
fmi_version: str = FMI_VERSION,
start_time = START_TIME,
stop_time = STOP_TIME,
step_size = STEP_SIZE,
user_validation: bool = False,
use_unzipped_model: bool = False,
):
# validate simulation: config_v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __set_fmu__(self, fmu_file, result_handler, solver, atol, rtol, verbose):\n if self.fmu is None:\n \n # TODO:\n # See what can be done in catching the exception/propagating it\n self.fmu = pyfmi.load_fmu(fmu_file)\n \n # Get the optio... | [
"0.629378",
"0.6192165",
"0.60618526",
"0.6044517",
"0.60348445",
"0.6019483",
"0.5948904",
"0.5907536",
"0.5832203",
"0.58019847",
"0.572914",
"0.5647409",
"0.5641304",
"0.5582606",
"0.55634594",
"0.55448914",
"0.5505208",
"0.5491149",
"0.54623306",
"0.5438175",
"0.53968614"... | 0.70113957 | 0 |
Close model and remove unzipped model from temporary folder. | def close_model(self):
# Ensure model has been initialized at least once
self._model_has_been_initialized("close_model")
# terminate fmu model
# - avoids error from calling self.fmu.terminate if termination has already been performed
self._terminate_model()
# f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up_temp_files():\n global __tmp_model_dir\n\n if __tmp_model_dir is not None:\n FileUtils.deleteDirectory(__tmp_model_dir)\n __tmp_model_dir = None",
"def delete_model(self):\n os.remove(self.filepath)\n self.cmodel = None",
"def cleanUp(self):\r\n # Close any... | [
"0.71848893",
"0.7168014",
"0.69020855",
"0.6778169",
"0.66447943",
"0.6597088",
"0.63135016",
"0.6312071",
"0.63115525",
"0.62721944",
"0.6262568",
"0.6260771",
"0.6243184",
"0.61231935",
"0.60675275",
"0.60634017",
"0.6029513",
"0.59984267",
"0.5996684",
"0.599638",
"0.5995... | 0.7889111 | 0 |
Get a list of all variables in the sim (removing duplicates, if any). Note, list is kept the same from first time this method is called. | def get_all_var_names(self):
if hasattr(self, "all_var_names"):
return self.all_var_names
# Append all variables in model (defined in YAML).
aux_all_var_names = []
aux_all_var_names.extend(self.sim_config_params)
aux_all_var_names.extend(self.sim_inputs)
aux... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_variables(self):\n return []",
"def get_all_variables(self):\n out = []\n for i in self.items:\n out += i.get_all_variables()\n return out",
"def get_all_variables(self):\n out = []\n for i in self.items:\n out += i.get_all_variables()... | [
"0.7587621",
"0.74283415",
"0.74283415",
"0.74283415",
"0.74034715",
"0.73497486",
"0.73163354",
"0.71726215",
"0.7025907",
"0.6996247",
"0.6937989",
"0.6923813",
"0.67796665",
"0.6772739",
"0.67677814",
"0.67526543",
"0.6719864",
"0.6713113",
"0.6711427",
"0.67106885",
"0.66... | 0.7627399 | 0 |
Get var indices for each var name provided in list. | def _var_names_to_indices(self, var_names: List):
if type(var_names) is not type([]):
# Return empty array if input is not 'list' type
print("[_var_names_to_indices] Provided input is not of type list.")
return []
indices_array = []
names_array = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indices_of_var(v):\n name = v.varName\n indices = name[2:].split(',')\n i, j = int(indices[0]), int(indices[1])\n return i, j",
"def index(self, variables):\n return [self._variables.index(v) for v in variables]",
"def vars(self):\n return [Var(i,self.dims[i]) for i in... | [
"0.74116653",
"0.6916294",
"0.61451054",
"0.611666",
"0.59596854",
"0.5946558",
"0.5905192",
"0.5892637",
"0.58531195",
"0.5848885",
"0.5842754",
"0.5840236",
"0.58368546",
"0.5804591",
"0.5756725",
"0.5740407",
"0.57103246",
"0.56983846",
"0.56811184",
"0.5670195",
"0.565843... | 0.72467065 | 1 |
Get unique id for instance name (identifier). | def _get_unique_id(self):
now = datetime.now()
u_id = now.second + 60*(now.minute + 60*(now.hour + 24*(now.day + 31*(now.month + 366*(now.year)))))
return "instance" + str(u_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_id(self) -> str:\n return pulumi.get(self, \"instance_id\")",
"def instance_identifier(self):\n return self._instance_identifier",
"def instance_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"instance_id\")",
"def instance_id(self) -> pulumi.Output[str]:\n ... | [
"0.7969054",
"0.7793897",
"0.7737086",
"0.7737086",
"0.7737086",
"0.7737086",
"0.7737086",
"0.7737086",
"0.7641148",
"0.763706",
"0.7468007",
"0.7468007",
"0.7468007",
"0.7468007",
"0.7468007",
"0.7468007",
"0.7405071",
"0.7405071",
"0.7405071",
"0.7374773",
"0.7366122",
"0... | 0.7873312 | 1 |
Make sure all elements are in bond_len_dict, and return the value | def check_bond_len(dict, el_a, el_b):
if el_a in dict:
if el_b in dict[el_a]:
return dict[el_a][el_b]
print()
print(el_a + " and " + el_b + " bond length currently unsupported. Add value to the csv file.")
sys.exit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bond_checker(atom, dict, bond_dict):\n bound = []\n for item, values in dict.items():\n bond_range = check_bond_len(bond_dict, atom[0], values[\"element\"]) + 0.2\n if distance_checker(atom[1:], values[\"coor\"]) <= bond_range:\n bound.append(item)\n return bound",
"def get_... | [
"0.6285508",
"0.6202662",
"0.59115434",
"0.5817686",
"0.5773312",
"0.5631281",
"0.5628951",
"0.5608762",
"0.559284",
"0.5581179",
"0.5579353",
"0.5575587",
"0.5575587",
"0.5575587",
"0.5542769",
"0.55310816",
"0.55075777",
"0.5494907",
"0.5452239",
"0.54492265",
"0.5444122",
... | 0.70560527 | 0 |
Check for all atoms in bonding range | def bond_checker(atom, dict, bond_dict):
bound = []
for item, values in dict.items():
bond_range = check_bond_len(bond_dict, atom[0], values["element"]) + 0.2
if distance_checker(atom[1:], values["coor"]) <= bond_range:
bound.append(item)
return bound | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overlaps(self, atom, check_up_to, get_all_overlapping_atoms=True):\n if (check_up_to == 0):\n return True, []\n distances = self.structure.get_distances(atom, [i for i in range(0, check_up_to)], mic=True)\n minimum_percentage_allowed = 0.99\n valid = True\n overlap... | [
"0.6651107",
"0.6298358",
"0.6284692",
"0.61737514",
"0.6166369",
"0.61443436",
"0.6105336",
"0.61047226",
"0.6011335",
"0.5903171",
"0.5824142",
"0.5755893",
"0.5749033",
"0.57480836",
"0.57447016",
"0.57203454",
"0.5719759",
"0.57171327",
"0.5711364",
"0.5645471",
"0.563580... | 0.6625112 | 1 |
Takes an atom dict and writes it to an .xyz file in foldername in /Created_QD with filename as name for the file | def dict2file(dict, filename, foldername):
if foldername:
if not os.path.exists("../Created_QD/" + foldername):
os.makedirs("../Created_QD/" + foldername)
file = open("../Created_QD/" + foldername + "/" + filename + ".xyz", "w")
else:
file = open("../Created_QD/" + filename +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_to_xyz(self, filename): \n with open( filename, 'a' ) as F:\n F = open( filename, 'a' )\n F.write( '%d\\n'%self.num_atoms )\n F.write( \"XYZ\\n\" )\n for num,row in enumerate(self.atoms):\n try:\n F.write('%s '%self.species[num])\n except:\n F.write(... | [
"0.64304036",
"0.63667876",
"0.6360757",
"0.6177127",
"0.60185474",
"0.59346175",
"0.58930415",
"0.5840039",
"0.58249146",
"0.5794842",
"0.57787114",
"0.5749572",
"0.5735917",
"0.5710008",
"0.57033205",
"0.5697638",
"0.56691194",
"0.56664854",
"0.56631005",
"0.5657911",
"0.56... | 0.75428385 | 0 |
Finds atoms at the origin in a dict, returns its id | def base_atom(dict):
for atom, values in dict.items():
xyz = values["coor"]
if xyz[0] == xyz[1] == xyz[2] == 0:
return atom | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_demand_id(demand_dict, vn_id, fvr_id, svr, nbr):\n #print vn_id, fvr_id, svr, nbr\n for demand_id in demand_dict:\n if vn_id == demand_dict[demand_id]['vn_id'] and \\\n fvr_id == demand_dict[demand_id]['fnode_id'] and \\\n svr == demand_dict[demand_id]['svr'] and \\\n ... | [
"0.5926452",
"0.5634988",
"0.5295975",
"0.5282709",
"0.52257067",
"0.5161398",
"0.508171",
"0.5079885",
"0.5073828",
"0.5048743",
"0.5029526",
"0.50288653",
"0.5028559",
"0.5015856",
"0.5008036",
"0.49915805",
"0.49639514",
"0.4963865",
"0.49622545",
"0.4933749",
"0.4920927",... | 0.6143067 | 0 |
Converts strings y and n to boolean | def y2true(text):
while True:
if text == 'y':
return True
elif text == 'n':
return False
else:
text = input("Wrong input, try again: ") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_bool(s: str):\n if s.strip().lower() == \"y\":\n return True\n else:\n return False",
"def _get_bool(string):\n string = string.lower()\n return True if string == 'y' else False",
"def eval_y_n(self, question):\n answer = raw_input(question + \" [y/n] : \")\n retu... | [
"0.7319038",
"0.69107634",
"0.6700293",
"0.66846",
"0.6606526",
"0.6605776",
"0.65743244",
"0.65112495",
"0.65079075",
"0.62479234",
"0.62007165",
"0.61767143",
"0.6154451",
"0.6152505",
"0.61269474",
"0.61194664",
"0.611237",
"0.6106023",
"0.6097604",
"0.60594904",
"0.604145... | 0.6958512 | 1 |
Returns a matrix of map tiles | def createTiles():
Renderer.Clear()
map = []
w, h = len(testmap[0]), len(testmap)
x, y = 0, 0
for row in testmap:
for char in row:
map.append(makeTile(char, x, y))
x += 1
y += 1
x = 0
return map, w, h | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tiles(self) -> list:\n n_rows = self.mosaic_dimensions[0]\n n_columns = self.mosaic_dimensions[1]\n return [\n self.get_tile(i_row, i_column)\n for i_row in range(n_rows)\n for i_column in range(n_columns)\n ]",
"def __init__tiles__(self):\n ... | [
"0.707192",
"0.7048794",
"0.6917319",
"0.6899672",
"0.67853016",
"0.6704365",
"0.6704365",
"0.6682728",
"0.66672593",
"0.6522762",
"0.6433973",
"0.63403666",
"0.6328379",
"0.63274586",
"0.6298421",
"0.62948275",
"0.62924397",
"0.62750506",
"0.6272464",
"0.62414765",
"0.623640... | 0.75113404 | 0 |
This method parses poetic movements as specified in the movements_to_scrape list, follows each movement link and yields a request using parse_movement method | def parse(self, response):
movements_to_scrape = ["Beat","Black Arts","Black Mountain","Conceptual Poetry","Concrete Poetry",
"Confessional Poetry","Contemporary","Dark Room Collective","Formalism","Futurism",
"Harlem Renaissance","Jazz Poetry","Lang... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_movement(self, response):\n movement_name = response.meta['movement_name']\n movement_url = response.meta['movement_url']\n\n sresponse = scrapy.Selector(response)\n\n #Because each movement page contains a table that has maximum of ten rows, we need to go to the next page\n ... | [
"0.75489324",
"0.71242",
"0.5760647",
"0.5611293",
"0.55545515",
"0.55472314",
"0.5544202",
"0.5456553",
"0.5455188",
"0.5418424",
"0.54031754",
"0.5396842",
"0.53465706",
"0.53382075",
"0.5328522",
"0.53110784",
"0.529639",
"0.52911603",
"0.52840555",
"0.5279618",
"0.5242923... | 0.74549824 | 1 |
This method looks at each movement page and creates a new PoetItem for each poet found in page's table | def parse_movement(self, response):
movement_name = response.meta['movement_name']
movement_url = response.meta['movement_url']
sresponse = scrapy.Selector(response)
#Because each movement page contains a table that has maximum of ten rows, we need to go to the next page
#in or... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_poet(self, response):\n item = response.meta['item']\n\n sresponse = scrapy.Selector(response)\n poetdata = sresponse.xpath('//div[@class=\"view-content\"]')\n\n #TODO: Clear empty strings from poet item fields\n\n item['poet_basicbio'] = poetdata[0].xpath('div/span//te... | [
"0.6383938",
"0.62331283",
"0.548556",
"0.5451658",
"0.52535385",
"0.5233169",
"0.51950914",
"0.5124749",
"0.5098735",
"0.50874716",
"0.5037494",
"0.5027248",
"0.49692222",
"0.4942993",
"0.49003536",
"0.48962796",
"0.48873606",
"0.48739573",
"0.4872106",
"0.48439267",
"0.4840... | 0.71895266 | 0 |
This method scrapes data (bio, url of all poems) from each poet page to continue creating the poet item | def parse_poet(self, response):
item = response.meta['item']
sresponse = scrapy.Selector(response)
poetdata = sresponse.xpath('//div[@class="view-content"]')
#TODO: Clear empty strings from poet item fields
item['poet_basicbio'] = poetdata[0].xpath('div/span//text()').extract(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_poet_poems(self, response):\n poet_poems_url = response.meta['poet_poems_url']\n\n sresponse = scrapy.Selector(response)\n\n #like the movement pages, this page contains a table that has maximum of ten rows, we need to go to the next\n # page in order to extract all of the poe... | [
"0.7948013",
"0.68461853",
"0.67603666",
"0.66625357",
"0.61643696",
"0.6150909",
"0.5885224",
"0.5870858",
"0.58600146",
"0.578315",
"0.5738709",
"0.57362324",
"0.57036006",
"0.5684646",
"0.5677119",
"0.5675798",
"0.56603056",
"0.565232",
"0.5634309",
"0.56316173",
"0.562194... | 0.82065254 | 0 |
This method parses the poems found in the page of all poems available for a specific poet The poet poems url is the foreign key to poets collection | def parse_poet_poems(self, response):
poet_poems_url = response.meta['poet_poems_url']
sresponse = scrapy.Selector(response)
#like the movement pages, this page contains a table that has maximum of ten rows, we need to go to the next
# page in order to extract all of the poems associat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_poet(self, response):\n item = response.meta['item']\n\n sresponse = scrapy.Selector(response)\n poetdata = sresponse.xpath('//div[@class=\"view-content\"]')\n\n #TODO: Clear empty strings from poet item fields\n\n item['poet_basicbio'] = poetdata[0].xpath('div/span//te... | [
"0.76509404",
"0.6316497",
"0.6232622",
"0.60066766",
"0.59613264",
"0.55365926",
"0.5433117",
"0.5388524",
"0.53653985",
"0.5345765",
"0.5338251",
"0.5269565",
"0.52671176",
"0.5202305",
"0.51900584",
"0.51822567",
"0.51615363",
"0.5134702",
"0.5116707",
"0.5097585",
"0.5093... | 0.80227727 | 0 |
This method parses each poem on poem pages and finally yields the poemitems | def parse_poet_poem(self, response):
poemitem = response.meta['poemitem']
sresponse = scrapy.Selector(response)
poemitem['poem_text'] = sresponse.xpath('//div[@property = "content:encoded"]//text()').extract()
poemitem['poem_copyright'] = sresponse.xpath('//div[@class = "poem-credit"]//p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_poet_poems(self, response):\n poet_poems_url = response.meta['poet_poems_url']\n\n sresponse = scrapy.Selector(response)\n\n #like the movement pages, this page contains a table that has maximum of ten rows, we need to go to the next\n # page in order to extract all of the poe... | [
"0.7213079",
"0.71406233",
"0.6475927",
"0.59090114",
"0.5766759",
"0.5761037",
"0.5740958",
"0.57350755",
"0.57176733",
"0.56667167",
"0.5645379",
"0.56218153",
"0.56191784",
"0.5588704",
"0.5571916",
"0.5538668",
"0.5532088",
"0.55089444",
"0.55086166",
"0.54917306",
"0.548... | 0.7146734 | 1 |
Creates a coroutine that does nothing for when no sleep is needed. | async def no_sleep_coro():
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def awaitable(obj):\n yield from asyncio.sleep(0)\n return obj",
"def run_no_args(self):\n while True:\n if self.cancelled:\n return\n self.func()\n time.sleep(self.sleep_time / 1000.00)",
"def without_wait(self):\n return self.temp_implicit_w... | [
"0.62436175",
"0.6190582",
"0.61719257",
"0.6137821",
"0.5900524",
"0.58804405",
"0.5874823",
"0.58503664",
"0.58102584",
"0.57648695",
"0.57648695",
"0.5745751",
"0.5739838",
"0.57116777",
"0.5652093",
"0.5645594",
"0.5622938",
"0.56145954",
"0.5602458",
"0.55889374",
"0.558... | 0.8199025 | 0 |
A replacement sleep for Windows. Note that unlike `time.sleep` this may sleep for slightly less than the specified time. This is generally not an issue for Textual's use case. In order to create a timer that _can_ be cancelled on Windows, we need to create a timer and a separate event, and then we wait for either of th... | def sleep(secs: float) -> Coroutine[None, None, None]:
# Subtract a millisecond to account for overhead
sleep_for = max(0, secs - 0.001)
if sleep_for < 0.0005:
# Less than 0.5ms and its not worth doing the sleep
return no_sleep_coro()
timer = kernel32.CreateWait... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sleep(self, sleep_time: float = 10) -> None:\n sleep_until_interrupt(sleep_time, lambda: self.stopped, interval=0.5)",
"def sleep(sleep_time=0.250):\n time.sleep(sleep_time)",
"def sleep(secs=1.0):\n time.sleep(secs)",
"def set_sleep_timer(self, option, time):\n params = [\n ... | [
"0.6478523",
"0.6467439",
"0.62972337",
"0.62152714",
"0.61905533",
"0.61398786",
"0.6105847",
"0.61010325",
"0.6100269",
"0.609553",
"0.6091412",
"0.6091412",
"0.6072209",
"0.60244656",
"0.6000396",
"0.59438556",
"0.59020305",
"0.5901713",
"0.5888825",
"0.58390737",
"0.58360... | 0.6513097 | 0 |
Sets the cancel event so we know we can stop waiting for the timer. | def cancel_inner():
kernel32.SetEvent(cancel_event) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cancel(self):\n self.waiter.set_result_if_pending(None)\n \n timer = self.timer\n if (timer is not None):\n self.timer = None\n timer.cancel()",
"def cancel(self):\n self.waiter.set_result_if_pending(True)\n \n timer = self.timer\n ... | [
"0.7676816",
"0.7467314",
"0.7397475",
"0.733986",
"0.7244259",
"0.71759206",
"0.71301645",
"0.71301645",
"0.7041629",
"0.70007837",
"0.6995933",
"0.6995933",
"0.69819576",
"0.6949455",
"0.69289273",
"0.68336475",
"0.68163085",
"0.67847276",
"0.6758899",
"0.67556834",
"0.6755... | 0.7688794 | 0 |
Function responsible for waiting for the timer or the cancel event. | def wait_inner():
if (
kernel32.WaitForMultipleObjects(
2,
ctypes.pointer((HANDLE * 2)(cancel_event, timer)),
False,
INFINITE,
)
== WAIT_FAILED
):
time_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait(self, timeoout=None, state=\"C-completed\"):",
"async def wait_for_cancel(self):\n await self._cancel",
"def _wait_for_completion(self):\n if self.do_timing:\n self.timer.start(\"Running.\")\n\n while self.state != State.COMPLETED:\n self._update_state()\n\n ... | [
"0.7174734",
"0.71252257",
"0.68507195",
"0.68419737",
"0.67769885",
"0.67605805",
"0.67037636",
"0.66891533",
"0.66845816",
"0.66050535",
"0.65404123",
"0.65313905",
"0.64974064",
"0.6473606",
"0.64717025",
"0.64504385",
"0.6397383",
"0.63804114",
"0.63804114",
"0.63766485",
... | 0.76650566 | 0 |
Check {sysproid}.{appname}.{cell} is running. | def _test_app_running(self, running_set, sysproid, cell, appname):
full_app_name = '%s.%s.%s' % (sysproid, appname, cell)
self.assertIn(full_app_name, running_set) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_running(program):\n \n #cmd = [\"xdotool\", \"search\", \"--name\", program]\n cmd = [\"xdotool\", \"search\", \"--name\", \"--class\", \"--classname\", program]\n try:\n subprocess.check_output(cmd)\n return True\n except:\n return False",
"def is_sm_running() -> bool:... | [
"0.66739565",
"0.6461373",
"0.6416072",
"0.63748014",
"0.6368051",
"0.6345569",
"0.6295888",
"0.62739915",
"0.62605065",
"0.6186457",
"0.61560464",
"0.609521",
"0.60186034",
"0.6016657",
"0.6009209",
"0.6008331",
"0.6001014",
"0.59857357",
"0.5974706",
"0.595932",
"0.5954081"... | 0.6727489 | 0 |
This method is called during a move's `action_done`. It'll actually move a quant from the source location to the destination location, and unreserve if needed in the source location. This method is intended to be called on all the move lines of a move. This method is not intended to be called when editing a `done` move... | def _action_done(self):
# First, we loop over all the move lines to do a preliminary check: `qty_done` should not
# be negative and, according to the presence of a picking type or a linked inventory
# adjustment, enforce some rules on the `lot_id` field. If `qty_done` is null, we unlink
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loot_enq_move(self, item, toloc):\n itemloc = item.Location.ToLocation()\n self.pqi.enq(2, ['move', [[itemloc.X, itemloc.Y, itemloc.Z],\n item.Id, itemloc.Z,\n [toloc.X, toloc.Y, toloc.Z],\n item.Count\n ... | [
"0.6281393",
"0.6151487",
"0.6090694",
"0.60468554",
"0.6036133",
"0.5997963",
"0.5967796",
"0.59452647",
"0.59211004",
"0.58850086",
"0.5854653",
"0.5854297",
"0.58422697",
"0.5832115",
"0.5814126",
"0.5808458",
"0.5793776",
"0.5744125",
"0.57013524",
"0.569954",
"0.5652009"... | 0.6330825 | 0 |
The response iterable as writeonly stream. | def stream(self):
return ResponseStream(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_as_stream(self) -> Any:\n raise NotImplementedError # pragma: no cover",
"def stream(self, write, request):\n raise NotImplementedError(\"%s.stream\" % reflect.qual(self.__class__))",
"def getOutputStream(self):\r\n self._setHeaders()\r\n return self._response.getOutpu... | [
"0.7330909",
"0.6544413",
"0.64807034",
"0.6401678",
"0.6401678",
"0.6224532",
"0.59967285",
"0.59855986",
"0.5966709",
"0.594459",
"0.58853096",
"0.5849615",
"0.58353543",
"0.57926196",
"0.5761642",
"0.5744629",
"0.5694836",
"0.5675186",
"0.56467724",
"0.5643159",
"0.5639434... | 0.6642246 | 1 |
Returns any live games currently happening with the API | def _get_live_games(self):
response = requests.get(self._get_score_url())
if response.status_code == 200:
return [g for g in response.json()['games'] if g['status']['state'] == self.desired_game_state] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def fetch_games(self):\n return await self.http.get_game_list()",
"def get_games_from_database (self):\n r = requests.get (self.url_endpoint)\n if (r.status_code != 200):\n print (\"Failed to get games:\\n\", r.text)\n return r\n \n games = json.load... | [
"0.7730199",
"0.7471135",
"0.7325539",
"0.7287605",
"0.7253883",
"0.71185577",
"0.71165675",
"0.69969124",
"0.68289065",
"0.6684004",
"0.6620107",
"0.65803075",
"0.6573545",
"0.6527177",
"0.6521868",
"0.6480549",
"0.6474347",
"0.6449517",
"0.6438656",
"0.64343774",
"0.6428631... | 0.84799916 | 0 |
Gets the current team's score from the API | def _get_current_teams_score(self):
for game in self._get_live_games():
teams_playing = [x['abbreviation'] for index, x in game['teams'].items()]
if self.team in teams_playing:
# Our team is playing in this game, get the score
return int(ga... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score(self):\n return self.client.call('GET', self.name + 'score')",
"def getScore(data):\n return score",
"def get_score(self):\n return self.score",
"def get_scores(self):\n return self.score",
"def get_score(self):\n return self.score",
"def get_score(self):\n ret... | [
"0.7527059",
"0.72310585",
"0.6813954",
"0.681293",
"0.675793",
"0.675793",
"0.675793",
"0.66784096",
"0.66253316",
"0.6584562",
"0.6568987",
"0.6539687",
"0.6478145",
"0.6478145",
"0.6478145",
"0.64599675",
"0.6432476",
"0.63932824",
"0.63802594",
"0.6361858",
"0.6353685",
... | 0.7543717 | 0 |
A callback for when the score has changed | def _score_has_changed(self):
print('The score for {} has changed'.format(self.team))
self.relay_controller.activate_solenoid() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_score():\n pass",
"def set_score(self, change):\n self._score = self._score + change",
"def change_score(self, change: float=1):\n self._score += change",
"def updateScore(self, score):\n self.__score += score",
"def change_score(self, change: float = 1):\n sel... | [
"0.8341499",
"0.74432063",
"0.73771644",
"0.7372784",
"0.734759",
"0.73033684",
"0.72073954",
"0.71673465",
"0.7100169",
"0.70697486",
"0.7063373",
"0.69999087",
"0.6984844",
"0.6956813",
"0.6926817",
"0.6926514",
"0.69130313",
"0.69130313",
"0.69130313",
"0.6872642",
"0.6860... | 0.7795641 | 1 |
return a dict(a2p=arr0, p2a=arr1). Key "a2p" means converting amber order to phenix order Key "p2a" means converting phenix order to amber order | def get_indices_convert_dict(fn):
pdb_inp = pdb.input(file_name=fn)
pdb_hierarchy = pdb_inp.construct_hierarchy()
newids = OrderedDict((atom.id_str(), idx) for (idx, atom) in enumerate(pdb_hierarchy.atoms()))
oldids= OrderedDict((atom.id_str(), idx) for (idx, atom) in enumerate(pdb_inp.atoms()))
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paramz_to_dict(p):\n return dict([(k.name, np.array(k)) for k in p])",
"def convert_arrpart_to_dict(particles):\n partdict = {}\n partdict['m'] = particles[:,0]\n partdict['Z'] = particles[:,2]\n partdict['rho'] = particles[:,5]\n partdict['R'] = particles[:,7]\n partdict['vphi'] = p... | [
"0.6365707",
"0.59968275",
"0.5911731",
"0.5696765",
"0.5571321",
"0.55429137",
"0.54785323",
"0.54684395",
"0.54655355",
"0.5458638",
"0.54449743",
"0.5401446",
"0.53939253",
"0.5382905",
"0.5363385",
"0.5341607",
"0.53321666",
"0.53309155",
"0.53248113",
"0.53123164",
"0.53... | 0.6150025 | 1 |
Emit a deprecation warning about a gnomerelated reactor. | def deprecatedGnomeReactor(name: str, version: Version) -> None:
stem = DEPRECATION_WARNING_FORMAT % {
"fqpn": "twisted.internet." + name,
"version": getVersionString(version),
}
msg = stem + ". Please use twisted.internet.gireactor instead."
warnings.warn(msg, category=DeprecationWarni... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deprecation(self, message, *args, **kws):\n self._log(DEPRECATION, message, args, **kws)",
"def guarded_deprecation_warning(*args, **kwargs):\n if os.environ.get(\"SERVE_WARN_V1_DEPRECATIONS\", \"0\") == \"1\":\n from ray._private.utils import deprecated\n\n return deprecated(*args, **kwa... | [
"0.63709056",
"0.6337697",
"0.61615217",
"0.6083312",
"0.6040545",
"0.59742963",
"0.58868295",
"0.5778024",
"0.5695411",
"0.563647",
"0.56345797",
"0.5613319",
"0.55875045",
"0.5550916",
"0.5532492",
"0.5523634",
"0.5511823",
"0.5491791",
"0.5482633",
"0.546482",
"0.54356366"... | 0.75850695 | 0 |
clears noise from given image using bilateral Filter. | def filter_image(img):
return cv2.bilateralFilter(img, 9, 50, 50) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filtering(image):\n output = np.array(image)\n for x in xrange(0,1):\n bilateralFilter_img = cv2.bilateralFilter(output,5, 75, 75)\n\n return bilateralFilter_img",
"def remove_noise(image):\n filtered = cv2.absdiff(image.astype(np.uint8), 255,\n cv2.ADAPTIVE_THRES... | [
"0.6837545",
"0.66253495",
"0.6352146",
"0.6252205",
"0.6215135",
"0.6187826",
"0.60780174",
"0.60614115",
"0.6018258",
"0.5996656",
"0.5905434",
"0.59041035",
"0.58784217",
"0.581671",
"0.5788512",
"0.57701117",
"0.5768871",
"0.5768721",
"0.57474273",
"0.57364833",
"0.568226... | 0.6760517 | 1 |
Receives two images to compare, img1 being the original. and a string indictating which error function to use. doesnt assume images are the same size. | def compare_img(img1, img2, err_function="ALL"):
# make sure images are the same shape #
height1, width1, height2, width2 = img1.shape[0], img1.shape[1], img2.shape[0], img2.shape[1]
if img1.shape != img2.shape:
if width1 * height1 > width2 * height2:
img1 = resize_image(img1, width2, h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_images(self, img1, img2):\n if self.debug:\n cv2.imshow('img1', img1)\n cv2.imshow('img2', img2)\n cv2.waitKey(5)\n time.sleep(2)\n\n # find the mean squared difference between the images\n # http://www.pyimagesearch.com/2014/09/15/python... | [
"0.7262324",
"0.72613925",
"0.7194562",
"0.71092004",
"0.69404185",
"0.6802441",
"0.66210765",
"0.6609339",
"0.66056174",
"0.65600413",
"0.646752",
"0.6427402",
"0.6348418",
"0.63423145",
"0.6291259",
"0.62624484",
"0.6253601",
"0.6207154",
"0.6180912",
"0.6175744",
"0.613465... | 0.81464946 | 0 |
Function to log an event with the given key. If the ``key`` has not exceeded their allotted events, then the function returns ``False`` to indicate that no limit is being imposed. If the ``key`` has exceeded the number of events, then the function returns ``True`` indicating ratelimiting should occur. | def limit(self, key):
if self._debug:
return False
counter = self.database.List(self.name + ':' + key)
n = len(counter)
is_limited = False
if n < self._limit:
counter.prepend(str(time.time()))
else:
oldest = counter[-1]
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rate_limited(self, key_function=None):\n if key_function is None:\n def key_function(*args, **kwargs):\n data = pickle.dumps((args, sorted(kwargs.items())))\n return hashlib.md5(data).hexdigest()\n\n def decorator(fn):\n @wraps(fn)\n ... | [
"0.6314541",
"0.6014755",
"0.577914",
"0.5500181",
"0.54538137",
"0.5354464",
"0.5334985",
"0.5245052",
"0.5227737",
"0.5022069",
"0.4968157",
"0.49460158",
"0.49370098",
"0.49285924",
"0.49258116",
"0.48979118",
"0.48943257",
"0.48854864",
"0.4861771",
"0.48335403",
"0.47916... | 0.6515088 | 0 |
Function or method decorator that will prevent calls to the decorated function when the number of events has been exceeded for the given time period. It is probably important that you take care to choose an appropriate key function. For instance, if ratelimiting a webpage you might use the requesting user's IP as the k... | def rate_limited(self, key_function=None):
if key_function is None:
def key_function(*args, **kwargs):
data = pickle.dumps((args, sorted(kwargs.items())))
return hashlib.md5(data).hexdigest()
def decorator(fn):
@wraps(fn)
def inner(*ar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timed(limit):\n def decorate(func):\n def newfunc(*arg, **kw):\n start = time.time()\n func(*arg, **kw)\n end = time.time()\n if end - start > limit:\n raise TimeExpired(\"Time limit (%s) exceeded\" % limit)\n newfunc = make_decorator(... | [
"0.65584713",
"0.65495706",
"0.6525419",
"0.6494096",
"0.6299879",
"0.61791515",
"0.6172259",
"0.61206627",
"0.6065372",
"0.59967524",
"0.5996692",
"0.59204817",
"0.5900531",
"0.58844846",
"0.5834017",
"0.57783157",
"0.5757396",
"0.57387686",
"0.57096756",
"0.56504446",
"0.56... | 0.7474835 | 0 |
Get reported total capacity of file system Returns | def get_capacity():
fs.get_capacity() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_space_used():\n fs.get_space_used()",
"def get_space_used():\n files = jobtracker.query(\"SELECT * FROM files \" \\\n \"WHERE status IN ('added', 'downloaded', 'unverified')\")\n\n total_size = 0\n for file in files:\n total_size += int(file['size'])\n re... | [
"0.7905383",
"0.7686586",
"0.76265246",
"0.7514304",
"0.740728",
"0.7393012",
"0.73364675",
"0.73107606",
"0.72528416",
"0.72520536",
"0.71825486",
"0.71104777",
"0.7035991",
"0.70202947",
"0.7017264",
"0.6983544",
"0.6979307",
"0.6925965",
"0.6920043",
"0.6917545",
"0.689413... | 0.8695405 | 0 |
Get space used on file system Returns | def get_space_used():
fs.get_space_used() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSpaceUsage(path):\n st = os.statvfs(path)\n \n flash = { \"free\" : st.f_bavail * st.f_frsize, \"used\":(st.f_blocks - st.f_bfree) * st.f_frsize }\n \n #free = st.f_bavail * st.f_frsize\n #total = st.f_blocks * st.f_frsize\n #used = (st.f_blocks - st.f_bfree) * st.f_frsize\n return f... | [
"0.8161204",
"0.7796477",
"0.7787275",
"0.7772227",
"0.7726032",
"0.7704461",
"0.762351",
"0.7598784",
"0.7515085",
"0.74991655",
"0.7485404",
"0.7462633",
"0.7449219",
"0.7406714",
"0.73842853",
"0.73459834",
"0.73239464",
"0.72179013",
"0.720543",
"0.72001547",
"0.7185789",... | 0.9013167 | 0 |
Determine the box grid, the row 'x' and column 'y' are in and return the box grid boundaries (top left, bottom right). | def get_box_grid(x, y):
for grid in GRIDS:
if x >= grid[0][0] and y >= grid[0][1] and \
x <= grid[1][0] and y <= grid[1][1]:
return grid
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bounding_box(x: Bounds, y: Bounds, grid_spacing: int) -> (Bounds, Bounds):\n # Check if requested grid size is allowable\n if grid_spacing not in Grid._SUPPORTED_SIZES:\n raise RuntimeError(f'Grid spacing should be one of {Grid._SUPPORTED_SIZES} to keep grids of different spacing align... | [
"0.7276697",
"0.7249602",
"0.7174105",
"0.7131322",
"0.70830506",
"0.69582266",
"0.69582236",
"0.6817992",
"0.6778762",
"0.6744852",
"0.6739384",
"0.6738154",
"0.67366695",
"0.67229617",
"0.6694428",
"0.66317385",
"0.66051924",
"0.6581854",
"0.65696084",
"0.65642273",
"0.6550... | 0.82200074 | 0 |
Check through the puzzle array in the range delimited by top left (tl) and bottom right (br) for values in 'potential'. Any value found that is in 'potential' is removed so only missing values remain when it is returned. | def rm_pot(potential, puzzle, tl, br):
for y in range(tl[1], br[1]+1):
for x in range(tl[0], br[0]+1):
if puzzle[y][x] in potential:
potential.remove(puzzle[y][x])
return potential | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def searchDeadEnd(self):\n boundaries = []\n if not self.red:\n i = self.midWidth - 1\n else:\n i = self.midWidth + 1\n boudaries = [(i, j) for j in range(self.height)]\n validPositions = []\n for i in boudaries:\n if not (i[0], i[1]) in se... | [
"0.588401",
"0.5613431",
"0.5605046",
"0.5547881",
"0.544818",
"0.5424087",
"0.53872746",
"0.5362563",
"0.53606844",
"0.53606844",
"0.53370255",
"0.5326348",
"0.53133196",
"0.5296384",
"0.52813685",
"0.5255672",
"0.52168256",
"0.52042156",
"0.5199848",
"0.51857",
"0.51857",
... | 0.66826487 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.