query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Update the graphics command stream to reflect appearance properties. | def set_appearance_state(stream, A):
# Add in the `gs` command, which will execute the named graphics state from
# the Resources dict, and set CA and/or ca values. The annotations
# themselves will need to ensure that the proper ExtGState object is
# present in the Resources dict.
graphics_state = A... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_figure(self):\n\n self.draw()",
"def read_graphics(self):\n self.graphics.set(self.lnp.read_graphics())",
"def update(self):\n self.redraw()\n self._changed = False",
"def update(self):\n self.redraw()\n self._changed = False",
"def drawChanges(self):\n ... | [
"0.64846647",
"0.63168716",
"0.618399",
"0.618399",
"0.6150522",
"0.6138483",
"0.61381185",
"0.61198586",
"0.6044978",
"0.60232055",
"0.602067",
"0.6009418",
"0.59969217",
"0.5952258",
"0.5945161",
"0.59364563",
"0.5893696",
"0.5881858",
"0.5862772",
"0.58571213",
"0.5844122"... | 0.5643241 | 40 |
Recharges battery to full for the robot | def recharge(self):
self.battery=self.full
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def charge(self):\n self.battery.charge_level = 100\n print(\"The vehicle is fully charged.\")",
"def charge(self):\r\n\r\n self.charge_level = 100\r\n print(\"The battery is fully charged.\")",
"def charge(self):\r\n\r\n self.charge_level = 100\r\n print(\"The battery... | [
"0.7847203",
"0.78022724",
"0.78022724",
"0.7616893",
"0.7258318",
"0.7221551",
"0.69768226",
"0.68285954",
"0.6589345",
"0.6503826",
"0.63644844",
"0.62508595",
"0.6239367",
"0.6198437",
"0.61726785",
"0.6153093",
"0.6151589",
"0.6126337",
"0.60840267",
"0.60840267",
"0.6004... | 0.79994446 | 0 |
Makes the robot go one step back if it has energy and within its space and not colliding with any other obstacles | def one_step_back(self):
if (self.row -1<0):
return False
elif (self.battery == 0):
return False
elif (self.maze[self.row - 1][self.column] == False):
return False
else:
self.row -= 1
self.battery -= 1
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jump(self):\r\n if self.grounded == True:\r\n self.vel.y = -13",
"def minusToHome():\n\tif (not checkMotorsInPosition(-134.76, -34.197)):\n\t\treturn\n\n\tmoveMotor(dktheta, 0)\n\tmoveMotor(dkappa, 0)\n\tsimpleLog(\"Done\")",
"def step(self):\n prey_neighbors = [x for x in self.mod... | [
"0.70162576",
"0.69764",
"0.67612404",
"0.66625553",
"0.66102785",
"0.65981543",
"0.6487013",
"0.6462569",
"0.64322984",
"0.64102584",
"0.6403422",
"0.6362306",
"0.63522005",
"0.6349368",
"0.6318689",
"0.62797546",
"0.6268162",
"0.62617797",
"0.62586004",
"0.6228403",
"0.6219... | 0.5993737 | 49 |
Makes the robot go one step left if it has energy and within its space and not colliding with any other obstacles | def one_step_left(self):
if (self.column-1 <0):
return False
elif (self.battery == 0):
return False
elif (self.maze[self.row][self.column-1] == False):
return False
else:
self.column-=1
self.battery -= 1
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GET_left(self):\n self.roomba.TurnInPlace(pyrobot.VELOCITY_SLOW, 'ccw')\n time.sleep(0.5)\n self.roomba.Stop()",
"def GET_right(self):\n self.roomba.TurnInPlace(pyrobot.VELOCITY_SLOW, 'cw')\n time.sleep(0.5)\n self.roomba.Stop()",
"def left(self, param):\n\t\tglobal estop_flag, move_state... | [
"0.7208208",
"0.67593354",
"0.6679505",
"0.6585803",
"0.64608604",
"0.6458323",
"0.64380366",
"0.6418375",
"0.63597184",
"0.6354614",
"0.629254",
"0.6289452",
"0.62779933",
"0.62175804",
"0.6214254",
"0.6190879",
"0.6180187",
"0.617891",
"0.612305",
"0.6115944",
"0.61070704",... | 0.6218113 | 13 |
Evaluate detection proposal recall metrics. | def evaluate_recall(self, candidate_boxes=None, thresholds=None,
area='all', limit=None):
# Record max overlap value for each gt box
# Return vector of overlap values
areas = {'all': 0, 'small': 1, 'medium': 2, 'large': 3,
'96-128': 4, '128-256': 5, '256-512': 6, '512-inf'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recall(self):\n self.overall_recall = recall_score(\n self.y_true, self.y_pred, average = self.average_type).round(self.digits_count_fp)\n self.classes_recall = recall_score(\n self.y_true, self.y_pred, average = None).round(self.digits_count_fp)",
"def recall(prediction, ... | [
"0.6943433",
"0.688604",
"0.66618407",
"0.6595394",
"0.658823",
"0.6544603",
"0.6522268",
"0.6518944",
"0.6463584",
"0.6451868",
"0.6446809",
"0.6428194",
"0.63338727",
"0.63338727",
"0.63338727",
"0.63338727",
"0.63338727",
"0.63338727",
"0.63317436",
"0.6320232",
"0.6318102... | 0.0 | -1 |
loads data from a file as a pd.DataFrame | def from_file(filename, delimiter):
return pd.read_csv(filename, sep=delimiter) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_file_to_dataframe(self, file_path: str) -> pd.DataFrame:\n return pd.read_csv(file_path, sep=\"\\t\")",
"def read_data(filepath):\n df = pd.read_csv(filepath)\n return df",
"def read_data(filepath):\n df = pd.read_csv(filepath)\n return df",
"def read_data(filepath... | [
"0.82033116",
"0.78748757",
"0.78748757",
"0.78748757",
"0.7846813",
"0.7663916",
"0.7602644",
"0.7587255",
"0.75712645",
"0.75670075",
"0.75539184",
"0.7529963",
"0.750034",
"0.74925834",
"0.7474127",
"0.7466889",
"0.74624103",
"0.7455554",
"0.7449472",
"0.74216306",
"0.7408... | 0.68976283 | 65 |
Sample from normal distribution. | def sample(self, shape=None):
if shape is None:
shape = tf.shape(self.mean)
return tf.random.normal(shape) * tf.exp(self.logstd) + self.mean | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal_sample(mu, sigma):\n return mu + sigma * torch.randn_like(sigma)",
"def _sampling_normal(self, args):\n z_mean, z_log_var = args\n return sampling_normal(z_mean, z_log_var, (None, self.latent_dim))",
"def _sampling_normal(self, args):\n z_mean, z_log_var = args\n retur... | [
"0.80387986",
"0.7802694",
"0.7802694",
"0.7802694",
"0.7802694",
"0.7802694",
"0.76857334",
"0.7489225",
"0.74875015",
"0.7405976",
"0.73989594",
"0.7342455",
"0.72987044",
"0.72549987",
"0.7231568",
"0.6873994",
"0.68688905",
"0.6845441",
"0.68117917",
"0.67624605",
"0.6732... | 0.0 | -1 |
A goal relating conjugate priors and their posterior forms. This goal unifies `y` with a tupleform expression for a dictionary specifying the graph's node replacements. Those replacements map prior random variable terms to their posteriors forms. All other terms depending on those terms essentially become posterior pre... | def conjugate_posteriors(x, y):
z = var()
# First, find a basic conjugate structure match.
goals = ((conjugate, x, z),)
# Second, each conjugate case might have its own special conditions.
goals += ((conde,) + conde_clauses,)
# Third, connect the discovered pieces and produce the necessary ou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def positive_conjugate_projection(y: torch.Tensor) -> torch.Tensor:\n evalues, s = eigh(y)\n evalues = torch.clamp(evalues, min=EPS[y.dtype])\n y_tilde = s @ torch.diag_embed(evalues) @ s.transpose(-1, -2)\n\n # we do this so no operation is applied on the matrices that are already positive definite\n ... | [
"0.53076863",
"0.5298841",
"0.4953584",
"0.4914561",
"0.488892",
"0.48730046",
"0.48607993",
"0.48525727",
"0.48283637",
"0.47539243",
"0.4723074",
"0.47104508",
"0.4687376",
"0.467654",
"0.46292725",
"0.46288237",
"0.46280265",
"0.46132",
"0.46028486",
"0.45882532",
"0.45548... | 0.6759026 | 0 |
Raw data like received from the hub. | def raw_data(self):
return self._raw_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw(self):\n return self.data",
"def data(self) -> RawData:\r\n\r\n return self.__data",
"def get_raw_data(self):\n return self.__data",
"def raw_data(self):\n return self._buf[self.data_offset():self.data_offset() + self.size()]",
"def rawdata(self) -> str:\n return ... | [
"0.78114355",
"0.7800073",
"0.77128446",
"0.75956637",
"0.746117",
"0.7311341",
"0.7311341",
"0.7217426",
"0.72078747",
"0.7164414",
"0.6922001",
"0.68944204",
"0.6813137",
"0.6813137",
"0.6813137",
"0.67874646",
"0.67874646",
"0.67874646",
"0.67874646",
"0.67874646",
"0.6787... | 0.78098595 | 2 |
Computes relatedness ratio as detailed in the paper for the augmented algorithm. | def get_relatedness(theme1,theme2):
nAB=0
nAB_plus=0
for sentence_1 in theme1.sentences:
for sentence_2 in theme2.sentences:
if cmp(sentence_1[2],sentence_2[2])==0:
nAB=nAB+1
if sentence_1[3]==sentence_2[3]:
nAB_plus=nAB_plus+1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relatedness(self):\n if self.het_1 * self.het_2:\n return (self.het_1_2 - 2 * self.n_ibs0) * 2 / math.sqrt(self.het_1 * self.het_2)\n else:\n return 0.0",
"def reciprocity_ratio(gd):\r\n reciprocal = 0.0\r\n edge_list = gd.get_edgelist()\r\n for i in it.permutati... | [
"0.7314351",
"0.68028414",
"0.6266785",
"0.62531847",
"0.62329304",
"0.61807775",
"0.605229",
"0.6033515",
"0.59394604",
"0.58587176",
"0.5846746",
"0.581486",
"0.5774218",
"0.57668847",
"0.5737077",
"0.5727987",
"0.57221746",
"0.57221746",
"0.57221746",
"0.57221746",
"0.5722... | 0.5878658 | 9 |
Close the pooled connection. | def close(self):
# Instead of actually closing the connection,
# return it to the pool so that it can be reused.
if self._con is not None:
self._pool.returnConnection(self._con)
self._con = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _close(self): # used by model_tests\n Connection.__pool__.pop(self.id)\n self.connected = False",
"def close(self):\r\n self.conn.close()\r\n gc.collect()",
"def close(self):\n with self.connlock:\n self.conn.do_close()",
"def close_connection(self):\n\t\tse... | [
"0.7492703",
"0.7404888",
"0.7334038",
"0.7268132",
"0.7226714",
"0.7206993",
"0.71130574",
"0.7104948",
"0.7100774",
"0.7083736",
"0.70691955",
"0.7068247",
"0.7068247",
"0.7068247",
"0.7064333",
"0.706051",
"0.7045232",
"0.7045066",
"0.7031671",
"0.7028513",
"0.70266503",
... | 0.77698314 | 0 |
Returns the repl of the object | def __repr__(self):
return f"Color('{self.color}')" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repl(self):\n raise NotImplementedError",
"def __repr__(self):\n\n rep = \"\"\n rep += str(self.literal)+\"\\n\"\n rep += str(self.bindings)+\"\\n\"\n rep += str(self.facts)+\"\\n\"\n return (rep)",
"def repr_(object_):\n return repr(object_)",
"def __repr__(s... | [
"0.7053237",
"0.6670055",
"0.63939816",
"0.62073827",
"0.61711717",
"0.608401",
"0.6063401",
"0.5965866",
"0.5965866",
"0.5965866",
"0.59549594",
"0.5933642",
"0.5890286",
"0.587594",
"0.587594",
"0.587594",
"0.587594",
"0.587594",
"0.587594",
"0.587594",
"0.587594",
"0.587... | 0.0 | -1 |
Verifies that operations fail on expired/missing claims. Methods should raise an exception when the claim doesn't exists and/or has expired. | def test_claim_doesnt_exist(self):
epoch = '000000000000000000000000'
self.assertRaises(storage.exceptions.ClaimDoesNotExist,
self.controller.get, self.queue_name,
epoch, project=self.project)
claim_id, messages = self.controller.create(self.q... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_token_claims(self, claims):\n if not self.assertion_validator.validate_required(\n claims, self._required_claims\n ):\n log.debug('Missing required claims. %s', claims)\n raise errors.MissingRequiredClaimError(\n description='One or mor... | [
"0.6694668",
"0.6213893",
"0.6140498",
"0.60564893",
"0.60551244",
"0.5883677",
"0.5877712",
"0.58623165",
"0.57845736",
"0.5756104",
"0.57401115",
"0.5739251",
"0.5720034",
"0.5718771",
"0.57158107",
"0.57065064",
"0.5696911",
"0.5623538",
"0.5617701",
"0.56163347",
"0.56085... | 0.7136603 | 0 |
Set up switches for Cozytouch component. Switches are based same device class as heater in Cozytouch. | async def async_setup_entry(hass, config_entry, async_add_entities):
setup = hass.data[DOMAIN][config_entry.unique_id]
entities = []
for heater in setup.heaters:
entities.append(CozytouchSwitch(heater))
async_add_entities(entities, True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_to_switches(self):\n for p4switch in self.topo.get_p4switches():\n thrift_port = self.topo.get_thrift_port(p4switch)\n self.controllers[p4switch] = SimpleSwitchThriftAPI(thrift_port)",
"def setup_platform(hass, config, add_devices, discovery_info=None):\n name = config... | [
"0.65123296",
"0.63555175",
"0.6256502",
"0.6229577",
"0.6218826",
"0.6209023",
"0.6204552",
"0.6198191",
"0.6165805",
"0.60969234",
"0.6045364",
"0.60374457",
"0.60279906",
"0.6019495",
"0.59347916",
"0.5932955",
"0.59136355",
"0.58143383",
"0.57802683",
"0.57626027",
"0.575... | 0.5691208 | 28 |
Return the unique id of this switch. | def unique_id(self):
return self.heater.id + "_switch" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_id(self) -> str:\n return f\"{self._inst.lower()}-{self._sid_data['sid']}_switch-{self._data[self._sid_data['sid_ref']]}\"",
"def unique_id(self):\n return f\"{self._mac_address}:{self._device_id}:{self._zone_id}:switch\"",
"def unique_id(self) -> str:\n return f\"{self._inst.lo... | [
"0.87085086",
"0.84749526",
"0.82009625",
"0.80656266",
"0.78457135",
"0.7814984",
"0.774047",
"0.774047",
"0.774047",
"0.774047",
"0.77301353",
"0.77301353",
"0.7700664",
"0.7664124",
"0.7664124",
"0.7664124",
"0.7664124",
"0.7664124",
"0.7664124",
"0.7664124",
"0.7664124",
... | 0.8852805 | 0 |
Return the display name of this switch. | def name(self):
return self.heater.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_display_name(self):\n return self.display_name",
"def get_display_name(self):\n\n return self._display_name",
"def get_display_name(self):\n return DisplayText(self._display_name)",
"def display_name(self) -> str:\n return pulumi.get(self, \"display_name\")",
"def displa... | [
"0.83004475",
"0.82291013",
"0.82227296",
"0.8164862",
"0.8164862",
"0.8164862",
"0.8164862",
"0.8164862",
"0.8164862",
"0.8164862",
"0.8164862",
"0.8164862",
"0.8164862",
"0.8164862",
"0.8164862",
"0.81415564",
"0.80937237",
"0.8086217",
"0.8086217",
"0.8086217",
"0.8086217"... | 0.0 | -1 |
Return the device class. | def device_class(self):
return "heat" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\r\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_clas... | [
"0.91731",
"0.916097",
"0.916097",
"0.916097",
"0.916097",
"0.916097",
"0.90751135",
"0.9070435",
"0.90700305",
"0.9045384",
"0.9005979",
"0.9005979",
"0.9005979",
"0.8895049",
"0.88414824",
"0.88414824",
"0.88129085",
"0.874694",
"0.87423843",
"0.87423843",
"0.87018865",
"... | 0.7379799 | 54 |
Test updating an existing row. | def test_update(self):
saver = ReportStatsDBAccessor("myreport", self.manifest_id)
returned_obj = saver._get_db_obj_query()
self.assertEqual(returned_obj.first().report_name, "myreport")
saver.update(
cursor_position=33,
last_completed_datetime=parser.parse("201... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_record(self):\n pass",
"def test_update(self, commit, expected, db):\n user = ExampleUserModel(username=\"foo\", email=\"foo@bar.com\")\n user.save()\n user.update(commit=commit, username=\"bar\")\n retrieved = db.session.execute(\"\"\"select * from testusers\"\... | [
"0.80022866",
"0.74984866",
"0.7450605",
"0.74160373",
"0.72862136",
"0.72231627",
"0.72231627",
"0.72231627",
"0.71945214",
"0.7020677",
"0.6884862",
"0.68618435",
"0.68162286",
"0.6805633",
"0.6748307",
"0.67288584",
"0.67162484",
"0.66855335",
"0.6659906",
"0.664967",
"0.6... | 0.0 | -1 |
Converts the name into a safe name on Android. | def safe_formal_name(name):
return re.sub(r"\s+", " ", re.sub(r'[!/\\:<>"\?\*\|]', "", name)).strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_safe_name(name: str) -> str:\n return regex_replace(r'\\-|\\.|:', \"\", name.replace(' ', '_'))",
"def normalize_name(cls, name):\n\t\treturn ' '.join(name.lower().strip().split())",
"def normalize_name(cls, name):\n\t\treturn ' '.join(name.lower().strip().split())",
"def normalize_name(cls, name):... | [
"0.6718424",
"0.6585809",
"0.6585809",
"0.6585809",
"0.65619147",
"0.654992",
"0.6507024",
"0.6464951",
"0.6418022",
"0.64071774",
"0.63311315",
"0.6322542",
"0.62818384",
"0.6256119",
"0.62448776",
"0.6242813",
"0.62094414",
"0.6195388",
"0.61888885",
"0.6183957",
"0.613894"... | 0.0 | -1 |
The path to the bundle for the app in the output format. The bundle is the templategenerated source form of the app. The path will usually be a directory, the existence of which is indicative that the template has been rolled out for an app. This overrides the default behavior, using a "safe" formal name | def bundle_path(self, app):
return (
self.platform_path / self.output_format / safe_formal_name(app.formal_name)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _bundle(self):\n # Default to DEFAULT_BUNDLE_NAME\n bundle_path = os.path.join(self.working_dir, DEFAULT_BUNDLE_NAME)\n return self.config['app'].get('bundle', bundle_path)",
"def get_bundle_file():\n if FLAGS.bundle_file is None:\n return None\n else:\n return os.path.expanduser... | [
"0.74816334",
"0.70072097",
"0.6831255",
"0.65515965",
"0.65515965",
"0.6485309",
"0.62016255",
"0.6141556",
"0.60853475",
"0.6048171",
"0.603771",
"0.60202736",
"0.5977583",
"0.59425217",
"0.5933437",
"0.5876704",
"0.5876704",
"0.58758",
"0.58705336",
"0.58670247",
"0.585420... | 0.833258 | 0 |
String representation for debugging. | def __repr__(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug_string(self):\n\n raise NotImplementedError",
"def str(self):\n out = \"{0}:\".format(self.gtype) if self.gtype else \"\"\n out += \"{0}\".format(repr(self.coords))\n out += \"[{0}]\".format(str(self.goalPtr)) if self.goalPtr else \"\"\n return out",
"def __str__(se... | [
"0.8545374",
"0.8019418",
"0.79999775",
"0.7790358",
"0.7776434",
"0.770187",
"0.76717454",
"0.7651955",
"0.75883985",
"0.75883985",
"0.75689715",
"0.75689715",
"0.75689715",
"0.75689715",
"0.75689715",
"0.75689715",
"0.75689715",
"0.75689715",
"0.75689715",
"0.75689715",
"0.... | 0.0 | -1 |
Test for GULP 'badly_conditioned_spline' error encountered when writing Basak potential | def test_badly_conditioned_spline(tmpdir):
gulp_input = u"""single
cell
5.468 5.468 5.468 90.0 90.0 90.0
frac
U 0 0 0
U 1/2 1/2 0
U 1/2 0 1/2
U 0 1/2 1/2
O 1/4 1/4 1/4
O 1/4 3/4 1/4
O 3/4 3/4 1/4
O 3/4 1/4 1/4
O 1/4 1/4 3/4
O 1/4 3/4 3/4
O 3/4 3/4 3/4
O 3/4 1/4 3/4
species
U 2.4
O -1.2
include potentials.lib"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bspline_no_points_given() -> None:\n with pytest.raises(ValueError):\n BSplineCurve(np.array([]))",
"def test_no_specification_error():\n try:\n bad_arm = survey.get_spiral_slice()\n except SyntaxError:\n assert True\n else:\n assert False",
"def test_Sobol_G_ra... | [
"0.62505066",
"0.6221024",
"0.61017287",
"0.60776955",
"0.6071846",
"0.60522187",
"0.6028767",
"0.59276116",
"0.5904576",
"0.58011734",
"0.5792597",
"0.5716259",
"0.5684793",
"0.567701",
"0.5640711",
"0.5633147",
"0.5614474",
"0.5607474",
"0.55917287",
"0.5569866",
"0.5555658... | 0.73258084 | 0 |
Add Vertex to graph | def add_vertex(self, label=None, properties=None, current_id=None):
if current_id is None:
done = False
while not done:
next_id = self.get_next_id()
if next_id not in self.vertices:
current_id = next_id
done = True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, vertex):\n raise NotImplementedError",
"def add_vertex(self, vertex):\n self.vertices.append(vertex)\n self.vertex_edge[vertex] = []",
"def add_vertex(self, vertex_id):\n pass # TODO",
"def add_vertex(self, vertex):\n if vertex not in self.__graph_dict... | [
"0.84831476",
"0.8374248",
"0.8256224",
"0.82480884",
"0.82480884",
"0.8217305",
"0.82042694",
"0.8159382",
"0.815056",
"0.81291944",
"0.80719405",
"0.8069006",
"0.80379397",
"0.80282456",
"0.8014925",
"0.8013942",
"0.7999782",
"0.7998408",
"0.79315525",
"0.79189837",
"0.7828... | 0.724511 | 56 |
Add edge to graph | def add_edge(self, current_id=None, in_vertex_id=None, out_vertex_id=None, label=None, properties=None):
if current_id is None:
done = False
while not done:
next_id = self.get_next_id()
if next_id not in self.edges:
current_id = next_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, edge):\n if(self.has_edge(edge) == 0):\n self.__graph_dict[edge[0]].append(edge[1])",
"def add_edge(self, edge):\n src = edge.get_source()\n dest = edge.get_destination()\n #weightEdge = WeightedEdge(src, dest, edge.get_total_distance(), edge.get_outdoor_... | [
"0.84528124",
"0.8388235",
"0.8271909",
"0.8251631",
"0.823839",
"0.81696016",
"0.81525034",
"0.8130112",
"0.81174165",
"0.8095377",
"0.80940336",
"0.80918396",
"0.80908763",
"0.80584824",
"0.80436015",
"0.8036798",
"0.802385",
"0.8018984",
"0.7985269",
"0.79833496",
"0.79631... | 0.0 | -1 |
Return the bitmap filename. | def GetFilename(self):
return self._filename | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acquire_image_filename(self):\n\t\titem_key = self.contents_data[ITEM_KEY]\n\t\tif not item_key: return None\n\t\treturn \"portrait_\" + item_key + \".bmp\"",
"def get_image_filename(self, filename):\n path = 'images/{folder}/{filename}'.format(\n folder=self.folder,\n filename=filename\n ... | [
"0.7694652",
"0.71375257",
"0.71177137",
"0.71148324",
"0.70119977",
"0.69819796",
"0.6928454",
"0.68453723",
"0.6795147",
"0.6772218",
"0.6764465",
"0.67536247",
"0.67435664",
"0.6724111",
"0.6709293",
"0.669675",
"0.6671853",
"0.66673887",
"0.6662574",
"0.6662024",
"0.66606... | 0.0 | -1 |
Assume that n1, n2 are positive integers Returns a tuple containing smallest common divisor > 1 and largest common divisor of n1 and n2. If no common divisor, returns (None, None) | def findExtremeDivisor(n1, n2):
minVal, maxVal = (None, None)
for i in range (2, min(n1, n2) + 1):
if n1 % i == 0 and n2 % i == 0:
if minVal == None:
minVal = i
maxVal = i
return (minVal, maxVal) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findExtremeDivisors(n1, n2):\n\n minVal, maxVal = None, None\n for i in range(2, min(n1, n2)+1):\n if n1%i == 0 and n2%i == 0:\n if minVal == None:\n minVal = i\n maxVal = i\n return (minVal, maxVal)",
"def findDivisors(n1, n2):\n divisors = () # the em... | [
"0.7895104",
"0.7590045",
"0.7551443",
"0.7527995",
"0.75163907",
"0.7449581",
"0.73202807",
"0.7145385",
"0.71237224",
"0.71205586",
"0.7119193",
"0.70423496",
"0.7010799",
"0.69791824",
"0.6941742",
"0.69291675",
"0.68756026",
"0.68261284",
"0.6815777",
"0.68140095",
"0.679... | 0.78746074 | 1 |
Returns lagged subsequences of a given sequence, this allows the model to receive the input from the past targets outside the sliding windows. This implementation is similar to gluonTS's implementation the only difference is that we pad the sequence that is not long enough | def get_lagged_subsequences(
sequence: torch.Tensor,
subsequences_length: int,
lags_seq: Optional[List[int]] = None,
mask: Optional[torch.Tensor] = None
) -> Tuple[torch.Tensor, Optional[torch.Tensor]]:
batch_size = sequence.shape[0]
num_features = sequence.shape[2]
if mask i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lagged_subsequences_inference(\n sequence: torch.Tensor,\n subsequences_length: int,\n lags_seq: List[int]) -> torch.Tensor:\n sequence_length = sequence.shape[1]\n batch_size = sequence.shape[0]\n lagged_values = []\n for lag_index in lags_seq:\n begin_index = -lag_... | [
"0.79449797",
"0.7679756",
"0.6363476",
"0.62020797",
"0.6181386",
"0.6178807",
"0.61282563",
"0.60695344",
"0.5976677",
"0.59474504",
"0.58481675",
"0.5840416",
"0.58296466",
"0.5794847",
"0.5771518",
"0.5771236",
"0.5756376",
"0.5751138",
"0.5749928",
"0.57133156",
"0.56910... | 0.79312795 | 1 |
pad tensor to meet the required length | def pad_tensor(self, tensor_to_be_padded: torch.Tensor, target_length: int) -> torch.Tensor:
tensor_shape = tensor_to_be_padded.shape
padding_size = [tensor_shape[0], target_length - tensor_shape[1], tensor_shape[-1]]
tensor_to_be_padded = torch.cat([tensor_to_be_padded.new_zeros(padding_size), ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad(tensor, num=1):\n return tf.pad(tensor, [[0, 0], [num, num], [num, num], [0, 0]], \"CONSTANT\")",
"def pad_tensor(tensor, length, padding_index=PADDING_INDEX):\n n_padding = length - tensor.shape[0]\n assert n_padding >= 0\n if n_padding == 0:\n return tensor\n padding = tensor.new(... | [
"0.7798389",
"0.7697797",
"0.76575756",
"0.76342046",
"0.7632129",
"0.75900644",
"0.7464474",
"0.7281519",
"0.72158617",
"0.7154794",
"0.7148223",
"0.7127681",
"0.70717615",
"0.7066624",
"0.70175695",
"0.6992459",
"0.69829285",
"0.6937472",
"0.6919333",
"0.69174874",
"0.68749... | 0.77046025 | 1 |
Maps a screen space point into the "index" space of the plot. Implements the AbstractPlotRenderer interface. | def map_data(self, screen_pt):
if self.orientation == 'h':
x, y = screen_pt
else:
y,x = screen_pt
return array((self.index_mapper.map_data(x),
self.value_mapper.map_data(y))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid_to_index(mapdata, x, y):\n i = (y * mapdata.info.width) + x\n return int (i)",
"def i_index(self, coord):\n return coord + 1 if coord + 1 > self.dimensions - 1 else 0",
"def xy_to_index(x, y):\n index = y * columns + x\n return index",
"def get_index(self, point, cell_size... | [
"0.61124253",
"0.5953397",
"0.57309145",
"0.5716991",
"0.56515443",
"0.5559498",
"0.55279315",
"0.55175054",
"0.5507188",
"0.5507188",
"0.55001485",
"0.5494117",
"0.54517835",
"0.5424788",
"0.53762674",
"0.5370705",
"0.5368631",
"0.5345835",
"0.5341659",
"0.5336567",
"0.53296... | 0.59073997 | 2 |
Return a valid Elasticsearch client object | def get_client():
client = Elasticsearch(host=HOST, port=PORT, timeout=300)
# wait for yellow status
for _ in range(100):
time.sleep(.1)
try:
# This errors because of decorators. Silence it.
# pylint: disable=E1123
client.cluster.health(wait_for_status=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_es_client(conf):\n return elasticsearch_client(conf)",
"def _create_es_client(self):\n from elasticsearch._async.client import AsyncElasticsearch\n\n use_basic_auth = self._username is not None and self._password is not None\n\n serializer = get_serializer()\n\n if use... | [
"0.80958706",
"0.73511314",
"0.72903967",
"0.6976422",
"0.68609506",
"0.6821079",
"0.67806816",
"0.6768928",
"0.67556524",
"0.6750968",
"0.6635067",
"0.6613933",
"0.6481584",
"0.64225805",
"0.63645875",
"0.6296709",
"0.6282455",
"0.62577593",
"0.62560034",
"0.6253603",
"0.625... | 0.7351269 | 1 |
Test that a Wigner object can be successfully reconstructed from its repr() output with no loss of information. | def test_repr(self):
namespace = {}
exec('tunneling = {0!r}'.format(self.tunneling), globals(), namespace)
self.assertIn('tunneling', namespace)
tunneling = namespace['tunneling']
self.assertAlmostEqual(self.tunneling.frequency.value, tunneling.frequency.value, 2)
self.as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_repr(self):\n dummy = DummyCryptographicObject()\n repr(dummy)",
"def test_repr(self, r, rep):\n assert repr(r) == rep",
"def test_repr(self):\n self.assertTrue(repr(self.obj1))\n self.assertTrue(repr(self.obj2))\n self.assertTrue(repr(self.obj3))\n sel... | [
"0.74062407",
"0.71504724",
"0.7120728",
"0.7020727",
"0.701199",
"0.69874465",
"0.6890161",
"0.68644017",
"0.68616515",
"0.6854533",
"0.6844324",
"0.680833",
"0.679797",
"0.67277485",
"0.67127997",
"0.66974735",
"0.6632023",
"0.6618176",
"0.66134274",
"0.66116977",
"0.658434... | 0.6105705 | 51 |
Test that an Eckart object can be successfully reconstructed from its repr() output with no loss of information. | def test_repr(self):
namespace = {}
exec('tunneling = {0!r}'.format(self.tunneling), globals(), namespace)
self.assertIn('tunneling', namespace)
tunneling = namespace['tunneling']
self.assertAlmostEqual(self.tunneling.frequency.value, tunneling.frequency.value, 2)
self.as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_repr():\n c = Circle(4) \n assert c.__repr__() == 'Circle(4)'",
"def test_repr(self):\n dummy = DummyCryptographicObject()\n repr(dummy)",
"def test_repr(self):\n self.assertTrue(repr(self.obj1))\n self.assertTrue(repr(self.obj2))\n self.assertTrue(repr(self.ob... | [
"0.7420796",
"0.7355144",
"0.7324702",
"0.72870576",
"0.72741735",
"0.7206706",
"0.718442",
"0.7026614",
"0.70026714",
"0.69436586",
"0.6884402",
"0.6757946",
"0.6755908",
"0.67521465",
"0.67182326",
"0.6702292",
"0.6698909",
"0.66903406",
"0.66657907",
"0.64848197",
"0.64756... | 0.58488035 | 75 |
Generates a random token with a length that is > 8 and < 32. | def generateToken():
length = random.randint(8, 32)
rdmtoken = ''.join(random.choice(string.printable) for i in range(length))
return f'{rdmtoken}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateToken():\n token_length = random.randint(MIN_TOKEN_LEN, MAX_TOKEN_LEN)\n token = ''.join(random.choice(POSS_TOKEN_CHARS) for _ in range(token_length))\n return token",
"def generate_token(length=30, chars=UNICODE_ASCII_CHARACTER_SET):\n rand = random.SystemRandom()\n return ''.join(ran... | [
"0.8160557",
"0.81090844",
"0.81090844",
"0.80169296",
"0.7991109",
"0.7943382",
"0.78063107",
"0.74373037",
"0.7372431",
"0.7357069",
"0.722048",
"0.71543074",
"0.70842046",
"0.7074404",
"0.6992788",
"0.6985047",
"0.691498",
"0.6879978",
"0.683083",
"0.67666435",
"0.67290694... | 0.8017513 | 3 |
Add a new experience to memory. | def add(self, state, action, reward, next_state, done):
e = self.experience(state, action, reward, next_state, done)
self.memory.append(e)
if done and self.episode % 50 == 0 and self.episode > 50:
self.episode += 1
self.remove_bad_experience()
elif done:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_experience(self, state, action, reward, next_state, done):\n e = self.experience(state, action, reward, next_state, done, self.max_priority)\n self.memory.append(e)",
"def add(self, state, action, reward, next_state, done):\n experience = Experience(state, action, reward, next_st... | [
"0.79575163",
"0.7904917",
"0.7880746",
"0.7578514",
"0.75727165",
"0.7448136",
"0.7361892",
"0.7218082",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.7146643",
"0.... | 0.72705156 | 7 |
Return the current average reward of internal memory. | def average(self):
total = 0
for t in self.memory:
total += t.reward
return total/self.__len__() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_reward(self):\n \n ##get total reward value from Q\n total_reward = 0.0\n for value in self.Q.itervalues():\n total_reward = total_reward + value\n \n ##return the average reward\n return total_reward",
"def get_reward(self):\n \n ... | [
"0.77477986",
"0.77477986",
"0.76918787",
"0.76674396",
"0.74763596",
"0.74763596",
"0.74763596",
"0.72849846",
"0.7250452",
"0.7010016",
"0.6913787",
"0.6913787",
"0.6909059",
"0.6890584",
"0.6829755",
"0.68206453",
"0.6819818",
"0.6798162",
"0.6766177",
"0.6750567",
"0.6725... | 0.8633403 | 0 |
Return the current size of internal memory. | def __len__(self):
return len(self.memory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSize(self) -> int:\n return len(self.mem)",
"def getSize(self):\n return self.bf.memory()",
"def memsize(self):\n return self.xlist(\"get-memsize\")[1][0] * 1024",
"def size(self):\n size = 0\n size += self.data.size * sys.getsizeof(self.data)\n return size / ... | [
"0.8571074",
"0.8215767",
"0.8198132",
"0.80832005",
"0.8020808",
"0.7889389",
"0.78188926",
"0.7797308",
"0.778622",
"0.775998",
"0.77557904",
"0.7751391",
"0.7751391",
"0.7750454",
"0.77327937",
"0.77303255",
"0.7716953",
"0.77102315",
"0.770489",
"0.77028936",
"0.7694357",... | 0.7512535 | 60 |
Returns a boolean value representing if int n is a prime number. Recursive implementation. | def is_prime(n):
if n==1:
return True
def prime_helper(divisor):
if divisor == 1:
return True
elif n % divisor == 0:
return False
else:
return prime_helper(divisor-1)
return prime_helper(n//2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isprime(n):\n\treturn is_prime(n)",
"def isprime(n):\r\n\treturn is_prime(n)",
"def isprime(n: int) -> bool:\r\n if n > 1:\r\n for i in range(2, int(n / 2) + 1):\r\n if (n % i) == 0:\r\n return False\r\n else:\r\n return True\r\n\r\n else:\r\n ... | [
"0.87610006",
"0.8757511",
"0.8605975",
"0.85548127",
"0.8515093",
"0.84381217",
"0.8408406",
"0.83987904",
"0.8398676",
"0.83806413",
"0.83526146",
"0.8344468",
"0.83412135",
"0.8332709",
"0.83325803",
"0.83299595",
"0.8321076",
"0.83180386",
"0.8310392",
"0.8308565",
"0.830... | 0.8252106 | 33 |
Convert axisangle representation to rotation matrix. | def batch_rodrigues(theta, dtype=torch.float32):
l1norm = torch.norm(theta + 1e-8, p = 2, dim = 1)
angle = torch.unsqueeze(l1norm, -1)
normalized = torch.div(theta, angle)
angle = angle * 0.5
v_cos = torch.cos(angle)
v_sin = torch.sin(angle)
quat = torch.cat([v_cos, v_sin * normalized], dim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def axis2rotmat(axis):\n return quat2rotmat(axis2quat(axis))",
"def rotation_matrix(angle, axis):\n about_z = rotation_about_z(angle)\n z_to_axis = z_to_vector(axis)\n axis_to_z = np.linalg.inv(z_to_axis)\n return reduce(np.dot, [z_to_axis, about_z, axis_to_z])",
"def angle_to_rotation_matrix(an... | [
"0.7975021",
"0.7776975",
"0.7642057",
"0.75718856",
"0.7484483",
"0.73852175",
"0.7374227",
"0.7331798",
"0.7323808",
"0.72060734",
"0.7166385",
"0.7143978",
"0.71211976",
"0.7071612",
"0.70691985",
"0.7067156",
"0.7056157",
"0.7056157",
"0.7034615",
"0.7027953",
"0.7001234"... | 0.0 | -1 |
Convert quaternion coefficients to rotation matrix. | def quat_to_rotmat(quat):
norm_quat = quat
norm_quat = norm_quat/norm_quat.norm(p=2, dim=1, keepdim=True)
w, x, y, z = norm_quat[:,0], norm_quat[:,1], norm_quat[:,2], norm_quat[:,3]
B = quat.size(0)
w2, x2, y2, z2 = w.pow(2), x.pow(2), y.pow(2), z.pow(2)
wx, wy, wz = w*x, w*y, w*z
xy, xz,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quaternion_to_rotation_matrix(quaternion):\n\n q_w, q_x, q_y, q_z = quaternion\n sqw, sqx, sqy, sqz = np.square(quaternion)\n norm = (sqx + sqy + sqz + sqw)\n rotation_matrix = np.zeros((3, 3))\n\n # division of square length if quaternion is not already normalized\n rotation_matrix[0, 0] = (... | [
"0.7666401",
"0.7480785",
"0.74480975",
"0.7431791",
"0.7220662",
"0.72003317",
"0.7190068",
"0.7073628",
"0.6884496",
"0.6882422",
"0.6881994",
"0.685318",
"0.68479955",
"0.68037885",
"0.67919123",
"0.677245",
"0.6759796",
"0.672846",
"0.670579",
"0.66775787",
"0.6654148",
... | 0.6941468 | 8 |
Convert 6D rotation representation to 3x3 rotation matrix. Based on Zhou et al., "On the Continuity of Rotation Representations in Neural Networks", CVPR 2019 | def rot6d_to_rotmat(x):
x = x.view(-1,3,2)
a1 = x[:, :, 0]
a2 = x[:, :, 1]
b1 = F.normalize(a1)
b2 = F.normalize(a2 - torch.einsum('bi,bi->b', b1, a2).unsqueeze(-1) * b1)
b3 = torch.cross(b1, b2)
return torch.stack((b1, b2, b3), dim=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rot6d_to_rotmat(x):\n x = x.view(-1, 3, 2)\n a1 = x[:, :, 0]\n a2 = x[:, :, 1]\n b1 = F.normalize(a1)\n b2 = F.normalize(a2 - torch.einsum('bi,bi->b', b1, a2).unsqueeze(-1) * b1)\n b3 = torch.cross(b1, b2)\n return torch.stack((b1, b2, b3), dim=-1)",
"def rot6d_to_rotmat(x):\n x = x.v... | [
"0.77543277",
"0.77543277",
"0.6994243",
"0.6880496",
"0.66545445",
"0.6611445",
"0.65356976",
"0.6473208",
"0.64339525",
"0.63568383",
"0.63190615",
"0.6281378",
"0.62577486",
"0.6244173",
"0.62424606",
"0.6231454",
"0.6197409",
"0.61918074",
"0.6186133",
"0.6180842",
"0.617... | 0.7786343 | 0 |
Calculate absolute magnitude from apparent magnitude and distance in meters | def apparent_to_absolute_magnitude(apparent_magnitude, distance):
distance_in_parsecs = distance / (648000. * astronomical_unit / np.pi)
absolute_magnitude = apparent_magnitude - 5*np.log10(distance_in_parsecs) + 5
return absolute_magnitude | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magabs(self):\n if not self.has_target():\n raise AttributeError(\"No target defined, I can't get the distance\")\n return self.mag - 5*( np.log10(self.target.distmpc*1.e6) - 1)",
"def absolute_magnitude(self):\n return self._absolute_magnitude",
"def magnitude(self):\n\t\tr... | [
"0.75686187",
"0.7425207",
"0.721044",
"0.71361697",
"0.7103473",
"0.70636183",
"0.70636183",
"0.7009219",
"0.6989118",
"0.6947378",
"0.6882786",
"0.6879637",
"0.66928095",
"0.664699",
"0.66155505",
"0.66040146",
"0.6582494",
"0.65506285",
"0.65086395",
"0.64651424",
"0.64219... | 0.76287776 | 0 |
Get the latest data from the sensor and update the state. | def update(self):
self.data_service.update()
self._state = self.data_service.data[self._json_key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n if self._api is not None:\n \"\"\"Fetch the latest data\"\"\"\n self._api.get()\n \n \"\"\"set our sensor values\"\"\"\n self._current_temperature = self._api._temperature\n self._current_humidity = self._api._humidity\n ... | [
"0.7439651",
"0.73668504",
"0.73454905",
"0.7332049",
"0.73009586",
"0.72067946",
"0.7145198",
"0.7052421",
"0.70145845",
"0.69574773",
"0.69449365",
"0.6904694",
"0.68926984",
"0.6854156",
"0.67607087",
"0.669671",
"0.6642103",
"0.6639291",
"0.6602712",
"0.6583256",
"0.65775... | 0.6523815 | 22 |
Return the state attributes. | def device_state_attributes(self):
return self._attributes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.8273077",
"0.82236886",
"0.8223562",
"0.8205066",
"0.8184393",
"0.81659013",
"0.8102565",
"0.8064994",
"0.8064994",... | 0.82871646 | 24 |
Return the state attributes. | def device_state_attributes(self):
return self._attributes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.8273077",
"0.82236886",
"0.8223562",
"0.8205066",
"0.8184393",
"0.81659013",
"0.8102565",
"0.8064994",
"0.8064994",... | 0.82871646 | 21 |
Initialize the power flow sensor. | def __init__(self, platform_name, sensor_key, data_service):
super().__init__(platform_name, sensor_key, data_service)
self._json_key = SENSOR_TYPES[self.sensor_key][0]
self._attributes = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize(self):\n self.flush()\n print(\"Initializing sensor...\")\n try:\n self.get_sample()\n print('Initialization successful')\n except:\n print('Initialization failed. Please disconnect and reconnect sensor.')",
"def init(self):\n se... | [
"0.6835123",
"0.6644227",
"0.66136813",
"0.6346254",
"0.6305805",
"0.63017976",
"0.62985486",
"0.6256741",
"0.62453306",
"0.6230699",
"0.6230349",
"0.6223901",
"0.62211394",
"0.6200156",
"0.6111567",
"0.60943276",
"0.6092511",
"0.6074873",
"0.6073007",
"0.60725117",
"0.604756... | 0.0 | -1 |
Return the state attributes. | def device_state_attributes(self):
return self._attributes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.8273077",
"0.82236886",
"0.8223562",
"0.8205066",
"0.8184393",
"0.81659013",
"0.8102565",
"0.8064994",
"0.8064994",... | 0.82871646 | 23 |
Initialize the power flow sensor. | def __init__(self, platform_name, sensor_key, data_service):
super().__init__(platform_name, sensor_key, data_service)
self._json_key = SENSOR_TYPES[self.sensor_key][0]
self._attributes = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize(self):\n self.flush()\n print(\"Initializing sensor...\")\n try:\n self.get_sample()\n print('Initialization successful')\n except:\n print('Initialization failed. Please disconnect and reconnect sensor.')",
"def init(self):\n se... | [
"0.68382084",
"0.6644406",
"0.66150683",
"0.63486034",
"0.6305984",
"0.6303345",
"0.6299833",
"0.62570703",
"0.62462556",
"0.62320715",
"0.6231465",
"0.62231946",
"0.62231505",
"0.62011117",
"0.61137176",
"0.609516",
"0.60939276",
"0.60756874",
"0.6074491",
"0.6073898",
"0.60... | 0.0 | -1 |
Return the state attributes. | def device_state_attributes(self):
return self._attributes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.8273077",
"0.82236886",
"0.8223562",
"0.8205066",
"0.8184393",
"0.81659013",
"0.8102565",
"0.8064994",
"0.8064994",... | 0.82871646 | 22 |
Return the device_class of the device. | def device_class(self):
return DEVICE_CLASS_BATTERY | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class"... | [
"0.8983246",
"0.8983246",
"0.8983246",
"0.8983246",
"0.8983246",
"0.8932369",
"0.8920512",
"0.8858923",
"0.8786422",
"0.8713565",
"0.86982346",
"0.8605397",
"0.8605397",
"0.8605397",
"0.85082746",
"0.8476465",
"0.8469167",
"0.8462864",
"0.8374014",
"0.8368908",
"0.8368908",
... | 0.681239 | 58 |
Canny edge detector finds all edges in an image. The user is required to specify the type of edge they are looking for. | def find_edges(img, colorimg):
# Start with all edges
edges = cv2.Canny(img, 0, 0)
# Create a black image, a window
cv2.namedWindow("Edges")
# create trackbars for edge params
cv2.createTrackbar("Min", "Edges", 0, 1000, nothing)
cv2.createTrackbar("Max", "Edges", 0, 1000, nothing)
whi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edge_detect_canny(gray_img):\n\n edges = cv2.Canny(gray_img, 100, 200)\n\n return edges",
"def edgeDetection(input_img, input_mode, sigma=1, output_path=None):\n\n if input_mode == 'fp':\n np_img = loadImage(input_img)\n elif input_mode == 'np':\n np_img = input_img\n else:\n ... | [
"0.77783626",
"0.7586976",
"0.74616116",
"0.73955643",
"0.7351781",
"0.7206633",
"0.708626",
"0.7039831",
"0.6972133",
"0.6937285",
"0.6899475",
"0.68814063",
"0.6842917",
"0.671484",
"0.67116356",
"0.67091995",
"0.66940844",
"0.66704136",
"0.66427654",
"0.66427654",
"0.66427... | 0.68802387 | 12 |
Depth images become an XYZ point cloud in the camera frame with shape (depth.shape[0], depth.shape[1], 3). Transform a depth image into a point cloud in the camera frame with one point for each pixel in the image, using the camera transform for a camera centred at cx, cy with field of view fx, fy. | def depth_image_to_point_cloud3(depth, intrinsics_matrix, dtype=np.float32):
depth = np.squeeze(depth)
XYZ = np.zeros(depth.shape + (3,))
XYZ = depth_image_to_point_cloud_numba(depth, intrinsics_matrix, XYZ)
return XYZ.astype(dtype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_depth_frame_to_pointcloud(depth_image, camera_intrinsics ):\n\t\n\t[height, width] = depth_image.shape\n\n\tnx = np.linspace(0, width-1, width)\n\tny = np.linspace(0, height-1, height)\n\tu, v = np.meshgrid(nx, ny)\n\tx = (u.flatten() - camera_intrinsics.ppx)/camera_intrinsics.fx\n\ty = (v.flatten() - ... | [
"0.8036142",
"0.8003891",
"0.79804736",
"0.7381889",
"0.7209336",
"0.7113369",
"0.68866074",
"0.6861274",
"0.6516945",
"0.6516718",
"0.64231616",
"0.6279732",
"0.6198881",
"0.61596596",
"0.6120213",
"0.6097662",
"0.6064686",
"0.60550714",
"0.60342205",
"0.5999688",
"0.5988467... | 0.7000817 | 6 |
Depth images become an XYZ point cloud in the camera frame with shape (depth.shape[0], depth.shape[1], 3). Transform a depth image into a point cloud in the camera frame with one point for each pixel in the image, using the camera transform for a camera centred at cx, cy with field of view fx, fy. | def depth_image_to_point_cloud2(depth, intrinsics_matrix, dtype=np.float32):
depth = np.squeeze(depth)
XYZ = np.zeros(depth.shape + (3,))
fx = intrinsics_matrix[0, 0]
fy = intrinsics_matrix[1, 1]
# center of image x coordinate
center_x = intrinsics_matrix[2, 0]
# center of image y coordina... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_depth_frame_to_pointcloud(depth_image, camera_intrinsics ):\n\t\n\t[height, width] = depth_image.shape\n\n\tnx = np.linspace(0, width-1, width)\n\tny = np.linspace(0, height-1, height)\n\tu, v = np.meshgrid(nx, ny)\n\tx = (u.flatten() - camera_intrinsics.ppx)/camera_intrinsics.fx\n\ty = (v.flatten() - ... | [
"0.8035264",
"0.8002948",
"0.797926",
"0.7380857",
"0.7112001",
"0.7000127",
"0.68844193",
"0.6859599",
"0.65162104",
"0.6515538",
"0.6422377",
"0.6278209",
"0.6197755",
"0.6159936",
"0.6118683",
"0.6097045",
"0.60638094",
"0.60526395",
"0.60344243",
"0.6000417",
"0.5987926",... | 0.720821 | 4 |
Return the value of the row for a given label. | def getValue(self, label, default=None):
# Allow getValue using the label string
if isinstance(label, basestring):
label = str2Label(label)
return self._labelDict.get(label, default) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _value(self, row):\n return row[\"_source\"][self.name]",
"def get_value( self, header, rowIndex ):\n return self.data[rowIndex, self.header2col[header]]",
"def get_value(self, row, colName):\n\t\treturn self[row][self._columns[colName]]",
"def getValue(self):\n return self._row[self... | [
"0.67791533",
"0.67668504",
"0.6715832",
"0.66683626",
"0.6667606",
"0.63243765",
"0.6252401",
"0.6224381",
"0.62243116",
"0.6151942",
"0.6125786",
"0.60242116",
"0.5992618",
"0.59564614",
"0.59358144",
"0.59293705",
"0.58953416",
"0.5852173",
"0.5823469",
"0.5821814",
"0.581... | 0.62321234 | 7 |
Return another Row that have exactly the same values as self. | def clone(self):
row = Row()
row.copyFromRow(self)
row._objId = self._objId
return row | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return type(self) == type(other) and \\\n self.row == other.row and \\\n self.column == other.column",
"def similar(self, other):\r\n if self.rows == other.rows and self.columns == other.columns:\r\n return True\r\n else:\r\n ... | [
"0.6690975",
"0.63903445",
"0.6352478",
"0.6341118",
"0.62653095",
"0.6134587",
"0.61291504",
"0.60655725",
"0.5995635",
"0.5980327",
"0.5960788",
"0.59576494",
"0.5945998",
"0.59376633",
"0.5886213",
"0.5845687",
"0.57799685",
"0.5777784",
"0.5698563",
"0.5665502",
"0.565079... | 0.70134485 | 0 |
Apply attention over encoder outputs and decoder state. | def _prepare_attended_output(self,
decoder_hidden_state: torch.Tensor,
state: Dict[str, torch.Tensor]) -> torch.Tensor:
# Ensure mask is also a FloatTensor. Or else the multiplication within
# attention will complain.
# shape: (ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_attention(self, decoder_state, forward_encoder_states, backward_encoder_states):\r\n\r\n\t\tassert len(forward_encoder_states) == len(backward_encoder_states)\r\n\t\tmax_encoding_len = len(forward_encoder_states)\r\n\t\toutput_states=[]\r\n\t\tfor i in range(max_encoding_len):\r\n\t\t\tstate = np.conca... | [
"0.7470629",
"0.72167873",
"0.6937865",
"0.685253",
"0.68191606",
"0.6761815",
"0.6761237",
"0.6684725",
"0.6528291",
"0.65015036",
"0.6455645",
"0.64354664",
"0.64287335",
"0.64080626",
"0.64048934",
"0.63962084",
"0.63941085",
"0.6372968",
"0.6362276",
"0.6345817",
"0.63451... | 0.67974275 | 5 |
Compute loss. Takes logits (unnormalized outputs from the decoder) of size (batch_size, num_decoding_steps, num_classes), target indices of size (batch_size, num_decoding_steps+1) and corresponding masks of size (batch_size, num_decoding_steps+1) steps and computes cross entropy loss while taking the mask into account.... | def _get_loss(self,
logits: torch.FloatTensor,
predictions: torch.LongTensor,
targets: torch.LongTensor,
target_mask: torch.LongTensor,
candidates: torch.LongTensor = None) -> torch.Tensor:
# shape: (batch_size, num_decodi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss(self, labels, logits, mask=None):\n losses = tf.nn.softmax_cross_entropy_with_logits(tf.one_hot(labels, depth=logits.shape[-1]), logits, axis=-1)\n seq_mask = mask # logits._keras_mask# tf.sequence_mask(lengths, self.seq_len)\n loss = tf.reduce_mean(tf.boolean_mask(losses, seq_mask))\... | [
"0.70058495",
"0.6829449",
"0.6792782",
"0.6687703",
"0.66831034",
"0.66598034",
"0.65945166",
"0.65499383",
"0.64644146",
"0.64490885",
"0.6394254",
"0.63340473",
"0.63002336",
"0.6235017",
"0.61895174",
"0.61076856",
"0.6085291",
"0.60850203",
"0.6079257",
"0.6068398",
"0.6... | 0.644908 | 10 |
Setter the tag_separator used in the preprocessed file. | def set_tag_separator(self, tag_separator):
self._tag_separator = tag_separator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_separator(self, separator):\n self._separator = separator",
"def tag_separator(self):\n\n return self._tag_separator",
"def attr_sep(self, new_sep: str) -> None:\n self._attr_sep = new_sep\n self._filters_tree = self._generate_filters_tree()",
"def set_content_sep(sep):\n i... | [
"0.741412",
"0.68213713",
"0.6610436",
"0.63379514",
"0.61462694",
"0.61361474",
"0.6119814",
"0.60399306",
"0.5972268",
"0.591466",
"0.58263826",
"0.57769364",
"0.57173836",
"0.5694928",
"0.56351495",
"0.56226903",
"0.5531465",
"0.5517981",
"0.5504511",
"0.5436017",
"0.54188... | 0.8514293 | 0 |
Getter of the POS tagged abstract of the preprocessed file. | def abstract(self):
return self._abstract | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pos(self):\n if 'pos' not in self.annotators:\n return None\n return [t[self.POS] for t in self.data]",
"def pos(self):\n if 'pos' not in self.annotators:\n return None\n return [t[self.POS] for t in self.data]",
"def get_paper_abstract(tree):\n\tpath = '//... | [
"0.5791895",
"0.5791895",
"0.5547595",
"0.5431506",
"0.5342566",
"0.52070963",
"0.5190056",
"0.51679295",
"0.5111183",
"0.5094322",
"0.50934464",
"0.5073222",
"0.50289243",
"0.50100195",
"0.4988212",
"0.49493816",
"0.49490637",
"0.49390373",
"0.49315926",
"0.4926357",
"0.4925... | 0.55036986 | 3 |
Returns the top rank for this program in the applicantList 1 if applicantList is empty | def GetTopRankInApplicantList(self, applicantList):
topRank = -1
for eachApplicant in applicantList:
applicantRank = self.GetApplicantRank(eachApplicant)
if topRank == -1 or applicantRank < topRank:
topRank = applicantRank
return topRank | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def FindLowestRankedApplicantInList(self, applicantList):\n tempRankList = [] #collection of rank spots\n\n for eachApplicant in applicantList:\n tempRankList.append(self.GetApplicantRank(eachApplicant))\n\n #will sort descending, so lowest ranked applicant is first\n #pdb.se... | [
"0.70736176",
"0.7000888",
"0.69737595",
"0.63719654",
"0.6267562",
"0.61305654",
"0.61280423",
"0.6035504",
"0.60074246",
"0.59447724",
"0.5842976",
"0.57497114",
"0.5712175",
"0.5712175",
"0.5712175",
"0.5678015",
"0.564668",
"0.5640155",
"0.5625737",
"0.5565436",
"0.555263... | 0.82299405 | 0 |
Distribution of browser of the visitors given an OS. | def get_browser_distribution(self, os_id):
ids = []
probabilities = []
sql = "SELECT * FROM [browser_by_os] WHERE [os_id]=%d"%(os_id)
rows = self.cursor.execute(sql)
for row in rows:
ids.append(int(row["browser_id"]))
probabilities.append(float(row["probab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_browser(request):\n #get the META data about the browser type\n browser=request.META['HTTP_USER_AGENT']\n #make META data all lowercase\n browser=browser.lower()\n #for firefox\n if 'firefox' in browser:\n browser='firefox'\n #for chrome\n elif 'chrome' in browser:\n ... | [
"0.6027",
"0.595808",
"0.5776524",
"0.5774975",
"0.5723559",
"0.5644563",
"0.5621359",
"0.5621359",
"0.5559177",
"0.5556279",
"0.5516961",
"0.54802066",
"0.54746634",
"0.5455027",
"0.5393856",
"0.53758764",
"0.53655475",
"0.5334025",
"0.5323154",
"0.52898777",
"0.5285139",
... | 0.7124988 | 0 |
Initialize the weights in backbone. | def init_weights(self, pretrained=None):
if isinstance(pretrained, str):
logger = get_root_logger()
load_checkpoint(self, pretrained, strict=False, logger=logger)
elif pretrained is None:
for m in self.modules():
if isinstance(m, nn.Conv2d):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def in... | [
"0.83809745",
"0.83567804",
"0.8318618",
"0.80969334",
"0.79236996",
"0.79064524",
"0.78415686",
"0.76821744",
"0.76756763",
"0.7579746",
"0.7504763",
"0.75038546",
"0.75038546",
"0.75038546",
"0.74933714",
"0.7491974",
"0.7485691",
"0.7437889",
"0.74249136",
"0.7403326",
"0.... | 0.0 | -1 |
Initialize the weights in backbone. | def init_weights(self, pretrained=None):
if isinstance(pretrained, str):
logger = get_root_logger()
load_checkpoint(self, pretrained, strict=False, logger=logger)
elif pretrained is None:
for m in self.modules():
if isinstance(m, nn.Conv2d):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def in... | [
"0.83809745",
"0.83567804",
"0.8318618",
"0.80969334",
"0.79236996",
"0.79064524",
"0.78415686",
"0.76821744",
"0.76756763",
"0.7579746",
"0.7504763",
"0.75038546",
"0.75038546",
"0.75038546",
"0.74933714",
"0.7491974",
"0.7485691",
"0.7437889",
"0.74249136",
"0.7403326",
"0.... | 0.0 | -1 |
Initialize the weights in backbone. | def init_weights(self, pretrained=None):
if isinstance(pretrained, str):
logger = get_root_logger()
load_checkpoint(self, pretrained, strict=False, logger=logger)
elif pretrained is None:
for m in self.modules():
if isinstance(m, nn.Conv2d):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def in... | [
"0.83809745",
"0.83567804",
"0.8318618",
"0.80969334",
"0.79236996",
"0.79064524",
"0.78415686",
"0.76821744",
"0.76756763",
"0.7579746",
"0.7504763",
"0.75038546",
"0.75038546",
"0.75038546",
"0.74933714",
"0.7491974",
"0.7485691",
"0.7437889",
"0.74249136",
"0.7403326",
"0.... | 0.0 | -1 |
Initialize the weights in backbone. | def init_weights(self, pretrained=None):
if isinstance(pretrained, str):
logger = get_root_logger()
load_checkpoint(self, pretrained, strict=False, logger=logger)
elif pretrained is None:
for m in self.modules():
if isinstance(m, nn.Conv2d):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def in... | [
"0.83809745",
"0.83567804",
"0.8318618",
"0.80969334",
"0.79236996",
"0.79064524",
"0.78415686",
"0.76821744",
"0.76756763",
"0.7579746",
"0.7504763",
"0.75038546",
"0.75038546",
"0.75038546",
"0.74933714",
"0.7491974",
"0.7485691",
"0.7437889",
"0.74249136",
"0.7403326",
"0.... | 0.0 | -1 |
Stack InvertedResidual blocks to build a layer for MobileNetV2. | def make_layer(self, out_channels, num_blocks, stride, expand_ratio):
layers = []
for i in range(num_blocks):
if i >= 1:
stride = 1
layers.append(InvertedResidual(self.in_channels, out_channels, stride, expand_ratio=expand_ratio, conv_cfg=self.conv_cfg, norm_cfg=s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_layer(self, out_channels, num_blocks):\n layers = []\n for i in range(num_blocks):\n stride = 2 if i == 0 else 1\n layers.append(InvertedResidual(in_channels=self.in_channels, out_channels=out_channels, stride=stride, conv_cfg=self.conv_cfg, norm_cfg=self.norm_cfg, act... | [
"0.6292122",
"0.6129501",
"0.61178213",
"0.6102227",
"0.60590327",
"0.6018183",
"0.60090405",
"0.59772414",
"0.59442794",
"0.5885008",
"0.5867726",
"0.58391887",
"0.5818666",
"0.58165723",
"0.5783878",
"0.5753458",
"0.5751327",
"0.5726953",
"0.5723741",
"0.57175475",
"0.56715... | 0.58735776 | 10 |
Initialize the weights in backbone. | def init_weights(self, pretrained=None):
if isinstance(pretrained, str):
logger = get_root_logger()
ckpt = _load_checkpoint(pretrained, logger=logger, map_location='cpu')
if 'state_dict' in ckpt:
_state_dict = ckpt['state_dict']
elif 'model' in ckp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def in... | [
"0.83809745",
"0.83567804",
"0.8318618",
"0.80969334",
"0.79236996",
"0.79064524",
"0.78415686",
"0.76821744",
"0.76756763",
"0.7579746",
"0.7504763",
"0.75038546",
"0.75038546",
"0.75038546",
"0.74933714",
"0.7491974",
"0.7485691",
"0.7437889",
"0.74249136",
"0.7403326",
"0.... | 0.0 | -1 |
Weight initialization for model. | def init_weights(self, pretrained=None):
if pretrained is not None:
self.pretrained = pretrained
for modal in self.modality:
getattr(self.backbone, modal).init_weights(self.pretrained.get(modal, None))
if hasattr(self, 'neck'):
self.neck.init_weights()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(model):\n ...",
"def init_weights_(self):\n raise NotImplementedError",
"def _initialize_weights(self):\n pass",
"def init_weight(self):\n init_bn(self.norm0)",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"d... | [
"0.85686207",
"0.848473",
"0.8421346",
"0.8388901",
"0.8246325",
"0.8199929",
"0.8101117",
"0.80370206",
"0.7984219",
"0.7940452",
"0.7931027",
"0.79122275",
"0.7875325",
"0.78611803",
"0.77435935",
"0.77398425",
"0.7737332",
"0.7697887",
"0.7692674",
"0.76801425",
"0.7677824... | 0.0 | -1 |
Calls either forward_train or forward_test depending on whether return_loss=True. Note this setting will change the expected inputs. | def forward(self, video, label=None, img_metas=None, return_loss=True, **kwargs):
if not isinstance(img_metas, (tuple, list)):
img_metas = [img_metas.data]
if return_loss:
return self.forward_train(video, label, img_metas[0], **kwargs)
return self.forward_test(video, labe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_train(self, *args, **kwargs):\n pass",
"def forward(self, X, training=False):\n pass",
"def forward(self, img, img_metas=None, return_loss=False, **kwargs):\n if return_loss:\n return self.forward_train(img, img_metas, **kwargs)\n return self.forward_test(img,... | [
"0.68793446",
"0.6742538",
"0.67208356",
"0.65698546",
"0.6494433",
"0.64842945",
"0.6481234",
"0.64600986",
"0.6428341",
"0.6426814",
"0.6352076",
"0.6299568",
"0.62467784",
"0.6203152",
"0.6182667",
"0.61751753",
"0.6171513",
"0.6162237",
"0.61599505",
"0.61579907",
"0.6140... | 0.56894004 | 82 |
Convert quaternion coefficients to rotation matrix. | def quat_to_rotmat(quat):
norm_quat = quat
norm_quat = norm_quat / norm_quat.norm(p=2, dim=1, keepdim=True)
w, x, y, z = norm_quat[:, 0], norm_quat[:, 1], norm_quat[:, 2], norm_quat[:, 3]
B = quat.size(0)
w2, x2, y2, z2 = w.pow(2), x.pow(2), y.pow(2), z.pow(2)
wx, wy, wz = w * x, w * y, w * z
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quaternion_to_rotation_matrix(quaternion):\n\n q_w, q_x, q_y, q_z = quaternion\n sqw, sqx, sqy, sqz = np.square(quaternion)\n norm = (sqx + sqy + sqz + sqw)\n rotation_matrix = np.zeros((3, 3))\n\n # division of square length if quaternion is not already normalized\n rotation_matrix[0, 0] = (... | [
"0.7666401",
"0.7480785",
"0.74480975",
"0.7431791",
"0.7220662",
"0.72003317",
"0.7190068",
"0.7073628",
"0.6941468",
"0.6884496",
"0.6881994",
"0.685318",
"0.68479955",
"0.68037885",
"0.67919123",
"0.677245",
"0.6759796",
"0.672846",
"0.670579",
"0.66775787",
"0.6654148",
... | 0.6882422 | 10 |
Convert axisangle representation to rotation matrix. | def batch_rodrigues(theta):
l2norm = torch.norm(theta + 1e-08, p=2, dim=1)
angle = torch.unsqueeze(l2norm, -1)
normalized = torch.div(theta, angle)
angle = angle * 0.5
v_cos = torch.cos(angle)
v_sin = torch.sin(angle)
quat = torch.cat([v_cos, v_sin * normalized], dim=1)
return quat_to_ro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def axis2rotmat(axis):\n return quat2rotmat(axis2quat(axis))",
"def rotation_matrix(angle, axis):\n about_z = rotation_about_z(angle)\n z_to_axis = z_to_vector(axis)\n axis_to_z = np.linalg.inv(z_to_axis)\n return reduce(np.dot, [z_to_axis, about_z, axis_to_z])",
"def angle_to_rotation_matrix(an... | [
"0.7975021",
"0.7776975",
"0.7642057",
"0.75718856",
"0.7484483",
"0.73852175",
"0.7374227",
"0.7331798",
"0.7323808",
"0.72060734",
"0.7166385",
"0.7143978",
"0.71211976",
"0.7071612",
"0.70691985",
"0.7067156",
"0.7056157",
"0.7056157",
"0.7034615",
"0.7027953",
"0.7001234"... | 0.0 | -1 |
Weight initialization for model. | def init_weights(self, pretrained=None):
if pretrained is not None:
self.pretrained = pretrained
self.backbone.init_weights(self.pretrained)
self.mesh_head.init_weights()
if self.with_gan:
self.discriminator.init_weights() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(model):\n ...",
"def init_weights_(self):\n raise NotImplementedError",
"def _initialize_weights(self):\n pass",
"def init_weight(self):\n init_bn(self.norm0)",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"d... | [
"0.85686207",
"0.848473",
"0.8421346",
"0.8388901",
"0.8246325",
"0.8199929",
"0.8101117",
"0.80370206",
"0.7984219",
"0.7940452",
"0.7931027",
"0.79122275",
"0.7875325",
"0.78611803",
"0.77435935",
"0.77398425",
"0.7737332",
"0.7697887",
"0.7692674",
"0.76801425",
"0.7677824... | 0.70198435 | 88 |
Get 3D joints from 3D mesh using predefined joints regressor. | def get_3d_joints_from_mesh(self, vertices):
return torch.matmul(self.joints_regressor, vertices) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fk3(joint_rotations):\n h0_3 = htm0_3(joint_rotations)\n x0_3 = h0_3[0, 3]\n y0_3 = h0_3[1, 3]\n z0_3 = h0_3[2, 3]\n d0_3 = [x0_3, y0_3, z0_3]\n return d0_3",
"def vertices2joints(J_regressor, vertices):\n return torch.einsum('bik,ji->bjk', [vertices, J_regressor])",
"def vertices2join... | [
"0.5559251",
"0.55435926",
"0.55435926",
"0.5519641",
"0.533805",
"0.5321818",
"0.52827793",
"0.5226791",
"0.52000743",
"0.5160625",
"0.51382494",
"0.51370203",
"0.5133971",
"0.51308125",
"0.5067422",
"0.5030773",
"0.4969826",
"0.49660763",
"0.49635682",
"0.49610776",
"0.4956... | 0.7331685 | 0 |
Forward function. Calls either forward_train or forward_test depending on whether return_loss=True. | def forward(self, img, img_metas=None, return_loss=False, **kwargs):
if return_loss:
return self.forward_train(img, img_metas, **kwargs)
return self.forward_test(img, img_metas, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _forward(self, *args, calc_score=False):\n with chainer.using_config('train', False), chainer.no_backprop_mode():\n if calc_score:\n self(*args)\n return self.y\n else:\n if self.predictor is None:\n print(\"[ERROR] pr... | [
"0.71872735",
"0.7128654",
"0.70319444",
"0.7026561",
"0.6894758",
"0.6802563",
"0.6779703",
"0.6705878",
"0.66595113",
"0.6588538",
"0.65810764",
"0.65727705",
"0.6538105",
"0.6522937",
"0.652293",
"0.65106237",
"0.6506749",
"0.64888895",
"0.6474941",
"0.6450967",
"0.6450814... | 0.7127736 | 2 |
Weight initialization for model. | def init_weights(self, pretrained=None):
if pretrained is not None:
self.pretrained = pretrained
self.backbone.init_weights(self.pretrained)
if self.with_necks:
for neck in self.necks:
if hasattr(neck, 'init_weights'):
neck.init_weights... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(model):\n ...",
"def init_weights_(self):\n raise NotImplementedError",
"def _initialize_weights(self):\n pass",
"def init_weight(self):\n init_bn(self.norm0)",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"d... | [
"0.85673505",
"0.84834665",
"0.8420753",
"0.8389227",
"0.82461745",
"0.8199778",
"0.810045",
"0.8035721",
"0.79831946",
"0.79390824",
"0.7930031",
"0.7911559",
"0.7874311",
"0.78609335",
"0.7743155",
"0.7739889",
"0.7736403",
"0.7696626",
"0.769211",
"0.76797533",
"0.7677288"... | 0.0 | -1 |
Draw bboxes with labels (optional) on an image. This is a wrapper of mmcv.imshow_bboxes. | def imshow_bboxes(img, bboxes, labels=None, colors='green', text_color='white', thickness=1, font_scale=0.5, show=True, win_name='', wait_time=0, out_file=None):
bboxes = np.split(bboxes, bboxes.shape[0], axis=0) if bboxes.shape[0] > 0 else []
if not isinstance(colors, list):
colors = [colors for _ in r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drawbboxes(img, bboxes, labels):\n thickness = 5\n color = (0, 255, 0)\n for bbox in bboxes:\n # top-left is x1, y1; bottom-right is x2,y2\n x1, y1, x2, y2, prob, category = (\n int(bbox[0]),\n int(bbox[1]),\n int(bbox[2]),\n int(bbox[3]),\n ... | [
"0.8425356",
"0.79669654",
"0.7939032",
"0.7938984",
"0.787777",
"0.78727245",
"0.7775163",
"0.76961917",
"0.7486975",
"0.74045867",
"0.7395205",
"0.7366733",
"0.73514307",
"0.7285908",
"0.7165967",
"0.7144592",
"0.707343",
"0.7056721",
"0.7021131",
"0.69743466",
"0.6963432",... | 0.81564605 | 1 |
Convert 6D rotation representation to 3x3 rotation matrix. Based on Zhou et al., "On the Continuity of Rotation Representations in Neural Networks", CVPR 2019 | def rot6d_to_rotmat(x):
x = x.view(-1, 3, 2)
a1 = x[:, :, 0]
a2 = x[:, :, 1]
b1 = F.normalize(a1)
b2 = F.normalize(a2 - torch.einsum('bi,bi->b', b1, a2).unsqueeze(-1) * b1)
b3 = torch.cross(b1, b2)
return torch.stack((b1, b2, b3), dim=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rot6d_to_rotmat(x):\n x = x.view(-1,3,2)\n a1 = x[:, :, 0]\n a2 = x[:, :, 1]\n b1 = F.normalize(a1)\n b2 = F.normalize(a2 - torch.einsum('bi,bi->b', b1, a2).unsqueeze(-1) * b1)\n b3 = torch.cross(b1, b2)\n return torch.stack((b1, b2, b3), dim=-1)",
"def rotmat_to_rot6d(rotmat):\n\n ro... | [
"0.77868396",
"0.69944537",
"0.6879761",
"0.6653499",
"0.6609096",
"0.6535051",
"0.64724016",
"0.6432443",
"0.63557816",
"0.6317468",
"0.62795895",
"0.62564325",
"0.62430626",
"0.6241044",
"0.62305796",
"0.6196107",
"0.6190647",
"0.6184934",
"0.61790997",
"0.61746114",
"0.615... | 0.7754819 | 2 |
Forward function. x is the image feature map and is expected to be in shape (batch size x channel number x height x width) | def forward(self, x):
batch_size = x.shape[0]
x = x.mean(dim=-1).mean(dim=-1)
init_pose = self.init_pose.expand(batch_size, -1)
init_shape = self.init_shape.expand(batch_size, -1)
init_cam = self.init_cam.expand(batch_size, -1)
pred_pose = init_pose
pred_shape = i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature_forward(self, x):\n raise NotImplementedError",
"def forward(self, x):\n x = self.features(x)\n x = x.view(x.size(0), 256 * 6 * 6)\n x = self.classifier(x)\n return x",
"def forward(self, x):\n x = self.features(x)\n return x",
"def forward(self, x... | [
"0.8109888",
"0.783628",
"0.7809797",
"0.76811504",
"0.7640014",
"0.7578948",
"0.75749266",
"0.7573663",
"0.75364065",
"0.7531707",
"0.7507958",
"0.747236",
"0.7470453",
"0.7470453",
"0.7401767",
"0.7383301",
"0.7383301",
"0.7383016",
"0.7380614",
"0.7374642",
"0.7372244",
... | 0.7186885 | 42 |
Restore global position of the rootcentered joints. | def _restore_global_position(x, root_pos, root_idx=None):
x = x + root_pos
if root_idx is not None:
x = np.insert(x, root_idx, root_pos.squeeze(1), axis=1)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_position(self):\n self.translate_to_point_O()\n\n # inverse rotation:\n rotation_matrix = np.stack(\n (self.pcs.i_hat, self.pcs.j_hat, self.pcs.k_hat), axis=0\n )\n\n self.rotate(rotation_matrix)",
"def reset_position(self, x, y):\n\t\tself.grid[x][y] = sel... | [
"0.6468122",
"0.64039344",
"0.6186904",
"0.6128712",
"0.6004282",
"0.60020596",
"0.5972203",
"0.5965829",
"0.594728",
"0.5924122",
"0.59190434",
"0.58652675",
"0.5814819",
"0.5810724",
"0.579582",
"0.57915163",
"0.57613224",
"0.5712127",
"0.56887126",
"0.56887126",
"0.5688712... | 0.6400782 | 2 |
Restore the target weight of the root joint after the restoration of the global position. | def _restore_root_target_weight(target_weight, root_weight, root_idx=None):
if root_idx is not None:
root_weight = np.full(target_weight.shape[0], root_weight, dtype=target_weight.dtype)
target_weight = np.insert(target_weight, root_idx, root_weight[:, None], axis=1)
return targe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore(self):\n self.weight = self._backup_weight",
"def update_target_model(self):\n self.target_model.set_weights(self.model.get_weights())",
"def update_target_model(self):\n self.target_model.set_weights(self.model.get_weights())",
"def update_target_model(self):\n self.t... | [
"0.6532418",
"0.626845",
"0.626845",
"0.626845",
"0.61817044",
"0.59743774",
"0.59608006",
"0.5948445",
"0.5932581",
"0.5902194",
"0.58527577",
"0.5794424",
"0.5779515",
"0.5766231",
"0.57529676",
"0.57319206",
"0.57286066",
"0.57243454",
"0.57059324",
"0.56769335",
"0.564747... | 0.73660153 | 0 |
Get indices in the 3D tensor. | def _get_3d_indices(indices, shape):
batch_size = indices.shape[0]
num_people = indices.shape[1]
indices_x = (indices // (shape[1] * shape[2])).reshape(batch_size, num_people, -1)
indices_y = (indices % (shape[1] * shape[2]) // shape[2]).reshape(batch_size, num_people, -1)
indice... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _index(tensor_3d, tensor_2d):\n x, y, z = tensor_3d.size()\n t = tensor_3d.reshape(x * y, z)\n tt = tensor_2d.reshape(x * y)\n v = t[torch.arange(x * y), tt]\n v = v.reshape(x, y)\n return v",
"def get_img_indices():\n if K.image_dim_ordering() == 'th':\n return 0, 1, 2, 3\n el... | [
"0.77685285",
"0.7458059",
"0.71643627",
"0.70784223",
"0.69235426",
"0.69099647",
"0.6634774",
"0.6597598",
"0.6582917",
"0.654125",
"0.6490288",
"0.64506537",
"0.6442221",
"0.6366239",
"0.6352815",
"0.63409746",
"0.6336338",
"0.6327924",
"0.63188136",
"0.6273791",
"0.615544... | 0.72924477 | 2 |
Compute 3D joints loss for the examples that 3D joint annotations are available. The loss is weighted by joints_3d_visible. | def joints_3d_loss(self, pred_joints_3d, gt_joints_3d, joints_3d_visible):
conf = joints_3d_visible.float()
if len(gt_joints_3d) > 0:
gt_pelvis = (gt_joints_3d[:, 2, :] + gt_joints_3d[:, 3, :]) / 2
gt_joints_3d = gt_joints_3d - gt_pelvis[:, None, :]
pred_pelvis = (pre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def joints_2d_loss(self, pred_joints_2d, gt_joints_2d, joints_2d_visible):\n conf = joints_2d_visible.float()\n loss = (conf * self.criterion_joints_2d(pred_joints_2d, gt_joints_2d)).mean()\n return loss",
"def pointnet_loss(preds, targets, chamfer_lambda, physical_lambda, joint_lambda, has_... | [
"0.6756533",
"0.60064924",
"0.59600157",
"0.5607383",
"0.5360164",
"0.53345627",
"0.5324913",
"0.528248",
"0.52383",
"0.52234066",
"0.52091354",
"0.519144",
"0.51809406",
"0.5140926",
"0.5132388",
"0.51157516",
"0.51082975",
"0.5080216",
"0.5026056",
"0.50177366",
"0.49956354... | 0.8305695 | 0 |
Perform orthographic projection of 3D points using the camera parameters, return projected 2D points in image plane. | def project_points(self, points_3d, camera):
batch_size = points_3d.shape[0]
device = points_3d.device
cam_t = torch.stack([camera[:, 1], camera[:, 2], 2 * self.focal_length / (self.img_res * camera[:, 0] + 1e-09)], dim=-1)
camera_center = camera.new_zeros([batch_size, 2])
rot_t ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project(points, camera_params, theta):\n \"\"\"\n Function takes input of 3d_points, transformations and Convert 3-D points to 2-D by projecting onto images. \n Input:\n points: 3D points in world frame\n camera_params: parameters of camera corrosponding to the point\n theta: Need... | [
"0.71469444",
"0.7131893",
"0.70798355",
"0.70352674",
"0.69473964",
"0.6943918",
"0.6870089",
"0.67666954",
"0.6736476",
"0.6724732",
"0.671313",
"0.6680877",
"0.6620804",
"0.64126754",
"0.63342166",
"0.6332999",
"0.628593",
"0.6259295",
"0.6257777",
"0.6186433",
"0.6171103"... | 0.7044382 | 3 |
Make zero inputs for AE loss. | def _make_input(t, requires_grad=False, device=torch.device('cpu')):
inp = torch.autograd.Variable(t, requires_grad=requires_grad)
inp = inp.sum()
inp = inp
return inp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def switch_to_no_feedforward_inputs(self):\n\n self.h_e=np.ones_like(self.inputs.noise_flat.T)*self.feed_forward_off_value\n self.h=np.vstack([self.h_e,self.h_i])",
"def zero(self):\n q = pinocchio.neutral(self.model)\n v = np.zeros(self.model.nv)\n return np.concatenate([q.flat, v])",... | [
"0.69209635",
"0.6261222",
"0.62184983",
"0.6188817",
"0.6159907",
"0.6061483",
"0.60535985",
"0.5981513",
"0.5974199",
"0.5957769",
"0.59405655",
"0.59405655",
"0.5939206",
"0.5891215",
"0.5864115",
"0.5849362",
"0.5842028",
"0.5831693",
"0.58147335",
"0.58132446",
"0.580216... | 0.0 | -1 |
Project 3D joint coordinates to 2D image plane using camera intrinsic parameters. | def project_joints(x, intrinsics):
while intrinsics.dim() < x.dim():
intrinsics.unsqueeze_(1)
f = intrinsics[..., :2]
c = intrinsics[..., 2:4]
_x = torch.clamp(x[:, :, :2] / x[:, :, 2:], -1, 1)
if intrinsics.shape[-1] == 9:
k = intrinsics[..., 4:7]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_points(self, points_3d, camera):\n batch_size = points_3d.shape[0]\n device = points_3d.device\n cam_t = torch.stack([camera[:, 1], camera[:, 2], 2 * self.focal_length / (self.img_res * camera[:, 0] + 1e-09)], dim=-1)\n camera_center = camera.new_zeros([batch_size, 2])\n ... | [
"0.6893198",
"0.66906667",
"0.64375496",
"0.6386052",
"0.63330364",
"0.6250995",
"0.6210345",
"0.62045944",
"0.61692065",
"0.61516637",
"0.6141883",
"0.61296594",
"0.6083696",
"0.5989321",
"0.5974358",
"0.59156924",
"0.5906794",
"0.5904153",
"0.5889489",
"0.58657324",
"0.5854... | 0.5457731 | 61 |
Generates a random string out of given charactes. | def randstr(chars=string.ascii_lowercase + string.digits, len=16) -> str:
return ''.join(random.choices(chars, k=len)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_random_char_string(n, base_s=\"\"):\n if n == 0:\n return base_s\n \n c = random.choice(string.ascii_letters)\n return gen_random_char_string(n-1, base_s + c)",
"def rand_string():\n out = ''\n for _ in range(24):\n out += choice(ascii_letters)\n return out",
"def ran... | [
"0.81032926",
"0.806971",
"0.7877198",
"0.7849856",
"0.7845163",
"0.7842866",
"0.7834733",
"0.777338",
"0.773708",
"0.76797926",
"0.7669728",
"0.76126826",
"0.7609616",
"0.76057935",
"0.7594953",
"0.7582613",
"0.75544643",
"0.7537375",
"0.75352347",
"0.75326586",
"0.7530695",... | 0.7981308 | 2 |
This function applies the query function on each subset of the original df in a parallel way It takes a dictionary with 1011 pairs keyvalue. Each key is the df subset name and each value is the df subset It returns a df with the IdRef. | def res_futures(dict_nb: dict) -> pd.DataFrame:
res = []
with concurrent.futures.ThreadPoolExecutor(max_workers=11, thread_name_prefix="thread") as executor:
# Start the load operations and mark each future with its URL
future_to_req = {executor.submit(query, df): df for df in dict_nb.values()}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query(df: pd.DataFrame) -> pd.DataFrame:\n pydref = pdref.Pydref()\n logger = get_logger(threading.current_thread().name)\n logger.info(\"start\")\n part_idref = {\"person_id\": [], \"name_corrected\": [], \"idref\": []}\n for _, r in df.iterrows():\n try:\n result = pydref.ide... | [
"0.6329121",
"0.6085262",
"0.5936317",
"0.5933766",
"0.57985693",
"0.55516374",
"0.5514657",
"0.55016136",
"0.5495835",
"0.54683244",
"0.5375725",
"0.5368782",
"0.5349592",
"0.5347283",
"0.5343006",
"0.5334667",
"0.53258467",
"0.53250384",
"0.5321837",
"0.53159046",
"0.530732... | 0.54051006 | 10 |
Gets configuration from environment variables that start with app_name Example with load_as_json=True | def get_envvar_configuration(app_name, load_as_json=True):
configuration = {}
prefix = '{0}_'.format(app_name.upper())
for key, value in os.environ.items():
if key.startswith(prefix):
config_name = key[len(prefix):]
configuration[config_name] = value
if load_as_json:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_config(app_environment) -> Dict:\n with open('config.json', 'r') as config_file:\n config_dict = json.load(config_file)\n\n if app_environment.startswith(\"develop\"):\n if \"development\" in config_dict:\n config = config_dict[\"development\"]\n else:\n ra... | [
"0.6923006",
"0.6858593",
"0.68416387",
"0.6788664",
"0.6689209",
"0.6604247",
"0.6604247",
"0.6558171",
"0.6507442",
"0.649356",
"0.6432491",
"0.63902104",
"0.6373164",
"0.6365966",
"0.6318764",
"0.6317983",
"0.62802994",
"0.6275604",
"0.627509",
"0.62469",
"0.6237867",
"0... | 0.8213723 | 0 |
If the associated mod archive contains a directory named 'fomod', return the internal path to that folder. Otherwise, return None. | async def get_fomod_path(self):
async for e in self.archive_contents(files=False):
# drop the last char because it is always '/' for directories
if os.path.basename(e.rstrip('/')).lower() == "fomod":
return e
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dir(self):\n if not self.on:\n return None\n try:\n return self._dir\n except AttributeError:\n pass\n try:\n parentdir = self._parent.dir\n ownername = self._ownername\n except AttributeError:\n return None\n ... | [
"0.57813084",
"0.5711752",
"0.5658194",
"0.56434447",
"0.56254584",
"0.56109285",
"0.5583636",
"0.5582432",
"0.55571324",
"0.55271435",
"0.5511979",
"0.55082214",
"0.5504758",
"0.54894316",
"0.54800737",
"0.5472066",
"0.5468324",
"0.54642063",
"0.5460707",
"0.5447479",
"0.544... | 0.84928703 | 0 |
Returns checkpoint instance id | def get_id(self):
return self.id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_id(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"instance_id\")",
"def instance_id(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"instance_id\")",
"def instance_id(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"instance_id\")",
"def instance_id... | [
"0.75324494",
"0.75324494",
"0.75324494",
"0.753174",
"0.753174",
"0.753174",
"0.73345107",
"0.73296505",
"0.73296505",
"0.73296505",
"0.73296505",
"0.73296505",
"0.73296505",
"0.73109585",
"0.73109585",
"0.73109585",
"0.7289635",
"0.7289635",
"0.7289635",
"0.7289635",
"0.728... | 0.0 | -1 |
To get upload path for specific user | def get_upload_path(instance, filename):
userpath = "{name}/{file}".format(name=instance.user.username, file=filename)
mainpath = os.path.join("infocomp",userpath)
return mainpath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_upload_path(instance, filename):\n \n return \"user_{username}/{goal}/{file}\".format(id=instance.user.username, \n goal=instance.name.slug, file=filename)",
"def user_directory_path(instance, filename: str) -> str:\n\n # File will be uploaded to MEDIA_ROOT/user_<id>/<filename>\n retur... | [
"0.76164734",
"0.74995077",
"0.73748523",
"0.6845557",
"0.6799951",
"0.67855966",
"0.658465",
"0.6570861",
"0.656437",
"0.65490043",
"0.65289664",
"0.64806134",
"0.6428075",
"0.6385826",
"0.63577163",
"0.63510114",
"0.63019615",
"0.6262501",
"0.61959994",
"0.6180763",
"0.6177... | 0.7651492 | 0 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
plt.imshow(cm, interpolation='nearest', cmap=cmap)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.81922984",
"0.80933887",
"0.80272716",
"0.8016492",
"0.79913706",
"0.79885876",
"0.79777396",
"0.79729784",
"0.7958926",
"0.7954523",
"0.79347897",
"0.7931899",
"0.7931772",
"0.7928666",
"0.7923684",
"0.7921764",
"0.79213995",
"0.7920191",
"0.792016",
"0.7919876",
"0.79153... | 0.0 | -1 |
Check if the pipeline executor build is enabled. Return | def pipeline_executor_build_enabled():
return tvm.contrib.pipeline_executor.pipeline_executor_enabled() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_pipeline_executor_interface(self):\n return not isinstance(self.io_owner, PipelineConfig.ModuleWrapper)",
"def available():\n if \"MojoPipeline\" not in h2o.cluster().list_core_extensions():\n print(\"Cannot use MOJO Pipelines - runtime was not found.\")\n return Fa... | [
"0.67274827",
"0.6549643",
"0.6535526",
"0.64671516",
"0.6108377",
"0.6032475",
"0.6018949",
"0.60120815",
"0.6000826",
"0.58864367",
"0.5872304",
"0.57963127",
"0.5774401",
"0.5767087",
"0.5716949",
"0.56814426",
"0.56527084",
"0.5635638",
"0.5632141",
"0.5623579",
"0.560476... | 0.8849949 | 0 |
Return a list with all nodes selected for compression. Each member list is a list with nodes that have identical formulas in the same level of derivation tree. The ProofGraph object has a attribute 'nodes_level', a dictionarylike object that stores nodes per level in derivation tree. | def get_nodes_repeated_formulas(proof_graph):
level = 0
repeated_formulas = {}
nodes_level = proof_graph.get_nodes_level()
for level, nodes in nodes_level.items():
repeated_formulas[level] = []
nodes_formula = {}
for node in nodes:
formula = proof_graph.get_node_attri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaf_nodes(self):\n deps = set([\n item for sublist in self.edges.values() for item in sublist\n ]) # Now contains all nodes that contain dependencies.\n return (x for x in self.nodes if x not in deps) # Generator that\n # contains all nodes *without* any dependencies (... | [
"0.59449786",
"0.59210926",
"0.58997107",
"0.5868533",
"0.58245146",
"0.57777065",
"0.5772594",
"0.5772203",
"0.5772203",
"0.5765101",
"0.57511866",
"0.5741092",
"0.5740438",
"0.57399815",
"0.5738622",
"0.57371634",
"0.5712226",
"0.57087314",
"0.56831145",
"0.56826526",
"0.56... | 0.5502048 | 42 |
Return True if exists a node that is out_neighbor of node_u and node_v. Return False if this node not exists. | def is_connected_same_node(graph, node_u, node_v):
for out_neighbor_u in graph.get_deductive_out_neighbors(node_u):
for out_neighbor_v in graph.get_deductive_out_neighbors(node_v):
if out_neighbor_u == out_neighbor_v:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_neighbour(self, node):\n if node in self.neighbours:\n return True\n return False",
"def is_neighbor(self, name_from, name_to):\n return name_to in self._main_dictionary[name_from]",
"def contains_edge(self, u: str, v: str) -> bool:\n if v in self.adj_list[u]:\n ... | [
"0.6862047",
"0.6402426",
"0.6183208",
"0.6169514",
"0.5991937",
"0.5986089",
"0.59851027",
"0.59416634",
"0.5934797",
"0.5917179",
"0.5912017",
"0.5889982",
"0.5870837",
"0.5857063",
"0.5856563",
"0.58118707",
"0.58051395",
"0.57932913",
"0.5790044",
"0.5782719",
"0.57803255... | 0.67921066 | 1 |
Testing the Add function of the calculator | def test_calculator_add(clear_history):
assert Calculator.add_number(1, 2) == 3
assert Calculator.add_number(2, 2) == 4
assert Calculator.add_number(3, 2) == 5
assert Calculator.add_number(4, 2) == 6
assert Calculator.history_count() == 4
assert Calculator.get_result_of_last_calculation_added_to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_addition():\n assert calculator.add(7, 3) == 10\n assert calculator.add(7.0, 3.0) == 10.0\n assert calculator.add(7, -3) == 4\n assert calculator.add(7.0, -3.0) == 4.0",
"def test_add_returns_correct_result(self):\n result = self.calc.add(2, 2)\n self.assertEqual(4, result)",
... | [
"0.8440173",
"0.8434948",
"0.8202158",
"0.8202158",
"0.8202158",
"0.81960595",
"0.8010745",
"0.80049014",
"0.7991473",
"0.7982925",
"0.7965928",
"0.79100037",
"0.7906378",
"0.78788674",
"0.7748355",
"0.7728935",
"0.760771",
"0.7594136",
"0.7570065",
"0.7547949",
"0.7540929",
... | 0.6875723 | 89 |
Testing the subtract method of the calculator | def test_calculator_subtract():
assert Calculator.subtract_number(1, 2) == -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_subtraction():\n assert calculator.subtract(7, 3) == 4\n assert calculator.subtract(7.0, 3.0) == 4.0\n assert calculator.subtract(7, -3) == 10\n assert calculator.subtract(7.0, -3.0) == 10.0",
"def test_calculator_subtract():\n calc = Calculator()\n calc.subtract(1)\n assert calc.ge... | [
"0.8693571",
"0.8651895",
"0.85075855",
"0.8305262",
"0.82759595",
"0.8261573",
"0.82330716",
"0.82330716",
"0.821264",
"0.8152954",
"0.8083025",
"0.80597436",
"0.7985497",
"0.7983098",
"0.77423507",
"0.7734247",
"0.7657529",
"0.75747967",
"0.7517118",
"0.7416459",
"0.7376896... | 0.8192774 | 9 |
Generate Plots in the HTML index page. | def index():
# create table for original dataset
table_1 = data_table_low(filepath = "sparkify_data.csv", title='Raw Sparkify Data')
table_2 = data_table_low(filepath = "cleaned_data.csv", title='Cleaned Sparkify Data')
# create and append plotly visuals into an array to be passed later for graphJSON ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index():\n graphs = [\n message_genre_bar_chart(df),\n category_bar_chart(df),\n top_words_bar_chart(df)\n ]\n \n # encode plotly graphs in JSON\n ids = [\"graph-{}\".format(i) for i, _ in enumerate(graphs)]\n graphJSON = json.dumps(graphs, cls=plotly.utils.PlotlyJSONEnco... | [
"0.7178311",
"0.70505464",
"0.70494276",
"0.64869934",
"0.6468016",
"0.64508504",
"0.6444026",
"0.643546",
"0.6432974",
"0.6426685",
"0.64226305",
"0.64135414",
"0.6410265",
"0.6410265",
"0.6407052",
"0.6404297",
"0.63878465",
"0.6367806",
"0.63612807",
"0.6347655",
"0.634359... | 0.7129036 | 1 |
2D ndarray to pd.DataFrame | def get_ts_df( N):
df = pd.DataFrame()
df['value'] = N.reshape(-1)
df['time'] = list(range( N.shape[1])) * N.shape[0]
df['unit'] = np.repeat( range( N.shape[0]), N.shape[1])
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_nparray_to_df(nparray: np.ndarray) -> pd.DataFrame:\n return pd.DataFrame(data=nparray[1:, 1:],\n index=nparray[1:, 0],\n columns=nparray[0, 1:])",
"def array_to_df (a_array,b_as_column='') :\n if b_as_column == '' :\n loc_result = __pd.DataFram... | [
"0.8012739",
"0.7327064",
"0.70615965",
"0.70131636",
"0.6823303",
"0.68077964",
"0.67281395",
"0.67181456",
"0.67167735",
"0.67092234",
"0.6660128",
"0.6505619",
"0.64926094",
"0.6486184",
"0.6472557",
"0.6431895",
"0.6426513",
"0.6403305",
"0.6307063",
"0.6212939",
"0.62013... | 0.56146455 | 91 |
Returns the user provided name or the lower() class name for use when | def get_name(cls):
return cls.name or cls.__name__.lower() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_name(name: str) -> str:\n return text.pascal_case(utils.safe_snake(name, \"type\"))",
"def classname(cls):\n return cls.__name__.lower()",
"def get_class_name(name):\n name = _strip_class_name(name)\n return convert_to_camel_case(name)",
"def class_name(self) -> Optional[pulumi.Inpu... | [
"0.7601749",
"0.72795516",
"0.72573864",
"0.72564507",
"0.7238398",
"0.709797",
"0.7060616",
"0.7001694",
"0.69945616",
"0.6987685",
"0.69607097",
"0.69228125",
"0.6897389",
"0.6884109",
"0.68566924",
"0.6851744",
"0.68311906",
"0.6830754",
"0.6827228",
"0.68000424",
"0.67342... | 0.77838355 | 0 |
Handle Incoming PATCH requests and dispatch to handle_patch_request method. | def patch(self, *args, **kwargs):
return self.handle_patch_request() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_client_can_do_patch_request(self):\n response = self.httpbin_4.test_requests_patch_method()\n self.assertEqual(response.request.method, 'PATCH')\n self.assertEqual(response.status_code, 200)",
"def patch(self, *args, **kwargs):\n self.request(\"patch\", *args, **kwargs)",
"... | [
"0.68794614",
"0.68380874",
"0.68149406",
"0.6793358",
"0.65440285",
"0.6491982",
"0.6459084",
"0.64541936",
"0.64541936",
"0.64541936",
"0.64171255",
"0.6402273",
"0.6372591",
"0.630911",
"0.62627673",
"0.622556",
"0.6204201",
"0.6175774",
"0.61528903",
"0.61523855",
"0.6145... | 0.70530725 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.