nwo stringlengths 5 106 | sha stringlengths 40 40 | path stringlengths 4 174 | language stringclasses 1
value | identifier stringlengths 1 140 | parameters stringlengths 0 87.7k | argument_list stringclasses 1
value | return_statement stringlengths 0 426k | docstring stringlengths 0 64.3k | docstring_summary stringlengths 0 26.3k | docstring_tokens list | function stringlengths 18 4.83M | function_tokens list | url stringlengths 83 304 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
zopefoundation/Zope | ea04dd670d1a48d4d5c879d3db38fc2e9b4330bb | src/Products/Five/fiveconfigure.py | python | pagesFromDirectory | (_context, directory, module, for_=None,
layer=IDefaultBrowserLayer, permission='zope.Public') | [] | def pagesFromDirectory(_context, directory, module, for_=None,
layer=IDefaultBrowserLayer, permission='zope.Public'):
if isinstance(module, str):
module = _context.resolve(module)
_prefix = os.path.dirname(module.__file__)
directory = os.path.join(_prefix, directory)
if... | [
"def",
"pagesFromDirectory",
"(",
"_context",
",",
"directory",
",",
"module",
",",
"for_",
"=",
"None",
",",
"layer",
"=",
"IDefaultBrowserLayer",
",",
"permission",
"=",
"'zope.Public'",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"str",
")",
":",
... | https://github.com/zopefoundation/Zope/blob/ea04dd670d1a48d4d5c879d3db38fc2e9b4330bb/src/Products/Five/fiveconfigure.py#L32-L49 | ||||
pm4py/pm4py-core | 7807b09a088b02199cd0149d724d0e28793971bf | pm4py/objects/petri_net/utils/petri_utils.py | python | get_cycles_petri_net_places | (net) | return cycles_places | Get the cycles of a Petri net (returning only list of places belonging to the cycle)
Parameters
-------------
net
Petri net
Returns
-------------
cycles
Cycles (places) of the Petri net | Get the cycles of a Petri net (returning only list of places belonging to the cycle) | [
"Get",
"the",
"cycles",
"of",
"a",
"Petri",
"net",
"(",
"returning",
"only",
"list",
"of",
"places",
"belonging",
"to",
"the",
"cycle",
")"
] | def get_cycles_petri_net_places(net):
"""
Get the cycles of a Petri net (returning only list of places belonging to the cycle)
Parameters
-------------
net
Petri net
Returns
-------------
cycles
Cycles (places) of the Petri net
"""
import networkx as nx
gra... | [
"def",
"get_cycles_petri_net_places",
"(",
"net",
")",
":",
"import",
"networkx",
"as",
"nx",
"graph",
",",
"inv_dictionary",
"=",
"create_networkx_directed_graph",
"(",
"net",
")",
"cycles",
"=",
"nx",
".",
"simple_cycles",
"(",
"graph",
")",
"cycles_places",
"... | https://github.com/pm4py/pm4py-core/blob/7807b09a088b02199cd0149d724d0e28793971bf/pm4py/objects/petri_net/utils/petri_utils.py#L323-L347 | |
SanPen/GridCal | d3f4566d2d72c11c7e910c9d162538ef0e60df31 | src/GridCal/Engine/Simulations/Dynamics/transient_stability_driver.py | python | TransientStability.run | (self) | Run transient stability | Run transient stability | [
"Run",
"transient",
"stability"
] | def run(self):
"""
Run transient stability
"""
self.progress_signal.emit(0.0)
self.progress_text.emit('Running transient stability...')
# print('Compiling...', end='')
numerical_circuit = self.grid.compile_snapshot()
calculation_inputs = numerical_circuit... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"progress_signal",
".",
"emit",
"(",
"0.0",
")",
"self",
".",
"progress_text",
".",
"emit",
"(",
"'Running transient stability...'",
")",
"# print('Compiling...', end='')",
"numerical_circuit",
"=",
"self",
".",
... | https://github.com/SanPen/GridCal/blob/d3f4566d2d72c11c7e910c9d162538ef0e60df31/src/GridCal/Engine/Simulations/Dynamics/transient_stability_driver.py#L78-L106 | ||
apple/ccs-calendarserver | 13c706b985fb728b9aab42dc0fef85aae21921c3 | twistedcaldav/config.py | python | Config.reload | (self) | [] | def reload(self):
configDict = self._provider.loadConfig()
if not self._provider.hasErrors():
if self._beforeResetHook:
# Give the beforeResetHook a chance to stash away values we want
# to preserve across the reload( )
preserved = self._before... | [
"def",
"reload",
"(",
"self",
")",
":",
"configDict",
"=",
"self",
".",
"_provider",
".",
"loadConfig",
"(",
")",
"if",
"not",
"self",
".",
"_provider",
".",
"hasErrors",
"(",
")",
":",
"if",
"self",
".",
"_beforeResetHook",
":",
"# Give the beforeResetHoo... | https://github.com/apple/ccs-calendarserver/blob/13c706b985fb728b9aab42dc0fef85aae21921c3/twistedcaldav/config.py#L255-L272 | ||||
log2timeline/dfvfs | 4ca7bf06b15cdc000297a7122a065f0ca71de544 | dfvfs/vfs/hfs_file_system.py | python | HFSFileSystem.GetRootFileEntry | (self) | return self.GetFileEntryByPathSpec(path_spec) | Retrieves the root file entry.
Returns:
HFSFileEntry: file entry. | Retrieves the root file entry. | [
"Retrieves",
"the",
"root",
"file",
"entry",
"."
] | def GetRootFileEntry(self):
"""Retrieves the root file entry.
Returns:
HFSFileEntry: file entry.
"""
path_spec = hfs_path_spec.HFSPathSpec(
location=self.LOCATION_ROOT,
identifier=self.ROOT_DIRECTORY_IDENTIFIER_NUMBER,
parent=self._path_spec.parent)
return self.GetFile... | [
"def",
"GetRootFileEntry",
"(",
"self",
")",
":",
"path_spec",
"=",
"hfs_path_spec",
".",
"HFSPathSpec",
"(",
"location",
"=",
"self",
".",
"LOCATION_ROOT",
",",
"identifier",
"=",
"self",
".",
"ROOT_DIRECTORY_IDENTIFIER_NUMBER",
",",
"parent",
"=",
"self",
".",... | https://github.com/log2timeline/dfvfs/blob/4ca7bf06b15cdc000297a7122a065f0ca71de544/dfvfs/vfs/hfs_file_system.py#L164-L174 | |
rembo10/headphones | b3199605be1ebc83a7a8feab6b1e99b64014187c | lib/configobj.py | python | ConfigObj.reset | (self) | Clear ConfigObj instance and restore to 'freshly created' state. | Clear ConfigObj instance and restore to 'freshly created' state. | [
"Clear",
"ConfigObj",
"instance",
"and",
"restore",
"to",
"freshly",
"created",
"state",
"."
] | def reset(self):
"""Clear ConfigObj instance and restore to 'freshly created' state."""
self.clear()
self._initialise()
# FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload)
# requires an empty dictionary
self.configspec = None
# ... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"clear",
"(",
")",
"self",
".",
"_initialise",
"(",
")",
"# FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload)",
"# requires an empty dictionary",
"self",
".",
"configspec",
"=",
"None"... | https://github.com/rembo10/headphones/blob/b3199605be1ebc83a7a8feab6b1e99b64014187c/lib/configobj.py#L2323-L2331 | ||
TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e | deep-learning/NLP/Seq2Seq-PyTorch/decode.py | python | BeamSearchDecoder.get_hidden_representation | (self, input) | return src_h, (h_t, c_t) | Get hidden representation for a sentence. | Get hidden representation for a sentence. | [
"Get",
"hidden",
"representation",
"for",
"a",
"sentence",
"."
] | def get_hidden_representation(self, input):
"""Get hidden representation for a sentence."""
src_emb = self.model.src_embedding(input)
h0_encoder, c0_encoder = self.model.get_state(src_emb)
src_h, (src_h_t, src_c_t) = self.model.encoder(
src_emb, (h0_encoder, c0_encoder)
... | [
"def",
"get_hidden_representation",
"(",
"self",
",",
"input",
")",
":",
"src_emb",
"=",
"self",
".",
"model",
".",
"src_embedding",
"(",
"input",
")",
"h0_encoder",
",",
"c0_encoder",
"=",
"self",
".",
"model",
".",
"get_state",
"(",
"src_emb",
")",
"src_... | https://github.com/TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials/blob/5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e/deep-learning/NLP/Seq2Seq-PyTorch/decode.py#L80-L95 | |
p2pool/p2pool | 53c438bbada06b9d4a9a465bc13f7694a7a322b7 | p2pool/util/expiring_dict.py | python | Node.connect | (prev, next) | [] | def connect(prev, next):
if prev.next is not None or next.prev is not None:
raise ValueError('node already connected')
prev.next, next.prev = next, prev | [
"def",
"connect",
"(",
"prev",
",",
"next",
")",
":",
"if",
"prev",
".",
"next",
"is",
"not",
"None",
"or",
"next",
".",
"prev",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"'node already connected'",
")",
"prev",
".",
"next",
",",
"next",
... | https://github.com/p2pool/p2pool/blob/53c438bbada06b9d4a9a465bc13f7694a7a322b7/p2pool/util/expiring_dict.py#L21-L24 | ||||
python/cpython | e13cdca0f5224ec4e23bdd04bb3120506964bc8b | Lib/idlelib/tree.py | python | TreeItem.IsEditable | (self) | Return whether the item's text may be edited. | Return whether the item's text may be edited. | [
"Return",
"whether",
"the",
"item",
"s",
"text",
"may",
"be",
"edited",
"."
] | def IsEditable(self):
"""Return whether the item's text may be edited.""" | [
"def",
"IsEditable",
"(",
"self",
")",
":"
] | https://github.com/python/cpython/blob/e13cdca0f5224ec4e23bdd04bb3120506964bc8b/Lib/idlelib/tree.py#L372-L373 | ||
genforce/idinvert | 138266724c7c8709fa4b2565c1f8e648ae5c6641 | dnnlib/submission/run_context.py | python | RunContext.update | (self, loss: Any = 0, cur_epoch: Any = 0, max_epoch: Any = None) | Do general housekeeping and keep the state of the context up-to-date.
Should be called often enough but not in a tight loop. | Do general housekeeping and keep the state of the context up-to-date.
Should be called often enough but not in a tight loop. | [
"Do",
"general",
"housekeeping",
"and",
"keep",
"the",
"state",
"of",
"the",
"context",
"up",
"-",
"to",
"-",
"date",
".",
"Should",
"be",
"called",
"often",
"enough",
"but",
"not",
"in",
"a",
"tight",
"loop",
"."
] | def update(self, loss: Any = 0, cur_epoch: Any = 0, max_epoch: Any = None) -> None:
"""Do general housekeeping and keep the state of the context up-to-date.
Should be called often enough but not in a tight loop."""
assert not self.has_closed
self.last_update_interval = time.time() - sel... | [
"def",
"update",
"(",
"self",
",",
"loss",
":",
"Any",
"=",
"0",
",",
"cur_epoch",
":",
"Any",
"=",
"0",
",",
"max_epoch",
":",
"Any",
"=",
"None",
")",
"->",
"None",
":",
"assert",
"not",
"self",
".",
"has_closed",
"self",
".",
"last_update_interval... | https://github.com/genforce/idinvert/blob/138266724c7c8709fa4b2565c1f8e648ae5c6641/dnnlib/submission/run_context.py#L61-L72 | ||
coherence-project/Coherence | 88016204c7778bf0d3ad1ae331b4d8fd725dd2af | coherence/extern/et.py | python | textElement | (parent, tag, namespace, text) | return elem | Create a subelement with text content. | Create a subelement with text content. | [
"Create",
"a",
"subelement",
"with",
"text",
"content",
"."
] | def textElement(parent, tag, namespace, text):
"""Create a subelement with text content."""
elem = ET.SubElement(parent, qname(tag, namespace))
elem.text = text
return elem | [
"def",
"textElement",
"(",
"parent",
",",
"tag",
",",
"namespace",
",",
"text",
")",
":",
"elem",
"=",
"ET",
".",
"SubElement",
"(",
"parent",
",",
"qname",
"(",
"tag",
",",
"namespace",
")",
")",
"elem",
".",
"text",
"=",
"text",
"return",
"elem"
] | https://github.com/coherence-project/Coherence/blob/88016204c7778bf0d3ad1ae331b4d8fd725dd2af/coherence/extern/et.py#L145-L149 | |
kennethreitz-archive/requests3 | 69eb662703b40db58fdc6c095d0fe130c56649bb | requests3/http_adapters.py | python | HTTPAdapter.build_response | (self, req, resp) | return response | Builds a :class:`Response <requests.Response>` object from a urllib3
response. This should not be called from user code, and is only exposed
for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
:param req: The :class:`PreparedRequest <PreparedRequest>` used ... | Builds a :class:`Response <requests.Response>` object from a urllib3
response. This should not be called from user code, and is only exposed
for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>` | [
"Builds",
"a",
":",
"class",
":",
"Response",
"<requests",
".",
"Response",
">",
"object",
"from",
"a",
"urllib3",
"response",
".",
"This",
"should",
"not",
"be",
"called",
"from",
"user",
"code",
"and",
"is",
"only",
"exposed",
"for",
"use",
"when",
"su... | def build_response(self, req, resp):
"""Builds a :class:`Response <requests.Response>` object from a urllib3
response. This should not be called from user code, and is only exposed
for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
:param req: The ... | [
"def",
"build_response",
"(",
"self",
",",
"req",
",",
"resp",
")",
":",
"response",
"=",
"Response",
"(",
")",
"# Fallback to None if there's no status_code, for whatever reason.",
"response",
".",
"status_code",
"=",
"getattr",
"(",
"resp",
",",
"\"status_code\"",
... | https://github.com/kennethreitz-archive/requests3/blob/69eb662703b40db58fdc6c095d0fe130c56649bb/requests3/http_adapters.py#L204-L233 | |
hardmaru/resnet-cppn-gan-tensorflow | 9206e06512c118e932fbc789c91a5cf4f9e5d2b9 | mnist_data.py | python | extract_images | (filename) | Extract the images into a 4D uint8 numpy array [index, y, x, depth]. | Extract the images into a 4D uint8 numpy array [index, y, x, depth]. | [
"Extract",
"the",
"images",
"into",
"a",
"4D",
"uint8",
"numpy",
"array",
"[",
"index",
"y",
"x",
"depth",
"]",
"."
] | def extract_images(filename):
"""Extract the images into a 4D uint8 numpy array [index, y, x, depth]."""
print('Extracting', filename)
with gzip.open(filename) as bytestream:
magic = _read32(bytestream)
if magic != 2051:
raise ValueError(
'Invalid magic number %d in MNIST image file: %s' %... | [
"def",
"extract_images",
"(",
"filename",
")",
":",
"print",
"(",
"'Extracting'",
",",
"filename",
")",
"with",
"gzip",
".",
"open",
"(",
"filename",
")",
"as",
"bytestream",
":",
"magic",
"=",
"_read32",
"(",
"bytestream",
")",
"if",
"magic",
"!=",
"205... | https://github.com/hardmaru/resnet-cppn-gan-tensorflow/blob/9206e06512c118e932fbc789c91a5cf4f9e5d2b9/mnist_data.py#L24-L39 | ||
pymedusa/Medusa | 1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38 | ext/boto/regioninfo.py | python | merge_endpoints | (defaults, additions) | return defaults | Given an existing set of endpoint data, this will deep-update it with
any similarly structured data in the additions.
:param defaults: The existing endpoints data
:type defaults: dict
:param defaults: The additional endpoints data
:type defaults: dict
:returns: The modified endpoints data
... | Given an existing set of endpoint data, this will deep-update it with
any similarly structured data in the additions. | [
"Given",
"an",
"existing",
"set",
"of",
"endpoint",
"data",
"this",
"will",
"deep",
"-",
"update",
"it",
"with",
"any",
"similarly",
"structured",
"data",
"in",
"the",
"additions",
"."
] | def merge_endpoints(defaults, additions):
"""
Given an existing set of endpoint data, this will deep-update it with
any similarly structured data in the additions.
:param defaults: The existing endpoints data
:type defaults: dict
:param defaults: The additional endpoints data
:type default... | [
"def",
"merge_endpoints",
"(",
"defaults",
",",
"additions",
")",
":",
"# We can't just do an ``defaults.update(...)`` here, as that could",
"# *overwrite* regions if present in both.",
"# We'll iterate instead, essentially doing a deeper merge.",
"for",
"service",
",",
"region_info",
... | https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/ext/boto/regioninfo.py#L60-L82 | |
quantumlib/OpenFermion | 6187085f2a7707012b68370b625acaeed547e62b | src/openfermion/transforms/opconversions/bravyi_kitaev.py | python | _occupation_set | (index) | return indices | The bits whose parity stores the occupation of mode `index`. | The bits whose parity stores the occupation of mode `index`. | [
"The",
"bits",
"whose",
"parity",
"stores",
"the",
"occupation",
"of",
"mode",
"index",
"."
] | def _occupation_set(index):
"""The bits whose parity stores the occupation of mode `index`."""
indices = set()
# For bit manipulation we need to count from 1 rather than 0
index += 1
indices.add(index - 1)
parent = index & (index - 1)
index -= 1
while index != parent:
indices.a... | [
"def",
"_occupation_set",
"(",
"index",
")",
":",
"indices",
"=",
"set",
"(",
")",
"# For bit manipulation we need to count from 1 rather than 0",
"index",
"+=",
"1",
"indices",
".",
"add",
"(",
"index",
"-",
"1",
")",
"parent",
"=",
"index",
"&",
"(",
"index"... | https://github.com/quantumlib/OpenFermion/blob/6187085f2a7707012b68370b625acaeed547e62b/src/openfermion/transforms/opconversions/bravyi_kitaev.py#L72-L87 | |
CharlesShang/FastMaskRCNN | bdae07702acccd85803e658f5e49690981efcdb2 | libs/boxes/anchor.py | python | _scale_enum | (anchor, scales) | return anchors | Enumerate a set of anchors for each scale wrt an anchor. | Enumerate a set of anchors for each scale wrt an anchor. | [
"Enumerate",
"a",
"set",
"of",
"anchors",
"for",
"each",
"scale",
"wrt",
"an",
"anchor",
"."
] | def _scale_enum(anchor, scales):
"""
Enumerate a set of anchors for each scale wrt an anchor.
"""
w, h, x_ctr, y_ctr = _whctrs(anchor)
ws = w * scales
hs = h * scales
anchors = _mkanchors(ws, hs, x_ctr, y_ctr)
return anchors | [
"def",
"_scale_enum",
"(",
"anchor",
",",
"scales",
")",
":",
"w",
",",
"h",
",",
"x_ctr",
",",
"y_ctr",
"=",
"_whctrs",
"(",
"anchor",
")",
"ws",
"=",
"w",
"*",
"scales",
"hs",
"=",
"h",
"*",
"scales",
"anchors",
"=",
"_mkanchors",
"(",
"ws",
",... | https://github.com/CharlesShang/FastMaskRCNN/blob/bdae07702acccd85803e658f5e49690981efcdb2/libs/boxes/anchor.py#L82-L91 | |
tp4a/teleport | 1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad | server/www/packages/packages-linux/x64/cffi/vengine_gen.py | python | VGenericEngine._loaded_gen_enum | (self, tp, name, module, library) | [] | def _loaded_gen_enum(self, tp, name, module, library):
for enumerator, enumvalue in zip(tp.enumerators, tp.enumvalues):
setattr(library, enumerator, enumvalue)
type(library)._cffi_dir.append(enumerator) | [
"def",
"_loaded_gen_enum",
"(",
"self",
",",
"tp",
",",
"name",
",",
"module",
",",
"library",
")",
":",
"for",
"enumerator",
",",
"enumvalue",
"in",
"zip",
"(",
"tp",
".",
"enumerators",
",",
"tp",
".",
"enumvalues",
")",
":",
"setattr",
"(",
"library... | https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-linux/x64/cffi/vengine_gen.py#L536-L539 | ||||
ambakick/Person-Detection-and-Tracking | f925394ac29b5cf321f1ce89a71b193381519a0b | utils/np_box_list_ops.py | python | clip_to_window | (boxlist, window) | return gather(clipped, nonzero_area_indices) | Clip bounding boxes to a window.
This op clips input bounding boxes (represented by bounding box
corners) to a window, optionally filtering out boxes that do not
overlap at all with the window.
Args:
boxlist: BoxList holding M_in boxes
window: a numpy array of shape [4] representing the
[y... | Clip bounding boxes to a window. | [
"Clip",
"bounding",
"boxes",
"to",
"a",
"window",
"."
] | def clip_to_window(boxlist, window):
"""Clip bounding boxes to a window.
This op clips input bounding boxes (represented by bounding box
corners) to a window, optionally filtering out boxes that do not
overlap at all with the window.
Args:
boxlist: BoxList holding M_in boxes
window: a numpy array of... | [
"def",
"clip_to_window",
"(",
"boxlist",
",",
"window",
")",
":",
"y_min",
",",
"x_min",
",",
"y_max",
",",
"x_max",
"=",
"np",
".",
"array_split",
"(",
"boxlist",
".",
"get",
"(",
")",
",",
"4",
",",
"axis",
"=",
"1",
")",
"win_y_min",
"=",
"windo... | https://github.com/ambakick/Person-Detection-and-Tracking/blob/f925394ac29b5cf321f1ce89a71b193381519a0b/utils/np_box_list_ops.py#L334-L365 | |
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/sympy/sympy/polys/polyclasses.py | python | DMP.to_ring | (f) | return f.convert(f.dom.get_ring()) | Make the ground domain a ring. | Make the ground domain a ring. | [
"Make",
"the",
"ground",
"domain",
"a",
"ring",
"."
] | def to_ring(f):
"""Make the ground domain a ring. """
return f.convert(f.dom.get_ring()) | [
"def",
"to_ring",
"(",
"f",
")",
":",
"return",
"f",
".",
"convert",
"(",
"f",
".",
"dom",
".",
"get_ring",
"(",
")",
")"
] | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/polys/polyclasses.py#L265-L267 | |
compas-dev/compas | 0b33f8786481f710115fb1ae5fe79abc2a9a5175 | src/compas/datastructures/network/network.py | python | Network.node_coordinates | (self, key, axes='xyz') | return [self.node[key][axis] for axis in axes] | Return the coordinates of a node.
Parameters
----------
key : hashable
The identifier of the node.
axes : str, optional
The components of the node coordinates to return.
Default is ``'xyz'``.
Returns
-------
list
T... | Return the coordinates of a node. | [
"Return",
"the",
"coordinates",
"of",
"a",
"node",
"."
] | def node_coordinates(self, key, axes='xyz'):
"""Return the coordinates of a node.
Parameters
----------
key : hashable
The identifier of the node.
axes : str, optional
The components of the node coordinates to return.
Default is ``'xyz'``.
... | [
"def",
"node_coordinates",
"(",
"self",
",",
"key",
",",
"axes",
"=",
"'xyz'",
")",
":",
"return",
"[",
"self",
".",
"node",
"[",
"key",
"]",
"[",
"axis",
"]",
"for",
"axis",
"in",
"axes",
"]"
] | https://github.com/compas-dev/compas/blob/0b33f8786481f710115fb1ae5fe79abc2a9a5175/src/compas/datastructures/network/network.py#L362-L378 | |
cloudera/hue | 23f02102d4547c17c32bd5ea0eb24e9eadd657a4 | desktop/core/ext-py/boto-2.46.1/boto/ec2/connection.py | python | EC2Connection.describe_account_attributes | (self, attribute_names=None, dry_run=False) | return self.get_list('DescribeAccountAttributes', params,
[('item', AccountAttribute)], verb='POST') | :type dry_run: bool
:param dry_run: Set to True if the operation should not actually run. | :type dry_run: bool
:param dry_run: Set to True if the operation should not actually run. | [
":",
"type",
"dry_run",
":",
"bool",
":",
"param",
"dry_run",
":",
"Set",
"to",
"True",
"if",
"the",
"operation",
"should",
"not",
"actually",
"run",
"."
] | def describe_account_attributes(self, attribute_names=None, dry_run=False):
"""
:type dry_run: bool
:param dry_run: Set to True if the operation should not actually run.
"""
params = {}
if attribute_names is not None:
self.build_list_params(params, attribute_... | [
"def",
"describe_account_attributes",
"(",
"self",
",",
"attribute_names",
"=",
"None",
",",
"dry_run",
"=",
"False",
")",
":",
"params",
"=",
"{",
"}",
"if",
"attribute_names",
"is",
"not",
"None",
":",
"self",
".",
"build_list_params",
"(",
"params",
",",
... | https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/boto-2.46.1/boto/ec2/connection.py#L4435-L4447 | |
HymanLiuTS/flaskTs | 286648286976e85d9b9a5873632331efcafe0b21 | flasky/lib/python2.7/site-packages/sqlalchemy/sql/elements.py | python | Cast.__init__ | (self, expression, type_) | Produce a ``CAST`` expression.
:func:`.cast` returns an instance of :class:`.Cast`.
E.g.::
from sqlalchemy import cast, Numeric
stmt = select([
cast(product_table.c.unit_price, Numeric(10, 4))
])
The above statement will pr... | Produce a ``CAST`` expression. | [
"Produce",
"a",
"CAST",
"expression",
"."
] | def __init__(self, expression, type_):
"""Produce a ``CAST`` expression.
:func:`.cast` returns an instance of :class:`.Cast`.
E.g.::
from sqlalchemy import cast, Numeric
stmt = select([
cast(product_table.c.unit_price, Numeric(10, 4))
... | [
"def",
"__init__",
"(",
"self",
",",
"expression",
",",
"type_",
")",
":",
"self",
".",
"type",
"=",
"type_api",
".",
"to_instance",
"(",
"type_",
")",
"self",
".",
"clause",
"=",
"_literal_as_binds",
"(",
"expression",
",",
"type_",
"=",
"self",
".",
... | https://github.com/HymanLiuTS/flaskTs/blob/286648286976e85d9b9a5873632331efcafe0b21/flasky/lib/python2.7/site-packages/sqlalchemy/sql/elements.py#L2290-L2341 | ||
lohriialo/photoshop-scripting-python | 6b97da967a5d0a45e54f7c99631b29773b923f09 | api_reference/photoshop_2020.py | python | _GallerySecurityOptions.SetTextColor | (self, arg0=defaultUnnamedArg) | return self._oleobj_.InvokeTypes(1346844722, LCID, 8, (24, 0), ((9, 0),),arg0
) | web page security text color | web page security text color | [
"web",
"page",
"security",
"text",
"color"
] | def SetTextColor(self, arg0=defaultUnnamedArg):
'web page security text color'
return self._oleobj_.InvokeTypes(1346844722, LCID, 8, (24, 0), ((9, 0),),arg0
) | [
"def",
"SetTextColor",
"(",
"self",
",",
"arg0",
"=",
"defaultUnnamedArg",
")",
":",
"return",
"self",
".",
"_oleobj_",
".",
"InvokeTypes",
"(",
"1346844722",
",",
"LCID",
",",
"8",
",",
"(",
"24",
",",
"0",
")",
",",
"(",
"(",
"9",
",",
"0",
")",
... | https://github.com/lohriialo/photoshop-scripting-python/blob/6b97da967a5d0a45e54f7c99631b29773b923f09/api_reference/photoshop_2020.py#L5158-L5161 | |
spulec/moto | a688c0032596a7dfef122b69a08f2bec3be2e481 | scripts/scaffold.py | python | initialize_service | (service, api_protocol) | Create lib and test dirs if they don't exist. | Create lib and test dirs if they don't exist. | [
"Create",
"lib",
"and",
"test",
"dirs",
"if",
"they",
"don",
"t",
"exist",
"."
] | def initialize_service(service, api_protocol):
"""Create lib and test dirs if they don't exist."""
lib_dir = get_lib_dir(service)
test_dir = get_test_dir(service)
print_progress("Initializing service", service, "green")
client = boto3.client(service)
service_class = client.__class__.__name__
... | [
"def",
"initialize_service",
"(",
"service",
",",
"api_protocol",
")",
":",
"lib_dir",
"=",
"get_lib_dir",
"(",
"service",
")",
"test_dir",
"=",
"get_test_dir",
"(",
"service",
")",
"print_progress",
"(",
"\"Initializing service\"",
",",
"service",
",",
"\"green\"... | https://github.com/spulec/moto/blob/a688c0032596a7dfef122b69a08f2bec3be2e481/scripts/scaffold.py#L169-L217 | ||
dropbox/dropbox-sdk-python | 015437429be224732990041164a21a0501235db1 | dropbox/files.py | python | GetThumbnailBatchResultEntry.failure | (cls, val) | return cls('failure', val) | Create an instance of this class set to the ``failure`` tag with value
``val``.
:param ThumbnailError val:
:rtype: GetThumbnailBatchResultEntry | Create an instance of this class set to the ``failure`` tag with value
``val``. | [
"Create",
"an",
"instance",
"of",
"this",
"class",
"set",
"to",
"the",
"failure",
"tag",
"with",
"value",
"val",
"."
] | def failure(cls, val):
"""
Create an instance of this class set to the ``failure`` tag with value
``val``.
:param ThumbnailError val:
:rtype: GetThumbnailBatchResultEntry
"""
return cls('failure', val) | [
"def",
"failure",
"(",
"cls",
",",
"val",
")",
":",
"return",
"cls",
"(",
"'failure'",
",",
"val",
")"
] | https://github.com/dropbox/dropbox-sdk-python/blob/015437429be224732990041164a21a0501235db1/dropbox/files.py#L3413-L3421 | |
learningequality/ka-lite | 571918ea668013dcf022286ea85eff1c5333fb8b | kalite/packages/bundled/django/db/backends/util.py | python | format_number | (value, max_digits, decimal_places) | Formats a number into a string with the requisite number of digits and
decimal places. | Formats a number into a string with the requisite number of digits and
decimal places. | [
"Formats",
"a",
"number",
"into",
"a",
"string",
"with",
"the",
"requisite",
"number",
"of",
"digits",
"and",
"decimal",
"places",
"."
] | def format_number(value, max_digits, decimal_places):
"""
Formats a number into a string with the requisite number of digits and
decimal places.
"""
if isinstance(value, decimal.Decimal):
context = decimal.getcontext().copy()
context.prec = max_digits
return '%s' % str(value.... | [
"def",
"format_number",
"(",
"value",
",",
"max_digits",
",",
"decimal_places",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"decimal",
".",
"Decimal",
")",
":",
"context",
"=",
"decimal",
".",
"getcontext",
"(",
")",
".",
"copy",
"(",
")",
"context"... | https://github.com/learningequality/ka-lite/blob/571918ea668013dcf022286ea85eff1c5333fb8b/kalite/packages/bundled/django/db/backends/util.py#L142-L152 | ||
tobegit3hub/deep_image_model | 8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e | java_predict_client/src/main/proto/tensorflow/contrib/framework/python/framework/experimental.py | python | _add_experimental_function_notice_to_docstring | (doc) | return decorator_utils.add_notice_to_docstring(
doc, '',
'EXPERIMENTAL FUNCTION',
'(experimental)', ['THIS FUNCTION IS EXPERIMENTAL. It may change or '
'be removed at any time, and without warning.']) | Adds an experimental notice to a docstring for experimental functions. | Adds an experimental notice to a docstring for experimental functions. | [
"Adds",
"an",
"experimental",
"notice",
"to",
"a",
"docstring",
"for",
"experimental",
"functions",
"."
] | def _add_experimental_function_notice_to_docstring(doc):
"""Adds an experimental notice to a docstring for experimental functions."""
return decorator_utils.add_notice_to_docstring(
doc, '',
'EXPERIMENTAL FUNCTION',
'(experimental)', ['THIS FUNCTION IS EXPERIMENTAL. It may change or '
... | [
"def",
"_add_experimental_function_notice_to_docstring",
"(",
"doc",
")",
":",
"return",
"decorator_utils",
".",
"add_notice_to_docstring",
"(",
"doc",
",",
"''",
",",
"'EXPERIMENTAL FUNCTION'",
",",
"'(experimental)'",
",",
"[",
"'THIS FUNCTION IS EXPERIMENTAL. It may change... | https://github.com/tobegit3hub/deep_image_model/blob/8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e/java_predict_client/src/main/proto/tensorflow/contrib/framework/python/framework/experimental.py#L27-L33 | |
leo-editor/leo-editor | 383d6776d135ef17d73d935a2f0ecb3ac0e99494 | leo/commands/commanderOutlineCommands.py | python | expandLevel4 | (self, event=None) | Expand the outline to level 4 | Expand the outline to level 4 | [
"Expand",
"the",
"outline",
"to",
"level",
"4"
] | def expandLevel4(self, event=None):
"""Expand the outline to level 4"""
self.expandToLevel(4) | [
"def",
"expandLevel4",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"self",
".",
"expandToLevel",
"(",
"4",
")"
] | https://github.com/leo-editor/leo-editor/blob/383d6776d135ef17d73d935a2f0ecb3ac0e99494/leo/commands/commanderOutlineCommands.py#L474-L476 | ||
mozman/ezdxf | 59d0fc2ea63f5cf82293428f5931da7e9f9718e9 | src/ezdxf/entities/dxfentity.py | python | DXFEntity.discard_app_data | (self, appid: str) | Discard application defined data for `appid`. Does not raise an
exception if no data for `appid` exist. | Discard application defined data for `appid`. Does not raise an
exception if no data for `appid` exist. | [
"Discard",
"application",
"defined",
"data",
"for",
"appid",
".",
"Does",
"not",
"raise",
"an",
"exception",
"if",
"no",
"data",
"for",
"appid",
"exist",
"."
] | def discard_app_data(self, appid: str):
"""Discard application defined data for `appid`. Does not raise an
exception if no data for `appid` exist.
"""
if self.appdata:
self.appdata.discard(appid) | [
"def",
"discard_app_data",
"(",
"self",
",",
"appid",
":",
"str",
")",
":",
"if",
"self",
".",
"appdata",
":",
"self",
".",
"appdata",
".",
"discard",
"(",
"appid",
")"
] | https://github.com/mozman/ezdxf/blob/59d0fc2ea63f5cf82293428f5931da7e9f9718e9/src/ezdxf/entities/dxfentity.py#L819-L824 | ||
AstroPrint/AstroBox | e7e3b8a7d33ea85fcb6b2696869c0d719ceb8b75 | src/astroprint/api/files.py | python | readPrintFile | (target, filename) | return jsonify(file) | [] | def readPrintFile(target, filename):
if not target in [FileDestinations.LOCAL, FileDestinations.SDCARD]:
return make_response("Unknown target: %s" % target, 404)
file = _getFileDetails(target, filename)
if not file:
return make_response("File not found on '%s': %s" % (target, filename), 404)
return jsonify(fi... | [
"def",
"readPrintFile",
"(",
"target",
",",
"filename",
")",
":",
"if",
"not",
"target",
"in",
"[",
"FileDestinations",
".",
"LOCAL",
",",
"FileDestinations",
".",
"SDCARD",
"]",
":",
"return",
"make_response",
"(",
"\"Unknown target: %s\"",
"%",
"target",
","... | https://github.com/AstroPrint/AstroBox/blob/e7e3b8a7d33ea85fcb6b2696869c0d719ceb8b75/src/astroprint/api/files.py#L207-L215 | |||
OmkarPathak/Python-Programs | ed96a4f7b2ddcad5be6c6a0f13cff89975731b77 | Programs/P34_Stack.py | python | Stack.isEmpty | (self) | return len(self.index) == [] | Checks whether the stack is empty | Checks whether the stack is empty | [
"Checks",
"whether",
"the",
"stack",
"is",
"empty"
] | def isEmpty(self):
''' Checks whether the stack is empty '''
return len(self.index) == [] | [
"def",
"isEmpty",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"index",
")",
"==",
"[",
"]"
] | https://github.com/OmkarPathak/Python-Programs/blob/ed96a4f7b2ddcad5be6c6a0f13cff89975731b77/Programs/P34_Stack.py#L29-L31 | |
akshaychawla/Adversarial-Examples-in-PyTorch | e9e4e1052c5a1147f0885b6f6248645167283dd3 | method2-FastGradientSignMethod/mnist-fast-gradient.py | python | Net.classify | (self, x) | return int(max_idx.data.numpy()), float(max_val.data.numpy()) | [] | def classify(self, x):
outputs = self.forward(x)
outputs = outputs / torch.norm(outputs)
max_val, max_idx = torch.max(outputs, 1)
return int(max_idx.data.numpy()), float(max_val.data.numpy()) | [
"def",
"classify",
"(",
"self",
",",
"x",
")",
":",
"outputs",
"=",
"self",
".",
"forward",
"(",
"x",
")",
"outputs",
"=",
"outputs",
"/",
"torch",
".",
"norm",
"(",
"outputs",
")",
"max_val",
",",
"max_idx",
"=",
"torch",
".",
"max",
"(",
"outputs... | https://github.com/akshaychawla/Adversarial-Examples-in-PyTorch/blob/e9e4e1052c5a1147f0885b6f6248645167283dd3/method2-FastGradientSignMethod/mnist-fast-gradient.py#L29-L33 | |||
qutebrowser/qutebrowser | 3a2aaaacbf97f4bf0c72463f3da94ed2822a5442 | qutebrowser/browser/commands.py | python | CommandDispatcher.tab_pin | (self, count=None) | Pin/Unpin the current/[count]th tab.
Pinning a tab shrinks it to the size of its title text.
Attempting to close a pinned tab will cause a confirmation,
unless --force is passed.
Args:
count: The tab index to pin or unpin, or None | Pin/Unpin the current/[count]th tab. | [
"Pin",
"/",
"Unpin",
"the",
"current",
"/",
"[",
"count",
"]",
"th",
"tab",
"."
] | def tab_pin(self, count=None):
"""Pin/Unpin the current/[count]th tab.
Pinning a tab shrinks it to the size of its title text.
Attempting to close a pinned tab will cause a confirmation,
unless --force is passed.
Args:
count: The tab index to pin or unpin, or None
... | [
"def",
"tab_pin",
"(",
"self",
",",
"count",
"=",
"None",
")",
":",
"tab",
"=",
"self",
".",
"_cntwidget",
"(",
"count",
")",
"if",
"tab",
"is",
"None",
":",
"return",
"to_pin",
"=",
"not",
"tab",
".",
"data",
".",
"pinned",
"tab",
".",
"set_pinned... | https://github.com/qutebrowser/qutebrowser/blob/3a2aaaacbf97f4bf0c72463f3da94ed2822a5442/qutebrowser/browser/commands.py#L266-L281 | ||
Blueqat/Blueqat | b676f30489b71767419fd20503403d290d4950b5 | blueqat/gate.py | python | CSwapGate.dagger | (self) | return self | [] | def dagger(self):
return self | [
"def",
"dagger",
"(",
"self",
")",
":",
"return",
"self"
] | https://github.com/Blueqat/Blueqat/blob/b676f30489b71767419fd20503403d290d4950b5/blueqat/gate.py#L863-L864 | |||
gkrizek/bash-lambda-layer | 703b0ade8174022d44779d823172ab7ac33a5505 | bin/s3transfer/manager.py | python | TransferManager.shutdown | (self, cancel=False, cancel_msg='') | Shutdown the TransferManager
It will wait till all transfers complete before it completely shuts
down.
:type cancel: boolean
:param cancel: If True, calls TransferFuture.cancel() for
all in-progress in transfers. This is useful if you want the
shutdown to happen... | Shutdown the TransferManager | [
"Shutdown",
"the",
"TransferManager"
] | def shutdown(self, cancel=False, cancel_msg=''):
"""Shutdown the TransferManager
It will wait till all transfers complete before it completely shuts
down.
:type cancel: boolean
:param cancel: If True, calls TransferFuture.cancel() for
all in-progress in transfers. T... | [
"def",
"shutdown",
"(",
"self",
",",
"cancel",
"=",
"False",
",",
"cancel_msg",
"=",
"''",
")",
":",
"self",
".",
"_shutdown",
"(",
"cancel",
",",
"cancel",
",",
"cancel_msg",
")"
] | https://github.com/gkrizek/bash-lambda-layer/blob/703b0ade8174022d44779d823172ab7ac33a5505/bin/s3transfer/manager.py#L531-L546 | ||
etetoolkit/ete | 2b207357dc2a40ccad7bfd8f54964472c72e4726 | ete3/phyloxml/_phyloxml.py | python | Sequence.export | (self, outfile, level, namespace_='phy:', name_='Sequence', namespacedef_='') | [] | def export(self, outfile, level, namespace_='phy:', name_='Sequence', namespacedef_=''):
showIndent(outfile, level)
outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
already_processed = []
self.exportAttributes(outfile, level, already_processed... | [
"def",
"export",
"(",
"self",
",",
"outfile",
",",
"level",
",",
"namespace_",
"=",
"'phy:'",
",",
"name_",
"=",
"'Sequence'",
",",
"namespacedef_",
"=",
"''",
")",
":",
"showIndent",
"(",
"outfile",
",",
"level",
")",
"outfile",
".",
"write",
"(",
"'<... | https://github.com/etetoolkit/ete/blob/2b207357dc2a40ccad7bfd8f54964472c72e4726/ete3/phyloxml/_phyloxml.py#L1479-L1490 | ||||
mesonbuild/meson | a22d0f9a0a787df70ce79b05d0c45de90a970048 | mesonbuild/scripts/depscan.py | python | DependencyScanner.scan_fortran_file | (self, fname: str) | [] | def scan_fortran_file(self, fname: str) -> None:
fpath = pathlib.Path(fname)
modules_in_this_file = set()
for line in fpath.read_text(encoding='utf-8').split('\n'):
import_match = FORTRAN_USE_RE.match(line)
export_match = FORTRAN_MODULE_RE.match(line)
submodul... | [
"def",
"scan_fortran_file",
"(",
"self",
",",
"fname",
":",
"str",
")",
"->",
"None",
":",
"fpath",
"=",
"pathlib",
".",
"Path",
"(",
"fname",
")",
"modules_in_this_file",
"=",
"set",
"(",
")",
"for",
"line",
"in",
"fpath",
".",
"read_text",
"(",
"enco... | https://github.com/mesonbuild/meson/blob/a22d0f9a0a787df70ce79b05d0c45de90a970048/mesonbuild/scripts/depscan.py#L58-L107 | ||||
DataDog/integrations-core | 934674b29d94b70ccc008f76ea172d0cdae05e1e | datadog_checks_base/datadog_checks/base/log.py | python | CheckLoggingAdapter.setup_sanitization | (self, sanitize) | [] | def setup_sanitization(self, sanitize):
# type: (Callable[[str], str]) -> None
for handler in self.logger.handlers:
if isinstance(handler, AgentLogHandler):
handler.setFormatter(SanitizationFormatter(handler.formatter, sanitize=sanitize)) | [
"def",
"setup_sanitization",
"(",
"self",
",",
"sanitize",
")",
":",
"# type: (Callable[[str], str]) -> None",
"for",
"handler",
"in",
"self",
".",
"logger",
".",
"handlers",
":",
"if",
"isinstance",
"(",
"handler",
",",
"AgentLogHandler",
")",
":",
"handler",
"... | https://github.com/DataDog/integrations-core/blob/934674b29d94b70ccc008f76ea172d0cdae05e1e/datadog_checks_base/datadog_checks/base/log.py#L41-L45 | ||||
reahl/reahl | 86aac47c3a9b5b98e9f77dad4939034a02d54d46 | reahl-sqlalchemysupport/reahl/sqlalchemysupport/sqlalchemysupport.py | python | SqlAlchemyControl.rollback | (self) | Rolls back the current transaction. Programmers should not need to deal with such transaction
management explicitly, since the framework already manages transactions itself. | Rolls back the current transaction. Programmers should not need to deal with such transaction
management explicitly, since the framework already manages transactions itself. | [
"Rolls",
"back",
"the",
"current",
"transaction",
".",
"Programmers",
"should",
"not",
"need",
"to",
"deal",
"with",
"such",
"transaction",
"management",
"explicitly",
"since",
"the",
"framework",
"already",
"manages",
"transactions",
"itself",
"."
] | def rollback(self):
"""Rolls back the current transaction. Programmers should not need to deal with such transaction
management explicitly, since the framework already manages transactions itself."""
Session.rollback() | [
"def",
"rollback",
"(",
"self",
")",
":",
"Session",
".",
"rollback",
"(",
")"
] | https://github.com/reahl/reahl/blob/86aac47c3a9b5b98e9f77dad4939034a02d54d46/reahl-sqlalchemysupport/reahl/sqlalchemysupport/sqlalchemysupport.py#L336-L339 | ||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/library/oc_serviceaccount.py | python | main | () | ansible oc module for service accounts | ansible oc module for service accounts | [
"ansible",
"oc",
"module",
"for",
"service",
"accounts"
] | def main():
'''
ansible oc module for service accounts
'''
module = AnsibleModule(
argument_spec=dict(
kubeconfig=dict(default='/etc/origin/master/admin.kubeconfig', type='str'),
state=dict(default='present', type='str',
choices=['present', 'absent... | [
"def",
"main",
"(",
")",
":",
"module",
"=",
"AnsibleModule",
"(",
"argument_spec",
"=",
"dict",
"(",
"kubeconfig",
"=",
"dict",
"(",
"default",
"=",
"'/etc/origin/master/admin.kubeconfig'",
",",
"type",
"=",
"'str'",
")",
",",
"state",
"=",
"dict",
"(",
"... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/library/oc_serviceaccount.py#L1761-L1784 | ||
pymedusa/Medusa | 1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38 | ext/boto/swf/layer2.py | python | WorkflowExecution.request_cancel | (self) | return self._swf.request_cancel_workflow_execution(self.domain,
self.workflowId, self.runId) | RequestCancelWorkflowExecution. | RequestCancelWorkflowExecution. | [
"RequestCancelWorkflowExecution",
"."
] | def request_cancel(self):
"""RequestCancelWorkflowExecution."""
return self._swf.request_cancel_workflow_execution(self.domain,
self.workflowId, self.runId) | [
"def",
"request_cancel",
"(",
"self",
")",
":",
"return",
"self",
".",
"_swf",
".",
"request_cancel_workflow_execution",
"(",
"self",
".",
"domain",
",",
"self",
".",
"workflowId",
",",
"self",
".",
"runId",
")"
] | https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/ext/boto/swf/layer2.py#L312-L315 | |
openhatch/oh-mainline | ce29352a034e1223141dcc2f317030bbc3359a51 | vendor/packages/twisted/twisted/python/failure.py | python | Failure.printBriefTraceback | (self, file=None, elideFrameworkCode=0) | Print a traceback as densely as possible. | Print a traceback as densely as possible. | [
"Print",
"a",
"traceback",
"as",
"densely",
"as",
"possible",
"."
] | def printBriefTraceback(self, file=None, elideFrameworkCode=0):
"""Print a traceback as densely as possible.
"""
self.printTraceback(file, elideFrameworkCode, detail='brief') | [
"def",
"printBriefTraceback",
"(",
"self",
",",
"file",
"=",
"None",
",",
"elideFrameworkCode",
"=",
"0",
")",
":",
"self",
".",
"printTraceback",
"(",
"file",
",",
"elideFrameworkCode",
",",
"detail",
"=",
"'brief'",
")"
] | https://github.com/openhatch/oh-mainline/blob/ce29352a034e1223141dcc2f317030bbc3359a51/vendor/packages/twisted/twisted/python/failure.py#L555-L558 | ||
cdhigh/KindleEar | 7c4ecf9625239f12a829210d1760b863ef5a23aa | lib/chardet/enums.py | python | SequenceLikelihood.get_num_categories | (cls) | return 4 | :returns: The number of likelihood categories in the enum. | :returns: The number of likelihood categories in the enum. | [
":",
"returns",
":",
"The",
"number",
"of",
"likelihood",
"categories",
"in",
"the",
"enum",
"."
] | def get_num_categories(cls):
""":returns: The number of likelihood categories in the enum."""
return 4 | [
"def",
"get_num_categories",
"(",
"cls",
")",
":",
"return",
"4"
] | https://github.com/cdhigh/KindleEar/blob/7c4ecf9625239f12a829210d1760b863ef5a23aa/lib/chardet/enums.py#L60-L62 | |
jcmgray/quimb | a54b22c61534be8acbc9efe4da97fb5c7f12057d | quimb/tensor/tensor_2d.py | python | TensorNetwork2D.flatten | (self, fuse_multibonds=True, inplace=False) | return tn.view_as_(TensorNetwork2DFlat, like=self) | Contract all tensors corresponding to each site into one. | Contract all tensors corresponding to each site into one. | [
"Contract",
"all",
"tensors",
"corresponding",
"to",
"each",
"site",
"into",
"one",
"."
] | def flatten(self, fuse_multibonds=True, inplace=False):
"""Contract all tensors corresponding to each site into one.
"""
tn = self if inplace else self.copy()
for i, j in self.gen_site_coos():
tn ^= (i, j)
if fuse_multibonds:
tn.fuse_multibonds_()
... | [
"def",
"flatten",
"(",
"self",
",",
"fuse_multibonds",
"=",
"True",
",",
"inplace",
"=",
"False",
")",
":",
"tn",
"=",
"self",
"if",
"inplace",
"else",
"self",
".",
"copy",
"(",
")",
"for",
"i",
",",
"j",
"in",
"self",
".",
"gen_site_coos",
"(",
")... | https://github.com/jcmgray/quimb/blob/a54b22c61534be8acbc9efe4da97fb5c7f12057d/quimb/tensor/tensor_2d.py#L515-L526 | |
khanhnamle1994/natural-language-processing | 01d450d5ac002b0156ef4cf93a07cb508c1bcdc5 | assignment1/.env/lib/python2.7/site-packages/IPython/external/pexpect/_pexpect.py | python | spawnb.isatty | (self) | return os.isatty(self.child_fd) | This returns True if the file descriptor is open and connected to a
tty(-like) device, else False. | This returns True if the file descriptor is open and connected to a
tty(-like) device, else False. | [
"This",
"returns",
"True",
"if",
"the",
"file",
"descriptor",
"is",
"open",
"and",
"connected",
"to",
"a",
"tty",
"(",
"-",
"like",
")",
"device",
"else",
"False",
"."
] | def isatty (self): # File-like object.
"""This returns True if the file descriptor is open and connected to a
tty(-like) device, else False. """
return os.isatty(self.child_fd) | [
"def",
"isatty",
"(",
"self",
")",
":",
"# File-like object.",
"return",
"os",
".",
"isatty",
"(",
"self",
".",
"child_fd",
")"
] | https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/IPython/external/pexpect/_pexpect.py#L713-L718 | |
leapcode/bitmask_client | d2fe20df24fc6eaf146fa5ce1e847de6ab515688 | src/leap/bitmask/backend/signaler.py | python | Signaler.start | (self) | Start the Signaler worker. | Start the Signaler worker. | [
"Start",
"the",
"Signaler",
"worker",
"."
] | def start(self):
"""
Start the Signaler worker.
"""
self._do_work.set()
self._worker_signaler.start() | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"_do_work",
".",
"set",
"(",
")",
"self",
".",
"_worker_signaler",
".",
"start",
"(",
")"
] | https://github.com/leapcode/bitmask_client/blob/d2fe20df24fc6eaf146fa5ce1e847de6ab515688/src/leap/bitmask/backend/signaler.py#L134-L139 | ||
tern-tools/tern | 723f43dcaae2f2f0a08a63e5e8de3938031a386e | tern/classes/docker_image.py | python | DockerImage.load_image | (self, load_until_layer=0) | Load metadata from an extracted docker image. This assumes the
image has already been downloaded and extracted into the working
directory | Load metadata from an extracted docker image. This assumes the
image has already been downloaded and extracted into the working
directory | [
"Load",
"metadata",
"from",
"an",
"extracted",
"docker",
"image",
".",
"This",
"assumes",
"the",
"image",
"has",
"already",
"been",
"downloaded",
"and",
"extracted",
"into",
"the",
"working",
"directory"
] | def load_image(self, load_until_layer=0):
"""Load metadata from an extracted docker image. This assumes the
image has already been downloaded and extracted into the working
directory"""
if load_until_layer > 0:
self._load_until_layer = load_until_layer
# else defaults... | [
"def",
"load_image",
"(",
"self",
",",
"load_until_layer",
"=",
"0",
")",
":",
"if",
"load_until_layer",
">",
"0",
":",
"self",
".",
"_load_until_layer",
"=",
"load_until_layer",
"# else defaults to 0 - handles negative load_until_layer",
"try",
":",
"self",
".",
"_... | https://github.com/tern-tools/tern/blob/723f43dcaae2f2f0a08a63e5e8de3938031a386e/tern/classes/docker_image.py#L136-L177 | ||
tkhirianov/lections_2019 | f90cf0241e82c23782d6d59bc06d45d1bf415bd3 | semestr_1/lec_10/bad_gun_1.py | python | gun.fire2_end | (self, event) | Выстрел мячом.
Происходит при отпускании кнопки мыши.
Начальные значения компонент скорости мяча vx и vy зависят от положения мыши. | Выстрел мячом. | [
"Выстрел",
"мячом",
"."
] | def fire2_end(self, event):
"""Выстрел мячом.
Происходит при отпускании кнопки мыши.
Начальные значения компонент скорости мяча vx и vy зависят от положения мыши.
"""
global balls, bullet
bullet += 1
new_ball = ball()
new_ball.r += 5
self.an = mat... | [
"def",
"fire2_end",
"(",
"self",
",",
"event",
")",
":",
"global",
"balls",
",",
"bullet",
"bullet",
"+=",
"1",
"new_ball",
"=",
"ball",
"(",
")",
"new_ball",
".",
"r",
"+=",
"5",
"self",
".",
"an",
"=",
"math",
".",
"atan",
"(",
"(",
"event",
".... | https://github.com/tkhirianov/lections_2019/blob/f90cf0241e82c23782d6d59bc06d45d1bf415bd3/semestr_1/lec_10/bad_gun_1.py#L97-L112 | ||
sfu-db/dataprep | 6dfb9c659e8bf73f07978ae195d0372495c6f118 | dataprep/eda/missing/render.py | python | render_bar_chart | (
data: Tuple[np.ndarray, np.ndarray, np.ndarray],
yscale: str,
plot_width: int,
plot_height: int,
) | return fig | Render a bar chart for the missing and present values | Render a bar chart for the missing and present values | [
"Render",
"a",
"bar",
"chart",
"for",
"the",
"missing",
"and",
"present",
"values"
] | def render_bar_chart(
data: Tuple[np.ndarray, np.ndarray, np.ndarray],
yscale: str,
plot_width: int,
plot_height: int,
) -> Figure:
"""
Render a bar chart for the missing and present values
"""
pres_cnts, null_cnts, cols = data
cols = [f"{col[:13]}...{col[len(col)-3:]}" if len(col) >... | [
"def",
"render_bar_chart",
"(",
"data",
":",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"np",
".",
"ndarray",
",",
"np",
".",
"ndarray",
"]",
",",
"yscale",
":",
"str",
",",
"plot_width",
":",
"int",
",",
"plot_height",
":",
"int",
",",
")",
"->",
"F... | https://github.com/sfu-db/dataprep/blob/6dfb9c659e8bf73f07978ae195d0372495c6f118/dataprep/eda/missing/render.py#L431-L498 | |
leancloud/satori | 701caccbd4fe45765001ca60435c0cb499477c03 | satori-rules/plugin/libs/requests/adapters.py | python | HTTPAdapter.add_headers | (self, request, **kwargs) | Add any headers needed by the connection. As of v2.0 this does
nothing by default, but is left for overriding by users that subclass
the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
This should not be called from user code, and is only exposed for use
when subclassing the
... | Add any headers needed by the connection. As of v2.0 this does
nothing by default, but is left for overriding by users that subclass
the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. | [
"Add",
"any",
"headers",
"needed",
"by",
"the",
"connection",
".",
"As",
"of",
"v2",
".",
"0",
"this",
"does",
"nothing",
"by",
"default",
"but",
"is",
"left",
"for",
"overriding",
"by",
"users",
"that",
"subclass",
"the",
":",
"class",
":",
"HTTPAdapter... | def add_headers(self, request, **kwargs):
"""Add any headers needed by the connection. As of v2.0 this does
nothing by default, but is left for overriding by users that subclass
the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
This should not be called from user code, and is on... | [
"def",
"add_headers",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | https://github.com/leancloud/satori/blob/701caccbd4fe45765001ca60435c0cb499477c03/satori-rules/plugin/libs/requests/adapters.py#L294-L306 | ||
wistbean/learn_python3_spider | 73c873f4845f4385f097e5057407d03dd37a117b | stackoverflow/venv/lib/python3.6/site-packages/twisted/words/xish/xmlstream.py | python | XmlStream.onDocumentStart | (self, rootElement) | Called whenever the start tag of a root element has been received.
Dispatches the L{STREAM_START_EVENT}. | Called whenever the start tag of a root element has been received. | [
"Called",
"whenever",
"the",
"start",
"tag",
"of",
"a",
"root",
"element",
"has",
"been",
"received",
"."
] | def onDocumentStart(self, rootElement):
""" Called whenever the start tag of a root element has been received.
Dispatches the L{STREAM_START_EVENT}.
"""
self.dispatch(self, STREAM_START_EVENT) | [
"def",
"onDocumentStart",
"(",
"self",
",",
"rootElement",
")",
":",
"self",
".",
"dispatch",
"(",
"self",
",",
"STREAM_START_EVENT",
")"
] | https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/twisted/words/xish/xmlstream.py#L112-L117 | ||
awslabs/aws-servicebroker | c301912e7df3a2f09a9c34d3ae7ffe67c55aa3a0 | sample-apps/rds/sample-app/src/bottle.py | python | auth_basic | (check, realm="private", text="Access denied") | return decorator | Callback decorator to require HTTP auth (basic).
TODO: Add route(check_auth=...) parameter. | Callback decorator to require HTTP auth (basic).
TODO: Add route(check_auth=...) parameter. | [
"Callback",
"decorator",
"to",
"require",
"HTTP",
"auth",
"(",
"basic",
")",
".",
"TODO",
":",
"Add",
"route",
"(",
"check_auth",
"=",
"...",
")",
"parameter",
"."
] | def auth_basic(check, realm="private", text="Access denied"):
''' Callback decorator to require HTTP auth (basic).
TODO: Add route(check_auth=...) parameter. '''
def decorator(func):
def wrapper(*a, **ka):
user, password = request.auth or (None, None)
if user is None or n... | [
"def",
"auth_basic",
"(",
"check",
",",
"realm",
"=",
"\"private\"",
",",
"text",
"=",
"\"Access denied\"",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"a",
",",
"*",
"*",
"ka",
")",
":",
"user",
",",
"password",
... | https://github.com/awslabs/aws-servicebroker/blob/c301912e7df3a2f09a9c34d3ae7ffe67c55aa3a0/sample-apps/rds/sample-app/src/bottle.py#L2680-L2692 | |
TencentCloud/tencentcloud-sdk-python | 3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2 | tencentcloud/gse/v20191112/models.py | python | ListFleetsResponse.__init__ | (self) | r"""
:param FleetIds: 服务器舰队 Id 列表
注意:此字段可能返回 null,表示取不到有效值。
:type FleetIds: list of str
:param TotalCount: 服务器舰队 Id 总数,最小值0
:type TotalCount: int
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | r"""
:param FleetIds: 服务器舰队 Id 列表
注意:此字段可能返回 null,表示取不到有效值。
:type FleetIds: list of str
:param TotalCount: 服务器舰队 Id 总数,最小值0
:type TotalCount: int
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | [
"r",
":",
"param",
"FleetIds",
":",
"服务器舰队",
"Id",
"列表",
"注意:此字段可能返回",
"null,表示取不到有效值。",
":",
"type",
"FleetIds",
":",
"list",
"of",
"str",
":",
"param",
"TotalCount",
":",
"服务器舰队",
"Id",
"总数,最小值0",
":",
"type",
"TotalCount",
":",
"int",
":",
"param",
"R... | def __init__(self):
r"""
:param FleetIds: 服务器舰队 Id 列表
注意:此字段可能返回 null,表示取不到有效值。
:type FleetIds: list of str
:param TotalCount: 服务器舰队 Id 总数,最小值0
:type TotalCount: int
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str
"""
... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"FleetIds",
"=",
"None",
"self",
".",
"TotalCount",
"=",
"None",
"self",
".",
"RequestId",
"=",
"None"
] | https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/gse/v20191112/models.py#L4946-L4958 | ||
zachwill/flask-engine | 7c8ad4bfe36382a8c9286d873ec7b785715832a4 | libs/flask/blueprints.py | python | Blueprint.add_url_rule | (self, rule, endpoint=None, view_func=None, **options) | Like :meth:`Flask.add_url_rule` but for a blueprint. The endpoint for
the :func:`url_for` function is prefixed with the name of the blueprint. | Like :meth:`Flask.add_url_rule` but for a blueprint. The endpoint for
the :func:`url_for` function is prefixed with the name of the blueprint. | [
"Like",
":",
"meth",
":",
"Flask",
".",
"add_url_rule",
"but",
"for",
"a",
"blueprint",
".",
"The",
"endpoint",
"for",
"the",
":",
"func",
":",
"url_for",
"function",
"is",
"prefixed",
"with",
"the",
"name",
"of",
"the",
"blueprint",
"."
] | def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
"""Like :meth:`Flask.add_url_rule` but for a blueprint. The endpoint for
the :func:`url_for` function is prefixed with the name of the blueprint.
"""
if endpoint:
assert '.' not in endpoint, "Blueprint e... | [
"def",
"add_url_rule",
"(",
"self",
",",
"rule",
",",
"endpoint",
"=",
"None",
",",
"view_func",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"endpoint",
":",
"assert",
"'.'",
"not",
"in",
"endpoint",
",",
"\"Blueprint endpoint's should not contain... | https://github.com/zachwill/flask-engine/blob/7c8ad4bfe36382a8c9286d873ec7b785715832a4/libs/flask/blueprints.py#L165-L172 | ||
numba/numba | bf480b9e0da858a65508c2b17759a72ee6a44c51 | numba/parfors/parfor.py | python | Parfor.get_shape_classes | (self, var, typemap=None) | return res | get the shape classes for a given variable.
If a typemap is specified then use it for type resolution | get the shape classes for a given variable.
If a typemap is specified then use it for type resolution | [
"get",
"the",
"shape",
"classes",
"for",
"a",
"given",
"variable",
".",
"If",
"a",
"typemap",
"is",
"specified",
"then",
"use",
"it",
"for",
"type",
"resolution"
] | def get_shape_classes(self, var, typemap=None):
"""get the shape classes for a given variable.
If a typemap is specified then use it for type resolution
"""
# We get shape classes from the equivalence set but that
# keeps its own typemap at a time prior to lowering. So
#... | [
"def",
"get_shape_classes",
"(",
"self",
",",
"var",
",",
"typemap",
"=",
"None",
")",
":",
"# We get shape classes from the equivalence set but that",
"# keeps its own typemap at a time prior to lowering. So",
"# if something is added during lowering then we can pass",
"# in a type m... | https://github.com/numba/numba/blob/bf480b9e0da858a65508c2b17759a72ee6a44c51/numba/parfors/parfor.py#L585-L601 | |
pkkid/python-plexapi | 8a048d28360b0cdc728a41fa7d3077d0593b68fb | plexapi/myplex.py | python | MyPlexAccount.createHomeUser | (self, user, server, sections=None, allowSync=False, allowCameraUpload=False,
allowChannels=False, filterMovies=None, filterTelevision=None, filterMusic=None) | return user_creation, library_assignment | Share library content with the specified user.
Parameters:
user (:class:`~plexapi.myplex.MyPlexUser`): `MyPlexUser` object, username, or email
of the user to be added.
server (:class:`~plexapi.server.PlexServer`): `PlexServer` object, or machineIdentifier... | Share library content with the specified user. | [
"Share",
"library",
"content",
"with",
"the",
"specified",
"user",
"."
] | def createHomeUser(self, user, server, sections=None, allowSync=False, allowCameraUpload=False,
allowChannels=False, filterMovies=None, filterTelevision=None, filterMusic=None):
""" Share library content with the specified user.
Parameters:
user (:class:`~plex... | [
"def",
"createHomeUser",
"(",
"self",
",",
"user",
",",
"server",
",",
"sections",
"=",
"None",
",",
"allowSync",
"=",
"False",
",",
"allowCameraUpload",
"=",
"False",
",",
"allowChannels",
"=",
"False",
",",
"filterMovies",
"=",
"None",
",",
"filterTelevisi... | https://github.com/pkkid/python-plexapi/blob/8a048d28360b0cdc728a41fa7d3077d0593b68fb/plexapi/myplex.py#L262-L309 | |
microsoft/azure-devops-python-api | 451cade4c475482792cbe9e522c1fee32393139e | azure-devops/azure/devops/v5_1/project_analysis/project_analysis_client.py | python | ProjectAnalysisClient.get_repository_activity_metrics | (self, project, repository_id, from_date, aggregation_type) | return self._deserialize('RepositoryActivityMetrics', response) | GetRepositoryActivityMetrics.
[Preview API]
:param str project: Project ID or project name
:param str repository_id:
:param datetime from_date:
:param str aggregation_type:
:rtype: :class:`<RepositoryActivityMetrics> <azure.devops.v5_1.project_analysis.models.RepositoryAc... | GetRepositoryActivityMetrics.
[Preview API]
:param str project: Project ID or project name
:param str repository_id:
:param datetime from_date:
:param str aggregation_type:
:rtype: :class:`<RepositoryActivityMetrics> <azure.devops.v5_1.project_analysis.models.RepositoryAc... | [
"GetRepositoryActivityMetrics",
".",
"[",
"Preview",
"API",
"]",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
"str",
"repository_id",
":",
":",
"param",
"datetime",
"from_date",
":",
":",
"param",
"str",
"aggre... | def get_repository_activity_metrics(self, project, repository_id, from_date, aggregation_type):
"""GetRepositoryActivityMetrics.
[Preview API]
:param str project: Project ID or project name
:param str repository_id:
:param datetime from_date:
:param str aggregation_type:
... | [
"def",
"get_repository_activity_metrics",
"(",
"self",
",",
"project",
",",
"repository_id",
",",
"from_date",
",",
"aggregation_type",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",
"'project'",
"]",
"... | https://github.com/microsoft/azure-devops-python-api/blob/451cade4c475482792cbe9e522c1fee32393139e/azure-devops/azure/devops/v5_1/project_analysis/project_analysis_client.py#L95-L119 | |
PaddlePaddle/Research | 2da0bd6c72d60e9df403aff23a7802779561c4a1 | KG/DuIE_Baseline/script/re_official_evaluation.py | python | check_format | (line) | return ret_code, json_info | 检查输入行是否格式错误 | 检查输入行是否格式错误 | [
"检查输入行是否格式错误"
] | def check_format(line):
"""检查输入行是否格式错误"""
ret_code = SUCCESS
json_info = {}
try:
line = line.strip()
except:
ret_code = ENCODING_ERROR
return ret_code, json_info
try:
json_info = json.loads(line)
except:
ret_code = JSON_ERROR
return ret_code, j... | [
"def",
"check_format",
"(",
"line",
")",
":",
"ret_code",
"=",
"SUCCESS",
"json_info",
"=",
"{",
"}",
"try",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"except",
":",
"ret_code",
"=",
"ENCODING_ERROR",
"return",
"ret_code",
",",
"json_info",
"try"... | https://github.com/PaddlePaddle/Research/blob/2da0bd6c72d60e9df403aff23a7802779561c4a1/KG/DuIE_Baseline/script/re_official_evaluation.py#L54-L84 | |
yuxiaokui/Intranet-Penetration | f57678a204840c83cbf3308e3470ae56c5ff514b | proxy/XX-Net/code/default/gae_proxy/server/lib/google/appengine/_internal/antlr3/recognizers.py | python | BaseRecognizer.emitErrorMessage | (self, msg) | Override this method to change where error messages go | Override this method to change where error messages go | [
"Override",
"this",
"method",
"to",
"change",
"where",
"error",
"messages",
"go"
] | def emitErrorMessage(self, msg):
"""Override this method to change where error messages go"""
sys.stderr.write(msg + '\n') | [
"def",
"emitErrorMessage",
"(",
"self",
",",
"msg",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"msg",
"+",
"'\\n'",
")"
] | https://github.com/yuxiaokui/Intranet-Penetration/blob/f57678a204840c83cbf3308e3470ae56c5ff514b/proxy/XX-Net/code/default/gae_proxy/server/lib/google/appengine/_internal/antlr3/recognizers.py#L466-L468 | ||
gammapy/gammapy | 735b25cd5bbed35e2004d633621896dcd5295e8b | docs/makers/make_reflected_regions.py | python | plot_regions | (ax, regions, on_region, exclusion_mask) | Little helper function to plot off regions | Little helper function to plot off regions | [
"Little",
"helper",
"function",
"to",
"plot",
"off",
"regions"
] | def plot_regions(ax, regions, on_region, exclusion_mask):
"""Little helper function to plot off regions"""
exclusion_mask.plot_mask(ax=ax, colors="gray")
on_region.to_pixel(ax.wcs).plot(ax=ax, edgecolor="tab:orange")
geom = RegionGeom.from_regions(regions)
geom.plot_region(ax=ax, color="tab:blue") | [
"def",
"plot_regions",
"(",
"ax",
",",
"regions",
",",
"on_region",
",",
"exclusion_mask",
")",
":",
"exclusion_mask",
".",
"plot_mask",
"(",
"ax",
"=",
"ax",
",",
"colors",
"=",
"\"gray\"",
")",
"on_region",
".",
"to_pixel",
"(",
"ax",
".",
"wcs",
")",
... | https://github.com/gammapy/gammapy/blob/735b25cd5bbed35e2004d633621896dcd5295e8b/docs/makers/make_reflected_regions.py#L35-L40 | ||
rembo10/headphones | b3199605be1ebc83a7a8feab6b1e99b64014187c | lib/mutagen/asf/__init__.py | python | ASFTags.__delitem__ | (self, key) | Delete all values associated with the key. | Delete all values associated with the key. | [
"Delete",
"all",
"values",
"associated",
"with",
"the",
"key",
"."
] | def __delitem__(self, key):
"""Delete all values associated with the key."""
# PY3 only
if isinstance(key, slice):
return list.__delitem__(self, key)
to_delete = [x for x in self if x[0] == key]
if not to_delete:
raise KeyError(key)
else:
... | [
"def",
"__delitem__",
"(",
"self",
",",
"key",
")",
":",
"# PY3 only",
"if",
"isinstance",
"(",
"key",
",",
"slice",
")",
":",
"return",
"list",
".",
"__delitem__",
"(",
"self",
",",
"key",
")",
"to_delete",
"=",
"[",
"x",
"for",
"x",
"in",
"self",
... | https://github.com/rembo10/headphones/blob/b3199605be1ebc83a7a8feab6b1e99b64014187c/lib/mutagen/asf/__init__.py#L102-L114 | ||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_openshift/library/oc_adm_registry.py | python | Yedit.append | (self, path, value) | return (True, self.yaml_dict) | append value to a list | append value to a list | [
"append",
"value",
"to",
"a",
"list"
] | def append(self, path, value):
'''append value to a list'''
try:
entry = Yedit.get_entry(self.yaml_dict, path, self.separator)
except KeyError:
entry = None
if entry is None:
self.put(path, [])
entry = Yedit.get_entry(self.yaml_dict, path,... | [
"def",
"append",
"(",
"self",
",",
"path",
",",
"value",
")",
":",
"try",
":",
"entry",
"=",
"Yedit",
".",
"get_entry",
"(",
"self",
".",
"yaml_dict",
",",
"path",
",",
"self",
".",
"separator",
")",
"except",
"KeyError",
":",
"entry",
"=",
"None",
... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_openshift/library/oc_adm_registry.py#L638-L655 | |
kubernetes-client/python | 47b9da9de2d02b2b7a34fbe05afb44afd130d73a | kubernetes/client/models/v1_namespace_condition.py | python | V1NamespaceCondition.last_transition_time | (self) | return self._last_transition_time | Gets the last_transition_time of this V1NamespaceCondition. # noqa: E501
Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON. Wrappers are provided for many of the factory methods that the time package offers. # noqa: E501
:return: The last_transition_time of this ... | Gets the last_transition_time of this V1NamespaceCondition. # noqa: E501 | [
"Gets",
"the",
"last_transition_time",
"of",
"this",
"V1NamespaceCondition",
".",
"#",
"noqa",
":",
"E501"
] | def last_transition_time(self):
"""Gets the last_transition_time of this V1NamespaceCondition. # noqa: E501
Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON. Wrappers are provided for many of the factory methods that the time package offers. # noqa: E501
... | [
"def",
"last_transition_time",
"(",
"self",
")",
":",
"return",
"self",
".",
"_last_transition_time"
] | https://github.com/kubernetes-client/python/blob/47b9da9de2d02b2b7a34fbe05afb44afd130d73a/kubernetes/client/models/v1_namespace_condition.py#L74-L82 | |
awslabs/aws-lambda-powertools-python | 0c6ac0fe183476140ee1df55fe9fa1cc20925577 | aws_lambda_powertools/utilities/data_classes/rabbit_mq_event.py | python | RabbitMessage.json_data | (self) | return self._json_data | Parses the data as json | Parses the data as json | [
"Parses",
"the",
"data",
"as",
"json"
] | def json_data(self) -> Any:
"""Parses the data as json"""
if self._json_data is None:
self._json_data = json.loads(self.decoded_data)
return self._json_data | [
"def",
"json_data",
"(",
"self",
")",
"->",
"Any",
":",
"if",
"self",
".",
"_json_data",
"is",
"None",
":",
"self",
".",
"_json_data",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"decoded_data",
")",
"return",
"self",
".",
"_json_data"
] | https://github.com/awslabs/aws-lambda-powertools-python/blob/0c6ac0fe183476140ee1df55fe9fa1cc20925577/aws_lambda_powertools/utilities/data_classes/rabbit_mq_event.py#L89-L93 | |
cloudera/impyla | 0c736af4cad2bade9b8e313badc08ec50e81c948 | impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py | python | get_partitions_ps_with_auth_args.__eq__ | (self, other) | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | [] | def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"return",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
"and",
"self",
".",
"__dict__",
"==",
"other",
".",
"__dict__"
] | https://github.com/cloudera/impyla/blob/0c736af4cad2bade9b8e313badc08ec50e81c948/impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py#L21106-L21107 | |||
omz/PythonistaAppTemplate | f560f93f8876d82a21d108977f90583df08d55af | PythonistaAppTemplate/PythonistaKit.framework/pylib/sgmllib.py | python | SGMLParser.__init__ | (self, verbose=0) | Initialize and reset this instance. | Initialize and reset this instance. | [
"Initialize",
"and",
"reset",
"this",
"instance",
"."
] | def __init__(self, verbose=0):
"""Initialize and reset this instance."""
self.verbose = verbose
self.reset() | [
"def",
"__init__",
"(",
"self",
",",
"verbose",
"=",
"0",
")",
":",
"self",
".",
"verbose",
"=",
"verbose",
"self",
".",
"reset",
"(",
")"
] | https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib/sgmllib.py#L67-L70 | ||
bazad/ida_kernelcache | b476036f988528ee733b9668ccec6558fd81f3ed | ida_kernelcache/ida_utilities.py | python | Addresses | (start, end=None, step=1, length=None, partial=False, aligned=False,
unmapped=True, allow_unmapped=False) | A generator to iterate over the addresses in an address range.
Arguments:
start: The start of the address range to iterate over.
Options:
end: The end of the address range to iterate over.
step: The amount to step the address by each iteration. Default is 1.
length: The number ... | A generator to iterate over the addresses in an address range. | [
"A",
"generator",
"to",
"iterate",
"over",
"the",
"addresses",
"in",
"an",
"address",
"range",
"."
] | def Addresses(start, end=None, step=1, length=None, partial=False, aligned=False,
unmapped=True, allow_unmapped=False):
"""A generator to iterate over the addresses in an address range.
Arguments:
start: The start of the address range to iterate over.
Options:
end: The end of the a... | [
"def",
"Addresses",
"(",
"start",
",",
"end",
"=",
"None",
",",
"step",
"=",
"1",
",",
"length",
"=",
"None",
",",
"partial",
"=",
"False",
",",
"aligned",
"=",
"False",
",",
"unmapped",
"=",
"True",
",",
"allow_unmapped",
"=",
"False",
")",
":",
"... | https://github.com/bazad/ida_kernelcache/blob/b476036f988528ee733b9668ccec6558fd81f3ed/ida_kernelcache/ida_utilities.py#L198-L239 | ||
kamalgill/flask-appengine-template | 11760f83faccbb0d0afe416fc58e67ecfb4643c2 | src/lib/werkzeug/wsgi.py | python | get_input_stream | (environ, safe_fallback=True) | return LimitedStream(stream, content_length) | Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length.
.. versionadded:: 0.9
:param environ: the WSGI environ ... | Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length. | [
"Returns",
"the",
"input",
"stream",
"from",
"the",
"WSGI",
"environment",
"and",
"wraps",
"it",
"in",
"the",
"most",
"sensible",
"way",
"possible",
".",
"The",
"stream",
"returned",
"is",
"not",
"the",
"raw",
"WSGI",
"stream",
"in",
"most",
"cases",
"but"... | def get_input_stream(environ, safe_fallback=True):
"""Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length.
..... | [
"def",
"get_input_stream",
"(",
"environ",
",",
"safe_fallback",
"=",
"True",
")",
":",
"stream",
"=",
"environ",
"[",
"'wsgi.input'",
"]",
"content_length",
"=",
"get_content_length",
"(",
"environ",
")",
"# A wsgi extension that tells us if the input is terminated. In"... | https://github.com/kamalgill/flask-appengine-template/blob/11760f83faccbb0d0afe416fc58e67ecfb4643c2/src/lib/werkzeug/wsgi.py#L182-L213 | |
pytest-dev/pluggy | 461ef63291d13589c4e21aa182cd1529257e9a0a | src/pluggy/_manager.py | python | PluginManager.register | (self, plugin, name=None) | return plugin_name | Register a plugin and return its canonical name or ``None`` if the name
is blocked from registering. Raise a :py:class:`ValueError` if the plugin
is already registered. | Register a plugin and return its canonical name or ``None`` if the name
is blocked from registering. Raise a :py:class:`ValueError` if the plugin
is already registered. | [
"Register",
"a",
"plugin",
"and",
"return",
"its",
"canonical",
"name",
"or",
"None",
"if",
"the",
"name",
"is",
"blocked",
"from",
"registering",
".",
"Raise",
"a",
":",
"py",
":",
"class",
":",
"ValueError",
"if",
"the",
"plugin",
"is",
"already",
"reg... | def register(self, plugin, name=None):
"""Register a plugin and return its canonical name or ``None`` if the name
is blocked from registering. Raise a :py:class:`ValueError` if the plugin
is already registered."""
plugin_name = name or self.get_canonical_name(plugin)
if plugin_... | [
"def",
"register",
"(",
"self",
",",
"plugin",
",",
"name",
"=",
"None",
")",
":",
"plugin_name",
"=",
"name",
"or",
"self",
".",
"get_canonical_name",
"(",
"plugin",
")",
"if",
"plugin_name",
"in",
"self",
".",
"_name2plugin",
"or",
"plugin",
"in",
"sel... | https://github.com/pytest-dev/pluggy/blob/461ef63291d13589c4e21aa182cd1529257e9a0a/src/pluggy/_manager.py#L82-L118 | |
graycatlabs/PyBBIO | 0d46115059ed7ec0c17afb6dd7ed2f507b4f2b8a | bbio/libraries/RotaryEncoder/rotary_encoder.py | python | RotaryEncoder.disable | (self) | return sysfs.kernelFileIO(enable_file, '0') | disable()
Turns the eQEP hardware OFF | disable()
Turns the eQEP hardware OFF | [
"disable",
"()",
"Turns",
"the",
"eQEP",
"hardware",
"OFF"
] | def disable(self):
'''
disable()
Turns the eQEP hardware OFF
'''
enable_file = "%s/enabled" % self.base_dir
return sysfs.kernelFileIO(enable_file, '0') | [
"def",
"disable",
"(",
"self",
")",
":",
"enable_file",
"=",
"\"%s/enabled\"",
"%",
"self",
".",
"base_dir",
"return",
"sysfs",
".",
"kernelFileIO",
"(",
"enable_file",
",",
"'0'",
")"
] | https://github.com/graycatlabs/PyBBIO/blob/0d46115059ed7ec0c17afb6dd7ed2f507b4f2b8a/bbio/libraries/RotaryEncoder/rotary_encoder.py#L59-L65 | |
rowliny/DiffHelper | ab3a96f58f9579d0023aed9ebd785f4edf26f8af | Tool/SitePackages/nltk/tokenize/sexpr.py | python | SExprTokenizer.tokenize | (self, text) | return result | Return a list of s-expressions extracted from *text*.
For example:
>>> SExprTokenizer().tokenize('(a b (c d)) e f (g)')
['(a b (c d))', 'e', 'f', '(g)']
All parentheses are assumed to mark s-expressions.
(No special processing is done to exclude parentheses that occur
... | Return a list of s-expressions extracted from *text*.
For example: | [
"Return",
"a",
"list",
"of",
"s",
"-",
"expressions",
"extracted",
"from",
"*",
"text",
"*",
".",
"For",
"example",
":"
] | def tokenize(self, text):
"""
Return a list of s-expressions extracted from *text*.
For example:
>>> SExprTokenizer().tokenize('(a b (c d)) e f (g)')
['(a b (c d))', 'e', 'f', '(g)']
All parentheses are assumed to mark s-expressions.
(No special processi... | [
"def",
"tokenize",
"(",
"self",
",",
"text",
")",
":",
"result",
"=",
"[",
"]",
"pos",
"=",
"0",
"depth",
"=",
"0",
"for",
"m",
"in",
"self",
".",
"_paren_regexp",
".",
"finditer",
"(",
"text",
")",
":",
"paren",
"=",
"m",
".",
"group",
"(",
")... | https://github.com/rowliny/DiffHelper/blob/ab3a96f58f9579d0023aed9ebd785f4edf26f8af/Tool/SitePackages/nltk/tokenize/sexpr.py#L89-L137 | |
WPO-Foundation/wptagent | 94470f007294213f900dcd9a207678b5b9fce5d3 | internal/devtools.py | python | DevTools.execute_js | (self, script) | return ret | Run the provided JS in the browser and return the result | Run the provided JS in the browser and return the result | [
"Run",
"the",
"provided",
"JS",
"in",
"the",
"browser",
"and",
"return",
"the",
"result"
] | def execute_js(self, script):
"""Run the provided JS in the browser and return the result"""
if self.must_exit:
return
ret = None
if self.task['error'] is None and not self.main_thread_blocked:
if self.is_webkit:
response = self.send_command('Runti... | [
"def",
"execute_js",
"(",
"self",
",",
"script",
")",
":",
"if",
"self",
".",
"must_exit",
":",
"return",
"ret",
"=",
"None",
"if",
"self",
".",
"task",
"[",
"'error'",
"]",
"is",
"None",
"and",
"not",
"self",
".",
"main_thread_blocked",
":",
"if",
"... | https://github.com/WPO-Foundation/wptagent/blob/94470f007294213f900dcd9a207678b5b9fce5d3/internal/devtools.py#L1070-L1089 | |
reddit-archive/reddit | 753b17407e9a9dca09558526805922de24133d53 | r2/r2/lib/emailer.py | python | share | (link, emails, from_name = "", reply_to = "", body = "") | Queues a 'share link' email. | Queues a 'share link' email. | [
"Queues",
"a",
"share",
"link",
"email",
"."
] | def share(link, emails, from_name = "", reply_to = "", body = ""):
"""Queues a 'share link' email."""
now = datetime.datetime.now(g.tz)
ival = now - timeago(g.new_link_share_delay)
date = max(now,link._date + ival)
Email.handler.add_to_queue(c.user, emails, from_name, g.share_reply,
... | [
"def",
"share",
"(",
"link",
",",
"emails",
",",
"from_name",
"=",
"\"\"",
",",
"reply_to",
"=",
"\"\"",
",",
"body",
"=",
"\"\"",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
"g",
".",
"tz",
")",
"ival",
"=",
"now",
"-",
... | https://github.com/reddit-archive/reddit/blob/753b17407e9a9dca09558526805922de24133d53/r2/r2/lib/emailer.py#L237-L245 | ||
cbrgm/telegram-robot-rss | 58fe98de427121fdc152c8df0721f1891174e6c9 | venv/lib/python2.7/site-packages/future/backports/email/message.py | python | Message.__len__ | (self) | return len(self._headers) | Return the total number of headers, including duplicates. | Return the total number of headers, including duplicates. | [
"Return",
"the",
"total",
"number",
"of",
"headers",
"including",
"duplicates",
"."
] | def __len__(self):
"""Return the total number of headers, including duplicates."""
return len(self._headers) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"_headers",
")"
] | https://github.com/cbrgm/telegram-robot-rss/blob/58fe98de427121fdc152c8df0721f1891174e6c9/venv/lib/python2.7/site-packages/future/backports/email/message.py#L333-L335 | |
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/django-1.2/django/contrib/gis/gdal/feature.py | python | Feature.fields | (self) | return [capi.get_field_name(capi.get_field_defn(self._fdefn, i))
for i in xrange(self.num_fields)] | Returns a list of fields in the Feature. | Returns a list of fields in the Feature. | [
"Returns",
"a",
"list",
"of",
"fields",
"in",
"the",
"Feature",
"."
] | def fields(self):
"Returns a list of fields in the Feature."
return [capi.get_field_name(capi.get_field_defn(self._fdefn, i))
for i in xrange(self.num_fields)] | [
"def",
"fields",
"(",
"self",
")",
":",
"return",
"[",
"capi",
".",
"get_field_name",
"(",
"capi",
".",
"get_field_defn",
"(",
"self",
".",
"_fdefn",
",",
"i",
")",
")",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"num_fields",
")",
"]"
] | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.2/django/contrib/gis/gdal/feature.py#L79-L82 | |
awslabs/aws-lambda-powertools-python | 0c6ac0fe183476140ee1df55fe9fa1cc20925577 | aws_lambda_powertools/event_handler/api_gateway.py | python | ApiGatewayResolver._compile_regex | (rule: str) | return re.compile("^{}$".format(rule_regex)) | Precompile regex pattern
Logic
-----
1. Find any dynamic routes defined as <pattern>
e.g. @app.get("/accounts/<account_id>")
2. Create a new regex by substituting every dynamic route found as a named group (?P<group>),
and match whole words only (word boundary) inst... | Precompile regex pattern | [
"Precompile",
"regex",
"pattern"
] | def _compile_regex(rule: str):
"""Precompile regex pattern
Logic
-----
1. Find any dynamic routes defined as <pattern>
e.g. @app.get("/accounts/<account_id>")
2. Create a new regex by substituting every dynamic route found as a named group (?P<group>),
and m... | [
"def",
"_compile_regex",
"(",
"rule",
":",
"str",
")",
":",
"rule_regex",
":",
"str",
"=",
"re",
".",
"sub",
"(",
"_DYNAMIC_ROUTE_PATTERN",
",",
"_NAMED_GROUP_BOUNDARY_PATTERN",
",",
"rule",
")",
"return",
"re",
".",
"compile",
"(",
"\"^{}$\"",
".",
"format"... | https://github.com/awslabs/aws-lambda-powertools-python/blob/0c6ac0fe183476140ee1df55fe9fa1cc20925577/aws_lambda_powertools/event_handler/api_gateway.py#L508-L538 | |
exodrifter/unity-python | bef6e4e9ddfbbf1eaf7acbbb973e9aa3dd64a20d | Lib/stringold.py | python | split | (s, sep=None, maxsplit=0) | return s.split(sep, maxsplit) | split(str [,sep [,maxsplit]]) -> list of strings
Return a list of the words in the string s, using sep as the
delimiter string. If maxsplit is nonzero, splits into at most
maxsplit words If sep is not specified, any whitespace string
is a separator. Maxsplit defaults to 0.
(split and splitfields... | split(str [,sep [,maxsplit]]) -> list of strings | [
"split",
"(",
"str",
"[",
"sep",
"[",
"maxsplit",
"]]",
")",
"-",
">",
"list",
"of",
"strings"
] | def split(s, sep=None, maxsplit=0):
"""split(str [,sep [,maxsplit]]) -> list of strings
Return a list of the words in the string s, using sep as the
delimiter string. If maxsplit is nonzero, splits into at most
maxsplit words If sep is not specified, any whitespace string
is a separator. Maxsplit... | [
"def",
"split",
"(",
"s",
",",
"sep",
"=",
"None",
",",
"maxsplit",
"=",
"0",
")",
":",
"return",
"s",
".",
"split",
"(",
"sep",
",",
"maxsplit",
")"
] | https://github.com/exodrifter/unity-python/blob/bef6e4e9ddfbbf1eaf7acbbb973e9aa3dd64a20d/Lib/stringold.py#L104-L115 | |
openstack/cinder | 23494a6d6c51451688191e1847a458f1d3cdcaa5 | cinder/volume/drivers/dell_emc/powermax/rest.py | python | PowerMaxRest.wait_for_job | (self, operation, status_code, job, extra_specs) | return task | Check if call is async, wait for it to complete.
:param operation: the operation being performed
:param status_code: the status code
:param job: the job
:param extra_specs: the extra specifications
:returns: task -- list of dicts detailing tasks in the job
:raises: Volum... | Check if call is async, wait for it to complete. | [
"Check",
"if",
"call",
"is",
"async",
"wait",
"for",
"it",
"to",
"complete",
"."
] | def wait_for_job(self, operation, status_code, job, extra_specs):
"""Check if call is async, wait for it to complete.
:param operation: the operation being performed
:param status_code: the status code
:param job: the job
:param extra_specs: the extra specifications
:ret... | [
"def",
"wait_for_job",
"(",
"self",
",",
"operation",
",",
"status_code",
",",
"job",
",",
"extra_specs",
")",
":",
"task",
"=",
"None",
"if",
"status_code",
"==",
"STATUS_202",
":",
"rc",
",",
"result",
",",
"status",
",",
"task",
"=",
"self",
".",
"w... | https://github.com/openstack/cinder/blob/23494a6d6c51451688191e1847a458f1d3cdcaa5/cinder/volume/drivers/dell_emc/powermax/rest.py#L410-L433 | |
ztwo/Auto_Analysis | 795db843dda0e677f20f1e1b16f38d945da83369 | lib/Utils.py | python | l | () | return log | 打印log
文件名+函数名,return
:return: | 打印log
文件名+函数名,return
:return: | [
"打印log",
"文件名",
"+",
"函数名",
"return",
":",
"return",
":"
] | def l():
"""
打印log
文件名+函数名,return
:return:
"""
def log(func):
def wrapper(*args, **kwargs):
t = func(*args, **kwargs)
filename = str(sys.argv[0]).split('/')[-1].split('.')[0]
Logging.success('{}:{}, return:{}'.format(filename, func.__name__, t))
... | [
"def",
"l",
"(",
")",
":",
"def",
"log",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"t",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"filename",
"=",
"str",
"(",
"sys",
"."... | https://github.com/ztwo/Auto_Analysis/blob/795db843dda0e677f20f1e1b16f38d945da83369/lib/Utils.py#L116-L132 | |
sightmachine/SimpleCV | 6c4d61b6d1d9d856b471910107cad0838954d2b2 | SimpleCV/MachineLearning/NaiveBayesClassifier.py | python | NaiveBayesClassifier.save | (self, fname) | Save the classifier to file | Save the classifier to file | [
"Save",
"the",
"classifier",
"to",
"file"
] | def save(self, fname):
"""
Save the classifier to file
"""
output = open(fname, 'wb')
pickle.dump(self,output,2) # use two otherwise it w
output.close() | [
"def",
"save",
"(",
"self",
",",
"fname",
")",
":",
"output",
"=",
"open",
"(",
"fname",
",",
"'wb'",
")",
"pickle",
".",
"dump",
"(",
"self",
",",
"output",
",",
"2",
")",
"# use two otherwise it w",
"output",
".",
"close",
"(",
")"
] | https://github.com/sightmachine/SimpleCV/blob/6c4d61b6d1d9d856b471910107cad0838954d2b2/SimpleCV/MachineLearning/NaiveBayesClassifier.py#L54-L60 | ||
liquidctl/liquidctl | 73962574632f94050c2a75f517e929a29797b5e2 | liquidctl/driver/smart_device.py | python | SmartDevice2.initialize | (self, **kwargs) | return sorted(status) | Initialize the device.
Detects and reports all connected fans and LED accessories, and allows
subsequent calls to get_status.
Returns a list of (key, value, unit) tuples. | Initialize the device. | [
"Initialize",
"the",
"device",
"."
] | def initialize(self, **kwargs):
"""Initialize the device.
Detects and reports all connected fans and LED accessories, and allows
subsequent calls to get_status.
Returns a list of (key, value, unit) tuples.
"""
self.device.clear_enqueued_reports()
# if fan cont... | [
"def",
"initialize",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"device",
".",
"clear_enqueued_reports",
"(",
")",
"# if fan controller, initialize fan reporting (#331)",
"if",
"self",
".",
"_speed_channels",
":",
"update_interval",
"=",
"(",
"la... | https://github.com/liquidctl/liquidctl/blob/73962574632f94050c2a75f517e929a29797b5e2/liquidctl/driver/smart_device.py#L419-L457 | |
snarfed/granary | ab085de2aef0cff8ac31a99b5e21443a249e8419 | granary/pixelfed.py | python | Pixelfed.status_url | (self, username, id) | return urllib.parse.urljoin(self.instance, f'/p/{urllib.parse.quote(username)}/{id}') | Returns the local instance URL for a status with a given id. | Returns the local instance URL for a status with a given id. | [
"Returns",
"the",
"local",
"instance",
"URL",
"for",
"a",
"status",
"with",
"a",
"given",
"id",
"."
] | def status_url(self, username, id):
"""Returns the local instance URL for a status with a given id."""
return urllib.parse.urljoin(self.instance, f'/p/{urllib.parse.quote(username)}/{id}') | [
"def",
"status_url",
"(",
"self",
",",
"username",
",",
"id",
")",
":",
"return",
"urllib",
".",
"parse",
".",
"urljoin",
"(",
"self",
".",
"instance",
",",
"f'/p/{urllib.parse.quote(username)}/{id}'",
")"
] | https://github.com/snarfed/granary/blob/ab085de2aef0cff8ac31a99b5e21443a249e8419/granary/pixelfed.py#L26-L28 | |
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/Ubuntu_13/ecdsa/six.py | python | remove_move | (name) | Remove item from six.moves. | Remove item from six.moves. | [
"Remove",
"item",
"from",
"six",
".",
"moves",
"."
] | def remove_move(name):
"""Remove item from six.moves."""
try:
delattr(_MovedItems, name)
except AttributeError:
try:
del moves.__dict__[name]
except KeyError:
raise AttributeError("no such move, %r" % (name,)) | [
"def",
"remove_move",
"(",
"name",
")",
":",
"try",
":",
"delattr",
"(",
"_MovedItems",
",",
"name",
")",
"except",
"AttributeError",
":",
"try",
":",
"del",
"moves",
".",
"__dict__",
"[",
"name",
"]",
"except",
"KeyError",
":",
"raise",
"AttributeError",
... | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Ubuntu_13/ecdsa/six.py#L197-L205 | ||
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit - MAC OSX/tools/sqli/thirdparty/bottle/bottle.py | python | Router.build | (self, _name, *anons, **query) | Build an URL by filling the wildcards in a rule. | Build an URL by filling the wildcards in a rule. | [
"Build",
"an",
"URL",
"by",
"filling",
"the",
"wildcards",
"in",
"a",
"rule",
"."
] | def build(self, _name, *anons, **query):
''' Build an URL by filling the wildcards in a rule. '''
builder = self.builder.get(_name)
if not builder: raise RouteBuildError("No route with that name.", _name)
try:
for i, value in enumerate(anons): query['anon%d'%i] = value
... | [
"def",
"build",
"(",
"self",
",",
"_name",
",",
"*",
"anons",
",",
"*",
"*",
"query",
")",
":",
"builder",
"=",
"self",
".",
"builder",
".",
"get",
"(",
"_name",
")",
"if",
"not",
"builder",
":",
"raise",
"RouteBuildError",
"(",
"\"No route with that n... | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit - MAC OSX/tools/sqli/thirdparty/bottle/bottle.py#L374-L383 | ||
openstack/trove | be86b79119d16ee77f596172f43b0c97cb2617bd | trove/taskmanager/models.py | python | FreshInstanceTasks._service_is_active | (self) | return False | Check that the database guest is active.
This function is meant to be called with poll_until to check that
the guest is alive before sending a 'create' message. This prevents
over billing a customer for an instance that they can never use.
Returns: boolean if the service is active.
... | Check that the database guest is active. | [
"Check",
"that",
"the",
"database",
"guest",
"is",
"active",
"."
] | def _service_is_active(self):
"""
Check that the database guest is active.
This function is meant to be called with poll_until to check that
the guest is alive before sending a 'create' message. This prevents
over billing a customer for an instance that they can never use.
... | [
"def",
"_service_is_active",
"(",
"self",
")",
":",
"service",
"=",
"InstanceServiceStatus",
".",
"find_by",
"(",
"instance_id",
"=",
"self",
".",
"id",
")",
"status",
"=",
"service",
".",
"get_status",
"(",
")",
"if",
"(",
"status",
"==",
"srvstatus",
"."... | https://github.com/openstack/trove/blob/be86b79119d16ee77f596172f43b0c97cb2617bd/trove/taskmanager/models.py#L769-L820 | |
mgedmin/check-manifest | 19f0a43ba00ecc536832f93801cf4446ea42e9b4 | check_manifest.py | python | cd | (directory) | Change the current working directory, temporarily.
Use as a context manager: with cd(d): ... | Change the current working directory, temporarily. | [
"Change",
"the",
"current",
"working",
"directory",
"temporarily",
"."
] | def cd(directory):
"""Change the current working directory, temporarily.
Use as a context manager: with cd(d): ...
"""
old_dir = os.getcwd()
try:
os.chdir(directory)
yield
finally:
os.chdir(old_dir) | [
"def",
"cd",
"(",
"directory",
")",
":",
"old_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"os",
".",
"chdir",
"(",
"directory",
")",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(",
"old_dir",
")"
] | https://github.com/mgedmin/check-manifest/blob/19f0a43ba00ecc536832f93801cf4446ea42e9b4/check_manifest.py#L171-L181 | ||
chainer/chainer | e9da1423255c58c37be9733f51b158aa9b39dc93 | chainermn/communicators/communicator_base.py | python | CommunicatorBase.rank | (self) | Rank (process id in the cluster) of this process in integer. | Rank (process id in the cluster) of this process in integer. | [
"Rank",
"(",
"process",
"id",
"in",
"the",
"cluster",
")",
"of",
"this",
"process",
"in",
"integer",
"."
] | def rank(self):
'''Rank (process id in the cluster) of this process in integer.'''
raise NotImplementedError() | [
"def",
"rank",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | https://github.com/chainer/chainer/blob/e9da1423255c58c37be9733f51b158aa9b39dc93/chainermn/communicators/communicator_base.py#L44-L46 | ||
TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e | java/java2py/antlr-3.1.3/runtime/Python/antlr3/debug.py | python | DebugEventListener.becomeRoot | (self, newRoot, oldRoot) | Make a node the new root of an existing root.
Note: the newRootID parameter is possibly different
than the TreeAdaptor.becomeRoot() newRoot parameter.
In our case, it will always be the result of calling
TreeAdaptor.becomeRoot() and not root_n or whatever.
The listener should a... | Make a node the new root of an existing root. | [
"Make",
"a",
"node",
"the",
"new",
"root",
"of",
"an",
"existing",
"root",
"."
] | def becomeRoot(self, newRoot, oldRoot):
"""Make a node the new root of an existing root.
Note: the newRootID parameter is possibly different
than the TreeAdaptor.becomeRoot() newRoot parameter.
In our case, it will always be the result of calling
TreeAdaptor.becomeRoot() and not root_n... | [
"def",
"becomeRoot",
"(",
"self",
",",
"newRoot",
",",
"oldRoot",
")",
":",
"pass"
] | https://github.com/TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials/blob/5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e/java/java2py/antlr-3.1.3/runtime/Python/antlr3/debug.py#L688-L705 | ||
golismero/golismero | 7d605b937e241f51c1ca4f47b20f755eeefb9d76 | thirdparty_libs/nltk/app/wordnet_app.py | python | Reference.encode | (self) | return base64.urlsafe_b64encode(string) | Encode this reference into a string to be used in a URL. | Encode this reference into a string to be used in a URL. | [
"Encode",
"this",
"reference",
"into",
"a",
"string",
"to",
"be",
"used",
"in",
"a",
"URL",
"."
] | def encode(self):
"""
Encode this reference into a string to be used in a URL.
"""
# This uses a tuple rather than an object since the python
# pickle representation is much smaller and there is no need
# to represent the complete object.
string = cPickle.dumps((s... | [
"def",
"encode",
"(",
"self",
")",
":",
"# This uses a tuple rather than an object since the python",
"# pickle representation is much smaller and there is no need",
"# to represent the complete object.",
"string",
"=",
"cPickle",
".",
"dumps",
"(",
"(",
"self",
".",
"word",
",... | https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/thirdparty_libs/nltk/app/wordnet_app.py#L690-L698 | |
unknown-horizons/unknown-horizons | 7397fb333006d26c3d9fe796c7bd9cb8c3b43a49 | horizons/world/__init__.py | python | World.get_health_instances | (self, position=None, radius=None) | return instances | Returns all instances that have health | Returns all instances that have health | [
"Returns",
"all",
"instances",
"that",
"have",
"health"
] | def get_health_instances(self, position=None, radius=None):
"""Returns all instances that have health"""
instances = []
for instance in self.get_ships(position, radius) + \
self.get_ground_units(position, radius):
if instance.has_component(HealthComponent):
instances.append(instance)
re... | [
"def",
"get_health_instances",
"(",
"self",
",",
"position",
"=",
"None",
",",
"radius",
"=",
"None",
")",
":",
"instances",
"=",
"[",
"]",
"for",
"instance",
"in",
"self",
".",
"get_ships",
"(",
"position",
",",
"radius",
")",
"+",
"self",
".",
"get_g... | https://github.com/unknown-horizons/unknown-horizons/blob/7397fb333006d26c3d9fe796c7bd9cb8c3b43a49/horizons/world/__init__.py#L637-L644 | |
scikit-hep/root_numpy | b062fefe5ee8164aea6c90d7d4435890a87dc112 | root_numpy/_graph.py | python | fill_graph | (graph, array) | Fill a ROOT graph with a NumPy array.
Parameters
----------
graph : a ROOT TGraph or TGraph2D
The ROOT graph to fill.
array : numpy array of shape [n_samples, n_dimensions]
The values to fill the graph with. The number of columns must match the
dimensionality of the graph. | Fill a ROOT graph with a NumPy array. | [
"Fill",
"a",
"ROOT",
"graph",
"with",
"a",
"NumPy",
"array",
"."
] | def fill_graph(graph, array):
"""Fill a ROOT graph with a NumPy array.
Parameters
----------
graph : a ROOT TGraph or TGraph2D
The ROOT graph to fill.
array : numpy array of shape [n_samples, n_dimensions]
The values to fill the graph with. The number of columns must match the
... | [
"def",
"fill_graph",
"(",
"graph",
",",
"array",
")",
":",
"import",
"ROOT",
"array",
"=",
"np",
".",
"asarray",
"(",
"array",
",",
"dtype",
"=",
"np",
".",
"double",
")",
"if",
"isinstance",
"(",
"graph",
",",
"ROOT",
".",
"TGraph",
")",
":",
"if"... | https://github.com/scikit-hep/root_numpy/blob/b062fefe5ee8164aea6c90d7d4435890a87dc112/root_numpy/_graph.py#L10-L44 | ||
moraes/tipfy | 20cc0dab85f5433e399ae2d948d2b32dad051d66 | tipfy/appengine/taskqueue.py | python | Mapper._continue | (self, start_key, batch_size) | Processes a batch of entities. | Processes a batch of entities. | [
"Processes",
"a",
"batch",
"of",
"entities",
"."
] | def _continue(self, start_key, batch_size):
"""Processes a batch of entities."""
q = self.get_query()
# If we're resuming, pick up where we left off last time.
if start_key:
q.filter('__key__ >', start_key)
# Keep updating records until we run out of time.
tr... | [
"def",
"_continue",
"(",
"self",
",",
"start_key",
",",
"batch_size",
")",
":",
"q",
"=",
"self",
".",
"get_query",
"(",
")",
"# If we're resuming, pick up where we left off last time.",
"if",
"start_key",
":",
"q",
".",
"filter",
"(",
"'__key__ >'",
",",
"start... | https://github.com/moraes/tipfy/blob/20cc0dab85f5433e399ae2d948d2b32dad051d66/tipfy/appengine/taskqueue.py#L138-L171 | ||
bendmorris/static-python | 2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473 | Lib/datetime.py | python | date.toordinal | (self) | return _ymd2ord(self._year, self._month, self._day) | Return proleptic Gregorian ordinal for the year, month and day.
January 1 of year 1 is day 1. Only the year, month and day values
contribute to the result. | Return proleptic Gregorian ordinal for the year, month and day. | [
"Return",
"proleptic",
"Gregorian",
"ordinal",
"for",
"the",
"year",
"month",
"and",
"day",
"."
] | def toordinal(self):
"""Return proleptic Gregorian ordinal for the year, month and day.
January 1 of year 1 is day 1. Only the year, month and day values
contribute to the result.
"""
return _ymd2ord(self._year, self._month, self._day) | [
"def",
"toordinal",
"(",
"self",
")",
":",
"return",
"_ymd2ord",
"(",
"self",
".",
"_year",
",",
"self",
".",
"_month",
",",
"self",
".",
"_day",
")"
] | https://github.com/bendmorris/static-python/blob/2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473/Lib/datetime.py#L766-L772 | |
Nuitka/Nuitka | 39262276993757fa4e299f497654065600453fc9 | nuitka/build/inline_copy/jinja2/jinja2/environment.py | python | create_cache | (size) | return LRUCache(size) | Return the cache class for the given size. | Return the cache class for the given size. | [
"Return",
"the",
"cache",
"class",
"for",
"the",
"given",
"size",
"."
] | def create_cache(size):
"""Return the cache class for the given size."""
if size == 0:
return None
if size < 0:
return {}
return LRUCache(size) | [
"def",
"create_cache",
"(",
"size",
")",
":",
"if",
"size",
"==",
"0",
":",
"return",
"None",
"if",
"size",
"<",
"0",
":",
"return",
"{",
"}",
"return",
"LRUCache",
"(",
"size",
")"
] | https://github.com/Nuitka/Nuitka/blob/39262276993757fa4e299f497654065600453fc9/nuitka/build/inline_copy/jinja2/jinja2/environment.py#L60-L66 | |
getway/diting | 58b6c99dbda2fd6855944cccdc93a702f192bd3e | apps/common/utils.py | python | generate_activation_code | (len=20, n=20) | return [''.join([random.choice(chars) for _ in range(len)]) for _ in range(n)] | 生成n个长度为len的随机序列码 | 生成n个长度为len的随机序列码 | [
"生成n个长度为len的随机序列码"
] | def generate_activation_code(len=20, n=20):
'''生成n个长度为len的随机序列码'''
random.seed()
chars = string.ascii_letters + string.digits
return [''.join([random.choice(chars) for _ in range(len)]) for _ in range(n)] | [
"def",
"generate_activation_code",
"(",
"len",
"=",
"20",
",",
"n",
"=",
"20",
")",
":",
"random",
".",
"seed",
"(",
")",
"chars",
"=",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
"return",
"[",
"''",
".",
"join",
"(",
"[",
"random"... | https://github.com/getway/diting/blob/58b6c99dbda2fd6855944cccdc93a702f192bd3e/apps/common/utils.py#L385-L389 | |
smokeleeteveryday/CTF_WRITEUPS | 4683f0d41c92c4ed407cc3dd3b1760c68a05943f | 2015/CODEGATE/web/owltube/challenge/index.py | python | logout | () | return resp | [] | def logout():
resp = make_response(redirect(url_for('index')))
resp.set_cookie("auth", "")
return resp | [
"def",
"logout",
"(",
")",
":",
"resp",
"=",
"make_response",
"(",
"redirect",
"(",
"url_for",
"(",
"'index'",
")",
")",
")",
"resp",
".",
"set_cookie",
"(",
"\"auth\"",
",",
"\"\"",
")",
"return",
"resp"
] | https://github.com/smokeleeteveryday/CTF_WRITEUPS/blob/4683f0d41c92c4ed407cc3dd3b1760c68a05943f/2015/CODEGATE/web/owltube/challenge/index.py#L132-L135 | |||
raganmd/TD-Examples | 4d2859ac09e65a71602594271da368adbc0354ad | ragan/python_in_touchdesigner/example_modules/text_module1.py | python | Full_date | () | return formatted_text | Create a formatted time stamp
A look at how we might create a formatted time stamp to use with
various logging applications.
Arguments
---------------
None
Returns
---------------
formatted_text( str ) - a string time stamp
Notes
--------------- | Create a formatted time stamp | [
"Create",
"a",
"formatted",
"time",
"stamp"
] | def Full_date():
'''Create a formatted time stamp
A look at how we might create a formatted time stamp to use with
various logging applications.
Arguments
---------------
None
Returns
---------------
formatted_text( str ) - a string time stamp
Notes
---------------
'''
now = datetime.datetime.now(... | [
"def",
"Full_date",
"(",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"year",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"year",
"month",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"... | https://github.com/raganmd/TD-Examples/blob/4d2859ac09e65a71602594271da368adbc0354ad/ragan/python_in_touchdesigner/example_modules/text_module1.py#L38-L75 | |
schollii/pypubsub | dd5c1e848ff501b192a26a0a0187e618fda13f97 | src/pubsub/core/listener.py | python | ListenerValidator.isValid | (self, listener: UserListener, curriedArgNames: Sequence[str] = None) | Same as validate() but returns True/False instead of raising an exception. | Same as validate() but returns True/False instead of raising an exception. | [
"Same",
"as",
"validate",
"()",
"but",
"returns",
"True",
"/",
"False",
"instead",
"of",
"raising",
"an",
"exception",
"."
] | def isValid(self, listener: UserListener, curriedArgNames: Sequence[str] = None) -> bool:
"""Same as validate() but returns True/False instead of raising an exception."""
try:
self.validate(listener, curriedArgNames=curriedArgNames)
return True
except ListenerMismatchErro... | [
"def",
"isValid",
"(",
"self",
",",
"listener",
":",
"UserListener",
",",
"curriedArgNames",
":",
"Sequence",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"try",
":",
"self",
".",
"validate",
"(",
"listener",
",",
"curriedArgNames",
"=",
"currie... | https://github.com/schollii/pypubsub/blob/dd5c1e848ff501b192a26a0a0187e618fda13f97/src/pubsub/core/listener.py#L279-L285 | ||
svetlyak40wt/django-tagging-ng | 7eb967649a713e1ab3b9b76fccbb91cd0fe5fddd | tagging/fields.py | python | TagField.__set__ | (self, instance, value) | Set an object's tags. | Set an object's tags. | [
"Set",
"an",
"object",
"s",
"tags",
"."
] | def __set__(self, instance, value):
"""
Set an object's tags.
"""
if instance is None:
raise AttributeError(_('%s can only be set on instances.') % self.name)
if settings.FORCE_LOWERCASE_TAGS and value is not None:
value = value.lower()
self._set_i... | [
"def",
"__set__",
"(",
"self",
",",
"instance",
",",
"value",
")",
":",
"if",
"instance",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"_",
"(",
"'%s can only be set on instances.'",
")",
"%",
"self",
".",
"name",
")",
"if",
"settings",
".",
"FORCE_L... | https://github.com/svetlyak40wt/django-tagging-ng/blob/7eb967649a713e1ab3b9b76fccbb91cd0fe5fddd/tagging/fields.py#L70-L78 | ||
Cadene/tensorflow-model-zoo.torch | 990b10ffc22d4c8eacb2a502f20415b4f70c74c2 | models/research/cognitive_mapping_and_planning/tfcode/cmp_utils.py | python | deconv | (x, is_training, wt_decay, neurons, strides, layers_per_block,
kernel_size, conv_fn, name, offset=0) | return x, outs | Generates a up sampling network with residual connections. | Generates a up sampling network with residual connections. | [
"Generates",
"a",
"up",
"sampling",
"network",
"with",
"residual",
"connections",
"."
] | def deconv(x, is_training, wt_decay, neurons, strides, layers_per_block,
kernel_size, conv_fn, name, offset=0):
"""Generates a up sampling network with residual connections.
"""
batch_norm_param = {'center': True, 'scale': True,
'activation_fn': tf.nn.relu,
... | [
"def",
"deconv",
"(",
"x",
",",
"is_training",
",",
"wt_decay",
",",
"neurons",
",",
"strides",
",",
"layers_per_block",
",",
"kernel_size",
",",
"conv_fn",
",",
"name",
",",
"offset",
"=",
"0",
")",
":",
"batch_norm_param",
"=",
"{",
"'center'",
":",
"T... | https://github.com/Cadene/tensorflow-model-zoo.torch/blob/990b10ffc22d4c8eacb2a502f20415b4f70c74c2/models/research/cognitive_mapping_and_planning/tfcode/cmp_utils.py#L113-L130 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.