repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
numenta/htmresearch
htmresearch/support/expsuite.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/support/expsuite.py#L426-L490
def browse(self): """ go through all subfolders (starting at '.') and return information about the existing experiments. if the -B option is given, all parameters are shown, -b only displays the most important ones. this function does *not* execute any experiments. "...
[ "def", "browse", "(", "self", ")", ":", "for", "d", "in", "self", ".", "get_exps", "(", "'.'", ")", ":", "params", "=", "self", ".", "get_params", "(", "d", ")", "name", "=", "params", "[", "'name'", "]", "basename", "=", "name", ".", "split", "(...
go through all subfolders (starting at '.') and return information about the existing experiments. if the -B option is given, all parameters are shown, -b only displays the most important ones. this function does *not* execute any experiments.
[ "go", "through", "all", "subfolders", "(", "starting", "at", ".", ")", "and", "return", "information", "about", "the", "existing", "experiments", ".", "if", "the", "-", "B", "option", "is", "given", "all", "parameters", "are", "shown", "-", "b", "only", ...
python
train
mfcloud/python-zvm-sdk
smtLayer/powerVM.py
https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/powerVM.py#L390-L484
def parseCmdline(rh): """ Parse the request command input. Input: Request Handle Output: Request Handle updated with parsed input. Return code - 0: ok, non-zero: error """ rh.printSysLog("Enter powerVM.parseCmdline") if rh.totalParms >= 2: rh.userid = rh.requ...
[ "def", "parseCmdline", "(", "rh", ")", ":", "rh", ".", "printSysLog", "(", "\"Enter powerVM.parseCmdline\"", ")", "if", "rh", ".", "totalParms", ">=", "2", ":", "rh", ".", "userid", "=", "rh", ".", "request", "[", "1", "]", ".", "upper", "(", ")", "e...
Parse the request command input. Input: Request Handle Output: Request Handle updated with parsed input. Return code - 0: ok, non-zero: error
[ "Parse", "the", "request", "command", "input", "." ]
python
train
ArchiveTeam/wpull
wpull/processor/rule.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/processor/rule.py#L426-L433
def consult_response_hook(self, item_session: ItemSession) -> Actions: '''Return scripting action when a response ends.''' try: return self.hook_dispatcher.call( PluginFunctions.handle_response, item_session ) except HookDisconnected: return Ac...
[ "def", "consult_response_hook", "(", "self", ",", "item_session", ":", "ItemSession", ")", "->", "Actions", ":", "try", ":", "return", "self", ".", "hook_dispatcher", ".", "call", "(", "PluginFunctions", ".", "handle_response", ",", "item_session", ")", "except"...
Return scripting action when a response ends.
[ "Return", "scripting", "action", "when", "a", "response", "ends", "." ]
python
train
edeposit/marcxml2mods
src/marcxml2mods/mods_postprocessor/monograph.py
https://github.com/edeposit/marcxml2mods/blob/7b44157e859b4d2a372f79598ddbf77e43d39812/src/marcxml2mods/mods_postprocessor/monograph.py#L82-L94
def add_uuid(dom, uuid): """ Add ``<mods:identifier>`` with `uuid`. """ mods_tag = get_mods_tag(dom) uuid_tag = dhtmlparser.HTMLElement( "mods:identifier", {"type": "uuid"}, [dhtmlparser.HTMLElement(uuid)] ) insert_tag(uuid_tag, dom.find("mods:identifier"), mods_tag...
[ "def", "add_uuid", "(", "dom", ",", "uuid", ")", ":", "mods_tag", "=", "get_mods_tag", "(", "dom", ")", "uuid_tag", "=", "dhtmlparser", ".", "HTMLElement", "(", "\"mods:identifier\"", ",", "{", "\"type\"", ":", "\"uuid\"", "}", ",", "[", "dhtmlparser", "."...
Add ``<mods:identifier>`` with `uuid`.
[ "Add", "<mods", ":", "identifier", ">", "with", "uuid", "." ]
python
train
facebook/watchman
winbuild/copy-dyn-deps.py
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/winbuild/copy-dyn-deps.py#L147-L166
def resolve_dep(self, depname): """ Locate dep in the search path; if found, return its path. If not found in the search path, and the dep is not a system-provided dep, raise an error """ for d in self._search_path: name = os.path.join(d, depname) if self._mock: ...
[ "def", "resolve_dep", "(", "self", ",", "depname", ")", ":", "for", "d", "in", "self", ".", "_search_path", ":", "name", "=", "os", ".", "path", ".", "join", "(", "d", ",", "depname", ")", "if", "self", ".", "_mock", ":", "return", "name", "if", ...
Locate dep in the search path; if found, return its path. If not found in the search path, and the dep is not a system-provided dep, raise an error
[ "Locate", "dep", "in", "the", "search", "path", ";", "if", "found", "return", "its", "path", ".", "If", "not", "found", "in", "the", "search", "path", "and", "the", "dep", "is", "not", "a", "system", "-", "provided", "dep", "raise", "an", "error" ]
python
train
tgalal/python-axolotl
axolotl/util/keyhelper.py
https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/util/keyhelper.py#L21-L34
def generateIdentityKeyPair(): """ Generate an identity key pair. Clients should only do this once, at install time. @return the generated IdentityKeyPair. """ keyPair = Curve.generateKeyPair() publicKey = IdentityKey(keyPair.getPublicKey()) serialized = ...
[ "def", "generateIdentityKeyPair", "(", ")", ":", "keyPair", "=", "Curve", ".", "generateKeyPair", "(", ")", "publicKey", "=", "IdentityKey", "(", "keyPair", ".", "getPublicKey", "(", ")", ")", "serialized", "=", "'0a21056e8936e8367f768a7bba008ade7cf58407bdc7a6aae293e2...
Generate an identity key pair. Clients should only do this once, at install time. @return the generated IdentityKeyPair.
[ "Generate", "an", "identity", "key", "pair", ".", "Clients", "should", "only", "do", "this", "once", "at", "install", "time", "." ]
python
train
square/connect-python-sdk
squareconnect/models/v1_page.py
https://github.com/square/connect-python-sdk/blob/adc1d09e817986cdc607391580f71d6b48ed4066/squareconnect/models/v1_page.py#L116-L132
def page_index(self, page_index): """ Sets the page_index of this V1Page. The page's position in the merchant's list of pages. Always an integer between 0 and 6, inclusive. :param page_index: The page_index of this V1Page. :type: int """ if page_index is None: ...
[ "def", "page_index", "(", "self", ",", "page_index", ")", ":", "if", "page_index", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `page_index`, must not be `None`\"", ")", "if", "page_index", ">", "6", ":", "raise", "ValueError", "(", "\"Inval...
Sets the page_index of this V1Page. The page's position in the merchant's list of pages. Always an integer between 0 and 6, inclusive. :param page_index: The page_index of this V1Page. :type: int
[ "Sets", "the", "page_index", "of", "this", "V1Page", ".", "The", "page", "s", "position", "in", "the", "merchant", "s", "list", "of", "pages", ".", "Always", "an", "integer", "between", "0", "and", "6", "inclusive", "." ]
python
train
apache/airflow
airflow/contrib/hooks/gcp_pubsub_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_pubsub_hook.py#L196-L225
def delete_subscription(self, project, subscription, fail_if_not_exists=False): """Deletes a Pub/Sub subscription, if it exists. :param project: the GCP project ID where the subscription exists :type project: str :param subscription: the Pub/Sub subscription ...
[ "def", "delete_subscription", "(", "self", ",", "project", ",", "subscription", ",", "fail_if_not_exists", "=", "False", ")", ":", "service", "=", "self", ".", "get_conn", "(", ")", "full_subscription", "=", "_format_subscription", "(", "project", ",", "subscrip...
Deletes a Pub/Sub subscription, if it exists. :param project: the GCP project ID where the subscription exists :type project: str :param subscription: the Pub/Sub subscription name to delete; do not include the ``projects/{project}/subscriptions/`` prefix. :type subscription...
[ "Deletes", "a", "Pub", "/", "Sub", "subscription", "if", "it", "exists", "." ]
python
test
guaix-ucm/pyemir
emirdrp/tools/display_slitlet_arrangement.py
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/display_slitlet_arrangement.py#L42-L248
def display_slitlet_arrangement(fileobj, grism=None, spfilter=None, bbox=None, adjust=None, geometry=None, debugplot=0): """...
[ "def", "display_slitlet_arrangement", "(", "fileobj", ",", "grism", "=", "None", ",", "spfilter", "=", "None", ",", "bbox", "=", "None", ",", "adjust", "=", "None", ",", "geometry", "=", "None", ",", "debugplot", "=", "0", ")", ":", "if", "fileobj", "....
Display slitlet arrangment from CSUP keywords in FITS header. Parameters ---------- fileobj : file object FITS or TXT file object. grism : str Grism. grism : str Filter. bbox : tuple of 4 floats If not None, values for xmin, xmax, ymin and ymax. adjust : bool...
[ "Display", "slitlet", "arrangment", "from", "CSUP", "keywords", "in", "FITS", "header", "." ]
python
train
hhatto/autopep8
autopep8.py
https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1201-L1204
def fix_w291(self, result): """Remove trailing whitespace.""" fixed_line = self.source[result['line'] - 1].rstrip() self.source[result['line'] - 1] = fixed_line + '\n'
[ "def", "fix_w291", "(", "self", ",", "result", ")", ":", "fixed_line", "=", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1", "]", ".", "rstrip", "(", ")", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1", "]",...
Remove trailing whitespace.
[ "Remove", "trailing", "whitespace", "." ]
python
train
revelc/pyaccumulo
pyaccumulo/proxy/AccumuloProxy.py
https://github.com/revelc/pyaccumulo/blob/8adcf535bb82ba69c749efce785c9efc487e85de/pyaccumulo/proxy/AccumuloProxy.py#L2735-L2743
def revokeSystemPermission(self, login, user, perm): """ Parameters: - login - user - perm """ self.send_revokeSystemPermission(login, user, perm) self.recv_revokeSystemPermission()
[ "def", "revokeSystemPermission", "(", "self", ",", "login", ",", "user", ",", "perm", ")", ":", "self", ".", "send_revokeSystemPermission", "(", "login", ",", "user", ",", "perm", ")", "self", ".", "recv_revokeSystemPermission", "(", ")" ]
Parameters: - login - user - perm
[ "Parameters", ":", "-", "login", "-", "user", "-", "perm" ]
python
train
profitbricks/profitbricks-sdk-python
profitbricks/client.py
https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/profitbricks/client.py#L80-L96
def _read_config(self, filename=None): """ Read the user configuration """ if filename: self._config_filename = filename else: try: import appdirs except ImportError: raise Exception("Missing dependency for deter...
[ "def", "_read_config", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", ":", "self", ".", "_config_filename", "=", "filename", "else", ":", "try", ":", "import", "appdirs", "except", "ImportError", ":", "raise", "Exception", "(", "\"M...
Read the user configuration
[ "Read", "the", "user", "configuration" ]
python
valid
coleifer/irc
irc.py
https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L87-L105
def connect(self): """\ Connect to the IRC server using the nickname """ self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if self.use_ssl: self._sock = ssl.wrap_socket(self._sock) try: self._sock.connect((self.server, self.port)) ...
[ "def", "connect", "(", "self", ")", ":", "self", ".", "_sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "if", "self", ".", "use_ssl", ":", "self", ".", "_sock", "=", "ssl", ".", "wrap_socket...
\ Connect to the IRC server using the nickname
[ "\\", "Connect", "to", "the", "IRC", "server", "using", "the", "nickname" ]
python
test
tensorflow/probability
tensorflow_probability/python/mcmc/internal/util.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/internal/util.py#L221-L244
def maybe_call_fn_and_grads(fn, fn_arg_list, result=None, grads=None, check_non_none_grads=True, name=None): """Calls `fn` and computes the gradient of the result wrt `args_list`...
[ "def", "maybe_call_fn_and_grads", "(", "fn", ",", "fn_arg_list", ",", "result", "=", "None", ",", "grads", "=", "None", ",", "check_non_none_grads", "=", "True", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "compat", ".", "v1", ".", "name_scope...
Calls `fn` and computes the gradient of the result wrt `args_list`.
[ "Calls", "fn", "and", "computes", "the", "gradient", "of", "the", "result", "wrt", "args_list", "." ]
python
test
neherlab/treetime
treetime/node_interpolator.py
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/node_interpolator.py#L165-L281
def convolve(cls, node_interp, branch_interp, max_or_integral='integral', n_grid_points = ttconf.NODE_GRID_SIZE, n_integral=ttconf.N_INTEGRAL, inverse_time=True, rel_tol=0.05, yc=10): ''' calculate H(t) = \int_tau f(t-tau)g(tau) if inverse_time=True H...
[ "def", "convolve", "(", "cls", ",", "node_interp", ",", "branch_interp", ",", "max_or_integral", "=", "'integral'", ",", "n_grid_points", "=", "ttconf", ".", "NODE_GRID_SIZE", ",", "n_integral", "=", "ttconf", ".", "N_INTEGRAL", ",", "inverse_time", "=", "True",...
calculate H(t) = \int_tau f(t-tau)g(tau) if inverse_time=True H(t) = \int_tau f(t+tau)g(tau) if inverse_time=False This function determines the time points of the grid of the result to ensure an accurate approximation.
[ "calculate", "H", "(", "t", ")", "=", "\\", "int_tau", "f", "(", "t", "-", "tau", ")", "g", "(", "tau", ")", "if", "inverse_time", "=", "True", "H", "(", "t", ")", "=", "\\", "int_tau", "f", "(", "t", "+", "tau", ")", "g", "(", "tau", ")", ...
python
test
CityOfZion/neo-python
neo/Core/State/SpentCoinState.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/SpentCoinState.py#L172-L187
def Serialize(self, writer): """ Serialize full object. Args: writer (neo.IO.BinaryWriter): """ super(SpentCoinState, self).Serialize(writer) writer.WriteUInt256(self.TransactionHash) writer.WriteUInt32(self.TransactionHeight) writer.WriteVar...
[ "def", "Serialize", "(", "self", ",", "writer", ")", ":", "super", "(", "SpentCoinState", ",", "self", ")", ".", "Serialize", "(", "writer", ")", "writer", ".", "WriteUInt256", "(", "self", ".", "TransactionHash", ")", "writer", ".", "WriteUInt32", "(", ...
Serialize full object. Args: writer (neo.IO.BinaryWriter):
[ "Serialize", "full", "object", "." ]
python
train
infothrill/python-dyndnsc
dyndnsc/updater/afraid.py
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/updater/afraid.py#L60-L74
def compute_auth_key(userid, password): """ Compute the authentication key for freedns.afraid.org. This is the SHA1 hash of the string b'userid|password'. :param userid: ascii username :param password: ascii password :return: ascii authentication key (SHA1 at this point) """ import sys...
[ "def", "compute_auth_key", "(", "userid", ",", "password", ")", ":", "import", "sys", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "0", ")", ":", "return", "hashlib", ".", "sha1", "(", "b\"|\"", ".", "join", "(", "(", "userid", ".", "encode...
Compute the authentication key for freedns.afraid.org. This is the SHA1 hash of the string b'userid|password'. :param userid: ascii username :param password: ascii password :return: ascii authentication key (SHA1 at this point)
[ "Compute", "the", "authentication", "key", "for", "freedns", ".", "afraid", ".", "org", "." ]
python
train
20c/xbahn
xbahn/engineer.py
https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/engineer.py#L214-L241
def make_command(self, ctx, name, info): """ make click sub-command from command info gotten from xbahn engineer """ @self.command() @click.option("--debug/--no-debug", default=False, help="Show debug information") @doc(info.get("description")) def func(...
[ "def", "make_command", "(", "self", ",", "ctx", ",", "name", ",", "info", ")", ":", "@", "self", ".", "command", "(", ")", "@", "click", ".", "option", "(", "\"--debug/--no-debug\"", ",", "default", "=", "False", ",", "help", "=", "\"Show debug informati...
make click sub-command from command info gotten from xbahn engineer
[ "make", "click", "sub", "-", "command", "from", "command", "info", "gotten", "from", "xbahn", "engineer" ]
python
train
peterbrittain/asciimatics
asciimatics/screen.py
https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/screen.py#L763-L793
def highlight(self, x, y, w, h, fg=None, bg=None, blend=100): """ Highlight a specified section of the screen. :param x: The column (x coord) for the start of the highlight. :param y: The line (y coord) for the start of the highlight. :param w: The width of the highlight (in cha...
[ "def", "highlight", "(", "self", ",", "x", ",", "y", ",", "w", ",", "h", ",", "fg", "=", "None", ",", "bg", "=", "None", ",", "blend", "=", "100", ")", ":", "# Convert to buffer coordinates", "y", "-=", "self", ".", "_start_line", "for", "i", "in",...
Highlight a specified section of the screen. :param x: The column (x coord) for the start of the highlight. :param y: The line (y coord) for the start of the highlight. :param w: The width of the highlight (in characters). :param h: The height of the highlight (in characters). :...
[ "Highlight", "a", "specified", "section", "of", "the", "screen", "." ]
python
train
python-wink/python-wink
src/pywink/devices/siren.py
https://github.com/python-wink/python-wink/blob/cf8bdce8c6518f30b91b23aa7aa32e89c2ce48da/src/pywink/devices/siren.py#L117-L130
def set_chime(self, sound, cycles=None): """ :param sound: a str, one of ["doorbell", "fur_elise", "doorbell_extended", "alert", "william_tell", "rondo_alla_turca", "police_siren", ""evacuation", "beep_beep", "beep", "inactive...
[ "def", "set_chime", "(", "self", ",", "sound", ",", "cycles", "=", "None", ")", ":", "desired_state", "=", "{", "\"activate_chime\"", ":", "sound", "}", "if", "cycles", "is", "not", "None", ":", "desired_state", ".", "update", "(", "{", "\"chime_cycles\"",...
:param sound: a str, one of ["doorbell", "fur_elise", "doorbell_extended", "alert", "william_tell", "rondo_alla_turca", "police_siren", ""evacuation", "beep_beep", "beep", "inactive"] :param cycles: Undocumented seems to have no effect...
[ ":", "param", "sound", ":", "a", "str", "one", "of", "[", "doorbell", "fur_elise", "doorbell_extended", "alert", "william_tell", "rondo_alla_turca", "police_siren", "evacuation", "beep_beep", "beep", "inactive", "]", ":", "param", "cycles", ":", "Undocumented", "s...
python
train
neurosnap/mudicom
mudicom/image.py
https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/image.py#L29-L37
def numpy(self): """ Grabs image data and converts it to a numpy array """ # load GDCM's image reading functionality image_reader = gdcm.ImageReader() image_reader.SetFileName(self.fname) if not image_reader.Read(): raise IOError("Could not read DICOM image") ...
[ "def", "numpy", "(", "self", ")", ":", "# load GDCM's image reading functionality", "image_reader", "=", "gdcm", ".", "ImageReader", "(", ")", "image_reader", ".", "SetFileName", "(", "self", ".", "fname", ")", "if", "not", "image_reader", ".", "Read", "(", ")...
Grabs image data and converts it to a numpy array
[ "Grabs", "image", "data", "and", "converts", "it", "to", "a", "numpy", "array" ]
python
train
Qiskit/qiskit-terra
qiskit/transpiler/coupling.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/coupling.py#L109-L113
def physical_qubits(self): """Returns a sorted list of physical_qubits""" if self._qubit_list is None: self._qubit_list = sorted([pqubit for pqubit in self.graph.nodes]) return self._qubit_list
[ "def", "physical_qubits", "(", "self", ")", ":", "if", "self", ".", "_qubit_list", "is", "None", ":", "self", ".", "_qubit_list", "=", "sorted", "(", "[", "pqubit", "for", "pqubit", "in", "self", ".", "graph", ".", "nodes", "]", ")", "return", "self", ...
Returns a sorted list of physical_qubits
[ "Returns", "a", "sorted", "list", "of", "physical_qubits" ]
python
test
bcbio/bcbio-nextgen
bcbio/workflow/template.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/workflow/template.py#L495-L504
def _convert_to_relpaths(data, work_dir): """Convert absolute paths in the input data to relative paths to the work directory. """ work_dir = os.path.abspath(work_dir) data["files"] = [os.path.relpath(f, work_dir) for f in data["files"]] for topk in ["metadata", "algorithm"]: for k, v in dat...
[ "def", "_convert_to_relpaths", "(", "data", ",", "work_dir", ")", ":", "work_dir", "=", "os", ".", "path", ".", "abspath", "(", "work_dir", ")", "data", "[", "\"files\"", "]", "=", "[", "os", ".", "path", ".", "relpath", "(", "f", ",", "work_dir", ")...
Convert absolute paths in the input data to relative paths to the work directory.
[ "Convert", "absolute", "paths", "in", "the", "input", "data", "to", "relative", "paths", "to", "the", "work", "directory", "." ]
python
train
Esri/ArcREST
src/arcrest/common/domain.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/domain.py#L71-L77
def removeCodedValue(self, name): """removes a codedValue by name""" for i in self._codedValues: if i['name'] == name: self._codedValues.remove(i) return True return False
[ "def", "removeCodedValue", "(", "self", ",", "name", ")", ":", "for", "i", "in", "self", ".", "_codedValues", ":", "if", "i", "[", "'name'", "]", "==", "name", ":", "self", ".", "_codedValues", ".", "remove", "(", "i", ")", "return", "True", "return"...
removes a codedValue by name
[ "removes", "a", "codedValue", "by", "name" ]
python
train
getsentry/rb
rb/clients.py
https://github.com/getsentry/rb/blob/569d1d13311f6c04bae537fc17e75da430e4ec45/rb/clients.py#L549-L565
def map(self, timeout=None, max_concurrency=64, auto_batch=None): """Returns a context manager for a map operation. This runs multiple queries in parallel and then joins in the end to collect all results. In the context manager the client available is a :class:`MappingClient`. ...
[ "def", "map", "(", "self", ",", "timeout", "=", "None", ",", "max_concurrency", "=", "64", ",", "auto_batch", "=", "None", ")", ":", "return", "MapManager", "(", "self", ".", "get_mapping_client", "(", "max_concurrency", ",", "auto_batch", ")", ",", "timeo...
Returns a context manager for a map operation. This runs multiple queries in parallel and then joins in the end to collect all results. In the context manager the client available is a :class:`MappingClient`. Example usage:: results = {} with cluster.map() as ...
[ "Returns", "a", "context", "manager", "for", "a", "map", "operation", ".", "This", "runs", "multiple", "queries", "in", "parallel", "and", "then", "joins", "in", "the", "end", "to", "collect", "all", "results", "." ]
python
train
cisco-sas/kitty
kitty/model/low_level/encoder.py
https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/model/low_level/encoder.py#L158-L163
def encode(self, value): ''' :param value: value to encode ''' encoded = strToBytes(value) + b'\x00' return Bits(bytes=encoded)
[ "def", "encode", "(", "self", ",", "value", ")", ":", "encoded", "=", "strToBytes", "(", "value", ")", "+", "b'\\x00'", "return", "Bits", "(", "bytes", "=", "encoded", ")" ]
:param value: value to encode
[ ":", "param", "value", ":", "value", "to", "encode" ]
python
train
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/import.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/import.py#L291-L324
async def import_aggregated(self, async_client, pid): """Import the SciObj at {pid}. If the SciObj is a Resource Map, also recursively import the aggregated objects. """ self._logger.info('Importing: {}'.format(pid)) task_set = set() object_info_pyxb = d1_common.types...
[ "async", "def", "import_aggregated", "(", "self", ",", "async_client", ",", "pid", ")", ":", "self", ".", "_logger", ".", "info", "(", "'Importing: {}'", ".", "format", "(", "pid", ")", ")", "task_set", "=", "set", "(", ")", "object_info_pyxb", "=", "d1_...
Import the SciObj at {pid}. If the SciObj is a Resource Map, also recursively import the aggregated objects.
[ "Import", "the", "SciObj", "at", "{", "pid", "}", "." ]
python
train
jepegit/cellpy
cellpy/readers/dbreader.py
https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L182-L194
def select_serial_number_row(self, serial_number): """Select row for identification number serial_number Args: serial_number: serial number Returns: pandas.DataFrame """ sheet = self.table col = self.db_sheet_cols.id rows = sheet.loc[:, c...
[ "def", "select_serial_number_row", "(", "self", ",", "serial_number", ")", ":", "sheet", "=", "self", ".", "table", "col", "=", "self", ".", "db_sheet_cols", ".", "id", "rows", "=", "sheet", ".", "loc", "[", ":", ",", "col", "]", "==", "serial_number", ...
Select row for identification number serial_number Args: serial_number: serial number Returns: pandas.DataFrame
[ "Select", "row", "for", "identification", "number", "serial_number" ]
python
train
materialsproject/pymatgen
pymatgen/io/zeopp.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/zeopp.py#L456-L513
def get_void_volume_surfarea(structure, rad_dict=None, chan_rad=0.3, probe_rad=0.1): """ Computes the volume and surface area of isolated void using Zeo++. Useful to compute the volume and surface area of vacant site. Args: structure: pymatgen Structure containing v...
[ "def", "get_void_volume_surfarea", "(", "structure", ",", "rad_dict", "=", "None", ",", "chan_rad", "=", "0.3", ",", "probe_rad", "=", "0.1", ")", ":", "with", "ScratchDir", "(", "'.'", ")", ":", "name", "=", "\"temp_zeo\"", "zeo_inp_filename", "=", "name", ...
Computes the volume and surface area of isolated void using Zeo++. Useful to compute the volume and surface area of vacant site. Args: structure: pymatgen Structure containing vacancy rad_dict(optional): Dictionary with short name of elements and their radii. chan_rad(option...
[ "Computes", "the", "volume", "and", "surface", "area", "of", "isolated", "void", "using", "Zeo", "++", ".", "Useful", "to", "compute", "the", "volume", "and", "surface", "area", "of", "vacant", "site", "." ]
python
train
knipknap/exscript
Exscript/util/ipv4.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/util/ipv4.py#L257-L273
def is_private(ip): """ Returns True if the given IP address is private, returns False otherwise. :type ip: string :param ip: An IP address. :rtype: bool :return: True if the IP is private, False otherwise. """ if matches_prefix(ip, '10.0.0.0/8'): return True if matche...
[ "def", "is_private", "(", "ip", ")", ":", "if", "matches_prefix", "(", "ip", ",", "'10.0.0.0/8'", ")", ":", "return", "True", "if", "matches_prefix", "(", "ip", ",", "'172.16.0.0/12'", ")", ":", "return", "True", "if", "matches_prefix", "(", "ip", ",", "...
Returns True if the given IP address is private, returns False otherwise. :type ip: string :param ip: An IP address. :rtype: bool :return: True if the IP is private, False otherwise.
[ "Returns", "True", "if", "the", "given", "IP", "address", "is", "private", "returns", "False", "otherwise", "." ]
python
train
CalebBell/thermo
thermo/dippr.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/dippr.py#L244-L315
def EQ104(T, A, B, C, D, E, order=0): r'''DIPPR Equation #104. Often used in calculating second virial coefficients of gases. All 5 parameters are required. C, D, and E are normally large values. .. math:: Y = A + \frac{B}{T} + \frac{C}{T^3} + \frac{D}{T^8} + \frac{E}{T^9} Parameters -...
[ "def", "EQ104", "(", "T", ",", "A", ",", "B", ",", "C", ",", "D", ",", "E", ",", "order", "=", "0", ")", ":", "if", "order", "==", "0", ":", "T2", "=", "T", "*", "T", "return", "A", "+", "(", "B", "+", "(", "C", "+", "(", "D", "+", ...
r'''DIPPR Equation #104. Often used in calculating second virial coefficients of gases. All 5 parameters are required. C, D, and E are normally large values. .. math:: Y = A + \frac{B}{T} + \frac{C}{T^3} + \frac{D}{T^8} + \frac{E}{T^9} Parameters ---------- T : float Temperatur...
[ "r", "DIPPR", "Equation", "#104", ".", "Often", "used", "in", "calculating", "second", "virial", "coefficients", "of", "gases", ".", "All", "5", "parameters", "are", "required", ".", "C", "D", "and", "E", "are", "normally", "large", "values", "." ]
python
valid
oseledets/ttpy
tt/core/matrix.py
https://github.com/oseledets/ttpy/blob/b440f6299a6338de4aea67f3d839d613f4ef1374/tt/core/matrix.py#L355-L374
def full(self): """ Transforms a TT-matrix into a full matrix""" N = self.n.prod() M = self.m.prod() a = self.tt.full() d = self.tt.d sz = _np.vstack((self.n, self.m)).flatten('F') a = a.reshape(sz, order='F') # Design a permutation prm = _np.arang...
[ "def", "full", "(", "self", ")", ":", "N", "=", "self", ".", "n", ".", "prod", "(", ")", "M", "=", "self", ".", "m", ".", "prod", "(", ")", "a", "=", "self", ".", "tt", ".", "full", "(", ")", "d", "=", "self", ".", "tt", ".", "d", "sz",...
Transforms a TT-matrix into a full matrix
[ "Transforms", "a", "TT", "-", "matrix", "into", "a", "full", "matrix" ]
python
train
twisted/mantissa
xmantissa/liveform.py
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/liveform.py#L1288-L1298
def forms(self, req, tag): """ Make and return some forms, using L{self.parameter.getInitialLiveForms}. @return: some subforms. @rtype: C{list} of L{LiveForm} """ liveForms = self.parameter.getInitialLiveForms() for liveForm in liveForms: liveForm.set...
[ "def", "forms", "(", "self", ",", "req", ",", "tag", ")", ":", "liveForms", "=", "self", ".", "parameter", ".", "getInitialLiveForms", "(", ")", "for", "liveForm", "in", "liveForms", ":", "liveForm", ".", "setFragmentParent", "(", "self", ")", "return", ...
Make and return some forms, using L{self.parameter.getInitialLiveForms}. @return: some subforms. @rtype: C{list} of L{LiveForm}
[ "Make", "and", "return", "some", "forms", "using", "L", "{", "self", ".", "parameter", ".", "getInitialLiveForms", "}", "." ]
python
train
cdriehuys/django-rest-email-auth
rest_email_auth/serializers.py
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L282-L295
def save(self): """ Reset the user's password if the provided information is valid. """ token = models.PasswordResetToken.objects.get( key=self.validated_data["key"] ) token.email.user.set_password(self.validated_data["password"]) token.email.user.sav...
[ "def", "save", "(", "self", ")", ":", "token", "=", "models", ".", "PasswordResetToken", ".", "objects", ".", "get", "(", "key", "=", "self", ".", "validated_data", "[", "\"key\"", "]", ")", "token", ".", "email", ".", "user", ".", "set_password", "(",...
Reset the user's password if the provided information is valid.
[ "Reset", "the", "user", "s", "password", "if", "the", "provided", "information", "is", "valid", "." ]
python
valid
eng-tools/bwplot
bwplot/colors.py
https://github.com/eng-tools/bwplot/blob/448bc422ffa301988f40d459230f9a4f21e2f1c6/bwplot/colors.py#L83-L157
def spectra(i, **kwargs): """ Define colours by number. Can be plotted either in order of gray scale or in the 'best' order for having a strong gray contrast for only three or four lines :param i: the index to access a colour """ ordered = kwargs.get('ordered', False) options = kwargs.ge...
[ "def", "spectra", "(", "i", ",", "*", "*", "kwargs", ")", ":", "ordered", "=", "kwargs", ".", "get", "(", "'ordered'", ",", "False", ")", "options", "=", "kwargs", ".", "get", "(", "'options'", ",", "'best'", ")", "gray", "=", "kwargs", ".", "get",...
Define colours by number. Can be plotted either in order of gray scale or in the 'best' order for having a strong gray contrast for only three or four lines :param i: the index to access a colour
[ "Define", "colours", "by", "number", ".", "Can", "be", "plotted", "either", "in", "order", "of", "gray", "scale", "or", "in", "the", "best", "order", "for", "having", "a", "strong", "gray", "contrast", "for", "only", "three", "or", "four", "lines", ":", ...
python
train
robotools/fontParts
Lib/fontParts/base/font.py
https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/font.py#L863-L884
def insertLayer(self, layer, name=None): """ Insert **layer** into the font. :: >>> layer = font.insertLayer(otherLayer, name="layer 2") This will not insert the layer directly. Rather, a new layer will be created and the data from **layer** will be copied to to the...
[ "def", "insertLayer", "(", "self", ",", "layer", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "layer", ".", "name", "name", "=", "normalizers", ".", "normalizeLayerName", "(", "name", ")", "if", "name", "in", "sel...
Insert **layer** into the font. :: >>> layer = font.insertLayer(otherLayer, name="layer 2") This will not insert the layer directly. Rather, a new layer will be created and the data from **layer** will be copied to to the new layer. **name** indicates the name that should b...
[ "Insert", "**", "layer", "**", "into", "the", "font", ".", "::" ]
python
train
HewlettPackard/python-hpOneView
hpOneView/resources/security/certificate_rabbitmq.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/security/certificate_rabbitmq.py#L44-L57
def generate(self, information, timeout=-1): """ Generates a self signed certificate or an internal CA signed certificate for RabbitMQ clients. Args: information (dict): Information to generate the certificate for RabbitMQ clients. timeout: Timeout in sec...
[ "def", "generate", "(", "self", ",", "information", ",", "timeout", "=", "-", "1", ")", ":", "return", "self", ".", "_client", ".", "create", "(", "information", ",", "timeout", "=", "timeout", ")" ]
Generates a self signed certificate or an internal CA signed certificate for RabbitMQ clients. Args: information (dict): Information to generate the certificate for RabbitMQ clients. timeout: Timeout in seconds. Wait for task completion by default. The timeout does not a...
[ "Generates", "a", "self", "signed", "certificate", "or", "an", "internal", "CA", "signed", "certificate", "for", "RabbitMQ", "clients", "." ]
python
train
michaelliao/sinaweibopy
snspy.py
https://github.com/michaelliao/sinaweibopy/blob/0f19dd71c1fbd16ee539620c7e9e986887f5c665/snspy.py#L231-L244
def _prepare_api(self, method, path, access_token, **kw): ''' Get api url. ''' headers = None if access_token: headers = {'Authorization': 'OAuth2 %s' % access_token} if '/remind/' in path: # sina remind api url is different: return met...
[ "def", "_prepare_api", "(", "self", ",", "method", ",", "path", ",", "access_token", ",", "*", "*", "kw", ")", ":", "headers", "=", "None", "if", "access_token", ":", "headers", "=", "{", "'Authorization'", ":", "'OAuth2 %s'", "%", "access_token", "}", "...
Get api url.
[ "Get", "api", "url", "." ]
python
train
contentful/contentful-management.py
contentful_management/webhook.py
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/webhook.py#L51-L60
def create_attributes(klass, attributes, previous_object=None): """ Attributes for webhook creation. """ result = super(Webhook, klass).create_attributes(attributes, previous_object) if 'topics' not in result: raise Exception("Topics ('topics') must be provided for ...
[ "def", "create_attributes", "(", "klass", ",", "attributes", ",", "previous_object", "=", "None", ")", ":", "result", "=", "super", "(", "Webhook", ",", "klass", ")", ".", "create_attributes", "(", "attributes", ",", "previous_object", ")", "if", "'topics'", ...
Attributes for webhook creation.
[ "Attributes", "for", "webhook", "creation", "." ]
python
train
OLC-Bioinformatics/sipprverse
cgecore/utility.py
https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L80-L87
def graceful_exit(self, msg): """ This function Tries to update the MSQL database before exiting. """ # Print stored errors to stderr if self.caught_error: self.print2file(self.stderr, False, False, self.caught_error) # Kill process with error message self.log(msg) sys.exit(...
[ "def", "graceful_exit", "(", "self", ",", "msg", ")", ":", "# Print stored errors to stderr", "if", "self", ".", "caught_error", ":", "self", ".", "print2file", "(", "self", ".", "stderr", ",", "False", ",", "False", ",", "self", ".", "caught_error", ")", ...
This function Tries to update the MSQL database before exiting.
[ "This", "function", "Tries", "to", "update", "the", "MSQL", "database", "before", "exiting", "." ]
python
train
mitsei/dlkit
dlkit/json_/assessment/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/managers.py#L2834-L2857
def get_assessment_taken_admin_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment taken admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessme...
[ "def", "get_assessment_taken_admin_session_for_bank", "(", "self", ",", "bank_id", ",", "proxy", ")", ":", "if", "not", "self", ".", "supports_assessment_taken_admin", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "##", "# Also include check to s...
Gets the ``OsidSession`` associated with the assessment taken admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentTakenAdminSession) - an ``AssessmentTakenSearchSessio...
[ "Gets", "the", "OsidSession", "associated", "with", "the", "assessment", "taken", "admin", "service", "for", "the", "given", "bank", "." ]
python
train
quora/qcore
qcore/helpers.py
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/helpers.py#L316-L333
def catchable_exceptions(exceptions): """Returns True if exceptions can be caught in the except clause. The exception can be caught if it is an Exception type or a tuple of exception types. """ if isinstance(exceptions, type) and issubclass(exceptions, BaseException): return True if (...
[ "def", "catchable_exceptions", "(", "exceptions", ")", ":", "if", "isinstance", "(", "exceptions", ",", "type", ")", "and", "issubclass", "(", "exceptions", ",", "BaseException", ")", ":", "return", "True", "if", "(", "isinstance", "(", "exceptions", ",", "t...
Returns True if exceptions can be caught in the except clause. The exception can be caught if it is an Exception type or a tuple of exception types.
[ "Returns", "True", "if", "exceptions", "can", "be", "caught", "in", "the", "except", "clause", "." ]
python
train
StackStorm/pybind
pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/path/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/path/__init__.py#L133-L154
def _set_path_hop(self, v, load=False): """ Setter method for path_hop, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/path/path_hop (list) If this variable is read-only (config: false) in the source YANG file, then _set_path_hop is considered as a private method. Backends looki...
[ "def", "_set_path_hop", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base"...
Setter method for path_hop, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/path/path_hop (list) If this variable is read-only (config: false) in the source YANG file, then _set_path_hop is considered as a private method. Backends looking to populate this variable should do so via ca...
[ "Setter", "method", "for", "path_hop", "mapped", "from", "YANG", "variable", "/", "mpls_config", "/", "router", "/", "mpls", "/", "mpls_cmds_holder", "/", "path", "/", "path_hop", "(", "list", ")", "If", "this", "variable", "is", "read", "-", "only", "(", ...
python
train
ajenhl/tacl
tacl/__main__.py
https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/__main__.py#L116-L120
def generate_catalogue(args, parser): """Generates and saves a catalogue file.""" catalogue = tacl.Catalogue() catalogue.generate(args.corpus, args.label) catalogue.save(args.catalogue)
[ "def", "generate_catalogue", "(", "args", ",", "parser", ")", ":", "catalogue", "=", "tacl", ".", "Catalogue", "(", ")", "catalogue", ".", "generate", "(", "args", ".", "corpus", ",", "args", ".", "label", ")", "catalogue", ".", "save", "(", "args", "....
Generates and saves a catalogue file.
[ "Generates", "and", "saves", "a", "catalogue", "file", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_lag.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_lag.py#L312-L325
def get_port_channel_detail_output_lacp_aggr_member_sync(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_port_channel_detail = ET.Element("get_port_channel_detail") config = get_port_channel_detail output = ET.SubElement(get_port_channel_deta...
[ "def", "get_port_channel_detail_output_lacp_aggr_member_sync", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_port_channel_detail", "=", "ET", ".", "Element", "(", "\"get_port_channel_detail\"", ")",...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
gitpython-developers/GitPython
git/refs/symbolic.py
https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/refs/symbolic.py#L517-L546
def create(cls, repo, path, reference='HEAD', force=False, logmsg=None): """Create a new symbolic reference, hence a reference pointing to another reference. :param repo: Repository to create the reference in :param path: full path at which the new symbolic reference is...
[ "def", "create", "(", "cls", ",", "repo", ",", "path", ",", "reference", "=", "'HEAD'", ",", "force", "=", "False", ",", "logmsg", "=", "None", ")", ":", "return", "cls", ".", "_create", "(", "repo", ",", "path", ",", "cls", ".", "_resolve_ref_on_cre...
Create a new symbolic reference, hence a reference pointing to another reference. :param repo: Repository to create the reference in :param path: full path at which the new symbolic reference is supposed to be created at, i.e. "NEW_HEAD" or "symrefs/my_new_symref" ...
[ "Create", "a", "new", "symbolic", "reference", "hence", "a", "reference", "pointing", "to", "another", "reference", "." ]
python
train
openpaperwork/paperwork-backend
paperwork_backend/index.py
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L403-L415
def upd_doc(self, doc, index_update=True, label_guesser_update=True): """ Update a document in the index """ if not self.index_writer and index_update: self.index_writer = self.index.writer() if not self.label_guesser_updater and label_guesser_update: self...
[ "def", "upd_doc", "(", "self", ",", "doc", ",", "index_update", "=", "True", ",", "label_guesser_update", "=", "True", ")", ":", "if", "not", "self", ".", "index_writer", "and", "index_update", ":", "self", ".", "index_writer", "=", "self", ".", "index", ...
Update a document in the index
[ "Update", "a", "document", "in", "the", "index" ]
python
train
google/python-gflags
gflags2man.py
https://github.com/google/python-gflags/blob/4f06c3d0d6cbe9b1fb90ee9fb1c082b3bf9285f6/gflags2man.py#L228-L272
def ParseDesc(self, start_line=0): """Parse the initial description. This could be Python or C++. Returns: (start_line, lang_type) start_line Line to start parsing flags on (int) lang_type Either 'python' or 'c' (-1, '') if the flags start could not be found """ ex...
[ "def", "ParseDesc", "(", "self", ",", "start_line", "=", "0", ")", ":", "exec_mod_start", "=", "self", ".", "executable", "+", "':'", "after_blank", "=", "0", "start_line", "=", "0", "# ignore the passed-in arg for now (?)", "for", "start_line", "in", "range", ...
Parse the initial description. This could be Python or C++. Returns: (start_line, lang_type) start_line Line to start parsing flags on (int) lang_type Either 'python' or 'c' (-1, '') if the flags start could not be found
[ "Parse", "the", "initial", "description", "." ]
python
train
jsommers/switchyard
switchyard/lib/topo/topobuild.py
https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L231-L251
def addLink(self, node1, node2, capacity, delay): ''' Add a bidirectional link between node1 and node2 with the given capacity and delay to the topology. ''' for n in (node1, node2): if not self.__nxgraph.has_node(n): raise Exception("No node {} exists...
[ "def", "addLink", "(", "self", ",", "node1", ",", "node2", ",", "capacity", ",", "delay", ")", ":", "for", "n", "in", "(", "node1", ",", "node2", ")", ":", "if", "not", "self", ".", "__nxgraph", ".", "has_node", "(", "n", ")", ":", "raise", "Exce...
Add a bidirectional link between node1 and node2 with the given capacity and delay to the topology.
[ "Add", "a", "bidirectional", "link", "between", "node1", "and", "node2", "with", "the", "given", "capacity", "and", "delay", "to", "the", "topology", "." ]
python
train
alex-kostirin/pyatomac
atomac/ldtpd/mouse.py
https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/ldtpd/mouse.py#L221-L244
def doubleclick(self, window_name, object_name): """ Double click on the object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either fu...
[ "def", "doubleclick", "(", "self", ",", "window_name", ",", "object_name", ")", ":", "object_handle", "=", "self", ".", "_get_object_handle", "(", "window_name", ",", "object_name", ")", "if", "not", "object_handle", ".", "AXEnabled", ":", "raise", "LdtpServerEx...
Double click on the object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heir...
[ "Double", "click", "on", "the", "object", "@param", "window_name", ":", "Window", "name", "to", "look", "for", "either", "full", "name", "LDTP", "s", "name", "convention", "or", "a", "Unix", "glob", ".", "@type", "window_name", ":", "string", "@param", "ob...
python
valid
ironfroggy/django-better-cache
bettercache/proxy.py
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/proxy.py#L65-L72
def header_name(name): """Convert header name like HTTP_XXXX_XXX to Xxxx-Xxx:""" words = name[5:].split('_') for i in range(len(words)): words[i] = words[i][0].upper() + words[i][1:].lower() result = '-'.join(words) return result
[ "def", "header_name", "(", "name", ")", ":", "words", "=", "name", "[", "5", ":", "]", ".", "split", "(", "'_'", ")", "for", "i", "in", "range", "(", "len", "(", "words", ")", ")", ":", "words", "[", "i", "]", "=", "words", "[", "i", "]", "...
Convert header name like HTTP_XXXX_XXX to Xxxx-Xxx:
[ "Convert", "header", "name", "like", "HTTP_XXXX_XXX", "to", "Xxxx", "-", "Xxx", ":" ]
python
train
razor-x/dichalcogenides
dichalcogenides/parameters/parameters.py
https://github.com/razor-x/dichalcogenides/blob/0fa1995a3a328b679c9926f73239d0ecdc6e5d3d/dichalcogenides/parameters/parameters.py#L69-L81
def get(self, name): """Get a parameter object by name. :param name: Name of the parameter object. :type name: str :return: The parameter. :rtype: Parameter """ parameter = next((p for p in self.parameters if p.name == name), None) if parameter is None: ...
[ "def", "get", "(", "self", ",", "name", ")", ":", "parameter", "=", "next", "(", "(", "p", "for", "p", "in", "self", ".", "parameters", "if", "p", ".", "name", "==", "name", ")", ",", "None", ")", "if", "parameter", "is", "None", ":", "raise", ...
Get a parameter object by name. :param name: Name of the parameter object. :type name: str :return: The parameter. :rtype: Parameter
[ "Get", "a", "parameter", "object", "by", "name", "." ]
python
train
vinta/haul
haul/finders/pipeline/html.py
https://github.com/vinta/haul/blob/234024ab8452ea2f41b18561377295cf2879fb20/haul/finders/pipeline/html.py#L30-L52
def a_href_finder(pipeline_index, soup, finder_image_urls=[], *args, **kwargs): """ Find image URL in <a>'s href attribute """ now_finder_image_urls = [] for a in soup.find_all('a'): href = a.get('href', None) if href: ...
[ "def", "a_href_finder", "(", "pipeline_index", ",", "soup", ",", "finder_image_urls", "=", "[", "]", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "now_finder_image_urls", "=", "[", "]", "for", "a", "in", "soup", ".", "find_all", "(", "'a'", ")"...
Find image URL in <a>'s href attribute
[ "Find", "image", "URL", "in", "<a", ">", "s", "href", "attribute" ]
python
valid
django-leonardo/django-leonardo
leonardo/module/web/widget/application/reverse.py
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widget/application/reverse.py#L31-L37
def cycle_app_reverse_cache(*args, **kwargs): """Does not really empty the cache; instead it adds a random element to the cache key generation which guarantees that the cache does not yet contain values for all newly generated keys""" value = '%07x' % (SystemRandom().randint(0, 0x10000000)) cache.se...
[ "def", "cycle_app_reverse_cache", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "value", "=", "'%07x'", "%", "(", "SystemRandom", "(", ")", ".", "randint", "(", "0", ",", "0x10000000", ")", ")", "cache", ".", "set", "(", "APP_REVERSE_CACHE_GENERAT...
Does not really empty the cache; instead it adds a random element to the cache key generation which guarantees that the cache does not yet contain values for all newly generated keys
[ "Does", "not", "really", "empty", "the", "cache", ";", "instead", "it", "adds", "a", "random", "element", "to", "the", "cache", "key", "generation", "which", "guarantees", "that", "the", "cache", "does", "not", "yet", "contain", "values", "for", "all", "ne...
python
train
cs50/check50
check50/api.py
https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/api.py#L107-L134
def import_checks(path): """ Import checks module given relative path. :param path: relative path from which to import checks module :type path: str :returns: the imported module :raises FileNotFoundError: if ``path / .check50.yaml`` does not exist :raises yaml.YAMLError: if ``path / .check...
[ "def", "import_checks", "(", "path", ")", ":", "dir", "=", "internal", ".", "check_dir", "/", "path", "file", "=", "internal", ".", "load_config", "(", "dir", ")", "[", "\"checks\"", "]", "mod", "=", "internal", ".", "import_file", "(", "dir", ".", "na...
Import checks module given relative path. :param path: relative path from which to import checks module :type path: str :returns: the imported module :raises FileNotFoundError: if ``path / .check50.yaml`` does not exist :raises yaml.YAMLError: if ``path / .check50.yaml`` is not a valid YAML file ...
[ "Import", "checks", "module", "given", "relative", "path", "." ]
python
train
jim-easterbrook/pyctools
src/pyctools/components/deinterlace/intrafield.py
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/components/deinterlace/intrafield.py#L28-L52
def IntraField(config={}): """Intra field interlace to sequential converter. This uses a vertical filter with an aperture of 8 lines, generated by :py:class:`~pyctools.components.interp.filtergenerator.FilterGenerator`. The aperture (and other parameters) can be adjusted after the :py:class:`In...
[ "def", "IntraField", "(", "config", "=", "{", "}", ")", ":", "return", "Compound", "(", "config", "=", "config", ",", "deint", "=", "SimpleDeinterlace", "(", ")", ",", "interp", "=", "Resize", "(", ")", ",", "filgen", "=", "FilterGenerator", "(", "yape...
Intra field interlace to sequential converter. This uses a vertical filter with an aperture of 8 lines, generated by :py:class:`~pyctools.components.interp.filtergenerator.FilterGenerator`. The aperture (and other parameters) can be adjusted after the :py:class:`IntraField` component is created.
[ "Intra", "field", "interlace", "to", "sequential", "converter", "." ]
python
train
contentful/contentful-management.py
contentful_management/client.py
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/client.py#L571-L618
def _contentful_user_agent(self): """ Sets the X-Contentful-User-Agent header. """ header = {} from . import __version__ header['sdk'] = { 'name': 'contentful-management.py', 'version': __version__ } header['app'] = { 'n...
[ "def", "_contentful_user_agent", "(", "self", ")", ":", "header", "=", "{", "}", "from", ".", "import", "__version__", "header", "[", "'sdk'", "]", "=", "{", "'name'", ":", "'contentful-management.py'", ",", "'version'", ":", "__version__", "}", "header", "[...
Sets the X-Contentful-User-Agent header.
[ "Sets", "the", "X", "-", "Contentful", "-", "User", "-", "Agent", "header", "." ]
python
train
googleapis/google-cloud-python
bigtable/google/cloud/bigtable/cluster.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable/cluster.py#L139-L147
def _update_from_pb(self, cluster_pb): """Refresh self from the server-provided protobuf. Helper for :meth:`from_pb` and :meth:`reload`. """ self.location_id = cluster_pb.location.split("/")[-1] self.serve_nodes = cluster_pb.serve_nodes self.default_storage_type = cluste...
[ "def", "_update_from_pb", "(", "self", ",", "cluster_pb", ")", ":", "self", ".", "location_id", "=", "cluster_pb", ".", "location", ".", "split", "(", "\"/\"", ")", "[", "-", "1", "]", "self", ".", "serve_nodes", "=", "cluster_pb", ".", "serve_nodes", "s...
Refresh self from the server-provided protobuf. Helper for :meth:`from_pb` and :meth:`reload`.
[ "Refresh", "self", "from", "the", "server", "-", "provided", "protobuf", ".", "Helper", "for", ":", "meth", ":", "from_pb", "and", ":", "meth", ":", "reload", "." ]
python
train
lyst/lightfm
lightfm/lightfm.py
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/lightfm/lightfm.py#L947-L974
def get_item_representations(self, features=None): """ Get the latent representations for items given model and features. Arguments --------- features: np.float32 csr_matrix of shape [n_items, n_item_features], optional Each row contains that item's weights over fe...
[ "def", "get_item_representations", "(", "self", ",", "features", "=", "None", ")", ":", "self", ".", "_check_initialized", "(", ")", "if", "features", "is", "None", ":", "return", "self", ".", "item_biases", ",", "self", ".", "item_embeddings", "features", "...
Get the latent representations for items given model and features. Arguments --------- features: np.float32 csr_matrix of shape [n_items, n_item_features], optional Each row contains that item's weights over features. An identity matrix will be used if not supplied. ...
[ "Get", "the", "latent", "representations", "for", "items", "given", "model", "and", "features", "." ]
python
train
zimeon/iiif
iiif/error.py
https://github.com/zimeon/iiif/blob/9d10018d01202fa2a76dfa61598dc6eca07b471f/iiif/error.py#L50-L69
def image_server_response(self, api_version=None): """Response, code and headers for image server error response. api_version selects the format (XML of 1.0). The return value is a tuple of response - body of HTTP response status - the HTTP status code headers - a ...
[ "def", "image_server_response", "(", "self", ",", "api_version", "=", "None", ")", ":", "headers", "=", "dict", "(", "self", ".", "headers", ")", "if", "(", "api_version", "<", "'1.1'", ")", ":", "headers", "[", "'Content-Type'", "]", "=", "'text/xml'", ...
Response, code and headers for image server error response. api_version selects the format (XML of 1.0). The return value is a tuple of response - body of HTTP response status - the HTTP status code headers - a dict of HTTP headers which will include the Content-Type ...
[ "Response", "code", "and", "headers", "for", "image", "server", "error", "response", "." ]
python
train
wummel/linkchecker
third_party/dnspython/dns/ipv6.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/dnspython/dns/ipv6.py#L96-L163
def inet_aton(text): """Convert a text format IPv6 address into network format. @param text: the textual address @type text: string @rtype: string @raises dns.exception.SyntaxError: the text was not properly formatted """ # # Our aim here is not something fast; we just want something t...
[ "def", "inet_aton", "(", "text", ")", ":", "#", "# Our aim here is not something fast; we just want something that works.", "#", "if", "text", "==", "'::'", ":", "text", "=", "'0::'", "#", "# Get rid of the icky dot-quad syntax if we have it.", "#", "m", "=", "_v4_ending"...
Convert a text format IPv6 address into network format. @param text: the textual address @type text: string @rtype: string @raises dns.exception.SyntaxError: the text was not properly formatted
[ "Convert", "a", "text", "format", "IPv6", "address", "into", "network", "format", "." ]
python
train
sepandhaghighi/pycm
pycm/pycm_overall_func.py
https://github.com/sepandhaghighi/pycm/blob/cb03258afd6a821d10acba73c965aaac174bedcd/pycm/pycm_overall_func.py#L472-L498
def lambda_A_calc(classes, table, P, POP): """ Calculate Goodman and Kruskal's lambda A. :param classes: confusion matrix classes :type classes : list :param table: confusion matrix table :type table : dict :param P: condition positive :type P : dict :param POP: population :type...
[ "def", "lambda_A_calc", "(", "classes", ",", "table", ",", "P", ",", "POP", ")", ":", "try", ":", "result", "=", "0", "maxreference", "=", "max", "(", "list", "(", "P", ".", "values", "(", ")", ")", ")", "length", "=", "POP", "for", "i", "in", ...
Calculate Goodman and Kruskal's lambda A. :param classes: confusion matrix classes :type classes : list :param table: confusion matrix table :type table : dict :param P: condition positive :type P : dict :param POP: population :type POP : int :return: Goodman and Kruskal's lambda A ...
[ "Calculate", "Goodman", "and", "Kruskal", "s", "lambda", "A", "." ]
python
train
econ-ark/HARK
HARK/ConsumptionSaving/ConsRepAgentModel.py
https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsRepAgentModel.py#L213-L235
def getStates(self): ''' Calculates updated values of normalized market resources and permanent income level. Uses pLvlNow, aNrmNow, PermShkNow, TranShkNow. Parameters ---------- None Returns ------- None ''' pLvlPrev = self.pLvlN...
[ "def", "getStates", "(", "self", ")", ":", "pLvlPrev", "=", "self", ".", "pLvlNow", "aNrmPrev", "=", "self", ".", "aNrmNow", "# Calculate new states: normalized market resources and permanent income level", "self", ".", "pLvlNow", "=", "pLvlPrev", "*", "self", ".", ...
Calculates updated values of normalized market resources and permanent income level. Uses pLvlNow, aNrmNow, PermShkNow, TranShkNow. Parameters ---------- None Returns ------- None
[ "Calculates", "updated", "values", "of", "normalized", "market", "resources", "and", "permanent", "income", "level", ".", "Uses", "pLvlNow", "aNrmNow", "PermShkNow", "TranShkNow", "." ]
python
train
striglia/pyramid_swagger
pyramid_swagger/ingest.py
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/ingest.py#L168-L192
def get_swagger_spec(settings): """Return a :class:`bravado_core.spec.Spec` constructed from the swagger specs in `pyramid_swagger.schema_directory`. If `pyramid_swagger.enable_swagger_spec_validation` is enabled the schema will be validated before returning it. :param settings: a pyramid registry ...
[ "def", "get_swagger_spec", "(", "settings", ")", ":", "schema_dir", "=", "settings", ".", "get", "(", "'pyramid_swagger.schema_directory'", ",", "'api_docs/'", ")", "schema_filename", "=", "settings", ".", "get", "(", "'pyramid_swagger.schema_file'", ",", "'swagger.js...
Return a :class:`bravado_core.spec.Spec` constructed from the swagger specs in `pyramid_swagger.schema_directory`. If `pyramid_swagger.enable_swagger_spec_validation` is enabled the schema will be validated before returning it. :param settings: a pyramid registry settings with configuration for ...
[ "Return", "a", ":", "class", ":", "bravado_core", ".", "spec", ".", "Spec", "constructed", "from", "the", "swagger", "specs", "in", "pyramid_swagger", ".", "schema_directory", ".", "If", "pyramid_swagger", ".", "enable_swagger_spec_validation", "is", "enabled", "t...
python
train
timstaley/voevent-parse
src/voeventparse/misc.py
https://github.com/timstaley/voevent-parse/blob/58fc1eb3af5eca23d9e819c727204950615402a7/src/voeventparse/misc.py#L95-L112
def Group(params, name=None, type=None): """Groups together Params for adding under the 'What' section. Args: params(list of :func:`Param`): Parameter elements to go in this group. name(str): Group name. NB ``None`` is valid, since the group may be best identified by its type. ...
[ "def", "Group", "(", "params", ",", "name", "=", "None", ",", "type", "=", "None", ")", ":", "atts", "=", "{", "}", "if", "name", ":", "atts", "[", "'name'", "]", "=", "name", "if", "type", ":", "atts", "[", "'type'", "]", "=", "type", "g", "...
Groups together Params for adding under the 'What' section. Args: params(list of :func:`Param`): Parameter elements to go in this group. name(str): Group name. NB ``None`` is valid, since the group may be best identified by its type. type(str): Type of group, e.g. 'complex' (for...
[ "Groups", "together", "Params", "for", "adding", "under", "the", "What", "section", "." ]
python
train
hugapi/hug
hug/middleware.py
https://github.com/hugapi/hug/blob/080901c81576657f82e2432fd4a82f1d0d2f370c/hug/middleware.py#L122-L134
def match_route(self, reqpath): """Match a request with parameter to it's corresponding route""" route_dicts = [routes for _, routes in self.api.http.routes.items()][0] routes = [route for route, _ in route_dicts.items()] if reqpath not in routes: for route in routes: # repl...
[ "def", "match_route", "(", "self", ",", "reqpath", ")", ":", "route_dicts", "=", "[", "routes", "for", "_", ",", "routes", "in", "self", ".", "api", ".", "http", ".", "routes", ".", "items", "(", ")", "]", "[", "0", "]", "routes", "=", "[", "rout...
Match a request with parameter to it's corresponding route
[ "Match", "a", "request", "with", "parameter", "to", "it", "s", "corresponding", "route" ]
python
train
gwastro/pycbc
pycbc/events/stat.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/events/stat.py#L261-L297
def logsignalrate(self, s0, s1, slide, step): """Calculate the normalized log rate density of signals via lookup""" td = numpy.array(s0['end_time'] - s1['end_time'] - slide*step, ndmin=1) pd = numpy.array((s0['coa_phase'] - s1['coa_phase']) % \ (2. * numpy.pi), ndmin=1) ...
[ "def", "logsignalrate", "(", "self", ",", "s0", ",", "s1", ",", "slide", ",", "step", ")", ":", "td", "=", "numpy", ".", "array", "(", "s0", "[", "'end_time'", "]", "-", "s1", "[", "'end_time'", "]", "-", "slide", "*", "step", ",", "ndmin", "=", ...
Calculate the normalized log rate density of signals via lookup
[ "Calculate", "the", "normalized", "log", "rate", "density", "of", "signals", "via", "lookup" ]
python
train
tk0miya/tk.phpautodoc
src/phply/phpparse.py
https://github.com/tk0miya/tk.phpautodoc/blob/cf789f64abaf76351485cee231a075227e665fb6/src/phply/phpparse.py#L203-L208
def p_statement_foreach(p): 'statement : FOREACH LPAREN expr AS foreach_variable foreach_optional_arg RPAREN foreach_statement' if p[6] is None: p[0] = ast.Foreach(p[3], None, p[5], p[8], lineno=p.lineno(1)) else: p[0] = ast.Foreach(p[3], p[5], p[6], p[8], lineno=p.lineno(1))
[ "def", "p_statement_foreach", "(", "p", ")", ":", "if", "p", "[", "6", "]", "is", "None", ":", "p", "[", "0", "]", "=", "ast", ".", "Foreach", "(", "p", "[", "3", "]", ",", "None", ",", "p", "[", "5", "]", ",", "p", "[", "8", "]", ",", ...
statement : FOREACH LPAREN expr AS foreach_variable foreach_optional_arg RPAREN foreach_statement
[ "statement", ":", "FOREACH", "LPAREN", "expr", "AS", "foreach_variable", "foreach_optional_arg", "RPAREN", "foreach_statement" ]
python
train
senaite/senaite.core
bika/lims/browser/analysisrequest/add2.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/analysisrequest/add2.py#L1522-L1673
def ajax_submit(self): """Submit & create the ARs """ # Get AR required fields (including extended fields) fields = self.get_ar_fields() # extract records from request records = self.get_records() fielderrors = {} errors = {"message": "", "fielderrors":...
[ "def", "ajax_submit", "(", "self", ")", ":", "# Get AR required fields (including extended fields)", "fields", "=", "self", ".", "get_ar_fields", "(", ")", "# extract records from request", "records", "=", "self", ".", "get_records", "(", ")", "fielderrors", "=", "{",...
Submit & create the ARs
[ "Submit", "&", "create", "the", "ARs" ]
python
train
ggaughan/pipe2py
pipe2py/modules/pipestrreplace.py
https://github.com/ggaughan/pipe2py/blob/4767d6d1fd354d2a35e6528594b8deb8a033eed4/pipe2py/modules/pipestrreplace.py#L38-L62
def asyncPipeStrreplace(context=None, _INPUT=None, conf=None, **kwargs): """A string module that asynchronously replaces text. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : twisted Deferred iterable of items or strings conf : { 'RULE': [ { ...
[ "def", "asyncPipeStrreplace", "(", "context", "=", "None", ",", "_INPUT", "=", "None", ",", "conf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "splits", "=", "yield", "asyncGetSplits", "(", "_INPUT", ",", "conf", "[", "'RULE'", "]", ",", "*", "*...
A string module that asynchronously replaces text. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : twisted Deferred iterable of items or strings conf : { 'RULE': [ { 'param': {'value': <match type: 1=first, 2=last, 3=every>}, ...
[ "A", "string", "module", "that", "asynchronously", "replaces", "text", ".", "Loopable", "." ]
python
train
allenai/allennlp
allennlp/nn/util.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L231-L269
def masked_softmax(vector: torch.Tensor, mask: torch.Tensor, dim: int = -1, memory_efficient: bool = False, mask_fill_value: float = -1e32) -> torch.Tensor: """ ``torch.nn.functional.softmax(vector)`` does not work if some elements of `...
[ "def", "masked_softmax", "(", "vector", ":", "torch", ".", "Tensor", ",", "mask", ":", "torch", ".", "Tensor", ",", "dim", ":", "int", "=", "-", "1", ",", "memory_efficient", ":", "bool", "=", "False", ",", "mask_fill_value", ":", "float", "=", "-", ...
``torch.nn.functional.softmax(vector)`` does not work if some elements of ``vector`` should be masked. This performs a softmax on just the non-masked portions of ``vector``. Passing ``None`` in for the mask is also acceptable; you'll just get a regular softmax. ``vector`` can have an arbitrary number of ...
[ "torch", ".", "nn", ".", "functional", ".", "softmax", "(", "vector", ")", "does", "not", "work", "if", "some", "elements", "of", "vector", "should", "be", "masked", ".", "This", "performs", "a", "softmax", "on", "just", "the", "non", "-", "masked", "p...
python
train
dmlc/gluon-nlp
scripts/machine_translation/dataprocessor.py
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/scripts/machine_translation/dataprocessor.py#L206-L265
def make_dataloader(data_train, data_val, data_test, args, use_average_length=False, num_shards=0, num_workers=8): """Create data loaders for training/validation/test.""" data_train_lengths = get_data_lengths(data_train) data_val_lengths = get_data_lengths(data_val) data_test_lengths...
[ "def", "make_dataloader", "(", "data_train", ",", "data_val", ",", "data_test", ",", "args", ",", "use_average_length", "=", "False", ",", "num_shards", "=", "0", ",", "num_workers", "=", "8", ")", ":", "data_train_lengths", "=", "get_data_lengths", "(", "data...
Create data loaders for training/validation/test.
[ "Create", "data", "loaders", "for", "training", "/", "validation", "/", "test", "." ]
python
train
bokeh/bokeh
bokeh/embed/server.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/embed/server.py#L271-L287
def _process_arguments(arguments): ''' Return user-supplied HTML arguments to add to a Bokeh server URL. Args: arguments (dict[str, object]) : Key/value pairs to add to the URL Returns: str ''' if arguments is None: return "" result = "" for key, value in argum...
[ "def", "_process_arguments", "(", "arguments", ")", ":", "if", "arguments", "is", "None", ":", "return", "\"\"", "result", "=", "\"\"", "for", "key", ",", "value", "in", "arguments", ".", "items", "(", ")", ":", "if", "not", "key", ".", "startswith", "...
Return user-supplied HTML arguments to add to a Bokeh server URL. Args: arguments (dict[str, object]) : Key/value pairs to add to the URL Returns: str
[ "Return", "user", "-", "supplied", "HTML", "arguments", "to", "add", "to", "a", "Bokeh", "server", "URL", "." ]
python
train
yunojuno-archive/django-package-monitor
package_monitor/management/commands/refresh_packages.py
https://github.com/yunojuno-archive/django-package-monitor/blob/534aa35ccfe187d2c55aeca0cb52b8278254e437/package_monitor/management/commands/refresh_packages.py#L28-L35
def local(): """Load local requirements file.""" logger.info("Loading requirements from local file.") with open(REQUIREMENTS_FILE, 'r') as f: requirements = parse(f) for r in requirements: logger.debug("Creating new package: %r", r) create_package_version(r)
[ "def", "local", "(", ")", ":", "logger", ".", "info", "(", "\"Loading requirements from local file.\"", ")", "with", "open", "(", "REQUIREMENTS_FILE", ",", "'r'", ")", "as", "f", ":", "requirements", "=", "parse", "(", "f", ")", "for", "r", "in", "requirem...
Load local requirements file.
[ "Load", "local", "requirements", "file", "." ]
python
train
xtuml/pyxtuml
xtuml/load.py
https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/xtuml/load.py#L285-L296
def _populate_matching_class(metamodel, kind, names, values): ''' Populate a *metamodel* with a class that matches the given *insert statement*. ''' attributes = list() for name, value in zip(names, values): ty = guess_type_name(value) attr = (name...
[ "def", "_populate_matching_class", "(", "metamodel", ",", "kind", ",", "names", ",", "values", ")", ":", "attributes", "=", "list", "(", ")", "for", "name", ",", "value", "in", "zip", "(", "names", ",", "values", ")", ":", "ty", "=", "guess_type_name", ...
Populate a *metamodel* with a class that matches the given *insert statement*.
[ "Populate", "a", "*", "metamodel", "*", "with", "a", "class", "that", "matches", "the", "given", "*", "insert", "statement", "*", "." ]
python
test
Varkal/chuda
chuda/shell.py
https://github.com/Varkal/chuda/blob/0d93b716dede35231c21be97bcc19a656655983f/chuda/shell.py#L159-L172
def kill(self): """ Kill the current non blocking command Raises: TypeError: If command is blocking """ if self.block: raise TypeError(NON_BLOCKING_ERROR_MESSAGE) try: self.process.kill() except ProcessLookupError as exc: ...
[ "def", "kill", "(", "self", ")", ":", "if", "self", ".", "block", ":", "raise", "TypeError", "(", "NON_BLOCKING_ERROR_MESSAGE", ")", "try", ":", "self", ".", "process", ".", "kill", "(", ")", "except", "ProcessLookupError", "as", "exc", ":", "self", ".",...
Kill the current non blocking command Raises: TypeError: If command is blocking
[ "Kill", "the", "current", "non", "blocking", "command" ]
python
train
tkf/rash
rash/interactive_search.py
https://github.com/tkf/rash/blob/585da418ec37dd138f1a4277718b6f507e9536a2/rash/interactive_search.py#L31-L49
def strip_glob(string, split_str=' '): """ Strip glob portion in `string`. >>> strip_glob('*glob*like') 'glob like' >>> strip_glob('glob?') 'glo' >>> strip_glob('glob[seq]') 'glob' >>> strip_glob('glob[!seq]') 'glob' :type string: str :rtype: str """ string = _...
[ "def", "strip_glob", "(", "string", ",", "split_str", "=", "' '", ")", ":", "string", "=", "_GLOB_PORTION_RE", ".", "sub", "(", "split_str", ",", "string", ")", "return", "string", ".", "strip", "(", ")" ]
Strip glob portion in `string`. >>> strip_glob('*glob*like') 'glob like' >>> strip_glob('glob?') 'glo' >>> strip_glob('glob[seq]') 'glob' >>> strip_glob('glob[!seq]') 'glob' :type string: str :rtype: str
[ "Strip", "glob", "portion", "in", "string", "." ]
python
train
pipermerriam/flex
flex/validation/request.py
https://github.com/pipermerriam/flex/blob/233f8149fb851a6255753bcec948cb6fefb2723b/flex/validation/request.py#L13-L65
def validate_request(request, schema): """ Request validation does the following steps. 1. validate that the path matches one of the defined paths in the schema. 2. validate that the request method conforms to a supported methods for the given path. 3. validate that the request parameters ...
[ "def", "validate_request", "(", "request", ",", "schema", ")", ":", "with", "ErrorDict", "(", ")", "as", "errors", ":", "# 1", "try", ":", "api_path", "=", "validate_path_to_api_path", "(", "path", "=", "request", ".", "path", ",", "context", "=", "schema"...
Request validation does the following steps. 1. validate that the path matches one of the defined paths in the schema. 2. validate that the request method conforms to a supported methods for the given path. 3. validate that the request parameters conform to the parameter definitions for ...
[ "Request", "validation", "does", "the", "following", "steps", "." ]
python
train
senaite/senaite.core
bika/lims/workflow/__init__.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/workflow/__init__.py#L228-L239
def isTransitionAllowed(instance, transition_id): """Checks if the object can perform the transition passed in. :returns: True if transition can be performed :rtype: bool """ wf_tool = getToolByName(instance, "portal_workflow") for wf_id in wf_tool.getChainFor(instance): wf = wf_tool.get...
[ "def", "isTransitionAllowed", "(", "instance", ",", "transition_id", ")", ":", "wf_tool", "=", "getToolByName", "(", "instance", ",", "\"portal_workflow\"", ")", "for", "wf_id", "in", "wf_tool", ".", "getChainFor", "(", "instance", ")", ":", "wf", "=", "wf_too...
Checks if the object can perform the transition passed in. :returns: True if transition can be performed :rtype: bool
[ "Checks", "if", "the", "object", "can", "perform", "the", "transition", "passed", "in", ".", ":", "returns", ":", "True", "if", "transition", "can", "be", "performed", ":", "rtype", ":", "bool" ]
python
train
fermiPy/fermipy
fermipy/version.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/version.py#L62-L74
def render_pep440(vcs): """Convert git release tag into a form that is PEP440 compliant.""" if vcs is None: return None tags = vcs.split('-') # Bare version number if len(tags) == 1: return tags[0] else: return tags[0] + '+' + '.'.join(tags[1:])
[ "def", "render_pep440", "(", "vcs", ")", ":", "if", "vcs", "is", "None", ":", "return", "None", "tags", "=", "vcs", ".", "split", "(", "'-'", ")", "# Bare version number", "if", "len", "(", "tags", ")", "==", "1", ":", "return", "tags", "[", "0", "...
Convert git release tag into a form that is PEP440 compliant.
[ "Convert", "git", "release", "tag", "into", "a", "form", "that", "is", "PEP440", "compliant", "." ]
python
train
shendo/websnort
websnort/web.py
https://github.com/shendo/websnort/blob/19495e8834a111e889ba28efad8cd90cf55eb661/websnort/web.py#L126-L138
def main(): """ Main entrypoint for command-line webserver. """ parser = argparse.ArgumentParser() parser.add_argument("-H", "--host", help="Web server Host address to bind to", default="0.0.0.0", action="store", required=False) parser.add_argument("-p", "--port", help="W...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"-H\"", ",", "\"--host\"", ",", "help", "=", "\"Web server Host address to bind to\"", ",", "default", "=", "\"0.0.0.0\"", ",", "act...
Main entrypoint for command-line webserver.
[ "Main", "entrypoint", "for", "command", "-", "line", "webserver", "." ]
python
train
KrishnaswamyLab/graphtools
graphtools/graphs.py
https://github.com/KrishnaswamyLab/graphtools/blob/44685352be7df2005d44722903092207967457f2/graphtools/graphs.py#L673-L700
def interpolate(self, transform, transitions=None, Y=None): """Interpolate new data onto a transformation of the graph data One of either transitions or Y should be provided Parameters ---------- transform : array-like, shape=[n_samples, n_transform_features] transiti...
[ "def", "interpolate", "(", "self", ",", "transform", ",", "transitions", "=", "None", ",", "Y", "=", "None", ")", ":", "if", "transitions", "is", "None", "and", "Y", "is", "None", ":", "# assume Y is self.data and use standard landmark transitions", "transitions",...
Interpolate new data onto a transformation of the graph data One of either transitions or Y should be provided Parameters ---------- transform : array-like, shape=[n_samples, n_transform_features] transitions : array-like, optional, shape=[n_samples_y, n_samples] ...
[ "Interpolate", "new", "data", "onto", "a", "transformation", "of", "the", "graph", "data" ]
python
train
AguaClara/aguaclara
aguaclara/design/sed_tank.py
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/design/sed_tank.py#L341-L358
def w_diffuser_inner(sed_inputs=sed_dict): """Return the inner width of each diffuser in the sedimentation tank. Parameters ---------- sed_inputs : dict A dictionary of all of the constant inputs needed for sedimentation tank calculations can be found in sed.yaml Returns ------- ...
[ "def", "w_diffuser_inner", "(", "sed_inputs", "=", "sed_dict", ")", ":", "return", "ut", ".", "ceil_nearest", "(", "w_diffuser_inner_min", "(", "sed_inputs", ")", ".", "magnitude", ",", "(", "np", ".", "arange", "(", "1", "/", "16", ",", "1", "/", "4", ...
Return the inner width of each diffuser in the sedimentation tank. Parameters ---------- sed_inputs : dict A dictionary of all of the constant inputs needed for sedimentation tank calculations can be found in sed.yaml Returns ------- float Inner width of each diffuser in ...
[ "Return", "the", "inner", "width", "of", "each", "diffuser", "in", "the", "sedimentation", "tank", ".", "Parameters", "----------", "sed_inputs", ":", "dict", "A", "dictionary", "of", "all", "of", "the", "constant", "inputs", "needed", "for", "sedimentation", ...
python
train
recurly/recurly-client-python
recurly/resource.py
https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L687-L692
def delete(self): """Submits a deletion request for this `Resource` instance as a ``DELETE`` request to its URL.""" response = self.http_request(self._url, 'DELETE') if response.status != 204: self.raise_http_error(response)
[ "def", "delete", "(", "self", ")", ":", "response", "=", "self", ".", "http_request", "(", "self", ".", "_url", ",", "'DELETE'", ")", "if", "response", ".", "status", "!=", "204", ":", "self", ".", "raise_http_error", "(", "response", ")" ]
Submits a deletion request for this `Resource` instance as a ``DELETE`` request to its URL.
[ "Submits", "a", "deletion", "request", "for", "this", "Resource", "instance", "as", "a", "DELETE", "request", "to", "its", "URL", "." ]
python
train
tanghaibao/goatools
goatools/gosubdag/go_edges.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L69-L76
def _rm_gos_edges_rel(self, rm_goids, edges_rel): """Remove any relationship that contain user-specified edges.""" edges_ret = {} for rname, edges_cur in edges_rel.items(): edges_new = self._rm_gos_edges(rm_goids, edges_cur) if edges_new: edges_ret[rname] ...
[ "def", "_rm_gos_edges_rel", "(", "self", ",", "rm_goids", ",", "edges_rel", ")", ":", "edges_ret", "=", "{", "}", "for", "rname", ",", "edges_cur", "in", "edges_rel", ".", "items", "(", ")", ":", "edges_new", "=", "self", ".", "_rm_gos_edges", "(", "rm_g...
Remove any relationship that contain user-specified edges.
[ "Remove", "any", "relationship", "that", "contain", "user", "-", "specified", "edges", "." ]
python
train
saltstack/salt
salt/modules/boto_iam.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_iam.py#L870-L891
def delete_virtual_mfa_device(serial, region=None, key=None, keyid=None, profile=None): ''' Deletes the specified virtual MFA device. CLI Example: .. code-block:: bash salt myminion boto_iam.delete_virtual_mfa_device serial_num ''' conn = __utils__['boto3.get_connection_func']('iam')(...
[ "def", "delete_virtual_mfa_device", "(", "serial", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "__utils__", "[", "'boto3.get_connection_func'", "]", "(", "'iam'", ")", ...
Deletes the specified virtual MFA device. CLI Example: .. code-block:: bash salt myminion boto_iam.delete_virtual_mfa_device serial_num
[ "Deletes", "the", "specified", "virtual", "MFA", "device", "." ]
python
train
cirruscluster/cirruscluster
cirruscluster/ext/ansible/callbacks.py
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/callbacks.py#L81-L99
def compute(self, runner_results, setup=False, poll=False, ignore_errors=False): ''' walk through all results and increment stats ''' for (host, value) in runner_results.get('contacted', {}).iteritems(): if not ignore_errors and (('failed' in value and bool(value['failed'])) or ...
[ "def", "compute", "(", "self", ",", "runner_results", ",", "setup", "=", "False", ",", "poll", "=", "False", ",", "ignore_errors", "=", "False", ")", ":", "for", "(", "host", ",", "value", ")", "in", "runner_results", ".", "get", "(", "'contacted'", ",...
walk through all results and increment stats
[ "walk", "through", "all", "results", "and", "increment", "stats" ]
python
train
mlperf/training
reinforcement/tensorflow/minigo/oneoffs/eval_sgf_to_cbt.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/oneoffs/eval_sgf_to_cbt.py#L179-L233
def write_eval_records(bt_table, game_data, last_game): """Write all eval_records to eval_table In addition to writing new rows table_state must be updated in row `table_state` columns `metadata:eval_game_counter` Args: bt_table: bigtable table to add rows to. game_data: metadata pairs (c...
[ "def", "write_eval_records", "(", "bt_table", ",", "game_data", ",", "last_game", ")", ":", "eval_num", "=", "last_game", "# Each column counts as a mutation so max rows is ~10000", "GAMES_PER_COMMIT", "=", "2000", "for", "games", "in", "grouper", "(", "tqdm", "(", "g...
Write all eval_records to eval_table In addition to writing new rows table_state must be updated in row `table_state` columns `metadata:eval_game_counter` Args: bt_table: bigtable table to add rows to. game_data: metadata pairs (column name, value) for each eval record. last_game: last...
[ "Write", "all", "eval_records", "to", "eval_table" ]
python
train
phaethon/kamene
kamene/contrib/gsm_um.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1664-L1686
def connectNetToMs(Facility_presence=0, ProgressIndicator_presence=0, ConnectedNumber_presence=0, ConnectedSubaddress_presence=0, UserUser_presence=0): """CONNECT Section 9.3.5.1""" a = TpPd(pd=0x3) b = MessageType(mesType=0x7) # 00000111 packet = a / b if Faci...
[ "def", "connectNetToMs", "(", "Facility_presence", "=", "0", ",", "ProgressIndicator_presence", "=", "0", ",", "ConnectedNumber_presence", "=", "0", ",", "ConnectedSubaddress_presence", "=", "0", ",", "UserUser_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(...
CONNECT Section 9.3.5.1
[ "CONNECT", "Section", "9", ".", "3", ".", "5", ".", "1" ]
python
train
rdussurget/py-altimetry
altimetry/data/alti_data.py
https://github.com/rdussurget/py-altimetry/blob/57ce7f2d63c6bbc4993821af0bbe46929e3a2d98/altimetry/data/alti_data.py#L198-L441
def read_sla(self,filename,params=None,force=False,timerange=None,datatype=None,**kwargs): """ Read AVISO Along-Track products :return outStr: Output data structure containing all recorded parameters as specificied by NetCDF file PARAMETER list. :author: Renaud Du...
[ "def", "read_sla", "(", "self", ",", "filename", ",", "params", "=", "None", ",", "force", "=", "False", ",", "timerange", "=", "None", ",", "datatype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", "time", "import", "time", "from", "dateti...
Read AVISO Along-Track products :return outStr: Output data structure containing all recorded parameters as specificied by NetCDF file PARAMETER list. :author: Renaud Dussurget
[ "Read", "AVISO", "Along", "-", "Track", "products", ":", "return", "outStr", ":", "Output", "data", "structure", "containing", "all", "recorded", "parameters", "as", "specificied", "by", "NetCDF", "file", "PARAMETER", "list", ".", ":", "author", ":", "Renaud",...
python
train
tuxpiper/cloudcast
cloudcast/_utils.py
https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/_utils.py#L3-L12
def caller_folder(): """ Returns the folder where the code of the caller's caller lives """ import inspect caller_file = inspect.stack()[2][1] if os.path.exists(caller_file): return os.path.abspath(os.path.dirname(caller_file)) else: return os.path.abspath(os.getcwd())
[ "def", "caller_folder", "(", ")", ":", "import", "inspect", "caller_file", "=", "inspect", ".", "stack", "(", ")", "[", "2", "]", "[", "1", "]", "if", "os", ".", "path", ".", "exists", "(", "caller_file", ")", ":", "return", "os", ".", "path", ".",...
Returns the folder where the code of the caller's caller lives
[ "Returns", "the", "folder", "where", "the", "code", "of", "the", "caller", "s", "caller", "lives" ]
python
train
fhcrc/taxtastic
taxtastic/refpkg.py
https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/refpkg.py#L247-L254
def resource_name(self, resource): """ Return the name of the file within the reference package for a particular named resource. """ if not(resource in self.contents['files']): raise ValueError("No such resource %r in refpkg" % (resource,)) return self.content...
[ "def", "resource_name", "(", "self", ",", "resource", ")", ":", "if", "not", "(", "resource", "in", "self", ".", "contents", "[", "'files'", "]", ")", ":", "raise", "ValueError", "(", "\"No such resource %r in refpkg\"", "%", "(", "resource", ",", ")", ")"...
Return the name of the file within the reference package for a particular named resource.
[ "Return", "the", "name", "of", "the", "file", "within", "the", "reference", "package", "for", "a", "particular", "named", "resource", "." ]
python
train
buildbot/buildbot
master/buildbot/db/pool.py
https://github.com/buildbot/buildbot/blob/5df3cfae6d760557d99156633c32b1822a1e130c/master/buildbot/db/pool.py#L42-L87
def timed_do_fn(f): """Decorate a do function to log before, after, and elapsed time, with the name of the calling function. This is not speedy!""" def wrap(callable, *args, **kwargs): global _debug_id # get a description of the function that called us st = traceback.extract_stack(...
[ "def", "timed_do_fn", "(", "f", ")", ":", "def", "wrap", "(", "callable", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "global", "_debug_id", "# get a description of the function that called us", "st", "=", "traceback", ".", "extract_stack", "(", "limi...
Decorate a do function to log before, after, and elapsed time, with the name of the calling function. This is not speedy!
[ "Decorate", "a", "do", "function", "to", "log", "before", "after", "and", "elapsed", "time", "with", "the", "name", "of", "the", "calling", "function", ".", "This", "is", "not", "speedy!" ]
python
train
kyuupichan/aiorpcX
aiorpcx/curio.py
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/curio.py#L143-L149
async def spawn(self, coro, *args): '''Create a new task that’s part of the group. Returns a Task instance. ''' task = await spawn(coro, *args, report_crash=False) self._add_task(task) return task
[ "async", "def", "spawn", "(", "self", ",", "coro", ",", "*", "args", ")", ":", "task", "=", "await", "spawn", "(", "coro", ",", "*", "args", ",", "report_crash", "=", "False", ")", "self", ".", "_add_task", "(", "task", ")", "return", "task" ]
Create a new task that’s part of the group. Returns a Task instance.
[ "Create", "a", "new", "task", "that’s", "part", "of", "the", "group", ".", "Returns", "a", "Task", "instance", "." ]
python
train
inasafe/inasafe
safe/report/expressions/infographic.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L228-L232
def age_gender_section_header_element(feature, parent): """Retrieve age gender section header string from definitions.""" _ = feature, parent # NOQA header = age_gender_section_header['string_format'] return header.capitalize()
[ "def", "age_gender_section_header_element", "(", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "header", "=", "age_gender_section_header", "[", "'string_format'", "]", "return", "header", ".", "capitalize", "(", ")" ]
Retrieve age gender section header string from definitions.
[ "Retrieve", "age", "gender", "section", "header", "string", "from", "definitions", "." ]
python
train
SheffieldML/GPy
GPy/util/linalg.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/util/linalg.py#L356-L368
def symmetrify(A, upper=False): """ Take the square matrix A and make it symmetrical by copting elements from the lower half to the upper works IN PLACE. note: tries to use cython, falls back to a slower numpy version """ if use_linalg_cython: _symmetrify_cython(A, upper) else:...
[ "def", "symmetrify", "(", "A", ",", "upper", "=", "False", ")", ":", "if", "use_linalg_cython", ":", "_symmetrify_cython", "(", "A", ",", "upper", ")", "else", ":", "_symmetrify_numpy", "(", "A", ",", "upper", ")" ]
Take the square matrix A and make it symmetrical by copting elements from the lower half to the upper works IN PLACE. note: tries to use cython, falls back to a slower numpy version
[ "Take", "the", "square", "matrix", "A", "and", "make", "it", "symmetrical", "by", "copting", "elements", "from", "the", "lower", "half", "to", "the", "upper" ]
python
train
kiwiz/gkeepapi
gkeepapi/__init__.py
https://github.com/kiwiz/gkeepapi/blob/78aaae8b988b1cf616e3973f7f15d4c6d5e996cc/gkeepapi/__init__.py#L344-L357
def get(self, blob): """Get the canonical link to a media blob. Args: blob (gkeepapi.node.Blob): The blob. Returns: str: A link to the media. """ return self._send( url=self._base_url + blob.parent.server_id + '/' + blob.server_id + '?s=0', ...
[ "def", "get", "(", "self", ",", "blob", ")", ":", "return", "self", ".", "_send", "(", "url", "=", "self", ".", "_base_url", "+", "blob", ".", "parent", ".", "server_id", "+", "'/'", "+", "blob", ".", "server_id", "+", "'?s=0'", ",", "method", "=",...
Get the canonical link to a media blob. Args: blob (gkeepapi.node.Blob): The blob. Returns: str: A link to the media.
[ "Get", "the", "canonical", "link", "to", "a", "media", "blob", "." ]
python
train
cdriehuys/django-rest-email-auth
rest_email_auth/serializers.py
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L89-L115
def validate_email(self, email): """ Validate the provided email address. The email address is first modified to match the RFC spec. Namely, the domain portion of the email is lowercased. Returns: The validated email address. Raises: serializers...
[ "def", "validate_email", "(", "self", ",", "email", ")", ":", "user", ",", "domain", "=", "email", ".", "rsplit", "(", "\"@\"", ",", "1", ")", "email", "=", "\"@\"", ".", "join", "(", "[", "user", ",", "domain", ".", "lower", "(", ")", "]", ")", ...
Validate the provided email address. The email address is first modified to match the RFC spec. Namely, the domain portion of the email is lowercased. Returns: The validated email address. Raises: serializers.ValidationError: If the serializer i...
[ "Validate", "the", "provided", "email", "address", "." ]
python
valid
iskandr/serializable
serializable/primitive_types.py
https://github.com/iskandr/serializable/blob/6807dfd582567b3bda609910806b7429d8d53b44/serializable/primitive_types.py#L26-L36
def return_primitive(fn): """ Decorator which wraps a single argument function to ignore any arguments of primitive type (simply returning them unmodified). """ @wraps(fn) def wrapped_fn(x): if isinstance(x, PRIMITIVE_TYPES): return x return fn(x) return wrapped_f...
[ "def", "return_primitive", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "wrapped_fn", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "PRIMITIVE_TYPES", ")", ":", "return", "x", "return", "fn", "(", "x", ")", "return", "wrapped_fn...
Decorator which wraps a single argument function to ignore any arguments of primitive type (simply returning them unmodified).
[ "Decorator", "which", "wraps", "a", "single", "argument", "function", "to", "ignore", "any", "arguments", "of", "primitive", "type", "(", "simply", "returning", "them", "unmodified", ")", "." ]
python
train
angr/angr
angr/analyses/cfg/cfg_emulated.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/cfg/cfg_emulated.py#L1635-L1821
def _handle_successor(self, job, successor, successors): """ Returns a new CFGJob instance for further analysis, or None if there is no immediate state to perform the analysis on. :param CFGJob job: The current job. """ state = successor all_successor_states = s...
[ "def", "_handle_successor", "(", "self", ",", "job", ",", "successor", ",", "successors", ")", ":", "state", "=", "successor", "all_successor_states", "=", "successors", "addr", "=", "job", ".", "addr", "# The PathWrapper instance to return", "pw", "=", "None", ...
Returns a new CFGJob instance for further analysis, or None if there is no immediate state to perform the analysis on. :param CFGJob job: The current job.
[ "Returns", "a", "new", "CFGJob", "instance", "for", "further", "analysis", "or", "None", "if", "there", "is", "no", "immediate", "state", "to", "perform", "the", "analysis", "on", "." ]
python
train