query stringlengths 9 9.05k | document stringlengths 10 222k | negatives listlengths 19 20 | metadata dict |
|---|---|---|---|
L{AMPConfiguration} should be poweredup as L{IOneTimePadGenerator}. | def test_poweredUp(self):
self.assertIdentical(
IOneTimePadGenerator(self.store),
self.store.findUnique(AMPConfiguration)) | [
"def test_generateOneTimePad(self):\n object.__setattr__(self.conf, 'callLater', lambda x, y: None)\n pad = self.conf.generateOneTimePad(self.store)\n self.assertNotEqual(\n pad, self.conf.generateOneTimePad(self.store))",
"def alarm_in_setup_change():\n setup_write(\"!M1 meas i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
takes no arguments tells you whether the shack is open | def open(self, irc, msg, args):
status = urlopen("http://portal.shack:8088/status").read()
status = json.loads(status)
if status['status'] == 'open':
irc.reply("shack is open.", prefixNick=False)
elif status['status'] == 'closed':
irc.reply("shack is clos... | [
"def _isopen(self):\n return self.dp.state()==PyTango.DevState.OPEN",
"def is_open(self):\n return self.status == \"O\"",
"def is_closed(self) -> bool:",
"def _isopen(self):\n return self._fsrc is not None",
"def is_open(self):\n\t\treturn self._session is not None",
"def is_open(self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If debug enabled, print a few rows from pandas DataFrame. | def debug_print_dataframe(data, num_rows=2, debug=False):
if debug:
with pandas.option_context('display.max_rows', None, 'display.max_columns',
None):
print(data[:num_rows]) | [
"def debug(df, path):\n print(path + \":\", end='\\n')\n print(df)\n print(\"col:\\n\", df.columns)\n print(\"\\n\")",
"def df_print(df):\n with pd.option_context('display.max_rows', None, 'display.max_columns', 3):\n print(df)",
"def printDataFrameAnalysis(df):\n print(df.head())\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A helper print function for seeing the table row length. | def print_data_table_length(document_label, data_frame, debug=False):
print('{}\n'.format(document_label), len(data_frame))
debug_print_dataframe(data_frame, debug=debug) | [
"def getPrintRowWidth(self):\n return len(self.getPrintMidRow(self.print_grid[0]))",
"def len_row(self):\n return ALIENS_IN_ROW * ALIEN_WIDTH + (ALIENS_IN_ROW - 1)*ALIEN_H_SEP",
"def getNumRows(self) -> int:\n ...",
"def len(self, table):\n return self.get_table_nb_lines(table)",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
find_popular_song_by_duration_in_min >>> popular_list=InternetStoreManager([Popular("numb",3,"linkin park",2003, Genre.rock),Popular("Astronimia",6,"tony igy",2010, Genre.electro),Popular("fire man",4,"miyagi&andy panda",2018, Genre.rap)]) >>> popular_list.find_popular_song_by_duration_in_min(3) | def find_popular_song_by_duration_in_min(self, duration_in_min):
lists = list(filter(lambda song: song.duration_in_min == duration_in_min, self.popular_list))
return print("".join(str(output_list) for output_list in lists)) | [
"def search(query, weight):\n Freesound.set_api_key('31ac7f49d68644c4bfafaf8213eddbc5')\n results = Sound.search(q=query, filter=\"duration:[1.0 TO 5.0]\",\n sort=\"rating_desc\", max_results=\"3\")\n DECREASE_FACTOR = .9 # decreate the weight farther away from top result\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a custom watermark | def custom_watermark(self, canvas, doc):
canvas.saveState()
canvas.setFont('Helvetica', 45)
canvas.setFillGray(0.80)
canvas.rotate(self.watermark_rotation)
canvas.drawCentredString(
self.watermark_position_x,
self.watermark_position_y,
self.wat... | [
"def add_watermark(self, image, watermark, position='scale', opacity=1, format=None):",
"def add_watermark_on_image(self):\n self.image = Image.alpha_composite(self.image,\n self.watermark_layer)",
"def add_watermark(self):\n w, h, n = self.__watermark.sha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
draw page number with custom format and position | def draw_page_number(self, page_count, position_x=285, position_y=5):
if page_count > 0:
self.setFillGray(0.2)
self.setFont("Helvetica", 8)
self.drawRightString(
position_x * mm, position_y * mm, "Page %d/%d" %
(self._pageNumber, page_count)) | [
"def format_page(pdf, cfg, page_mapping):\n\n # pick a standard indent that almost every chunk will fit (except for intros and probably verse 10 and greater)\n STANDARD_LABEL_INDENT_LENGTH = myStringWidth('8) ', cfg.FONT_FACE, cfg.SONGLINE_SIZE)\n\n # REMEMBER: we are in the 1st Quadrant (like Math) ... lower ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing service template (can be ``None``). | def service_template(cls):
return relationship.many_to_one(cls, 'service_template') | [
"def service_template(self) -> Optional['outputs.IndexerClusterSpecServiceTemplate']:\n return pulumi.get(self, \"service_template\")",
"def test_show_service_template(self):\n new_template = self._create_service_template()\n with self.rbac_utils.override_role(self):\n self.service... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing service template (can be ``None``). | def service_template(cls):
return relationship.many_to_one(cls, 'service_template') | [
"def service_template(self) -> Optional['outputs.IndexerClusterSpecServiceTemplate']:\n return pulumi.get(self, \"service_template\")",
"def test_show_service_template(self):\n new_template = self._create_service_template()\n with self.rbac_utils.override_role(self):\n self.service... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing interface template (can be ``None``). | def interface_template(cls):
return relationship.many_to_one(cls, 'interface_template') | [
"def defaultTemplate(self):\n \n pass",
"def make_template():\n raise NotImplementedError",
"def test_get_implant_template(self):\n pass",
"def is_template(self):\n raise NotImplementedError(\n 'operation is_template(...) not yet implemented')",
"def cmd_template(se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing operation template (can be ``None``). | def operation_template(cls):
return relationship.many_to_one(cls, 'operation_template') | [
"def cmd_template(self):",
"def containerTemplate(*args, **kwargs):\n\n pass",
"def _cloud_formation_template(self):\n return None",
"def __operations(self, conf):\n result = \"\"\"## Operations [back to top](#toc)\nThe operations that this API implements are:\n\"\"\"\n ops = \"\\n\"\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing operation template (can be ``None``). | def operation_template(cls):
return relationship.many_to_one(cls, 'operation_template') | [
"def cmd_template(self):",
"def containerTemplate(*args, **kwargs):\n\n pass",
"def _cloud_formation_template(self):\n return None",
"def __operations(self, conf):\n result = \"\"\"## Operations [back to top](#toc)\nThe operations that this API implements are:\n\"\"\"\n ops = \"\\n\"\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing node template (can be ``None``). | def node_template(cls):
return relationship.many_to_one(cls, 'node_template') | [
"def node():\n return render_template('nodes.html')",
"def template_inst_node(templ, names, starname, scope_key, copy):\n node = TemplateInstanceNode()\n node.template = templ.node.copy() if copy else templ.node\n node.names = names\n node.starname = starname\n node.scope_key = scope_key\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing group template (can be ``None``). | def group_template(cls):
return relationship.many_to_one(cls, 'group_template') | [
"def template_group_name(self):\n return self._template_group_name",
"def process_template_groups(element):\n for node in element.iter():\n if node.get('groups'):\n request.env['ir.ui.view'].set_studio_groups(node)",
"def get_template_groups(cls):\n ret... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing policy template (can be ``None``). | def policy_template(cls):
return relationship.many_to_one(cls, 'policy_template') | [
"def _cloud_formation_template(self):\n return None",
"def translate_policy(policy: dict):\n if 'PolicyName' in policy:\n # This is a normal policy that should not be expanded\n return policy\n template_name = next(iter(policy))\n template_parameters = policy[template_name]\n try:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing relationship template (can be ``None``). | def relationship_template(cls):
return relationship.many_to_one(cls, 'relationship_template') | [
"def test_get_relationship_templates(self):\n pass",
"def node_template(cls):\n return relationship.many_to_one(cls, 'node_template')",
"def join_path(self, template, parent):\r\n return template",
"def operation_template(cls):\n return relationship.many_to_one(cls, 'operation_temp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing capability template (can be ``None``). | def capability_template(cls):
return relationship.many_to_one(cls, 'capability_template') | [
"def capability(self):\n return self.get(\"capabilityClass\")",
"def _cloud_formation_template(self):\n return None",
"def capability(self):\r\n return PythonCapability(self.mixins().values())",
"def get_capability(feature: Feature, capability: str) -> Any:\n return feature[\"properties\"]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing artifact template (can be ``None``). | def artifact_template(cls):
return relationship.many_to_one(cls, 'artifact_template') | [
"def template_artifact_source_relative_path(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"template_artifact_source_relative_path\")",
"def _get_project_template(self): # suppress(no-self-use)\n parent = os.path.realpath(os.path.join(os.path.dirname(__file__),\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing policy (can be ``None``). | def policy(cls):
return relationship.many_to_one(cls, 'policy') | [
"def get_policy(self):\n\n return",
"def policy(self) -> HwPolicy:\n return self._policy",
"def policy(self) -> typing.Optional[\"BucketPolicy\"]:\n return jsii.get(self, \"policy\")",
"def get_policy(self, typ: Type[policy.Policy]):\n ret = None\n cur = self\n while ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing capability (can be ``None``). | def capability(cls):
return relationship.many_to_one(cls, 'capability') | [
"def capability(self):\n return self.get(\"capabilityClass\")",
"def has_capability(self, capability):\n return False",
"def get_capability(feature: Feature, capability: str) -> Any:\n return feature[\"properties\"].get(capability)",
"def capability(self):\r\n return PythonCapability(self.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing artifact (can be ``None``). | def artifact(cls):
return relationship.many_to_one(cls, 'artifact') | [
"def artifact_root(self) -> Optional[str]:\n return pulumi.get(self, \"artifact_root\")",
"def test_get_artifact(self):\n pass",
"def artifacts():\n pass",
"def pipeline_artifact(self):\n pass",
"def get_artifact(self, artifact_name: str) -> Optional[Any]:\n\n return super().g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Containing node template (can be ``None``). | def node_template(cls):
return relationship.many_to_one(cls, 'node_template') | [
"def node():\n return render_template('nodes.html')",
"def template_inst_node(templ, names, starname, scope_key, copy):\n node = TemplateInstanceNode()\n node.template = templ.node.copy() if copy else templ.node\n node.names = names\n node.starname = starname\n node.scope_key = scope_key\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method gets element XSD type It is used to determine if element is Simple or Complex | def _get_element_type(self, element):
if (self._client == None):
raise ValueError('Specification is not imported yet')
el_type = None
for value in self._client.wsdl.schema.types.values():
if (value.name == element):
if ('Simple' in value.id):
... | [
"def get_type(self):\n return self.element_type",
"def element_type(self) -> global___Type:",
"def get_element_type(cls):\r\n return cls._type_name(cls.element_type)",
"def element_type(self, xml):\n assert(xml.size() == 1)\n return xml[0].tag",
"def get_xsd_type(self, item):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method gets element XSD namespace It is used to construct XML element with correct namespaces | def _get_element_ns(self, element):
if (self._client == None):
raise ValueError('Specification is not imported yet')
ns = None
for key in self._client.wsdl.schema.types.keys():
if (key[0] == element):
ns = key[1]
break
return ns | [
"def getElementNamespace(self):\n return _libsbml.SBasePlugin_getElementNamespace(self)",
"def XmlNamespace(self) -> str:",
"def getElementNamespace(self):\n return _libsbml.ASTBasePlugin_getElementNamespace(self)",
"def get_root_tag(xmlschema, namespaces, **kwargs):\n return str(_xpath_eval(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method creates dummy WSDL file | def _create_dummy_wsdl(self, xsd):
if (path.exists(xsd)):
try:
with open(xsd, 'r') as f:
tns = search(r'targetNamespace="(.*)"', f.read()).group(1)
if ('"' in tns):
tns = tns[: tns.index('"')]
filename ... | [
"def test_cmd_gen_soap():\n test_folder = os.path.split(__file__)[0]\n xyzpath = os.path.abspath(os.path.join(test_folder, 'small_molecules-1000.xyz'))\n runner = CliRunner()\n with runner.isolated_filesystem():\n result = runner.invoke(asap, ['gen_desc', '--fxyz', xyzpath, 'soap'])\n assert r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Saves model to with provided checkpoint prefix. | def _save_checkpoint(checkpoint, model_dir, checkpoint_prefix):
checkpoint_path = os.path.join(model_dir, checkpoint_prefix)
saved_path = checkpoint.save(checkpoint_path)
logging.info('Saving model as TF checkpoint: %s', saved_path)
return | [
"def save(self, model_dir, model_prefix):\n self.saver.save(self.sess, os.path.join(model_dir, model_prefix))\n self.logger.info('Model saved in {}, with prefix {}.'.format(model_dir, model_prefix))",
"def save(self, file_prefix, options=None):\n options = options or checkpoint_options.Checkpoint... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the value of a floatvalue keras metric. | def _float_metric_value(metric):
return metric.result().numpy().astype(float) | [
"def get_float(self):\n return self.value",
"def value(self) -> float:\n return pulumi.get(self, \"value\")",
"def getMetricValue(self):\n return self.getOrDefault(self.metricParams)",
"def valf(node: md.Document) -> float:\n try:\n return float(val(node))\n except ValueError... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
turn magics dict into jsonable dict of the same structure replaces object instances with their class names as strings | def _jsonable(self):
magic_dict = {}
mman = self.magics_manager
magics = mman.lsmagic()
for key, subdict in magics.items():
d = {}
magic_dict[key] = d
for name, obj in subdict.items():
try:
classname = obj.__self__._... | [
"def custom_encode(obj):\n if isinstance(obj, DictionaryMethods):\n key = '__Dictionary__'\n return {key: [list(obj), obj.alpha, obj.pat, obj.pat_args,\n obj.auto_fields]}\n elif isinstance(obj, Entry):\n return obj.data\n else:\n raise TypeError(\"obj {!r} ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create an alias for an existing line or cell magic. Examples | def alias_magic(self, line=''):
args = magic_arguments.parse_argstring(self.alias_magic, line)
shell = self.shell
mman = self.shell.magics_manager
escs = ''.join(magic_escapes.values())
target = args.target.lstrip(escs)
name = args.name.lstrip(escs)
params = ar... | [
"def addAlias(self, alias, command, classes = [], title = None, simple = None):\r\n if simple == None:\r\n simple = self.config.get('entry', 'simple')\r\n if title == None:\r\n title = alias\r\n c = re.compile(alias)\r\n self.aliases[c] = source.Source(c, self.formatCode(command), classes, simple, title)",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pretty print the object and display it through a pager. %page [options] OBJECT If no object is given, use _ (last output). | def page(self, parameter_s=''):
# After a function contributed by Olivier Aubert, slightly modified.
# Process options/args
opts, args = self.parse_options(parameter_s, 'r')
raw = 'r' in opts
oname = args and args or '_'
info = self.shell._ofind(oname)
if info.... | [
"def pprint(object, stream=None):\r\n printer = PrettyPrinter(stream=stream)\r\n printer.pprint(object)",
"def __pprint(object, stream=None, indent=1, width=80, depth=None):\n printer = PrettyPrinterExt(\n stream=stream, indent=indent, width=width, depth=depth)\n printer.pprint(object)",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Switch color scheme for prompts, info system and exception handlers. | def colors(self, parameter_s=''):
def color_switch_err(name):
warn('Error changing %s color schemes.\n%s' %
(name, sys.exc_info()[1]), stacklevel=2)
new_scheme = parameter_s.strip()
if not new_scheme:
raise UsageError(
"%colors: you must... | [
"def magic_colors(self,parameter_s = ''):\n \n new_scheme = parameter_s.strip()\n if not new_scheme:\n print 'You must specify a color scheme.'\n return\n try:\n self.shell.outputcache.set_colors(new_scheme)\n except:\n warn('Error chang... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Switch modes for the exception handlers. | def xmode(self, parameter_s=''):
def xmode_switch_err(name):
warn('Error changing %s exception modes.\n%s' %
(name,sys.exc_info()[1]))
shell = self.shell
if parameter_s.strip() == "--show":
shell.InteractiveTB.skip_hidden = False
return
... | [
"def set_exception_handler(self):\n sys.excepthook = self.exception_handler",
"def magic_xmode(self,parameter_s = ''):\n\n new_mode = parameter_s.strip().capitalize()\n try:\n self.InteractiveTB.set_mode(mode = new_mode)\n print 'Exception reporting mode:',self.Interacti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Show a quick reference sheet | def quickref(self, arg):
from IPython.core.usage import quick_reference
qr = quick_reference + self._magic_docs(brief=True)
page.page(qr) | [
"def print_sheet(self, f):\n self.sample_sheet.print_v1(f)",
"def print_sheet(self, f):\n self.sample_sheet.print_v2(f)",
"def habHelp(self):\n rf = os.path.join('docs','helpButtons','prefsHabitat.html')\n self.showHelpFile( rf )",
"def show_help():\n\n url = (\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Toggle doctest mode on and off. This mode is intended to make IPython behave as much as possible like a plain Python shell, from the perspective of how its prompts, exceptions and output look. This makes it easy to copy and paste parts of a | def doctest_mode(self, parameter_s=''):
# Shorthands
shell = self.shell
meta = shell.meta
disp_formatter = self.shell.display_formatter
ptformatter = disp_formatter.formatters['text/plain']
# dstore is a data store kept in the instance metadata bag to track any
#... | [
"def do_doctest(self, subcmd, opts):\n import doctest\n doctest.testmod()",
"def _test():\n import doctest\n doctest.testmod()",
"def test_doctests_run(self):\n results = doctest.testmod(lab, optionflags=TESTDOC_FLAGS, report=False)\n self.assertEqual(results[0], 0)",
"def sk... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set floating point precision for pretty printing. Can set either integer precision or a format string. If numpy has been imported and precision is an int, numpy display precision will also be set, via ``numpy.set_printoptions``. If no argument is given, defaults will be restored. Examples | def precision(self, s=''):
ptformatter = self.shell.display_formatter.formatters['text/plain']
ptformatter.float_precision = s
return ptformatter.float_format | [
"def pretty(precision=None):\n\n global _pretty\n _pretty = True\n\n if precision is not None:\n print_precision(precision)",
"def set_floating_point_precision(\n self,\n precision: FloatingPointPrecisionStr | QtCore.QDataStream.FloatingPointPrecision,\n ):\n self.setFloati... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export and convert IPython notebooks. This function can export the current IPython history to a notebook file. For example, to export the history to "foo.ipynb" do "%notebook foo.ipynb". | def notebook(self, s):
args = magic_arguments.parse_argstring(self.notebook, s)
outfname = os.path.expanduser(args.filename)
from nbformat import write, v4
cells = []
hist = list(self.shell.history_manager.get_range())
if(len(hist)<=1):
raise ValueError('His... | [
"def export_notebook():\n #system(\"jupyter nbconvert --to HTML \\\"Look At Enron data set.ipynb\\\"\")\n system(\"jupyter nbconvert --to HTML --output=Look+At+Enron+data+set.html \\\"Look At Enron data set.ipynb\\\"\")\n return",
"def save_history(self):\n try:\n from nbformat import w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allow to change the status of the autoawait option. This allow you to set a specific asynchronous code runner. If no value is passed, print the currently used asynchronous integration and whether it is activated. | def autoawait(self, parameter_s):
param = parameter_s.strip()
d = {True: "on", False: "off"}
if not param:
print("IPython autoawait is `{}`, and set to use `{}`".format(
d[self.shell.autoawait],
self.shell.loop_runner
))
retur... | [
"def set_eprint_async(do_async):\n CONFIG['do_async'] = do_async",
"async def async_service_option_active(call):\n await _async_service_key_value(call, \"set_options_active_program\")",
"def EnableSetAsyncConfig(self):\n\t\treturn self._get_attribute('enableSetAsyncConfig')",
"def enable_async(self)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Decode data_dict using torch_load if needed. | def _decode_data_dict(self, data_dict: dict) -> dict:
if ENCODED_DATA_KEY not in data_dict:
return data_dict
encoded_data = data_dict[ENCODED_DATA_KEY]
_buffer = io.BytesIO(encoded_data)
data_dict = torch.load(
_buffer,
map_location="cpu"
... | [
"def _load(self, load_dict):\n self._data_ = load_dict",
"def _load(self, load_dict):\n try:\n self.v_protocol = load_dict.pop(PickleParameter.PROTOCOL)\n except KeyError:\n # For backwards compatibility\n dump = next(load_dict.values())\n self.v_pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the dt_land_slide_time of this LandslideViewModel. | def dt_land_slide_time(self, dt_land_slide_time):
self._dt_land_slide_time = dt_land_slide_time | [
"def dt_land_slide_time_end(self, dt_land_slide_time_end):\n\n self._dt_land_slide_time_end = dt_land_slide_time_end",
"def dt_off_land_slide_time(self, dt_off_land_slide_time):\n\n self._dt_off_land_slide_time = dt_off_land_slide_time",
"def dt_off_land_slide_time_end(self, dt_off_land_slide_time... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the utm_north_stop of this LandslideViewModel. | def utm_north_stop(self, utm_north_stop):
self._utm_north_stop = utm_north_stop | [
"def utm_north(self, utm_north):\n\n self._utm_north = utm_north",
"def utm_north_start(self, utm_north_start):\n\n self._utm_north_start = utm_north_start",
"def utm_east_stop(self, utm_east_stop):\n\n self._utm_east_stop = utm_east_stop",
"def utm_east_start(self, utm_east_start):\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the utm_east_stop of this LandslideViewModel. | def utm_east_stop(self, utm_east_stop):
self._utm_east_stop = utm_east_stop | [
"def utm_east(self, utm_east):\n\n self._utm_east = utm_east",
"def utm_east_start(self, utm_east_start):\n\n self._utm_east_start = utm_east_start",
"def utm_north_stop(self, utm_north_stop):\n\n self._utm_north_stop = utm_north_stop",
"def set_east(self, east=False):\n try:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the utm_zone_stop of this LandslideViewModel. | def utm_zone_stop(self, utm_zone_stop):
self._utm_zone_stop = utm_zone_stop | [
"def utm_east_stop(self, utm_east_stop):\n\n self._utm_east_stop = utm_east_stop",
"def utm_north_stop(self, utm_north_stop):\n\n self._utm_north_stop = utm_north_stop",
"def utm_zone(self, utm_zone):\n\n self._utm_zone = utm_zone",
"def utm_zone_start(self, utm_zone_start):\n\n se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the land_slide_tid of this LandslideViewModel. | def land_slide_tid(self, land_slide_tid):
self._land_slide_tid = land_slide_tid | [
"def land_slide_trigger_tid(self, land_slide_trigger_tid):\n\n self._land_slide_trigger_tid = land_slide_trigger_tid",
"def land_slide_size_tid(self, land_slide_size_tid):\n\n self._land_slide_size_tid = land_slide_size_tid",
"def land_slide_name(self, land_slide_name):\n\n self._land_slide... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the land_slide_name of this LandslideViewModel. | def land_slide_name(self, land_slide_name):
self._land_slide_name = land_slide_name | [
"def land_slide_trigger_name(self, land_slide_trigger_name):\n\n self._land_slide_trigger_name = land_slide_trigger_name",
"def land_slide_size_name(self, land_slide_size_name):\n\n self._land_slide_size_name = land_slide_size_name",
"def set_name(self, _name):\n self.__name = _name",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the land_slide_trigger_tid of this LandslideViewModel. | def land_slide_trigger_tid(self, land_slide_trigger_tid):
self._land_slide_trigger_tid = land_slide_trigger_tid | [
"def land_slide_tid(self, land_slide_tid):\n\n self._land_slide_tid = land_slide_tid",
"def land_slide_trigger_name(self, land_slide_trigger_name):\n\n self._land_slide_trigger_name = land_slide_trigger_name",
"def avalanche_trigger_tid(self, avalanche_trigger_tid):\n\n self._avalanche_trig... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the land_slide_trigger_name of this LandslideViewModel. | def land_slide_trigger_name(self, land_slide_trigger_name):
self._land_slide_trigger_name = land_slide_trigger_name | [
"def land_slide_name(self, land_slide_name):\n\n self._land_slide_name = land_slide_name",
"def trigger_name(self, trigger_name: \"str\"):\n self._attrs[\"triggerName\"] = trigger_name",
"def SetTriggerName(self, trname):\n self.__triggername = trname",
"def SetTriggerName(self, triggerNa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the land_slide_size_tid of this LandslideViewModel. | def land_slide_size_tid(self, land_slide_size_tid):
self._land_slide_size_tid = land_slide_size_tid | [
"def land_slide_size_name(self, land_slide_size_name):\n\n self._land_slide_size_name = land_slide_size_name",
"def land_slide_tid(self, land_slide_tid):\n\n self._land_slide_tid = land_slide_tid",
"def setStepsize(self, step_size=None):\n if step_size:\n self.step_size = step_si... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the land_slide_size_name of this LandslideViewModel. | def land_slide_size_name(self, land_slide_size_name):
self._land_slide_size_name = land_slide_size_name | [
"def land_slide_name(self, land_slide_name):\n\n self._land_slide_name = land_slide_name",
"def land_slide_size_tid(self, land_slide_size_tid):\n\n self._land_slide_size_tid = land_slide_size_tid",
"def land_slide_trigger_name(self, land_slide_trigger_name):\n\n self._land_slide_trigger_nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the dt_land_slide_time_end of this LandslideViewModel. | def dt_land_slide_time_end(self, dt_land_slide_time_end):
self._dt_land_slide_time_end = dt_land_slide_time_end | [
"def dt_off_land_slide_time_end(self, dt_off_land_slide_time_end):\n\n self._dt_off_land_slide_time_end = dt_off_land_slide_time_end",
"def end_date_time(self, end_date_time):\n\n self._end_date_time = end_date_time",
"def end_time(self, end_time):\n\n self._end_time = end_time",
"def dt_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the geo_hazard_name of this LandslideViewModel. | def geo_hazard_name(self, geo_hazard_name):
self._geo_hazard_name = geo_hazard_name | [
"def land_slide_trigger_name(self, land_slide_trigger_name):\n\n self._land_slide_trigger_name = land_slide_trigger_name",
"def geo_hazard_tid(self, geo_hazard_tid):\n\n self._geo_hazard_tid = geo_hazard_tid",
"def land_slide_name(self, land_slide_name):\n\n self._land_slide_name = land_sli... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the activity_influenced_tid of this LandslideViewModel. | def activity_influenced_tid(self, activity_influenced_tid):
self._activity_influenced_tid = activity_influenced_tid | [
"def activity_influenced_name(self, activity_influenced_name):\n\n self._activity_influenced_name = activity_influenced_name",
"def activity_id(self, activity_id):\n\n self._activity_id = activity_id",
"def activity_instance_id(self, activity_instance_id):\n\n self._activity_instance_id = a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the activity_influenced_name of this LandslideViewModel. | def activity_influenced_name(self, activity_influenced_name):
self._activity_influenced_name = activity_influenced_name | [
"def set_activity_name(activity, activity_name, hide_activity):\n if hide_activity:\n activity.set(\"name\", \"{activity_name}\".format(activity_name=activity_name))\n elif not hide_activity:\n activity.set(\"name\", \"{activity_name}_Activity\".format(activity_name=activity_name))",
"def acti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the forecast_accurate_tid of this LandslideViewModel. | def forecast_accurate_tid(self, forecast_accurate_tid):
self._forecast_accurate_tid = forecast_accurate_tid | [
"def forecast_accurate_name(self, forecast_accurate_name):\n\n self._forecast_accurate_name = forecast_accurate_name",
"def forecast_region_tid(self, forecast_region_tid):\n\n self._forecast_region_tid = forecast_region_tid",
"def set_task_forecast(self):\n\n tasks = self._get_all_tasks()\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the forecast_accurate_name of this LandslideViewModel. | def forecast_accurate_name(self, forecast_accurate_name):
self._forecast_accurate_name = forecast_accurate_name | [
"def forecast_region_name(self, forecast_region_name):\n\n self._forecast_region_name = forecast_region_name",
"def forecast_accurate_tid(self, forecast_accurate_tid):\n\n self._forecast_accurate_tid = forecast_accurate_tid",
"def forecast_date(self, forecast_date):\n self._forecast_date = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the damage_extent_tid of this LandslideViewModel. | def damage_extent_tid(self, damage_extent_tid):
self._damage_extent_tid = damage_extent_tid | [
"def damage_extent_name(self, damage_extent_name):\n\n self._damage_extent_name = damage_extent_name",
"def extent(self, extent):\n\n self._extent = extent",
"def setDamage(self, x):\r\n self.damage = x",
"def set_damage(self, damage):\n self.playerDamage = damage",
"def tower_da... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the damage_extent_name of this LandslideViewModel. | def damage_extent_name(self, damage_extent_name):
self._damage_extent_name = damage_extent_name | [
"def damage_extent_tid(self, damage_extent_tid):\n\n self._damage_extent_tid = damage_extent_tid",
"def extent(self, extent):\n\n self._extent = extent",
"def setDamage(self, x):\r\n self.damage = x",
"def land_slide_size_name(self, land_slide_size_name):\n\n self._land_slide_size_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the utm_zone_start of this LandslideViewModel. | def utm_zone_start(self, utm_zone_start):
self._utm_zone_start = utm_zone_start | [
"def utm_north_start(self, utm_north_start):\n\n self._utm_north_start = utm_north_start",
"def utm_east_start(self, utm_east_start):\n\n self._utm_east_start = utm_east_start",
"def terrain_start_zone_tid(self, terrain_start_zone_tid):\n\n self._terrain_start_zone_tid = terrain_start_zone_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the utm_north_start of this LandslideViewModel. | def utm_north_start(self, utm_north_start):
self._utm_north_start = utm_north_start | [
"def utm_north(self, utm_north):\n\n self._utm_north = utm_north",
"def utm_east_start(self, utm_east_start):\n\n self._utm_east_start = utm_east_start",
"def utm_north_stop(self, utm_north_stop):\n\n self._utm_north_stop = utm_north_stop",
"def utm_zone_start(self, utm_zone_start):\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the utm_east_start of this LandslideViewModel. | def utm_east_start(self, utm_east_start):
self._utm_east_start = utm_east_start | [
"def utm_east(self, utm_east):\n\n self._utm_east = utm_east",
"def utm_east_stop(self, utm_east_stop):\n\n self._utm_east_stop = utm_east_stop",
"def utm_north_start(self, utm_north_start):\n\n self._utm_north_start = utm_north_start",
"def utm_north(self, utm_north):\n\n self._ut... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the dt_off_land_slide_time of this LandslideViewModel. | def dt_off_land_slide_time(self, dt_off_land_slide_time):
self._dt_off_land_slide_time = dt_off_land_slide_time | [
"def dt_off_land_slide_time_end(self, dt_off_land_slide_time_end):\n\n self._dt_off_land_slide_time_end = dt_off_land_slide_time_end",
"def dt_land_slide_time_end(self, dt_land_slide_time_end):\n\n self._dt_land_slide_time_end = dt_land_slide_time_end",
"def dt_land_slide_time(self, dt_land_slide_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the dt_off_land_slide_time_end of this LandslideViewModel. | def dt_off_land_slide_time_end(self, dt_off_land_slide_time_end):
self._dt_off_land_slide_time_end = dt_off_land_slide_time_end | [
"def dt_off_land_slide_time(self, dt_off_land_slide_time):\n\n self._dt_off_land_slide_time = dt_off_land_slide_time",
"def dt_land_slide_time_end(self, dt_land_slide_time_end):\n\n self._dt_land_slide_time_end = dt_land_slide_time_end",
"def end_date_time(self, end_date_time):\n\n self._en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the urls of this LandslideViewModel. | def urls(self, urls):
self._urls = urls | [
"def image_urls(self, image_urls):\n\n self._image_urls = image_urls",
"def url_domains(self, url_domains):\n self._url_domains = url_domains",
"def setTweetUrls(self):\n self.urls = [u[\"url\"] for u in self.tweet[\"entities\"][\"urls\"]]",
"def websites(self, websites):\n\n self.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get the exact archaelogical SFH if at_birth is True, then use the birth masses of the stars (i.e., rewind stellar mass loss). otherwise uses the present masses of the stars | def get_archeological_sfh(self, at_birth=True, zero=True):
from .histograms import cumulative_histogram
xprop = 'form.scalefactor'
aform = self.star_particle_prop('form.scalefactor')
tform = self.star_particle_prop('form.time')
if at_birth:
mass = self.star_particle... | [
"def aperture_photometry(self, x_stars, y_stars, aperture, background):\n print '--------------------------------------------------------------------- aperture_photometry'\n\n #--- CONSTANTS ---#\n gain = 0.73 # Gain of camera: electrons pr ADU (ADU = counts from object)- ajust to came... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get different moments (i.e., important times) of the star formation history. returns a dictionary w/ entires 'time.'+percentiles[ii] corresponds to the cosmic time when the SFH hit each percentile. 'duration.'+durations[ii][0]+'.to.'+durations[ii][1] corresponds to the time difference between when the SFH hit the first... | def get_sfh_moments(self, sfh=None, percentiles=[5, 10, 25, 50, 90, 95, 100], durations=[[10, 90]], masses=[1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10]):
if sfh is None:
if self.sfh is None:
sfh = self.get_archeological_sfh()
else:
sfh = self.sfh
res ... | [
"def moment_stats(ffs):\n frames_data = np.array([ ff['data'] for ff in ffs ])\n frame_times = [ ff['msg'].header.stamp.to_sec() for ff in ffs ]\n frames_time_weights = weight_time(m_start, m_stop, frame_times)\n frame_features = np.nansum(frames_data, axi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
build/get the index in each hals[ii] of the main branch progenitor of this halo or of a host | def build_hals_main_branch_indices(self, do_host=False):
def get_mmp_index(my_id, previous_hal, mmp_prop='vel.circ.max'):
# first get the indices in the previous catalog where the descendant is my ID
if not len(previous_hal):
return -2**31
progenitor_indices... | [
"def get_main_branch_indices(self):\n\n assert self.halt is not None\n prog_main_index = self.halt_index\n prog_main_indices = self.halt.prop(\n 'progenitor.main.indices', self.halt_index)\n self.main_branch_indices = prog_main_indices\n return prog_main_indices",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set/return the indices of the main branch of the halo in the halt tree really just a thin wrapper around self.halt.prop('progenitor.main.indices') | def get_main_branch_indices(self):
assert self.halt is not None
prog_main_index = self.halt_index
prog_main_indices = self.halt.prop(
'progenitor.main.indices', self.halt_index)
self.main_branch_indices = prog_main_indices
return prog_main_indices | [
"def build_hals_main_branch_indices(self, do_host=False):\n\n def get_mmp_index(my_id, previous_hal, mmp_prop='vel.circ.max'):\n # first get the indices in the previous catalog where the descendant is my ID\n if not len(previous_hal):\n return -2**31\n\n progen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
gets + assigns distance from the host (or host2) as a function of scalefactor, time, and redshift pericentric distance xprop of pericentric distance first infall time (defined as crossing halt.prop('radius')) last infall time if infall_radius > 0, then use a fixed physical radius to define infall. otherwise, grabs halt... | def get_orbit_history(self, preferred_method='halt', wrt_host2=False, infall_radius=-1, interpolate=0):
host = 'host'
if wrt_host2:
host = 'host2'
dist_prop = host+'.distance.total'
total_distance_evolution = self.get_prop_evolution(
prop_name=dist_prop, preferre... | [
"def interpolate(self, distance, normalized=...): # -> BaseGeometry:\n ...",
"def InterpolateDerivs(self, , p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provide the finalize interface but returns an empty bytestring. | def finalize(self):
return b"" | [
"def finalize(self):\n return self._encryptor.finalize()",
"def finalize(self):\n pass",
"def finalize(self):\n return self._decryptor.finalize()",
"def _finalize(self, rv):\n try:\n self.finalize(rv)\n except:\n ex, val, tb = sys.exc_info()\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build an instance of this padding type. | def build(self, block_size=None):
# type: (int) -> Any
return self.padding(mgf=self.mgf(algorithm=self.mgf_digest()), algorithm=self.digest(), label=None) | [
"def build(self):\n pad_size_tmp = list(self.pad_size)\n\n # This handles the case where the padding is equal to the image size\n if pad_size_tmp[0] == self.input_size[0]:\n pad_size_tmp[0] -= 1\n pad_size_tmp[1] -= 1\n if pad_size_tmp[2] == self.input_size[1]:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determine whether the requested algorithm name is compatible with this cipher | def validate_algorithm(self, algorithm):
# type: (Text) -> None
if not algorithm == self.java_name:
raise InvalidAlgorithmError(
'Requested algorithm "{requested}" is not compatible with cipher "{actual}"'.format(
requested=algorithm, actual=self.java_name... | [
"def test_compatibility(cipher, mode):\n\n chiper_obj = cipher_params(cipher, os.urandom(length_by_cipher[cipher]))[0] #need to be object, not interface, to validate_for_algorithm work\n if chiper_obj.name == \"ChaCha20\":\n return True\n mode_object = None\n if mode == 'CBC':\n mode_obje... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Catcher for algorithms that do not support encryption. | def _disabled_encrypt(self, *args, **kwargs):
raise NotImplementedError('"encrypt" is not supported by the "{}" algorithm'.format(self.java_name)) | [
"def cipher_feedback(self):",
"def test_encryption_cycle_default_algorithm_non_framed_no_encryption_context(self):\n ciphertext, _ = aws_encryption_sdk.encrypt(\n source=VALUES[\"plaintext_128\"], key_provider=self.kms_master_key_provider, frame_length=0\n )\n plaintext, _ = aws_en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Catcher for algorithms that do not support decryption. | def _disabled_decrypt(self, *args, **kwargs):
raise NotImplementedError('"decrypt" is not supported by the "{}" algorithm'.format(self.java_name)) | [
"def decrypt_fable():",
"def decrypt(self, data):",
"def decrypt_vigenere(ciphertext, keyword):\n pass # Your implementation here",
"def test_decrypt_format(self):\n with pytest.raises(EncryptionError):\n decrypt('message')",
"def _post_decrypt_checks(self, aad, plaintext, protected_me... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wrap key using AES keywrap. | def wrap(self, wrapping_key, key_to_wrap):
# type: (bytes, bytes) -> bytes
if self.java_name not in ("AES", "AESWrap"):
raise NotImplementedError('"wrap" is not supported by the "{}" cipher'.format(self.java_name))
try:
return keywrap.aes_key_wrap(wrapping_key=wrapping_k... | [
"def aes_key_wrap(self, kek: bytes, key_to_wrap: bytes) -> bytes:\n return keywrap.aes_key_wrap(kek, key_to_wrap, default_backend())",
"def aes_key_wrap(self, kek: bytes, key_to_wrap: bytes) -> bytes:\n if len(kek) not in (16, 24, 32):\n raise ValueError(\"The wrapping key must be a valid... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unwrap key using AES keywrap. | def unwrap(self, wrapping_key, wrapped_key):
# type: (bytes, bytes) -> bytes
if self.java_name not in ("AES", "AESWrap"):
raise NotImplementedError('"unwrap" is not supported by this cipher')
try:
return keywrap.aes_key_unwrap(wrapping_key=wrapping_key, wrapped_key=wrapp... | [
"def aes_key_unwrap(self, kek: bytes, wrapped_key: bytes) -> bytes:\n return keywrap.aes_key_unwrap(kek, wrapped_key, default_backend())",
"def aes_key_unwrap(self, kek: bytes, wrapped_key: bytes) -> bytes:\n if len(kek) not in (16, 24, 32):\n raise ValueError(\"The wrapping key must be a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Load an RSA key object from the provided raw key bytes. | def load_rsa_key(key, key_type, key_encoding):
# (bytes, EncryptionKeyType, KeyEncodingType) -> Any
# narrow down the output type
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
try:
loader = _RSA_KEY_LOADING[key_type][key_encoding]
except KeyError:
raise ValueError... | [
"def decode_public_key(bytes):\r\n return RSA.importKey(bytes)",
"def load(data):\n d, n = RSAUtils.parse_key(data)\n return RSAPrivateKey(d, n)",
"def load_received_public_key_bytes(self, public_key_str):\n return self.load_received_public_key(\n VerifyingKey.from_string(publ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Refreshes all the documentation from the setup file | def setup_doc(request):
if not request.user.is_superuser:
messages.info(request, "Logon to set up VNS")
return HttpResponseRedirect('/login/')
do_setup_doc()
messages.info(request, "Refreshed documentation")
return HttpResponseRedirect('/') | [
"def update_docs():\n site_path = os.path.join(PROJECTS_ROOT, CURRENT_SITE)\n docs_path = os.path.join(site_path, 'doc_src')\n with cd(docs_path):\n run('git reset --hard && git pull --all')\n run('workon djangopatterns && cd doc_src && make clean')\n run('workon djangopatterns && cd d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a dictionary of suggestion data keyed by total costs. | def suggestion_data_by_cost(suggestions, costs, details, cutoff_rank=None):
data_by_cost = dict()
sugg_count = 0
last_cost_to_include = None
for i in range(len(suggestions)):
sugg_count += 1
sugg = suggestions[i]
cost = costs[i]
detail = de... | [
"def calculate_cost(self):\n costs = {}\n if np.abs(self.agent.get_position()[1]) > self.y_lim:\n costs['cost_outside_bounds'] = 1.\n if self.agent.velocity_violation:\n costs['cost_velocity_violation'] = 1.\n # sum all costs in one total cost\n costs['cost']... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to download PDF CV. | def download(filename):
return send_from_directory(directory='pdf', filename=filename) | [
"def download(self):\n self.build_pdf()\n with open(self.pdf_file, 'rb') as pdf:\n return pdf.read(), 200, {'Content-Type': 'application/pdf',\n 'Content-Disposition': 'attachment; filename=\"Invoice #{}.pdf\"'.format(self.name)}",
"def fetch_pdf(url, b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Called when bot has successfully signed on to server. | def signedOn(self):
log.msg("Signed on")
if self.nickname != self.factory.nickname:
log.msg('Name taken, new is ''"{}".'.format(self.nickname))
self.join(self.factory.channel) | [
"def signedOn(self):\n logging.info(\"Signed on\")\n self.join(self.factory.channel)",
"def signedOn(self):\n self.join(self.factory.channel)\n print \"joined server\"",
"def signedOn(self):\n self.logger.log('identifying to nickserv')\n self.msg(\"NickServ\", \"identif... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Objective function for Matthews correlation coefficient for binary classification. | def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):
with warnings.catch_warnings():
# catches runtime warning when dividing by 0.0
warnings.simplefilter("ignore", RuntimeWarning)
return metrics.matthews_corrcoef(
y_true, y_predicted,... | [
"def matthews_correlation_coefficient(y_true: np.array, y_score: np.array) -> float:\n mat_cor = sklearn.metrics.matthews_corrcoef(y_true, y_score)\n return mat_cor",
"def concordance_correlation_coefficient(y_true, y_pred,\n sample_weight=None,\n multiout... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Objective function for Matthews correlation coefficient for multiclass classification. | def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):
with warnings.catch_warnings():
# catches runtime warning when dividing by 0.0
warnings.simplefilter("ignore", RuntimeWarning)
return metrics.matthews_corrcoef(
y_true, y_predicted,... | [
"def correlation(i_preds, j_preds, labels):\n\n # Calculating the relationship matrix between `i` and `j`\n r_matrix = relationship_matrix(i_preds, j_preds, labels)\n\n # Gathering `a`, `b`, `c` and `d`\n a, b, c, d = r_matrix[0][0], r_matrix[0][1], r_matrix[1][0], r_matrix[1][1]\n\n # Calculating th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Objective function for root mean squared error for regression. | def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):
return metrics.mean_squared_error(
y_true, y_predicted, squared=False, sample_weight=sample_weight
) | [
"def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):\n return metrics.mean_squared_error(\n y_true, y_predicted, sample_weight=sample_weight\n )",
"def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):\n return metrics.mean_absolu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If True, this objective is only valid for positive data. | def positive_only(self):
return True | [
"def isPositive(self):\n return (self.data > 0.).all()",
"def nonNegative(self) -> bool:\n ...",
"def is_positive(self):\n raise NotImplementedError(\n 'operation is_positive(...) not yet implemented')",
"def is_nonpositive(self, a):\n return a <= 0",
"def is_nonnegati... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Objective function for mean squared log error for regression. | def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):
return metrics.mean_squared_log_error(
y_true, y_predicted, sample_weight=sample_weight
) | [
"def train_model_log(features, target):\n lr = LinearRegression()\n lr.fit(features, target)\n y_pred = np.exp(lr.predict(features))\n r2 = lr.score(features, target)\n rsme = mean_squared_error(target, y_pred)\n print('R Squared:' + str(r2), 'RSME:' + str((rsme**.5)))\n return lr",
"def obje... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If True, this objective is only valid for positive data. | def positive_only(self):
return True | [
"def isPositive(self):\n return (self.data > 0.).all()",
"def nonNegative(self) -> bool:\n ...",
"def is_positive(self):\n raise NotImplementedError(\n 'operation is_positive(...) not yet implemented')",
"def is_nonpositive(self, a):\n return a <= 0",
"def is_nonnegati... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Objective function for mean absolute error for regression. | def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):
return metrics.mean_absolute_error(
y_true, y_predicted, sample_weight=sample_weight
) | [
"def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):\n return metrics.mean_squared_error(\n y_true, y_predicted, sample_weight=sample_weight\n )",
"def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):\n return metrics.mean_square... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Objective function for mean squared error for regression. | def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):
return metrics.mean_squared_error(
y_true, y_predicted, sample_weight=sample_weight
) | [
"def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):\n return metrics.mean_squared_error(\n y_true, y_predicted, squared=False, sample_weight=sample_weight\n )",
"def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):\n return metr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Objective function for median absolute error for regression. | def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):
return metrics.median_absolute_error(
y_true, y_predicted, sample_weight=sample_weight
) | [
"def median_absolute_error(y_true, y_pred, *, multioutput=..., sample_weight=...):\n ...",
"def median_absolute_error(self):\n print('Median absolute error regression loss: ' + str(median_absolute_error(self.model.dataset.get_y_test(),\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Objective function for maximum residual error for regression. | def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):
return metrics.max_error(y_true, y_predicted) | [
"def max_error(self):\n print('Maximum residual error: ' + str(max_error(self.model.dataset.get_y_test(), self.model.get_predicted())))",
"def objective(params):\n\t# hyperopt casts as float\n\tparams['num_boost_round'] = int(params['num_boost_round'])\n\tparams['num_leaves'] = int(params['num_leaves'])\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Objective function for explained variance score for regression. | def objective_function(self, y_true, y_predicted, X=None, sample_weight=None):
return metrics.explained_variance_score(
y_true, y_predicted, sample_weight=sample_weight
) | [
"def explained_variance_score(self):\n print('Explained variance score: ' + str(explained_variance_score(self.model.dataset.get_y_test(),\n self.model.get_predicted())))",
"def explained_variance(ypred,y):\n assert y.ndim == 1 and ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
initialize connection and cursor to the database file named 'class_num_2' (or specified with an argument). | def __init__(self, name='class_num_2'):
self.conn = self.cursor = None
exists = os.path.exists(name)
self.conn = sqlite3.connect(name)
self.cursor = self.conn.cursor()
if not exists:
for command in self.CREATE_TABLES:
self.conn.execute(command)
... | [
"def __init__(self, in_db_path, in_db_name):\n if not os.path.isfile(in_db_path + in_db_name):\n self._connection, self._cursor = None, None\n raise Exception('PASSED IN DATABASE PATH IS NOT VALID.')\n else:\n self._connection = sqlite3.connect(in_db_path + in_db_name)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return sql statement that is augmnted by ORDER BY clause. | def _augment_order(self, stmt, key, reverse):
sqlstmt = stmt + " ORDER BY %s" % key
if reverse:
sqlstmt += " DESC"
else:
sqlstmt += " ASC"
return sqlstmt | [
"def _orderby_sql(self, quote_char: Optional[str] = None, **kwargs: Any) -> str:\n clauses = []\n selected_aliases = {s.alias for s in self.base_query._selects}\n for field, directionality in self._orderbys:\n term = (\n format_quotes(field.alias, quote_char)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Select class numbers for range of discriminants. disc_low < disc_high. | def _select_by_range(self, disc_low, disc_high):
sqlstmt = "SELECT h FROM %s WHERE d>=? and d<=?" % self.VIEW
pickup = self.cursor.execute(sqlstmt, (disc_low, disc_high,))
return [h[0] for h in pickup] | [
"def give_class(value, minimum, maximum):\n value = round(value)\n # interval length is the length of each interval after\n # the gap between minimum and maximum is divided by 5 and rounded up\n interval_len = ceil((abs(maximum) - abs(minimum) + 1) / float(5))\n td_classes = ['vlow', 'low', 'medium',... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Insert a (discriminant, class number) pair into the table. | def _insert_single(self, disc, class_num):
self.cursor.execute(self.INSERT, (disc, class_num))
self.conn.commit() | [
"def db_insert_class_in_table(conn: sqlite3.Connection, dataclass: any, table: str):\n class_dict = {}\n\n # We pull all the fields to insert into the table from the dataclass object and build a dictionary of them\n # along with their values, of special note, we are pickling some of the fields values as we... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update value of class number corresponding to the discriminant. | def _update_single(self, disc, class_num):
self.cursor.execute(self.UPDATE, (class_num, disc))
self.conn.commit() | [
"def update_class(self):\n neighbors_set = list(set(self.neighbors))\n counts = np.array([self.neighbors.count(n) for n in neighbors_set])\n probs = (counts / counts.sum()) * (1-self.mutation_prob)\n probs = np.append(probs, self.mutation_prob)\n neighbors_set.append(np.random.cho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Select class numbers for range of discriminants. disc_low < disc_high, both ends included. | def _select_by_range(self, disc_low, disc_high):
sqlstmt = "SELECT h FROM %s WHERE d>=? and d<=?" % self.VIEW
pickup = self.cursor.execute(sqlstmt, (-disc_high, -disc_low))
return [h[0] for h in pickup] | [
"def _select_by_range(self, disc_low, disc_high):\n sqlstmt = \"SELECT h FROM %s WHERE d>=? and d<=?\" % self.VIEW\n pickup = self.cursor.execute(sqlstmt, (disc_low, disc_high,))\n return [h[0] for h in pickup]",
"def give_class(value, minimum, maximum):\n value = round(value)\n # inter... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Funktion to find an arbitrary first hinge X is a numpy ndarray that contains the X values of all datapoints the dimension of data[0] is d x n | def arbitrary_first_hinge(data):
n, d = data[0].shape
max_val = np.zeros((d))
min_val = np.zeros((d))
for i in range(d):
max_val[i] = np.max(data[0][:,i])
min_val[i] = np.min(data[0][:,i])
Delta = np.zeros((d))
no_suitable_hinge = True
count = 0
while no_suitable_hinge: #... | [
"def SGD_hinge(data, labels, C, eta_0, T):\n data = sklearn.preprocessing.normalize(data)\n w = np.zeros(data[0].shape[0])\n n = len(labels)\n for t in range(T):\n rand = np.random.randint(0, n)\n x, y = data[rand], labels[rand]\n eta = eta_0 / (t+1)\n if np.dot(y * w, x) < 1... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Solve the tile in row one at the specified column Updates puzzle and returns a move string | def solve_row1_tile(self, target_col):
moves_str = ""
current_row, current_col = self.current_position(1, target_col)
zero_row, zero_col = self.current_position(0, 0)
moves_str += self.position_tile(zero_row, zero_col, current_row, current_col)
moves_str += "ur"
sel... | [
"def solve_row1_tile(self, target_col):\n # replace with your code\n assert self.row1_invariant(target_col), \"row1 invariant does not hold before solve row1\"\n \n move_string = \"\"\n \n correcttile_pos = self.current_position(1, target_col)\n \n #print corr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This will extract the weights from we big W array. in a 1hidden layer network. this can be easily generalized. | def _extract_weights(self,W):
wl1_size = self._D*self._hidden_layer_size
bl1_size = self._hidden_layer_size
wl2_size = self._hidden_layer_size*self._output_size
bl2_size = self._output_size
weights_L1 = W[0:wl1_size].reshape((self._D,self._hidden_layer_size))
... | [
"def get_weights(self):",
"def get_weights_from_dna(self):\n\n W1_size = self.n_input*self.n_hidden_1\n W2_size = self.n_hidden_1*self.n_hidden_2\n W3_size = self.n_hidden_2*self.n_output\n\n start_W1, end_W1 = 0, W1_size\n start_B1, end_B1 = end_W1, end_W1 + self.n_hidden_1\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if a given packet is a terminal element. | def is_terminal(p):
return isinstance(p, _TerminalPacket) | [
"def terminal(node):\n return node[L] == ''",
"def is_terminal(self, u1):\n\t\treturn (u1 in self.T) # returns True if in array, else False",
"def isTerminal(self, symbol):\n return symbol in self.terminalKeys()",
"def matches(self, terminal):\n return self.kind == terminal.name",
"def is_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |