nwo stringlengths 5 106 | sha stringlengths 40 40 | path stringlengths 4 174 | language stringclasses 1
value | identifier stringlengths 1 140 | parameters stringlengths 0 87.7k | argument_list stringclasses 1
value | return_statement stringlengths 0 426k | docstring stringlengths 0 64.3k | docstring_summary stringlengths 0 26.3k | docstring_tokens list | function stringlengths 18 4.83M | function_tokens list | url stringlengths 83 304 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
LINKIWI/modern-paste | ecc4168bda2a9e5981d495f9e0538258d9f727a2 | app/api/paste.py | python | submit_paste | () | Endpoint for submitting a new paste. | Endpoint for submitting a new paste. | [
"Endpoint",
"for",
"submitting",
"a",
"new",
"paste",
"."
] | def submit_paste():
"""
Endpoint for submitting a new paste.
"""
if config.REQUIRE_LOGIN_TO_PASTE and not current_user.is_authenticated:
return (
flask.jsonify(constants.api.UNAUTHENTICATED_PASTES_DISABLED_FAILURE),
constants.api.UNAUTHENTICATED_PASTES_DISABLED_FAILURE_CO... | [
"def",
"submit_paste",
"(",
")",
":",
"if",
"config",
".",
"REQUIRE_LOGIN_TO_PASTE",
"and",
"not",
"current_user",
".",
"is_authenticated",
":",
"return",
"(",
"flask",
".",
"jsonify",
"(",
"constants",
".",
"api",
".",
"UNAUTHENTICATED_PASTES_DISABLED_FAILURE",
"... | https://github.com/LINKIWI/modern-paste/blob/ecc4168bda2a9e5981d495f9e0538258d9f727a2/app/api/paste.py#L22-L91 | ||
nltk/nltk | 3f74ac55681667d7ef78b664557487145f51eb02 | nltk/corpus/reader/wordnet.py | python | Synset.path_similarity | (self, other, verbose=False, simulate_root=True) | return 1.0 / (distance + 1) | Path Distance Similarity:
Return a score denoting how similar two word senses are, based on the
shortest path that connects the senses in the is-a (hypernym/hypnoym)
taxonomy. The score is in the range 0 to 1, except in those cases where
a path cannot be found (will only be true for verb... | Path Distance Similarity:
Return a score denoting how similar two word senses are, based on the
shortest path that connects the senses in the is-a (hypernym/hypnoym)
taxonomy. The score is in the range 0 to 1, except in those cases where
a path cannot be found (will only be true for verb... | [
"Path",
"Distance",
"Similarity",
":",
"Return",
"a",
"score",
"denoting",
"how",
"similar",
"two",
"word",
"senses",
"are",
"based",
"on",
"the",
"shortest",
"path",
"that",
"connects",
"the",
"senses",
"in",
"the",
"is",
"-",
"a",
"(",
"hypernym",
"/",
... | def path_similarity(self, other, verbose=False, simulate_root=True):
"""
Path Distance Similarity:
Return a score denoting how similar two word senses are, based on the
shortest path that connects the senses in the is-a (hypernym/hypnoym)
taxonomy. The score is in the range 0 to ... | [
"def",
"path_similarity",
"(",
"self",
",",
"other",
",",
"verbose",
"=",
"False",
",",
"simulate_root",
"=",
"True",
")",
":",
"distance",
"=",
"self",
".",
"shortest_path_distance",
"(",
"other",
",",
"simulate_root",
"=",
"simulate_root",
"and",
"(",
"sel... | https://github.com/nltk/nltk/blob/3f74ac55681667d7ef78b664557487145f51eb02/nltk/corpus/reader/wordnet.py#L837-L870 | |
Calysto/calysto_scheme | 15bf81987870bcae1264e5a0a06feb9a8ee12b8b | calysto_scheme/scheme.py | python | mit_style_define_q_hat | (asexp) | return (define_q_hat(asexp)) and (pair_q_hat(cadr_hat(asexp))) | [] | def mit_style_define_q_hat(asexp):
return (define_q_hat(asexp)) and (pair_q_hat(cadr_hat(asexp))) | [
"def",
"mit_style_define_q_hat",
"(",
"asexp",
")",
":",
"return",
"(",
"define_q_hat",
"(",
"asexp",
")",
")",
"and",
"(",
"pair_q_hat",
"(",
"cadr_hat",
"(",
"asexp",
")",
")",
")"
] | https://github.com/Calysto/calysto_scheme/blob/15bf81987870bcae1264e5a0a06feb9a8ee12b8b/calysto_scheme/scheme.py#L6832-L6833 | |||
openstack/tempest | fe0ac89a5a1c43fa908a76759cd99eea3b1f9853 | tempest/common/waiters.py | python | wait_for_volume_resource_status | (client, resource_id, status) | Waits for a volume resource to reach a given status.
This function is a common function for volume, snapshot and backup
resources. The function extracts the name of the desired resource from
the client class name of the resource. | Waits for a volume resource to reach a given status. | [
"Waits",
"for",
"a",
"volume",
"resource",
"to",
"reach",
"a",
"given",
"status",
"."
] | def wait_for_volume_resource_status(client, resource_id, status):
"""Waits for a volume resource to reach a given status.
This function is a common function for volume, snapshot and backup
resources. The function extracts the name of the desired resource from
the client class name of the resource.
... | [
"def",
"wait_for_volume_resource_status",
"(",
"client",
",",
"resource_id",
",",
"status",
")",
":",
"resource_name",
"=",
"re",
".",
"findall",
"(",
"r'(volume|group-snapshot|snapshot|backup|group)'",
",",
"client",
".",
"resource_type",
")",
"[",
"-",
"1",
"]",
... | https://github.com/openstack/tempest/blob/fe0ac89a5a1c43fa908a76759cd99eea3b1f9853/tempest/common/waiters.py#L281-L314 | ||
INK-USC/KagNet | b386661ac5841774b9d17cc132e991a7bef3c5ef | embeddings/OpenKE/models/TransH.py | python | TransH._transfer | (self, e, n) | return e - tf.reduce_sum(e * n, 1, keep_dims = True) * n | [] | def _transfer(self, e, n):
return e - tf.reduce_sum(e * n, 1, keep_dims = True) * n | [
"def",
"_transfer",
"(",
"self",
",",
"e",
",",
"n",
")",
":",
"return",
"e",
"-",
"tf",
".",
"reduce_sum",
"(",
"e",
"*",
"n",
",",
"1",
",",
"keep_dims",
"=",
"True",
")",
"*",
"n"
] | https://github.com/INK-USC/KagNet/blob/b386661ac5841774b9d17cc132e991a7bef3c5ef/embeddings/OpenKE/models/TransH.py#L11-L12 | |||
hakril/PythonForWindows | 61e027a678d5b87aa64fcf8a37a6661a86236589 | windows/debug/debugger.py | python | Debugger._restore_breakpoint_MEMBP | (self, bp, target) | return target.virtual_protect(page_addr, PAGE_SIZE, page_prot, None) | [] | def _restore_breakpoint_MEMBP(self, bp, target):
(page_addr, page_prot) = bp._reput_page
return target.virtual_protect(page_addr, PAGE_SIZE, page_prot, None) | [
"def",
"_restore_breakpoint_MEMBP",
"(",
"self",
",",
"bp",
",",
"target",
")",
":",
"(",
"page_addr",
",",
"page_prot",
")",
"=",
"bp",
".",
"_reput_page",
"return",
"target",
".",
"virtual_protect",
"(",
"page_addr",
",",
"PAGE_SIZE",
",",
"page_prot",
","... | https://github.com/hakril/PythonForWindows/blob/61e027a678d5b87aa64fcf8a37a6661a86236589/windows/debug/debugger.py#L416-L418 | |||
pysmt/pysmt | ade4dc2a825727615033a96d31c71e9f53ce4764 | pysmt/formula.py | python | FormulaManager.BVURem | (self, left, right) | return self.create_node(node_type=op.BV_UREM,
args=(left, right),
payload=(left.bv_width(),)) | Returns the reminder of the two BV. | Returns the reminder of the two BV. | [
"Returns",
"the",
"reminder",
"of",
"the",
"two",
"BV",
"."
] | def BVURem(self, left, right):
"""Returns the reminder of the two BV."""
return self.create_node(node_type=op.BV_UREM,
args=(left, right),
payload=(left.bv_width(),)) | [
"def",
"BVURem",
"(",
"self",
",",
"left",
",",
"right",
")",
":",
"return",
"self",
".",
"create_node",
"(",
"node_type",
"=",
"op",
".",
"BV_UREM",
",",
"args",
"=",
"(",
"left",
",",
"right",
")",
",",
"payload",
"=",
"(",
"left",
".",
"bv_width... | https://github.com/pysmt/pysmt/blob/ade4dc2a825727615033a96d31c71e9f53ce4764/pysmt/formula.py#L757-L761 | |
pysathq/pysat | 07bf3a5a4428d40eca804e7ebdf4f496aadf4213 | pysat/solvers.py | python | Minicard.delete | (self) | Destructor. | Destructor. | [
"Destructor",
"."
] | def delete(self):
"""
Destructor.
"""
if self.minicard:
pysolvers.minicard_del(self.minicard)
self.minicard = None | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"minicard",
":",
"pysolvers",
".",
"minicard_del",
"(",
"self",
".",
"minicard",
")",
"self",
".",
"minicard",
"=",
"None"
] | https://github.com/pysathq/pysat/blob/07bf3a5a4428d40eca804e7ebdf4f496aadf4213/pysat/solvers.py#L4237-L4244 | ||
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/numpy-1.16.0-py3.7-macosx-10.9-x86_64.egg/numpy/lib/scimath.py | python | _fix_real_abs_gt_1 | (x) | return x | Convert `x` to complex if it has real components x_i with abs(x_i)>1.
Otherwise, output is just the array version of the input (via asarray).
Parameters
----------
x : array_like
Returns
-------
array
Examples
--------
>>> np.lib.scimath._fix_real_abs_gt_1([0,1])
array([0... | Convert `x` to complex if it has real components x_i with abs(x_i)>1. | [
"Convert",
"x",
"to",
"complex",
"if",
"it",
"has",
"real",
"components",
"x_i",
"with",
"abs",
"(",
"x_i",
")",
">",
"1",
"."
] | def _fix_real_abs_gt_1(x):
"""Convert `x` to complex if it has real components x_i with abs(x_i)>1.
Otherwise, output is just the array version of the input (via asarray).
Parameters
----------
x : array_like
Returns
-------
array
Examples
--------
>>> np.lib.scimath._fix... | [
"def",
"_fix_real_abs_gt_1",
"(",
"x",
")",
":",
"x",
"=",
"asarray",
"(",
"x",
")",
"if",
"any",
"(",
"isreal",
"(",
"x",
")",
"&",
"(",
"abs",
"(",
"x",
")",
">",
"1",
")",
")",
":",
"x",
"=",
"_tocomplex",
"(",
"x",
")",
"return",
"x"
] | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/numpy-1.16.0-py3.7-macosx-10.9-x86_64.egg/numpy/lib/scimath.py#L154-L178 | |
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/lib-python/3/sndhdr.py | python | get_long_le | (b) | return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0] | [] | def get_long_le(b):
return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0] | [
"def",
"get_long_le",
"(",
"b",
")",
":",
"return",
"(",
"b",
"[",
"3",
"]",
"<<",
"24",
")",
"|",
"(",
"b",
"[",
"2",
"]",
"<<",
"16",
")",
"|",
"(",
"b",
"[",
"1",
"]",
"<<",
"8",
")",
"|",
"b",
"[",
"0",
"]"
] | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/sndhdr.py#L186-L187 | |||
sethmlarson/virtualbox-python | 984a6e2cb0e8996f4df40f4444c1528849f1c70d | virtualbox/library_ext/console.py | python | IConsole.register_on_drag_and_drop_mode_changed | (self, callback) | return self.event_source.register_callback(callback, event_type) | Set the callback function to consume on drag and drop mode changed
events.
Callback receives a IDragAndDropModeChangedEvent object.
Returns the callback_id | Set the callback function to consume on drag and drop mode changed
events. | [
"Set",
"the",
"callback",
"function",
"to",
"consume",
"on",
"drag",
"and",
"drop",
"mode",
"changed",
"events",
"."
] | def register_on_drag_and_drop_mode_changed(self, callback):
"""Set the callback function to consume on drag and drop mode changed
events.
Callback receives a IDragAndDropModeChangedEvent object.
Returns the callback_id
"""
event_type = library.VBoxEventType.on_drag_and_... | [
"def",
"register_on_drag_and_drop_mode_changed",
"(",
"self",
",",
"callback",
")",
":",
"event_type",
"=",
"library",
".",
"VBoxEventType",
".",
"on_drag_and_drop_mode_changed",
"return",
"self",
".",
"event_source",
".",
"register_callback",
"(",
"callback",
",",
"e... | https://github.com/sethmlarson/virtualbox-python/blob/984a6e2cb0e8996f4df40f4444c1528849f1c70d/virtualbox/library_ext/console.py#L65-L74 | |
vsjha18/nsetools | b0e99c8decac0cba0bc19427428fd2d7b8836eaf | downloader.py | python | BaseBhavcopyDownloader.__init__ | (self, from_date, to_date=dt.datetime.now().date(), skip_dates=[]) | accepts date in fuzzy format | accepts date in fuzzy format | [
"accepts",
"date",
"in",
"fuzzy",
"format"
] | def __init__(self, from_date, to_date=dt.datetime.now().date(), skip_dates=[]):
"""accepts date in fuzzy format"""
self.bhavcopy_base_url = "https://www.nseindia.com/content/historical/EQUITIES/%s/%s/cm%s%s%sbhav.csv.zip"
self.bhavcopy_base_filename = "cm%s%s%sbhav.csv"
self.from_date = ... | [
"def",
"__init__",
"(",
"self",
",",
"from_date",
",",
"to_date",
"=",
"dt",
".",
"datetime",
".",
"now",
"(",
")",
".",
"date",
"(",
")",
",",
"skip_dates",
"=",
"[",
"]",
")",
":",
"self",
".",
"bhavcopy_base_url",
"=",
"\"https://www.nseindia.com/cont... | https://github.com/vsjha18/nsetools/blob/b0e99c8decac0cba0bc19427428fd2d7b8836eaf/downloader.py#L36-L44 | ||
openstack/cinder | 23494a6d6c51451688191e1847a458f1d3cdcaa5 | cinder/volume/drivers/nec/volume_helper.py | python | MStorageDSVDriver.revert_to_snapshot | (self, context, volume, snapshot) | called to perform revert volume from snapshot.
:param context: Our working context.
:param volume: the volume to be reverted.
:param snapshot: the snapshot data revert to volume.
:return None | called to perform revert volume from snapshot. | [
"called",
"to",
"perform",
"revert",
"volume",
"from",
"snapshot",
"."
] | def revert_to_snapshot(self, context, volume, snapshot):
"""called to perform revert volume from snapshot.
:param context: Our working context.
:param volume: the volume to be reverted.
:param snapshot: the snapshot data revert to volume.
:return None
"""
msgparm... | [
"def",
"revert_to_snapshot",
"(",
"self",
",",
"context",
",",
"volume",
",",
"snapshot",
")",
":",
"msgparm",
"=",
"(",
"'Volume ID = %(vol_id)s, '",
"'Snapshot ID = %(snap_id)s, '",
"'Snapshot Volume ID = %(snapvol_id)s'",
"%",
"{",
"'vol_id'",
":",
"volume",
".",
"... | https://github.com/openstack/cinder/blob/23494a6d6c51451688191e1847a458f1d3cdcaa5/cinder/volume/drivers/nec/volume_helper.py#L1951-L1972 | ||
twilio/twilio-python | 6e1e811ea57a1edfadd5161ace87397c563f6915 | twilio/rest/preview/__init__.py | python | Preview.bulk_exports | (self) | return self._bulk_exports | :returns: Version bulk_exports of preview
:rtype: twilio.rest.preview.bulk_exports.BulkExports | :returns: Version bulk_exports of preview
:rtype: twilio.rest.preview.bulk_exports.BulkExports | [
":",
"returns",
":",
"Version",
"bulk_exports",
"of",
"preview",
":",
"rtype",
":",
"twilio",
".",
"rest",
".",
"preview",
".",
"bulk_exports",
".",
"BulkExports"
] | def bulk_exports(self):
"""
:returns: Version bulk_exports of preview
:rtype: twilio.rest.preview.bulk_exports.BulkExports
"""
if self._bulk_exports is None:
self._bulk_exports = BulkExports(self)
return self._bulk_exports | [
"def",
"bulk_exports",
"(",
"self",
")",
":",
"if",
"self",
".",
"_bulk_exports",
"is",
"None",
":",
"self",
".",
"_bulk_exports",
"=",
"BulkExports",
"(",
"self",
")",
"return",
"self",
".",
"_bulk_exports"
] | https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/preview/__init__.py#L44-L51 | |
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/distutils/config.py | python | PyPIRCCommand._read_pypirc | (self) | return {} | Reads the .pypirc file. | Reads the .pypirc file. | [
"Reads",
"the",
".",
"pypirc",
"file",
"."
] | def _read_pypirc(self):
"""Reads the .pypirc file."""
rc = self._get_rc_file()
if os.path.exists(rc):
self.announce('Using PyPI login from %s' % rc)
repository = self.repository or self.DEFAULT_REPOSITORY
config = RawConfigParser()
config.read(rc)... | [
"def",
"_read_pypirc",
"(",
"self",
")",
":",
"rc",
"=",
"self",
".",
"_get_rc_file",
"(",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"rc",
")",
":",
"self",
".",
"announce",
"(",
"'Using PyPI login from %s'",
"%",
"rc",
")",
"repository",
"=",
... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/distutils/config.py#L48-L110 | |
facelessuser/ColorHelper | cfed17c35dbae4db49a14165ef222407c48a3014 | ch_native_picker.py | python | LinuxPick.pick | (self) | return color | Pick the color. | Pick the color. | [
"Pick",
"the",
"color",
"."
] | def pick(self):
"""Pick the color."""
color = self.color.convert('srgb')
hx = color.to_string(hex=True, alpha=False)
try:
p = subprocess.Popen(
['kcolorchooser', '--print', '--color', hx],
stdin=subprocess.PIPE,
stdout=subproce... | [
"def",
"pick",
"(",
"self",
")",
":",
"color",
"=",
"self",
".",
"color",
".",
"convert",
"(",
"'srgb'",
")",
"hx",
"=",
"color",
".",
"to_string",
"(",
"hex",
"=",
"True",
",",
"alpha",
"=",
"False",
")",
"try",
":",
"p",
"=",
"subprocess",
".",... | https://github.com/facelessuser/ColorHelper/blob/cfed17c35dbae4db49a14165ef222407c48a3014/ch_native_picker.py#L150-L171 | |
openstenoproject/plover | 4394ef158579c1b3088335e3eb7323453fcc0b73 | plover/formatting.py | python | rightmost_word | (s) | return last_word | Get the rightmost word in s. | Get the rightmost word in s. | [
"Get",
"the",
"rightmost",
"word",
"in",
"s",
"."
] | def rightmost_word(s):
"""Get the rightmost word in s."""
words = WORD_RX.findall(s)
if not words:
return ''
last_word = words[-1]
if last_word[-1].isspace():
return ''
return last_word | [
"def",
"rightmost_word",
"(",
"s",
")",
":",
"words",
"=",
"WORD_RX",
".",
"findall",
"(",
"s",
")",
"if",
"not",
"words",
":",
"return",
"''",
"last_word",
"=",
"words",
"[",
"-",
"1",
"]",
"if",
"last_word",
"[",
"-",
"1",
"]",
".",
"isspace",
... | https://github.com/openstenoproject/plover/blob/4394ef158579c1b3088335e3eb7323453fcc0b73/plover/formatting.py#L956-L964 | |
pculture/miro | d8e4594441939514dd2ac29812bf37087bb3aea5 | tv/lib/frontends/widgets/tablist.py | python | LibraryTabList._auto_tabs_after | (self, name) | return self.auto_tab_order[pos+1:] | Get the auto-tabs that should be below name. | Get the auto-tabs that should be below name. | [
"Get",
"the",
"auto",
"-",
"tabs",
"that",
"should",
"be",
"below",
"name",
"."
] | def _auto_tabs_after(self, name):
"""Get the auto-tabs that should be below name."""
pos = self.auto_tab_order.index(name)
return self.auto_tab_order[pos+1:] | [
"def",
"_auto_tabs_after",
"(",
"self",
",",
"name",
")",
":",
"pos",
"=",
"self",
".",
"auto_tab_order",
".",
"index",
"(",
"name",
")",
"return",
"self",
".",
"auto_tab_order",
"[",
"pos",
"+",
"1",
":",
"]"
] | https://github.com/pculture/miro/blob/d8e4594441939514dd2ac29812bf37087bb3aea5/tv/lib/frontends/widgets/tablist.py#L463-L466 | |
kakao/khaiii | 328d5a8af456a5941130383354c07d1cd0e47cf5 | train/validate_errpatch.py | python | _sent_iter | (args: Namespace) | sentence generator
Args:
args: arguments
Yields:
sentence | sentence generator
Args:
args: arguments
Yields:
sentence | [
"sentence",
"generator",
"Args",
":",
"args",
":",
"arguments",
"Yields",
":",
"sentence"
] | def _sent_iter(args: Namespace) -> Iterator[Sentence]:
"""
sentence generator
Args:
args: arguments
Yields:
sentence
"""
if not _CORPUS:
for name in sorted(os.listdir(args.corpus_dir)):
if not name.endswith('.txt'):
continue
path =... | [
"def",
"_sent_iter",
"(",
"args",
":",
"Namespace",
")",
"->",
"Iterator",
"[",
"Sentence",
"]",
":",
"if",
"not",
"_CORPUS",
":",
"for",
"name",
"in",
"sorted",
"(",
"os",
".",
"listdir",
"(",
"args",
".",
"corpus_dir",
")",
")",
":",
"if",
"not",
... | https://github.com/kakao/khaiii/blob/328d5a8af456a5941130383354c07d1cd0e47cf5/train/validate_errpatch.py#L57-L76 | ||
google/grr | 8ad8a4d2c5a93c92729206b7771af19d92d4f915 | grr/client/grr_response_client/unprivileged/filesystem/server.py | python | CreateFilesystemServer | (
device_file_descriptor: Optional[int] = None) | return server.CreateServer(extra_file_descriptors,
interface_registry.Interface.FILESYSTEM) | [] | def CreateFilesystemServer(
device_file_descriptor: Optional[int] = None) -> communication.Server:
extra_file_descriptors = []
if device_file_descriptor is not None:
extra_file_descriptors.append(
communication.FileDescriptor.FromFileDescriptor(device_file_descriptor))
return server.CreateServer(e... | [
"def",
"CreateFilesystemServer",
"(",
"device_file_descriptor",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
"->",
"communication",
".",
"Server",
":",
"extra_file_descriptors",
"=",
"[",
"]",
"if",
"device_file_descriptor",
"is",
"not",
"None",
":",
"ext... | https://github.com/google/grr/blob/8ad8a4d2c5a93c92729206b7771af19d92d4f915/grr/client/grr_response_client/unprivileged/filesystem/server.py#L11-L18 | |||
huggingface/transformers | 623b4f7c63f60cce917677ee704d6c93ee960b4b | examples/research_projects/seq2seq-distillation/utils.py | python | Seq2SeqDataCollator.__call__ | (self, batch) | return batch | [] | def __call__(self, batch) -> Dict[str, torch.Tensor]:
if hasattr(self.tokenizer, "prepare_seq2seq_batch"):
batch = self._encode(batch)
input_ids, attention_mask, labels = (
batch["input_ids"],
batch["attention_mask"],
batch["labels"],
... | [
"def",
"__call__",
"(",
"self",
",",
"batch",
")",
"->",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
":",
"if",
"hasattr",
"(",
"self",
".",
"tokenizer",
",",
"\"prepare_seq2seq_batch\"",
")",
":",
"batch",
"=",
"self",
".",
"_encode",
"(",
... | https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/examples/research_projects/seq2seq-distillation/utils.py#L278-L305 | |||
wbond/packagecontrol.io | 9f5eb7e3392e6bc2ad979ad32d3dd27ef9c00b20 | app/lib/package_control/clients/github_client.py | python | GitHubClient._user_repo_branch | (self, url) | return (user_repo, branch) | Extract the username/repo and branch name from the URL
:param url:
The URL to extract the info from, in one of the forms:
https://github.com/{user}/{repo}
https://github.com/{user}/{repo}/tree/{branch}
:return:
A tuple of (user/repo, branch name) or ... | Extract the username/repo and branch name from the URL | [
"Extract",
"the",
"username",
"/",
"repo",
"and",
"branch",
"name",
"from",
"the",
"URL"
] | def _user_repo_branch(self, url):
"""
Extract the username/repo and branch name from the URL
:param url:
The URL to extract the info from, in one of the forms:
https://github.com/{user}/{repo}
https://github.com/{user}/{repo}/tree/{branch}
:retur... | [
"def",
"_user_repo_branch",
"(",
"self",
",",
"url",
")",
":",
"branch",
"=",
"None",
"branch_match",
"=",
"re",
".",
"match",
"(",
"'https?://github.com/[^/]+/[^/]+/tree/([^/]+)/?$'",
",",
"url",
")",
"if",
"branch_match",
"is",
"not",
"None",
":",
"branch",
... | https://github.com/wbond/packagecontrol.io/blob/9f5eb7e3392e6bc2ad979ad32d3dd27ef9c00b20/app/lib/package_control/clients/github_client.py#L311-L334 | |
mtianyan/VueDjangoAntdProBookShop | fd8fa2151c81edde2f8b8e6df8e1ddd799f940c2 | third_party/social_core/backends/qiita.py | python | QiitaOAuth2.user_data | (self, access_token, *args, **kwargs) | return self.get_json(
'https://qiita.com/api/v2/authenticated_user',
headers={
'Authorization': 'Bearer {0}'.format(access_token)
}) | Loads user data from service | Loads user data from service | [
"Loads",
"user",
"data",
"from",
"service"
] | def user_data(self, access_token, *args, **kwargs):
"""Loads user data from service"""
return self.get_json(
'https://qiita.com/api/v2/authenticated_user',
headers={
'Authorization': 'Bearer {0}'.format(access_token)
}) | [
"def",
"user_data",
"(",
"self",
",",
"access_token",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get_json",
"(",
"'https://qiita.com/api/v2/authenticated_user'",
",",
"headers",
"=",
"{",
"'Authorization'",
":",
"'Bearer {0}'",
... | https://github.com/mtianyan/VueDjangoAntdProBookShop/blob/fd8fa2151c81edde2f8b8e6df8e1ddd799f940c2/third_party/social_core/backends/qiita.py#L60-L66 | |
chb/indivo_server | 9826c67ab17d7fc0df935db327344fb0c7d237e5 | indivo/accesscontrol/__init__.py | python | load_access_rules | () | Initializes the accesscontrol system by loading the access rules for the views | Initializes the accesscontrol system by loading the access rules for the views | [
"Initializes",
"the",
"accesscontrol",
"system",
"by",
"loading",
"the",
"access",
"rules",
"for",
"the",
"views"
] | def load_access_rules():
"""
Initializes the accesscontrol system by loading the access rules for the views
"""
# These are run after the paramloader middleware, which means kw_args have been
# converted to Django models.
# Thus, access_funcs should take 'record', 'carenet', 'account', etc. instead of
#... | [
"def",
"load_access_rules",
"(",
")",
":",
"# These are run after the paramloader middleware, which means kw_args have been",
"# converted to Django models.",
"# Thus, access_funcs should take 'record', 'carenet', 'account', etc. instead of",
"# view_args, view_kwargs.",
"#",
"# The syntax for d... | https://github.com/chb/indivo_server/blob/9826c67ab17d7fc0df935db327344fb0c7d237e5/indivo/accesscontrol/__init__.py#L9-L386 | ||
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/lib-python/3/idlelib/ClassBrowser.py | python | MethodBrowserTreeItem.__init__ | (self, name, cl, file) | [] | def __init__(self, name, cl, file):
self.name = name
self.cl = cl
self.file = file | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"cl",
",",
"file",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"cl",
"=",
"cl",
"self",
".",
"file",
"=",
"file"
] | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/idlelib/ClassBrowser.py#L185-L188 | ||||
hatRiot/zarp | 2e772350a01c2aeed3f4da9685cd0cc5d6b3ecad | src/lib/scapy/layers/inet6.py | python | _HopByHopOptionsField.i2len | (self, pkt, i) | return l | [] | def i2len(self, pkt, i):
l = len(self.i2m(pkt, i))
return l | [
"def",
"i2len",
"(",
"self",
",",
"pkt",
",",
"i",
")",
":",
"l",
"=",
"len",
"(",
"self",
".",
"i2m",
"(",
"pkt",
",",
"i",
")",
")",
"return",
"l"
] | https://github.com/hatRiot/zarp/blob/2e772350a01c2aeed3f4da9685cd0cc5d6b3ecad/src/lib/scapy/layers/inet6.py#L741-L743 | |||
zjy-ucas/ChineseNER | 48e1007e60194c13377f8ce612c505d484b18c7d | utils.py | python | test_ner | (results, path) | return eval_lines | Run perl script to evaluate model | Run perl script to evaluate model | [
"Run",
"perl",
"script",
"to",
"evaluate",
"model"
] | def test_ner(results, path):
"""
Run perl script to evaluate model
"""
output_file = os.path.join(path, "ner_predict.utf8")
with open(output_file, "w") as f:
to_write = []
for block in results:
for line in block:
to_write.append(line + "\n")
to... | [
"def",
"test_ner",
"(",
"results",
",",
"path",
")",
":",
"output_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"\"ner_predict.utf8\"",
")",
"with",
"open",
"(",
"output_file",
",",
"\"w\"",
")",
"as",
"f",
":",
"to_write",
"=",
"[",
... | https://github.com/zjy-ucas/ChineseNER/blob/48e1007e60194c13377f8ce612c505d484b18c7d/utils.py#L53-L67 | |
ctxis/canape | 5f0e03424577296bcc60c2008a60a98ec5307e4b | CANAPE.Scripting/Lib/nntplib.py | python | NNTP.putline | (self, line) | Internal: send one line to the server, appending CRLF. | Internal: send one line to the server, appending CRLF. | [
"Internal",
":",
"send",
"one",
"line",
"to",
"the",
"server",
"appending",
"CRLF",
"."
] | def putline(self, line):
"""Internal: send one line to the server, appending CRLF."""
line = line + CRLF
if self.debugging > 1: print '*put*', repr(line)
self.sock.sendall(line) | [
"def",
"putline",
"(",
"self",
",",
"line",
")",
":",
"line",
"=",
"line",
"+",
"CRLF",
"if",
"self",
".",
"debugging",
">",
"1",
":",
"print",
"'*put*'",
",",
"repr",
"(",
"line",
")",
"self",
".",
"sock",
".",
"sendall",
"(",
"line",
")"
] | https://github.com/ctxis/canape/blob/5f0e03424577296bcc60c2008a60a98ec5307e4b/CANAPE.Scripting/Lib/nntplib.py#L189-L193 | ||
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/astropy-4.0-py3.7-macosx-10.9-x86_64.egg/astropy/_erfa/core.py | python | fal03 | (t) | return c_retval | Wrapper for ERFA function ``eraFal03``.
Parameters
----------
t : double array
Returns
-------
c_retval : double array
Notes
-----
The ERFA documentation is below.
- - - - - - - - -
e r a F a l 0 3
- - - - - - - - -
Fundamental argument, IERS Conventions (2003):... | Wrapper for ERFA function ``eraFal03``. | [
"Wrapper",
"for",
"ERFA",
"function",
"eraFal03",
"."
] | def fal03(t):
"""
Wrapper for ERFA function ``eraFal03``.
Parameters
----------
t : double array
Returns
-------
c_retval : double array
Notes
-----
The ERFA documentation is below.
- - - - - - - - -
e r a F a l 0 3
- - - - - - - - -
Fundamental argument... | [
"def",
"fal03",
"(",
"t",
")",
":",
"c_retval",
"=",
"ufunc",
".",
"fal03",
"(",
"t",
")",
"return",
"c_retval"
] | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/astropy-4.0-py3.7-macosx-10.9-x86_64.egg/astropy/_erfa/core.py#L5369-L5419 | |
kubernetes-client/python | 47b9da9de2d02b2b7a34fbe05afb44afd130d73a | kubernetes/client/models/v1alpha1_role_binding_list.py | python | V1alpha1RoleBindingList.metadata | (self) | return self._metadata | Gets the metadata of this V1alpha1RoleBindingList. # noqa: E501
:return: The metadata of this V1alpha1RoleBindingList. # noqa: E501
:rtype: V1ListMeta | Gets the metadata of this V1alpha1RoleBindingList. # noqa: E501 | [
"Gets",
"the",
"metadata",
"of",
"this",
"V1alpha1RoleBindingList",
".",
"#",
"noqa",
":",
"E501"
] | def metadata(self):
"""Gets the metadata of this V1alpha1RoleBindingList. # noqa: E501
:return: The metadata of this V1alpha1RoleBindingList. # noqa: E501
:rtype: V1ListMeta
"""
return self._metadata | [
"def",
"metadata",
"(",
"self",
")",
":",
"return",
"self",
".",
"_metadata"
] | https://github.com/kubernetes-client/python/blob/47b9da9de2d02b2b7a34fbe05afb44afd130d73a/kubernetes/client/models/v1alpha1_role_binding_list.py#L141-L148 | |
rhinstaller/anaconda | 63edc8680f1b05cbfe11bef28703acba808c5174 | pyanaconda/modules/common/task/result.py | python | ResultProvider._set_result | (self, result) | Set the result of the task.
:param result: a result of the task | Set the result of the task. | [
"Set",
"the",
"result",
"of",
"the",
"task",
"."
] | def _set_result(self, result):
"""Set the result of the task.
:param result: a result of the task
"""
with self.__result_lock:
self.__result = result | [
"def",
"_set_result",
"(",
"self",
",",
"result",
")",
":",
"with",
"self",
".",
"__result_lock",
":",
"self",
".",
"__result",
"=",
"result"
] | https://github.com/rhinstaller/anaconda/blob/63edc8680f1b05cbfe11bef28703acba808c5174/pyanaconda/modules/common/task/result.py#L34-L40 | ||
Esri/ArcREST | ab240fde2b0200f61d4a5f6df033516e53f2f416 | src/arcrest/ags/featureservice.py | python | FeatureService.fullExtent | (self) | return self._fullExtent | returns the full extent of the feature service | returns the full extent of the feature service | [
"returns",
"the",
"full",
"extent",
"of",
"the",
"feature",
"service"
] | def fullExtent(self):
""" returns the full extent of the feature service """
if self._fullExtent is None:
self.__init()
return self._fullExtent | [
"def",
"fullExtent",
"(",
"self",
")",
":",
"if",
"self",
".",
"_fullExtent",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"return",
"self",
".",
"_fullExtent"
] | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/featureservice.py#L217-L221 | |
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.9.40/roles/lib_openshift/library/oc_adm_policy_user.py | python | Yedit.get_entry | (data, key, sep='.') | return data | Get an item from a dictionary with key notation a.b.c
d = {'a': {'b': 'c'}}}
key = a.b
return c | Get an item from a dictionary with key notation a.b.c
d = {'a': {'b': 'c'}}}
key = a.b
return c | [
"Get",
"an",
"item",
"from",
"a",
"dictionary",
"with",
"key",
"notation",
"a",
".",
"b",
".",
"c",
"d",
"=",
"{",
"a",
":",
"{",
"b",
":",
"c",
"}}}",
"key",
"=",
"a",
".",
"b",
"return",
"c"
] | def get_entry(data, key, sep='.'):
''' Get an item from a dictionary with key notation a.b.c
d = {'a': {'b': 'c'}}}
key = a.b
return c
'''
if key == '':
pass
elif (not (key and Yedit.valid_key(key, sep)) and
isinstance(data, (... | [
"def",
"get_entry",
"(",
"data",
",",
"key",
",",
"sep",
"=",
"'.'",
")",
":",
"if",
"key",
"==",
"''",
":",
"pass",
"elif",
"(",
"not",
"(",
"key",
"and",
"Yedit",
".",
"valid_key",
"(",
"key",
",",
"sep",
")",
")",
"and",
"isinstance",
"(",
"... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.40/roles/lib_openshift/library/oc_adm_policy_user.py#L330-L352 | |
mit-han-lab/once-for-all | 4f6fce3652ee4553ea811d38f32f90ac8b1bc378 | ofa/utils/layers.py | python | ConvLayer.__init__ | (self, in_channels, out_channels,
kernel_size=3, stride=1, dilation=1, groups=1, bias=False, has_shuffle=False, use_se=False,
use_bn=True, act_func='relu', dropout_rate=0, ops_order='weight_bn_act') | [] | def __init__(self, in_channels, out_channels,
kernel_size=3, stride=1, dilation=1, groups=1, bias=False, has_shuffle=False, use_se=False,
use_bn=True, act_func='relu', dropout_rate=0, ops_order='weight_bn_act'):
# default normal 3x3_Conv with bn and relu
self.kernel_size = kernel_size
... | [
"def",
"__init__",
"(",
"self",
",",
"in_channels",
",",
"out_channels",
",",
"kernel_size",
"=",
"3",
",",
"stride",
"=",
"1",
",",
"dilation",
"=",
"1",
",",
"groups",
"=",
"1",
",",
"bias",
"=",
"False",
",",
"has_shuffle",
"=",
"False",
",",
"use... | https://github.com/mit-han-lab/once-for-all/blob/4f6fce3652ee4553ea811d38f32f90ac8b1bc378/ofa/utils/layers.py#L134-L148 | ||||
gpodder/mygpo | 7a028ad621d05d4ca0d58fd22fb92656c8835e43 | mygpo/web/google.py | python | adsense | (request) | return {"adsense_client": adclient, "adsense_slot_bottom": slot_bottom} | [] | def adsense(request):
adclient = settings.ADSENSE_CLIENT
if not adclient:
return {}
slot_bottom = settings.ADSENSE_SLOT_BOTTOM
if not slot_bottom:
return {}
return {"adsense_client": adclient, "adsense_slot_bottom": slot_bottom} | [
"def",
"adsense",
"(",
"request",
")",
":",
"adclient",
"=",
"settings",
".",
"ADSENSE_CLIENT",
"if",
"not",
"adclient",
":",
"return",
"{",
"}",
"slot_bottom",
"=",
"settings",
".",
"ADSENSE_SLOT_BOTTOM",
"if",
"not",
"slot_bottom",
":",
"return",
"{",
"}",... | https://github.com/gpodder/mygpo/blob/7a028ad621d05d4ca0d58fd22fb92656c8835e43/mygpo/web/google.py#L12-L21 | |||
iclavera/learning_to_adapt | bd7d99ba402521c96631e7d09714128f549db0f1 | learning_to_adapt/mujoco_py/mjtypes.py | python | MjrContextWrapper.texture | (self, value) | [] | def texture(self, value):
val_ptr = np.array(value, dtype=np.float64).ctypes.data_as(POINTER(c_int))
memmove(self._wrapped.contents.texture, val_ptr, 100 * sizeof(c_int)) | [
"def",
"texture",
"(",
"self",
",",
"value",
")",
":",
"val_ptr",
"=",
"np",
".",
"array",
"(",
"value",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
".",
"ctypes",
".",
"data_as",
"(",
"POINTER",
"(",
"c_int",
")",
")",
"memmove",
"(",
"self",
... | https://github.com/iclavera/learning_to_adapt/blob/bd7d99ba402521c96631e7d09714128f549db0f1/learning_to_adapt/mujoco_py/mjtypes.py#L1163-L1165 | ||||
nltk/nltk | 3f74ac55681667d7ef78b664557487145f51eb02 | nltk/metrics/scores.py | python | f_measure | (reference, test, alpha=0.5) | return 1.0 / (alpha / p + (1 - alpha) / r) | Given a set of reference values and a set of test values, return
the f-measure of the test values, when compared against the
reference values. The f-measure is the harmonic mean of the
``precision`` and ``recall``, weighted by ``alpha``. In particular,
given the precision *p* and recall *r* defined by... | Given a set of reference values and a set of test values, return
the f-measure of the test values, when compared against the
reference values. The f-measure is the harmonic mean of the
``precision`` and ``recall``, weighted by ``alpha``. In particular,
given the precision *p* and recall *r* defined by... | [
"Given",
"a",
"set",
"of",
"reference",
"values",
"and",
"a",
"set",
"of",
"test",
"values",
"return",
"the",
"f",
"-",
"measure",
"of",
"the",
"test",
"values",
"when",
"compared",
"against",
"the",
"reference",
"values",
".",
"The",
"f",
"-",
"measure"... | def f_measure(reference, test, alpha=0.5):
"""
Given a set of reference values and a set of test values, return
the f-measure of the test values, when compared against the
reference values. The f-measure is the harmonic mean of the
``precision`` and ``recall``, weighted by ``alpha``. In particular... | [
"def",
"f_measure",
"(",
"reference",
",",
"test",
",",
"alpha",
"=",
"0.5",
")",
":",
"p",
"=",
"precision",
"(",
"reference",
",",
"test",
")",
"r",
"=",
"recall",
"(",
"reference",
",",
"test",
")",
"if",
"p",
"is",
"None",
"or",
"r",
"is",
"N... | https://github.com/nltk/nltk/blob/3f74ac55681667d7ef78b664557487145f51eb02/nltk/metrics/scores.py#L86-L116 | |
numenta/nupic | b9ebedaf54f49a33de22d8d44dff7c765cdb5548 | src/nupic/swarming/utils.py | python | rApply | (d, f) | Recursively applies f to the values in dict d.
Args:
d: The dict to recurse over.
f: A function to apply to values in d that takes the value and a list of
keys from the root of the dict to the value. | Recursively applies f to the values in dict d. | [
"Recursively",
"applies",
"f",
"to",
"the",
"values",
"in",
"dict",
"d",
"."
] | def rApply(d, f):
"""Recursively applies f to the values in dict d.
Args:
d: The dict to recurse over.
f: A function to apply to values in d that takes the value and a list of
keys from the root of the dict to the value.
"""
remainingDicts = [(d, ())]
while len(remainingDicts) > 0:
curren... | [
"def",
"rApply",
"(",
"d",
",",
"f",
")",
":",
"remainingDicts",
"=",
"[",
"(",
"d",
",",
"(",
")",
")",
"]",
"while",
"len",
"(",
"remainingDicts",
")",
">",
"0",
":",
"current",
",",
"prevKeys",
"=",
"remainingDicts",
".",
"pop",
"(",
")",
"for... | https://github.com/numenta/nupic/blob/b9ebedaf54f49a33de22d8d44dff7c765cdb5548/src/nupic/swarming/utils.py#L614-L630 | ||
mlcommons/training | 4a4d5a0b7efe99c680306b1940749211d4238a84 | translation/tensorflow/bert/run_squad.py | python | create_model | (bert_config, is_training, input_ids, input_mask, segment_ids,
use_one_hot_embeddings) | return (start_logits, end_logits) | Creates a classification model. | Creates a classification model. | [
"Creates",
"a",
"classification",
"model",
"."
] | def create_model(bert_config, is_training, input_ids, input_mask, segment_ids,
use_one_hot_embeddings):
"""Creates a classification model."""
model = modeling.BertModel(
config=bert_config,
is_training=is_training,
input_ids=input_ids,
input_mask=input_mask,
token_type... | [
"def",
"create_model",
"(",
"bert_config",
",",
"is_training",
",",
"input_ids",
",",
"input_mask",
",",
"segment_ids",
",",
"use_one_hot_embeddings",
")",
":",
"model",
"=",
"modeling",
".",
"BertModel",
"(",
"config",
"=",
"bert_config",
",",
"is_training",
"=... | https://github.com/mlcommons/training/blob/4a4d5a0b7efe99c680306b1940749211d4238a84/translation/tensorflow/bert/run_squad.py#L550-L587 | |
gluon/AbletonLive9_RemoteScripts | 0c0db5e2e29bbed88c82bf327f54d4968d36937e | LiveControl_2_1_31/random.py | python | WichmannHill.getstate | (self) | return self.VERSION, self._seed, self.gauss_next | Return internal state; can be passed to setstate() later. | Return internal state; can be passed to setstate() later. | [
"Return",
"internal",
"state",
";",
"can",
"be",
"passed",
"to",
"setstate",
"()",
"later",
"."
] | def getstate(self):
"""Return internal state; can be passed to setstate() later."""
return self.VERSION, self._seed, self.gauss_next | [
"def",
"getstate",
"(",
"self",
")",
":",
"return",
"self",
".",
"VERSION",
",",
"self",
".",
"_seed",
",",
"self",
".",
"gauss_next"
] | https://github.com/gluon/AbletonLive9_RemoteScripts/blob/0c0db5e2e29bbed88c82bf327f54d4968d36937e/LiveControl_2_1_31/random.py#L675-L677 | |
mysql/mysql-utilities | 08276b2258bf9739f53406b354b21195ff69a261 | mysql/utilities/common/frm_reader.py | python | FrmReader._read_default_values | (self) | Read the default values for all columns | Read the default values for all columns | [
"Read",
"the",
"default",
"values",
"for",
"all",
"columns"
] | def _read_default_values(self):
"""Read the default values for all columns
"""
offset = self.general_data['IO_SIZE'] + \
self.general_data['tmp_key_length']
try:
# Skip ahead to key section
if self.verbosity > 1:
print "# Skipping to de... | [
"def",
"_read_default_values",
"(",
"self",
")",
":",
"offset",
"=",
"self",
".",
"general_data",
"[",
"'IO_SIZE'",
"]",
"+",
"self",
".",
"general_data",
"[",
"'tmp_key_length'",
"]",
"try",
":",
"# Skip ahead to key section",
"if",
"self",
".",
"verbosity",
... | https://github.com/mysql/mysql-utilities/blob/08276b2258bf9739f53406b354b21195ff69a261/mysql/utilities/common/frm_reader.py#L681-L699 | ||
EasyIME/PIME | 0f1eee10169c1cb2eaa0b59a77fa6f931ecb33b3 | python/python3/tornado/escape.py | python | utf8 | (value: Union[None, str, bytes]) | return value.encode("utf-8") | Converts a string argument to a byte string.
If the argument is already a byte string or None, it is returned unchanged.
Otherwise it must be a unicode string and is encoded as utf8. | Converts a string argument to a byte string. | [
"Converts",
"a",
"string",
"argument",
"to",
"a",
"byte",
"string",
"."
] | def utf8(value: Union[None, str, bytes]) -> Optional[bytes]: # noqa: F811
"""Converts a string argument to a byte string.
If the argument is already a byte string or None, it is returned unchanged.
Otherwise it must be a unicode string and is encoded as utf8.
"""
if isinstance(value, _UTF8_TYPES):... | [
"def",
"utf8",
"(",
"value",
":",
"Union",
"[",
"None",
",",
"str",
",",
"bytes",
"]",
")",
"->",
"Optional",
"[",
"bytes",
"]",
":",
"# noqa: F811",
"if",
"isinstance",
"(",
"value",
",",
"_UTF8_TYPES",
")",
":",
"return",
"value",
"if",
"not",
"isi... | https://github.com/EasyIME/PIME/blob/0f1eee10169c1cb2eaa0b59a77fa6f931ecb33b3/python/python3/tornado/escape.py#L188-L198 | |
JiYou/openstack | 8607dd488bde0905044b303eb6e52bdea6806923 | packages/source/cinder/cinder/api/views/backups.py | python | ViewBuilder.detail | (self, request, backup) | return {
'backup': {
'id': backup.get('id'),
'status': backup.get('status'),
'size': backup.get('size'),
'object_count': backup.get('object_count'),
'availability_zone': backup.get('availability_zone'),
'containe... | Detailed view of a single backup. | Detailed view of a single backup. | [
"Detailed",
"view",
"of",
"a",
"single",
"backup",
"."
] | def detail(self, request, backup):
"""Detailed view of a single backup."""
return {
'backup': {
'id': backup.get('id'),
'status': backup.get('status'),
'size': backup.get('size'),
'object_count': backup.get('object_count'),
... | [
"def",
"detail",
"(",
"self",
",",
"request",
",",
"backup",
")",
":",
"return",
"{",
"'backup'",
":",
"{",
"'id'",
":",
"backup",
".",
"get",
"(",
"'id'",
")",
",",
"'status'",
":",
"backup",
".",
"get",
"(",
"'status'",
")",
",",
"'size'",
":",
... | https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/cinder/cinder/api/views/backups.py#L60-L77 | |
IronLanguages/main | a949455434b1fda8c783289e897e78a9a0caabb5 | External.LCA_RESTRICTED/Languages/CPython/27/Lib/email/utils.py | python | _bdecode | (s) | return base64.decodestring(s) | Decodes a base64 string.
This function is equivalent to base64.decodestring and it's retained only
for backward compatibility. It used to remove the last \n of the decoded
string, if it had any (see issue 7143). | Decodes a base64 string. | [
"Decodes",
"a",
"base64",
"string",
"."
] | def _bdecode(s):
"""Decodes a base64 string.
This function is equivalent to base64.decodestring and it's retained only
for backward compatibility. It used to remove the last \n of the decoded
string, if it had any (see issue 7143).
"""
if not s:
return s
return base64.decodestring(s... | [
"def",
"_bdecode",
"(",
"s",
")",
":",
"if",
"not",
"s",
":",
"return",
"s",
"return",
"base64",
".",
"decodestring",
"(",
"s",
")"
] | https://github.com/IronLanguages/main/blob/a949455434b1fda8c783289e897e78a9a0caabb5/External.LCA_RESTRICTED/Languages/CPython/27/Lib/email/utils.py#L62-L71 | |
mlouielu/twstock | bcd9b022aeb858549992b1251151c741e0c22d80 | twstock/stock.py | python | Stock.fetch_31 | (self) | return self.data | Fetch 31 days data | Fetch 31 days data | [
"Fetch",
"31",
"days",
"data"
] | def fetch_31(self):
"""Fetch 31 days data"""
today = datetime.datetime.today()
before = today - datetime.timedelta(days=60)
self.fetch_from(before.year, before.month)
self.data = self.data[-31:]
return self.data | [
"def",
"fetch_31",
"(",
"self",
")",
":",
"today",
"=",
"datetime",
".",
"datetime",
".",
"today",
"(",
")",
"before",
"=",
"today",
"-",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"60",
")",
"self",
".",
"fetch_from",
"(",
"before",
".",
"year"... | https://github.com/mlouielu/twstock/blob/bcd9b022aeb858549992b1251151c741e0c22d80/twstock/stock.py#L179-L185 | |
RasaHQ/rasa_core | 48cb1cf263044e323691a7b3f5a71d2da0172b38 | rasa/core/domain.py | python | Domain.num_states | (self) | return len(self.input_states) | Number of used input states for the action prediction. | Number of used input states for the action prediction. | [
"Number",
"of",
"used",
"input",
"states",
"for",
"the",
"action",
"prediction",
"."
] | def num_states(self):
"""Number of used input states for the action prediction."""
return len(self.input_states) | [
"def",
"num_states",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"input_states",
")"
] | https://github.com/RasaHQ/rasa_core/blob/48cb1cf263044e323691a7b3f5a71d2da0172b38/rasa/core/domain.py#L304-L307 | |
spacetx/starfish | 0e879d995d5c49b6f5a842e201e3be04c91afc7e | starfish/core/experiment/builder/providers.py | python | TileFetcher.get_tile | (
self, fov_id: int, round_label: int, ch_label: int, zplane_label: int) | Given fov_id, round_label, ch_label, and zplane_label, return an instance of a
:py:class:`.FetchedTile` that can be queried for the image data. | Given fov_id, round_label, ch_label, and zplane_label, return an instance of a
:py:class:`.FetchedTile` that can be queried for the image data. | [
"Given",
"fov_id",
"round_label",
"ch_label",
"and",
"zplane_label",
"return",
"an",
"instance",
"of",
"a",
":",
"py",
":",
"class",
":",
".",
"FetchedTile",
"that",
"can",
"be",
"queried",
"for",
"the",
"image",
"data",
"."
] | def get_tile(
self, fov_id: int, round_label: int, ch_label: int, zplane_label: int) -> FetchedTile:
"""
Given fov_id, round_label, ch_label, and zplane_label, return an instance of a
:py:class:`.FetchedTile` that can be queried for the image data.
"""
raise NotImplem... | [
"def",
"get_tile",
"(",
"self",
",",
"fov_id",
":",
"int",
",",
"round_label",
":",
"int",
",",
"ch_label",
":",
"int",
",",
"zplane_label",
":",
"int",
")",
"->",
"FetchedTile",
":",
"raise",
"NotImplementedError",
"(",
")"
] | https://github.com/spacetx/starfish/blob/0e879d995d5c49b6f5a842e201e3be04c91afc7e/starfish/core/experiment/builder/providers.py#L68-L74 | ||
taomujian/linbing | fe772a58f41e3b046b51a866bdb7e4655abaf51a | python/app/thirdparty/dirsearch/thirdparty/jinja2/runtime.py | python | LoopContext.depth | (self) | return self.depth0 + 1 | How many levels deep a recursive loop currently is, starting at 1. | How many levels deep a recursive loop currently is, starting at 1. | [
"How",
"many",
"levels",
"deep",
"a",
"recursive",
"loop",
"currently",
"is",
"starting",
"at",
"1",
"."
] | def depth(self) -> int:
"""How many levels deep a recursive loop currently is, starting at 1."""
return self.depth0 + 1 | [
"def",
"depth",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"depth0",
"+",
"1"
] | https://github.com/taomujian/linbing/blob/fe772a58f41e3b046b51a866bdb7e4655abaf51a/python/app/thirdparty/dirsearch/thirdparty/jinja2/runtime.py#L501-L503 | |
moinwiki/moin | 568f223231aadecbd3b21a701ec02271f8d8021d | src/moin/storage/backends/stores.py | python | Backend.__init__ | (self, meta_store, data_store) | :param meta_store: a ByteStore for metadata
:param data_store: a FileStore for data | :param meta_store: a ByteStore for metadata
:param data_store: a FileStore for data | [
":",
"param",
"meta_store",
":",
"a",
"ByteStore",
"for",
"metadata",
":",
"param",
"data_store",
":",
"a",
"FileStore",
"for",
"data"
] | def __init__(self, meta_store, data_store):
"""
:param meta_store: a ByteStore for metadata
:param data_store: a FileStore for data
"""
self.meta_store = meta_store
self.data_store = data_store | [
"def",
"__init__",
"(",
"self",
",",
"meta_store",
",",
"data_store",
")",
":",
"self",
".",
"meta_store",
"=",
"meta_store",
"self",
".",
"data_store",
"=",
"data_store"
] | https://github.com/moinwiki/moin/blob/568f223231aadecbd3b21a701ec02271f8d8021d/src/moin/storage/backends/stores.py#L47-L53 | ||
openstack/python-neutronclient | 517bef2c5454dde2eba5cc2194ee857be6be7164 | neutronclient/client.py | python | HTTPClient.request | (self, url, method, body=None, headers=None, **kwargs) | return resp, resp.text | Request without authentication. | Request without authentication. | [
"Request",
"without",
"authentication",
"."
] | def request(self, url, method, body=None, headers=None, **kwargs):
"""Request without authentication."""
content_type = kwargs.pop('content_type', None) or 'application/json'
headers = headers or {}
headers.setdefault('Accept', content_type)
if body:
headers.setdefa... | [
"def",
"request",
"(",
"self",
",",
"url",
",",
"method",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"content_type",
"=",
"kwargs",
".",
"pop",
"(",
"'content_type'",
",",
"None",
")",
"or",
"'applicatio... | https://github.com/openstack/python-neutronclient/blob/517bef2c5454dde2eba5cc2194ee857be6be7164/neutronclient/client.py#L146-L175 | |
tflearn/tflearn | db5176773299b67a2a75c5889fb2aba7fd0fea8a | tflearn/data_preprocessing.py | python | ImagePreprocessing._compute_global_std | (self, dataset, session, limit=None) | return std | Compute std of a dataset. A limit can be specified for faster
computation, considering only 'limit' first elements. | Compute std of a dataset. A limit can be specified for faster
computation, considering only 'limit' first elements. | [
"Compute",
"std",
"of",
"a",
"dataset",
".",
"A",
"limit",
"can",
"be",
"specified",
"for",
"faster",
"computation",
"considering",
"only",
"limit",
"first",
"elements",
"."
] | def _compute_global_std(self, dataset, session, limit=None):
""" Compute std of a dataset. A limit can be specified for faster
computation, considering only 'limit' first elements. """
_dataset = dataset
std = 0.
if isinstance(limit, int):
_dataset = _dataset[:limit]
... | [
"def",
"_compute_global_std",
"(",
"self",
",",
"dataset",
",",
"session",
",",
"limit",
"=",
"None",
")",
":",
"_dataset",
"=",
"dataset",
"std",
"=",
"0.",
"if",
"isinstance",
"(",
"limit",
",",
"int",
")",
":",
"_dataset",
"=",
"_dataset",
"[",
":",... | https://github.com/tflearn/tflearn/blob/db5176773299b67a2a75c5889fb2aba7fd0fea8a/tflearn/data_preprocessing.py#L511-L528 | |
axcore/tartube | 36dd493642923fe8b9190a41db596c30c043ae90 | tartube/config.py | python | CustomDLEditWin.setup_mirrors_tab | (self) | Called by self.setup_tabs().
Sets up the 'Mirrors' tab. | Called by self.setup_tabs(). | [
"Called",
"by",
"self",
".",
"setup_tabs",
"()",
"."
] | def setup_mirrors_tab(self):
"""Called by self.setup_tabs().
Sets up the 'Mirrors' tab.
"""
tab, grid = self.add_notebook_tab(_('Mirrors'))
grid_width = 2
# Mirror settings
self.add_label(grid,
'<u>' + _('Mirror settings') + '</u>',
0, ... | [
"def",
"setup_mirrors_tab",
"(",
"self",
")",
":",
"tab",
",",
"grid",
"=",
"self",
".",
"add_notebook_tab",
"(",
"_",
"(",
"'Mirrors'",
")",
")",
"grid_width",
"=",
"2",
"# Mirror settings",
"self",
".",
"add_label",
"(",
"grid",
",",
"'<u>'",
"+",
"_",... | https://github.com/axcore/tartube/blob/36dd493642923fe8b9190a41db596c30c043ae90/tartube/config.py#L3223-L3317 | ||
nosmokingbandit/Watcher3 | 0217e75158b563bdefc8e01c3be7620008cf3977 | lib/cherrypy/lib/jsontools.py | python | json_in | (content_type=[ntou('application/json'), ntou('text/javascript')],
force=True, debug=False, processor=json_processor) | Add a processor to parse JSON request entities:
The default processor places the parsed data into request.json.
Incoming request entities which match the given content_type(s) will
be deserialized from JSON to the Python equivalent, and the result
stored at cherrypy.request.json. The 'content_type' arg... | Add a processor to parse JSON request entities:
The default processor places the parsed data into request.json. | [
"Add",
"a",
"processor",
"to",
"parse",
"JSON",
"request",
"entities",
":",
"The",
"default",
"processor",
"places",
"the",
"parsed",
"data",
"into",
"request",
".",
"json",
"."
] | def json_in(content_type=[ntou('application/json'), ntou('text/javascript')],
force=True, debug=False, processor=json_processor):
"""Add a processor to parse JSON request entities:
The default processor places the parsed data into request.json.
Incoming request entities which match the given co... | [
"def",
"json_in",
"(",
"content_type",
"=",
"[",
"ntou",
"(",
"'application/json'",
")",
",",
"ntou",
"(",
"'text/javascript'",
")",
"]",
",",
"force",
"=",
"True",
",",
"debug",
"=",
"False",
",",
"processor",
"=",
"json_processor",
")",
":",
"request",
... | https://github.com/nosmokingbandit/Watcher3/blob/0217e75158b563bdefc8e01c3be7620008cf3977/lib/cherrypy/lib/jsontools.py#L15-L57 | ||
diamond-org/flask-diamond | bb1c1f64f18a0c9af6ff1d245b0bf22aa206d0c3 | flask_diamond/mixins/marshmallow.py | python | MarshmallowMixin.dump | (self) | return self.__schema__().dump(self).data | serialize the Model object as a python object | serialize the Model object as a python object | [
"serialize",
"the",
"Model",
"object",
"as",
"a",
"python",
"object"
] | def dump(self):
"serialize the Model object as a python object"
return self.__schema__().dump(self).data | [
"def",
"dump",
"(",
"self",
")",
":",
"return",
"self",
".",
"__schema__",
"(",
")",
".",
"dump",
"(",
"self",
")",
".",
"data"
] | https://github.com/diamond-org/flask-diamond/blob/bb1c1f64f18a0c9af6ff1d245b0bf22aa206d0c3/flask_diamond/mixins/marshmallow.py#L11-L13 | |
tendenci/tendenci | 0f2c348cc0e7d41bc56f50b00ce05544b083bf1d | tendenci/apps/base/views.py | python | timeout_test | (request) | [] | def timeout_test(request):
# Sleep for 60 seconds to simulate a long process time
time.sleep(60)
raise Http404 | [
"def",
"timeout_test",
"(",
"request",
")",
":",
"# Sleep for 60 seconds to simulate a long process time",
"time",
".",
"sleep",
"(",
"60",
")",
"raise",
"Http404"
] | https://github.com/tendenci/tendenci/blob/0f2c348cc0e7d41bc56f50b00ce05544b083bf1d/tendenci/apps/base/views.py#L315-L318 | ||||
CJWorkbench/cjworkbench | e0b878d8ff819817fa049a4126efcbfcec0b50e6 | cjwstate/models/module_registry.py | python | ModuleRegistry._download_or_reuse_zipfile | (self, db_module: DbModuleVersion) | Ensure `self._cache` contains a `ModuleZipfile` for `db_module`, and return it.
Raise `KeyError` if the module does not exist in s3. | Ensure `self._cache` contains a `ModuleZipfile` for `db_module`, and return it. | [
"Ensure",
"self",
".",
"_cache",
"contains",
"a",
"ModuleZipfile",
"for",
"db_module",
"and",
"return",
"it",
"."
] | def _download_or_reuse_zipfile(self, db_module: DbModuleVersion) -> ModuleZipfile:
"""Ensure `self._cache` contains a `ModuleZipfile` for `db_module`, and return it.
Raise `KeyError` if the module does not exist in s3.
"""
module_id = db_module.id_name
version = ModuleVersion(db... | [
"def",
"_download_or_reuse_zipfile",
"(",
"self",
",",
"db_module",
":",
"DbModuleVersion",
")",
"->",
"ModuleZipfile",
":",
"module_id",
"=",
"db_module",
".",
"id_name",
"version",
"=",
"ModuleVersion",
"(",
"db_module",
".",
"source_version_hash",
")",
"# 1. Get ... | https://github.com/CJWorkbench/cjworkbench/blob/e0b878d8ff819817fa049a4126efcbfcec0b50e6/cjwstate/models/module_registry.py#L83-L130 | ||
magenta/magenta | be6558f1a06984faff6d6949234f5fe9ad0ffdb5 | magenta/models/svg_vae/svg_utils.py | python | make_simple_cmds_long | (out) | return np.concatenate([out[..., :1],
np.zeros(shape_minus_dim + [3]),
out[..., 1:3],
np.zeros(shape_minus_dim + [3]),
out[..., 3:4],
np.zeros(shape_minus_dim + [14]),
out... | Converts svg decoder output to format required by some render functions. | Converts svg decoder output to format required by some render functions. | [
"Converts",
"svg",
"decoder",
"output",
"to",
"format",
"required",
"by",
"some",
"render",
"functions",
"."
] | def make_simple_cmds_long(out):
"""Converts svg decoder output to format required by some render functions."""
# out has 10 dims
# the first 4 are respectively dims 0, 4, 5, 9 of the full 20-dim onehot vec
# the latter 6 are the 6 last dims of the 10-dim arg vec
shape_minus_dim = list(np.shape(out))[:-1]
re... | [
"def",
"make_simple_cmds_long",
"(",
"out",
")",
":",
"# out has 10 dims",
"# the first 4 are respectively dims 0, 4, 5, 9 of the full 20-dim onehot vec",
"# the latter 6 are the 6 last dims of the 10-dim arg vec",
"shape_minus_dim",
"=",
"list",
"(",
"np",
".",
"shape",
"(",
"out"... | https://github.com/magenta/magenta/blob/be6558f1a06984faff6d6949234f5fe9ad0ffdb5/magenta/models/svg_vae/svg_utils.py#L581-L593 | |
openstack/manila | 142990edc027e14839d5deaf4954dd6fc88de15e | manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py | python | NetAppCmodeMultiSVMFileStorageLibrary.manage_server | (self, context, share_server, identifier, driver_options) | return new_vserver_name, backend_details | Manages a vserver by renaming it and returning backend_details. | Manages a vserver by renaming it and returning backend_details. | [
"Manages",
"a",
"vserver",
"by",
"renaming",
"it",
"and",
"returning",
"backend_details",
"."
] | def manage_server(self, context, share_server, identifier, driver_options):
"""Manages a vserver by renaming it and returning backend_details."""
new_vserver_name = self._get_vserver_name(share_server['id'])
old_vserver_name = self._get_correct_vserver_old_name(identifier)
if new_vserver... | [
"def",
"manage_server",
"(",
"self",
",",
"context",
",",
"share_server",
",",
"identifier",
",",
"driver_options",
")",
":",
"new_vserver_name",
"=",
"self",
".",
"_get_vserver_name",
"(",
"share_server",
"[",
"'id'",
"]",
")",
"old_vserver_name",
"=",
"self",
... | https://github.com/openstack/manila/blob/142990edc027e14839d5deaf4954dd6fc88de15e/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py#L630-L647 | |
chribsen/simple-machine-learning-examples | dc94e52a4cebdc8bb959ff88b81ff8cfeca25022 | venv/lib/python2.7/site-packages/scipy/integrate/quadpack.py | python | _OptFunc.__call__ | (self, *args) | return self.opt | Return stored dict. | Return stored dict. | [
"Return",
"stored",
"dict",
"."
] | def __call__(self, *args):
"""Return stored dict."""
return self.opt | [
"def",
"__call__",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"self",
".",
"opt"
] | https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/scipy/integrate/quadpack.py#L727-L729 | |
Defense-Cyber-Crime-Center/DC3-MWCP | 92f4be12e73d60673a5e9fa59694e75cc27b4edf | mwcp/resources/techanarchy_bridge.py | python | map_ta_jar_fields | (data, reporter) | This routine is for the unrecom family | This routine is for the unrecom family | [
"This",
"routine",
"is",
"for",
"the",
"unrecom",
"family"
] | def map_ta_jar_fields(data, reporter):
"""This routine is for the unrecom family"""
jarinfo = ''
mwcpkey = ''
if 'jarfoldername' in data:
jarinfo = data['jarfoldername']
mwcpkey = 'directory'
if 'jarname' in data:
# if a directory is added put in the \\
if jarinfo:
... | [
"def",
"map_ta_jar_fields",
"(",
"data",
",",
"reporter",
")",
":",
"jarinfo",
"=",
"''",
"mwcpkey",
"=",
"''",
"if",
"'jarfoldername'",
"in",
"data",
":",
"jarinfo",
"=",
"data",
"[",
"'jarfoldername'",
"]",
"mwcpkey",
"=",
"'directory'",
"if",
"'jarname'",... | https://github.com/Defense-Cyber-Crime-Center/DC3-MWCP/blob/92f4be12e73d60673a5e9fa59694e75cc27b4edf/mwcp/resources/techanarchy_bridge.py#L288-L305 | ||
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/docutils/utils/math/math2html.py | python | Bracket.parsebit | (self, pos) | return self | Parse the bracket | Parse the bracket | [
"Parse",
"the",
"bracket"
] | def parsebit(self, pos):
"Parse the bracket"
self.parsecomplete(pos, self.innerformula)
return self | [
"def",
"parsebit",
"(",
"self",
",",
"pos",
")",
":",
"self",
".",
"parsecomplete",
"(",
"pos",
",",
"self",
".",
"innerformula",
")",
"return",
"self"
] | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/docutils/utils/math/math2html.py#L2769-L2772 | |
lsbardel/python-stdnet | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | docs/source/_ext/sphinxtogithub.py | python | LayoutFactory.is_underscore_dir | (self, path, directory) | return (self.dir_helper.is_dir(self.file_helper.path_join(path, directory))
and directory.startswith("_")) | [] | def is_underscore_dir(self, path, directory):
return (self.dir_helper.is_dir(self.file_helper.path_join(path, directory))
and directory.startswith("_")) | [
"def",
"is_underscore_dir",
"(",
"self",
",",
"path",
",",
"directory",
")",
":",
"return",
"(",
"self",
".",
"dir_helper",
".",
"is_dir",
"(",
"self",
".",
"file_helper",
".",
"path_join",
"(",
"path",
",",
"directory",
")",
")",
"and",
"directory",
"."... | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/docs/source/_ext/sphinxtogithub.py#L235-L238 | |||
openstack/cinder | 23494a6d6c51451688191e1847a458f1d3cdcaa5 | cinder/volume/drivers/sandstone/sds_client.py | python | RestCmd.create_lun_from_snapshot | (self, snapshot_name, src_volume_name,
poolid, dst_volume_name) | Create lun from source lun snapshot. | Create lun from source lun snapshot. | [
"Create",
"lun",
"from",
"source",
"lun",
"snapshot",
"."
] | def create_lun_from_snapshot(self, snapshot_name, src_volume_name,
poolid, dst_volume_name):
"""Create lun from source lun snapshot."""
url = 'resource/snapshot/clone'
data = {"snapshot": {"poolId": poolid,
"lunName": src_volume_name,... | [
"def",
"create_lun_from_snapshot",
"(",
"self",
",",
"snapshot_name",
",",
"src_volume_name",
",",
"poolid",
",",
"dst_volume_name",
")",
":",
"url",
"=",
"'resource/snapshot/clone'",
"data",
"=",
"{",
"\"snapshot\"",
":",
"{",
"\"poolId\"",
":",
"poolid",
",",
... | https://github.com/openstack/cinder/blob/23494a6d6c51451688191e1847a458f1d3cdcaa5/cinder/volume/drivers/sandstone/sds_client.py#L616-L635 | ||
ladybug-tools/honeybee-legacy | bd62af4862fe022801fb87dbc8794fdf1dff73a9 | src/Honeybee_Export To OpenStudio.py | python | WriteOPS.setSizingForRecirc | (self, airloop) | [] | def setSizingForRecirc(self, airloop):
# set the sizing on the system to not use 100% outdoor air
sizingSystem = airloop.sizingSystem()
sizingSystem.setAllOutdoorAirinCooling(False)
sizingSystem.setAllOutdoorAirinHeating(False) | [
"def",
"setSizingForRecirc",
"(",
"self",
",",
"airloop",
")",
":",
"# set the sizing on the system to not use 100% outdoor air",
"sizingSystem",
"=",
"airloop",
".",
"sizingSystem",
"(",
")",
"sizingSystem",
".",
"setAllOutdoorAirinCooling",
"(",
"False",
")",
"sizingSys... | https://github.com/ladybug-tools/honeybee-legacy/blob/bd62af4862fe022801fb87dbc8794fdf1dff73a9/src/Honeybee_Export To OpenStudio.py#L2284-L2288 | ||||
skylander86/lambda-text-extractor | 6da52d077a2fc571e38bfe29c33ae68f6443cd5a | lib-linux_x64/pptx/opc/package.py | python | OpcPackage.main_document_part | (self) | return self.part_related_by(RT.OFFICE_DOCUMENT) | Return a reference to the main document part for this package.
Examples include a document part for a WordprocessingML package, a
presentation part for a PresentationML package, or a workbook part
for a SpreadsheetML package. | Return a reference to the main document part for this package.
Examples include a document part for a WordprocessingML package, a
presentation part for a PresentationML package, or a workbook part
for a SpreadsheetML package. | [
"Return",
"a",
"reference",
"to",
"the",
"main",
"document",
"part",
"for",
"this",
"package",
".",
"Examples",
"include",
"a",
"document",
"part",
"for",
"a",
"WordprocessingML",
"package",
"a",
"presentation",
"part",
"for",
"a",
"PresentationML",
"package",
... | def main_document_part(self):
"""
Return a reference to the main document part for this package.
Examples include a document part for a WordprocessingML package, a
presentation part for a PresentationML package, or a workbook part
for a SpreadsheetML package.
"""
... | [
"def",
"main_document_part",
"(",
"self",
")",
":",
"return",
"self",
".",
"part_related_by",
"(",
"RT",
".",
"OFFICE_DOCUMENT",
")"
] | https://github.com/skylander86/lambda-text-extractor/blob/6da52d077a2fc571e38bfe29c33ae68f6443cd5a/lib-linux_x64/pptx/opc/package.py#L93-L100 | |
fedden/poker_ai | 73fb394b26623c897459ffa3e66d7a5cb47e9962 | poker_ai/poker/player.py | python | Player.n_bet_chips | (self) | return self.pot[self] | Returns the n_chips this player has bet so far. | Returns the n_chips this player has bet so far. | [
"Returns",
"the",
"n_chips",
"this",
"player",
"has",
"bet",
"so",
"far",
"."
] | def n_bet_chips(self) -> int:
"""Returns the n_chips this player has bet so far."""
return self.pot[self] | [
"def",
"n_bet_chips",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"pot",
"[",
"self",
"]"
] | https://github.com/fedden/poker_ai/blob/73fb394b26623c897459ffa3e66d7a5cb47e9962/poker_ai/poker/player.py#L129-L131 | |
windelbouwman/ppci | 915c069e0667042c085ec42c78e9e3c9a5295324 | ppci/graph/digraph.py | python | dfs | (start_node, reverse=False) | Visit nodes in depth-first-search order.
Args:
- start_node: node to start with
- reverse: traverse the graph by reversing the edge directions. | Visit nodes in depth-first-search order. | [
"Visit",
"nodes",
"in",
"depth",
"-",
"first",
"-",
"search",
"order",
"."
] | def dfs(start_node, reverse=False):
"""Visit nodes in depth-first-search order.
Args:
- start_node: node to start with
- reverse: traverse the graph by reversing the edge directions.
"""
visited = set()
worklist = [(None, start_node)]
while worklist:
parent, node = workl... | [
"def",
"dfs",
"(",
"start_node",
",",
"reverse",
"=",
"False",
")",
":",
"visited",
"=",
"set",
"(",
")",
"worklist",
"=",
"[",
"(",
"None",
",",
"start_node",
")",
"]",
"while",
"worklist",
":",
"parent",
",",
"node",
"=",
"worklist",
".",
"pop",
... | https://github.com/windelbouwman/ppci/blob/915c069e0667042c085ec42c78e9e3c9a5295324/ppci/graph/digraph.py#L84-L103 | ||
stanfordroboticsclub/StanfordQuadruped | 62277f64dc4d1b293feddc8ecd0986d144f656d6 | woofer/Kinematics.py | python | four_legs_inverse_kinematics | (r_body_foot, config) | return alpha | Find the joint angles for all twelve DOF correspoinding to the given matrix of body-relative foot positions.
Parameters
----------
r_body_foot : numpy array (3,4)
Matrix of the body-frame foot positions. Each column corresponds to a separate foot.
config : Config object
Object of robot c... | Find the joint angles for all twelve DOF correspoinding to the given matrix of body-relative foot positions.
Parameters
----------
r_body_foot : numpy array (3,4)
Matrix of the body-frame foot positions. Each column corresponds to a separate foot.
config : Config object
Object of robot c... | [
"Find",
"the",
"joint",
"angles",
"for",
"all",
"twelve",
"DOF",
"correspoinding",
"to",
"the",
"given",
"matrix",
"of",
"body",
"-",
"relative",
"foot",
"positions",
".",
"Parameters",
"----------",
"r_body_foot",
":",
"numpy",
"array",
"(",
"3",
"4",
")",
... | def four_legs_inverse_kinematics(r_body_foot, config):
"""Find the joint angles for all twelve DOF correspoinding to the given matrix of body-relative foot positions.
Parameters
----------
r_body_foot : numpy array (3,4)
Matrix of the body-frame foot positions. Each column corresponds to a separ... | [
"def",
"four_legs_inverse_kinematics",
"(",
"r_body_foot",
",",
"config",
")",
":",
"alpha",
"=",
"np",
".",
"zeros",
"(",
"(",
"3",
",",
"4",
")",
")",
"for",
"i",
"in",
"range",
"(",
"4",
")",
":",
"body_offset",
"=",
"config",
".",
"LEG_ORIGINS",
... | https://github.com/stanfordroboticsclub/StanfordQuadruped/blob/62277f64dc4d1b293feddc8ecd0986d144f656d6/woofer/Kinematics.py#L79-L98 | |
weechat/scripts | 99ec0e7eceefabb9efb0f11ec26d45d6e8e84335 | python/dcc_antispam.py | python | dcc_is_blocked | (dcc) | return False | Return True if dcc is blocked, False if dcc is not blocked. | Return True if dcc is blocked, False if dcc is not blocked. | [
"Return",
"True",
"if",
"dcc",
"is",
"blocked",
"False",
"if",
"dcc",
"is",
"not",
"blocked",
"."
] | def dcc_is_blocked(dcc):
""" Return True if dcc is blocked, False if dcc is not blocked. """
global dcc_settings_regex
for key, value in dcc.items():
if key in dcc_settings_regex:
if weechat.config_get_plugin(key) != "":
for regex in dcc_settings_regex[key]:
... | [
"def",
"dcc_is_blocked",
"(",
"dcc",
")",
":",
"global",
"dcc_settings_regex",
"for",
"key",
",",
"value",
"in",
"dcc",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"dcc_settings_regex",
":",
"if",
"weechat",
".",
"config_get_plugin",
"(",
"key",
")",
... | https://github.com/weechat/scripts/blob/99ec0e7eceefabb9efb0f11ec26d45d6e8e84335/python/dcc_antispam.py#L74-L88 | |
SecurityInnovation/PGPy | 955d1669472b7b182571f686ee312435f93033e4 | pgpy/pgp.py | python | PGPKey.revoke | (self, target, **prefs) | return self._sign(target, sig, **prefs) | Revoke a key, a subkey, or all current certification signatures of a User ID that were generated by this key so far.
:param target: The key to revoke
:type target: :py:obj:`PGPKey`, :py:obj:`PGPUID`
:raises: :py:exc:`~pgpy.errors.PGPError` if the key is passphrase-protected and has not been unl... | Revoke a key, a subkey, or all current certification signatures of a User ID that were generated by this key so far. | [
"Revoke",
"a",
"key",
"a",
"subkey",
"or",
"all",
"current",
"certification",
"signatures",
"of",
"a",
"User",
"ID",
"that",
"were",
"generated",
"by",
"this",
"key",
"so",
"far",
"."
] | def revoke(self, target, **prefs):
"""
Revoke a key, a subkey, or all current certification signatures of a User ID that were generated by this key so far.
:param target: The key to revoke
:type target: :py:obj:`PGPKey`, :py:obj:`PGPUID`
:raises: :py:exc:`~pgpy.errors.PGPError` ... | [
"def",
"revoke",
"(",
"self",
",",
"target",
",",
"*",
"*",
"prefs",
")",
":",
"hash_algo",
"=",
"prefs",
".",
"pop",
"(",
"'hash'",
",",
"None",
")",
"if",
"isinstance",
"(",
"target",
",",
"PGPUID",
")",
":",
"sig_type",
"=",
"SignatureType",
".",
... | https://github.com/SecurityInnovation/PGPy/blob/955d1669472b7b182571f686ee312435f93033e4/pgpy/pgp.py#L2208-L2251 | |
datacenter/acitoolkit | 629b84887dd0f0183b81efc8adb16817f985541a | acitoolkit/acisession.py | python | Session._send_login | (self, timeout=None) | return ret | Send the actual login request to the APIC and open the web
socket interface. | Send the actual login request to the APIC and open the web
socket interface. | [
"Send",
"the",
"actual",
"login",
"request",
"to",
"the",
"APIC",
"and",
"open",
"the",
"web",
"socket",
"interface",
"."
] | def _send_login(self, timeout=None):
"""
Send the actual login request to the APIC and open the web
socket interface.
"""
if not self.verify_ssl:
try:
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
except (AttributeError... | [
"def",
"_send_login",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"verify_ssl",
":",
"try",
":",
"requests",
".",
"packages",
".",
"urllib3",
".",
"disable_warnings",
"(",
"InsecureRequestWarning",
")",
"except",
"(",
"Att... | https://github.com/datacenter/acitoolkit/blob/629b84887dd0f0183b81efc8adb16817f985541a/acitoolkit/acisession.py#L620-L664 | |
paylogic/py2deb | 28e671231c2dcf7dc7b4963ed75d8cbe4a8778e9 | py2deb/package.py | python | PackageToConvert.__init__ | (self, converter, requirement) | Initialize a package to convert.
:param converter: The :class:`.PackageConverter` that holds the user
options and knows how to transform package names.
:param requirement: A :class:`pip_accel.req.Requirement` object
(created by :func:`~py2deb.conver... | Initialize a package to convert. | [
"Initialize",
"a",
"package",
"to",
"convert",
"."
] | def __init__(self, converter, requirement):
"""
Initialize a package to convert.
:param converter: The :class:`.PackageConverter` that holds the user
options and knows how to transform package names.
:param requirement: A :class:`pip_accel.req.Requirement` obje... | [
"def",
"__init__",
"(",
"self",
",",
"converter",
",",
"requirement",
")",
":",
"self",
".",
"converter",
"=",
"converter",
"self",
".",
"requirement",
"=",
"requirement"
] | https://github.com/paylogic/py2deb/blob/28e671231c2dcf7dc7b4963ed75d8cbe4a8778e9/py2deb/package.py#L70-L80 | ||
jodal/pyspotify | 770aee08de274951b63e60bdd8835188b58e7862 | spotify/config.py | python | Config.dont_save_metadata_for_playlists | (self) | return bool(self._sp_session_config.dont_save_metadata_for_playlists) | Don't save metadata for local copies of playlists.
Defaults to :class:`False`.
Reduces disk space usage at the expense of needing to request metadata
from Spotify backend when loading list. | Don't save metadata for local copies of playlists. | [
"Don",
"t",
"save",
"metadata",
"for",
"local",
"copies",
"of",
"playlists",
"."
] | def dont_save_metadata_for_playlists(self):
"""Don't save metadata for local copies of playlists.
Defaults to :class:`False`.
Reduces disk space usage at the expense of needing to request metadata
from Spotify backend when loading list.
"""
return bool(self._sp_session_... | [
"def",
"dont_save_metadata_for_playlists",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"_sp_session_config",
".",
"dont_save_metadata_for_playlists",
")"
] | https://github.com/jodal/pyspotify/blob/770aee08de274951b63e60bdd8835188b58e7862/spotify/config.py#L160-L168 | |
ifwe/digsby | f5fe00244744aa131e07f09348d10563f3d8fa99 | digsby/lib/pyxmpp/jabber/muc.py | python | MucRoomState.request_instant_room | (self) | return self.configure_room(form) | Request an "instant room" -- the default configuration for a MUC room.
:return: id of the request stanza.
:returntype: `unicode` | Request an "instant room" -- the default configuration for a MUC room. | [
"Request",
"an",
"instant",
"room",
"--",
"the",
"default",
"configuration",
"for",
"a",
"MUC",
"room",
"."
] | def request_instant_room(self):
"""
Request an "instant room" -- the default configuration for a MUC room.
:return: id of the request stanza.
:returntype: `unicode`
"""
if self.configured:
raise RuntimeError, "Instant room may be requested for unconfigured ro... | [
"def",
"request_instant_room",
"(",
"self",
")",
":",
"if",
"self",
".",
"configured",
":",
"raise",
"RuntimeError",
",",
"\"Instant room may be requested for unconfigured room only\"",
"form",
"=",
"Form",
"(",
"\"submit\"",
")",
"return",
"self",
".",
"configure_roo... | https://github.com/ifwe/digsby/blob/f5fe00244744aa131e07f09348d10563f3d8fa99/digsby/lib/pyxmpp/jabber/muc.py#L782-L792 | |
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/Python-2.7.9/Tools/bgen/bgen/bgenType.py | python | FakeType.getArgDeclarations | (self, name, reference=False, constmode=False, outmode=False) | return [] | [] | def getArgDeclarations(self, name, reference=False, constmode=False, outmode=False):
return [] | [
"def",
"getArgDeclarations",
"(",
"self",
",",
"name",
",",
"reference",
"=",
"False",
",",
"constmode",
"=",
"False",
",",
"outmode",
"=",
"False",
")",
":",
"return",
"[",
"]"
] | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Tools/bgen/bgen/bgenType.py#L220-L221 | |||
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/sympy/sympy/core/basic.py | python | Basic._has | (self, pattern) | Helper for .has() | Helper for .has() | [
"Helper",
"for",
".",
"has",
"()"
] | def _has(self, pattern):
"""Helper for .has()"""
from sympy.core.function import UndefinedFunction, Function
if isinstance(pattern, UndefinedFunction):
return any(f.func == pattern or f == pattern
for f in self.atoms(Function, UndefinedFunction))
pattern = sympif... | [
"def",
"_has",
"(",
"self",
",",
"pattern",
")",
":",
"from",
"sympy",
".",
"core",
".",
"function",
"import",
"UndefinedFunction",
",",
"Function",
"if",
"isinstance",
"(",
"pattern",
",",
"UndefinedFunction",
")",
":",
"return",
"any",
"(",
"f",
".",
"... | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/core/basic.py#L1150-L1166 | ||
IndicoDataSolutions/Passage | af6e100804dfe332c88bd2cd192e93a807377887 | passage/theano_utils.py | python | sharedX | (X, dtype=theano.config.floatX, name=None) | return theano.shared(np.asarray(X, dtype=dtype), name=name) | [] | def sharedX(X, dtype=theano.config.floatX, name=None):
return theano.shared(np.asarray(X, dtype=dtype), name=name) | [
"def",
"sharedX",
"(",
"X",
",",
"dtype",
"=",
"theano",
".",
"config",
".",
"floatX",
",",
"name",
"=",
"None",
")",
":",
"return",
"theano",
".",
"shared",
"(",
"np",
".",
"asarray",
"(",
"X",
",",
"dtype",
"=",
"dtype",
")",
",",
"name",
"=",
... | https://github.com/IndicoDataSolutions/Passage/blob/af6e100804dfe332c88bd2cd192e93a807377887/passage/theano_utils.py#L10-L11 | |||
ilius/pyglossary | d599b3beda3ae17642af5debd83bb991148e6425 | pyglossary/ui/ui_cmd_interactive.py | python | UI.__init__ | (self) | [] | def __init__(self):
self._inputFilename = ""
self._outputFilename = ""
self._inputFormat = ""
self._outputFormat = ""
self.config = None
self._readOptions = None
self._writeOptions = None
self._convertOptions = None
ui_cmd.UI.__init__(self)
self.ls_parser = argparse.ArgumentParser(add_help=False)
... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_inputFilename",
"=",
"\"\"",
"self",
".",
"_outputFilename",
"=",
"\"\"",
"self",
".",
"_inputFormat",
"=",
"\"\"",
"self",
".",
"_outputFormat",
"=",
"\"\"",
"self",
".",
"config",
"=",
"None",
"s... | https://github.com/ilius/pyglossary/blob/d599b3beda3ae17642af5debd83bb991148e6425/pyglossary/ui/ui_cmd_interactive.py#L262-L313 | ||||
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra.py | python | FiniteDimensionalAlgebra._coerce_map_from_ | (self, S) | return S == self or (self.base_ring().has_coerce_map_from(S) and self.is_unitary()) | TESTS::
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
sage: A.has_coerce_map_from(ZZ)
True
sage: A.has_coerce_map_from(GF(3))
True
sage: A.has_coerce_map_from(GF(5))
False
s... | TESTS:: | [
"TESTS",
"::"
] | def _coerce_map_from_(self, S):
"""
TESTS::
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
sage: A.has_coerce_map_from(ZZ)
True
sage: A.has_coerce_map_from(GF(3))
True
sage: A.has_co... | [
"def",
"_coerce_map_from_",
"(",
"self",
",",
"S",
")",
":",
"return",
"S",
"==",
"self",
"or",
"(",
"self",
".",
"base_ring",
"(",
")",
".",
"has_coerce_map_from",
"(",
"S",
")",
"and",
"self",
".",
"is_unitary",
"(",
")",
")"
] | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra.py#L196-L210 | |
seanbell/opensurfaces | 7f3e987560faa62cd37f821760683ccd1e053c7c | server/mturk/views/external.py | python | external_task | (request, experiment_id, hit=None, override=None) | Renders a MTurk task, both preview and instructions.
override: either None, "inst", "task", or "tut" | Renders a MTurk task, both preview and instructions.
override: either None, "inst", "task", or "tut" | [
"Renders",
"a",
"MTurk",
"task",
"both",
"preview",
"and",
"instructions",
".",
"override",
":",
"either",
"None",
"inst",
"task",
"or",
"tut"
] | def external_task(request, experiment_id, hit=None, override=None):
"""
Renders a MTurk task, both preview and instructions.
override: either None, "inst", "task", or "tut"
"""
# override is only for staff members
#if not request.user.is_staff:
#override = None
# browser check
... | [
"def",
"external_task",
"(",
"request",
",",
"experiment_id",
",",
"hit",
"=",
"None",
",",
"override",
"=",
"None",
")",
":",
"# override is only for staff members",
"#if not request.user.is_staff:",
"#override = None",
"# browser check",
"response",
"=",
"external_task_... | https://github.com/seanbell/opensurfaces/blob/7f3e987560faa62cd37f821760683ccd1e053c7c/server/mturk/views/external.py#L81-L114 | ||
lisa-lab/pylearn2 | af81e5c362f0df4df85c3e54e23b2adeec026055 | pylearn2/space/__init__.py | python | Space._check_is_symbolic | (batch) | .. todo::
WRITEME | .. todo:: | [
"..",
"todo",
"::"
] | def _check_is_symbolic(batch):
"""
.. todo::
WRITEME
"""
if not is_symbolic_batch(batch):
raise TypeError('Expected batch to be a symbolic variable, but '
'instead it was of type "%s"' % type(batch)) | [
"def",
"_check_is_symbolic",
"(",
"batch",
")",
":",
"if",
"not",
"is_symbolic_batch",
"(",
"batch",
")",
":",
"raise",
"TypeError",
"(",
"'Expected batch to be a symbolic variable, but '",
"'instead it was of type \"%s\"'",
"%",
"type",
"(",
"batch",
")",
")"
] | https://github.com/lisa-lab/pylearn2/blob/af81e5c362f0df4df85c3e54e23b2adeec026055/pylearn2/space/__init__.py#L815-L823 | ||
nextgenusfs/funannotate | f737bedfca5c5fd1e9a356bd400a4391926f76e4 | funannotate/library.py | python | selectTrainingModels | (input, fasta, genemark_gtf, output) | return len(final) | function to take a GFF3 file and filter the gene models so they are non-overalpping
also sort the models by number of exons, the more the better. | function to take a GFF3 file and filter the gene models so they are non-overalpping
also sort the models by number of exons, the more the better. | [
"function",
"to",
"take",
"a",
"GFF3",
"file",
"and",
"filter",
"the",
"gene",
"models",
"so",
"they",
"are",
"non",
"-",
"overalpping",
"also",
"sort",
"the",
"models",
"by",
"number",
"of",
"exons",
"the",
"more",
"the",
"better",
"."
] | def selectTrainingModels(input, fasta, genemark_gtf, output):
from collections import OrderedDict
'''
function to take a GFF3 file and filter the gene models so they are non-overalpping
also sort the models by number of exons, the more the better.
'''
def _sortDict(d):
return (len(d[1]['... | [
"def",
"selectTrainingModels",
"(",
"input",
",",
"fasta",
",",
"genemark_gtf",
",",
"output",
")",
":",
"from",
"collections",
"import",
"OrderedDict",
"def",
"_sortDict",
"(",
"d",
")",
":",
"return",
"(",
"len",
"(",
"d",
"[",
"1",
"]",
"[",
"'CDS'",
... | https://github.com/nextgenusfs/funannotate/blob/f737bedfca5c5fd1e9a356bd400a4391926f76e4/funannotate/library.py#L8414-L8529 | |
UrbanCCD-UChicago/plenario | aabd5bbaea9166231b38c350a1b9d081976a968d | plenario/api/sensor.py | python | wban_is_valid | (wban) | return True | :param wban: User-submitted WBAN code
:return: wban code as provided if valid, otherwise False | :param wban: User-submitted WBAN code
:return: wban code as provided if valid, otherwise False | [
":",
"param",
"wban",
":",
"User",
"-",
"submitted",
"WBAN",
"code",
":",
"return",
":",
"wban",
"code",
"as",
"provided",
"if",
"valid",
"otherwise",
"False"
] | def wban_is_valid(wban):
"""
:param wban: User-submitted WBAN code
:return: wban code as provided if valid, otherwise False
"""
if not wban:
return False
try:
stations_table = Table('weather_stations', postgres_base.metadata,
autoload=True, autolo... | [
"def",
"wban_is_valid",
"(",
"wban",
")",
":",
"if",
"not",
"wban",
":",
"return",
"False",
"try",
":",
"stations_table",
"=",
"Table",
"(",
"'weather_stations'",
",",
"postgres_base",
".",
"metadata",
",",
"autoload",
"=",
"True",
",",
"autoload_with",
"=",... | https://github.com/UrbanCCD-UChicago/plenario/blob/aabd5bbaea9166231b38c350a1b9d081976a968d/plenario/api/sensor.py#L173-L195 | |
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/full/http/cookiejar.py | python | CookieJar.clear_expired_cookies | (self) | Discard all expired cookies.
You probably don't need to call this method: expired cookies are never
sent back to the server (provided you're using DefaultCookiePolicy),
this method is called by CookieJar itself every so often, and the
.save() method won't save expired cookies anyway (un... | Discard all expired cookies. | [
"Discard",
"all",
"expired",
"cookies",
"."
] | def clear_expired_cookies(self):
"""Discard all expired cookies.
You probably don't need to call this method: expired cookies are never
sent back to the server (provided you're using DefaultCookiePolicy),
this method is called by CookieJar itself every so often, and the
.save() ... | [
"def",
"clear_expired_cookies",
"(",
"self",
")",
":",
"self",
".",
"_cookies_lock",
".",
"acquire",
"(",
")",
"try",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"for",
"cookie",
"in",
"self",
":",
"if",
"cookie",
".",
"is_expired",
"(",
"now",
"... | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/http/cookiejar.py#L1739-L1756 | ||
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/manifolds/scalarfield.py | python | ScalarField.common_charts | (self, other) | r"""
Find common charts for the expressions of the scalar field and
``other``.
INPUT:
- ``other`` -- a scalar field
OUTPUT:
- list of common charts; if no common chart is found, ``None`` is
returned (instead of an empty list)
EXAMPLES:
Sear... | r"""
Find common charts for the expressions of the scalar field and
``other``. | [
"r",
"Find",
"common",
"charts",
"for",
"the",
"expressions",
"of",
"the",
"scalar",
"field",
"and",
"other",
"."
] | def common_charts(self, other):
r"""
Find common charts for the expressions of the scalar field and
``other``.
INPUT:
- ``other`` -- a scalar field
OUTPUT:
- list of common charts; if no common chart is found, ``None`` is
returned (instead of an empt... | [
"def",
"common_charts",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ScalarField",
")",
":",
"raise",
"TypeError",
"(",
"\"the second argument must be a scalar field\"",
")",
"coord_changes",
"=",
"self",
".",
"_manifold",
... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/manifolds/scalarfield.py#L2319-L2462 | ||
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/min/modulefinder.py | python | ModuleFinder.determine_parent | (self, caller, level=-1) | return None | [] | def determine_parent(self, caller, level=-1):
self.msgin(4, "determine_parent", caller, level)
if not caller or level == 0:
self.msgout(4, "determine_parent -> None")
return None
pname = caller.__name__
if level >= 1: # relative import
if caller.__path... | [
"def",
"determine_parent",
"(",
"self",
",",
"caller",
",",
"level",
"=",
"-",
"1",
")",
":",
"self",
".",
"msgin",
"(",
"4",
",",
"\"determine_parent\"",
",",
"caller",
",",
"level",
")",
"if",
"not",
"caller",
"or",
"level",
"==",
"0",
":",
"self",... | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/min/modulefinder.py#L181-L214 | |||
mchristopher/PokemonGo-DesktopMap | ec37575f2776ee7d64456e2a1f6b6b78830b4fe0 | app/pywin/Lib/mailbox.py | python | Babyl.get_string | (self, key) | return original_headers.getvalue() + \
self._file.read(stop - self._file.tell()).replace(os.linesep,
'\n') | Return a string representation or raise a KeyError. | Return a string representation or raise a KeyError. | [
"Return",
"a",
"string",
"representation",
"or",
"raise",
"a",
"KeyError",
"."
] | def get_string(self, key):
"""Return a string representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
self._file.readline() # Skip '1,' line specifying labels.
original_headers = StringIO.StringIO()
while True:
line = se... | [
"def",
"get_string",
"(",
"self",
",",
"key",
")",
":",
"start",
",",
"stop",
"=",
"self",
".",
"_lookup",
"(",
"key",
")",
"self",
".",
"_file",
".",
"seek",
"(",
"start",
")",
"self",
".",
"_file",
".",
"readline",
"(",
")",
"# Skip '1,' line speci... | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/ec37575f2776ee7d64456e2a1f6b6b78830b4fe0/app/pywin/Lib/mailbox.py#L1283-L1300 | |
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/lib-python/3/email/_header_value_parser.py | python | get_name_addr | (value) | return name_addr, value | name-addr = [display-name] angle-addr | name-addr = [display-name] angle-addr | [
"name",
"-",
"addr",
"=",
"[",
"display",
"-",
"name",
"]",
"angle",
"-",
"addr"
] | def get_name_addr(value):
""" name-addr = [display-name] angle-addr
"""
name_addr = NameAddr()
# Both the optional display name and the angle-addr can start with cfws.
leader = None
if value[0] in CFWS_LEADER:
leader, value = get_cfws(value)
if not value:
raise error... | [
"def",
"get_name_addr",
"(",
"value",
")",
":",
"name_addr",
"=",
"NameAddr",
"(",
")",
"# Both the optional display name and the angle-addr can start with cfws.",
"leader",
"=",
"None",
"if",
"value",
"[",
"0",
"]",
"in",
"CFWS_LEADER",
":",
"leader",
",",
"value",... | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/email/_header_value_parser.py#L1753-L1781 | |
justquick/django-activity-stream | 12bceac1d8d37124d29c7717fc928496319fe03a | actstream/templatetags/activity_tags.py | python | activity_stream | (context, stream_type, *args, **kwargs) | return '' | Renders an activity stream as a list into the template's context.
Streams loaded by stream_type can be the default ones (eg user, actor, etc.) or a user defined stream.
Extra args/kwargs are passed into the stream call.
::
{% activity_stream 'actor' user %}
{% for action in stream %}
... | Renders an activity stream as a list into the template's context.
Streams loaded by stream_type can be the default ones (eg user, actor, etc.) or a user defined stream.
Extra args/kwargs are passed into the stream call. | [
"Renders",
"an",
"activity",
"stream",
"as",
"a",
"list",
"into",
"the",
"template",
"s",
"context",
".",
"Streams",
"loaded",
"by",
"stream_type",
"can",
"be",
"the",
"default",
"ones",
"(",
"eg",
"user",
"actor",
"etc",
".",
")",
"or",
"a",
"user",
"... | def activity_stream(context, stream_type, *args, **kwargs):
"""
Renders an activity stream as a list into the template's context.
Streams loaded by stream_type can be the default ones (eg user, actor, etc.) or a user defined stream.
Extra args/kwargs are passed into the stream call.
::
{% ... | [
"def",
"activity_stream",
"(",
"context",
",",
"stream_type",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"stream_type",
"==",
"'model'",
":",
"stream_type",
"=",
"'model_actions'",
"if",
"not",
"hasattr",
"(",
"Action",
".",
"objects",
",",... | https://github.com/justquick/django-activity-stream/blob/12bceac1d8d37124d29c7717fc928496319fe03a/actstream/templatetags/activity_tags.py#L240-L259 | |
IBM/lale | b4d6829c143a4735b06083a0e6c70d2cca244162 | lale/lib/lale/optimize_suffix.py | python | _OptimizeSuffix.__init__ | (
self,
prefix: Optional[lale.operators.TrainedOperator] = None,
suffix: Optional[lale.operators.Operator] = None,
optimizer: Optional[lale.operators.PlannedIndividualOp] = None,
optimizer_args=None,
**kwargs
) | [] | def __init__(
self,
prefix: Optional[lale.operators.TrainedOperator] = None,
suffix: Optional[lale.operators.Operator] = None,
optimizer: Optional[lale.operators.PlannedIndividualOp] = None,
optimizer_args=None,
**kwargs
):
self._prefix = prefix
_suff... | [
"def",
"__init__",
"(",
"self",
",",
"prefix",
":",
"Optional",
"[",
"lale",
".",
"operators",
".",
"TrainedOperator",
"]",
"=",
"None",
",",
"suffix",
":",
"Optional",
"[",
"lale",
".",
"operators",
".",
"Operator",
"]",
"=",
"None",
",",
"optimizer",
... | https://github.com/IBM/lale/blob/b4d6829c143a4735b06083a0e6c70d2cca244162/lale/lib/lale/optimize_suffix.py#L36-L63 | ||||
awslabs/autogluon | 7309118f2ab1c9519f25acf61a283a95af95842b | tabular/src/autogluon/tabular/models/catboost/catboost_model.py | python | CatBoostModel._preprocess_nonadaptive | (self, X, **kwargs) | return X | [] | def _preprocess_nonadaptive(self, X, **kwargs):
X = super()._preprocess_nonadaptive(X, **kwargs)
if self._category_features is None:
self._category_features = list(X.select_dtypes(include='category').columns)
if self._category_features:
X = X.copy()
for catego... | [
"def",
"_preprocess_nonadaptive",
"(",
"self",
",",
"X",
",",
"*",
"*",
"kwargs",
")",
":",
"X",
"=",
"super",
"(",
")",
".",
"_preprocess_nonadaptive",
"(",
"X",
",",
"*",
"*",
"kwargs",
")",
"if",
"self",
".",
"_category_features",
"is",
"None",
":",... | https://github.com/awslabs/autogluon/blob/7309118f2ab1c9519f25acf61a283a95af95842b/tabular/src/autogluon/tabular/models/catboost/catboost_model.py#L47-L59 | |||
EdCo95/scientific-paper-summarisation | 5a6217556704dda5694c298e17b909acd1608be1 | Models/SummariserNetClassifier/summariser_net_v2.py | python | graph | () | return return_dict | Function to encapsulate the construction of a TensorFlow computation graph.
:return: input placeholders, optimisation operation, loss, accuracy, prediction operations | Function to encapsulate the construction of a TensorFlow computation graph.
:return: input placeholders, optimisation operation, loss, accuracy, prediction operations | [
"Function",
"to",
"encapsulate",
"the",
"construction",
"of",
"a",
"TensorFlow",
"computation",
"graph",
".",
":",
"return",
":",
"input",
"placeholders",
"optimisation",
"operation",
"loss",
"accuracy",
"prediction",
"operations"
] | def graph():
"""
Function to encapsulate the construction of a TensorFlow computation graph.
:return: input placeholders, optimisation operation, loss, accuracy, prediction operations
"""
# ----> Define placeholders <----
# Input has shape [batch_size x num_steps x num_input (word vector dimen... | [
"def",
"graph",
"(",
")",
":",
"# ----> Define placeholders <----",
"# Input has shape [batch_size x num_steps x num_input (word vector dimensions)]",
"sentence_input",
"=",
"tf",
".",
"placeholder",
"(",
"dtype",
"=",
"tf",
".",
"float32",
",",
"shape",
"=",
"[",
"None",... | https://github.com/EdCo95/scientific-paper-summarisation/blob/5a6217556704dda5694c298e17b909acd1608be1/Models/SummariserNetClassifier/summariser_net_v2.py#L181-L288 | |
Pyomo/pyomo | dbd4faee151084f343b893cc2b0c04cf2b76fd92 | pyomo/common/tempfiles.py | python | TempfileContext.gettempprefix | (self) | return tempfile.gettempprefix() | Return the filename prefix used to create temporary files.
See :func:`tempfile.gettempprefix()` | Return the filename prefix used to create temporary files. | [
"Return",
"the",
"filename",
"prefix",
"used",
"to",
"create",
"temporary",
"files",
"."
] | def gettempprefix(self):
"""Return the filename prefix used to create temporary files.
See :func:`tempfile.gettempprefix()`
"""
return tempfile.gettempprefix() | [
"def",
"gettempprefix",
"(",
"self",
")",
":",
"return",
"tempfile",
".",
"gettempprefix",
"(",
")"
] | https://github.com/Pyomo/pyomo/blob/dbd4faee151084f343b893cc2b0c04cf2b76fd92/pyomo/common/tempfiles.py#L319-L325 | |
FSecureLABS/Jandroid | e31d0dab58a2bfd6ed8e0a387172b8bd7c893436 | libs/platform-tools/platform-tools_darwin/systrace/catapult/devil/devil/android/sdk/shared_prefs.py | python | BasePref.set | (self, value) | Set from a value casted as a string. | Set from a value casted as a string. | [
"Set",
"from",
"a",
"value",
"casted",
"as",
"a",
"string",
"."
] | def set(self, value):
"""Set from a value casted as a string."""
self._elem.set('value', str(value)) | [
"def",
"set",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_elem",
".",
"set",
"(",
"'value'",
",",
"str",
"(",
"value",
")",
")"
] | https://github.com/FSecureLABS/Jandroid/blob/e31d0dab58a2bfd6ed8e0a387172b8bd7c893436/libs/platform-tools/platform-tools_darwin/systrace/catapult/devil/devil/android/sdk/shared_prefs.py#L54-L56 | ||
omz/PythonistaAppTemplate | f560f93f8876d82a21d108977f90583df08d55af | PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/sympy/mpmath/libmp/gammazeta.py | python | mpc_zetasum | (s, a, n, derivatives, reflect, prec) | return xs, ys | Fast version of mp._zetasum, assuming s = complex, a = integer. | Fast version of mp._zetasum, assuming s = complex, a = integer. | [
"Fast",
"version",
"of",
"mp",
".",
"_zetasum",
"assuming",
"s",
"=",
"complex",
"a",
"=",
"integer",
"."
] | def mpc_zetasum(s, a, n, derivatives, reflect, prec):
"""
Fast version of mp._zetasum, assuming s = complex, a = integer.
"""
wp = prec + 10
have_derivatives = derivatives != [0]
have_one_derivative = len(derivatives) == 1
# parse s
sre, sim = s
critical_line = (sre == fhalf)
s... | [
"def",
"mpc_zetasum",
"(",
"s",
",",
"a",
",",
"n",
",",
"derivatives",
",",
"reflect",
",",
"prec",
")",
":",
"wp",
"=",
"prec",
"+",
"10",
"have_derivatives",
"=",
"derivatives",
"!=",
"[",
"0",
"]",
"have_one_derivative",
"=",
"len",
"(",
"derivativ... | https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/sympy/mpmath/libmp/gammazeta.py#L1468-L1563 | |
HymanLiuTS/flaskTs | 286648286976e85d9b9a5873632331efcafe0b21 | flasky/lib/python2.7/site-packages/jinja2/filters.py | python | do_random | (environment, seq) | Return a random item from the sequence. | Return a random item from the sequence. | [
"Return",
"a",
"random",
"item",
"from",
"the",
"sequence",
"."
] | def do_random(environment, seq):
"""Return a random item from the sequence."""
try:
return choice(seq)
except IndexError:
return environment.undefined('No random item, sequence was empty.') | [
"def",
"do_random",
"(",
"environment",
",",
"seq",
")",
":",
"try",
":",
"return",
"choice",
"(",
"seq",
")",
"except",
"IndexError",
":",
"return",
"environment",
".",
"undefined",
"(",
"'No random item, sequence was empty.'",
")"
] | https://github.com/HymanLiuTS/flaskTs/blob/286648286976e85d9b9a5873632331efcafe0b21/flasky/lib/python2.7/site-packages/jinja2/filters.py#L364-L369 | ||
huggingface/transformers | 623b4f7c63f60cce917677ee704d6c93ee960b4b | src/transformers/models/ibert/quant_modules.py | python | symmetric_linear_quantization_params | (num_bits, saturation_min, saturation_max, per_channel=False) | return scale | Compute the scaling factor with the given quantization range for symmetric quantization.
Args:
saturation_min (`torch.Tensor`):
Lower bound for quantization range.
saturation_max (`torch.Tensor`):
Upper bound for quantization range.
per_channel (`bool`, *optional*, d... | Compute the scaling factor with the given quantization range for symmetric quantization. | [
"Compute",
"the",
"scaling",
"factor",
"with",
"the",
"given",
"quantization",
"range",
"for",
"symmetric",
"quantization",
"."
] | def symmetric_linear_quantization_params(num_bits, saturation_min, saturation_max, per_channel=False):
"""
Compute the scaling factor with the given quantization range for symmetric quantization.
Args:
saturation_min (`torch.Tensor`):
Lower bound for quantization range.
saturati... | [
"def",
"symmetric_linear_quantization_params",
"(",
"num_bits",
",",
"saturation_min",
",",
"saturation_max",
",",
"per_channel",
"=",
"False",
")",
":",
"# in this part, we do not need any gradient computation,",
"# in order to enforce this, we put torch.no_grad()",
"with",
"torch... | https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/ibert/quant_modules.py#L601-L630 | |
NifTK/NiftyNet | 935bf4334cd00fa9f9d50f6a95ddcbfdde4031e0 | niftynet/evaluation/region_properties.py | python | RegionProperties.homogeneity | (self, matrix) | return homogeneity | Calculates the homogeneity over the glcm matrix
:param matrix:
:return: | Calculates the homogeneity over the glcm matrix | [
"Calculates",
"the",
"homogeneity",
"over",
"the",
"glcm",
"matrix"
] | def homogeneity(self, matrix):
"""
Calculates the homogeneity over the glcm matrix
:param matrix:
:return:
"""
homogeneity = 0
for i in range(0, matrix.shape[0]):
for j in range(0, matrix.shape[1]):
homogeneity += matrix[i, j] / (1 - a... | [
"def",
"homogeneity",
"(",
"self",
",",
"matrix",
")",
":",
"homogeneity",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"matrix",
".",
"shape",
"[",
"0",
"]",
")",
":",
"for",
"j",
"in",
"range",
"(",
"0",
",",
"matrix",
".",
"shape",
"[... | https://github.com/NifTK/NiftyNet/blob/935bf4334cd00fa9f9d50f6a95ddcbfdde4031e0/niftynet/evaluation/region_properties.py#L421-L432 | |
pradyun/Py2C | b5c9fd238db589f6d7709482901e33ffebb764eb | py2c/processing/to_ast.py | python | SourceToAST.work | (self, code) | Translate the passed code into a Python AST and simplify it. | Translate the passed code into a Python AST and simplify it. | [
"Translate",
"the",
"passed",
"code",
"into",
"a",
"Python",
"AST",
"and",
"simplify",
"it",
"."
] | def work(self, code):
"""Translate the passed code into a Python AST and simplify it.
"""
try:
node = ast.parse(code)
except Exception as e:
raise SourceToASTTranslationError() from e
else:
return self.visit(node) | [
"def",
"work",
"(",
"self",
",",
"code",
")",
":",
"try",
":",
"node",
"=",
"ast",
".",
"parse",
"(",
"code",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"SourceToASTTranslationError",
"(",
")",
"from",
"e",
"else",
":",
"return",
"self",
".... | https://github.com/pradyun/Py2C/blob/b5c9fd238db589f6d7709482901e33ffebb764eb/py2c/processing/to_ast.py#L37-L45 | ||
dimagi/commcare-hq | d67ff1d3b4c51fa050c19e60c3253a79d3452a39 | corehq/apps/reports/v2/formatters/cases.py | python | CaseDataFormatter.opened_by_user_id | (self) | return user['id'] | Computed metadata | Computed metadata | [
"Computed",
"metadata"
] | def opened_by_user_id(self):
"""Computed metadata"""
user = self._creating_user
if user is None:
return _("No data")
return user['id'] | [
"def",
"opened_by_user_id",
"(",
"self",
")",
":",
"user",
"=",
"self",
".",
"_creating_user",
"if",
"user",
"is",
"None",
":",
"return",
"_",
"(",
"\"No data\"",
")",
"return",
"user",
"[",
"'id'",
"]"
] | https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/reports/v2/formatters/cases.py#L83-L88 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.