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 |
|---|---|---|---|---|---|---|
Tests if a path is a directory. Returns false if the path doesn't exist Arguments path path from base_dir to test Returns True if the relative path exists and is a directory, false otherwise | def is_dir(self, path: PathLike): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_dir(path: str) -> bool:\n return _fs().is_dir(path)",
"def __is_dir(path):\n if path[-2:] == \"..\":\n return False\n try:\n os.listdir(path)\n return True\n except OSError:\n return False",
"def is_dir(self, path):",
"def isdir(path)... | [
"0.7775716",
"0.77111894",
"0.7675745",
"0.7675417",
"0.76733047",
"0.76327056",
"0.7531978",
"0.7465637",
"0.7448249",
"0.73913187",
"0.73895854",
"0.73610806",
"0.7224734",
"0.72012424",
"0.7200191",
"0.715806",
"0.7147332",
"0.71111375",
"0.70972735",
"0.7096089",
"0.70793... | 0.79958636 | 0 |
Moves a file Arguments path file to move dest new name force overwrite destination if it already exists | def move_file(self, path: PathLike, dest: PathLike, force: bool = False): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_file(self, ctx):\n pass",
"def move_file(source, destination):\n shutil.move(source, destination)",
"def move_file_in_dir(name_file, desten):\n\n if os.path.isfile(config_tools.full_dest+name_file):\n try:\n shutil.move(config_tools.full_dest + name_file, config_tools.fu... | [
"0.6376328",
"0.62976724",
"0.62910587",
"0.62454826",
"0.6236591",
"0.62363887",
"0.6194982",
"0.61860204",
"0.6177733",
"0.61675274",
"0.61501664",
"0.6081892",
"0.6053807",
"0.6048145",
"0.6032804",
"0.6019842",
"0.59479195",
"0.5903915",
"0.58947736",
"0.58812994",
"0.584... | 0.70383036 | 0 |
Sends the content of a filelike object to dest Arguments f filelike object to send the data from dest destination file force overwrite dest if it exists | def send_data(self, fp, dest: PathLike, force: bool = False): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_file(self, src: PathLike, dest: PathLike, force: bool = False):",
"def send_file(cobj, dest, port, fname, hash, handler):\n pass",
"def xwritefile(self, contents, dest):\n plog(\"Write FILE: %s (target)\" % dest)\n self.process_lock.acquire()\n self.file_event = threading.Event... | [
"0.7389688",
"0.70732176",
"0.67923933",
"0.6595714",
"0.6592659",
"0.652012",
"0.6485715",
"0.6468337",
"0.6403283",
"0.6335797",
"0.62887317",
"0.62700003",
"0.6240795",
"0.6138478",
"0.61377096",
"0.6116488",
"0.6108914",
"0.6072602",
"0.6052494",
"0.6020278",
"0.6005322",... | 0.76653785 | 0 |
Sends a local file to the filesystem Arguments src local path to send dest destination file force overwrite dest if it exists | def send_file(self, src: PathLike, dest: PathLike, force: bool = False): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_data(self, fp, dest: PathLike, force: bool = False):",
"def send_file(cobj, dest, port, fname, hash, handler):\n pass",
"def send_to(self, dest='.', src='/tmp/', url='localhost',\n rsync='rsync -auv'):\n files = self.setup(dest=dest, src=src)\n self.send_files(files, ur... | [
"0.7577915",
"0.73347324",
"0.7274894",
"0.71229845",
"0.6995063",
"0.6992337",
"0.68810284",
"0.6863784",
"0.6861998",
"0.67873704",
"0.67468715",
"0.6723805",
"0.67111367",
"0.6682649",
"0.6672077",
"0.6606493",
"0.6596375",
"0.6595891",
"0.6586833",
"0.6533342",
"0.6529708... | 0.85472107 | 0 |
Sends a local directory to the filesystem Arguments src local path to send dest destination file force overwrite dest if it exists | def send_dir(self, src: PathLike, dest: PathLike, force: bool = False): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_file(self, src: PathLike, dest: PathLike, force: bool = False):",
"def send_to(self, dest='.', src='/tmp/', url='localhost',\n rsync='rsync -auv'):\n files = self.setup(dest=dest, src=src)\n self.send_files(files, url=url, rsync=rsync)",
"async def send_dir(self, l_dir: st... | [
"0.7308566",
"0.72171694",
"0.71321857",
"0.6915138",
"0.6844987",
"0.64524376",
"0.64404553",
"0.6421553",
"0.6401422",
"0.6370069",
"0.6315896",
"0.629873",
"0.6294959",
"0.62886375",
"0.6280499",
"0.6256389",
"0.62376684",
"0.62245905",
"0.6223178",
"0.62230736",
"0.622185... | 0.85504943 | 0 |
Prints summary about the plotting factory, i.e. how many plots and how many datasets per plot. | def info(self):
print(
"""
Factory holds {0} unique plots
""".format(
len(self.plots)
)
)
for i, plot in enumerate(self.plots):
print("\t\tPlot {0} holds {1} unique datasets".format(i, len(plot)))
for j, data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summary(self):\n print('est0: %s (%s) shape: %s' % (str(self.est0.name),\\\n str(self.est0.type_name),str(self.shape0)))\n print('est1: %s (%s) shape: %s' % (str(self.est1.name),\\\n str(self.est1.type_name),str(self.shape1)))",
"def plot_summary(... | [
"0.638623",
"0.62468517",
"0.6173558",
"0.6142212",
"0.6122228",
"0.61037403",
"0.6093931",
"0.601596",
"0.5982683",
"0.59800595",
"0.5973954",
"0.5948189",
"0.5923871",
"0.59236693",
"0.5902417",
"0.5874367",
"0.58703357",
"0.5861119",
"0.58554405",
"0.5850963",
"0.5842174",... | 0.79544735 | 0 |
Gets the metricDataName and stores it in inputDict. @ In, metricDataName, string, the name of the metric data to find in currentInputs @ In, currentInputs, list of inputs to the step. @ Out, metricData, (data, probability) or Distribution | def __getMetricSide(self, metricDataName, currentInputs):
origMetricDataName = metricDataName
metricData = None
if metricDataName.count("|") == 2:
#Split off the data name and if this is input or output.
dataName, inputOrOutput, metricDataName = metricDataName.split("|")
inputOrOutput = [i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metric_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"metric_name\")",
"def metric_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"metric_name\")",
"def metric_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"metric_name\")",
"def metric_name(se... | [
"0.624774",
"0.624774",
"0.624774",
"0.624774",
"0.624774",
"0.624774",
"0.624774",
"0.624774",
"0.624774",
"0.6004401",
"0.60013425",
"0.5968178",
"0.59263635",
"0.5769216",
"0.57137525",
"0.5678455",
"0.5656198",
"0.5650079",
"0.5625243",
"0.56057525",
"0.5547415",
"0.542... | 0.7487086 | 0 |
Method to convert an input object into the internal format that is understandable by this pp. @ In, currentInputs, list or DataObject, data object or a list of data objects @ Out, measureList, list of (feature, target), the list of the features and targets to measure the distance between | def inputToInternal(self, currentInputs):
if type(currentInputs) != list:
currentInputs = [currentInputs]
hasPointSet = False
hasHistorySet = False
#Check for invalid types
for currentInput in currentInputs:
inputType = None
if hasattr(currentInput, 'type'):
inputType = cur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getMetricSide(self, metricDataName, currentInputs):\n origMetricDataName = metricDataName\n metricData = None\n if metricDataName.count(\"|\") == 2:\n #Split off the data name and if this is input or output.\n dataName, inputOrOutput, metricDataName = metricDataName.split(\"|\")\n inp... | [
"0.5752724",
"0.5747186",
"0.5526306",
"0.5408583",
"0.53520834",
"0.5276916",
"0.52656496",
"0.5253841",
"0.5166172",
"0.5164107",
"0.51506317",
"0.5145506",
"0.5129836",
"0.51163447",
"0.50772375",
"0.507193",
"0.507193",
"0.507193",
"0.50570136",
"0.5051872",
"0.5046417",
... | 0.6491432 | 0 |
Function to place all of the computed data into the output object, (Files or DataObjects) @ In, finishedJob, object, JobHandler object that is in charge of running this postprocessor @ In, output, object, the object where we want to place our computed results @ Out, None | def collectOutput(self, finishedJob, output):
evaluation = finishedJob.getEvaluation()
outputDict = evaluation[1]
# FIXED: writing directly to file is no longer an option!
#if isinstance(output, Files.File):
# availExtens = ['xml']
# outputExtension = output.getExt().lower()
# if outputEx... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collectOutput(self, finishedJob, output):\n evaluation = finishedJob.getEvaluation()\n realizations = evaluation[1]\n for rlz in realizations:\n output.addRealization(rlz)",
"def process_data_impl(\n self,\n data_dir: Path,\n output_processed_data_dir: Path,\n ... | [
"0.6574675",
"0.6127392",
"0.6064729",
"0.5923782",
"0.5727356",
"0.57027656",
"0.5702203",
"0.56893665",
"0.56857604",
"0.5634375",
"0.56176984",
"0.5612928",
"0.55692834",
"0.55657125",
"0.5565299",
"0.5564332",
"0.5558506",
"0.5557487",
"0.5541403",
"0.54904854",
"0.547541... | 0.74126345 | 0 |
Defines the method for writing the postprocessor to the metadata within a data object @ In, output, DataObject, instance to write to @ In, outputDictionary, dict, dictionary stores importance ranking outputs @ Out, xml, xmlUtils.StaticXmlElement instance, written data in XML format | def _writeXML(self,output,outputDictionary):
if self.dynamic:
outputInstance = xmlUtils.DynamicXmlElement('MetricPostProcessor', pivotParam=self.pivotParameter)
else:
outputInstance = xmlUtils.StaticXmlElement('MetricPostProcessor')
if self.dynamic:
for key, values in outputDictionary.item... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writer(output, output_name, output_data):\n\n kml = simplekml.Kml(name=output_name)\n for exif in output_data:\n if('Latitude' in exif.keys() and\n 'Latitude Reference' in exif.keys() and\n 'Longitude Reference' in exif.keys() and\n 'Longitude' in exif.keys()):\n\n ... | [
"0.62848055",
"0.6091799",
"0.59281194",
"0.58995914",
"0.5892859",
"0.57950956",
"0.57250816",
"0.5724971",
"0.5711625",
"0.558252",
"0.55467606",
"0.54956454",
"0.54015774",
"0.5382033",
"0.5348868",
"0.53484285",
"0.5312449",
"0.53020865",
"0.5281496",
"0.5264914",
"0.5247... | 0.6912283 | 0 |
This method executes the postprocessor action. In this case, it computes all the requested statistical FOMs @ In, inputIn, object, object contained the data to process. (inputToInternal output) @ Out, outputDict, dict, Dictionary containing the results | def run(self, inputIn):
measureList = self.inputToInternal(inputIn)
outputDict = {}
assert(len(self.features) == len(measureList))
for metricInstance in self.metricsDict.values():
metricEngine = MetricDistributor.factory.returnInstance('MetricDistributor', metricInstance)
for cnt in range(le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postprocess(self, predicted_output, original_input=None, stats=None,\n **kwargs):\n pass",
"def post_process(self, xout, params_out):\n # Should be used by all methods matching \"solve_*\"\n for post_processor in self.post_processors:\n xout, params_out = post_pro... | [
"0.63886046",
"0.6093946",
"0.58364964",
"0.5822951",
"0.5724847",
"0.5722103",
"0.5666244",
"0.5653509",
"0.56486124",
"0.5609944",
"0.5551084",
"0.55437094",
"0.54901344",
"0.54787505",
"0.54780346",
"0.5470728",
"0.5443683",
"0.5413777",
"0.5413007",
"0.541193",
"0.5403984... | 0.62134475 | 1 |
Adds this shifts to the shifts of a Manager | def addShift(self,shift):
self.shifts.append(shift) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_move(self, src_stool, dest_stool):\n self._moves.append((src_stool, dest_stool))",
"def shift_world(self, shift_x):\n \n # Keep track of the shift amount\n self.world_shift += shift_x\n \n # Go through all the sprite lists and shift\n for platform in self.platform_list:... | [
"0.5510193",
"0.5454511",
"0.5426584",
"0.53517616",
"0.5312542",
"0.5295599",
"0.52190506",
"0.5210897",
"0.51928455",
"0.5148344",
"0.51470137",
"0.5092125",
"0.5090508",
"0.5028467",
"0.49895385",
"0.49328935",
"0.49303526",
"0.49029002",
"0.48992595",
"0.4875514",
"0.4857... | 0.70099694 | 1 |
Adds shifts to the shifts of an OtherEmployee | def addShift(self,shift):
self.shifts.append(shift) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timeShift(requestContext, seriesList, timeShift, resetEnd=True):\n # Default to negative. parseTimeOffset defaults to +\n if timeShift[0].isdigit():\n timeShift = '-' + timeShift\n delta = parseTimeOffset(timeShift)\n myContext = requestContext.copy()\n myContext['startTime'] = requestContext['startTim... | [
"0.52900124",
"0.5264831",
"0.52391547",
"0.5217946",
"0.51995075",
"0.5186599",
"0.5149791",
"0.5123219",
"0.5078442",
"0.5069971",
"0.5008187",
"0.49915016",
"0.49864426",
"0.4894055",
"0.4874483",
"0.4814141",
"0.4812422",
"0.47921404",
"0.47912908",
"0.47912908",
"0.47864... | 0.6298685 | 1 |
WikiWrap output correct for a term used as an example | def testTermKnownValuesWikiWrapAsExample(self):
for wikilang, pos, termlang, thisterm, termgender, asexample, \
forlist in self.knownValues:
if pos == 'noun':
aterm = term.Noun(termlang, thisterm, gender=termgender)
if pos == 'verb':
aterm ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wikihtml(func):\r\n\r\n def wrapper(*args):\r\n\r\n title, summary, url = func(*args)\r\n\r\n if title is nan:\r\n title = \"\"\r\n\r\n if summary is nan:\r\n summary = \"No summary available on Wikipedia.\"\r\n\r\n html = textwrap.dedent(\"\"\"\r\n <... | [
"0.6259538",
"0.61308336",
"0.60023135",
"0.59724516",
"0.5887239",
"0.5870651",
"0.586986",
"0.5780278",
"0.57456815",
"0.56735915",
"0.56726545",
"0.5595575",
"0.5580393",
"0.549892",
"0.5473067",
"0.54588115",
"0.5457374",
"0.54445356",
"0.5441951",
"0.5429863",
"0.5413854... | 0.6360194 | 0 |
WikiWrap output correct for a term when used in a list | def testTermKnownValuesWikiWrapForList(self):
for wikilang, pos, termlang, thisterm, termgender, asexample, \
forlist in self.knownValues:
if pos == 'noun':
aterm = term.Noun(termlang, thisterm, gender=termgender)
if pos == 'verb':
aterm = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testTermKnownValuesWikiWrapAsTranslation(self):\n for wikilang, pos, termlang, thisterm, termgender, asexample, \\\n forlist in self.knownValues:\n if pos == 'noun':\n aterm = term.Noun(termlang, thisterm, gender=termgender)\n if pos == 'verb':\n ... | [
"0.60811985",
"0.5811943",
"0.5799776",
"0.5790018",
"0.57783914",
"0.5683409",
"0.5631308",
"0.5524831",
"0.54605496",
"0.5458223",
"0.5432345",
"0.54296",
"0.5403986",
"0.54038787",
"0.53376156",
"0.5331078",
"0.5297676",
"0.52778816",
"0.52608824",
"0.5248866",
"0.5247119"... | 0.64140075 | 0 |
WikiWrap output correct for a term when used as a translation | def testTermKnownValuesWikiWrapAsTranslation(self):
for wikilang, pos, termlang, thisterm, termgender, asexample, \
forlist in self.knownValues:
if pos == 'noun':
aterm = term.Noun(termlang, thisterm, gender=termgender)
if pos == 'verb':
at... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def question_new_translate():",
"def _HandleWikiWord(self, input_line, match, output_stream):\n if match[0] == \"!\":\n self._formatting_handler.HandleEscapedText(\n input_line,\n output_stream,\n match[1:])\n elif match not in self._wikipages:\n self._formatting_handle... | [
"0.61304134",
"0.60676885",
"0.60357094",
"0.5808856",
"0.5800657",
"0.5795465",
"0.5773981",
"0.57644665",
"0.5750903",
"0.57123756",
"0.5696135",
"0.5682429",
"0.5663875",
"0.54854393",
"0.5484407",
"0.5482715",
"0.5454619",
"0.5419677",
"0.5401871",
"0.5371818",
"0.5371774... | 0.6413181 | 0 |
self.term, self.gender and self.number parsed correctly from Wiki format | def testParser(self):
for wikiline, termlang, thisterm, termgender, termnumber in \
self.knownParserValues:
aterm = term.Term(termlang, '', wikiline=wikiline)
self.assertEqual(aterm.getTerm(), thisterm)
self.assertEqual(aterm.getGender(), termgender)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_entity(self, term):\n pass",
"def _parse_mw(self, line):\n # Parse the line\n # pylint: disable=W0612\n if self.lang == ENGLISH:\n # From the README:\n # The emw.cd file contains the following fields:\n # 1. IdNum\n # 2. Word... | [
"0.5894961",
"0.56694114",
"0.56184226",
"0.5518839",
"0.5471428",
"0.5400701",
"0.53893095",
"0.52972084",
"0.5262395",
"0.5254933",
"0.5240294",
"0.52389646",
"0.5211205",
"0.52041274",
"0.5142659",
"0.5133027",
"0.512932",
"0.51003706",
"0.51003706",
"0.5087278",
"0.508297... | 0.6180837 | 0 |
Query to count all rows is reasonable. | def test_count_all_rows_query(self):
mock_connector = MagicMock()
database = Database()
database.connect(connector_impl=mock_connector)
connection = mock_connector.connect()
cursor = connection.cursor()
cursor.__iter__.return_value = [(123,)]
num = database.count_all_rows()
self.asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_rows(self):\n with self.conn:\n return len(self.select_all_rows())",
"async def count_rows(self, query: str, args: Optional[Iterable]=None) -> float:\n res = await self.fetch_all(query, args)\n return len(res)",
"def count(self):\n return self.query.count(with_limit... | [
"0.7627017",
"0.7416478",
"0.7366328",
"0.72437716",
"0.7188708",
"0.7025157",
"0.69626915",
"0.68946433",
"0.6866815",
"0.6857725",
"0.6837531",
"0.67531246",
"0.67092586",
"0.6696347",
"0.6684697",
"0.6655666",
"0.6645447",
"0.6617978",
"0.65894985",
"0.6576684",
"0.6555207... | 0.7575799 | 1 |
Query to insert/update a row is reasonable. | def test_insert_or_update_query(self):
row = (
'source',
'signal',
'time_type',
'geo_type',
'time_value',
'geo_value',
'value',
'stderr',
'sample_size',
)
mock_connector = MagicMock()
database = Database()
database.connect(connector_impl=mock_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_or_update(self, table, connection, row):\n\n # find line, if it exist\n dbrow = self.find(connection, table, row)\n\n # TODO XXX use actual database function instead of this stupid thing\n now = datetime.datetime.now()\n\n column_names = table.columns.keys()\n\n ... | [
"0.76564175",
"0.66174394",
"0.64279103",
"0.64259017",
"0.6400733",
"0.6382513",
"0.63072944",
"0.6271968",
"0.62710655",
"0.6250457",
"0.62496334",
"0.62363833",
"0.62318635",
"0.6199405",
"0.6178845",
"0.61777246",
"0.61772615",
"0.6159623",
"0.61551017",
"0.6107208",
"0.6... | 0.7286461 | 1 |
Query to get rows with stale `direction` is reasonable. | def test_get_rows_with_stale_direction_query(self):
mock_connector = MagicMock()
database = Database()
database.connect(connector_impl=mock_connector)
result = database.get_rows_with_stale_direction()
self.assertIsInstance(result, list)
connection = mock_connector.connect()
cursor = conn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_rows_to_compute_direction_query(self):\n\n args = (\n 'source',\n 'signal',\n 'geo_type',\n 'time_value',\n 'geo_value',\n )\n mock_connector = MagicMock()\n database = Database()\n database.connect(connector_impl=mock_connector)\n\n result = database.get_row... | [
"0.5330039",
"0.51772547",
"0.5100459",
"0.48738676",
"0.48217666",
"0.47217762",
"0.46997115",
"0.46946546",
"0.46683863",
"0.46158323",
"0.45928907",
"0.45430845",
"0.45256373",
"0.45004687",
"0.44779253",
"0.44767517",
"0.44638798",
"0.4460516",
"0.4448653",
"0.4410873",
"... | 0.6514791 | 0 |
Query to get rows needed to compute `direction` is reasonable. | def test_get_rows_to_compute_direction_query(self):
args = (
'source',
'signal',
'geo_type',
'time_value',
'geo_value',
)
mock_connector = MagicMock()
database = Database()
database.connect(connector_impl=mock_connector)
result = database.get_rows_to_compute_direc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_direction_matrix(self) -> int:",
"def fetch_direction(file_list, column_name):\r\n start_time_aggrigating_vector_components = time.time()\r\n res_dir_x_list, res_dir_y_list, mag, direction = draw_dirs2(file_list, column_name)\r\n all_in_x = np.zeros_like(mag[0])\r\n all_in_y = np.zeros_like(m... | [
"0.5975554",
"0.57898206",
"0.5425772",
"0.5416021",
"0.5339897",
"0.5261038",
"0.519674",
"0.5189174",
"0.51775736",
"0.51775736",
"0.51775736",
"0.51775736",
"0.51775736",
"0.51775736",
"0.51775736",
"0.5123078",
"0.51217896",
"0.5089011",
"0.50849056",
"0.50772333",
"0.506... | 0.58570343 | 1 |
Query to update a row's `direction` is reasonable. | def test_update_direction_query(self):
args = (
'source',
'signal',
'time_type',
'geo_type',
'time_value',
'geo_value',
'direction',
)
mock_connector = MagicMock()
database = Database()
database.connect(connector_impl=mock_connector)
database.update_di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_player_direction(self,direction):\n pass",
"def update_direction(self, move : np.ndarray, direction: np.ndarray):\r\n pos = move.copy()\r\n \r\n\r\n pos += direction\r\n while(self.in_board(pos)):\r\n if self.board[pos[0],pos[1]] == self.turn:\r\n ... | [
"0.6100122",
"0.5839325",
"0.5755454",
"0.5448772",
"0.5359819",
"0.5185797",
"0.51543975",
"0.5129638",
"0.51227224",
"0.5081128",
"0.50525045",
"0.499222",
"0.49913445",
"0.4981526",
"0.49705264",
"0.49473912",
"0.4944359",
"0.4928729",
"0.49278006",
"0.49232808",
"0.489834... | 0.65735036 | 0 |
Upload the trigger to demisto_client | def upload(self, client: demisto_client):
# return client.import_triggers(file=self.path)
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_command_trigger_webhook_post(self):\n pass",
"def webhook_upload(user, application, complete_path, init_es, tool, scan_name, user_host, to_name,hook_log):\n hook_log = WebhookLog.objects.get(id=hook_log)\n hook_log.file_upload_event = True\n hook_log.file_upload_datetime = timezone.now()... | [
"0.6085336",
"0.6010173",
"0.5882553",
"0.57079124",
"0.56743056",
"0.56453544",
"0.56365526",
"0.5575185",
"0.5550827",
"0.55411583",
"0.55089366",
"0.5488863",
"0.5441688",
"0.54115045",
"0.5375873",
"0.5364103",
"0.53598547",
"0.5352826",
"0.5338035",
"0.5316052",
"0.53024... | 0.80932665 | 0 |
Adds a tip to the TipableVMobject instance, recognising that the endpoints might need to be switched if it's a 'starting tip' or not. | def add_tip(self, tip_length=None, at_start=False):
tip = self.create_tip(tip_length, at_start)
self.reset_endpoints_based_on_tip(tip, at_start)
self.asign_tip_attr(tip, at_start)
self.add(tip)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_tip(self, tip_length=None, at_start=False):\n tip = self.get_unpositioned_tip(tip_length)\n self.position_tip(tip, at_start)\n return tip",
"def addToolTip(self, tip: str):\n self.setToolTip(tip)\n self.setFont(qtawesome.font('fa', 13))\n self.setText(self.tex... | [
"0.577072",
"0.57233423",
"0.56006104",
"0.5510364",
"0.5394609",
"0.52906525",
"0.51290935",
"0.5120605",
"0.5050957",
"0.503774",
"0.50003445",
"0.497575",
"0.49572206",
"0.49561787",
"0.49531072",
"0.49295446",
"0.491895",
"0.4917904",
"0.49155957",
"0.49069536",
"0.487378... | 0.70821476 | 0 |
Stylises the tip, positions it spacially, and returns the newly instantiated tip to the caller. | def create_tip(self, tip_length=None, at_start=False):
tip = self.get_unpositioned_tip(tip_length)
self.position_tip(tip, at_start)
return tip | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_unpositioned_tip(self, tip_length=None):\n if tip_length is None:\n tip_length = self.get_default_tip_length()\n color = self.get_color()\n style = {\n \"fill_color\": color,\n \"stroke_color\": color\n }\n style.update(self.tip_style)\n ... | [
"0.6056852",
"0.6019949",
"0.5465432",
"0.54215854",
"0.5221702",
"0.5127146",
"0.51173925",
"0.5049858",
"0.5008842",
"0.49951535",
"0.4990454",
"0.4975458",
"0.49079397",
"0.49059188",
"0.4904365",
"0.4904365",
"0.4904365",
"0.49027798",
"0.4886907",
"0.48354802",
"0.482837... | 0.7228701 | 0 |
Returns a VGroup (collection of VMobjects) containing the TipableVMObject instance's tips. | def get_tips(self):
result = VGroup()
if hasattr(self, "tip"):
result.add(self.tip)
if hasattr(self, "start_tip"):
result.add(self.start_tip)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gettiposdisponiveis() -> List[str]:\r\n\r\n return [\"Layer\", \"Marked\", \"Start\", \"End\", \"Style\", \"Name\", \"MarginL\", \"MarginR\", \"MarginV\", \"Effect\", \"Text\"]",
"def get_tips(self, padding=False):\n tips = {'tips': [{'x': int(v[0]), 'y': int(v[1])}\n for v in self._... | [
"0.549341",
"0.54353267",
"0.54347295",
"0.51674384",
"0.5108722",
"0.5085301",
"0.505671",
"0.5008012",
"0.49594852",
"0.49506715",
"0.49342513",
"0.4854558",
"0.4826706",
"0.48018616",
"0.46965593",
"0.46308154",
"0.46291572",
"0.4620837",
"0.46160424",
"0.46116495",
"0.460... | 0.805735 | 0 |
Returns the TipableVMobject instance's (first) tip, otherwise throws an exception. | def get_tip(self):
tips = self.get_tips()
if len(tips) == 0:
raise Exception("tip not found")
else:
return tips[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTip(self):\n return None",
"def __TipToUseFor(self, vial):\n if not vial.getLabel() in Instrument.__transportTipUsageMap.keys():\n raise InstrumentError (\"%s vial has no designated tip!\" % (vial.getLabel()))\n return (vial.getSector(), Instrument.__transportTipUsageMap[vi... | [
"0.6145511",
"0.5751582",
"0.5692942",
"0.54714465",
"0.5439622",
"0.5321403",
"0.5022782",
"0.4965701",
"0.4929289",
"0.49054495",
"0.48894674",
"0.48825702",
"0.48694706",
"0.4868604",
"0.4860638",
"0.4836213",
"0.4814093",
"0.4800698",
"0.47787264",
"0.47769305",
"0.476783... | 0.741154 | 0 |
Add a dictionary of telemetry to the input queue. | def add(self, telemetry):
# Check the telemetry dictionary contains the required fields.
for _field in self.REQUIRED_FIELDS:
if _field not in telemetry:
self.log_error("JSON object missing required field %s" % _field)
return
# Add it to the queue if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, telemetry):\n # Check the telemetry dictionary contains the required fields.\n for _field in self.REQUIRED_FIELDS:\n if _field not in telemetry:\n self.log_error(\"JSON object missing required field %s\" % _field)\n return\n\n # Add it to ... | [
"0.79048663",
"0.60377306",
"0.60186136",
"0.5915719",
"0.5755671",
"0.574349",
"0.5703809",
"0.56934947",
"0.5691415",
"0.5672941",
"0.5580649",
"0.5578332",
"0.55634093",
"0.5549206",
"0.5479271",
"0.5477963",
"0.5430261",
"0.5374483",
"0.5373574",
"0.531905",
"0.530469",
... | 0.79055864 | 0 |
Process data from the input queue, and write telemetry to log files. | def process_queue(self):
self.log_info("Started Telemetry Logger Thread.")
while self.input_processing_running:
# Process everything in the queue.
while self.input_queue.qsize() > 0:
try:
_telem = self.input_queue.get_nowait()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_queue(self):\n while self.input_processing_running:\n\n # Process everything in the queue.\n while self.input_queue.qsize() > 0:\n try:\n _telem = self.input_queue.get_nowait()\n self.process_telemetry(_telem)\n\n ... | [
"0.7224707",
"0.6353192",
"0.62871027",
"0.6264066",
"0.6239567",
"0.6054869",
"0.6022689",
"0.5990858",
"0.596374",
"0.59428614",
"0.57359576",
"0.57206047",
"0.5679634",
"0.5671539",
"0.5623765",
"0.5613288",
"0.56038845",
"0.558273",
"0.5579886",
"0.55674654",
"0.5556673",... | 0.82298416 | 0 |
Convert a telemetry dictionary to a CSV string. | def telemetry_to_string(self, telemetry):
_log_line = "%s,%s,%d,%.5f,%.5f,%.1f,%.1f,%s,%.3f\n" % (
telemetry['datetime'],
telemetry['id'],
telemetry['frame'],
telemetry['lat'],
telemetry['lon'],
telemetry['alt'],
telemetry['temp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traces_to_csv(filename, dictionary):\n \n headings = []\n for key_string in list(dictionary.keys()):\n headings.append(key_string)\n \n # Use first element of dict to determine array length\n length = len(dictionary[headings[0]])\n filename += '_traces'\n with open(filename + '.c... | [
"0.6931288",
"0.6853061",
"0.664821",
"0.6543472",
"0.65304273",
"0.6495118",
"0.64411235",
"0.6404622",
"0.6308096",
"0.62764317",
"0.62746584",
"0.6146629",
"0.599945",
"0.5959358",
"0.59449553",
"0.591635",
"0.5910029",
"0.59084666",
"0.59015906",
"0.58516014",
"0.5850159"... | 0.6905581 | 1 |
Write a packet of telemetry to a log file. | def write_telemetry(self, telemetry):
_id = telemetry['id']
_type = telemetry['type']
# If there is no log open for the current ID check to see if there is an existing (closed) log file, and open it.
if _id not in self.open_logs:
_search_string = os.path.join(self.log_direc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeToLogFile(self, event):\n outPutStr = '{:013}'.format(0)\n logOutPutStr = outPutStr + '\\t' + '{:.2f}'.format (time ()) + '\\t' + event + '\\t' + datetime.fromtimestamp (int (time())).isoformat (' ')\n printOutPutStr = outPutStr + '\\t' + datetime.fromtimestamp (int (time())).isofor... | [
"0.62904984",
"0.61438245",
"0.6044253",
"0.60187745",
"0.6016599",
"0.6005454",
"0.59394264",
"0.5924721",
"0.59105086",
"0.5889823",
"0.5859688",
"0.5849721",
"0.5800581",
"0.57630736",
"0.5734948",
"0.5717049",
"0.56980664",
"0.56645256",
"0.5657077",
"0.5591958",
"0.55677... | 0.6711523 | 0 |
Close any open logs that have not had telemetry added in X seconds. | def cleanup_logs(self):
_now = time.time()
for _id in self.open_logs.keys():
try:
if _now > (self.open_logs[_id]['last_time'] + self.FILE_ACTIVITY_TIMEOUT):
# Flush and close the log file, and pop this element from the dictionary.
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unload(self):\n for f in self.logs.values():\n f.close()",
"def close(self):\n for key, logger in self._loggers.items():\n logger.close()",
"def close(self):\n for logger in self._loggers:\n logger.close()",
"def close_idle(self):\n now = time.... | [
"0.6893975",
"0.6622721",
"0.65859586",
"0.62827563",
"0.62822205",
"0.6275291",
"0.625936",
"0.6167051",
"0.61455953",
"0.61455953",
"0.6102678",
"0.6073764",
"0.60718066",
"0.60292953",
"0.60044223",
"0.5995624",
"0.5983772",
"0.5983564",
"0.59717757",
"0.5961879",
"0.59535... | 0.7794429 | 0 |
Average weights from all iterations. | def average_weights(self):
for feat, weight in self.weights.items():
total = self._totals[feat]
total += (self.i - self._tstamps[feat]) * weight
averaged = total / float(self.i)
self.weights[feat] = averaged
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_weights(w):\n w_avg = copy.deepcopy(w[0])\n for key in w_avg.keys():\n for i in range(1, len(w)):\n w_avg[key] += w[i][key]\n w_avg[key] = torch.div(w_avg[key], len(w))\n return w_avg",
"def average_weights(w):\n w_avg = copy.deepcopy(w[0])\n for key in w_avg.k... | [
"0.7645877",
"0.7645877",
"0.7645877",
"0.7287163",
"0.6916528",
"0.6883835",
"0.6876188",
"0.68008715",
"0.6799388",
"0.67378736",
"0.6708711",
"0.6663066",
"0.6648263",
"0.6628374",
"0.6612669",
"0.6556008",
"0.6423112",
"0.6373538",
"0.6367814",
"0.63559115",
"0.6329041",
... | 0.81786764 | 0 |
Return a DataFrame of factor vectors for this type factor. | def get_factors(self, factor_encoding="one-hot"):
if not self.levels:
df = pd.DataFrame(0, index=range(self.number_elements), columns=[self.type_value])
df.loc[list(self.direct_indices.keys()), [self.type_value]] = 1
return df
levels = list(self.levels.keys()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_df(self):\r\n return pd.DataFrame(self.vectors).set_index(self.words)",
"def to_vdf(self):\n\t\treturn (vDataFrame(self.name, self.cursor))",
"def factorsWith(self,v,copy=True):\n Lv = self.L.getrow(v).tocoo();\n factors = [Factor([Var(int(v),2)],[-th,th]).exp() for th in [self.h[v]] if sel... | [
"0.64751077",
"0.6063727",
"0.5958115",
"0.5932507",
"0.5892115",
"0.58247876",
"0.58050406",
"0.57995164",
"0.579368",
"0.574358",
"0.56963384",
"0.5660653",
"0.5642072",
"0.5619792",
"0.5606311",
"0.5589297",
"0.5589297",
"0.5586548",
"0.5575213",
"0.5569275",
"0.5559799",
... | 0.70371807 | 0 |
Count the number of events and multiples in a list. | def _count_level_events(count_list):
if not len(count_list):
return 0, 0, None
number_events = 0
number_multiple = 0
max_multiple = count_list[0]
for index, count in enumerate(count_list):
if count_list[index] > 0:
number_events = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_evens(list):\n pass",
"def count(*, list : Union[List[Any], ConduitVariable]) -> int:\n return len(list)",
"def count(some_list):\n return len(some_list)",
"def count_element (input_list):\n counter = 0\n for dummy_i in input_list:\n counter +=1\n return counter",
"de... | [
"0.72312695",
"0.6910348",
"0.6869172",
"0.6822377",
"0.6726759",
"0.67264605",
"0.6698752",
"0.6541436",
"0.647482",
"0.6471752",
"0.6451944",
"0.644694",
"0.6410734",
"0.6410734",
"0.6373402",
"0.63511115",
"0.63427484",
"0.63278735",
"0.631273",
"0.6203676",
"0.61676127",
... | 0.74355847 | 0 |
Initialises a new object with given word inside a container. | def __init__(self, scene: 'Scene', word: str, container=None, attrs=None) -> None:
if container:
super(Object, self).__init__(scene, container=container)
else:
super(Object, self).__init__(scene)
self.word = word
if attrs:
self.attributes = attrs
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_word(cls, word):\n return cls(word=word.word, definition=word.definition)",
"def __init__(self, word, items=[]):\n if items:\n dict.__init__(self, items)\n self.word = word",
"def __init__(self, sentence, string, lemma=None, type=None, index=0):\n if not isinstan... | [
"0.6943347",
"0.68540335",
"0.6424625",
"0.63369876",
"0.6330441",
"0.6289518",
"0.6260407",
"0.6227002",
"0.61848086",
"0.60501987",
"0.5933885",
"0.5892958",
"0.5854336",
"0.58512056",
"0.58510554",
"0.5838484",
"0.58349663",
"0.58317196",
"0.583125",
"0.5827937",
"0.582789... | 0.7053014 | 0 |
Parse the bites.csv file (= stats variable passed in), see example output in the Bite description. Return a list of Bite IDs (int or str values are fine) of the N most complex Bites. | def get_most_complex_bites(N=10, stats=stats):
with open(stats, encoding="utf-8-sig") as f:
bites = list(csv.DictReader(f, delimiter=';'))
pprint(bites)
bites.sort(key=_parse_difficulty, reverse=True)
return [bites[i]['Bite'] for i in range(N)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_most_complex_bites(N=10, stats=stats):\n def get_bite_id(s):\n return s[5:s.index(\".\")]\n\n with open(stats, encoding=\"utf-8-sig\") as csv_file:\n reader = csv.DictReader(csv_file, delimiter=\";\")\n filtered_list = [bite for bite in reader if bite[\"Difficulty\"] != \"None\"]... | [
"0.73635286",
"0.730562",
"0.5457074",
"0.5412959",
"0.52037644",
"0.52037644",
"0.51832443",
"0.5182175",
"0.508715",
"0.5061811",
"0.50590515",
"0.50497925",
"0.49228895",
"0.49039412",
"0.4903011",
"0.48812973",
"0.48760438",
"0.48643646",
"0.48386773",
"0.4821559",
"0.481... | 0.7472916 | 0 |
Create an invoice using default currency and language | def test_use_default_language_and_currency(self):
self._invoice_manager.create(
client_id = self._test_client.key().id(),
invoice_no = '2011/44',
invoice_date = date.today(),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_invoice(self):\n sales_tax = 0.06\n item_sum = 0\n inv = f'Invoice#: {self.invoice_id}\\n'\n for key, value in self.items_with_price.items():\n item_sum += value\n inv += f'{key}.....${value:.2f}\\n'\n\n tax = item_sum * sales_tax\n inv += ... | [
"0.70681363",
"0.6681925",
"0.66724634",
"0.6480485",
"0.6386146",
"0.6375932",
"0.6286728",
"0.6255604",
"0.6160744",
"0.6064679",
"0.6054783",
"0.6024481",
"0.60135674",
"0.6011001",
"0.5977337",
"0.5975371",
"0.5963588",
"0.59228784",
"0.59067136",
"0.5868332",
"0.5866136"... | 0.69670916 | 1 |
Create an invoice specifying a different language than customer default | def test_set_custom_language(self):
self._invoice_manager.create(
client_id = self._test_client.key().id(),
invoice_no = '2011/26',
invoice_date = date.today(),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_use_default_language_and_currency(self):\r\n self._invoice_manager.create(\r\n client_id = self._test_client.key().id(), \r\n invoice_no = '2011/44', \r\n invoice_date = date.today(), \r\n ... | [
"0.7071627",
"0.5753003",
"0.57508594",
"0.56759703",
"0.56743413",
"0.56259704",
"0.5565574",
"0.5483609",
"0.5432262",
"0.5425274",
"0.54212373",
"0.5395123",
"0.53446835",
"0.53423697",
"0.53159",
"0.53132063",
"0.53106153",
"0.53025985",
"0.5290682",
"0.5273233",
"0.52706... | 0.7058566 | 1 |
Create an invoice specifying a different currency than customer default | def test_set_custom_currency(self):
self._invoice_manager.create(
client_id = self._test_client.key().id(),
currency_id = self._test_currency.key().id(),
invoice_no = '2011/26',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDefaultCurrency():",
"def create_invoice(self):\n sales_tax = 0.06\n item_sum = 0\n inv = f'Invoice#: {self.invoice_id}\\n'\n for key, value in self.items_with_price.items():\n item_sum += value\n inv += f'{key}.....${value:.2f}\\n'\n\n tax = item_s... | [
"0.6430806",
"0.6353556",
"0.6336654",
"0.62089866",
"0.6097629",
"0.59662205",
"0.58765984",
"0.58744097",
"0.5860895",
"0.57814944",
"0.57814944",
"0.5780651",
"0.57290375",
"0.5727345",
"0.56984854",
"0.5676626",
"0.56723225",
"0.56287116",
"0.5603652",
"0.55745834",
"0.55... | 0.69610304 | 0 |
Add an invoice item to the current invoice and update totals | def _add_invoice_item(self, description, quantity, unit_price):
self._invoice_manager.add_invoice_item(description, quantity, unit_price)
self._sub_total += quantity * unit_price
self._total += quantity * unit_price | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(self, item):\n item_exists = self.get_item(item.id)\n\n if item_exists:\n item_exists._increment_quantity(item.quantity)\n else:\n self.items.append(item)",
"def add_to_inv(self, item):\n for obj in self.inv:\n if obj.name == item.name:\n ... | [
"0.69356513",
"0.69239235",
"0.6733385",
"0.6706951",
"0.66711944",
"0.65880275",
"0.6570466",
"0.64419645",
"0.6405202",
"0.6337143",
"0.6334653",
"0.63073",
"0.62725693",
"0.62651527",
"0.62594026",
"0.6257524",
"0.6244216",
"0.62118423",
"0.6171449",
"0.6101527",
"0.608875... | 0.7693839 | 0 |
Loads the words from topic file into a dictionary and returns that. | def load_topic_words(topic_file):
f = open(topic_file, 'r')
# Get word/score combinations into a list
lines = f.readlines()
# File is no longer needed
f.close()
topic_dict = {}
# Split all the lines, convert to tuples and then put it into the dict
for (word, score) in map(tuple, map... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_wordlist(filename):\n # YOUR CODE HERE\n words = {}\n f = open(filename, 'rU')\n text = f.read()\n text = text.split('\\n')\n for line in text:\n words[line] = 1\n f.close()\n return words",
"def word_dict():\n fin = open('words.txt')\n w_dict = {}\n for line in f... | [
"0.71240246",
"0.70358014",
"0.6993878",
"0.6961244",
"0.6945208",
"0.69236803",
"0.6913186",
"0.6797306",
"0.67938143",
"0.67758304",
"0.674296",
"0.67393655",
"0.66789144",
"0.66478366",
"0.66035426",
"0.65942776",
"0.6590566",
"0.65897554",
"0.6587534",
"0.65834767",
"0.65... | 0.82899475 | 0 |
Gets the n top scored words from topic_words_dict. | def get_top_n_words(topic_words_dict, n):
score_wordlist = topic_words_dict.items()
score_wordlist.sort(key=lambda x: x[1], reverse=True)
return [word for (word,score) in score_wordlist[:n]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top_n_words(topic_dict, n=5):\n top_words = []\n for num, data in topic_dict.items():\n sorted_words = {k: v for k, v in sorted(data['words'].items(),\n key=lambda x: x[1],\n reverse=True\n ... | [
"0.8106335",
"0.79211116",
"0.7804142",
"0.77737975",
"0.7696975",
"0.7691545",
"0.76559055",
"0.76447916",
"0.7511303",
"0.7477074",
"0.71667165",
"0.71047443",
"0.71033424",
"0.7084527",
"0.7046334",
"0.70240855",
"0.7004317",
"0.69901013",
"0.6987456",
"0.6985063",
"0.6960... | 0.858172 | 0 |
Filters the top n unique words from the word list, sorted by their topic words score. | def filter_top_n_words(topic_words_dict, n, word_list):
# First remove any redundant words in word_list
words = set(word_list)
# Now get the intersection with words, that appear as keys in the dict
topic_words_intersect = set(topic_words_dict.keys()).intersection(words)
# Now get the words with thei... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top_n_words(topic_words_dict, n):\n score_wordlist = topic_words_dict.items()\n score_wordlist.sort(key=lambda x: x[1], reverse=True)\n return [word for (word,score) in score_wordlist[:n]]",
"def get_top_n_words(word_list, n):\n\tfreqs = get_word_frequencies(word_list)\n\tfreq_words = sorted(fre... | [
"0.78475636",
"0.76823705",
"0.76783645",
"0.7641622",
"0.759833",
"0.7572459",
"0.7565104",
"0.75533044",
"0.7499505",
"0.74300605",
"0.74222994",
"0.72614247",
"0.6943483",
"0.68170434",
"0.67947507",
"0.6756186",
"0.6747678",
"0.6721182",
"0.6683026",
"0.66444707",
"0.6609... | 0.8395242 | 0 |
collection is a directory containing textfiles. The first n of those text files will be loaded as sentences. | def load_collection_sentences(collection, n):
files = os.listdir(collection)
files_sentences = []
for f in files:
files_sentences.append(load_file_sentences(collection + "/" + f,f))
n -= 1
if n == 0:
break
return files_sentences | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data_sentences(dirname):\n sentence_list = []\n for fname in os.listdir(dirname):\n with open(os.path.join(dirname, fname)) as file:\n #sentence_list.append(gensim.models.word2vec.LineSentence(file))\n sentence_list.append(file)\n return sentence_list",
"def read_in... | [
"0.63905025",
"0.63544846",
"0.63502246",
"0.63078845",
"0.62785506",
"0.61905974",
"0.61603606",
"0.5869132",
"0.5830292",
"0.57335895",
"0.57322437",
"0.5696989",
"0.56887877",
"0.5675542",
"0.56598073",
"0.56473756",
"0.56295043",
"0.56049615",
"0.5589258",
"0.55711365",
"... | 0.8466149 | 0 |
Returns the dependency parse of the given sentence. | def dependency_parse_sentence(sentence):
p = Parser()
deps = p.parseToStanfordDependencies(sentence)
# Flatten and organize in the required format
return [(r, gov.text, dep.text) for r, gov, dep in deps.dependencies] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_for_lm(sentence):\n return sentence.text",
"def parse(self, sentence):\n if self.cnf is None:\n self.compute_cnf()\n cnf_tree = self.cnf.cky_parse(sentence)\n original_tree = self.get_original_tree(cnf_tree)\n return original_tree",
"def stanford_parse(senten... | [
"0.65250015",
"0.6136723",
"0.6067007",
"0.58751744",
"0.5771676",
"0.5657536",
"0.5648869",
"0.55972624",
"0.5564531",
"0.5503623",
"0.5476823",
"0.54661816",
"0.5431226",
"0.53829974",
"0.53559285",
"0.5352021",
"0.5332381",
"0.5330422",
"0.53206635",
"0.5292753",
"0.527057... | 0.7475272 | 0 |
Returns a list of unique words which that appear together with word in the dependency_list. | def get_linked_words(dependency_list, word):
words = set() # Unique words, so first a set
for (rel, gov, dep) in dependency_list:
if gov == word:
words.add(dep)
elif dep == word:
words.add(gov)
return list(words) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wordset(word_list):\n\n unique_words = []\n\n for word in word_list:\n\n if word not in unique_words:\n unique_words.append(word)\n\n unique_words.sort()\n\n return unique_words",
"def known(words: list[str]) -> list[str]:\n return [z for z in list(set(words)) if z in... | [
"0.7397748",
"0.7332242",
"0.6955943",
"0.68045413",
"0.6680356",
"0.6583253",
"0.6573687",
"0.65147394",
"0.6503563",
"0.6490802",
"0.6450996",
"0.6449669",
"0.6428956",
"0.64201736",
"0.6405528",
"0.6399228",
"0.6366292",
"0.6344379",
"0.6321502",
"0.6304007",
"0.6293037",
... | 0.84802175 | 0 |
Creates a feature space for a collection. | def create_collection_feature_space(collection_path):
sentences = load_collection_sentences(collection_path, __fape_files_to_load)
return create_feature_space(reduce(lambda x,y: x[0]+y[0], sentences)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_collection(collection):\n return db[collection]",
"def create_feature_set(es_host: str, model_name: str) -> None:\n features_path = PATH / f'{model_name}' / 'features'\n feature_set = {\n 'featureset': {\n 'name': model_name,\n 'features': [process_feature_file(st... | [
"0.62077636",
"0.60677195",
"0.59403694",
"0.5913387",
"0.5871601",
"0.58175534",
"0.56797963",
"0.5639592",
"0.5618073",
"0.55651855",
"0.5545924",
"0.5499076",
"0.54756826",
"0.54747015",
"0.54698896",
"0.54566467",
"0.54304636",
"0.53826386",
"0.5378772",
"0.53718174",
"0.... | 0.78218096 | 0 |
vectorize from solution to hw1. Creates a vector for the given sentence in accordance to the given feature space. | def vectorize(vector_space, sentence):
vector = [0] * len(vector_space)
for word in sentence[0].split():
vector[vector_space[word]] = 1
return vector | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def review_to_vec(words, model, num_features , index2word_set):\n \n feature_vec = np.zeros((num_features), dtype=\"float32\")\n word_count = 0\n \n \n \n for word in words:\n if word in index2word_set: \n word_count += 1\n feature_vec += model[word]\n\n if word... | [
"0.7167462",
"0.711601",
"0.6921717",
"0.691232",
"0.68577504",
"0.6759357",
"0.67189",
"0.6510275",
"0.6496161",
"0.6467595",
"0.6440803",
"0.6375761",
"0.6344278",
"0.62959903",
"0.62770647",
"0.62246174",
"0.62212145",
"0.6216949",
"0.62104607",
"0.6208797",
"0.61744964",
... | 0.72096866 | 0 |
Vectorizes an entire collection. | def vectorize_collection(feature_space, collection_path):
sentences = load_collection_sentences(collection_path, __fape_files_to_load)
# concatenate all the string lists
sentences = reduce(lambda x,y: x[0]+y[0], sentences)
return zip(sentences, map(vectorize, [feature_space]*len(sentences),\
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vectorize(self):\n return vectorize(self)",
"def normalize(self):\n self._vectors = [vector.normalized() for vector in self._vectors]",
"def AsVector(self) -> BaseVector:",
"def vectorize(items, cls=None):\n if cls is None:\n cls = type(items[0])\n res = r.std.vector(cls)()\n ... | [
"0.7024608",
"0.6474128",
"0.62290186",
"0.62209076",
"0.6193116",
"0.61428595",
"0.61237097",
"0.6084418",
"0.6016029",
"0.60159826",
"0.59674233",
"0.5906563",
"0.5757021",
"0.5696986",
"0.56942457",
"0.5682722",
"0.5681969",
"0.56319535",
"0.5628052",
"0.5621202",
"0.56044... | 0.6553656 | 1 |
Computes centrality of a given vector regarding the given list of vectors and using the given similarity metric. | def centrality(similarity, vector, vectors):
return 1.0/len(vectors)*sum([similarity(vector,y) for y in vectors\
if y != vector]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def similarity_vec(self, vec1: numpy.ndarray, vec2: numpy.ndarray, metric='cosine') -> float:\n if numpy.count_nonzero(vec1) == 0 or numpy.count_nonzero(vec2) == 0:\n if metric == 'cosine':\n return 0.\n else:\n return 0.\n\n vec1 = vec1.reshape((1,... | [
"0.72945714",
"0.7072555",
"0.67674327",
"0.67392194",
"0.67035276",
"0.66957986",
"0.6677136",
"0.66584283",
"0.6637581",
"0.6600296",
"0.644426",
"0.6418538",
"0.639941",
"0.63717186",
"0.63677496",
"0.63481575",
"0.63465947",
"0.63196737",
"0.63120115",
"0.6299113",
"0.629... | 0.8485807 | 0 |
Ranks the sentences from the collection in collection_path by their centrality. | def rank_by_centrality(collection_path, sim_func):
# First get the feature space and vectorize the collection
fs = create_collection_feature_space(collection_path)
vectorized = vectorize_collection(fs, collection_path)
all_vectors = [vector for (sent, vector) in vectorized]
# Compute all centrality ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_ideal(self, gens):",
"def organize():\n\n corpusNames = []\n for keyword in range(1, 10):\n keyword = str(keyword)\n corpusNames.append(organize_files_by_regex(keyword))\n # Calls the helper function 'organize_files_by_regex' for each participant number keyword\n # App... | [
"0.53972936",
"0.51999867",
"0.49404708",
"0.4881049",
"0.4788437",
"0.47789904",
"0.47210398",
"0.46956",
"0.46928346",
"0.4688245",
"0.467457",
"0.46562147",
"0.4646832",
"0.46406034",
"0.4612456",
"0.46117538",
"0.46052045",
"0.45960557",
"0.45836714",
"0.45634475",
"0.456... | 0.55398077 | 0 |
Given a sentence and a list of topic words, returns the number of topic words in the sentence. | def topic_weight(sentence, topic_words):
topic_words = set(topic_words) # slight speedup, lookup in set is faster
topic_weight = 0
for word in sentence.split():
if word in topic_words:
topic_weight += 1
return topic_weight | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_words(sent):\n words = word_tokenize(sent)\n return len(words)",
"def count_words(sentence):\n\tblob = tb.TextBlob(sentence.decode('utf-8','ignore'))\n\tword_list = [w for w in blob.words if '\\'' not in w]\n\treturn len(word_list)",
"def count_words(text, words):\n count = 0\n for word i... | [
"0.7414087",
"0.7379703",
"0.7250825",
"0.71797293",
"0.70543844",
"0.7038951",
"0.7038228",
"0.6985188",
"0.6980322",
"0.69720775",
"0.6968148",
"0.69617456",
"0.69166696",
"0.68925667",
"0.68560517",
"0.6786804",
"0.6775031",
"0.672444",
"0.67102593",
"0.6679824",
"0.667249... | 0.77707624 | 0 |
Ranks the collection in collection_path by topic weight, using the topic words found in topic_file. | def rank_by_tweight(collection_path, topic_file):
# First get the sentences and the topic words
ts = load_topic_words(topic_file).keys()
sentences = load_collection_sentences(collection_path, __fape_files_to_load)
# reduce to 1-dimensional list of tuples (sentence, filename)
sentences = reduce(lambd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combined_ranking(collection_path, topic_file, sim_func):\n cent_rank = rank_by_centrality(collection_path, sim_func)\n tweight_rank = rank_by_tweight(collection_path, topic_file)\n # Normalize topic weights to have Values in [0,1]\n max_weight = max([w for (x,w) in tweight_rank])\n tweight_rank ... | [
"0.54155016",
"0.51857126",
"0.51600516",
"0.5120221",
"0.5112809",
"0.5080428",
"0.5051803",
"0.5007921",
"0.5004605",
"0.49770793",
"0.49573356",
"0.49171788",
"0.49147108",
"0.49144885",
"0.48594907",
"0.48516676",
"0.484289",
"0.48361325",
"0.48044315",
"0.4801349",
"0.47... | 0.6932714 | 0 |
Combines centrality and topic weight ranking into one. | def combined_ranking(collection_path, topic_file, sim_func):
cent_rank = rank_by_centrality(collection_path, sim_func)
tweight_rank = rank_by_tweight(collection_path, topic_file)
# Normalize topic weights to have Values in [0,1]
max_weight = max([w for (x,w) in tweight_rank])
tweight_rank = [(x,(flo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_prop_and_freq_scores(\n self, network_prop_scores, network_freq_scores, raw_or_rank\n ):\n\n for index, network_score_dict in enumerate([network_prop_scores, network_freq_scores]):\n # Only need to order propensities if converting to probability\n # scores via the... | [
"0.61443216",
"0.6115722",
"0.59341866",
"0.58569634",
"0.57908785",
"0.5622314",
"0.5620723",
"0.56037676",
"0.560004",
"0.5583877",
"0.5583751",
"0.5509328",
"0.55019414",
"0.54943794",
"0.5463744",
"0.53794634",
"0.53605205",
"0.5341432",
"0.53403914",
"0.5339888",
"0.5311... | 0.6482419 | 0 |
Returns a summary of approximately summary_len made from the list of ranked sentences in ranked_sents. | def summarize_ranked_sentences(ranked_sents, summary_len):
summary = []
for (sent, value) in ranked_sents:
summary.append(sent)
summary_len -= len(sent.split())
if summary_len <= 5:
# We stop at n-5 words already, as an effort to avoid being
# really far off.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summarize_ranked_sentences_fixed(ranked_sents, summary_len,\\\n min_sentence_length=None, max_sentence_length=None,\\\n max_similarity=None, sim_func=None):\n summary = []\n # Feature space for ranked sentences, needed for similarity testing:\n fs = create_feature_space(map(lambda x:x[0]... | [
"0.7793844",
"0.6746576",
"0.5995227",
"0.59792197",
"0.589691",
"0.584097",
"0.5769905",
"0.57228327",
"0.57124573",
"0.5625778",
"0.5615167",
"0.559903",
"0.5591387",
"0.55860156",
"0.55769086",
"0.5525552",
"0.55234677",
"0.54954785",
"0.5474877",
"0.5473331",
"0.5435104",... | 0.8302205 | 0 |
Returns a summary of approximately summary_len made from the list of ranked sentences in ranked_sents. | def summarize_ranked_sentences_fixed(ranked_sents, summary_len,\
min_sentence_length=None, max_sentence_length=None,\
max_similarity=None, sim_func=None):
summary = []
# Feature space for ranked sentences, needed for similarity testing:
fs = create_feature_space(map(lambda x:x[0], ranked_sen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summarize_ranked_sentences(ranked_sents, summary_len):\n summary = []\n for (sent, value) in ranked_sents:\n summary.append(sent)\n summary_len -= len(sent.split())\n if summary_len <= 5:\n # We stop at n-5 words already, as an effort to avoid being\n # really f... | [
"0.8303372",
"0.67473304",
"0.59950644",
"0.597926",
"0.5895404",
"0.58428013",
"0.5769547",
"0.5721766",
"0.57108516",
"0.5627067",
"0.5615921",
"0.5597304",
"0.55905074",
"0.5586839",
"0.5576498",
"0.55265445",
"0.55229414",
"0.5494074",
"0.5475931",
"0.5473112",
"0.5435678... | 0.7794806 | 1 |
Method to begin a resource claim for a new instance. | def begin_instance_resource_claim(self, context, instance_ref, *args,
**kwargs):
memory_mb = instance_ref['memory_mb']
disk_gb = instance_ref['root_gb'] + instance_ref['ephemeral_gb']
claim = self._do_begin_resource_claim(context, memory_mb, disk_gb,
*args, **kwargs)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: AuthServerClaimDefaultArgs,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def create(self):\n raise WufooException(\"InstanceResource creation not supported\")",
"def begin_resource_c... | [
"0.62509257",
"0.60371166",
"0.5969876",
"0.5818339",
"0.5743511",
"0.571801",
"0.571801",
"0.571801",
"0.571801",
"0.571801",
"0.571801",
"0.5654904",
"0.56244344",
"0.5619872",
"0.56168664",
"0.5578573",
"0.5573552",
"0.55535185",
"0.55503863",
"0.55503863",
"0.5525074",
... | 0.7002623 | 0 |
Indicate that the compute operation that previously claimed the resources identified by 'claim' has now completed and the resources have been allocated at the virt layer. Calling this keeps the available resource data more accurate and timely than letting the claim timeout elapse and waiting for update_available_resour... | def finish_resource_claim(self, claim):
if self.disabled:
return
if self.claims.pop(claim.claim_id, None):
LOG.info(_("Finishing claim: %s") % claim)
else:
LOG.info(_("Can't find claim %d. It may have been 'finished' "
"twice, or it ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_available_resource(self, context):\n # ask hypervisor for its view of resource availability &\n # usage:\n resources = self.driver.get_available_resource()\n if not resources:\n # The virt driver does not support this function\n LOG.warn(_(\"Virt driver ... | [
"0.6132909",
"0.59938806",
"0.59435874",
"0.5765076",
"0.56295913",
"0.5618212",
"0.54339164",
"0.5378912",
"0.52741885",
"0.5247547",
"0.51627636",
"0.51092154",
"0.50321853",
"0.49828237",
"0.4950891",
"0.49456367",
"0.4934022",
"0.49241692",
"0.49221307",
"0.48853132",
"0.... | 0.6251847 | 0 |
Indicate that the operation that claimed the resources identified by 'claim_id' has either failed or been aborted and the resources are no longer needed. | def abort_resource_claim(self, context, claim):
if self.disabled:
return
# un-claim the resources:
if self.claims.pop(claim.claim_id, None):
LOG.info(_("Aborting claim: %s") % claim)
values = claim.undo_claim(self.compute_node)
self.compute_node =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finish_resource_claim(self, claim):\n if self.disabled:\n return\n\n if self.claims.pop(claim.claim_id, None):\n LOG.info(_(\"Finishing claim: %s\") % claim)\n else:\n LOG.info(_(\"Can't find claim %d. It may have been 'finished' \"\n ... | [
"0.64828455",
"0.5375456",
"0.5339127",
"0.5339127",
"0.5339127",
"0.5339127",
"0.5310975",
"0.5310661",
"0.5280237",
"0.52453005",
"0.5241044",
"0.52293926",
"0.5226949",
"0.5221688",
"0.51996416",
"0.51984817",
"0.51676387",
"0.51649946",
"0.5132377",
"0.51301146",
"0.50660... | 0.71807176 | 0 |
Override inmemory calculations of compute node resource usage based on data audited from the hypervisor layer. Add in resource claims in progress to account for operations that have declared a need for resources, but not necessarily retrieved them from the hypervisor layer yet. | def update_available_resource(self, context):
# ask hypervisor for its view of resource availability &
# usage:
resources = self.driver.get_available_resource()
if not resources:
# The virt driver does not support this function
LOG.warn(_("Virt driver does not sup... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_metrics(self):\n pass",
"def compute_node_utilization_update(context, host, free_ram_mb_delta=0,\n free_disk_gb_delta=0, work_delta=0, vm_delta=0):\n session = get_session()\n compute_node = None\n with session.begin(subtransactions=True):\n compute_nod... | [
"0.610261",
"0.5831945",
"0.5707102",
"0.5675143",
"0.5586414",
"0.5548546",
"0.55291885",
"0.5527537",
"0.5514095",
"0.5490712",
"0.5457888",
"0.5434306",
"0.54277164",
"0.5409481",
"0.53984797",
"0.53762645",
"0.5356401",
"0.53561056",
"0.5332552",
"0.5330801",
"0.5322882",... | 0.6395029 | 0 |
Create the compute node in the DB | def _create(self, context, values):
# initialize load stats from existing instances:
compute_node = db.compute_node_create(context, values)
return compute_node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_node_create(context, values, session=None):\n if not session:\n session = get_session()\n\n _adjust_compute_node_values_for_utilization(context, values, session)\n with session.begin(subtransactions=True):\n compute_node_ref = models.ComputeNode()\n session.add(compute_nod... | [
"0.7886462",
"0.66315305",
"0.65461665",
"0.6531865",
"0.6467387",
"0.6465618",
"0.64177716",
"0.64140356",
"0.6410627",
"0.6333173",
"0.6254638",
"0.62438357",
"0.622373",
"0.61956275",
"0.6154375",
"0.61337537",
"0.6101469",
"0.60924846",
"0.6083357",
"0.60276544",
"0.60234... | 0.7969122 | 0 |
For each existing instance generate load stats for the compute node record. | def _create_load_stats(self, context, instance=None):
values = {}
if instance:
instances = [instance]
else:
self.stats.clear() # re-generating all, so clear old stats
# grab all instances that are not yet DELETED
filters = {'host': self.host, 'd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_load_stats_for_instance(self, context, old_ref, instance_ref):\n\n if self.disabled:\n return\n\n values = {}\n self.stats.update_stats_for_instance(old_ref, instance_ref)\n values['stats'] = self.stats\n\n values['current_workload'] = self.stats.calculate_w... | [
"0.6632865",
"0.6099012",
"0.5805302",
"0.5798235",
"0.57113814",
"0.56337655",
"0.56083333",
"0.55467355",
"0.5513725",
"0.54401135",
"0.5419466",
"0.5405712",
"0.5375009",
"0.5313308",
"0.52906615",
"0.52668417",
"0.5256041",
"0.5241589",
"0.5240477",
"0.5235982",
"0.523336... | 0.7430736 | 0 |
Persist the compute node updates to the DB | def _update(self, context, values, prune_stats=False):
return db.compute_node_update(context, self.compute_node['id'],
values, prune_stats) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_node_update(context, compute_id, values, auto_adjust):\n session = get_session()\n if auto_adjust:\n _adjust_compute_node_values_for_utilization(context, values, session)\n with session.begin(subtransactions=True):\n values['updated_at'] = timeutils.utcnow()\n convert_date... | [
"0.65285313",
"0.6118009",
"0.604902",
"0.6043689",
"0.5975559",
"0.5921199",
"0.5864714",
"0.5849919",
"0.57917213",
"0.5789143",
"0.57578045",
"0.57397336",
"0.57336444",
"0.57336444",
"0.5711781",
"0.57054156",
"0.56855655",
"0.56813747",
"0.5673421",
"0.5673421",
"0.56734... | 0.64617336 | 1 |
Test output format for catkin_lint text output | def test_text(self):
result = self._do_output(o.TextOutput(o.Color.Never), self._demo_msgs)
self.assertEqual(result,
"mock: mock.cmake(1): error: short text\n"
"mock: mock.cmake(2): warning: short text\n"
"mock: mock.cmake(3): no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cli_conversion(self):\n output = main('coloredlogs', '--convert', 'coloredlogs', '--demo', capture=True)\n # Make sure the output is encoded as HTML.\n assert '<span' in output",
"def task_format_check():\n return {\"actions\": [[\"black\", HERE, \"--check\"]], \"verbosity\": 1}"... | [
"0.65368015",
"0.6312445",
"0.6249199",
"0.6211281",
"0.6120904",
"0.61186886",
"0.610369",
"0.6053451",
"0.6029783",
"0.5949499",
"0.59367526",
"0.59056807",
"0.5903612",
"0.58756447",
"0.5865295",
"0.58424324",
"0.58035696",
"0.579489",
"0.5769348",
"0.57533115",
"0.5719392... | 0.66062003 | 0 |
Test output format for catkin_lint text output with explanations | def test_explained_text(self):
result = self._do_output(o.ExplainedTextOutput(o.Color.Never), self._demo_msgs)
self.assertEqual(result,
"mock: mock.cmake(1): error: short text\n"
" * long text\n"
" * You can ignore this p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_text(self):\n result = self._do_output(o.TextOutput(o.Color.Never), self._demo_msgs)\n self.assertEqual(result,\n \"mock: mock.cmake(1): error: short text\\n\"\n \"mock: mock.cmake(2): warning: short text\\n\"\n \"mock: ... | [
"0.6820659",
"0.66512114",
"0.6582962",
"0.64088684",
"0.62419",
"0.62119657",
"0.6206299",
"0.6198279",
"0.6178129",
"0.6112987",
"0.6082602",
"0.60623485",
"0.6046402",
"0.60262376",
"0.60258967",
"0.59677523",
"0.5952068",
"0.5897076",
"0.589639",
"0.5884636",
"0.5877434",... | 0.7078935 | 0 |
Test output format for catkin_lint JSON output | def test_json(self):
result = self._do_output(o.JsonOutput(), self._demo_msgs)
self.assertEqual(result,
'{"errors": ['
'{"id": "MOCK_MSG", "location": {"file": "mock.cmake", "line": 1, "package": "mock"}, "text": "short text"}, '
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_to_json(self):\n actual_result = ResultBuilder(IPERF_PARSER_EXPECTED_RESULT,\n OK_MESSAGE,\n OK_RETURN_CODE).build_json()\n self.assertMultiLineEqual(actual_result,\n EXPECTED_OUTPUT_BU... | [
"0.6491087",
"0.63575923",
"0.63511103",
"0.6325256",
"0.6238206",
"0.6232294",
"0.6071464",
"0.60508937",
"0.6035635",
"0.59810036",
"0.5936991",
"0.59324217",
"0.5884454",
"0.5811954",
"0.57944614",
"0.5770887",
"0.5752774",
"0.57514",
"0.5739572",
"0.57337415",
"0.57236123... | 0.6956471 | 0 |
Test output format for catkin_lint XML output | def test_xml(self):
result = self._do_output(o.XmlOutput(), self._demo_msgs)
self.assertEqual(result,
'<catkin_lint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/fkie/catkin_lint/%(version)s/catkin_lint.xsd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cli_conversion(self):\n output = main('coloredlogs', '--convert', 'coloredlogs', '--demo', capture=True)\n # Make sure the output is encoded as HTML.\n assert '<span' in output",
"def test_html_output(self):\n pass",
"def test_02_Xml1(self):\n l_xml = self.m_xml.ligh... | [
"0.5840639",
"0.5795574",
"0.5722757",
"0.5670652",
"0.56481016",
"0.56112283",
"0.55850196",
"0.5540962",
"0.5533451",
"0.5530737",
"0.5510001",
"0.5506588",
"0.550099",
"0.54983294",
"0.5489602",
"0.5455667",
"0.5433676",
"0.54104465",
"0.5404742",
"0.540282",
"0.53616744",... | 0.77167076 | 0 |
Add a part to this geometry. | def add_part(self, part_name, part, overwrite=False):
if not part.is_valid:
raise ValueError("Part " + part_name + " is not a valid polygon.")
if (part_name in self.parts) and (not overwrite):
raise ValueError("Attempted to overwrite the part " + part_name + ".")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_part(\n self, part_name: str, part: Union[LineString, Polygon], overwrite: bool = False\n ):\n if isinstance(part, Polygon) and not part.is_valid:\n raise ValueError(f\"Part {part_name} is not a valid polygon.\")\n\n part.virtual = False\n\n super().add_part(\n ... | [
"0.70585144",
"0.6734559",
"0.6557342",
"0.6538195",
"0.6288837",
"0.6218431",
"0.6200463",
"0.60914123",
"0.60444534",
"0.5913402",
"0.5888297",
"0.5887131",
"0.58248377",
"0.5767808",
"0.5729774",
"0.56559455",
"0.5629866",
"0.56137794",
"0.5554628",
"0.5544584",
"0.5536391... | 0.7265412 | 0 |
Returns the build order restricted to parts. | def part_build_order(self):
priority = []
for geo_item in self.build_order:
if geo_item in self.parts:
priority += [geo_item]
return priority | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def part_build_order(self) -> List[str]:\n priority = []\n for geo_item in self.build_order:\n if geo_item in self.parts and isinstance(self.parts[geo_item], Polygon):\n priority += [geo_item]\n return priority",
"def requirement_order(variables):\n # TODO: chang... | [
"0.6569069",
"0.53607655",
"0.5346127",
"0.51932895",
"0.51610893",
"0.512908",
"0.5114032",
"0.50841725",
"0.5063228",
"0.5004926",
"0.49911422",
"0.4983267",
"0.49718508",
"0.49679783",
"0.49623498",
"0.49623498",
"0.49615237",
"0.4951187",
"0.49428612",
"0.49221104",
"0.49... | 0.71300155 | 0 |
Get the list of vertex coordinates for a part | def part_coord_list(self,part_name):
# Note that in shapely, the first coord is repeated at the end, which we trim off:
coord_list = list(np.array(self.parts[part_name].exterior.coords.xy).T)[:-1]
return coord_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coord_list(self, part_name: str) -> List:\n part = self.parts[part_name]\n if isinstance(part, Polygon):\n # Note that in shapely, the first coord is repeated at the end, which we\n # trim off:\n return list(np.array(part.exterior.coords.xy).T)[:-1]\n elif ... | [
"0.74417055",
"0.7328162",
"0.68468404",
"0.6826052",
"0.6826052",
"0.6753993",
"0.67460376",
"0.67353445",
"0.6734459",
"0.67202014",
"0.66925484",
"0.6681662",
"0.6653243",
"0.664822",
"0.6546319",
"0.649704",
"0.64740205",
"0.6470348",
"0.6461982",
"0.6460211",
"0.64141345... | 0.7724178 | 0 |
Get the list of vertex coordinates for an edge. | def edge_coord_list(self,edge_name):
coord_list = list(np.array(self.edges[edge_name].coords.xy).T)[:]
return coord_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edge_vertices(edge):\n return [edge.vertex1, edge.vertex2]",
"def vertices_from_edge(self, edge):\n assert isinstance(edge, Edge)\n return map(Vertex, self._top_exp.vertices_from_edge(edge.topods_shape()))",
"def get_edge_coords(self):\n return self.coords",
"def get_edge_ids(self... | [
"0.8280774",
"0.77096665",
"0.744324",
"0.70164496",
"0.69808906",
"0.6954093",
"0.68951213",
"0.67977554",
"0.67594576",
"0.6726835",
"0.6689108",
"0.6666376",
"0.66438687",
"0.6643371",
"0.6640205",
"0.66248316",
"0.66205746",
"0.661167",
"0.6602474",
"0.6597047",
"0.659399... | 0.7957288 | 1 |
Get mapping of part names to materials. | def get_material_mapping(self):
return {name: self.get_material(name) for name in self.parts.keys()} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def info_materials_polymer_get():\n materials = _material_by_group(974) # 974 == intermediate group\n return materials, 200",
"def info_materials_get():\n materials = _material_by_group() # empty means all groups\n return materials, 200",
"def info_materials_raw_get():\n materials = _material_by... | [
"0.648668",
"0.60782313",
"0.5990773",
"0.5898165",
"0.5876841",
"0.5867664",
"0.58336645",
"0.5824792",
"0.57789636",
"0.57509327",
"0.5715026",
"0.5701652",
"0.56807667",
"0.567221",
"0.5644511",
"0.56316775",
"0.55670387",
"0.55413884",
"0.5515615",
"0.55024874",
"0.549085... | 0.81129396 | 0 |
Remove a part from this geometry. | def remove_part(self, part_name, ignore_if_absent=False):
if part_name in self.parts:
del self.parts[part_name]
else:
if not ignore_if_absent:
raise ValueError(
"Attempted to remove the part " + part_name + ", which doesn't exist.")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_parts(self, parts):\r\n self.board.remove_parts(parts)\r\n self.set_changed(parts)",
"def remove(self):\n\t\tcall_sdk_function('PrlVmDevHdPart_Remove', self.handle)",
"def remove_part(self, part_name, ignore_if_absent=False):\n if part_name in self.parts:\n del self.p... | [
"0.6718372",
"0.65129596",
"0.6473044",
"0.63571346",
"0.6277983",
"0.61714953",
"0.60705364",
"0.6008346",
"0.5999255",
"0.59667516",
"0.5946174",
"0.594038",
"0.5867004",
"0.5863945",
"0.5858506",
"0.58270794",
"0.58269894",
"0.58269894",
"0.5820676",
"0.58111167",
"0.58083... | 0.6786756 | 0 |
Write geometry to a fcstd file. Returns the fcstd file path. | def write_fcstd(self, file_path=None):
if file_path is None:
file_path = '_'.join([item[0:4].replace(' ', '_') for item in self.build_order]) + '.fcstd'
write_deserialised(self.serial_fcdoc, file_path)
return file_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_mat_file(self):\n mat_dict = {}\n mat_dict['Lx_p'] = self.Lx_p\n mat_dict['Ly_p'] = self.Ly_p\n mat_dict['Lz_p'] = self.Lz_p\n mat_dict['Lo'] = self.obst.get_Lo()\n mat_dict['Ny_divs'] = self.N_divs\n mat_dict['rho_p'] = self.rho_p\n mat_dict['nu_p'... | [
"0.61089766",
"0.58492243",
"0.58348626",
"0.5711159",
"0.5689639",
"0.5679398",
"0.56370866",
"0.56361693",
"0.5601309",
"0.5553817",
"0.55333287",
"0.5525343",
"0.5501694",
"0.54869753",
"0.54513437",
"0.54398495",
"0.54351586",
"0.54289746",
"0.53706634",
"0.53396595",
"0.... | 0.7280355 | 0 |
covert ros point cloud to open3d point cloud | def rospc_to_o3dpc(rospc, remove_nans=False):
field_names = [field.name for field in rospc.fields]
is_rgb = 'rgb' in field_names
cloud_array = ros_numpy.point_cloud2.pointcloud2_to_array(rospc)
if remove_nans:
mask = np.isfinite(cloud_array['x']) & np.isfinite(cloud_array['y']) & np.isfinite(clo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertcloud(points):\n pcd = open3d.geometry.PointCloud()\n pcd.points = open3d.utility.Vector3dVector(points)\n return pcd",
"def o3dpc_to_rospc(o3dpc, frame_id=None, stamp=None):\n\n cloud_npy = np.asarray(copy.deepcopy(o3dpc.points))\n is_color = o3dpc.colors\n \n\n n_points = le... | [
"0.7631663",
"0.6904647",
"0.66574097",
"0.64891225",
"0.6486366",
"0.63585716",
"0.61352915",
"0.6126815",
"0.6074843",
"0.5837435",
"0.5813765",
"0.5804848",
"0.579644",
"0.5776669",
"0.5772508",
"0.57610273",
"0.5756851",
"0.57459956",
"0.571352",
"0.57003003",
"0.56894284... | 0.7198232 | 1 |
Function that filters a point cloud depending of a desired field of view. Resulting point cloud will have horizontal FOV of +fov/2. | def lidar_cloud_filtering(cloud: np.ndarray, fov: float) -> np.ndarray:
min_fov = -(fov/2)*(3.14/180)
max_fov = (fov/2)*(3.14/180)
mask = ((cloud[:,2] > -2.00)
& (np.arctan2(cloud[:,1], cloud[:,0]) > min_fov)
& (np.arctan2(cloud[:,1], cloud[:,0]) < max_fov))
cloud = cloud[mask]
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fov_setting(points, x, y, z, dist, h_fov, v_fov):\n\n if h_fov[1] == 180 and h_fov[0] == -180 and v_fov[1] == 2.0 and v_fov[0] == -24.9:\n return points\n\n if h_fov[1] == 180 and h_fov[0] == -180:\n return points[in_v_range_points(dist, z, v_fov)]\n elif v_fov[1] == 2.0 and v_fov[0] == ... | [
"0.65764093",
"0.61239827",
"0.58919877",
"0.5884863",
"0.56311095",
"0.56129175",
"0.55908173",
"0.5536127",
"0.55347115",
"0.55347115",
"0.55347115",
"0.5531457",
"0.5524439",
"0.55058485",
"0.548033",
"0.54685426",
"0.5422279",
"0.54143703",
"0.54134655",
"0.5365292",
"0.5... | 0.7485544 | 0 |
Performs RANSAC plane segmentation over a point cloud and returns | def ransac_plane_segmentation(cloud: object, thresh: int, n_iter: int) -> Tuple[object, object]:
plane_model, inliers = cloud.segment_plane(
distance_threshold=thresh,
ransac_n=3,
num_iterations=n_iter)
plane_cloud = cloud.select_by_index(inliers)
obstacles_cloud = cloud.select_by_in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ransac_plane_estimation (numpy_cloud, threshold, fixed_point=None, w = .9, z = 0.95 ):\r\n\r\n # variables\r\n current_consensus = 0 # keeps track of how many points match the current plane\r\n best_consensus = 0 # shows how many points matched the best plane yet\r\n ... | [
"0.6336735",
"0.610941",
"0.60093796",
"0.6004247",
"0.5990745",
"0.58605415",
"0.57858086",
"0.55426097",
"0.55380136",
"0.5503953",
"0.53902084",
"0.5346371",
"0.53190625",
"0.52973086",
"0.5292462",
"0.528988",
"0.5254189",
"0.52460873",
"0.52317154",
"0.52079624",
"0.5202... | 0.6539922 | 0 |
Performs clustering over obstacles in a point cloud applying Open3D implementation of DBSCAN algorithm. | def clustering_dbscan_o3d():
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster(self):\n\n result_nominatim = self.nominatim()\n try:\n coord = [(float( i['lat'] ), float( i['lon'] )) for i in result_nominatim]\n except:\n return None\n #print( \"coord\", coord )\n kms_per_radian = 6371.0088\n # Augmenter cette valeur... | [
"0.6015871",
"0.58707076",
"0.58356494",
"0.58203876",
"0.57932305",
"0.5774804",
"0.5752",
"0.5748449",
"0.5735503",
"0.5672406",
"0.56204516",
"0.5585565",
"0.5535619",
"0.5530266",
"0.5528324",
"0.54942405",
"0.548726",
"0.5471146",
"0.54368615",
"0.5419215",
"0.5398244",
... | 0.70152134 | 0 |
Function that classify the labels obtained after Open3D clustering with DBSCAN algorithm and returns a list of clusters and other stats. | def classify_clusters_o3d(cloud: object, labels: np.ndarray) -> Tuple[list, list]:
cloud_np = np.asarray(cloud.points)
indices = list(dict.fromkeys(labels))
if (-1 in indices):
indices.remove(-1)
clusters = [[] for i in indices]
for (i, point) in enumerate(cloud_np, start=0):
if (lab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify_k_cluster(labels, datas):\n classify_k_cluster_to_redis(labels=labels, texts=datas)",
"def DBscan_clustering(self,d,s):\r\n print(colored(\"Performing agglomerative clustering\",color = 'yellow', attrs=['bold']))\r\n self.clustering = DBSCAN(eps=d,min_samples=s,metric = 'euclidean')... | [
"0.6853057",
"0.67281973",
"0.67161256",
"0.65965825",
"0.6511011",
"0.6432635",
"0.6409616",
"0.6387448",
"0.6358647",
"0.6332532",
"0.6244226",
"0.62289804",
"0.6200969",
"0.6192915",
"0.61822176",
"0.6101818",
"0.60621715",
"0.6026377",
"0.60244054",
"0.59592366",
"0.59586... | 0.6981123 | 0 |
Request to cancel execution of the given run. | def cancel_run(self, run_id):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel(self, run_id):\n postresult = requests.post(\n f\"{self.proto}://{self.host}/ga4gh/wes/v1/runs/{run_id}/cancel\",\n headers=self.auth,\n )\n return wes_reponse(postresult)",
"def cancel_run(run_id):\n # Get the access token first to raise an error immediat... | [
"0.762823",
"0.7267763",
"0.7248652",
"0.7227221",
"0.72146887",
"0.7104296",
"0.7104296",
"0.7096916",
"0.7096916",
"0.7096916",
"0.70521456",
"0.7015864",
"0.7009463",
"0.7007429",
"0.69997257",
"0.69966495",
"0.6995695",
"0.69163126",
"0.6828244",
"0.68196803",
"0.68196803... | 0.85699 | 0 |
Execute a given workflow template for a set of argument values. Returns an unique identifier for the started workflow run. | def execute(self, template, arguments):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def launch_template_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"launch_template_id\")",
"def test_workflows_id_templates_post(self):\n pass",
"def execute(args, config):\n\n token = jwtfile.read()\n api = config['API']\n if not args.job: # users would supply name of workf... | [
"0.57848144",
"0.55960804",
"0.556407",
"0.5503356",
"0.54954636",
"0.54168403",
"0.54159296",
"0.54074675",
"0.5271457",
"0.5265076",
"0.5257633",
"0.5242289",
"0.5222247",
"0.5220376",
"0.5206206",
"0.51957536",
"0.51943433",
"0.5190086",
"0.5152901",
"0.51406693",
"0.51390... | 0.6466405 | 0 |
Load transaction into a list of transactions | def load_transactions(directory):
transactions = []
with open(directory, "r") as infile:
for line in infile:
transaction = line.split()
transactions.append(transaction)
return transactions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_transactions(self, address, update=True, verbose=False, **kwargs):\n if self.apikey is None:\n update = False\n if verbose:\n print('load_transactions', address)\n fn = os.path.join(self.cache_dir, address + '.json')\n startblock = None\n transactio... | [
"0.710692",
"0.661772",
"0.63588184",
"0.62911063",
"0.6285592",
"0.620764",
"0.6070961",
"0.5993426",
"0.59712225",
"0.59509104",
"0.5831362",
"0.581861",
"0.5800975",
"0.57938397",
"0.5789504",
"0.5732287",
"0.57019025",
"0.5695308",
"0.56871927",
"0.5665952",
"0.56581",
... | 0.68966335 | 1 |
return n number of uniq items | def get_uniq_n(self, num=4):
ret = []
tmp = []
idx = 0
# iterate list, or until 4 items grabbed
#while (idx < len(self.counts)) and (len(tmp) < num):
while True:
print("> x:", idx, tmp, ret)
# done with group, next group
if len(tmp)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_items(self):\n if self._n_items is None:\n self._n_items = len(self.item_unique_vals)\n return self._n_items",
"def distinct(n):\n if n <= 10:\n return [_distincts[2*i] for i in range(0, n)]\n elif n <= 20:\n return _distincts[:n]\n else:\n return _dis... | [
"0.6980629",
"0.69095874",
"0.6584818",
"0.6331963",
"0.63206124",
"0.6299949",
"0.6284743",
"0.6284552",
"0.62726873",
"0.62726873",
"0.62346977",
"0.6186611",
"0.61509174",
"0.61465144",
"0.61274713",
"0.6097903",
"0.6096079",
"0.60583496",
"0.6049501",
"0.60321844",
"0.600... | 0.7341703 | 0 |
return cost for a set of books | def cost(books):
num_types = len(set(books))
assert num_types < 6, "Discounts indeterminate"
return DISCOUNT_TABLE.get(num_types, 0) * 8 * len(books) * 100 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_total(books):\n\n if len(books) <= 5:\n return cost(books)\n\n # try 4-group chunks\n cost4 = sum(map(cost, Chunk(books).get_groups(4)))\n\n # try 5-group chunks\n cost5 = sum(map(cost, Chunk(books).get_groups(5)))\n\n # return whatever's smaller\n return min(cost4, cost5)... | [
"0.6807694",
"0.64842665",
"0.6360522",
"0.6166378",
"0.60549176",
"0.5987826",
"0.5980296",
"0.59670144",
"0.59312326",
"0.5900605",
"0.5817881",
"0.5790117",
"0.57712775",
"0.57615566",
"0.5744646",
"0.57277024",
"0.57190454",
"0.5713545",
"0.5703072",
"0.5695666",
"0.56913... | 0.76283944 | 0 |
Apply transformations to the feedbacks in dataset_dict, if any. | def transform_feedbacks(dataset_dict, image_shape, transforms, *, min_box_size=0):
if "feedback_proposal_boxes" in dataset_dict:
# Transform proposal boxes
proposal_boxes = transforms.apply_box(
BoxMode.convert(
dataset_dict.pop("feedback_proposal_boxes"),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _transform(self, dataset):\n raise NotImplementedError()",
"def apply_transform(key, data, transform_list):\n for transform in transform_list:\n method_name = transform[MethodKeys.METHOD]\n method_params = transform[MethodKeys.PARAMETERS]\n\n if method_name == '... | [
"0.62110144",
"0.6171037",
"0.6075402",
"0.5885071",
"0.58126515",
"0.5768654",
"0.57244396",
"0.56812954",
"0.5636151",
"0.5625626",
"0.55071694",
"0.5455338",
"0.5446471",
"0.5426323",
"0.54253227",
"0.5411171",
"0.538824",
"0.53843725",
"0.53836364",
"0.5367892",
"0.535730... | 0.66173154 | 0 |
initalize the Portfolio object with a PositionHandler, an event history, along with cash balance. Make sure the portfolio denomination currency is also set. | def __init__(
self,
start_dt,
starting_cash=0.0,
currency = "USD",
portfolio_id=None,
name=None
):
self.start_dt = start_dt
self.current_dt = start_dt
self.starting_cash = starting_cash
self.currency = currency
self.portfolio_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initalize_portfolio_with_cash(self):\n self.cash = copy.copy(self.starting_cash)\n\n if self.starting_cash > 0.0:\n self.history.append(\n PortfolioEvent.create_subscription(\n self.current_dt, self.starting_cash, self.starting_cash\n )... | [
"0.7173111",
"0.6831782",
"0.67134976",
"0.6678022",
"0.65675235",
"0.6527908",
"0.6390145",
"0.6258053",
"0.62282896",
"0.62212044",
"0.6000357",
"0.59435725",
"0.5930339",
"0.5854626",
"0.5842731",
"0.5830696",
"0.579761",
"0.57606167",
"0.57326436",
"0.57089895",
"0.569233... | 0.71243984 | 1 |
initalize the portfolio with a (default) currency Cash Asset with quantity equal to 'starting_cash'. | def _initalize_portfolio_with_cash(self):
self.cash = copy.copy(self.starting_cash)
if self.starting_cash > 0.0:
self.history.append(
PortfolioEvent.create_subscription(
self.current_dt, self.starting_cash, self.starting_cash
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_cash(self, cash):\n portfolio = self.get_portfolio_object()\n if portfolio is not None:\n portfolio.cash += cash\n portfolio.initial_cash += cash",
"async def init(self, ctx, *amount_and_symbol : str):\n user = ctx.message.author\n portfolio = GetPortfolio(user.i... | [
"0.72195965",
"0.6654873",
"0.6479836",
"0.62634933",
"0.6254535",
"0.6159562",
"0.61312175",
"0.6044168",
"0.5925858",
"0.5922093",
"0.5849026",
"0.5737447",
"0.5727892",
"0.5719678",
"0.56384236",
"0.5622496",
"0.56089795",
"0.56013167",
"0.5577498",
"0.5574091",
"0.5544536... | 0.80738497 | 0 |
Obtain the total market value of the portfolio excluding cash. | def total_market_value(self):
return self.pos_handler.total_market_value() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_equity(self):\n return self.total_market_value + self.cash",
"def total_value(self):\n total = 0.0\n for account in self.accounts():\n total += account.available_cash()\n for asset in account.assets():\n total += asset.adjusted_value()\n ... | [
"0.7649796",
"0.69502854",
"0.6722701",
"0.6394569",
"0.63577044",
"0.6176712",
"0.615809",
"0.61579525",
"0.60663974",
"0.60509324",
"0.6004026",
"0.599746",
"0.59863096",
"0.59831744",
"0.59295094",
"0.5906891",
"0.5896239",
"0.5874856",
"0.58583444",
"0.5849165",
"0.584621... | 0.74222666 | 1 |
Obtain the total market value of the portfolio including cash. | def total_equity(self):
return self.total_market_value + self.cash | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_market_value(self):\n return self.pos_handler.total_market_value()",
"def total_value(self):\n total = 0.0\n for account in self.accounts():\n total += account.available_cash()\n for asset in account.assets():\n total += asset.adjusted_value()\n... | [
"0.7671627",
"0.75416785",
"0.7099624",
"0.6975173",
"0.67064476",
"0.66260713",
"0.6544043",
"0.6533217",
"0.6508555",
"0.6503629",
"0.64636236",
"0.6411057",
"0.64103353",
"0.6406251",
"0.63845277",
"0.6358938",
"0.63136154",
"0.6281191",
"0.62557274",
"0.6252469",
"0.62497... | 0.80464536 | 0 |
Withdraw funds from the portfolio if there is enough cash to allow it. | def withdraw_funds(self, dt, amount):
# Check that amount is positive and that there is
# enough in the portfolio to withdraw the funds
if dt < self.current_dt:
raise ValueError(
'Withdrawal datetime (%s) is earlier than '
'current portfolio datetime (... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safeWithdrawal(self):\n if self._after_dead_line():\n # each contributor can withdraw the amount they contributed if the goal was not reached\n if not self._funding_goal_reached.get():\n amount = self._balances[self.msg.sender]\n self._balances[self.ms... | [
"0.74107724",
"0.72163254",
"0.699449",
"0.6918128",
"0.689299",
"0.6868044",
"0.6859463",
"0.683509",
"0.663997",
"0.66042185",
"0.6593318",
"0.6527396",
"0.6500984",
"0.6495702",
"0.6479582",
"0.6476689",
"0.6464946",
"0.6458756",
"0.6449556",
"0.6433253",
"0.6429987",
"0... | 0.7463754 | 0 |
Output the portfolio holdings information as a dictionary with Assets as keys and subdictionaries as values. This excludes cash. Returns `dict` The portfolio holdings. | def portfolio_to_dict(self):
holdings = {}
for asset, pos in self.pos_handler.positions.items():
holdings[asset] = {
"quantity": pos.net_quantity,
"market_value": pos.market_value,
"unrealised_pnl": pos.unrealised_pnl,
"realised... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _construct_all_holdings(self):\n d = dict((s, 0.0) for s in self.symbol_list)\n d['datetime'] = self.backtest_date\n d['cash'] = self.initial_capital\n d['commission'] = 0.0\n d['total'] = self.initial_capital\n d['buy_times'] = 0\n d['sell_times'] = 0\n ... | [
"0.6569179",
"0.6421952",
"0.6421952",
"0.63862634",
"0.63862634",
"0.63605213",
"0.60193604",
"0.5961092",
"0.5930267",
"0.55896163",
"0.5566243",
"0.5548045",
"0.55441123",
"0.55261385",
"0.55183345",
"0.54996383",
"0.5492355",
"0.54301274",
"0.53714633",
"0.53534925",
"0.5... | 0.75006324 | 0 |
Update the market value of the asset to the current trade price and date. | def update_market_value_of_asset(
self, asset, current_price, current_dt
):
if asset not in self.pos_handler.positions:
return
else:
if current_price < 0.0:
raise ValueError(
'Current trade price of %s is negative for '
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_portfolio_on_market(self, market: MarketEvent):\n self._portfolio.update_market_value(market)",
"def update(self, context, data):\n self.context = context\n self.data = data\n\n dt = get_datetime()\n\n for tkt, bo in self._d_orders['trades'].items():\n pri... | [
"0.6770506",
"0.6666336",
"0.655968",
"0.63940954",
"0.6377642",
"0.62694365",
"0.61117345",
"0.6039604",
"0.6034311",
"0.5963494",
"0.5958086",
"0.5876996",
"0.5860456",
"0.5858723",
"0.5831601",
"0.5800546",
"0.57977796",
"0.5793063",
"0.57892066",
"0.57275933",
"0.5683779"... | 0.7675501 | 0 |
Creates a Pandas DataFrame of the Portfolio history. | def history_to_df(self):
records = [pe.to_dict() for pe in self.history]
return pd.DataFrame.from_records(
records, columns=[
"date", "type", "description", "debit", "credit", "balance"
]
).set_index(keys=["date"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_price_history(self):\n # Connect to the database and return cursor\n database = DatabaseMySQL()\n\n # Query database.\n sql = \"Select published_at, `close` from company_price_volume_history \\\n where company_id =\" + str(self.company_id)\n df = database.g... | [
"0.7041479",
"0.70078605",
"0.691566",
"0.67901385",
"0.6777132",
"0.67641455",
"0.6627967",
"0.66017205",
"0.65697855",
"0.6559828",
"0.6557792",
"0.64947486",
"0.649178",
"0.6465591",
"0.6461615",
"0.64101964",
"0.6392582",
"0.6389661",
"0.6381566",
"0.6366472",
"0.6352194"... | 0.79478663 | 0 |
Test MSE for null model | def null_model_MSE(y_all):
y_train = y_all[y_all["yyyymm"] < TRAIN_DATE].iloc[:,1].to_numpy()
y_test = y_all[y_all["yyyymm"] >= TRAIN_DATE].iloc[:,1].to_numpy()
MSE = np.sum((np.mean(y_train) - y_test)**2) / len(y_test)
print("Null MSE: {:.6f}".format(MSE))
print("Null MSE as % of square m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _raise_none_model(self):\n raise ValueError(\"Model is of type None! Was it not initialized?\")",
"def test_plot_mcse_no_sample_stats(models):\n idata = models.model_1\n with pytest.raises(ValueError, match=\"must contain sample_stats\"):\n plot_mcse(idata.posterior, rug=True)",
"def te... | [
"0.6632859",
"0.64758897",
"0.63328713",
"0.63182884",
"0.63009566",
"0.6226597",
"0.6221253",
"0.618825",
"0.61653984",
"0.6114206",
"0.60586286",
"0.6023301",
"0.5990606",
"0.5981989",
"0.5972182",
"0.595759",
"0.5947279",
"0.5942478",
"0.5935756",
"0.59146076",
"0.59018666... | 0.69770265 | 0 |
Number of stages in series. | def N_stages(self):
return 5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_stages(self) -> int:\n return self.pg_mesh.size(self.pipeline_axis)",
"def n_series(self):\n return self.container['n_series']",
"def num_seq_dep_stages(self):\n n_s = [0]*len(self)\n for i in range(len(self)):\n for j in range(i):\n if self.A[i,j] ... | [
"0.7094457",
"0.68827665",
"0.68428504",
"0.68162185",
"0.6773421",
"0.6773421",
"0.6675808",
"0.65918994",
"0.6582753",
"0.65544665",
"0.64684325",
"0.6448135",
"0.64401495",
"0.63980275",
"0.6377673",
"0.6271794",
"0.6246347",
"0.6210202",
"0.613833",
"0.6106045",
"0.606924... | 0.7792204 | 0 |
Turnover time (hr) calculated by batch time divided by number of trains. | def tau_turnover(self):
return self.tau_batch/self.N_trains | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def averageTime(self):\n \n pass",
"def get_time_walking(self):\n return self.time_step_to_enqueue - self.time_entered",
"def _calcPlungerMoveTime(self, move_steps):\n sd = self.sim_state\n start_speed = sd['start_speed']\n top_speed = sd['top_speed']\n cutoff_speed... | [
"0.5784227",
"0.57500553",
"0.5724595",
"0.5668751",
"0.56564844",
"0.56511545",
"0.5630987",
"0.5584381",
"0.55751765",
"0.5519167",
"0.54794383",
"0.54614097",
"0.5459399",
"0.5434004",
"0.5428243",
"0.5414287",
"0.5315894",
"0.53076774",
"0.52923393",
"0.52743506",
"0.5263... | 0.65438557 | 0 |
Return `True` if the url is a page on the website. | def is_page(self, url):
netloc = urlparse.urlparse(url).netloc.lower()
return any(map(lambda domain: netloc.endswith(domain), self.allowed_domains)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_link(self, url):\n return not self.is_page(url)",
"def is_url(url):\n\n return bool(re.match(re_url, url))",
"def is_url(self, url):\n return self.is_regex_url(url, self.is_url_regex)",
"def isHomePage(self):\n home = self.getHome(self.url)\n if home == self.url:\n ... | [
"0.73452467",
"0.70458114",
"0.6811103",
"0.67811906",
"0.67241377",
"0.6651423",
"0.66420513",
"0.66280663",
"0.6598485",
"0.6566262",
"0.65482503",
"0.6537461",
"0.653123",
"0.641096",
"0.6390091",
"0.6388571",
"0.6378757",
"0.635098",
"0.6335107",
"0.63305783",
"0.6328795"... | 0.82439804 | 0 |
Compute the pka of every molecule in the reactants. The pka, as well as the id of the "pka_point" is stored in the molecule. The "pka_point" is the id of the Hydrogen most likely to be donated, or the id of the atom most likely to accept a Hydrogen. The pka is based off of the pka_point of the atom. | def pka(reactants, conditions):
if 'pkas' in conditions and 'pka_points' in conditions:
for reactant in reactants:
id_ = reactant.id
reactant.pka = conditions['pkas'][id_]
reactant.pka_point = conditions['pka_points'][id_]
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdb2pka_sugelm(self):\n import Protool\n P=Protool.structureIO()\n P.readpdb(self.pdbfile)\n P.RemoveALT()\n #import Protool.mutate\n #MUT=Protool.mutate.Mutate(P)\n #\n # Construct arrays\n #\n import pKD_dict\n self.data=pKD_dict.pK... | [
"0.5158348",
"0.48979437",
"0.48744103",
"0.48531747",
"0.47961274",
"0.47541335",
"0.47500744",
"0.4750029",
"0.47356266",
"0.47118792",
"0.46887466",
"0.4687435",
"0.46834368",
"0.46807116",
"0.46598148",
"0.46575442",
"0.46462256",
"0.4611831",
"0.45965326",
"0.45921457",
... | 0.62386024 | 0 |
Region from Resize Returns a new set of region points based on a current width and height and the bounding box | def regionFromResize(curr_width, curr_height, bounds_width, bounds_height):
# Return
lRet = [0, 0, 0, 0]
# If the current width is larger than the bounds width
if curr_width > bounds_width:
lRet[0] = int(round((curr_width - bounds_width) / 2.0))
lRet[1] = 0
lRet[2] = int(bounds_width + round((curr_width - ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def canvas_bounds(self) -> utils.BoxRegion:",
"def region_points(x, y, width, xmin, xmax):\n right = (x, y + width / 2)\n top = (xmax, y)\n left = (x, y - width / 2)\n bottom = (xmin, y)\n return (right, top, left, bottom)",
"def store_region_boundaries(self): \n # Generate mask that dist... | [
"0.697886",
"0.6666205",
"0.65117455",
"0.62974226",
"0.6295849",
"0.6254296",
"0.6123672",
"0.61174107",
"0.5990237",
"0.5970507",
"0.5891778",
"0.5888146",
"0.5876723",
"0.5858563",
"0.5818475",
"0.57617384",
"0.5739866",
"0.5718716",
"0.56975836",
"0.5684751",
"0.5664272",... | 0.7247056 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.