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 |
|---|---|---|---|---|---|---|
Convert Ax fixed parameter to a dictionary. | def fixed_parameter_to_dict(parameter: FixedParameter) -> Dict[str, Any]:
return {
"__type": parameter.__class__.__name__,
"name": parameter.name,
"parameter_type": parameter.parameter_type,
"value": parameter.value,
"is_fidelity": parameter.is_fidelity,
"target_value... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_dict(params, x):\n parameters = {}\n for i, p in enumerate(feature_map.ordered_parameters):\n parameters[p] = x[i]\n for i, p in enumerate(var_form.ordered_parameters):\n parameters[p] = params[i]\n return parameters",
"def transform_params(cls, orion_params, space):\n ... | [
"0.6616411",
"0.64693075",
"0.6368463",
"0.6224811",
"0.61784416",
"0.57968396",
"0.5790116",
"0.5738215",
"0.56811947",
"0.5542162",
"0.5521996",
"0.55138856",
"0.54939157",
"0.54856753",
"0.5464929",
"0.546039",
"0.54472554",
"0.54368734",
"0.5431676",
"0.54211044",
"0.5420... | 0.6069665 | 5 |
Convert Ax order parameter constraint to a dictionary. | def order_parameter_constraint_to_dict(
parameter_constraint: OrderConstraint,
) -> Dict[str, Any]:
return {
"__type": parameter_constraint.__class__.__name__,
"lower_name": parameter_constraint.lower_parameter.name,
"upper_name": parameter_constraint.upper_parameter.name,
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameter_constraint_to_dict(\n parameter_constraint: ParameterConstraint,\n) -> Dict[str, Any]:\n return {\n \"__type\": parameter_constraint.__class__.__name__,\n \"constraint_dict\": parameter_constraint.constraint_dict,\n \"bound\": parameter_constraint.bound,\n }",
"def sum... | [
"0.70250034",
"0.6755246",
"0.6282842",
"0.59978515",
"0.59347343",
"0.59243685",
"0.57637775",
"0.573151",
"0.57286584",
"0.5690171",
"0.55415326",
"0.5537508",
"0.5456873",
"0.5437464",
"0.54136723",
"0.54021055",
"0.53909326",
"0.5379604",
"0.5377456",
"0.53282666",
"0.532... | 0.7378955 | 0 |
Convert Ax sum parameter constraint to a dictionary. | def sum_parameter_constraint_to_dict(
parameter_constraint: SumConstraint,
) -> Dict[str, Any]:
return {
"__type": parameter_constraint.__class__.__name__,
"parameter_names": parameter_constraint._parameter_names,
"is_upper_bound": parameter_constraint._is_upper_bound,
# SumParam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameter_constraint_to_dict(\n parameter_constraint: ParameterConstraint,\n) -> Dict[str, Any]:\n return {\n \"__type\": parameter_constraint.__class__.__name__,\n \"constraint_dict\": parameter_constraint.constraint_dict,\n \"bound\": parameter_constraint.bound,\n }",
"def ord... | [
"0.6681107",
"0.615913",
"0.5842451",
"0.5724158",
"0.5704301",
"0.567434",
"0.566814",
"0.5667221",
"0.5610335",
"0.5545479",
"0.54901546",
"0.54531944",
"0.5447402",
"0.53731257",
"0.5371384",
"0.53389007",
"0.5310174",
"0.52993345",
"0.5281479",
"0.5250952",
"0.52383286",
... | 0.76757425 | 0 |
Convert Ax sum parameter constraint to a dictionary. | def parameter_constraint_to_dict(
parameter_constraint: ParameterConstraint,
) -> Dict[str, Any]:
return {
"__type": parameter_constraint.__class__.__name__,
"constraint_dict": parameter_constraint.constraint_dict,
"bound": parameter_constraint.bound,
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_parameter_constraint_to_dict(\n parameter_constraint: SumConstraint,\n) -> Dict[str, Any]:\n return {\n \"__type\": parameter_constraint.__class__.__name__,\n \"parameter_names\": parameter_constraint._parameter_names,\n \"is_upper_bound\": parameter_constraint._is_upper_bound,\n... | [
"0.7674618",
"0.6158456",
"0.5840943",
"0.57238036",
"0.57042503",
"0.567443",
"0.5667753",
"0.5667361",
"0.5609302",
"0.55442905",
"0.5489536",
"0.5452178",
"0.544599",
"0.53719735",
"0.5371491",
"0.5337446",
"0.5311322",
"0.5298335",
"0.52804583",
"0.52501833",
"0.52372897"... | 0.6680723 | 1 |
String for representing the Model object (in Admin site etc.) | def __str__(self):
return self.igName | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')",
"def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"",
"def __str_... | [
"0.7801034",
"0.771108",
"0.76740676",
"0.76740676",
"0.75247556",
"0.7401969",
"0.7396954",
"0.7376422",
"0.7326549",
"0.7270134",
"0.7242486",
"0.723401",
"0.72065157",
"0.71748495",
"0.716576",
"0.71091646",
"0.7036524",
"0.7036524",
"0.7012059",
"0.69871324",
"0.696656",
... | 0.0 | -1 |
Retrieve and update the Player information used by this class. Optionally, the ID already present on the instance may be overridden. | async def refresh(self, player_id=None):
self._player = await self._pytheos.api.player.get_player_info(player_id if player_id else self.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updatePlayer(self, player_info):\n player = self._get_or_create_player(**player_info)\n player.update(player_info)",
"def get_player(self, player_id):\r\n \r\n if player_id in self.players:\r\n player = self.players[player_id]\r\n else:\r\n pla... | [
"0.66836107",
"0.64410776",
"0.640123",
"0.6389119",
"0.6357115",
"0.6285872",
"0.6285872",
"0.6284486",
"0.6265534",
"0.6234241",
"0.6231726",
"0.62001145",
"0.61006993",
"0.61006993",
"0.6094042",
"0.60725015",
"0.60665053",
"0.6046958",
"0.6020837",
"0.6016125",
"0.6002181... | 0.72934955 | 0 |
Instructs the player to play the specified input source. Optionally, this input source can live on another Player on the network, which can be specified with the source_player parameter. | async def play_input(self, input_source: models.source.InputSource, source_player: Optional[models.Player]=None):
source_player_id = source_player.player_id if source_player else None
await self._pytheos.api.browse.play_input(self.id, input_name=input_source, source_player_id=source_player_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_select_source(self, source: str) -> None:\n await self._volumio.play_playlist(source)\n self._currentplaylist = source",
"def input(self, source):\n if self._input is source:\n return\n if self._input is not None:\n self._input.remove_callback(sel... | [
"0.6839437",
"0.65549195",
"0.6492702",
"0.61505014",
"0.60640144",
"0.6063953",
"0.6058635",
"0.60560435",
"0.6001099",
"0.5991787",
"0.5991787",
"0.5991787",
"0.5991787",
"0.5991787",
"0.5991787",
"0.5991787",
"0.59365976",
"0.5899308",
"0.5837673",
"0.58090997",
"0.5670863... | 0.8264708 | 0 |
Determines if the player is muted | async def get_mute(self) -> bool:
return await self._pytheos.api.player.get_mute(self.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def muted(self) -> bool:\n return self._muted",
"def is_volume_muted(self) -> str | None:\n return self.zone.Mute",
"def is_volume_muted(self) -> bool:\n return int(self._state.get(\"playback_mute\", 0)) == 1",
"def is_volume_muted(self):\n return self._muted",
"def is_volume_mu... | [
"0.80836314",
"0.80168563",
"0.79745257",
"0.79238254",
"0.79238254",
"0.79238254",
"0.7923404",
"0.79083645",
"0.7872212",
"0.78089786",
"0.7734288",
"0.7623286",
"0.75032455",
"0.70604074",
"0.7031613",
"0.6821551",
"0.67993015",
"0.67134523",
"0.6562891",
"0.65578526",
"0.... | 0.69503707 | 15 |
Sets the current mute status | async def set_mute(self, value: bool):
await self._pytheos.api.player.set_mute(self.id, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mute(self, value: bool) -> None:\n self.audio_mixer.setmute(value)\n self.update_status()",
"def mute(self, status=None):\n if status is None:\n status = not self.status.volume_muted\n\n self._socket_client.receiver_controller.set_volume_muted(status)",
"def mute(self... | [
"0.7956274",
"0.79184675",
"0.78892756",
"0.7831008",
"0.764453",
"0.7631729",
"0.7435448",
"0.7400257",
"0.7308956",
"0.7272677",
"0.7264612",
"0.72503746",
"0.717794",
"0.7170206",
"0.71608025",
"0.7102396",
"0.70053685",
"0.6987237",
"0.6901179",
"0.6840266",
"0.68230677",... | 0.7440952 | 6 |
Retrieves the currently playing media | async def get_now_playing(self) -> models.MediaItem: # FIXME: Maybe want to abstract MediaItem out
return await self._pytheos.api.player.get_now_playing_media(self.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_current_media(self):\n key = int(self.status.content_id.split(\"/\")[-1])\n media_item = self.pms.fetchItem(key).reload()\n media_idx = self.status.media_custom_data.get(\"mediaIndex\", 0)\n part_idx = self.status.media_custom_data.get(\"partIndex\", 0)\n media = media_i... | [
"0.73931164",
"0.67802805",
"0.67752814",
"0.66668504",
"0.6516602",
"0.64392173",
"0.6381317",
"0.63449466",
"0.63348305",
"0.6289103",
"0.62793976",
"0.62793976",
"0.62793976",
"0.62793976",
"0.6241527",
"0.62331885",
"0.62331885",
"0.61231667",
"0.6111469",
"0.6101856",
"0... | 0.74365187 | 0 |
Retries and returns the current play mode, which includes the Repeat & Shuffle status. | async def get_play_mode(self) -> tuple:
state = await self._pytheos.api.player.get_play_mode(self.id)
return state.repeat, state.shuffle | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_repeat(self) -> models.player.RepeatMode:\n repeat, _ = await self.get_play_mode()\n return repeat",
"async def get_shuffle(self) -> models.player.ShuffleMode:\n _, shuffle = await self.get_play_mode()\n return shuffle",
"def get_repeat_mode(self):\n response = ... | [
"0.7727305",
"0.686272",
"0.6753911",
"0.66733265",
"0.63247",
"0.63032025",
"0.6187156",
"0.59927005",
"0.5836798",
"0.5812603",
"0.5714184",
"0.56912535",
"0.5618556",
"0.56171626",
"0.5610621",
"0.55654824",
"0.55627465",
"0.5525542",
"0.55010265",
"0.54364",
"0.53980017",... | 0.72983116 | 1 |
String representation of a rule. | def __str__(self):
return 'IF {0} THEN {1}'.format(', '.join([str(fv) for fv in self.fvals]),
str(self.label)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return \"{ %s }\" % str(self.__rule)",
"def __str__(self):\n return \"[ %s ]\" % str(self.__rule)",
"def __str__(self):\n return \"{ %s }1\" % str(self.__rule)",
"def __str__ (self) :\n\t\ttext_rule = \"\"\n\t\t\n\t\tfor key, rules in self.production_rules.items() :\... | [
"0.83769774",
"0.83200026",
"0.79783237",
"0.7778663",
"0.7400893",
"0.73091453",
"0.72953486",
"0.725484",
"0.71773463",
"0.7139186",
"0.7100819",
"0.7026633",
"0.69189614",
"0.67429066",
"0.66980946",
"0.6672009",
"0.6672009",
"0.6598364",
"0.65805036",
"0.65805036",
"0.658... | 0.0 | -1 |
String representation of a decision list. | def __str__(self):
ret = ''
for rule in self.rules:
ret += str(rule) + '\n'
ret += 'IF TRUE THEN {0}'.format(self.default)
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_repr(self):\n pretty = []\n pretty.append(self.name)\n for node in self.evaluation_sequence:\n pretty.append(node.list_repr())\n return '\\n '.join(pretty)",
"def __str__(self):\n return str(self.list)",
"def __str__(self):\n str_list = ['[']\n ... | [
"0.69354224",
"0.6714814",
"0.666355",
"0.6517677",
"0.64540243",
"0.64034003",
"0.64011115",
"0.639956",
"0.63743293",
"0.6358435",
"0.6350684",
"0.6324823",
"0.6324823",
"0.63111824",
"0.6290448",
"0.6258903",
"0.62541413",
"0.6241724",
"0.6236936",
"0.62181693",
"0.6204071... | 0.0 | -1 |
Generate a random string to test in the file content | def setUp(self):
chars = string.ascii_uppercase + string.digits
self.file_text = ''.join(random.choice(chars) for x in range(6))
self.file_text = "Dummy Test: %s" % self.file_text
self.VERBOSE = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_filename():\n\n return ''.join(random.choices(string.ascii_uppercase + string.digits, k=5))",
"def random_text(random_file=None):\n if random_file is None:\n random_file = os.path.join(\n os.path.dirname(os.path.dirname(__file__)), \"data\", \"random.txt\"\n )\n with ... | [
"0.73341805",
"0.73096246",
"0.7236877",
"0.6995767",
"0.68509",
"0.6844827",
"0.68247956",
"0.6822039",
"0.67711186",
"0.67155576",
"0.6697203",
"0.6654374",
"0.6651617",
"0.663386",
"0.6519124",
"0.6517529",
"0.65137315",
"0.650087",
"0.64785224",
"0.6454835",
"0.64486414",... | 0.0 | -1 |
Return the set triggers path. | def get_triggers_path():
return TRIGGERS_PATH | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def triggers(self) -> pulumi.Output[Optional[Mapping[str, str]]]:\n return pulumi.get(self, \"triggers\")",
"def triggers(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:\n return pulumi.get(self, \"triggers\")",
"def triggers(self) -> Optional[pulumi.Input[Mapping[str, pulumi.In... | [
"0.6953054",
"0.6743383",
"0.6743383",
"0.64517665",
"0.602643",
"0.59534055",
"0.58629054",
"0.5860294",
"0.583536",
"0.5807561",
"0.57063335",
"0.570253",
"0.57024586",
"0.56939733",
"0.5688026",
"0.5629786",
"0.56064916",
"0.55854505",
"0.55703634",
"0.55703634",
"0.556218... | 0.8461856 | 0 |
Return a list of valid environments in proper order from candidates list. Given some list of environments, we validate that they're valid environments from our list (see ENVIRONMENTS) and that they come in the specific order of ENVIRONMENTS, as if that order is not maintained, the system can break as at least the initi... | def get_environments(candidates):
candidates = [str(candidate).lower() for candidate in candidates]
environments = []
for env in get_all_environments():
if env in candidates:
environments.append(env)
return environments | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def environments(self):\n env_txt = self.config[\"tox\"][\"envlist\"]\n env_lst_raw = env_txt.strip().replace(\"\\n\",\",\").split(\",\")\n env_lst = [x.strip() for x in env_lst_raw if x != \"\"]\n return env_lst",
"def _validate_envs(self):\n self.params.setdefault(\"fixed_env... | [
"0.6250549",
"0.60304165",
"0.60232043",
"0.5746839",
"0.57054394",
"0.56630826",
"0.56583",
"0.56552",
"0.5552066",
"0.54435354",
"0.54353595",
"0.5394181",
"0.5377956",
"0.5367124",
"0.53361195",
"0.53243375",
"0.53238887",
"0.5309738",
"0.5299743",
"0.5296233",
"0.52847147... | 0.78177494 | 0 |
Sets random seed for numpy and both CPU/GPU pytorch routines. If cuda is not available, this is silently ignored. | def set_seed(seed: int):
np.random.seed(seed)
torch.manual_seed(seed) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_random_seed(seed, cuda):\r\n if seed is None:\r\n seed = random.randint(0, 1000000000)\r\n\r\n torch.manual_seed(seed)\r\n np.random.seed(seed)\r\n random.seed(seed)\r\n if cuda:\r\n torch.cuda.manual_seed(seed)\r\n return seed",
"def set_seed(seed: int = 42) -> None:\n ... | [
"0.800863",
"0.7996074",
"0.7975033",
"0.7835161",
"0.7835161",
"0.7734041",
"0.77306277",
"0.7723644",
"0.7713678",
"0.77044183",
"0.76990074",
"0.76615953",
"0.7661553",
"0.7629241",
"0.7629241",
"0.7611851",
"0.7543603",
"0.7513361",
"0.74753404",
"0.7461881",
"0.74581224"... | 0.709249 | 43 |
Performs a feed forward step of the given model and returns model outputs given a torch.Tensor input. | def forward(model: nn.Module, inputs: torch.Tensor, device: torch.device):
model.eval()
model.to(device)
with torch.no_grad():
inputs = inputs.to(device)
return model(inputs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, *inputs) -> torch.Tensor:\n return self.model(*inputs)",
"def _forward(self, inputs):\n if is_tf_available():\n # TODO trace model\n predictions = self.model(inputs)[0]\n else:\n import torch\n with torch.no_grad():\n ... | [
"0.76977736",
"0.7204329",
"0.7195278",
"0.7128585",
"0.7097982",
"0.704494",
"0.7038716",
"0.70085025",
"0.6868424",
"0.68613386",
"0.6828786",
"0.6806121",
"0.6737558",
"0.6733474",
"0.6724154",
"0.6706891",
"0.6704583",
"0.6702153",
"0.66637564",
"0.66450244",
"0.66189146"... | 0.7512393 | 1 |
Freeze or unfreeze weights | def set_module_trainable(module: nn.Module, mode: bool) -> None:
for param in module.parameters():
param.requires_grad = mode | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_weights(self):\n self.policy_backbone.reset_weights()\n self.value_backbone.reset_weights()\n self.action_head.reset_weights()\n self.critic_head.reset_weights()",
"def _Freeze(self) -> None:\n self._SetNodes(_FROZEN_NODE_COUNT)",
"def update_weights(self):\n\t\tpass",
... | [
"0.675625",
"0.67483294",
"0.667603",
"0.66535515",
"0.6608448",
"0.66018456",
"0.6579561",
"0.6530836",
"0.65286416",
"0.64714706",
"0.6356653",
"0.6345366",
"0.6322158",
"0.6300846",
"0.6296267",
"0.6280216",
"0.62768",
"0.62339324",
"0.6233554",
"0.6233554",
"0.6203171",
... | 0.0 | -1 |
Sets the maximum number of open files a picard process should use, at most. Conservatively lowered than the actual ulimit. | def _set_max_open_files(command, key):
global _MAX_OPEN_FILES
if _MAX_OPEN_FILES is None:
_MAX_OPEN_FILES = (paleomix.common.system.get_max_open_files(),)
(max_open_files,) = _MAX_OPEN_FILES
if max_open_files:
max_open_files = int(max_open_files * _FRAC_MAX_OPEN_FILES)
if max_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_open_file_limit(soft_limit: int) -> None:\n if os.name != 'nt': # resource module not available on Windows OS\n curr_soft_limit, curr_hard_limit = resource.getrlimit(\n resource.RLIMIT_NOFILE)\n if curr_soft_limit < soft_limit < curr_hard_limit:\n resource.setrlimit(... | [
"0.7524843",
"0.73289907",
"0.674657",
"0.6675783",
"0.6484213",
"0.6349542",
"0.62938243",
"0.6214472",
"0.62090945",
"0.61764324",
"0.61717737",
"0.6097594",
"0.5975605",
"0.5941119",
"0.59247196",
"0.59000725",
"0.5889576",
"0.5880121",
"0.5879073",
"0.58566475",
"0.582695... | 0.73297346 | 1 |
Represents a tagged region of an image. | def __init__(self, tag_name, left, top, width, height):
self.tag_name = tag_name
self.left = left
self.top = top
self.width = width
self.height = height | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def region(self):\n # type: () -> string_types\n return self._region",
"def GetRegion(self, label: 'unsigned char') -> \"itkImageRegion2\":\n return _itkLabelStatisticsImageFilterPython.itkLabelStatisticsImageFilterIF2IUC2_GetRegion(self, label)",
"def GetRegion(self, label: 'unsigned shor... | [
"0.6123968",
"0.6123431",
"0.6115299",
"0.6066477",
"0.605978",
"0.6051609",
"0.6044339",
"0.6000625",
"0.5988138",
"0.5939037",
"0.5926026",
"0.59246236",
"0.591588",
"0.5912396",
"0.5903",
"0.58908653",
"0.58900553",
"0.58764136",
"0.58636034",
"0.58482456",
"0.58307606",
... | 0.0 | -1 |
the evaluation function for the minmax algorithm. It evaluates the given situation, the evaluation function increases with the quality of the situation for the player | def evalFunction(situation, joueur):
number_moves = 0
for i in range(3):
for j in range(3):
if situation[i][j] != '':
number_moves += 1
winner = getWinner({"":0},situation, joueur)
if winner != None:
if Player.get_name(joueur) == Player.get_name(winner... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maximizer(evaluate):\n def strategy(player, board):\n def score_move(move):\n return evaluate(player, Othello.make_move(move, player, list(board)))\n return max(Othello.legal_moves(player, board), key=score_move)\n return strategy",
"def play_minimax(self, board, depth, max_pla... | [
"0.6288708",
"0.62397385",
"0.618512",
"0.6179201",
"0.6155608",
"0.6150884",
"0.6147977",
"0.6116346",
"0.6106967",
"0.61022943",
"0.6086872",
"0.59877646",
"0.5984906",
"0.5969812",
"0.5964938",
"0.5959587",
"0.59511477",
"0.59266704",
"0.59151864",
"0.5910679",
"0.5896348"... | 0.5997235 | 11 |
Create a batcher that uses the `batch_by_padded_size` strategy. The padded size is defined as the maximum length of sequences within the batch multiplied by the number of sequences in the batch. | def configure_minibatch_by_padded_size(
*,
size: Sizing,
buffer: int,
discard_oversize: bool,
get_length: Optional[Callable[[ItemT], int]] = None
) -> BatcherT:
# Avoid displacing optional values from the underlying function.
optionals = {"get_length": get_length} if get_length is not None e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_sequence(batch, padding_value=0.0):\n max_size = batch[0].size()\n trailing_dims = max_size[1:]\n max_len = max([s.size(0) for s in batch])\n \n if all(x.shape[0] == max_len for x in batch):\n # if all data sequences in batch have the same length, no need to pad\n return batch\... | [
"0.69971573",
"0.69015735",
"0.66134757",
"0.6612931",
"0.65997624",
"0.63594764",
"0.6271613",
"0.62341106",
"0.62217367",
"0.61242425",
"0.6122865",
"0.6017992",
"0.6004926",
"0.59535927",
"0.5933952",
"0.59226054",
"0.5919577",
"0.5911063",
"0.5905428",
"0.5885369",
"0.587... | 0.6848572 | 2 |
Minibatch a sequence by the size of padded batches that would result, with sequences binned by length within a window. The padded size is defined as the maximum length of sequences within the batch multiplied by the number of sequences in the batch. | def minibatch_by_padded_size(
seqs: Iterable[ItemT],
size: Sizing,
buffer: int = 256,
discard_oversize: bool = False,
get_length: Callable = len,
) -> Iterable[List[ItemT]]:
if isinstance(size, int):
size_ = itertools.repeat(size) # type: Iterator[int]
else:
size_ = iter(siz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_minibatch_by_padded_size(\n *,\n size: Sizing,\n buffer: int,\n discard_oversize: bool,\n get_length: Optional[Callable[[ItemT], int]] = None\n) -> BatcherT:\n # Avoid displacing optional values from the underlying function.\n optionals = {\"get_length\": get_length} if get_lengt... | [
"0.67373866",
"0.6609055",
"0.6508829",
"0.63938195",
"0.6390194",
"0.63546246",
"0.61919475",
"0.61403996",
"0.612676",
"0.6045568",
"0.6028677",
"0.5950269",
"0.5947748",
"0.59245944",
"0.59152263",
"0.59033376",
"0.5873051",
"0.5866662",
"0.5810848",
"0.5798175",
"0.579749... | 0.68472254 | 0 |
Given a list of sequences, return a batched list of indices into the list, where the batches are grouped by length, in descending order. Batches may be at most max_words in size, defined as max sequence length size. | def _batch_by_length(
seqs: Sequence[Any], max_words: int, get_length=len
) -> List[List[Any]]:
# Use negative index so we can get sort by position ascending.
lengths_indices = [(get_length(seq), i) for i, seq in enumerate(seqs)]
lengths_indices.sort()
batches = []
batch: List[int] = []
for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_by_length(seqs, max_words: int) -> List[List[int]]:\n # Use negative index so we can get sort by position ascending.\n lengths_indices = [(len(seq), i) for i, seq in enumerate(seqs)]\n lengths_indices.sort()\n batches: List[List[int]] = []\n batch: List[int] = []\n for length, i in leng... | [
"0.79594916",
"0.662542",
"0.6537568",
"0.62752527",
"0.6268335",
"0.60453343",
"0.60075045",
"0.58778757",
"0.58778757",
"0.58778757",
"0.5862835",
"0.5858457",
"0.5846378",
"0.58032376",
"0.5743052",
"0.5734373",
"0.5697787",
"0.5694817",
"0.5674217",
"0.5653801",
"0.562649... | 0.76815635 | 1 |
Returns your trade history for a given market, specified by the "currencyPair" POST parameter. You may specify "all" as the currencyPair to receive your trade history for all markets. You may optionally specify a range via "start" and/or "end" POST parameters, given in UNIX timestamp format; if you do not specify a ran... | def returnTradeHistory(self,
currency_pair="all",
start=datetime.now() - timedelta(days=1),
end=datetime.now()):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_trade_history(self, currency_pair):\n return self.api_query('returnTradeHistory', {\"currencyPair\": currency_pair})",
"def public_market_history(self, market_symbol):\n return self.get(f'markets/{market_symbol}/trades')",
"def get_trade_history(self, pair, limit=20):\r\n method... | [
"0.7803931",
"0.7041022",
"0.70198363",
"0.6681903",
"0.6533068",
"0.6526645",
"0.6486975",
"0.6471808",
"0.6391747",
"0.6347381",
"0.63212645",
"0.6296558",
"0.6241187",
"0.62240875",
"0.6195843",
"0.6189345",
"0.61432767",
"0.6142551",
"0.61038566",
"0.60693336",
"0.6027254... | 0.8027637 | 1 |
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]
print("Normalized confusion matrix")
else:
... | {
"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.8193291",
"0.8094472",
"0.8027684",
"0.80178267",
"0.799257",
"0.7989883",
"0.7979287",
"0.7974278",
"0.79594076",
"0.79549026",
"0.79360807",
"0.79330444",
"0.7932846",
"0.7929725",
"0.79248244",
"0.7923015",
"0.7922415",
"0.7922163",
"0.7921376",
"0.79207855",
"0.791628"... | 0.7827241 | 82 |
This function adjusts the translation vector such that the difference between the observed real world coordinates X_gcp and the triangulated real world coordinates of u_gcp is minimized. | def estimate_translation(X_gcp, u_gcp, t0, R, P0):
# Note: u_gcp is of the form [u1, v1, u2, v2]
x1, x2 = u_gcp[:, :2], u_gcp[:, 2:]
t = t0.copy()
def residuals(t, X_gcp, x1, x2, R, P0):
t_tmp = t.copy()
P1 = np.column_stack((R, t_tmp))
xyz = get_point_estimates(P0, P1, x1, x2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimate_pose(self, X_gcp, u_gcp, p0):\n\n self.p = p0.copy()\n\n def residuals(p, X_gcp, u_gcp):\n self.p = p.copy()\n xuv = self.ene_to_camera(X_gcp)\n return xuv.ravel() - u_gcp.ravel()\n\n res = least_squares(residuals, self.p, args=(X_gcp, u_gcp))\n ... | [
"0.603583",
"0.54517376",
"0.53136885",
"0.52078396",
"0.5162308",
"0.51604646",
"0.50973505",
"0.50883937",
"0.5033131",
"0.50299877",
"0.5010085",
"0.49948713",
"0.49875307",
"0.49869317",
"0.4986291",
"0.4980593",
"0.4980397",
"0.49668637",
"0.49386597",
"0.49290872",
"0.4... | 0.6933285 | 0 |
Initialiser for a Node, this just sets the unique index and then increases the counter for the unique indices. | def __init__(self):
self._idx = Node.index
Node.index += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, num_nodes):\n self._num_nodes = num_nodes\n self._node_numbers = [node for node in range(num_nodes) for dummy_idx in range(num_nodes)]",
"def __init__(self, num_nodes):\n self._num_nodes = num_nodes\n self._node_numbers = [node for node in range(num_nodes) for dummy... | [
"0.6841737",
"0.6841737",
"0.6841737",
"0.6841737",
"0.6841737",
"0.6841737",
"0.6810584",
"0.6672741",
"0.6578876",
"0.656762",
"0.642964",
"0.6417224",
"0.6397527",
"0.6388278",
"0.63882124",
"0.6369581",
"0.6299679",
"0.62996477",
"0.62693936",
"0.62686634",
"0.62533724",
... | 0.79367363 | 0 |
Get the name of the node. | def get_name(self):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_node_name(self, node):\n return node.name",
"def node_name(self):\n return self._node_name",
"def get_node_name(self):\n return util.join_names_underscore(self.name, str(self.as_pointer()))",
"def get_node_name(self, node):\n raise NotImplementedError()",
"def read_name(... | [
"0.91318023",
"0.8909156",
"0.8667112",
"0.8659755",
"0.85862726",
"0.85862726",
"0.85862726",
"0.85862726",
"0.8533004",
"0.84526956",
"0.84089714",
"0.83891714",
"0.82571524",
"0.8160213",
"0.8159024",
"0.81400615",
"0.8117765",
"0.81086236",
"0.81086236",
"0.7943999",
"0.7... | 0.0 | -1 |
Get the unique name for this node, by default this corresponds to the unique index given to it. | def get_unique_name(self):
return self._idx | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_node_name(self):\n return util.join_names_underscore(self.name, str(self.as_pointer()))",
"def node_name(self):\n return self._node_name",
"def _auto_name(self):\n return \"node_\"+str(self._id)",
"def name(self):\n return self._unique_id",
"def _generate_node_name(self)... | [
"0.77868366",
"0.7597439",
"0.75457835",
"0.74656796",
"0.73368305",
"0.73246914",
"0.7228866",
"0.7161467",
"0.712376",
"0.7115033",
"0.71007776",
"0.707128",
"0.70702845",
"0.7030005",
"0.7023139",
"0.7021814",
"0.7021814",
"0.7021814",
"0.7021814",
"0.702045",
"0.69965774"... | 0.8197985 | 0 |
Function that gets the number of leaf nodes reachable from the current node. Should return a set of leaf nodes. | def get_leaf_nodes(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaf_count(self) -> int:\n if self.children == []:\n return 1\n else:\n return sum([x.leaf_count() for x in self.children])",
"def leaf_count(t: Tree) -> int:\n if t.children == []:\n return 1\n else:\n return sum([leaf_count(child) for child in t.child... | [
"0.7865371",
"0.7445376",
"0.7384279",
"0.72760844",
"0.7270197",
"0.7221459",
"0.7176545",
"0.7164392",
"0.7137541",
"0.7086531",
"0.70462614",
"0.70396817",
"0.6928041",
"0.68939304",
"0.6814443",
"0.6812536",
"0.67891836",
"0.67710936",
"0.6677024",
"0.6630219",
"0.6600195... | 0.6573927 | 24 |
Returns a dictionary of thermodynamic values for a structure, using all available distinct spinstate calculations. | def get_thermo(self, structure):
dir = IO(dir=os.path.join(self.loc, structure))
values = dir.get_values(
structure, "freq.log", self.freqvalid, self.thermo_vals)
return values | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thermo_all(self):\n \n print(\"Calculating thermodynamic values.\")\n # Collect thermodynamic values from files. \n results = dvals([self.get_thermo(struct) for struct in self.structs])\n \n # Construct dataframe. \n headers = np.array(self.thermvals)\n t... | [
"0.6017293",
"0.5776705",
"0.57002956",
"0.5685253",
"0.56660265",
"0.5654497",
"0.5594675",
"0.5579747",
"0.55148935",
"0.5354339",
"0.53286994",
"0.5325417",
"0.5310011",
"0.53041065",
"0.52913284",
"0.5281502",
"0.52713674",
"0.5250682",
"0.524717",
"0.52428365",
"0.523023... | 0.5299207 | 14 |
Go straight down and turn off the motors. Do not call this function if you use the with keyword. Landing is done automatically when the context goes out of scope. | def land(self, velocity=VELOCITY):
action = Land(velocity=velocity)
goal = PositionControlGoal(pickle.dumps(action))
self._add_mc_goal(goal) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n self.turnOffMotors()",
"def stop(self) -> None:\n turnOffMotors()",
"def turnOffMotors(self) -> None:\n mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)\n mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE)\n mh.getMotor(3).run(Adafruit_MotorHAT.RELEASE)\n mh.... | [
"0.7661179",
"0.76510394",
"0.721095",
"0.7113851",
"0.710707",
"0.7047729",
"0.6981663",
"0.69774455",
"0.68791",
"0.6867762",
"0.68237245",
"0.68184423",
"0.6810357",
"0.67925936",
"0.6777448",
"0.67730796",
"0.6759469",
"0.67592764",
"0.6749892",
"0.6678987",
"0.6661292",
... | 0.0 | -1 |
Generate random numbers with custom probability density function. To generate the sample, the truncation method is used. x values vector. y values vector. Output vector shape. Interpolation type. See scipy.interpolate.interp1d. Random numbers with given shape. | def rand_custom(x: np.ndarray, y: np.ndarray,
shape: tuple=(1,), interp_type: str='linear') -> np.ndarray :
assert (y >= 0).any(), "y shouldn't contain negative numbers"
size = 1
for n in shape:
size *= n
y_norm = y/y.max()
func = interp1d(x, y_norm, kind=inte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, shape):\n return np.random.uniform(low=self.minval, high=self.maxval, size=shape)",
"def __call__(self, shape):\n return np.random.normal(loc=self.mean, scale=self.stddev, size=shape)",
"def generateData(numPoints,x,y):\n\tfor i in range(0,numPoints):\n\t\tif (i % 2 == 0):\n\t\... | [
"0.64920694",
"0.6336859",
"0.61459595",
"0.59701604",
"0.59701604",
"0.5966256",
"0.5944712",
"0.5892467",
"0.5871198",
"0.58628494",
"0.5826367",
"0.5774362",
"0.5734146",
"0.569712",
"0.56898415",
"0.56016535",
"0.5598789",
"0.55917114",
"0.55769706",
"0.5570158",
"0.55340... | 0.69818455 | 0 |
Reshapes a 1hot vector into a 1hot tensor keras requires the tensor | def make_tensor(self,vec):
return np.reshape(vec, (1,len(vec))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flat_to_one_hot(val, ndim):\n shape =np.array(val).shape\n v = np.zeros(shape + (ndim,))\n if len(shape) == 1:\n v[np.arange(shape[0]), val] = 1.0\n else:\n v[val] = 1.0\n return v",
"def one_hot(x, num_classes, dtype=jnp.float32):\n return jax.nn.one_hot(x, num_classes).astype(... | [
"0.72796166",
"0.7178082",
"0.7126229",
"0.71131223",
"0.71026784",
"0.7070449",
"0.7070449",
"0.7055149",
"0.7004683",
"0.69970095",
"0.6963246",
"0.69434893",
"0.6929555",
"0.69155747",
"0.68983394",
"0.6893339",
"0.68506235",
"0.68482786",
"0.6826335",
"0.68231493",
"0.681... | 0.0 | -1 |
Create and initialize a "Card" object of a specific "suit" and "rank". | def __init__(self, suit, rank):
if (suit in SUITS) and (rank in RANKS):
self.suit = suit
self.rank = rank
else:
self.suit = None
self.rank = None
global outcome
outcome = INVALID_CARD, suit, rank | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def card_factory(rank,suit):\n pass",
"def __init__(self, suit: str, rank: str) -> None:\n self.suit = suit\n self.rank = rank\n self.value = Card.values[rank]\n self.hidden = False",
"def __init__(self, rank, suit):\n self._rank = rank\n self._suit = suit",
"def ... | [
"0.8417709",
"0.82448536",
"0.80454075",
"0.80450934",
"0.7753314",
"0.7684203",
"0.7673155",
"0.764854",
"0.7525316",
"0.747562",
"0.72691536",
"0.7186329",
"0.7092202",
"0.7051383",
"0.6941752",
"0.690207",
"0.68854225",
"0.6798506",
"0.6795253",
"0.6778751",
"0.67590874",
... | 0.7888103 | 4 |
Return a string representation of a "Card" object in a humanreadable form. | def __str__(self):
return self.suit + self.rank | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cards_to_string(self, cards):\n return repr(self._eval.card2string(map(lambda x: x & 63, cards)))\\\n #.lower().replace(\"h\", u\"\\u2761\").replace(\"s\", u\"\\u2660\").replace(\"c\", u\"\\u2663\").replace(\"d\", u\"\\u2662\")",
"def __repr__(self):\n return f\"Card({self.face}, {s... | [
"0.7887338",
"0.7832243",
"0.78112024",
"0.7648394",
"0.75565225",
"0.75565225",
"0.7496251",
"0.7464843",
"0.7463946",
"0.74505657",
"0.74111986",
"0.74104804",
"0.7308573",
"0.72759026",
"0.72759026",
"0.7273749",
"0.7191384",
"0.7181591",
"0.71749115",
"0.7135009",
"0.7124... | 0.64313865 | 62 |
Create and initialize the "Hand" object to have an empty list of "Card" objects. | def __init__(self):
self.hand = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, cards_on_table=None, cards=[], hands_list=[]):\n self.cards = cards\n self.cards_on_table = cards_on_table\n self.hands_list = hands_list",
"def init_hand(self):\n for _ in range(self._handsize):\n if self._deck.size() == 0:\n self._discard... | [
"0.78346866",
"0.78093284",
"0.77272063",
"0.76039076",
"0.7411558",
"0.736056",
"0.7340134",
"0.72759813",
"0.71990746",
"0.71608406",
"0.7145801",
"0.7127543",
"0.7098431",
"0.70586973",
"0.703005",
"0.69854844",
"0.6920605",
"0.69036525",
"0.6880182",
"0.6829131",
"0.67907... | 0.75171715 | 4 |
Return a string representation of a "Hand" object in a humanreadable form. | def __str__(self):
string_representation = HAND_CONTAINS
for card in self.hand:
string_representation += str(card) + " "
return string_representation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return Hand.__str__(self) + '\\nHand Rank: ' + self.get_full_label()",
"def __str__(self):\n string = \"Hand contains \"\n h = self.hand\n \n for i in range(len(h)):\n string += str(h[i].get_suit()) + str(h[i].get_rank()) + \" \"\n \n ... | [
"0.8378531",
"0.7888545",
"0.7866206",
"0.7686549",
"0.7391914",
"0.72460425",
"0.7219685",
"0.71884423",
"0.7114498",
"0.68291724",
"0.676512",
"0.6754457",
"0.6744275",
"0.66804856",
"0.6679284",
"0.6673427",
"0.660103",
"0.65977013",
"0.659113",
"0.6550406",
"0.650652",
... | 0.78102654 | 3 |
Return a string representation of a "Deck" object in a humanreadable form. | def __str__(self):
string_representation = DECK_CONTAINS
for card in self.deck:
string_representation += str(card) + " "
return string_representation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\r\n output = \"Deck contains\"\r\n for card in self.deck:\r\n output += \" %s\" % (card)\r\n return output + \".\"",
"def __str__(self):\n string = \"Deck contains \"\n\n for i in range(len(self.deck)):\n string += str(self.deck[i].get_s... | [
"0.8254089",
"0.80279183",
"0.7866177",
"0.7859308",
"0.7789782",
"0.7629925",
"0.76150256",
"0.7581183",
"0.7512425",
"0.7495297",
"0.7343425",
"0.7267655",
"0.71549875",
"0.7119685",
"0.7005873",
"0.6941851",
"0.6941851",
"0.693934",
"0.69350797",
"0.69010574",
"0.69010574"... | 0.77253217 | 5 |
Pause the specified instance. | def pause(self, instance, callback):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pause(self, instance):\n self.power_off(instance)",
"def pause(self, arguments):\n instance_name = arguments['<instance>']\n instance_name = self.activate(instance_name)\n\n vmrun = VMrun(self.vmx, user=self.user, password=self.password)\n if vmrun.pause() is None:\n ... | [
"0.7846715",
"0.7468729",
"0.7352451",
"0.7137987",
"0.6999904",
"0.6735755",
"0.67219514",
"0.6661565",
"0.66468155",
"0.6605586",
"0.6605586",
"0.6526896",
"0.65103674",
"0.65103674",
"0.6468604",
"0.6464788",
"0.64631665",
"0.6452783",
"0.644703",
"0.64444405",
"0.6418519"... | 0.7687334 | 1 |
Find the level with maximum sum in a binary tree. | def level_with_maximum_sum(root):
if root is None:
return
stack = [root]
level = 1
max_sum = root.data
max_sum_level = 1
while len(stack):
current_level_sum = 0
next_level_nodes = []
for _ in range(len(stack)):
node = stack.pop(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_level_maxsum (self):\r\n level_queue = [self]\r\n next_level_queue = []\r\n curr_level = 0\r\n max_sum = -sys.maxsize\r\n while level_queue:\r\n curr_node = level_queue.pop(0)\r\n if curr_node.left:\r\n next_level_queue.append(curr_no... | [
"0.8270512",
"0.771773",
"0.75250995",
"0.72688776",
"0.7244109",
"0.72228926",
"0.72160995",
"0.7200714",
"0.71639454",
"0.713765",
"0.70733386",
"0.70430434",
"0.6949941",
"0.6937614",
"0.6919456",
"0.6903202",
"0.68495774",
"0.6849166",
"0.6833248",
"0.6807303",
"0.6791756... | 0.7986476 | 1 |
Get learning rate warmup. | def _get_learning_rate_warmup(global_step):
warmup_steps = FLAGS.warmup_steps
warmup_scheme = FLAGS.warmup_scheme
tf.logging.info(" learning_rate=%g, warmup_steps=%d, warmup_scheme=%s" %
(FLAGS.learning_rate, warmup_steps, warmup_scheme))
# Apply inverse decay if global steps less than warmu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_learning_rate():\n return 0.00001",
"def learning_rate_fn():\n start_learning_rate = FLAGS.start_learning_rate\n step = tf.cast(tf.compat.v1.train.get_or_create_global_step(), 'float32')\n effective_step = tf.maximum(step - FLAGS.lr_decay_after_num_steps + 1, 0)\n lr_step_ratio = tf.cast(effective... | [
"0.769033",
"0.7636417",
"0.7619416",
"0.758551",
"0.74790305",
"0.74744624",
"0.7455846",
"0.74309945",
"0.73360914",
"0.70708805",
"0.7050627",
"0.7050627",
"0.70045936",
"0.6984606",
"0.6972434",
"0.69477254",
"0.6905006",
"0.68998766",
"0.6884278",
"0.68823004",
"0.688230... | 0.75143474 | 4 |
Configures the learning rate. | def configure_learning_rate(num_samples_per_epoch, global_step):
start_decay_step, decay_steps, decay_factor = _get_decay_info()
tf.logging.info(" decay_scheme=%s, start_decay_step=%d, decay_steps %d, "
"decay_factor %g" % (FLAGS.decay_scheme,
start_decay_st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_learning_rate(self, rate):\n self.SGD.set_learning_rate(rate)",
"def adjust_lr(self):\n learning_rate = self.params.base_lr * (1 - float(self.epoch) / self.params.num_epoch) ** self.params.power\n for param_group in self.opt.param_groups:\n param_group['lr'] = learning_rat... | [
"0.78593874",
"0.75907296",
"0.742758",
"0.7406107",
"0.739691",
"0.7320627",
"0.7320627",
"0.72974896",
"0.7253351",
"0.7229305",
"0.721023",
"0.72072744",
"0.71990186",
"0.71936136",
"0.7180078",
"0.7170698",
"0.7169669",
"0.7165654",
"0.71405464",
"0.71101654",
"0.71101654... | 0.0 | -1 |
Whether to use L2 weight decay for `param_name`. | def _do_use_weight_decay(self, param_name):
if not self.weight_decay_rate:
return False
if self.exclude_from_weight_decay:
for r in self.exclude_from_weight_decay:
if re.search(r, param_name) is not None:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _do_use_weight_decay(self, param_name):\n if self._exclude_from_weight_decay:\n for r in self._exclude_from_weight_decay:\n if re.search(r, param_name) is not None:\n return False\n return True",
"def _do_use_weight_decay(self, param_name):\n ... | [
"0.7041217",
"0.70360625",
"0.69714236",
"0.69714236",
"0.69714236",
"0.69714236",
"0.6149769",
"0.6118704",
"0.60733795",
"0.5877474",
"0.573254",
"0.5686321",
"0.56087875",
"0.5540929",
"0.5531922",
"0.55270326",
"0.5491952",
"0.5461079",
"0.54471636",
"0.54453224",
"0.5440... | 0.7056546 | 4 |
Determine the locale best suited for the current user. | def _get_locale() -> str:
languages = flask.current_app.config['LANGUAGES'].keys()
locale = flask.request.accept_languages.best_match(languages)
# If no locale could be determined, fall back to the default.
if locale is None:
locale = flask.current_app.config['BABEL_DEFAULT_LOCALE']
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_locale_for_user(self):\n return 'en_US' # TODO(psimakov): choose proper locale from profile",
"def get_locale():\n localLang = request.args.get('locale')\n supportLang = app.config['LANGUAGES']\n if localLang in supportLang:\n return localLang\n userId = request.args.get('login... | [
"0.80114067",
"0.8005258",
"0.71447736",
"0.71329165",
"0.6947764",
"0.69275945",
"0.68886733",
"0.68472785",
"0.68013805",
"0.67823595",
"0.66362613",
"0.66362613",
"0.6544875",
"0.6440085",
"0.6418648",
"0.6359177",
"0.62580633",
"0.6096582",
"0.60913056",
"0.6077827",
"0.6... | 0.695923 | 4 |
Get the median of a list of values | def median(values):
# Write the median() function
midpoint = int(len(values) / 2)
if len(values) % 2 == 0:
median = (values[midpoint - 1] + values[midpoint]) / 2
else:
median = values[midpoint]
return float(median) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_median(numlist):\n return np.median(numlist)",
"def median(v: List[float]) -> float:\n return _median_even(v) if len(v) % 2 == 0 else _median_odd(v)",
"def median(values):\n # Write the median() function\n midpoint = int(len(values) / 2)\n if len(values) % 2 == 0:\n median = (valu... | [
"0.856921",
"0.84415704",
"0.82220733",
"0.8212018",
"0.8115945",
"0.80988985",
"0.80986464",
"0.8095384",
"0.8089248",
"0.8082627",
"0.7885181",
"0.78799623",
"0.7876769",
"0.78682256",
"0.77975774",
"0.779382",
"0.7740889",
"0.77263594",
"0.77061564",
"0.7684539",
"0.763421... | 0.8278074 | 2 |
This method is used to compute section modulus at RBS center (step 2 and 3 in ANSI Section 5.8) | def compute_probable_moment_RBS(self, connection_type, steel, left_beam, right_beam):
Cpr = (steel.Fy+steel.Fu) / (2*steel.Fy)
if Cpr >= 1.2:
Cpr = 1.2
if connection_type == 'typical exterior' or connection_type == 'top exterior':
left_Z_RBS = left_beam.section['Zx']... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modulus(self):\n return math.sqrt(self._reNum ** 2 + self._imNum ** 2)",
"def bulk_modulus():\n\n return 10000.0",
"def modulus(self):\n return self._n",
"def modulus(vect):\n return np.sqrt(vect[0]**2 + vect[1]**2 + vect[2]**2)",
"def initial_shear_modulus(self):\n retur... | [
"0.7032002",
"0.69448715",
"0.6898137",
"0.6703035",
"0.6404891",
"0.63789225",
"0.6259087",
"0.610944",
"0.60928386",
"0.6070669",
"0.5936395",
"0.59359664",
"0.5895157",
"0.5874702",
"0.580055",
"0.57279116",
"0.5695238",
"0.5590553",
"0.55862683",
"0.5561799",
"0.5543533",... | 0.0 | -1 |
This method calculates the probable maximum moment at the face of the column. (step 5 in ANSI Section 5.8) | def compute_probable_moment_column_face(self, connection_type):
Sh = self.left_RBS_dimension['a'] + self.left_RBS_dimension['b']/2
if connection_type == 'typical exterior' or connection_type == 'top exterior':
self.moment['Mf1'] = self.moment['Mpr1'] + self.shear_force['VRBS1']*Sh
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_greatest_probability(self):\n greatest = -1\n for i in range(self.dim):\n for j in range(self.dim):\n if self.kb[i][j] > greatest:\n greatest = self.kb[i][j]\n\n return greatest",
"def findMaxFactor(self):\n factorMax = 0\n f... | [
"0.6816111",
"0.65952337",
"0.63161397",
"0.62459975",
"0.6177082",
"0.6126146",
"0.6116763",
"0.6106041",
"0.60926247",
"0.6061725",
"0.6061407",
"0.6061407",
"0.6061407",
"0.6061407",
"0.6061407",
"0.6061407",
"0.6030242",
"0.60264355",
"0.6014071",
"0.60043937",
"0.600139"... | 0.5905731 | 31 |
Extended expiration time of token by 15 min. | def keep_alive(self):
if self.__isLogin:
url = buildCommandUrl(
self.server, "/as/user/keep", self.__userInfo.strToken)
result = json_request("GET", url, token=self.__userInfo.strToken)
return result["maxAge"]
else:
raise ServerXmlRpcError(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expire(self):\n logging.debug(\"Expiring token as wanted...\")\n self.expiration = datetime.now() - timedelta(seconds=(10))",
"def token_expires_in(self):\n return 60 * 60",
"def _set_token_expiration_time(self, expires_in):\n self.token_expiration_time = dt.datetime.utcnow() + ... | [
"0.7644133",
"0.7555094",
"0.7392228",
"0.7228399",
"0.7171136",
"0.6989114",
"0.6852538",
"0.67627484",
"0.67546636",
"0.6662883",
"0.6662883",
"0.6661481",
"0.6408124",
"0.6371231",
"0.62859744",
"0.62859744",
"0.62859744",
"0.62782234",
"0.62540656",
"0.62321687",
"0.62181... | 0.0 | -1 |
Test the ``delete_files_and_folders`` function is called once correctly. | def test_delete_files_and_folders_called_once_correctly(
self,
temporary_frameworks: Path,
patch_delete_files_and_folders: MagicMock,
test_input_dir_cookiecutter_docs_aqa: str,
) -> None:
# Define a path to the example output folder, which is the parent of
# `tempora... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n for d in os.listdir(tmp_dir_path):\n d_path = os.path.join(tmp_dir_path,d)\n try:\n os.remove(d_path)\n except:\n for f in os.listdir(d_path):\n f_path = os.path.join(d_path,f)\n os.rem... | [
"0.7142677",
"0.7087033",
"0.6894392",
"0.6893574",
"0.66832036",
"0.6672585",
"0.66723126",
"0.6597923",
"0.6595609",
"0.6594561",
"0.6527313",
"0.65036017",
"0.64994246",
"0.64462423",
"0.64364576",
"0.64364576",
"0.64283115",
"0.6414156",
"0.6406395",
"0.6393021",
"0.63851... | 0.7202115 | 0 |
Draws and hides the annotation box for the given axis "ax". | def annotate(self, ax):
annotation = ax.annotate(self.template, xy=(0, 0), ha='right',
xytext=self.offsets, textcoords='offset points', va='bottom',
bbox=dict(boxstyle='round,pad=0.5', fc='yellow', alpha=0.5),
arrowprops=dict(arrowstyle='->', connectionstyle='arc3... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hide_axes(plot, axes=('x', 'y')):\n if isinstance(axes, str):\n axes = tuple(axes)\n\n for label in axes:\n axis = getattr(plot, label + 'axis')\n axis = axis[0]\n axis.major_label_text_alpha = 0.0\n axis.major_label_text_font_size = '0pt'\n axis.axis_line_alpha ... | [
"0.646807",
"0.62232107",
"0.6115653",
"0.6101362",
"0.5957293",
"0.5921123",
"0.58736056",
"0.582345",
"0.5802178",
"0.5774309",
"0.57678103",
"0.5736092",
"0.573",
"0.5703413",
"0.569252",
"0.562651",
"0.561573",
"0.5609526",
"0.5596867",
"0.5590682",
"0.5588717",
"0.5583... | 0.5963586 | 5 |
Compute sum along the given axis. Assumes that nonnans of arr are grouped at the beginning of the sequence. | def get_ragged_sum(
arr,
lens,
axis = -1,
device=torch.device('cpu'),
):
# add zero as first dimension so that when there are zero non-nan values,
# it selects zero as the value
zeros_shape = list(arr.shape)
zeros_shape[axis] = 1
zero = torch.zeros(zeros_shape).to(device)
arr = torch.cat([ze... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_sum(a, axis, count):\n if a.shape[axis] == count:\n return a.sum(axis)\n elif a.shape[axis] == 1:\n return count * a.sum(axis)\n else:\n raise IndexError('Cannot be broadcast: a.shape=%s, axis=%d, count=%d' % (a.shape, axis, count))",
"def sum(input, axis=None, dtype=None, ke... | [
"0.7088682",
"0.6781375",
"0.6716286",
"0.66546416",
"0.66476053",
"0.65899515",
"0.6581948",
"0.6536099",
"0.65120155",
"0.64802307",
"0.6477352",
"0.64318466",
"0.6395206",
"0.6370942",
"0.62027407",
"0.62027186",
"0.6149912",
"0.6144445",
"0.6127261",
"0.6119597",
"0.61173... | 0.6800572 | 1 |
Quest gets rewarded to the user. The quest must be active or force to be true for that to be possible. Returns true if the user was rewarded or false if conditions were not met. | def giveReward(self, session, quest_id, force = False):
quest = Quest.getByID(session, quest_id)
if force == False:
# This means if the quest is not active,
# because the ORM returns an empty list
if quest.active == []:
print("COULD NOT GIVE REWARD FOR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkGoal(self):\n # -- It is not included for simplifity --#\n if self.reward_cumulative != None:\n x = round((abs(self.reward_cumulative) - abs(round(self.reward_cumulative))) * 100);\n rem_goal = x % 25\n rem_timeout = x % 20\n if rem_goal == 0 and x... | [
"0.62315357",
"0.608068",
"0.5782439",
"0.555646",
"0.55398476",
"0.55210125",
"0.5489494",
"0.5483745",
"0.5472129",
"0.5458005",
"0.53758585",
"0.5372846",
"0.5320866",
"0.531467",
"0.5296906",
"0.5264385",
"0.52607036",
"0.5251061",
"0.523796",
"0.52271503",
"0.52027553",
... | 0.7536441 | 0 |
Returnns an ORM (object) where the User.id is matched | def getByID(session, id):
return session.query(User).filter(User.id == id).first() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_id(cls, _id):\n user = cls.query.filter_by(id=_id).first()\n return user",
"def find_by_id(cls, user_id):\n return UsersModel.query.filter_by(id=user_id).first()",
"def get_object(self):\n return get_object_or_404(User, id__iexact=self.request.user.id)",
"def get_objec... | [
"0.7423261",
"0.73571414",
"0.7324542",
"0.7324542",
"0.73180574",
"0.73009616",
"0.726618",
"0.72439265",
"0.7165027",
"0.71345896",
"0.7105183",
"0.70998126",
"0.70787853",
"0.70536464",
"0.70536464",
"0.70536464",
"0.70536464",
"0.7039098",
"0.70174104",
"0.69973165",
"0.6... | 0.7113671 | 10 |
Load an image from file into a numpy array. Puts image into numpy array to feed into tensorflow graph. Note that by convention we put it into a numpy array with shape (height, width, channels), where channels=3 for RGB. | def load_image_into_numpy_array(path):
img_data = tf.io.gfile.GFile(path, 'rb').read()
image = Image.open(BytesIO(img_data))
(im_width, im_height) = image.size
return np.array(image.getdata()).reshape(
(im_height, im_width, 3)).astype(np.uint8) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_image_into_numpy_array(path):\n return np.array(Image.open(path))",
"def load_image_into_numpy_array(path):\n return np.array(Image.open(path))",
"def load_image_into_numpy_array(path):\n MAX_SIZE = (1440, 1080)\n # img_data = tf.io.gfile.GFile(path, 'rb').read()\n image = Image.open(pa... | [
"0.7774965",
"0.7774965",
"0.771784",
"0.7717185",
"0.7704105",
"0.77009773",
"0.7624171",
"0.7611585",
"0.75013953",
"0.74523175",
"0.7431118",
"0.74028707",
"0.734838",
"0.7312722",
"0.7295734",
"0.72744113",
"0.72401977",
"0.7219901",
"0.7203454",
"0.7185667",
"0.71833575"... | 0.78659564 | 0 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
id = dictionary.get('id')
consumer_id = dictionary.get('consumerId')
consumer_ssn = dictionary.get('consumerSsn')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.83181584",
"0.8168118",
"0.8168118",
"0.8118749",
"0.8089047",
"0.79787344",
"0.7949278",
"0.79231393",
"0.7898951",
"0.78923255",
"0.788838",
"0.7882321",
"0.7882212",
"0.7876749",
"0.78585315",
"0.7836853",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",... | 0.7390997 | 97 |
Set the status to success for aggregation. | def fixit(file):
with open(file, "r") as f:
config = json.load(f)
if "job_status" in config["supply-curve-aggregation"]:
del config["supply-curve-aggregation"]["job_status"]
if "rep-profiles" in config:
del config["rep-profiles"]
fname = os.path.basename(file)
cname = "_".joi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def success(self):\n self.succeeded = True",
"def addSuccess(self, test):\n test.status = \"success\"",
"def indicate_success(self):\n pass",
"def success(self, success):\n self._success = success",
"def mark_success(self):\n LOGGER.debug('Marking current_state as: %s', s... | [
"0.70651424",
"0.70146805",
"0.6989558",
"0.6974699",
"0.68759906",
"0.6851615",
"0.6814895",
"0.6687058",
"0.65164775",
"0.64398915",
"0.6432007",
"0.6432007",
"0.6432007",
"0.6432007",
"0.6432007",
"0.6432007",
"0.6432007",
"0.63550615",
"0.63550615",
"0.63550615",
"0.63550... | 0.0 | -1 |
Calculate the great circle distance between two points on the earth (specified in decimal degrees) All args must be of equal length. | def haversine_np(lon1, lat1, lon2, lat2):
lon1, lat1, lon2, lat2 = map(np.radians, [lon1, lat1, lon2, lat2])
dlon = lon2 - lon1
dlat = lat2 - lat1
a = np.sin(dlat/2.0)**2 + np.cos(lat1) * np.cos(lat2) * np.sin(dlon/2.0)**2
c = 2 * np.arcsin(np.sqrt(a))
km = 6367 * c
return km | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def great_circle(lat_1, long_1, lat_2, long_2):\n long_1 = m.radians(long_1)\n lat_1 = m.radians(lat_1)\n long_2 = m.radians(long_2)\n lat_2 = m.radians(lat_2)\n\n d = 2 * 6367.45 * m.asin(\n m.sqrt(haversine(lat_2 - lat_1)\n + m.cos(lat_1)*m.cos(lat_2) *\n haversine(long... | [
"0.77671224",
"0.759654",
"0.7484878",
"0.7325109",
"0.72861654",
"0.7247699",
"0.71952677",
"0.7115459",
"0.7086906",
"0.705637",
"0.7032969",
"0.70192075",
"0.7010684",
"0.69994247",
"0.69162226",
"0.6907159",
"0.6864115",
"0.68605155",
"0.6820379",
"0.6818472",
"0.68025315... | 0.0 | -1 |
Name of this `Description`. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self) -> str:\n pass",
"def name(self) -> str:\n pass",
"def name(self) -> str:\n pass",
"def name(self) -> str:\n pass",
"def name(self):\n pass",
"def name(self):\n return self.NAME",
"def name(self):\r\n pass",
"def name(self) -> str:\n ... | [
"0.8301062",
"0.8301062",
"0.8301062",
"0.8301062",
"0.8257291",
"0.8244603",
"0.82430655",
"0.813708",
"0.813708",
"0.813708",
"0.813708",
"0.813708",
"0.813708",
"0.813708",
"0.8134998",
"0.8134998",
"0.8134998",
"0.8134998",
"0.8134998",
"0.8134998",
"0.8134998",
"0.8134... | 0.0 | -1 |
Construct a new `Description` from a JSON data `dict` | def from_json(cls, jdata):
name = jdata.pop('name', None)
desc = jdata.pop('desc', None)
cisid = jdata.pop('id', None)
apiurl = jdata.pop('url', None)
return Description(name, description=desc, cisid=cisid,
apiurl=apiurl, **jdata) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(self, data: dict):\n if 'title' in data:\n self.title = data['title']\n if 'description' in data:\n self.description = data['description']\n if 'deadline' in data:\n self.deadline = parser.parse(data['deadline'])\n return",
"def from_json... | [
"0.6458457",
"0.6456327",
"0.63140553",
"0.6300957",
"0.629882",
"0.62520736",
"0.6230323",
"0.6217382",
"0.6180097",
"0.61252064",
"0.60867536",
"0.60386324",
"0.5956258",
"0.5934828",
"0.5921481",
"0.58984005",
"0.5872617",
"0.5867657",
"0.5867657",
"0.5867657",
"0.585801",... | 0.798175 | 0 |
Return the filename of the chunk based on the identifier and chunk number | def get_chunk_filename(self, number):
return '%s-%s.tmp' % (self.identifier, number) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunk_base_name(path_name, out_dir, chunk_i = None, tag= \"\"):\n bn = os.path.join(out_dir, \"{}-chunk\".format(path_name))\n if chunk_i is not None:\n bn += \"-{}\".format(chunk_i)\n return \"{}{}\".format(bn, tag)",
"def find_chunk(self, identifier):\n for i, name in enumerate(self.... | [
"0.68299866",
"0.6511543",
"0.63706",
"0.61125296",
"0.60637337",
"0.6054636",
"0.60274017",
"0.60242105",
"0.59998304",
"0.5899711",
"0.5896355",
"0.58904064",
"0.5864566",
"0.5826429",
"0.5778097",
"0.5776535",
"0.57104975",
"0.5692125",
"0.56895345",
"0.5689062",
"0.568375... | 0.81551534 | 0 |
Create a random chromosome length long. | def makeChrom(length):
output = []
for i in range(length):
output.append(randrange(14))
return output | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_random(length, is_binary=False):\n limit = 255 if is_binary else 126\n return \"\".join([chr(choice(range(32, limit))) for _ in range(length)]) + \"\\n\"",
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=lengt... | [
"0.66844845",
"0.6597362",
"0.65453297",
"0.653738",
"0.65291023",
"0.6527683",
"0.65163904",
"0.64539605",
"0.63870525",
"0.6338585",
"0.631057",
"0.6304651",
"0.6297393",
"0.62910885",
"0.6287666",
"0.6265423",
"0.624918",
"0.6240082",
"0.6235991",
"0.62323344",
"0.6228493"... | 0.6764059 | 0 |
Scale features of X according to feature_range. | def transform(self, X):
X = np.asarray(X, dtype=np.float64)
X *= self.scale_
X += self.min_
return X | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale(x, feature_range=(-1, 1)):\n \n # scale from 0-1 to feature_range\n min, max = feature_range\n #x = x * (max - min) + min\n #x = torch.add(torch.mul(x, (max-min)), min)\n x = x.mul(max-min).add_(min)\n return x",
"def scale(x, feature_range=(-1,1)):\r\n x = x * 2 - 1\r\n retu... | [
"0.8160937",
"0.8143202",
"0.7903505",
"0.7344753",
"0.72719556",
"0.6921821",
"0.6885553",
"0.6853056",
"0.6786406",
"0.6773343",
"0.66281414",
"0.6572111",
"0.64861304",
"0.64708704",
"0.63672197",
"0.6338498",
"0.6315042",
"0.63008803",
"0.62983584",
"0.6293539",
"0.624894... | 0.6307188 | 17 |
Compute the minimum and maximum and Scale features of X according to feature_range. | def fit_transform(self, X):
X = np.asarray(X, dtype=np.float64)
self.fit(X)
return self.transform(X) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minmax_scale(X, feature_range=..., *, axis=..., copy=...):\n ...",
"def scale(x, feature_range=(-1, 1)):\n \n # scale from 0-1 to feature_range\n min, max = feature_range\n #x = x * (max - min) + min\n #x = torch.add(torch.mul(x, (max-min)), min)\n x = x.mul(max-min).add_(min)\n retur... | [
"0.82087547",
"0.7314982",
"0.72109634",
"0.71941787",
"0.7182349",
"0.7086159",
"0.69801885",
"0.68005323",
"0.67514676",
"0.67437094",
"0.66456234",
"0.6608722",
"0.6578918",
"0.6504474",
"0.6471988",
"0.6453719",
"0.6373933",
"0.63693935",
"0.63304275",
"0.625541",
"0.6253... | 0.0 | -1 |
Flask application factory. Initializes and returns the Flask application. Blueprints are registered in here. | def create_app(config):
# Initialize app. Flatten config_obj to dictionary (resolve properties).
app = Flask(__name__)
config_dict = dict(
[(k, getattr(config, k)) for k in dir(config) if
not k.startswith('_')])
app.config.update(config_dict)
for bp in all_blueprints:
imp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_app() -> Flask:\r\n app = Flask(__name__.split('.')[0])\r\n init_config(app)\r\n app.register_blueprint(observer)\r\n app.teardown_appcontext(close_db)\r\n app.cli.add_command(init_db)\r\n\r\n return app",
"def create_app():\n app = Flask(__name__, instance_relative_config=False)\... | [
"0.8325744",
"0.8228782",
"0.8225165",
"0.8200131",
"0.8163992",
"0.8108015",
"0.809352",
"0.80708855",
"0.8065196",
"0.80361736",
"0.8017686",
"0.79469216",
"0.79379684",
"0.79226726",
"0.7917556",
"0.79084563",
"0.78816926",
"0.7874658",
"0.7864581",
"0.785593",
"0.78318006... | 0.7821881 | 22 |
Given the join conditions, return the indices of the columns used in the join. | def _get_join_indices(left_table, right_table, join_conditions):
left_indices = []
right_indices = []
for cond in join_conditions:
for join_col_name in (cond.left_operand, cond.right_operand):
left_col = left_table.get_column_for_name(join_col_name)
right_col = right_table.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _resolve_join_columns(left_table, right_table, indices):\n return [ merge_columns(left_table.columns[li], right_table.columns[ri]) for li, ri in indices ]",
"def _join_columns(left_table, right_table, join_indices):\n\n join_columns = _resolve_join_columns(left_table, right_table, join_indices)\n no... | [
"0.67867494",
"0.66560304",
"0.65226907",
"0.62158746",
"0.5779471",
"0.56709194",
"0.55108315",
"0.5421642",
"0.54074836",
"0.5390655",
"0.53544647",
"0.53075194",
"0.53068066",
"0.53063947",
"0.5300796",
"0.52936226",
"0.52858007",
"0.52842987",
"0.52601147",
"0.5230157",
"... | 0.8495805 | 0 |
Given the indices of join columns, return the ordered column names in the joined result. | def _join_columns(left_table, right_table, join_indices):
join_columns = _resolve_join_columns(left_table, right_table, join_indices)
nonjoin_columns = _resolve_nonjoin_columns(left_table, right_table, join_indices)
join_result_columns = join_columns + nonjoin_columns
LOG.debug('Resolved join result c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _resolve_join_columns(left_table, right_table, indices):\n return [ merge_columns(left_table.columns[li], right_table.columns[ri]) for li, ri in indices ]",
"def _get_join_indices(left_table, right_table, join_conditions):\n\n left_indices = []\n right_indices = []\n for cond in join_conditions:\... | [
"0.7789697",
"0.6314696",
"0.59900767",
"0.59072864",
"0.5900094",
"0.5599504",
"0.5521436",
"0.5497052",
"0.54750675",
"0.5463443",
"0.5413986",
"0.54046667",
"0.5339884",
"0.53296024",
"0.53157055",
"0.5290794",
"0.52112764",
"0.51674026",
"0.5166242",
"0.5160192",
"0.51132... | 0.76351 | 1 |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,12,13,14,15, 16,17,18,19,20, 21,22,23,24,25,] | def create_rooms(width=10, height=10):
# create blank rooms
rooms = [Room(id) for id in range(1, (width * height + 1))]
# make some rooms inaccessible
for _ in range(0, height*width//10):
rand_num = randint(0, height*width-1)
while rooms[rand_num].is_accessible == False:
ran... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grAList() -> list:\n return [2, 5, 6, 9, 10, 11, 13, 17, 18, 30]",
"def range() -> List[int]:\n pass",
"def ex_pingpong(data):\n a, b, step = _cleanse_range_args(data)\n rv = list(range(a, b+sign(step), step))\n if rv:\n rv += list(range(rv[-1]-step, a, -step))\n return rv",
"def c... | [
"0.6880827",
"0.59972864",
"0.59655637",
"0.5952579",
"0.5925201",
"0.5905311",
"0.58870214",
"0.5843892",
"0.581917",
"0.5817181",
"0.580626",
"0.5799639",
"0.57943416",
"0.5792499",
"0.5790267",
"0.5771284",
"0.5721593",
"0.57120645",
"0.5700348",
"0.56947947",
"0.56856245"... | 0.0 | -1 |
Process K, M and G suffixes | def clean_value(self):
value = self.cleaned_data["value"]
m = value[-1].lower()
if m in self.MULTIPLIERS:
mp = self.MULTIPLIERS[m]
value = value[:-1]
else:
mp = 1
try:
value = int(value)
except ValueError:
raise ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suffixDict():\n return {'trpk': 'tpke', 'forges': 'frgs', 'bypas': 'byp', 'mnr': 'mnr', 'viaduct': 'via', 'mnt': 'mt',\n 'lndng': 'lndg', 'vill': 'vlg', 'aly': 'aly', 'mill': 'ml', 'pts': 'pts', 'centers': 'ctrs', 'row': 'row', 'cnter': 'ctr',\n 'hrbor': 'hbr', 'tr': 'trl', 'lndg': 'ln... | [
"0.6089298",
"0.5375306",
"0.52516323",
"0.5085442",
"0.507887",
"0.50221944",
"0.50177974",
"0.4999105",
"0.49477822",
"0.49453652",
"0.49277952",
"0.4918703",
"0.4916508",
"0.49015558",
"0.48968717",
"0.48823842",
"0.48698232",
"0.48494914",
"0.4844003",
"0.48413697",
"0.48... | 0.0 | -1 |
Assumes that the input contains a sequence of quoted strings. Replaces spaces inside strings with underscores. | def underscore_strings(entry):
chars = ""
in_string = False
for ch in entry:
if ch == '"':
in_string = not in_string
elif ch == ' ' and in_string:
ch = '_'
chars += ch
if in_string:
raise Exception("unfinished string")
return chars | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unscorize(s):\n return s.replace(\" \", \"_\")",
"def sanitize(s):\n s = s.replace(\"_\", \"\\\\_\")\n return s",
"def test_space_replacements(self):\n testString = sanitize(' a b c d ', '_')\n self.assertEqual(testString, '__a_b_c_d___')",
"def sanitize(mystr):\n ret... | [
"0.7371347",
"0.7328069",
"0.7147251",
"0.71350276",
"0.7061357",
"0.6887427",
"0.6815222",
"0.67419106",
"0.6731806",
"0.66996044",
"0.66793466",
"0.6583518",
"0.6555954",
"0.65446204",
"0.6543787",
"0.64806086",
"0.64158434",
"0.6390861",
"0.6376488",
"0.6372422",
"0.636056... | 0.7109796 | 4 |
1399. Count Largest Group Given an integer n. Each number from 1 to n is grouped according to the sum of its digits. Return how many groups have the largest size. | def count_largest_group(n):
group = collections.defaultdict(int)
largest = 0
for i in range(1, n + 1):
num = i
count = 0
while num >= 10:
count += num % 10
num //= 10
count += num
group[count] += 1
largest = max(largest, group[count])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(n, array):\n\n counters = [0] * n\n\n # Current greatest value calculated so far\n max_count = 0\n\n for i in range(len(array)):\n if array[i] == n + 1:\n # max_count = max(counters)\n counters = [max_count] * n\n else:\n counters[array[i] - 1] += 1\n\n # To avoid calcula... | [
"0.65151894",
"0.6454776",
"0.62637645",
"0.62530714",
"0.62176317",
"0.6185821",
"0.6121438",
"0.61023664",
"0.6091893",
"0.6064139",
"0.604518",
"0.5998349",
"0.59922093",
"0.5974526",
"0.59742206",
"0.59450513",
"0.59426135",
"0.59251875",
"0.5914286",
"0.5888736",
"0.5884... | 0.8677422 | 0 |
Serializes this instance to a JSON string. | def to_json_string(self):
return json.dumps(dict(self), indent=2, sort_keys=True) + "\n" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(self) -> str:\n return json.dumps(self.__dict__)",
"def serialize(self):\n return json.dumps(self.as_dict())",
"def to_json(self) -> str:\n return json.dumps(self.to_dict())",
"def to_json(self) -> str:\n return json.dumps(self.to_dict())",
"def to_json(self) -> st... | [
"0.88999254",
"0.8837045",
"0.8805053",
"0.8805053",
"0.8805053",
"0.8805053",
"0.8805053",
"0.8805053",
"0.8805053",
"0.8805053",
"0.8805053",
"0.87147456",
"0.8637419",
"0.8619328",
"0.8598524",
"0.8572258",
"0.8568808",
"0.8568808",
"0.8446259",
"0.8446259",
"0.8446259",
... | 0.82127887 | 40 |
Deserializes this instance from a JSON string. | def from_json_string(cls, json_string: Text, check_params=False):
lparams = json.loads(json_string)
if check_params:
return cls(**lparams)
else:
return cls.from_dict(lparams, return_instance=True, return_unused=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deserialize_json(self, json_string):\n return self._json_deserializer.from_json(json_string)",
"def from_json(cls, string):\n dct = json.loads(string)\n return cls.from_dict(dct)",
"def from_json(cls, s, **kwargs):\n return loads(s, cls, **kwargs)",
"def fromJSONString(self, J... | [
"0.83151937",
"0.76013553",
"0.74522537",
"0.73328704",
"0.73279977",
"0.7179891",
"0.7152297",
"0.7152297",
"0.7100653",
"0.7085298",
"0.7079573",
"0.70778674",
"0.70699346",
"0.6915981",
"0.6856485",
"0.6830481",
"0.6723637",
"0.6723637",
"0.6723637",
"0.669243",
"0.6681583... | 0.6597302 | 24 |
Deserializes this instance from a YAML string. | def from_yaml_string(cls, yaml_string: Text, check_params=False):
Params._check_yaml_import()
import yaml
lparams = yaml.safe_load(yaml_string)
if check_params:
return cls(**lparams)
else:
return cls.from_dict(lparams, return_instance=True, return_unused=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_yaml_string(cls, string):\n return cls(_yaml_load(string))",
"def from_yaml(cls, b):\n return cls.from_dict(yaml.safe_load(b))",
"def from_yaml(cls, yml: str):\n\n return cls.from_dict(feast_yaml.yaml_loader(yml, load_single=True))",
"def from_yaml(self, content):\r\n if ... | [
"0.74931926",
"0.7410007",
"0.72521317",
"0.708254",
"0.69066846",
"0.68719363",
"0.67875874",
"0.65657204",
"0.6559147",
"0.6551181",
"0.6527973",
"0.6476767",
"0.6461323",
"0.6445635",
"0.63919705",
"0.6334649",
"0.6137961",
"0.60620993",
"0.6046176",
"0.60366726",
"0.60366... | 0.6601148 | 7 |
Writes the instance to a json file. | def to_json_file(self, file_path, **kwargs):
try:
with Params._open_file(file_path, "w") as fp:
json.dump(dict(self), fp, **kwargs)
return file_path
except Exception as err:
print("Failed to write {} instance to: {}".format(self.__class__.__name__, fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self):\r\n\r\n with open(self.filename + \".json\", mode='w') as json_file:\r\n json.dump(self.data, json_file, separators=(',', ':'))",
"def save(self, file):\n\n import json\n\n if hasattr(file, 'write'):\n f = file\n else:\n f = open(file,... | [
"0.8216278",
"0.811791",
"0.80316955",
"0.8012655",
"0.79599553",
"0.78928065",
"0.78829473",
"0.7759528",
"0.7742558",
"0.7660379",
"0.764265",
"0.75718766",
"0.75581443",
"0.7527358",
"0.7527358",
"0.7527358",
"0.7520794",
"0.7518143",
"0.75176114",
"0.74089533",
"0.7399639... | 0.77052563 | 9 |
Constructs an instance from a yaml file. | def from_yaml_file(cls, yaml_file, check_params=False):
Params._check_yaml_import()
import yaml
try:
with Params._open_file(yaml_file, "r") as reader:
text = reader.read()
return cls.from_yaml_string(text, check_params=check_params)
except Excepti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_yaml_file(cls, file_path: str) -> Config:\n return cls(**read_yaml_file(file_path))",
"def create_from_config_file(cls, filename: str):\n return cls(load_yaml_config(filename))",
"def from_yaml(cls, yml: str):\n\n return cls.from_dict(feast_yaml.yaml_loader(yml, load_single=True))... | [
"0.8300059",
"0.81348294",
"0.79235214",
"0.789893",
"0.7853166",
"0.77773696",
"0.77333766",
"0.7722922",
"0.7627954",
"0.7625138",
"0.7615017",
"0.7544892",
"0.7530015",
"0.7526441",
"0.74598294",
"0.73685205",
"0.730705",
"0.7239579",
"0.7190939",
"0.7060429",
"0.7056052",... | 0.7731021 | 7 |
Validate email must be not registered in database. | def unique_registered_email(value):
from .models import Person
if Person.objects.filter(email=value).exists():
raise ValidationError(_('Email already registered.')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_email(self, email):\n user = User.query.filter_by(email=email.data).first()\n if user is not None:\n raise ValidationError('Please use a different email address.')",
"def validate_email(self, email):\n user = User.query.filter_by(email=email.data).first()\n if ... | [
"0.80774695",
"0.8062263",
"0.7913619",
"0.7888286",
"0.78351355",
"0.7805316",
"0.77784556",
"0.777343",
"0.7742732",
"0.76449126",
"0.76345164",
"0.76336837",
"0.75793326",
"0.75582486",
"0.7453978",
"0.74527925",
"0.74527925",
"0.7440616",
"0.7428069",
"0.74122095",
"0.737... | 0.7017035 | 51 |
Creates and saves a superuser with the given email and password. | def create_superuser(self, email, password, full_name=None):
user = self.create_user(
email,
password=password,
)
user.staff = True
user.admin = True
user.save(using=self._db)
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createsuperuser():\n\n email = prompt('User E-Mail')\n email_confirm = prompt('Confirm E-Mail')\n\n if not email == email_confirm:\n sys.exit('\\nCould not create user: E-Mail did not match')\n\n if not EMAIL_REGEX.match(email):\n sys.exit('\\nCould not create user: Invalid E-Mail add... | [
"0.83345544",
"0.82813346",
"0.8258201",
"0.8249415",
"0.8248188",
"0.8223905",
"0.82129776",
"0.8210377",
"0.8180428",
"0.8175924",
"0.8174477",
"0.8159496",
"0.81555283",
"0.8152179",
"0.8147241",
"0.8146682",
"0.81466043",
"0.81466043",
"0.81466043",
"0.81454295",
"0.81319... | 0.7907019 | 75 |
This iterator returns one set of values for each run; one run is given by each iteration of grid_iterator. These values can then be subbed in for the corresponding keys. | def mix_iterator(self):
self.job = OrderedDict()
for list_i in self.grid_iterator():
# Pick the values to be used in this run
for (k, i) in zip(self.table.keys(), list_i):
self.job[k] = self.table[k][i]
# Do the string replace operations on the values ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n\n # For each key in set of keys\n for key in self.keys_set:\n\n # Yield that key and associated value\n yield key, self.__getitem__(key)",
"def itervalues(self):\n def make_iter(self=self):\n keys = self.iterkeys()\n while Tru... | [
"0.68674684",
"0.6633346",
"0.6609571",
"0.64338243",
"0.6405762",
"0.639633",
"0.6321232",
"0.6225039",
"0.62134415",
"0.62093055",
"0.61545277",
"0.6152395",
"0.61314857",
"0.6116",
"0.6111703",
"0.60577893",
"0.6052443",
"0.6007395",
"0.6007344",
"0.6007344",
"0.59918225",... | 0.6784546 | 1 |
A class method for finding strain distribution for a give na_z and phi | def strain_distribution(self,na_z,phi):
return (self.mesh_center - na_z)*phi | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Z(phi = None):\n if phi == None:\n return sz\n else:\n return scipy.linalg.expm(-1j * phi / 2 * sz)",
"def phi(U, n):\n phi_params = n['phi']\n return phi_params['r_max'] / (1 + np.exp(-phi_params['beta'] * (U - phi_params['alpha'])))",
"def g_func(init_par, alpha, delta, plx_obs,... | [
"0.6000811",
"0.57885844",
"0.57675153",
"0.56532854",
"0.5571382",
"0.55565107",
"0.54951555",
"0.54812926",
"0.544237",
"0.5408946",
"0.540471",
"0.53792876",
"0.53530765",
"0.53359944",
"0.5322928",
"0.5303421",
"0.5246338",
"0.52461946",
"0.52455103",
"0.5235561",
"0.5227... | 0.820195 | 0 |
Constructor for networkNIM class | def __init__(
self,
network_list=None,
noise_dist='poisson',
ffnet_out=-1,
input_dim_list=None,
batch_size=None,
tf_seed=0):
if network_list is None:
raise TypeError('Must specify network list.')
# Call __i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, network: Network):\n self.graph = network.graph",
"def __init__(self, *args):\n _snap.TNEANetNodeI_swiginit(self, _snap.new_TNEANetNodeI(*args))",
"def __init__(self, *args):\n _snap.TModeNetNodeI_swiginit(self, _snap.new_TModeNetNodeI(*args))",
"def __init__(self, *ar... | [
"0.733312",
"0.72543633",
"0.7209408",
"0.7180078",
"0.7179606",
"0.71771157",
"0.713644",
"0.7105793",
"0.7060286",
"0.70120966",
"0.6935843",
"0.69245",
"0.6892153",
"0.6868055",
"0.68278474",
"0.68170613",
"0.6792062",
"0.677481",
"0.6742106",
"0.67255074",
"0.6720192",
... | 0.6447443 | 46 |
Calculates the average probability per bin to normalize the Poisson likelihood | def set_poisson_norm(self, data_out):
if type(data_out) is not list:
data_out = [data_out]
self.poisson_unit_norm = []
for i, temp_data in enumerate(data_out):
nc = self.network_list[self.ffnet_out[i]]['layer_sizes'][-1]
assert nc == temp_data.shape[1], 'Out... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_to_prob(inp):\n return (inp + 1)/2",
"def BWMeansEstimate(self):\n for i in range(self.noOfEmmittingStates):\n self.outputProbabilities[i,0] = ((self.L[i,:] *\n self.observationSequence).sum() /\n self.L[i,:].su... | [
"0.6357495",
"0.6312766",
"0.6256403",
"0.6203595",
"0.6152585",
"0.60393476",
"0.6021299",
"0.60042727",
"0.59559345",
"0.58994406",
"0.58754385",
"0.58552617",
"0.58470184",
"0.58209926",
"0.58181083",
"0.5818041",
"0.5808344",
"0.5775554",
"0.57573515",
"0.57566786",
"0.57... | 0.0 | -1 |
Obtain an iterator iterating over the transaction IDs of transactions whose results have been cached. | def __iter__(self) -> Iterator[int]:
return iter(self._cache) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n for transaction in self.transaction_list:\n yield transaction",
"def _get_all_transactions(self) -> Iterator[BaseTransaction]:\n raise NotImplementedError",
"def __iter__(self):\n self._fetch_all()\n return iter(self._result_cache)",
"def __iter__(... | [
"0.68311375",
"0.67771184",
"0.65938914",
"0.6297298",
"0.62870824",
"0.62327623",
"0.60308045",
"0.59337425",
"0.578223",
"0.5757523",
"0.5725274",
"0.57112086",
"0.56814265",
"0.56156856",
"0.5607855",
"0.55999845",
"0.5588609",
"0.5531008",
"0.5509821",
"0.55078274",
"0.55... | 0.65172595 | 3 |
Obtain the time from now to the age out time for the oldest entry in the cache. The result value is positive if the age out time is in the future, and negative if it is in the past. | def time_to_next_ageout(self) -> Optional[float]:
if not len(self):
return None
insertion_time_earliest = min(map(lambda t: t[1], self.values()))
age_out_time = insertion_time_earliest + self._lifetime
delta = age_out_time - time.monotonic()
return delta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def age(self):\n delta = now() - self.creation\n return delta.seconds",
"def expires_in(self):\n # TODO: Use Arrow?\n expiration = datetime.datetime.fromtimestamp(self.expiration)\n now = datetime.datetime.now()\n\n return expiration - now",
"def getOldestTime(self):\n... | [
"0.6560227",
"0.6413566",
"0.6274437",
"0.6210515",
"0.61070484",
"0.60542184",
"0.6004932",
"0.5988007",
"0.5975584",
"0.5845282",
"0.5818701",
"0.5798714",
"0.57685083",
"0.57585764",
"0.57187253",
"0.5706395",
"0.5703079",
"0.5661564",
"0.56597817",
"0.56317735",
"0.562040... | 0.7127541 | 0 |
Obtain the connection state. | def __bool__(self) -> bool:
return not self._disconnected | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_connection_state(self):\n return self.connection_state",
"def state(self):\n return pn_connection_state(self._impl)",
"def get_status(self):\n return self._conn_state",
"def connection_status(self):\n return self._connection_status",
"def getConnectionStatus(self): \n ... | [
"0.90148234",
"0.84909576",
"0.8290324",
"0.79617226",
"0.7404384",
"0.71745414",
"0.7082634",
"0.70647305",
"0.7013675",
"0.7013675",
"0.7013675",
"0.7013675",
"0.7013675",
"0.69848394",
"0.69848394",
"0.69342494",
"0.69190884",
"0.69190884",
"0.69190884",
"0.69190884",
"0.6... | 0.0 | -1 |
Return an iterator yielding transaction IDs with active tasks. | def __iter__(self) -> Iterator[int]:
return iter(self._tasks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n for transaction in self.transaction_list:\n yield transaction",
"def get_active_tasks(self):\n qry = Task.query.filter_by(user=self.id)\n qry = qry.filter_by(completed_on=None)\n return qry.all()",
"def __iter__(self):\n return iter(self._task... | [
"0.6932615",
"0.68787175",
"0.68286616",
"0.680897",
"0.6663568",
"0.65299225",
"0.6528705",
"0.63623893",
"0.62837696",
"0.61766243",
"0.6107625",
"0.60332036",
"0.60089",
"0.5997518",
"0.5952421",
"0.5877513",
"0.5861765",
"0.585085",
"0.58319974",
"0.5825003",
"0.5764042",... | 0.7081312 | 0 |
Check whether the server is running. | def __bool__(self):
return not self._stopped | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ServerIsRunning( self ):\n return utils.ProcessIsRunning( self._gocode_handle )",
"def _checkTorcsServer(self):\n isRunning = False\n if self.torcsServerProcess is not None:\n if self.torcsServerProcess.poll() is None:\n isRunning = True\n return isRunning",... | [
"0.85171527",
"0.8018528",
"0.7777151",
"0.776873",
"0.7755704",
"0.77318627",
"0.7687597",
"0.7678787",
"0.7658998",
"0.7657073",
"0.7634926",
"0.7633568",
"0.7594499",
"0.7577041",
"0.7507422",
"0.75073624",
"0.7403906",
"0.7403025",
"0.74010557",
"0.7391936",
"0.7355238",
... | 0.0 | -1 |
Close the connection. Safe to call if already closed. | def _close(self, send_rst: bool = True):
if self.closed:
return
if send_rst:
self._send(PacketHeader(flags=PacketFlags.RST).serialize())
if (t := self._ping_task) is not None:
t.cancel()
if (t := self._inactivity_check_task) is not None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_connection(self):\n self._conn.close()",
"def close_connection(self):\n self.connection.close()",
"def close_connection(self):\n self.connection.close()",
"def close_connection(self):\n self.conn.close()",
"def close_connection(self) -> None:\n self.connection.c... | [
"0.8500303",
"0.84443665",
"0.84443665",
"0.8434478",
"0.8420725",
"0.841316",
"0.8363447",
"0.83307314",
"0.82863146",
"0.8274644",
"0.8263735",
"0.8263735",
"0.8263735",
"0.8263735",
"0.8263735",
"0.8263735",
"0.8263735",
"0.82468426",
"0.8226376",
"0.8220282",
"0.8202477",... | 0.0 | -1 |
Close the connection. Safe to call if already closed. | def close(self):
self._close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_connection(self):\n self._conn.close()",
"def close_connection(self):\n self.connection.close()",
"def close_connection(self):\n self.connection.close()",
"def close_connection(self):\n self.conn.close()",
"def close_connection(self) -> None:\n self.connection.c... | [
"0.8500303",
"0.84443665",
"0.84443665",
"0.8434478",
"0.8420725",
"0.841316",
"0.8363447",
"0.83307314",
"0.82863146",
"0.8274644",
"0.8263735",
"0.8263735",
"0.8263735",
"0.8263735",
"0.8263735",
"0.8263735",
"0.8263735",
"0.82468426",
"0.8226376",
"0.8220282",
"0.8202477",... | 0.0 | -1 |
Returns an access policy based on the name. | def get_access_policy(access_policy_id: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetAccessPolicyResult:
__args__ = dict()
__args__['accessPolicyId'] = access_policy_id
opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(self, policy_name):\n path = self.vault.normalize(\"/sys/policies/acl/\" + policy_name)\n address = self.vault.vault_adress + \"/v1\" + path\n logging.debug(\"Reading the policy: %s\", address)\n response = self.vault.requests_request(\n \"GET\", address, headers=sel... | [
"0.7024677",
"0.6522782",
"0.6474692",
"0.6341822",
"0.62265134",
"0.5986205",
"0.595365",
"0.59472954",
"0.5912938",
"0.58822393",
"0.5838049",
"0.5806485",
"0.5806485",
"0.57576644",
"0.5749303",
"0.5727727",
"0.5727727",
"0.5727727",
"0.5727727",
"0.5727727",
"0.5727727",
... | 0.5786226 | 13 |
Returns an access policy based on the name. | def get_access_policy_output(access_policy_id: Optional[pulumi.Input[str]] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetAccessPolicyResult]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(self, policy_name):\n path = self.vault.normalize(\"/sys/policies/acl/\" + policy_name)\n address = self.vault.vault_adress + \"/v1\" + path\n logging.debug(\"Reading the policy: %s\", address)\n response = self.vault.requests_request(\n \"GET\", address, headers=sel... | [
"0.7027466",
"0.6523637",
"0.6476891",
"0.63430536",
"0.6227675",
"0.5987686",
"0.59551024",
"0.5949008",
"0.5915986",
"0.58838934",
"0.5837903",
"0.5808621",
"0.5808621",
"0.57867837",
"0.575989",
"0.57496303",
"0.5730067",
"0.5730067",
"0.5730067",
"0.5730067",
"0.5730067",... | 0.54247963 | 36 |
Transforms a dictionary of confusion matrices to a dictionary (with the same key as dict_confmx) of dictionaries of metrics. | def dict_confmx_to_dict_metrics(dict_confmx):
dict_metrics = dict()
for key, confmx in dict_confmx.items():
dict_metrics[key] = confmx_to_metrics(confmx)
return dict_metrics | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confmx_to_metrics(confmx):\n confmx = tf.cast(confmx, tf.int64) # prevent from overflow\n nb_cls = confmx.shape[0]\n dict_metrics = {\n \"SNS\":dict(),\n \"SPC\":dict(),\n \"PRC\":dict(),\n \"ACC\":dict(),\n \"BAC\":dict(),\n \"F1\":dict(),\n \"GM\":dic... | [
"0.6995583",
"0.62190753",
"0.6135253",
"0.60354257",
"0.60106593",
"0.5794973",
"0.56588763",
"0.5634888",
"0.5597155",
"0.5573204",
"0.55151534",
"0.55028826",
"0.54459214",
"0.5398382",
"0.5387574",
"0.5384269",
"0.53755444",
"0.5372671",
"0.5365875",
"0.5351758",
"0.53424... | 0.8063944 | 0 |
draw 3d skeleton on matplotlib axis | def draw_3D_joints(ax, joints, c=None):
def _draw3djoints(ax, joints, links, c=None):
""" draw segments """
if c:
colors = [c, c, c, c, c]
else:
colors = ['r', 'm', 'b', 'c', 'g']
for finger_idx, finger_links in enumerate(links):
for idx in range(l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def viewer(\n self, units='nm', \n draw_edges=True, draw_vertices=True,\n color_by='radius'\n ):\n try:\n import matplotlib.pyplot as plt\n from mpl_toolkits.mplot3d import Axes3D \n from matplotlib import cm\n except ImportError:\n print(\"Skeleton.viewer requires matplotlib. T... | [
"0.6615972",
"0.6231747",
"0.61475915",
"0.6088361",
"0.6035807",
"0.60086066",
"0.58363414",
"0.58162874",
"0.57992923",
"0.5712818",
"0.56541127",
"0.5652035",
"0.5607056",
"0.56037074",
"0.55620235",
"0.5550177",
"0.5543903",
"0.550769",
"0.5458259",
"0.54128194",
"0.54125... | 0.0 | -1 |
Create a django superuser | def create_superuser(username=None, email=None):
require("virtualenv_path", "project_path", "sudo_user")
cmd = "createsuperuser"
if username:
cmd = "%s --username=%s" % (cmd, username)
if email:
cmd = "%s --email=%s" % (cmd, email)
utils.django_manage_run(
env.virtualenv_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_superuser(self, username, email, password):\n print(\"creating super user....\")\n user = self.create_user(\n\n username=username,\n password=password,\n email = email,\n commit=False,\n )\n user.is_staff = True\n user.is_sup... | [
"0.7995487",
"0.78964347",
"0.7873499",
"0.78520703",
"0.78242",
"0.78239703",
"0.782182",
"0.7816901",
"0.7804718",
"0.779874",
"0.77878237",
"0.77729684",
"0.77599025",
"0.7746733",
"0.7726053",
"0.7701209",
"0.7688846",
"0.76848376",
"0.7683693",
"0.76788914",
"0.76688164"... | 0.7538719 | 40 |
Capitalise the first letter of each sentence in a string. Currently, only matched the period punctuation. | def capsentence(value):
value = value.lower()
return ". ".join([sentence.capitalize() for sentence in value.split(". ")]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capitalize_sentences(text: str) -> str:\n punctuation = ['.', '?','!']\n text = list(text)\n \n for i in range(len(text)-2):\n if i == 0:\n text[i] = text[i].upper()\n if text[i] in punctuation and text[i+1] == ' ':\n text[i+2] = text[i+2].upper()\n \n retu... | [
"0.7673889",
"0.73652786",
"0.7159303",
"0.71208197",
"0.7066823",
"0.6934083",
"0.69084585",
"0.68986845",
"0.68826896",
"0.6880302",
"0.68626046",
"0.68423533",
"0.6798169",
"0.6791353",
"0.677822",
"0.6760499",
"0.6733353",
"0.6663429",
"0.66557777",
"0.66488916",
"0.65980... | 0.75521356 | 1 |
Capitalizes only the first letter in a string | def capfirst(value, force_lower=False):
if force_lower:
return '%s%s' % (value[:1].upper(), value[1:].lower())
else:
return value.capitalize() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capitalize1(s):\n return s[:1].upper() + s[1:]",
"def capitalizeFirst(word):\n return word[0].upper() + word[1:]",
"def cap_first(word):\n return word[0].upper() + word[1:]",
"def capitalize_first_letter(text):\n chars = list(text.strip())\n chars[0] = chars[0].upper()\n return \"\".joi... | [
"0.8473961",
"0.84636444",
"0.8419744",
"0.8334661",
"0.8141314",
"0.793776",
"0.7833382",
"0.7748912",
"0.77244955",
"0.7695578",
"0.76884615",
"0.76326936",
"0.76245654",
"0.7605462",
"0.75210035",
"0.7467867",
"0.744002",
"0.73996514",
"0.7388638",
"0.7380803",
"0.7375221"... | 0.7520518 | 15 |
Return the binary root directory >>> rb = RustBuild() >>> rb.build_dir = "build" >>> rb.bin_root() == os.path.join("build", "stage0") True | def bin_root(self):
return os.path.join(self.build_dir, self.build, "stage0") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bin_dir():\n return os.path.abspath(os.path.join(get_root_dir(), 'bin/'))",
"def get_buildroot():\r\n try:\r\n return BuildRoot().path\r\n except BuildRoot.NotFoundError as e:\r\n print(e.message, file=sys.stderr)\r\n sys.exit(1)",
"def rootdir():\n return util.path(__file__).parent.pa... | [
"0.76200527",
"0.7064678",
"0.6812878",
"0.6662838",
"0.6638394",
"0.6630937",
"0.6612604",
"0.658851",
"0.6570939",
"0.65611887",
"0.65354985",
"0.65354985",
"0.6533948",
"0.6532341",
"0.6519628",
"0.6472493",
"0.6440775",
"0.633309",
"0.63251346",
"0.63222516",
"0.6283077",... | 0.83690536 | 0 |
Returns the value of the given key in config.toml, otherwise returns None >>> rb = RustBuild() >>> rb.config_toml = 'key1 = "value1"\\nkey2 = "value2"' >>> rb.get_toml("key2") 'value2' | def get_toml(self, key, section=None):
cur_section = None
for line in self.config_toml.splitlines():
section_match = re.match(r'^\s*\[(.*)\]\s*$', line)
if section_match is not None:
cur_section = section_match.group(1)
match = re.match(r'^{}\s*=(.*)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(key: str) -> Any:\n _check_key(key)\n config = _read_config()\n return config.get(key, DEFAULT_CONFIG.get(key))",
"def get_value(key: str) -> str:\n Config.__get()\n assert Config.__config is not None\n return Config.__config.get(\"wsgi\", key)",
"def get_config(key):\n ... | [
"0.6698035",
"0.63968873",
"0.6393324",
"0.63587815",
"0.6320904",
"0.62330943",
"0.6206609",
"0.6192353",
"0.6150525",
"0.6131707",
"0.6120839",
"0.6047462",
"0.6031733",
"0.6027957",
"0.59958225",
"0.59900004",
"0.59763926",
"0.59745294",
"0.59592485",
"0.59276414",
"0.5911... | 0.73380095 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.