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
amperser/proselint
eaf108a8b2237fea07f1294c9922103d2f980a33
proselint/command_line.py
python
_delete_compiled_python_files
()
Remove files with a 'pyc' extension.
Remove files with a 'pyc' extension.
[ "Remove", "files", "with", "a", "pyc", "extension", "." ]
def _delete_compiled_python_files(): """Remove files with a 'pyc' extension.""" for path, _, files in os.walk(os.getcwd()): for fname in [f for f in files if os.path.splitext(f)[1] == ".pyc"]: try: os.remove(os.path.join(path, fname)) except OSError: ...
[ "def", "_delete_compiled_python_files", "(", ")", ":", "for", "path", ",", "_", ",", "files", "in", "os", ".", "walk", "(", "os", ".", "getcwd", "(", ")", ")", ":", "for", "fname", "in", "[", "f", "for", "f", "in", "files", "if", "os", ".", "path...
https://github.com/amperser/proselint/blob/eaf108a8b2237fea07f1294c9922103d2f980a33/proselint/command_line.py#L48-L55
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/full/argparse.py
python
ArgumentParser.__init__
(self, prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=HelpFormatter, prefix_chars='-', fromfile_prefix_chars=None, argument_default=...
[]
def __init__(self, prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=HelpFormatter, prefix_chars='-', fromfile_prefix_chars=None, argum...
[ "def", "__init__", "(", "self", ",", "prog", "=", "None", ",", "usage", "=", "None", ",", "description", "=", "None", ",", "epilog", "=", "None", ",", "parents", "=", "[", "]", ",", "formatter_class", "=", "HelpFormatter", ",", "prefix_chars", "=", "'-...
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/argparse.py#L1689-L1750
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-windows/x86/ldap3/strategy/ldifProducer.py
python
LdifProducerStrategy._open_socket
(self, address, use_ssl=False, unix_socket=False)
[]
def _open_socket(self, address, use_ssl=False, unix_socket=False): # fake open socket self.connection.socket = NotImplemented # placeholder for a dummy socket if self.connection.usage: self.connection._usage.open_sockets += 1 self.connection.closed = False
[ "def", "_open_socket", "(", "self", ",", "address", ",", "use_ssl", "=", "False", ",", "unix_socket", "=", "False", ")", ":", "# fake open socket", "self", ".", "connection", ".", "socket", "=", "NotImplemented", "# placeholder for a dummy socket", "if", "self", ...
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-windows/x86/ldap3/strategy/ldifProducer.py#L61-L66
TheSouthFrog/stylealign
910632d2fccc9db61b00c265ae18a88913113c1d
util/curve.py
python
curve_fitting
(points, samples, index)
return curve_tmp
[]
def curve_fitting(points, samples, index): num_points = points.shape[0] assert(num_points > 1) valid_points = [points[0]] for i in range(1,num_points): if (distance(points[i, :], points[i-1, :]) > 0.001): valid_points.append(points[i, :]) assert(len(valid_points) > 1) valid_points = np.asarray(val...
[ "def", "curve_fitting", "(", "points", ",", "samples", ",", "index", ")", ":", "num_points", "=", "points", ".", "shape", "[", "0", "]", "assert", "(", "num_points", ">", "1", ")", "valid_points", "=", "[", "points", "[", "0", "]", "]", "for", "i", ...
https://github.com/TheSouthFrog/stylealign/blob/910632d2fccc9db61b00c265ae18a88913113c1d/util/curve.py#L40-L121
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/Python-2.7.9/Tools/scripts/xxci.py
python
differing
(file)
return sts != 0
[]
def differing(file): cmd = 'co -p ' + file + ' 2>/dev/null | cmp -s - ' + file sts = os.system(cmd) return sts != 0
[ "def", "differing", "(", "file", ")", ":", "cmd", "=", "'co -p '", "+", "file", "+", "' 2>/dev/null | cmp -s - '", "+", "file", "sts", "=", "os", ".", "system", "(", "cmd", ")", "return", "sts", "!=", "0" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Tools/scripts/xxci.py#L98-L101
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/core/ext-py/boto-2.46.1/boto/mturk/connection.py
python
MTurkConnection.set_reviewing
(self, hit_id, revert=None)
return self._process_request('SetHITAsReviewing', params)
Update a HIT with a status of Reviewable to have a status of Reviewing, or reverts a Reviewing HIT back to the Reviewable status. Only HITs with a status of Reviewable can be updated with a status of Reviewing. Similarly, only Reviewing HITs can be reverted back to a status of Reviewab...
Update a HIT with a status of Reviewable to have a status of Reviewing, or reverts a Reviewing HIT back to the Reviewable status.
[ "Update", "a", "HIT", "with", "a", "status", "of", "Reviewable", "to", "have", "a", "status", "of", "Reviewing", "or", "reverts", "a", "Reviewing", "HIT", "back", "to", "the", "Reviewable", "status", "." ]
def set_reviewing(self, hit_id, revert=None): """ Update a HIT with a status of Reviewable to have a status of Reviewing, or reverts a Reviewing HIT back to the Reviewable status. Only HITs with a status of Reviewable can be updated with a status of Reviewing. Similarly, only R...
[ "def", "set_reviewing", "(", "self", ",", "hit_id", ",", "revert", "=", "None", ")", ":", "params", "=", "{", "'HITId'", ":", "hit_id", "}", "if", "revert", ":", "params", "[", "'Revert'", "]", "=", "revert", "return", "self", ".", "_process_request", ...
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/boto-2.46.1/boto/mturk/connection.py#L468-L480
PyTorchLightning/pytorch-lightning
5914fb748fb53d826ab337fc2484feab9883a104
pytorch_lightning/loops/base.py
python
Loop.on_load_checkpoint
(self, state_dict: Dict)
Called when loading a model checkpoint, use to reload loop state.
Called when loading a model checkpoint, use to reload loop state.
[ "Called", "when", "loading", "a", "model", "checkpoint", "use", "to", "reload", "loop", "state", "." ]
def on_load_checkpoint(self, state_dict: Dict) -> None: """Called when loading a model checkpoint, use to reload loop state."""
[ "def", "on_load_checkpoint", "(", "self", ",", "state_dict", ":", "Dict", ")", "->", "None", ":" ]
https://github.com/PyTorchLightning/pytorch-lightning/blob/5914fb748fb53d826ab337fc2484feab9883a104/pytorch_lightning/loops/base.py#L261-L262
sdispater/orator
0666e522be914db285b6936e3c36801fc1a9c2e7
orator/orm/relations/morph_to.py
python
MorphTo.match
(self, models, results, relation)
return models
Match the eagerly loaded results to their parents. :type models: Collection :type results: Collection :type relation: str
Match the eagerly loaded results to their parents.
[ "Match", "the", "eagerly", "loaded", "results", "to", "their", "parents", "." ]
def match(self, models, results, relation): """ Match the eagerly loaded results to their parents. :type models: Collection :type results: Collection :type relation: str """ return models
[ "def", "match", "(", "self", ",", "models", ",", "results", ",", "relation", ")", ":", "return", "models" ]
https://github.com/sdispater/orator/blob/0666e522be914db285b6936e3c36801fc1a9c2e7/orator/orm/relations/morph_to.py#L68-L76
gem/oq-engine
1bdb88f3914e390abcbd285600bfd39477aae47c
openquake/hazardlib/nrml.py
python
get
(xml, investigation_time=50., rupture_mesh_spacing=5., width_of_mfd_bin=1.0, area_source_discretization=10)
return src
:param xml: the XML representation of a source :param investigation_time: investigation time :param rupture_mesh_spacing: rupture mesh spacing :param width_of_mfd_bin: width of MFD bin :param area_source_discretization: area source discretization :returns: a python source object
:param xml: the XML representation of a source :param investigation_time: investigation time :param rupture_mesh_spacing: rupture mesh spacing :param width_of_mfd_bin: width of MFD bin :param area_source_discretization: area source discretization :returns: a python source object
[ ":", "param", "xml", ":", "the", "XML", "representation", "of", "a", "source", ":", "param", "investigation_time", ":", "investigation", "time", ":", "param", "rupture_mesh_spacing", ":", "rupture", "mesh", "spacing", ":", "param", "width_of_mfd_bin", ":", "widt...
def get(xml, investigation_time=50., rupture_mesh_spacing=5., width_of_mfd_bin=1.0, area_source_discretization=10): """ :param xml: the XML representation of a source :param investigation_time: investigation time :param rupture_mesh_spacing: rupture mesh spacing :param width_of_mfd_bin: widt...
[ "def", "get", "(", "xml", ",", "investigation_time", "=", "50.", ",", "rupture_mesh_spacing", "=", "5.", ",", "width_of_mfd_bin", "=", "1.0", ",", "area_source_discretization", "=", "10", ")", ":", "text", "=", "'''<?xml version='1.0' encoding='UTF-8'?>\n<nrml xmlns=\...
https://github.com/gem/oq-engine/blob/1bdb88f3914e390abcbd285600bfd39477aae47c/openquake/hazardlib/nrml.py#L417-L440
JimmXinu/FanFicFare
bc149a2deb2636320fe50a3e374af6eef8f61889
fanficfare/adapters/adapter_storiesonlinenet.py
python
StoriesOnlineNetAdapter.parseDate
(self,label)
return value
[]
def parseDate(self,label): # date is passed as a timestamp and converted in JS. used to # use noscript value instead, but found one story that didn't # include it. # <script> tag processing not working? # logger.debug('parseDate label: "%s"' % label) script = label.findN...
[ "def", "parseDate", "(", "self", ",", "label", ")", ":", "# date is passed as a timestamp and converted in JS. used to", "# use noscript value instead, but found one story that didn't", "# include it.", "# <script> tag processing not working?", "# logger.debug('parseDate label: \"%s\"' % la...
https://github.com/JimmXinu/FanFicFare/blob/bc149a2deb2636320fe50a3e374af6eef8f61889/fanficfare/adapters/adapter_storiesonlinenet.py#L392-L416
thenetcircle/dino
1047c3458e91a1b4189e9f48f1393b3a68a935b3
dino/cache/__init__.py
python
ICache.set_all_permanent_rooms
(self, rooms)
:param rooms: :return:
[]
def set_all_permanent_rooms(self, rooms): """ :param rooms: :return: """
[ "def", "set_all_permanent_rooms", "(", "self", ",", "rooms", ")", ":" ]
https://github.com/thenetcircle/dino/blob/1047c3458e91a1b4189e9f48f1393b3a68a935b3/dino/cache/__init__.py#L159-L164
mcedit/mcedit2
4bb98da521447b6cf43d923cea9f00acf2f427e9
src/mcedit2/widgets/layout.py
python
Column
(*a, **kw)
return box
:rtype: QtGui.QVBoxLayout
:rtype: QtGui.QVBoxLayout
[ ":", "rtype", ":", "QtGui", ".", "QVBoxLayout" ]
def Column(*a, **kw): """ :rtype: QtGui.QVBoxLayout """ margin = kw.pop('margin', None) box = QtGui.QVBoxLayout(**kw) _Box(box, *a) if margin is not None: box.setContentsMargins(margin, margin, margin, margin) return box
[ "def", "Column", "(", "*", "a", ",", "*", "*", "kw", ")", ":", "margin", "=", "kw", ".", "pop", "(", "'margin'", ",", "None", ")", "box", "=", "QtGui", ".", "QVBoxLayout", "(", "*", "*", "kw", ")", "_Box", "(", "box", ",", "*", "a", ")", "i...
https://github.com/mcedit/mcedit2/blob/4bb98da521447b6cf43d923cea9f00acf2f427e9/src/mcedit2/widgets/layout.py#L41-L50
google/tf-quant-finance
8fd723689ebf27ff4bb2bd2acb5f6091c5e07309
tf_quant_finance/experimental/finite_difference/methods.py
python
non_uniform_grid
(num, ndim, skip=42, large=False)
return sobol_seq.i4_sobol_generate(ndim, num, skip=skip)
Build a non-uniform grid with num points of ndim dimensions.
Build a non-uniform grid with num points of ndim dimensions.
[ "Build", "a", "non", "-", "uniform", "grid", "with", "num", "points", "of", "ndim", "dimensions", "." ]
def non_uniform_grid(num, ndim, skip=42, large=False): """Build a non-uniform grid with num points of ndim dimensions.""" if not large: _check_not_too_large(num * ndim) return sobol_seq.i4_sobol_generate(ndim, num, skip=skip)
[ "def", "non_uniform_grid", "(", "num", ",", "ndim", ",", "skip", "=", "42", ",", "large", "=", "False", ")", ":", "if", "not", "large", ":", "_check_not_too_large", "(", "num", "*", "ndim", ")", "return", "sobol_seq", ".", "i4_sobol_generate", "(", "ndim...
https://github.com/google/tf-quant-finance/blob/8fd723689ebf27ff4bb2bd2acb5f6091c5e07309/tf_quant_finance/experimental/finite_difference/methods.py#L43-L47
mailgun/expiringdict
2dfafb4db837c44d7ef9b1c49f591d52c0713bd1
expiringdict/__init__.py
python
ExpiringDict.fromkeys
(self)
Create a new dictionary with keys from seq and values set to value.
Create a new dictionary with keys from seq and values set to value.
[ "Create", "a", "new", "dictionary", "with", "keys", "from", "seq", "and", "values", "set", "to", "value", "." ]
def fromkeys(self): """ Create a new dictionary with keys from seq and values set to value. """ raise NotImplementedError()
[ "def", "fromkeys", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
https://github.com/mailgun/expiringdict/blob/2dfafb4db837c44d7ef9b1c49f591d52c0713bd1/expiringdict/__init__.py#L169-L171
BitconFeng/Deep-Feature-video
fff73fbcd0e21d5db566d2b63c644e18b2732551
rfcn/symbols/resnet_v1_101_rfcn.py
python
resnet_v1_101_rfcn.__init__
(self)
Use __init__ to define parameter network needs
Use __init__ to define parameter network needs
[ "Use", "__init__", "to", "define", "parameter", "network", "needs" ]
def __init__(self): """ Use __init__ to define parameter network needs """ self.eps = 1e-5 self.use_global_stats = True self.workspace = 512 self.units = (3, 4, 23, 3) # use for 101 self.filter_list = [256, 512, 1024, 2048]
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "eps", "=", "1e-5", "self", ".", "use_global_stats", "=", "True", "self", ".", "workspace", "=", "512", "self", ".", "units", "=", "(", "3", ",", "4", ",", "23", ",", "3", ")", "# use for 101",...
https://github.com/BitconFeng/Deep-Feature-video/blob/fff73fbcd0e21d5db566d2b63c644e18b2732551/rfcn/symbols/resnet_v1_101_rfcn.py#L18-L26
scipy/scipy
e0a749f01e79046642ccfdc419edbf9e7ca141ad
scipy/io/matlab/_mio5.py
python
MatFile5Reader.guess_byte_order
(self)
return mi == b'IM' and '<' or '>'
Guess byte order. Sets stream pointer to 0
Guess byte order. Sets stream pointer to 0
[ "Guess", "byte", "order", ".", "Sets", "stream", "pointer", "to", "0" ]
def guess_byte_order(self): ''' Guess byte order. Sets stream pointer to 0''' self.mat_stream.seek(126) mi = self.mat_stream.read(2) self.mat_stream.seek(0) return mi == b'IM' and '<' or '>'
[ "def", "guess_byte_order", "(", "self", ")", ":", "self", ".", "mat_stream", ".", "seek", "(", "126", ")", "mi", "=", "self", ".", "mat_stream", ".", "read", "(", "2", ")", "self", ".", "mat_stream", ".", "seek", "(", "0", ")", "return", "mi", "=="...
https://github.com/scipy/scipy/blob/e0a749f01e79046642ccfdc419edbf9e7ca141ad/scipy/io/matlab/_mio5.py#L209-L215
OpenCobolIDE/OpenCobolIDE
c78d0d335378e5fe0a5e74f53c19b68b55e85388
open_cobol_ide/extlibs/pyqode/core/modes/pygments_sh.py
python
PygmentsSH.pygments_style
(self, value)
[]
def pygments_style(self, value): self._pygments_style = value self._update_style() # triggers a rehighlight self.color_scheme = ColorScheme(value)
[ "def", "pygments_style", "(", "self", ",", "value", ")", ":", "self", ".", "_pygments_style", "=", "value", "self", ".", "_update_style", "(", ")", "# triggers a rehighlight", "self", ".", "color_scheme", "=", "ColorScheme", "(", "value", ")" ]
https://github.com/OpenCobolIDE/OpenCobolIDE/blob/c78d0d335378e5fe0a5e74f53c19b68b55e85388/open_cobol_ide/extlibs/pyqode/core/modes/pygments_sh.py#L155-L159
MartinThoma/algorithms
6199cfa3446e1056c7b4d75ca6e306e9e56fd95b
codejam/2016/1-Qualification/B.py
python
remove_end_plus
(s)
return new_s[::-1]
Remove plusses at the end.
Remove plusses at the end.
[ "Remove", "plusses", "at", "the", "end", "." ]
def remove_end_plus(s): """Remove plusses at the end.""" r = s[::-1] new_s = "" seen_minus = False for el in r: if not seen_minus: if el == "-": seen_minus = True new_s = el else: new_s += el return new_s[::-1]
[ "def", "remove_end_plus", "(", "s", ")", ":", "r", "=", "s", "[", ":", ":", "-", "1", "]", "new_s", "=", "\"\"", "seen_minus", "=", "False", "for", "el", "in", "r", ":", "if", "not", "seen_minus", ":", "if", "el", "==", "\"-\"", ":", "seen_minus"...
https://github.com/MartinThoma/algorithms/blob/6199cfa3446e1056c7b4d75ca6e306e9e56fd95b/codejam/2016/1-Qualification/B.py#L6-L18
IBM/lale
b4d6829c143a4735b06083a0e6c70d2cca244162
lale/util/numpy_to_torch_dataset.py
python
NumpyTorchDataset.__len__
(self)
return self.X.shape[0]
[]
def __len__(self): return self.X.shape[0]
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "X", ".", "shape", "[", "0", "]" ]
https://github.com/IBM/lale/blob/b4d6829c143a4735b06083a0e6c70d2cca244162/lale/util/numpy_to_torch_dataset.py#L42-L43
twilio/twilio-python
6e1e811ea57a1edfadd5161ace87397c563f6915
twilio/rest/api/v2010/account/usage/record/today.py
python
TodayInstance.description
(self)
return self._properties['description']
:returns: A plain-language description of the usage category :rtype: unicode
:returns: A plain-language description of the usage category :rtype: unicode
[ ":", "returns", ":", "A", "plain", "-", "language", "description", "of", "the", "usage", "category", ":", "rtype", ":", "unicode" ]
def description(self): """ :returns: A plain-language description of the usage category :rtype: unicode """ return self._properties['description']
[ "def", "description", "(", "self", ")", ":", "return", "self", ".", "_properties", "[", "'description'", "]" ]
https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/api/v2010/account/usage/record/today.py#L525-L530
ring04h/weakfilescan
b1a3066e3fdcd60b8ecf635526f49cb5ad603064
libs/requests/packages/chardet/latin1prober.py
python
Latin1Prober.get_confidence
(self)
return confidence
[]
def get_confidence(self): if self.get_state() == eNotMe: return 0.01 total = sum(self._mFreqCounter) if total < 0.01: confidence = 0.0 else: confidence = ((self._mFreqCounter[3] - self._mFreqCounter[1] * 20.0) / total) ...
[ "def", "get_confidence", "(", "self", ")", ":", "if", "self", ".", "get_state", "(", ")", "==", "eNotMe", ":", "return", "0.01", "total", "=", "sum", "(", "self", ".", "_mFreqCounter", ")", "if", "total", "<", "0.01", ":", "confidence", "=", "0.0", "...
https://github.com/ring04h/weakfilescan/blob/b1a3066e3fdcd60b8ecf635526f49cb5ad603064/libs/requests/packages/chardet/latin1prober.py#L124-L139
cgat-developers/ruffus
fc8fa8dcf7b5f4b877e5bb712146e87abd26d046
doc/static_data/example_scripts/complicated_example.py
python
generate_params_for_combining_evolutionary_analyses
()
Custom function to combining evolutionary analyses per unknown gene set
Custom function to combining evolutionary analyses per unknown gene set
[ "Custom", "function", "to", "combining", "evolutionary", "analyses", "per", "unknown", "gene", "set" ]
def generate_params_for_combining_evolutionary_analyses (): """ Custom function to combining evolutionary analyses per unknown gene set """ gene_set_names = get_unknown_gene_set_names() for x in gene_set_names: results_files = glob.glob("%s/multiple_alignment/%s/*.evo_res" % (w_dir, x)) ...
[ "def", "generate_params_for_combining_evolutionary_analyses", "(", ")", ":", "gene_set_names", "=", "get_unknown_gene_set_names", "(", ")", "for", "x", "in", "gene_set_names", ":", "results_files", "=", "glob", ".", "glob", "(", "\"%s/multiple_alignment/%s/*.evo_res\"", "...
https://github.com/cgat-developers/ruffus/blob/fc8fa8dcf7b5f4b877e5bb712146e87abd26d046/doc/static_data/example_scripts/complicated_example.py#L436-L444
lukelbd/proplot
d0bc9c0857d9295b380b8613ef9aba81d50a067c
proplot/externals/hsluv.py
python
lchuv_to_hsluv
(triple)
return [H, S, L]
[]
def lchuv_to_hsluv(triple): L, C, H = triple if L > 99.9999999: return [H, 0.0, 100.0] if L < 0.00000001: return [H, 0.0, 0.0] mx = max_chroma(L, H) S = 100.0 * C / mx return [H, S, L]
[ "def", "lchuv_to_hsluv", "(", "triple", ")", ":", "L", ",", "C", ",", "H", "=", "triple", "if", "L", ">", "99.9999999", ":", "return", "[", "H", ",", "0.0", ",", "100.0", "]", "if", "L", "<", "0.00000001", ":", "return", "[", "H", ",", "0.0", "...
https://github.com/lukelbd/proplot/blob/d0bc9c0857d9295b380b8613ef9aba81d50a067c/proplot/externals/hsluv.py#L211-L219
cloudera/impyla
0c736af4cad2bade9b8e313badc08ec50e81c948
impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py
python
add_foreign_key_result.__init__
(self, o1=None, o2=None,)
[]
def __init__(self, o1=None, o2=None,): self.o1 = o1 self.o2 = o2
[ "def", "__init__", "(", "self", ",", "o1", "=", "None", ",", "o2", "=", "None", ",", ")", ":", "self", ".", "o1", "=", "o1", "self", ".", "o2", "=", "o2" ]
https://github.com/cloudera/impyla/blob/0c736af4cad2bade9b8e313badc08ec50e81c948/impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py#L14537-L14539
leancloud/satori
701caccbd4fe45765001ca60435c0cb499477c03
satori-rules/plugin/libs/requests/packages/chardet/chardistribution.py
python
SJISDistributionAnalysis.get_order
(self, aBuf)
return order
[]
def get_order(self, aBuf): # for sjis encoding, we are interested # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe # no validation needed here. State machine has done that first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(a...
[ "def", "get_order", "(", "self", ",", "aBuf", ")", ":", "# for sjis encoding, we are interested", "# first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe", "# second byte range: 0x40 -- 0x7e, 0x81 -- oxfe", "# no validation needed here. State machine has done that", "first_char", ",", "se...
https://github.com/leancloud/satori/blob/701caccbd4fe45765001ca60435c0cb499477c03/satori-rules/plugin/libs/requests/packages/chardet/chardistribution.py#L197-L212
twilio/twilio-python
6e1e811ea57a1edfadd5161ace87397c563f6915
twilio/rest/preview/understand/assistant/__init__.py
python
AssistantContext.__init__
(self, version, sid)
Initialize the AssistantContext :param Version version: Version that contains the resource :param sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.preview.understand.assistant.AssistantContext :rtype: twilio.rest.preview.understand.assistant.Assi...
Initialize the AssistantContext
[ "Initialize", "the", "AssistantContext" ]
def __init__(self, version, sid): """ Initialize the AssistantContext :param Version version: Version that contains the resource :param sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.preview.understand.assistant.AssistantContext ...
[ "def", "__init__", "(", "self", ",", "version", ",", "sid", ")", ":", "super", "(", "AssistantContext", ",", "self", ")", ".", "__init__", "(", "version", ")", "# Path Solution", "self", ".", "_solution", "=", "{", "'sid'", ":", "sid", ",", "}", "self"...
https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/preview/understand/assistant/__init__.py#L235-L259
treethought/flask-assistant
0cb4f20ca60f04e57b36d6eb127b10b403772c78
api_ai/api.py
python
ApiAi.post_intent
(self, intent_json)
return self._post(endpoint, data=intent_json)
Sends post request to create a new intent
Sends post request to create a new intent
[ "Sends", "post", "request", "to", "create", "a", "new", "intent" ]
def post_intent(self, intent_json): """Sends post request to create a new intent""" endpoint = self._intent_uri() return self._post(endpoint, data=intent_json)
[ "def", "post_intent", "(", "self", ",", "intent_json", ")", ":", "endpoint", "=", "self", ".", "_intent_uri", "(", ")", "return", "self", ".", "_post", "(", "endpoint", ",", "data", "=", "intent_json", ")" ]
https://github.com/treethought/flask-assistant/blob/0cb4f20ca60f04e57b36d6eb127b10b403772c78/api_ai/api.py#L91-L94
joxeankoret/pigaios
5548856559c7f2bf8d069a61a3bf4b7ee75f0536
pygments/scanner.py
python
Scanner.test
(self, pattern)
return self.check(pattern) is not None
Apply a pattern on the current position and check if it patches. Doesn't touch pos.
Apply a pattern on the current position and check if it patches. Doesn't touch pos.
[ "Apply", "a", "pattern", "on", "the", "current", "position", "and", "check", "if", "it", "patches", ".", "Doesn", "t", "touch", "pos", "." ]
def test(self, pattern): """Apply a pattern on the current position and check if it patches. Doesn't touch pos.""" return self.check(pattern) is not None
[ "def", "test", "(", "self", ",", "pattern", ")", ":", "return", "self", ".", "check", "(", "pattern", ")", "is", "not", "None" ]
https://github.com/joxeankoret/pigaios/blob/5548856559c7f2bf8d069a61a3bf4b7ee75f0536/pygments/scanner.py#L67-L70
nortikin/sverchok
7b460f01317c15f2681bfa3e337c5e7346f3711b
utils/intersect_edges.py
python
intersect_edges_3d_np
(verts, edges, s_epsilon, only_touching=True)
return np.concatenate([np_verts, inters]).tolist(), np.concatenate(new_edges).tolist()
Brute force Numpy implementation of edges intersections
Brute force Numpy implementation of edges intersections
[ "Brute", "force", "Numpy", "implementation", "of", "edges", "intersections" ]
def intersect_edges_3d_np(verts, edges, s_epsilon, only_touching=True): '''Brute force Numpy implementation of edges intersections''' indices = cross_indices_np(len(edges)) np_verts = verts if isinstance(verts, np.ndarray) else np.array(verts) np_edges = edges if isinstance(edges, np.ndarray) else np.ar...
[ "def", "intersect_edges_3d_np", "(", "verts", ",", "edges", ",", "s_epsilon", ",", "only_touching", "=", "True", ")", ":", "indices", "=", "cross_indices_np", "(", "len", "(", "edges", ")", ")", "np_verts", "=", "verts", "if", "isinstance", "(", "verts", "...
https://github.com/nortikin/sverchok/blob/7b460f01317c15f2681bfa3e337c5e7346f3711b/utils/intersect_edges.py#L183-L253
andresriancho/w3af
cd22e5252243a87aaa6d0ddea47cf58dacfe00a9
w3af/core/controllers/core_helpers/status.py
python
CoreStatus.has_finished_crawl
(self)
return dc.has_finished()
[]
def has_finished_crawl(self): dc = self._w3af_core.strategy.get_discovery_consumer() # The user never enabled crawl plugins or the scan has already finished # and no crawl plugins will be run if dc is None: return True return dc.has_finished()
[ "def", "has_finished_crawl", "(", "self", ")", ":", "dc", "=", "self", ".", "_w3af_core", ".", "strategy", ".", "get_discovery_consumer", "(", ")", "# The user never enabled crawl plugins or the scan has already finished", "# and no crawl plugins will be run", "if", "dc", "...
https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/core/controllers/core_helpers/status.py#L240-L248
rail-berkeley/softlearning
13cf187cc93d90f7c217ea2845067491c3c65464
softlearning/value_functions/base_value_function.py
python
BaseValueFunction.weights
(self)
return self.trainable_weights + self.non_trainable_weights
Returns the list of all policy variables/weights. Returns: A list of variables.
Returns the list of all policy variables/weights.
[ "Returns", "the", "list", "of", "all", "policy", "variables", "/", "weights", "." ]
def weights(self): """Returns the list of all policy variables/weights. Returns: A list of variables. """ return self.trainable_weights + self.non_trainable_weights
[ "def", "weights", "(", "self", ")", ":", "return", "self", ".", "trainable_weights", "+", "self", ".", "non_trainable_weights" ]
https://github.com/rail-berkeley/softlearning/blob/13cf187cc93d90f7c217ea2845067491c3c65464/softlearning/value_functions/base_value_function.py#L38-L44
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/django/template/response.py
python
SimpleTemplateResponse.resolve_template
(self, template)
Accepts a template object, path-to-template or list of paths
Accepts a template object, path-to-template or list of paths
[ "Accepts", "a", "template", "object", "path", "-", "to", "-", "template", "or", "list", "of", "paths" ]
def resolve_template(self, template): "Accepts a template object, path-to-template or list of paths" if isinstance(template, (list, tuple)): return select_template(template, using=self.using) elif isinstance(template, six.string_types): return get_template(template, using...
[ "def", "resolve_template", "(", "self", ",", "template", ")", ":", "if", "isinstance", "(", "template", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "select_template", "(", "template", ",", "using", "=", "self", ".", "using", ")", "elif", "...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/django/template/response.py#L63-L70
IronLanguages/ironpython3
7a7bb2a872eeab0d1009fc8a6e24dca43f65b693
Src/StdLib/Lib/curses/has_key.py
python
has_key
(ch)
[]
def has_key(ch): if isinstance(ch, str): ch = ord(ch) # Figure out the correct capability name for the keycode. capability_name = _capability_names.get(ch) if capability_name is None: return False #Check the current terminal description for that capability; #if present, return ...
[ "def", "has_key", "(", "ch", ")", ":", "if", "isinstance", "(", "ch", ",", "str", ")", ":", "ch", "=", "ord", "(", "ch", ")", "# Figure out the correct capability name for the keycode.", "capability_name", "=", "_capability_names", ".", "get", "(", "ch", ")", ...
https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/curses/has_key.py#L162-L176
a312863063/seeprettyface-generator-wanghong
77c5962cb7b194a1d3c5e052725ae23b48b140da
dnnlib/submission/run_context.py
python
RunContext.get_time_since_start
(self)
return time.time() - self.start_time
How much time has passed since the creation of the context.
How much time has passed since the creation of the context.
[ "How", "much", "time", "has", "passed", "since", "the", "creation", "of", "the", "context", "." ]
def get_time_since_start(self) -> float: """How much time has passed since the creation of the context.""" return time.time() - self.start_time
[ "def", "get_time_since_start", "(", "self", ")", "->", "float", ":", "return", "time", ".", "time", "(", ")", "-", "self", ".", "start_time" ]
https://github.com/a312863063/seeprettyface-generator-wanghong/blob/77c5962cb7b194a1d3c5e052725ae23b48b140da/dnnlib/submission/run_context.py#L78-L80
pywinauto/pywinauto
7235e6f83edfd96a7aeb8bbf9fef7b8f3d912512
pywinauto/handleprops.py
python
has_style
(handle, tocheck)
return tocheck & hwnd_style == tocheck
Return True if the control has style tocheck
Return True if the control has style tocheck
[ "Return", "True", "if", "the", "control", "has", "style", "tocheck" ]
def has_style(handle, tocheck): """Return True if the control has style tocheck""" hwnd_style = style(handle) return tocheck & hwnd_style == tocheck
[ "def", "has_style", "(", "handle", ",", "tocheck", ")", ":", "hwnd_style", "=", "style", "(", "handle", ")", "return", "tocheck", "&", "hwnd_style", "==", "tocheck" ]
https://github.com/pywinauto/pywinauto/blob/7235e6f83edfd96a7aeb8bbf9fef7b8f3d912512/pywinauto/handleprops.py#L354-L357
FederatedAI/FATE
32540492623568ecd1afcb367360133616e02fa3
python/federatedml/ensemble/basic_algorithms/decision_tree/hetero/hetero_decision_tree_host.py
python
HeteroDecisionTreeHost.report_init_status
(self)
[]
def report_init_status(self): LOGGER.info('reporting initialization status') LOGGER.info('using new version code {}'.format(self.new_ver)) if self.run_sparse_opt: LOGGER.info('running sparse optimization') if self.complete_secure_tree: LOGGER.info('running comple...
[ "def", "report_init_status", "(", "self", ")", ":", "LOGGER", ".", "info", "(", "'reporting initialization status'", ")", "LOGGER", ".", "info", "(", "'using new version code {}'", ".", "format", "(", "self", ".", "new_ver", ")", ")", "if", "self", ".", "run_s...
https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/federatedml/ensemble/basic_algorithms/decision_tree/hetero/hetero_decision_tree_host.py#L59-L71
gitabcworld/FewShotLearning
2eff1881f96212e0fb31737a48f82fab9c2fac83
model/lstm/bnlstm.py
python
LSTMCell.forward
(self, input_, hx)
return h_1, c_1
Args: input_: A (batch, input_size) tensor containing input features. hx: A tuple (h_0, c_0), which contains the initial hidden and cell state, where the size of both states is (batch, hidden_size). Returns: h_1, c_1: Tensors co...
Args: input_: A (batch, input_size) tensor containing input features. hx: A tuple (h_0, c_0), which contains the initial hidden and cell state, where the size of both states is (batch, hidden_size). Returns: h_1, c_1: Tensors co...
[ "Args", ":", "input_", ":", "A", "(", "batch", "input_size", ")", "tensor", "containing", "input", "features", ".", "hx", ":", "A", "tuple", "(", "h_0", "c_0", ")", "which", "contains", "the", "initial", "hidden", "and", "cell", "state", "where", "the", ...
def forward(self, input_, hx): """ Args: input_: A (batch, input_size) tensor containing input features. hx: A tuple (h_0, c_0), which contains the initial hidden and cell state, where the size of both states is (batch, hidden_size)...
[ "def", "forward", "(", "self", ",", "input_", ",", "hx", ")", ":", "h_0", ",", "c_0", "=", "hx", "batch_size", "=", "h_0", ".", "size", "(", "0", ")", "bias_batch", "=", "(", "self", ".", "bias", ".", "unsqueeze", "(", "0", ")", ".", "expand", ...
https://github.com/gitabcworld/FewShotLearning/blob/2eff1881f96212e0fb31737a48f82fab9c2fac83/model/lstm/bnlstm.py#L111-L133
SteveDoyle2/pyNastran
eda651ac2d4883d95a34951f8a002ff94f642a1a
pyNastran/converters/abaqus/abaqus.py
python
read_solid_section
(line0, lines, iline, log)
return iline, solid_section
reads *solid section
reads *solid section
[ "reads", "*", "solid", "section" ]
def read_solid_section(line0, lines, iline, log): """reads *solid section""" # TODO: skips header parsing #iline += 1 assert '*solid' in line0, line0 word2 = line0.strip('*').lower() params_map = get_param_map(iline, word2, required_keys=['material']) log.debug(' param_map = %s' % params_...
[ "def", "read_solid_section", "(", "line0", ",", "lines", ",", "iline", ",", "log", ")", ":", "# TODO: skips header parsing", "#iline += 1", "assert", "'*solid'", "in", "line0", ",", "line0", "word2", "=", "line0", ".", "strip", "(", "'*'", ")", ".", "lower",...
https://github.com/SteveDoyle2/pyNastran/blob/eda651ac2d4883d95a34951f8a002ff94f642a1a/pyNastran/converters/abaqus/abaqus.py#L1241-L1258
uwdata/termite-data-server
1085571407c627bdbbd21c352e793fed65d09599
web2py/gluon/contrib/ipaddr.py
python
_BaseV6._string_from_ip_int
(self, ip_int=None)
return ':'.join(hextets)
Turns a 128-bit integer into hexadecimal notation. Args: ip_int: An integer, the IP address. Returns: A string, the hexadecimal representation of the address. Raises: ValueError: The address is bigger than 128 bits of all ones.
Turns a 128-bit integer into hexadecimal notation.
[ "Turns", "a", "128", "-", "bit", "integer", "into", "hexadecimal", "notation", "." ]
def _string_from_ip_int(self, ip_int=None): """Turns a 128-bit integer into hexadecimal notation. Args: ip_int: An integer, the IP address. Returns: A string, the hexadecimal representation of the address. Raises: ValueError: The address is bigger t...
[ "def", "_string_from_ip_int", "(", "self", ",", "ip_int", "=", "None", ")", ":", "if", "not", "ip_int", "and", "ip_int", "!=", "0", ":", "ip_int", "=", "int", "(", "self", ".", "_ip", ")", "if", "ip_int", ">", "self", ".", "_ALL_ONES", ":", "raise", ...
https://github.com/uwdata/termite-data-server/blob/1085571407c627bdbbd21c352e793fed65d09599/web2py/gluon/contrib/ipaddr.py#L1623-L1648
pyjs/pyjs
6c4a3d3a67300cd5df7f95a67ca9dcdc06950523
pyjs/lib_trans/pycompiler/pyassem.py
python
Block.pruneNext
(self)
Remove bogus edge for unconditional transfers Each block has a next edge that accounts for implicit control transfers, e.g. from a JUMP_IF_FALSE to the block that will be executed if the test is true. These edges must remain for the current assembler code to work. If they are r...
Remove bogus edge for unconditional transfers
[ "Remove", "bogus", "edge", "for", "unconditional", "transfers" ]
def pruneNext(self): """Remove bogus edge for unconditional transfers Each block has a next edge that accounts for implicit control transfers, e.g. from a JUMP_IF_FALSE to the block that will be executed if the test is true. These edges must remain for the current assembler cod...
[ "def", "pruneNext", "(", "self", ")", ":", "try", ":", "op", ",", "arg", "=", "self", ".", "insts", "[", "-", "1", "]", "except", "(", "IndexError", ",", "ValueError", ")", ":", "return", "if", "op", "in", "self", ".", "_uncond_transfer", ":", "sel...
https://github.com/pyjs/pyjs/blob/6c4a3d3a67300cd5df7f95a67ca9dcdc06950523/pyjs/lib_trans/pycompiler/pyassem.py#L265-L284
CaptainEven/Vehicle-Car-detection-and-multilabel-classification
0b0ab3ad8478c5a0ac29819b4fce3ae110d44d82
Clipper.py
python
Cropper.update_fig
(self)
更新绘图
更新绘图
[ "更新绘图" ]
def update_fig(self): """ 更新绘图 """ if self.idx < len(self.imgs_path): # 释放上一帧缓存 self.ax.cla() # 重绘一帧图像 self.img = Image.open(self.imgs_path[self.idx]) # 读取图像 ax_img = self.ax.imshow(self.img, picker=True) self.ax.s...
[ "def", "update_fig", "(", "self", ")", ":", "if", "self", ".", "idx", "<", "len", "(", "self", ".", "imgs_path", ")", ":", "# 释放上一帧缓存", "self", ".", "ax", ".", "cla", "(", ")", "# 重绘一帧图像", "self", ".", "img", "=", "Image", ".", "open", "(", "self...
https://github.com/CaptainEven/Vehicle-Car-detection-and-multilabel-classification/blob/0b0ab3ad8478c5a0ac29819b4fce3ae110d44d82/Clipper.py#L199-L218
kchua/handful-of-trials
77fd8802cc30b7683f0227c90527b5414c0df34c
dmbrl/misc/Agent.py
python
Agent.__init__
(self, params)
Initializes an agent. Arguments: params: (DotMap) A DotMap of agent parameters. .env: (OpenAI gym environment) The environment for this agent. .noisy_actions: (bool) Indicates whether random Gaussian noise will be added to the actions of this age...
Initializes an agent.
[ "Initializes", "an", "agent", "." ]
def __init__(self, params): """Initializes an agent. Arguments: params: (DotMap) A DotMap of agent parameters. .env: (OpenAI gym environment) The environment for this agent. .noisy_actions: (bool) Indicates whether random Gaussian noise will ...
[ "def", "__init__", "(", "self", ",", "params", ")", ":", "self", ".", "env", "=", "params", ".", "env", "self", ".", "noise_stddev", "=", "params", ".", "noise_stddev", "if", "params", ".", "get", "(", "\"noisy_actions\"", ",", "False", ")", "else", "N...
https://github.com/kchua/handful-of-trials/blob/77fd8802cc30b7683f0227c90527b5414c0df34c/dmbrl/misc/Agent.py#L15-L35
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/sympy/sympy/physics/quantum/cartesian.py
python
XOp.default_args
(self)
return ("X",)
[]
def default_args(self): return ("X",)
[ "def", "default_args", "(", "self", ")", ":", "return", "(", "\"X\"", ",", ")" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/physics/quantum/cartesian.py#L45-L46
oracle/graalpython
577e02da9755d916056184ec441c26e00b70145c
graalpython/lib-python/3/distutils/bcppcompiler.py
python
BCPPCompiler.compile
(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None)
return objects
[]
def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, ...
[ "def", "compile", "(", "self", ",", "sources", ",", "output_dir", "=", "None", ",", "macros", "=", "None", ",", "include_dirs", "=", "None", ",", "debug", "=", "0", ",", "extra_preargs", "=", "None", ",", "extra_postargs", "=", "None", ",", "depends", ...
https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/distutils/bcppcompiler.py#L81-L141
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/pg8000.py
python
PGDialect_pg8000.do_prepare_twophase
(self, connection, xid)
[]
def do_prepare_twophase(self, connection, xid): connection.connection.tpc_prepare()
[ "def", "do_prepare_twophase", "(", "self", ",", "connection", ",", "xid", ")", ":", "connection", ".", "connection", ".", "tpc_prepare", "(", ")" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/pg8000.py#L256-L257
facelessuser/RegReplace
c127d48c9f81a610eb01dbd78f4cc40182ab6800
rr_notify.py
python
notify
(msg)
Notify message.
Notify message.
[ "Notify", "message", "." ]
def notify(msg): """Notify message.""" settings = sublime.load_settings("reg_replace.sublime-settings") if settings.get("use_sub_notify", False) and Notify.is_ready(): sublime.run_command("sub_notify", {"title": "RegReplace", "msg": msg}) else: sublime.status_message(msg)
[ "def", "notify", "(", "msg", ")", ":", "settings", "=", "sublime", ".", "load_settings", "(", "\"reg_replace.sublime-settings\"", ")", "if", "settings", ".", "get", "(", "\"use_sub_notify\"", ",", "False", ")", "and", "Notify", ".", "is_ready", "(", ")", ":"...
https://github.com/facelessuser/RegReplace/blob/c127d48c9f81a610eb01dbd78f4cc40182ab6800/rr_notify.py#L26-L33
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/libs/hadoop/src/hadoop/fs/webhdfs.py
python
WebHdfs.open
(self, path, mode='r')
return File(self, path, mode)
DEPRECATED! open(path, mode='r') -> File object This exists for legacy support and backwards compatibility only. Please use read().
DEPRECATED! open(path, mode='r') -> File object
[ "DEPRECATED!", "open", "(", "path", "mode", "=", "r", ")", "-", ">", "File", "object" ]
def open(self, path, mode='r'): """ DEPRECATED! open(path, mode='r') -> File object This exists for legacy support and backwards compatibility only. Please use read(). """ return File(self, path, mode)
[ "def", "open", "(", "self", ",", "path", ",", "mode", "=", "'r'", ")", ":", "return", "File", "(", "self", ",", "path", ",", "mode", ")" ]
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/libs/hadoop/src/hadoop/fs/webhdfs.py#L599-L607
glue-viz/glue
840b4c1364b0fa63bf67c914540c93dd71df41e1
glue/core/data_combo_helper.py
python
ManualDataComboHelper.set_multiple_data
(self, datasets)
Add multiple datasets to the combo in one go (and clear any previous datasets). Parameters ---------- datasets : list The list of :class:`~glue.core.data.Data` objects to add
Add multiple datasets to the combo in one go (and clear any previous datasets).
[ "Add", "multiple", "datasets", "to", "the", "combo", "in", "one", "go", "(", "and", "clear", "any", "previous", "datasets", ")", "." ]
def set_multiple_data(self, datasets): """ Add multiple datasets to the combo in one go (and clear any previous datasets). Parameters ---------- datasets : list The list of :class:`~glue.core.data.Data` objects to add """ self._datasets.clear() ...
[ "def", "set_multiple_data", "(", "self", ",", "datasets", ")", ":", "self", ".", "_datasets", ".", "clear", "(", ")", "for", "data", "in", "unique_data_iter", "(", "datasets", ")", ":", "self", ".", "append_data", "(", "data", ",", "refresh", "=", "False...
https://github.com/glue-viz/glue/blob/840b4c1364b0fa63bf67c914540c93dd71df41e1/glue/core/data_combo_helper.py#L510-L522
BlackLight/platypush
a6b552504e2ac327c94f3a28b607061b6b60cf36
platypush/plugins/sound/__init__.py
python
SoundPlugin.query_streams
(self)
return streams
:returns: A list of active audio streams
:returns: A list of active audio streams
[ ":", "returns", ":", "A", "list", "of", "active", "audio", "streams" ]
def query_streams(self): """ :returns: A list of active audio streams """ streams = { i: { attr: getattr(stream, attr) for attr in ['active', 'closed', 'stopped', 'blocksize', 'channels', 'cpu_load', 'device', 'dty...
[ "def", "query_streams", "(", "self", ")", ":", "streams", "=", "{", "i", ":", "{", "attr", ":", "getattr", "(", "stream", ",", "attr", ")", "for", "attr", "in", "[", "'active'", ",", "'closed'", ",", "'stopped'", ",", "'blocksize'", ",", "'channels'", ...
https://github.com/BlackLight/platypush/blob/a6b552504e2ac327c94f3a28b607061b6b60cf36/platypush/plugins/sound/__init__.py#L731-L753
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/networkx/classes/function.py
python
all_neighbors
(graph, node)
return values
Returns all of the neighbors of a node in the graph. If the graph is directed returns predecessors as well as successors. Parameters ---------- graph : NetworkX graph Graph to find neighbors. node : node The node whose neighbors will be returned. Returns ------- neigh...
Returns all of the neighbors of a node in the graph.
[ "Returns", "all", "of", "the", "neighbors", "of", "a", "node", "in", "the", "graph", "." ]
def all_neighbors(graph, node): """Returns all of the neighbors of a node in the graph. If the graph is directed returns predecessors as well as successors. Parameters ---------- graph : NetworkX graph Graph to find neighbors. node : node The node whose neighbors will be retur...
[ "def", "all_neighbors", "(", "graph", ",", "node", ")", ":", "if", "graph", ".", "is_directed", "(", ")", ":", "values", "=", "chain", "(", "graph", ".", "predecessors", "(", "node", ")", ",", "graph", ".", "successors", "(", "node", ")", ")", "else"...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/networkx/classes/function.py#L833-L855
zhanghang1989/PyTorch-Encoding
331ecdd5306104614cb414b16fbcd9d1a8d40e1e
encoding/utils/train_helper.py
python
get_selabel_vector
(target, nclass)
return tvect
r"""Get SE-Loss Label in a batch Args: predict: input 4D tensor target: label 3D tensor (BxHxW) nclass: number of categories (int) Output: 2D tensor (BxnClass)
r"""Get SE-Loss Label in a batch Args: predict: input 4D tensor target: label 3D tensor (BxHxW) nclass: number of categories (int) Output: 2D tensor (BxnClass)
[ "r", "Get", "SE", "-", "Loss", "Label", "in", "a", "batch", "Args", ":", "predict", ":", "input", "4D", "tensor", "target", ":", "label", "3D", "tensor", "(", "BxHxW", ")", "nclass", ":", "number", "of", "categories", "(", "int", ")", "Output", ":", ...
def get_selabel_vector(target, nclass): r"""Get SE-Loss Label in a batch Args: predict: input 4D tensor target: label 3D tensor (BxHxW) nclass: number of categories (int) Output: 2D tensor (BxnClass) """ batch = target.size(0) tvect = torch.zeros(batch, nclass) ...
[ "def", "get_selabel_vector", "(", "target", ",", "nclass", ")", ":", "batch", "=", "target", ".", "size", "(", "0", ")", "tvect", "=", "torch", ".", "zeros", "(", "batch", ",", "nclass", ")", "for", "i", "in", "range", "(", "batch", ")", ":", "hist...
https://github.com/zhanghang1989/PyTorch-Encoding/blob/331ecdd5306104614cb414b16fbcd9d1a8d40e1e/encoding/utils/train_helper.py#L51-L68
sdaps/sdaps
51d1072185223f5e48512661e2c1e8399d63e876
sdaps/cmdline/csvdata.py
python
csvdata_export
(cmdline)
return csvdata.csvdata_export(survey, outfile, image_writer, filter=cmdline['filter'], export_images=cmdline['export_images'], export_question_images=cmdline['export_question_images'], export_quality=cmdline['export_quality'], csvoptions=csvoptions)
[]
def csvdata_export(cmdline): from sdaps import csvdata survey = model.survey.Survey.load(cmdline['project']) if cmdline['output']: if cmdline['output'] == '-': outfd = os.dup(sys.stdout.fileno()) outfile = os.fdopen(outfd, 'w') else: filename = cmdline['...
[ "def", "csvdata_export", "(", "cmdline", ")", ":", "from", "sdaps", "import", "csvdata", "survey", "=", "model", ".", "survey", ".", "Survey", ".", "load", "(", "cmdline", "[", "'project'", "]", ")", "if", "cmdline", "[", "'output'", "]", ":", "if", "c...
https://github.com/sdaps/sdaps/blob/51d1072185223f5e48512661e2c1e8399d63e876/sdaps/cmdline/csvdata.py#L85-L119
Abjad/abjad
d0646dfbe83db3dc5ab268f76a0950712b87b7fd
abjad/sequence.py
python
Sequence.rotate
(self, n=0)
return type(self)(items=items)
r""" Rotates sequence by index ``n``. .. container:: example Rotates sequence to the right: .. container:: example >>> sequence = abjad.Sequence(range(10)) >>> sequence.rotate(n=4) Sequence([6, 7, 8, 9, 0, 1, 2, 3, 4, 5]) ...
r""" Rotates sequence by index ``n``.
[ "r", "Rotates", "sequence", "by", "index", "n", "." ]
def rotate(self, n=0) -> "Sequence": r""" Rotates sequence by index ``n``. .. container:: example Rotates sequence to the right: .. container:: example >>> sequence = abjad.Sequence(range(10)) >>> sequence.rotate(n=4) ...
[ "def", "rotate", "(", "self", ",", "n", "=", "0", ")", "->", "\"Sequence\"", ":", "n", "=", "n", "or", "0", "items", "=", "[", "]", "if", "len", "(", "self", ")", ":", "n", "=", "n", "%", "len", "(", "self", ")", "for", "item", "in", "self"...
https://github.com/Abjad/abjad/blob/d0646dfbe83db3dc5ab268f76a0950712b87b7fd/abjad/sequence.py#L2601-L2645
angr/angr
4b04d56ace135018083d36d9083805be8146688b
angr/analyses/cfg/indirect_jump_resolvers/mips_elf_fast.py
python
OverwriteTmpValueCallback.overwrite_tmp_value
(self, state)
[]
def overwrite_tmp_value(self, state): state.inspect.tmp_write_expr = state.solver.BVV(self.gp_value, state.arch.bits)
[ "def", "overwrite_tmp_value", "(", "self", ",", "state", ")", ":", "state", ".", "inspect", ".", "tmp_write_expr", "=", "state", ".", "solver", ".", "BVV", "(", "self", ".", "gp_value", ",", "state", ".", "arch", ".", "bits", ")" ]
https://github.com/angr/angr/blob/4b04d56ace135018083d36d9083805be8146688b/angr/analyses/cfg/indirect_jump_resolvers/mips_elf_fast.py#L29-L30
exodrifter/unity-python
bef6e4e9ddfbbf1eaf7acbbb973e9aa3dd64a20d
Lib/modulefinder.py
python
ModuleFinder.any_missing_maybe
(self)
return missing, maybe
Return two lists, one with modules that are certainly missing and one with modules that *may* be missing. The latter names could either be submodules *or* just global names in the package. The reason it can't always be determined is that it's impossible to tell which names are imported ...
Return two lists, one with modules that are certainly missing and one with modules that *may* be missing. The latter names could either be submodules *or* just global names in the package.
[ "Return", "two", "lists", "one", "with", "modules", "that", "are", "certainly", "missing", "and", "one", "with", "modules", "that", "*", "may", "*", "be", "missing", ".", "The", "latter", "names", "could", "either", "be", "submodules", "*", "or", "*", "j...
def any_missing_maybe(self): """Return two lists, one with modules that are certainly missing and one with modules that *may* be missing. The latter names could either be submodules *or* just global names in the package. The reason it can't always be determined is that it's impossible t...
[ "def", "any_missing_maybe", "(", "self", ")", ":", "missing", "=", "[", "]", "maybe", "=", "[", "]", "for", "name", "in", "self", ".", "badmodules", ":", "if", "name", "in", "self", ".", "excludes", ":", "continue", "i", "=", "name", ".", "rfind", ...
https://github.com/exodrifter/unity-python/blob/bef6e4e9ddfbbf1eaf7acbbb973e9aa3dd64a20d/Lib/modulefinder.py#L579-L623
adamcaudill/yawast
5e9e7a37831c030530adb971925ee135e9bfcafb
yawast/commands/ssl.py
python
start
(session: Session)
[]
def start(session: Session): print(f"Scanning: {session.url}") # make sure it resolves try: socket.gethostbyname(session.domain) except socket.gaierror as error: output.debug_exception() output.error(f"Fatal Error: Unable to resolve {session.domain} ({str(error)})") ret...
[ "def", "start", "(", "session", ":", "Session", ")", ":", "print", "(", "f\"Scanning: {session.url}\"", ")", "# make sure it resolves", "try", ":", "socket", ".", "gethostbyname", "(", "session", ".", "domain", ")", "except", "socket", ".", "gaierror", "as", "...
https://github.com/adamcaudill/yawast/blob/5e9e7a37831c030530adb971925ee135e9bfcafb/yawast/commands/ssl.py#L13-L60
roclark/sportsipy
c19f545d3376d62ded6304b137dc69238ac620a9
sportsipy/ncaab/schedule.py
python
Game.datetime
(self)
return datetime.strptime(date_string, '%a, %b %d, %Y %I:%M%p')
Returns a datetime object to indicate the month, day, year, and time the requested game took place.
Returns a datetime object to indicate the month, day, year, and time the requested game took place.
[ "Returns", "a", "datetime", "object", "to", "indicate", "the", "month", "day", "year", "and", "time", "the", "requested", "game", "took", "place", "." ]
def datetime(self): """ Returns a datetime object to indicate the month, day, year, and time the requested game took place. """ # Sometimes, the time isn't displayed on the game page. In this case, # the time property will be empty, causing the time parsing to fail as ...
[ "def", "datetime", "(", "self", ")", ":", "# Sometimes, the time isn't displayed on the game page. In this case,", "# the time property will be empty, causing the time parsing to fail as", "# it can't match the expected format. To prevent the issue, and since", "# the time can't properly be parsed...
https://github.com/roclark/sportsipy/blob/c19f545d3376d62ded6304b137dc69238ac620a9/sportsipy/ncaab/schedule.py#L207-L230
log2timeline/plaso
fe2e316b8c76a0141760c0f2f181d84acb83abc2
plaso/parsers/gdrive_synclog.py
python
GoogleDriveSyncLogEventData.__init__
(self)
Initializes event data.
Initializes event data.
[ "Initializes", "event", "data", "." ]
def __init__(self): """Initializes event data.""" super(GoogleDriveSyncLogEventData, self).__init__(data_type=self.DATA_TYPE) self.log_level = None self.message = None self.pid = None self.source_code = None self.thread = None
[ "def", "__init__", "(", "self", ")", ":", "super", "(", "GoogleDriveSyncLogEventData", ",", "self", ")", ".", "__init__", "(", "data_type", "=", "self", ".", "DATA_TYPE", ")", "self", ".", "log_level", "=", "None", "self", ".", "message", "=", "None", "s...
https://github.com/log2timeline/plaso/blob/fe2e316b8c76a0141760c0f2f181d84acb83abc2/plaso/parsers/gdrive_synclog.py#L32-L39
andresriancho/w3af
cd22e5252243a87aaa6d0ddea47cf58dacfe00a9
w3af/core/controllers/core_helpers/plugins.py
python
CorePlugins.resolve_dependencies
(self)
[]
def resolve_dependencies(self): for plugin_type, enabled_plugins in self._plugins_names_dict.iteritems(): for plugin_name in enabled_plugins: plugin_inst = self.get_quick_instance(plugin_type, plugin_name) for dep in plugin_inst.get_plugin_deps(): ...
[ "def", "resolve_dependencies", "(", "self", ")", ":", "for", "plugin_type", ",", "enabled_plugins", "in", "self", ".", "_plugins_names_dict", ".", "iteritems", "(", ")", ":", "for", "plugin_name", "in", "enabled_plugins", ":", "plugin_inst", "=", "self", ".", ...
https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/core/controllers/core_helpers/plugins.py#L322-L345
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/icicle/marker/_colorbar.py
python
ColorBar.x
(self)
return self["x"]
Sets the x position of the color bar (in plot fraction). Defaults to 1.02 when `orientation` is "v" and 0.5 when `orientation` is "h". The 'x' property is a number and may be specified as: - An int or float in the interval [-2, 3] Returns ------- int|float
Sets the x position of the color bar (in plot fraction). Defaults to 1.02 when `orientation` is "v" and 0.5 when `orientation` is "h". The 'x' property is a number and may be specified as: - An int or float in the interval [-2, 3]
[ "Sets", "the", "x", "position", "of", "the", "color", "bar", "(", "in", "plot", "fraction", ")", ".", "Defaults", "to", "1", ".", "02", "when", "orientation", "is", "v", "and", "0", ".", "5", "when", "orientation", "is", "h", ".", "The", "x", "prop...
def x(self): """ Sets the x position of the color bar (in plot fraction). Defaults to 1.02 when `orientation` is "v" and 0.5 when `orientation` is "h". The 'x' property is a number and may be specified as: - An int or float in the interval [-2, 3] Returns ...
[ "def", "x", "(", "self", ")", ":", "return", "self", "[", "\"x\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/icicle/marker/_colorbar.py#L1259-L1272
pymedusa/Medusa
1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38
ext/rebulk/pattern.py
python
Pattern._match
(self, pattern, input_string, context=None)
Computes all unprocess matches for a given pattern and input. :param pattern: the pattern to use :param input_string: the string to parse :type input_string: str :param context: the context :type context: dict :return: matches based on input_string for this pattern ...
Computes all unprocess matches for a given pattern and input.
[ "Computes", "all", "unprocess", "matches", "for", "a", "given", "pattern", "and", "input", "." ]
def _match(self, pattern, input_string, context=None): # pragma: no cover """ Computes all unprocess matches for a given pattern and input. :param pattern: the pattern to use :param input_string: the string to parse :type input_string: str :param context: the context ...
[ "def", "_match", "(", "self", ",", "pattern", ",", "input_string", ",", "context", "=", "None", ")", ":", "# pragma: no cover", "pass" ]
https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/ext/rebulk/pattern.py#L366-L378
jython/frozen-mirror
b8d7aa4cee50c0c0fe2f4b235dd62922dd0f3f99
lib-python/2.7/idlelib/configHandler.py
python
IdleUserConfParser.SetOption
(self,section,option,value)
Sets option to value, adding section if required. Returns 1 if option was added or changed, otherwise 0.
Sets option to value, adding section if required. Returns 1 if option was added or changed, otherwise 0.
[ "Sets", "option", "to", "value", "adding", "section", "if", "required", ".", "Returns", "1", "if", "option", "was", "added", "or", "changed", "otherwise", "0", "." ]
def SetOption(self,section,option,value): """ Sets option to value, adding section if required. Returns 1 if option was added or changed, otherwise 0. """ if self.has_option(section,option): if self.get(section,option)==value: return 0 else...
[ "def", "SetOption", "(", "self", ",", "section", ",", "option", ",", "value", ")", ":", "if", "self", ".", "has_option", "(", "section", ",", "option", ")", ":", "if", "self", ".", "get", "(", "section", ",", "option", ")", "==", "value", ":", "ret...
https://github.com/jython/frozen-mirror/blob/b8d7aa4cee50c0c0fe2f4b235dd62922dd0f3f99/lib-python/2.7/idlelib/configHandler.py#L110-L125
3YOURMIND/django-migration-linter
7674a51bc9f984cc3dd4f5233a6d25be5b71f100
django_migration_linter/management/commands/makemigrations.py
python
Command.write_migration_files
(self, changes)
[]
def write_migration_files(self, changes): super(Command, self).write_migration_files(changes) if ( not getattr(settings, "MIGRATION_LINTER_OVERRIDE_MAKEMIGRATIONS", False) and not self.lint ): return if self.dry_run: """ Since...
[ "def", "write_migration_files", "(", "self", ",", "changes", ")", ":", "super", "(", "Command", ",", "self", ")", ".", "write_migration_files", "(", "changes", ")", "if", "(", "not", "getattr", "(", "settings", ",", "\"MIGRATION_LINTER_OVERRIDE_MAKEMIGRATIONS\"", ...
https://github.com/3YOURMIND/django-migration-linter/blob/7674a51bc9f984cc3dd4f5233a6d25be5b71f100/django_migration_linter/management/commands/makemigrations.py#L47-L90
scipopt/PySCIPOpt
31527a80d8d0c2b706a26b34d93602aeea5f785f
examples/finished/flp.py
python
flp
(I,J,d,M,f,c)
return model
flp -- model for the capacitated facility location problem Parameters: - I: set of customers - J: set of facilities - d[i]: demand for customer i - M[j]: capacity of facility j - f[j]: fixed cost for using a facility in point j - c[i,j]: unit cost of servicing demand ...
flp -- model for the capacitated facility location problem Parameters: - I: set of customers - J: set of facilities - d[i]: demand for customer i - M[j]: capacity of facility j - f[j]: fixed cost for using a facility in point j - c[i,j]: unit cost of servicing demand ...
[ "flp", "--", "model", "for", "the", "capacitated", "facility", "location", "problem", "Parameters", ":", "-", "I", ":", "set", "of", "customers", "-", "J", ":", "set", "of", "facilities", "-", "d", "[", "i", "]", ":", "demand", "for", "customer", "i", ...
def flp(I,J,d,M,f,c): """flp -- model for the capacitated facility location problem Parameters: - I: set of customers - J: set of facilities - d[i]: demand for customer i - M[j]: capacity of facility j - f[j]: fixed cost for using a facility in point j - c[i,j]: u...
[ "def", "flp", "(", "I", ",", "J", ",", "d", ",", "M", ",", "f", ",", "c", ")", ":", "model", "=", "Model", "(", "\"flp\"", ")", "x", ",", "y", "=", "{", "}", ",", "{", "}", "for", "j", "in", "J", ":", "y", "[", "j", "]", "=", "model",...
https://github.com/scipopt/PySCIPOpt/blob/31527a80d8d0c2b706a26b34d93602aeea5f785f/examples/finished/flp.py#L11-L46
andreisavu/zookeeper-monitoring
f0aaddd640e3aa1cd0f2984b754b74938e383681
ganglia/zookeeper_ganglia.py
python
ZooKeeperServer._parse
(self, data)
return result
Parse the output from the 'mntr' 4letter word command
Parse the output from the 'mntr' 4letter word command
[ "Parse", "the", "output", "from", "the", "mntr", "4letter", "word", "command" ]
def _parse(self, data): """ Parse the output from the 'mntr' 4letter word command """ h = StringIO(data) result = {} for line in h.readlines(): try: key, value = self._parse_line(line) result[key] = value except ValueError: ...
[ "def", "_parse", "(", "self", ",", "data", ")", ":", "h", "=", "StringIO", "(", "data", ")", "result", "=", "{", "}", "for", "line", "in", "h", ".", "readlines", "(", ")", ":", "try", ":", "key", ",", "value", "=", "self", ".", "_parse_line", "...
https://github.com/andreisavu/zookeeper-monitoring/blob/f0aaddd640e3aa1cd0f2984b754b74938e383681/ganglia/zookeeper_ganglia.py#L71-L83
sschuhmann/Helium
861700f120d7e7a4187419e1cb27be78bd368fda
lib/client/traitlets/traitlets.py
python
HasTraits.set_trait
(self, name, value)
Forcibly sets trait attribute, including read-only attributes.
Forcibly sets trait attribute, including read-only attributes.
[ "Forcibly", "sets", "trait", "attribute", "including", "read", "-", "only", "attributes", "." ]
def set_trait(self, name, value): """Forcibly sets trait attribute, including read-only attributes.""" cls = self.__class__ if not self.has_trait(name): raise TraitError("Class %s does not have a trait named %s" % (cls.__name__, name)) else: ...
[ "def", "set_trait", "(", "self", ",", "name", ",", "value", ")", ":", "cls", "=", "self", ".", "__class__", "if", "not", "self", ".", "has_trait", "(", "name", ")", ":", "raise", "TraitError", "(", "\"Class %s does not have a trait named %s\"", "%", "(", "...
https://github.com/sschuhmann/Helium/blob/861700f120d7e7a4187419e1cb27be78bd368fda/lib/client/traitlets/traitlets.py#L1336-L1343
dropbox/dropbox-sdk-python
015437429be224732990041164a21a0501235db1
dropbox/team_log.py
python
EventDetails.paper_content_remove_member_details
(cls, val)
return cls('paper_content_remove_member_details', val)
Create an instance of this class set to the ``paper_content_remove_member_details`` tag with value ``val``. :param PaperContentRemoveMemberDetails val: :rtype: EventDetails
Create an instance of this class set to the ``paper_content_remove_member_details`` tag with value ``val``.
[ "Create", "an", "instance", "of", "this", "class", "set", "to", "the", "paper_content_remove_member_details", "tag", "with", "value", "val", "." ]
def paper_content_remove_member_details(cls, val): """ Create an instance of this class set to the ``paper_content_remove_member_details`` tag with value ``val``. :param PaperContentRemoveMemberDetails val: :rtype: EventDetails """ return cls('paper_content_remov...
[ "def", "paper_content_remove_member_details", "(", "cls", ",", "val", ")", ":", "return", "cls", "(", "'paper_content_remove_member_details'", ",", "val", ")" ]
https://github.com/dropbox/dropbox-sdk-python/blob/015437429be224732990041164a21a0501235db1/dropbox/team_log.py#L9953-L9961
IronLanguages/ironpython3
7a7bb2a872eeab0d1009fc8a6e24dca43f65b693
Src/StdLib/Lib/tkinter/__init__.py
python
Listbox.see
(self, index)
Scroll such that INDEX is visible.
Scroll such that INDEX is visible.
[ "Scroll", "such", "that", "INDEX", "is", "visible", "." ]
def see(self, index): """Scroll such that INDEX is visible.""" self.tk.call(self._w, 'see', index)
[ "def", "see", "(", "self", ",", "index", ")", ":", "self", ".", "tk", ".", "call", "(", "self", ".", "_w", ",", "'see'", ",", "index", ")" ]
https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/tkinter/__init__.py#L2662-L2664
Randl/ShuffleNetV2-pytorch
be26c0a32cd979f373a85e7f267345f6c5a9283e
flops_benchmark.py
python
count_flops
(model, batch_size, device, dtype, input_size, in_channels, *params)
return net.compute_average_flops_cost() / 2
[]
def count_flops(model, batch_size, device, dtype, input_size, in_channels, *params): net = model(*params) # print(net) net = add_flops_counting_methods(net) net.to(device=device, dtype=dtype) net = net.train() batch = torch.randn(batch_size, in_channels, input_size, input_size).to(device=devic...
[ "def", "count_flops", "(", "model", ",", "batch_size", ",", "device", ",", "dtype", ",", "input_size", ",", "in_channels", ",", "*", "params", ")", ":", "net", "=", "model", "(", "*", "params", ")", "# print(net)", "net", "=", "add_flops_counting_methods", ...
https://github.com/Randl/ShuffleNetV2-pytorch/blob/be26c0a32cd979f373a85e7f267345f6c5a9283e/flops_benchmark.py#L249-L261
X-DataInitiative/tick
bbc561804eb1fdcb4c71b9e3e2d83a66e7b13a48
doc/sphinxext/gen_rst.py
python
get_short_module_name
(module_name, obj_name)
return short_name
Get the shortest possible module name
Get the shortest possible module name
[ "Get", "the", "shortest", "possible", "module", "name" ]
def get_short_module_name(module_name, obj_name): """ Get the shortest possible module name """ parts = module_name.split('.') short_name = module_name for i in range(len(parts) - 1, 0, -1): short_name = '.'.join(parts[:i]) try: exec('from %s import %s' % (short_name, obj_nam...
[ "def", "get_short_module_name", "(", "module_name", ",", "obj_name", ")", ":", "parts", "=", "module_name", ".", "split", "(", "'.'", ")", "short_name", "=", "module_name", "for", "i", "in", "range", "(", "len", "(", "parts", ")", "-", "1", ",", "0", "...
https://github.com/X-DataInitiative/tick/blob/bbc561804eb1fdcb4c71b9e3e2d83a66e7b13a48/doc/sphinxext/gen_rst.py#L729-L741
phonopy/phonopy
816586d0ba8177482ecf40e52f20cbdee2260d51
phonopy/api_phonopy.py
python
Phonopy.symmetrize_force_constants
(self, level=1, show_drift=True)
Symmetrize force constants. This applies translational and permutation symmetries successfully, but not simultaneously. Parameters ---------- level : int, optional Application of translational and permulation symmetries is repeated by this number. Defaul...
Symmetrize force constants.
[ "Symmetrize", "force", "constants", "." ]
def symmetrize_force_constants(self, level=1, show_drift=True): """Symmetrize force constants. This applies translational and permutation symmetries successfully, but not simultaneously. Parameters ---------- level : int, optional Application of translationa...
[ "def", "symmetrize_force_constants", "(", "self", ",", "level", "=", "1", ",", "show_drift", "=", "True", ")", ":", "if", "self", ".", "_force_constants", "is", "None", ":", "raise", "RuntimeError", "(", "\"Force constants have not been produced yet.\"", ")", "if"...
https://github.com/phonopy/phonopy/blob/816586d0ba8177482ecf40e52f20cbdee2260d51/phonopy/api_phonopy.py#L1050-L1081
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_vendored_deps/library/oc_scale.py
python
Utils.create_tmp_file_from_contents
(rname, data, ftype='yaml')
return tmp
create a file in tmp with name and contents
create a file in tmp with name and contents
[ "create", "a", "file", "in", "tmp", "with", "name", "and", "contents" ]
def create_tmp_file_from_contents(rname, data, ftype='yaml'): ''' create a file in tmp with name and contents''' tmp = Utils.create_tmpfile(prefix=rname) if ftype == 'yaml': # AUDIT:no-member makes sense here due to ruamel.YAML/PyYAML usage # pylint: disable=no-member ...
[ "def", "create_tmp_file_from_contents", "(", "rname", ",", "data", ",", "ftype", "=", "'yaml'", ")", ":", "tmp", "=", "Utils", ".", "create_tmpfile", "(", "prefix", "=", "rname", ")", "if", "ftype", "==", "'yaml'", ":", "# AUDIT:no-member makes sense here due to...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_vendored_deps/library/oc_scale.py#L1165-L1185
bjmayor/hacker
e3ce2ad74839c2733b27dac6c0f495e0743e1866
venv/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/util/retry.py
python
Retry.get_backoff_time
(self)
return min(self.BACKOFF_MAX, backoff_value)
Formula for computing the current backoff :rtype: float
Formula for computing the current backoff
[ "Formula", "for", "computing", "the", "current", "backoff" ]
def get_backoff_time(self): """ Formula for computing the current backoff :rtype: float """ if self._observed_errors <= 1: return 0 backoff_value = self.backoff_factor * (2 ** (self._observed_errors - 1)) return min(self.BACKOFF_MAX, backoff_value)
[ "def", "get_backoff_time", "(", "self", ")", ":", "if", "self", ".", "_observed_errors", "<=", "1", ":", "return", "0", "backoff_value", "=", "self", ".", "backoff_factor", "*", "(", "2", "**", "(", "self", ".", "_observed_errors", "-", "1", ")", ")", ...
https://github.com/bjmayor/hacker/blob/e3ce2ad74839c2733b27dac6c0f495e0743e1866/venv/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/util/retry.py#L173-L182
lohriialo/photoshop-scripting-python
6b97da967a5d0a45e54f7c99631b29773b923f09
api_reference/photoshop_2021.py
python
PathItems.__iter__
(self)
return win32com.client.util.Iterator(ob, '{8B0CB532-4ACC-4BF3-9E42-0949B679D120}')
Return a Python iterator for this object
Return a Python iterator for this object
[ "Return", "a", "Python", "iterator", "for", "this", "object" ]
def __iter__(self): "Return a Python iterator for this object" try: ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) except pythoncom.error: raise TypeError("This object does not support enumeration") return win32com.client.util.Iterator(ob, '{8B0CB532-4ACC-4BF3-9E42-0949B679D120}')
[ "def", "__iter__", "(", "self", ")", ":", "try", ":", "ob", "=", "self", ".", "_oleobj_", ".", "InvokeTypes", "(", "-", "4", ",", "LCID", ",", "2", ",", "(", "13", ",", "10", ")", ",", "(", ")", ")", "except", "pythoncom", ".", "error", ":", ...
https://github.com/lohriialo/photoshop-scripting-python/blob/6b97da967a5d0a45e54f7c99631b29773b923f09/api_reference/photoshop_2021.py#L2647-L2653
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/modules/virt.py
python
pool_define
( name, ptype, target=None, permissions=None, source_devices=None, source_dir=None, source_initiator=None, source_adapter=None, source_hosts=None, source_auth=None, source_name=None, source_format=None, transient=False, start=True, # pylint: disable=redefined-out...
return True
Create libvirt pool. :param name: Pool name :param ptype: Pool type. See `libvirt documentation <https://libvirt.org/storage.html>`_ for the possible values. :param target: Pool full path target :param permissions: Permissions to set on the target folder. This is mostly used fo...
Create libvirt pool.
[ "Create", "libvirt", "pool", "." ]
def pool_define( name, ptype, target=None, permissions=None, source_devices=None, source_dir=None, source_initiator=None, source_adapter=None, source_hosts=None, source_auth=None, source_name=None, source_format=None, transient=False, start=True, # pylint: disabl...
[ "def", "pool_define", "(", "name", ",", "ptype", ",", "target", "=", "None", ",", "permissions", "=", "None", ",", "source_devices", "=", "None", ",", "source_dir", "=", "None", ",", "source_initiator", "=", "None", ",", "source_adapter", "=", "None", ",",...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/modules/virt.py#L7930-L8104
Chaffelson/nipyapi
d3b186fd701ce308c2812746d98af9120955e810
nipyapi/registry/models/versioned_processor.py
python
VersionedProcessor.__init__
(self, identifier=None, name=None, comments=None, position=None, bundle=None, style=None, type=None, properties=None, property_descriptors=None, annotation_data=None, scheduling_period=None, scheduling_strategy=None, execution_node=None, penalty_duration=None, yield_duration=None, bulletin_level=None, run_duration_mill...
VersionedProcessor - a model defined in Swagger
VersionedProcessor - a model defined in Swagger
[ "VersionedProcessor", "-", "a", "model", "defined", "in", "Swagger" ]
def __init__(self, identifier=None, name=None, comments=None, position=None, bundle=None, style=None, type=None, properties=None, property_descriptors=None, annotation_data=None, scheduling_period=None, scheduling_strategy=None, execution_node=None, penalty_duration=None, yield_duration=None, bulletin_level=None, run_d...
[ "def", "__init__", "(", "self", ",", "identifier", "=", "None", ",", "name", "=", "None", ",", "comments", "=", "None", ",", "position", "=", "None", ",", "bundle", "=", "None", ",", "style", "=", "None", ",", "type", "=", "None", ",", "properties", ...
https://github.com/Chaffelson/nipyapi/blob/d3b186fd701ce308c2812746d98af9120955e810/nipyapi/registry/models/versioned_processor.py#L83-L154
analyticalmindsltd/smote_variants
dedbc3d00b266954fedac0ae87775e1643bc920a
utils/study.py
python
extract_bibtex_entry
(string, types= ['@article', '@inproceedings', '@book', '@unknown'])
return {}
Extract bibtex entry from string Args: string (str): string to process types (list(str)): types of bibtex entries to find Returns: dict: the dict of the bibtex entry
Extract bibtex entry from string Args: string (str): string to process types (list(str)): types of bibtex entries to find Returns: dict: the dict of the bibtex entry
[ "Extract", "bibtex", "entry", "from", "string", "Args", ":", "string", "(", "str", ")", ":", "string", "to", "process", "types", "(", "list", "(", "str", "))", ":", "types", "of", "bibtex", "entries", "to", "find", "Returns", ":", "dict", ":", "the", ...
def extract_bibtex_entry(string, types= ['@article', '@inproceedings', '@book', '@unknown']): """ Extract bibtex entry from string Args: string (str): string to process types (list(str)): types of bibtex entries to find Returns: dict: the dict of the bibtex entry """ lowe...
[ "def", "extract_bibtex_entry", "(", "string", ",", "types", "=", "[", "'@article'", ",", "'@inproceedings'", ",", "'@book'", ",", "'@unknown'", "]", ")", ":", "lowercase", "=", "string", ".", "lower", "(", ")", "for", "t", "in", "types", ":", "t", "=", ...
https://github.com/analyticalmindsltd/smote_variants/blob/dedbc3d00b266954fedac0ae87775e1643bc920a/utils/study.py#L88-L112
openhatch/oh-mainline
ce29352a034e1223141dcc2f317030bbc3359a51
vendor/packages/Pygments/pygments/formatters/img.py
python
ImageFormatter._paint_line_number_bg
(self, im)
Paint the line number background on the image.
Paint the line number background on the image.
[ "Paint", "the", "line", "number", "background", "on", "the", "image", "." ]
def _paint_line_number_bg(self, im): """ Paint the line number background on the image. """ if not self.line_numbers: return if self.line_number_fg is None: return draw = ImageDraw.Draw(im) recth = im.size[-1] rectw = self.image_pad...
[ "def", "_paint_line_number_bg", "(", "self", ",", "im", ")", ":", "if", "not", "self", ".", "line_numbers", ":", "return", "if", "self", ".", "line_number_fg", "is", "None", ":", "return", "draw", "=", "ImageDraw", ".", "Draw", "(", "im", ")", "recth", ...
https://github.com/openhatch/oh-mainline/blob/ce29352a034e1223141dcc2f317030bbc3359a51/vendor/packages/Pygments/pygments/formatters/img.py#L460-L475
ARM-DOE/pyart
72affe5b669f1996cd3cc39ec7d8dd29b838bd48
pyart/retrieve/kdp_proc.py
python
_forward_reverse_phidp
(k, bcs, verbose=False)
return phidp_f, phidp_r
Compute the forward and reverse direction propagation differential phases from the control variable k and boundary conditions following equations (1) and (7) in Maesaka et al. (2012). Parameters ---------- k : ndarray Control variable k of the Maesaka et al. (2012) method. The control ...
Compute the forward and reverse direction propagation differential phases from the control variable k and boundary conditions following equations (1) and (7) in Maesaka et al. (2012).
[ "Compute", "the", "forward", "and", "reverse", "direction", "propagation", "differential", "phases", "from", "the", "control", "variable", "k", "and", "boundary", "conditions", "following", "equations", "(", "1", ")", "and", "(", "7", ")", "in", "Maesaka", "et...
def _forward_reverse_phidp(k, bcs, verbose=False): """ Compute the forward and reverse direction propagation differential phases from the control variable k and boundary conditions following equations (1) and (7) in Maesaka et al. (2012). Parameters ---------- k : ndarray Control va...
[ "def", "_forward_reverse_phidp", "(", "k", ",", "bcs", ",", "verbose", "=", "False", ")", ":", "# parse near and far range gate boundary conditions", "_", ",", "ng", "=", "k", ".", "shape", "phi_near", ",", "phi_far", "=", "bcs", "# compute forward direction propaga...
https://github.com/ARM-DOE/pyart/blob/72affe5b669f1996cd3cc39ec7d8dd29b838bd48/pyart/retrieve/kdp_proc.py#L1739-L1785
vertical-knowledge/ripozo
e648db2967c4fbf4315860c21a8418f384db4454
ripozo/resources/fields/common.py
python
DateTimeField._translate
(self, obj, skip_required=False)
First checks if the obj is None or already a datetime object Returns that if true. Otherwise assumes that it is a string and attempts to parse it out using the formats in self.valid_formats and the datetime.strptime method Additionally it strips out any whitespace from the beginning an...
First checks if the obj is None or already a datetime object Returns that if true. Otherwise assumes that it is a string and attempts to parse it out using the formats in self.valid_formats and the datetime.strptime method
[ "First", "checks", "if", "the", "obj", "is", "None", "or", "already", "a", "datetime", "object", "Returns", "that", "if", "true", ".", "Otherwise", "assumes", "that", "it", "is", "a", "string", "and", "attempts", "to", "parse", "it", "out", "using", "the...
def _translate(self, obj, skip_required=False): """ First checks if the obj is None or already a datetime object Returns that if true. Otherwise assumes that it is a string and attempts to parse it out using the formats in self.valid_formats and the datetime.strptime method ...
[ "def", "_translate", "(", "self", ",", "obj", ",", "skip_required", "=", "False", ")", ":", "if", "isinstance", "(", "obj", ",", "datetime", ")", ":", "return", "obj", "obj", "=", "obj", ".", "strip", "(", ")", "for", "date_format", "in", "self", "."...
https://github.com/vertical-knowledge/ripozo/blob/e648db2967c4fbf4315860c21a8418f384db4454/ripozo/resources/fields/common.py#L177-L201
NVlabs/noise2noise
7355519e7bfc49e0606cca8867748e736431244b
dnnlib/tflib/autosummary.py
python
finalize_autosummaries
()
return layout
Create the necessary ops to include autosummaries in TensorBoard report. Note: This should be done only once per graph.
Create the necessary ops to include autosummaries in TensorBoard report. Note: This should be done only once per graph.
[ "Create", "the", "necessary", "ops", "to", "include", "autosummaries", "in", "TensorBoard", "report", ".", "Note", ":", "This", "should", "be", "done", "only", "once", "per", "graph", "." ]
def finalize_autosummaries() -> None: """Create the necessary ops to include autosummaries in TensorBoard report. Note: This should be done only once per graph. """ global _finalized tfutil.assert_tf_initialized() if _finalized: return None _finalized = True tfutil.init_uniniti...
[ "def", "finalize_autosummaries", "(", ")", "->", "None", ":", "global", "_finalized", "tfutil", ".", "assert_tf_initialized", "(", ")", "if", "_finalized", ":", "return", "None", "_finalized", "=", "True", "tfutil", ".", "init_uninitialized_vars", "(", "[", "var...
https://github.com/NVlabs/noise2noise/blob/7355519e7bfc49e0606cca8867748e736431244b/dnnlib/tflib/autosummary.py#L97-L153
naturomics/CapsLayer
aed1feadfe9244ff7c8fddeb26f67146ea638d2a
capslayer/layers/layers.py
python
dense
(inputs, activation, num_outputs, out_caps_dims, routing_method='EMRouting', coordinate_addition=False, reuse=None, name=None)
return(pose, activation)
A fully connected capsule layer. Args: inputs: A 4-D tensor with shape [batch_size, num_inputs] + in_caps_dims or [batch_size, in_height, in_width, in_channels] + in_caps_dims activation: [batch_size, num_inputs] or [batch_size, in_height, in_width, in_channels] num_outputs: Integer, the nu...
A fully connected capsule layer.
[ "A", "fully", "connected", "capsule", "layer", "." ]
def dense(inputs, activation, num_outputs, out_caps_dims, routing_method='EMRouting', coordinate_addition=False, reuse=None, name=None): """A fully connected capsule layer. Args: inputs: A 4-D tensor with shape [batch_size, num_inputs] + in_ca...
[ "def", "dense", "(", "inputs", ",", "activation", ",", "num_outputs", ",", "out_caps_dims", ",", "routing_method", "=", "'EMRouting'", ",", "coordinate_addition", "=", "False", ",", "reuse", "=", "None", ",", "name", "=", "None", ")", ":", "name", "=", "\"...
https://github.com/naturomics/CapsLayer/blob/aed1feadfe9244ff7c8fddeb26f67146ea638d2a/capslayer/layers/layers.py#L32-L91
chribsen/simple-machine-learning-examples
dc94e52a4cebdc8bb959ff88b81ff8cfeca25022
venv/lib/python2.7/site-packages/numpy/core/shape_base.py
python
vstack
(tup)
return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
Stack arrays in sequence vertically (row wise). Take a sequence of arrays and stack them vertically to make a single array. Rebuild arrays divided by `vsplit`. Parameters ---------- tup : sequence of ndarrays Tuple containing arrays to be stacked. The arrays must have the same shap...
Stack arrays in sequence vertically (row wise).
[ "Stack", "arrays", "in", "sequence", "vertically", "(", "row", "wise", ")", "." ]
def vstack(tup): """ Stack arrays in sequence vertically (row wise). Take a sequence of arrays and stack them vertically to make a single array. Rebuild arrays divided by `vsplit`. Parameters ---------- tup : sequence of ndarrays Tuple containing arrays to be stacked. The arrays mu...
[ "def", "vstack", "(", "tup", ")", ":", "return", "_nx", ".", "concatenate", "(", "[", "atleast_2d", "(", "_m", ")", "for", "_m", "in", "tup", "]", ",", "0", ")" ]
https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/numpy/core/shape_base.py#L180-L230
dragonchain/dragonchain
495130a40f79bca48371a2af8645d6476c92339b
dragonchain/lib/matchmaking.py
python
get_or_create_claim_check
(block_id: str, requirements: dict)
return create_claim_check(block_id, requirements)
Get a claim check for a block if it already exists, else create a new one Args: block_id: block_id for the claim check requirements: requirements for the claim check (if it needs to create one) Returns: Dict of claim check
Get a claim check for a block if it already exists, else create a new one Args: block_id: block_id for the claim check requirements: requirements for the claim check (if it needs to create one) Returns: Dict of claim check
[ "Get", "a", "claim", "check", "for", "a", "block", "if", "it", "already", "exists", "else", "create", "a", "new", "one", "Args", ":", "block_id", ":", "block_id", "for", "the", "claim", "check", "requirements", ":", "requirements", "for", "the", "claim", ...
def get_or_create_claim_check(block_id: str, requirements: dict) -> dict: """Get a claim check for a block if it already exists, else create a new one Args: block_id: block_id for the claim check requirements: requirements for the claim check (if it needs to create one) Returns: Dict...
[ "def", "get_or_create_claim_check", "(", "block_id", ":", "str", ",", "requirements", ":", "dict", ")", "->", "dict", ":", "try", ":", "return", "get_claim_check", "(", "block_id", ")", "except", "Exception", ":", "# nosec (We don't care why getting a claim check fail...
https://github.com/dragonchain/dragonchain/blob/495130a40f79bca48371a2af8645d6476c92339b/dragonchain/lib/matchmaking.py#L206-L218
jim-easterbrook/pywws
31519ade415545e9cd711237b98aad33d070c1f9
src/pywws/device_cython_hidapi.py
python
USBDevice.read_data
(self, size)
return result
Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int)
Receive data from the device.
[ "Receive", "data", "from", "the", "device", "." ]
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
[ "def", "read_data", "(", "self", ",", "size", ")", ":", "result", "=", "list", "(", ")", "with", "self", ".", "open", "(", ")", ":", "while", "size", ">", "0", ":", "count", "=", "min", "(", "size", ",", "8", ")", "buf", "=", "self", ".", "hi...
https://github.com/jim-easterbrook/pywws/blob/31519ade415545e9cd711237b98aad33d070c1f9/src/pywws/device_cython_hidapi.py#L86-L111
DeepPavlov/convai
54d921f99606960941ece4865a396925dfc264f4
2017/solutions/rllchatbot/models/alicebot/aiml/Kernel.py
python
Kernel._processRandom
(self, elem, sessionID)
return self._processElement(listitems[0], sessionID)
Process a <random> AIML element. <random> elements contain zero or more <li> elements. If none, the empty string is returned. If one or more <li> elements are present, one of them is selected randomly to be processed recursively and have its results returned. Only the chosen ...
Process a <random> AIML element.
[ "Process", "a", "<random", ">", "AIML", "element", "." ]
def _processRandom(self, elem, sessionID): """Process a <random> AIML element. <random> elements contain zero or more <li> elements. If none, the empty string is returned. If one or more <li> elements are present, one of them is selected randomly to be processed recursively an...
[ "def", "_processRandom", "(", "self", ",", "elem", ",", "sessionID", ")", ":", "listitems", "=", "[", "]", "for", "e", "in", "elem", "[", "2", ":", "]", ":", "if", "e", "[", "0", "]", "==", "'li'", ":", "listitems", ".", "append", "(", "e", ")"...
https://github.com/DeepPavlov/convai/blob/54d921f99606960941ece4865a396925dfc264f4/2017/solutions/rllchatbot/models/alicebot/aiml/Kernel.py#L833-L853
MDAnalysis/mdanalysis
3488df3cdb0c29ed41c4fb94efe334b541e31b21
package/MDAnalysis/coordinates/chemfiles.py
python
ChemfilesReader.__init__
(self, filename, chemfiles_format="", **kwargs)
Parameters ---------- filename : chemfiles.Trajectory or str the chemfiles object to read or filename to read chemfiles_format : str (optional) if *filename* was a string, use the given format name instead of guessing from the extension. The `list of supported...
Parameters ---------- filename : chemfiles.Trajectory or str the chemfiles object to read or filename to read chemfiles_format : str (optional) if *filename* was a string, use the given format name instead of guessing from the extension. The `list of supported...
[ "Parameters", "----------", "filename", ":", "chemfiles", ".", "Trajectory", "or", "str", "the", "chemfiles", "object", "to", "read", "or", "filename", "to", "read", "chemfiles_format", ":", "str", "(", "optional", ")", "if", "*", "filename", "*", "was", "a"...
def __init__(self, filename, chemfiles_format="", **kwargs): """ Parameters ---------- filename : chemfiles.Trajectory or str the chemfiles object to read or filename to read chemfiles_format : str (optional) if *filename* was a string, use the given forma...
[ "def", "__init__", "(", "self", ",", "filename", ",", "chemfiles_format", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "if", "not", "check_chemfiles_version", "(", ")", ":", "raise", "RuntimeError", "(", "\"Please install Chemfiles > {}\"", "\"\"", ".", "fo...
https://github.com/MDAnalysis/mdanalysis/blob/3488df3cdb0c29ed41c4fb94efe334b541e31b21/package/MDAnalysis/coordinates/chemfiles.py#L143-L167
junxiaosong/AlphaZero_Gomoku
a2555b26e38aaaa08270e0731c53135e6222ef46
policy_value_net_pytorch.py
python
PolicyValueNet.train_step
(self, state_batch, mcts_probs, winner_batch, lr)
return loss.data[0], entropy.data[0]
perform a training step
perform a training step
[ "perform", "a", "training", "step" ]
def train_step(self, state_batch, mcts_probs, winner_batch, lr): """perform a training step""" # wrap in Variable if self.use_gpu: state_batch = Variable(torch.FloatTensor(state_batch).cuda()) mcts_probs = Variable(torch.FloatTensor(mcts_probs).cuda()) winner_...
[ "def", "train_step", "(", "self", ",", "state_batch", ",", "mcts_probs", ",", "winner_batch", ",", "lr", ")", ":", "# wrap in Variable", "if", "self", ".", "use_gpu", ":", "state_batch", "=", "Variable", "(", "torch", ".", "FloatTensor", "(", "state_batch", ...
https://github.com/junxiaosong/AlphaZero_Gomoku/blob/a2555b26e38aaaa08270e0731c53135e6222ef46/policy_value_net_pytorch.py#L117-L148
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/gse/v20191112/models.py
python
DescribeAssetsResponse.__init__
(self)
r""" :param TotalCount: 生成包总数 :type TotalCount: int :param Assets: 生成包列表 :type Assets: list of Asset :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
r""" :param TotalCount: 生成包总数 :type TotalCount: int :param Assets: 生成包列表 :type Assets: list of Asset :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
[ "r", ":", "param", "TotalCount", ":", "生成包总数", ":", "type", "TotalCount", ":", "int", ":", "param", "Assets", ":", "生成包列表", ":", "type", "Assets", ":", "list", "of", "Asset", ":", "param", "RequestId", ":", "唯一请求", "ID,每次请求都会返回。定位问题时需要提供该次请求的", "RequestId。",...
def __init__(self): r""" :param TotalCount: 生成包总数 :type TotalCount: int :param Assets: 生成包列表 :type Assets: list of Asset :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str """ self.TotalCount = None self.Asset...
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "TotalCount", "=", "None", "self", ".", "Assets", "=", "None", "self", ".", "RequestId", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/gse/v20191112/models.py#L1522-L1533
oracle/graalpython
577e02da9755d916056184ec441c26e00b70145c
graalpython/lib-python/3/email/generator.py
python
Generator._handle_message_delivery_status
(self, msg)
[]
def _handle_message_delivery_status(self, msg): # We can't just write the headers directly to self's file object # because this will leave an extra newline between the last header # block and the boundary. Sigh. blocks = [] for part in msg.get_payload(): s = self._ne...
[ "def", "_handle_message_delivery_status", "(", "self", ",", "msg", ")", ":", "# We can't just write the headers directly to self's file object", "# because this will leave an extra newline between the last header", "# block and the boundary. Sigh.", "blocks", "=", "[", "]", "for", "...
https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/email/generator.py#L323-L342
carnal0wnage/weirdAAL
c14e36d7bb82447f38a43da203f4bc29429f4cf4
modules/aws/iam.py
python
module_iam_list_users
()
Lists the IAM users that have the specified path prefix. If no path prefix is specified, the operation returns all users in the AWS account. If there are none, the operation returns an empty list. python3 weirdAAL.py -m iam_list_users -t yolo
Lists the IAM users that have the specified path prefix. If no path prefix is specified, the operation returns all users in the AWS account. If there are none, the operation returns an empty list. python3 weirdAAL.py -m iam_list_users -t yolo
[ "Lists", "the", "IAM", "users", "that", "have", "the", "specified", "path", "prefix", ".", "If", "no", "path", "prefix", "is", "specified", "the", "operation", "returns", "all", "users", "in", "the", "AWS", "account", ".", "If", "there", "are", "none", "...
def module_iam_list_users(): ''' Lists the IAM users that have the specified path prefix. If no path prefix is specified, the operation returns all users in the AWS account. If there are none, the operation returns an empty list. python3 weirdAAL.py -m iam_list_users -t yolo ''' iam_list_users()
[ "def", "module_iam_list_users", "(", ")", ":", "iam_list_users", "(", ")" ]
https://github.com/carnal0wnage/weirdAAL/blob/c14e36d7bb82447f38a43da203f4bc29429f4cf4/modules/aws/iam.py#L32-L37
zacharyvoase/markdoc
694914ccb198d74e37321fc601061fe7f725b1ce
src/markdoc/cli/commands.py
python
command
(function)
return wrapper
Decorator/wrapper to declare a function as a Markdoc CLI task.
Decorator/wrapper to declare a function as a Markdoc CLI task.
[ "Decorator", "/", "wrapper", "to", "declare", "a", "function", "as", "a", "Markdoc", "CLI", "task", "." ]
def command(function): """Decorator/wrapper to declare a function as a Markdoc CLI task.""" cmd_name = function.__name__.replace('_', '-') help = (function.__doc__ or '').rstrip('.') or None parser = subparsers.add_parser(cmd_name, help=help) @wraps(function) def wrapper(config, args):...
[ "def", "command", "(", "function", ")", ":", "cmd_name", "=", "function", ".", "__name__", ".", "replace", "(", "'_'", ",", "'-'", ")", "help", "=", "(", "function", ".", "__doc__", "or", "''", ")", ".", "rstrip", "(", "'.'", ")", "or", "None", "pa...
https://github.com/zacharyvoase/markdoc/blob/694914ccb198d74e37321fc601061fe7f725b1ce/src/markdoc/cli/commands.py#L19-L32
theupdateframework/python-tuf
45cf6076e3da7ff47968975f8106c4d6a03f9d4c
tuf/client/updater.py
python
Updater.__init__
(self, repository_name, repository_mirrors, fetcher=None)
<Purpose> Constructor. Instantiating an updater object causes all the metadata files for the top-level roles to be read from disk, including the key and role information for the delegated targets of 'targets'. The actual metadata for delegated roles is not loaded in __init__. The metadata for...
<Purpose> Constructor. Instantiating an updater object causes all the metadata files for the top-level roles to be read from disk, including the key and role information for the delegated targets of 'targets'. The actual metadata for delegated roles is not loaded in __init__. The metadata for...
[ "<Purpose", ">", "Constructor", ".", "Instantiating", "an", "updater", "object", "causes", "all", "the", "metadata", "files", "for", "the", "top", "-", "level", "roles", "to", "be", "read", "from", "disk", "including", "the", "key", "and", "role", "informati...
def __init__(self, repository_name, repository_mirrors, fetcher=None): """ <Purpose> Constructor. Instantiating an updater object causes all the metadata files for the top-level roles to be read from disk, including the key and role information for the delegated targets of 'targets'. The act...
[ "def", "__init__", "(", "self", ",", "repository_name", ",", "repository_mirrors", ",", "fetcher", "=", "None", ")", ":", "# Do the arguments have the correct format?", "# These checks ensure the arguments have the appropriate", "# number of objects and object types and that all dict...
https://github.com/theupdateframework/python-tuf/blob/45cf6076e3da7ff47968975f8106c4d6a03f9d4c/tuf/client/updater.py#L617-L771
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/decimal.py
python
Context._ignore_flags
(self, *flags)
return list(flags)
Ignore the flags, if they are raised
Ignore the flags, if they are raised
[ "Ignore", "the", "flags", "if", "they", "are", "raised" ]
def _ignore_flags(self, *flags): """Ignore the flags, if they are raised""" # Do not mutate-- This way, copies of a context leave the original # alone. self._ignored_flags = (self._ignored_flags + list(flags)) return list(flags)
[ "def", "_ignore_flags", "(", "self", ",", "*", "flags", ")", ":", "# Do not mutate-- This way, copies of a context leave the original", "# alone.", "self", ".", "_ignored_flags", "=", "(", "self", ".", "_ignored_flags", "+", "list", "(", "flags", ")", ")", "return",...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/decimal.py#L3932-L3937
Amulet-Team/Amulet-Core
a57aeaa4216806401ff35a2dba38782a35abc42e
amulet/level/formats/anvil_world/format.py
python
AnvilFormat._load_player
(self, player_id: str)
return Player( player_id, dimension_str, position, rotation, )
Gets the :class:`Player` object that belongs to the specified player id If no parameter is supplied, the data of the local player will be returned :param player_id: The desired player id :return: A Player instance
Gets the :class:`Player` object that belongs to the specified player id
[ "Gets", "the", ":", "class", ":", "Player", "object", "that", "belongs", "to", "the", "specified", "player", "id" ]
def _load_player(self, player_id: str) -> Player: """ Gets the :class:`Player` object that belongs to the specified player id If no parameter is supplied, the data of the local player will be returned :param player_id: The desired player id :return: A Player instance ""...
[ "def", "_load_player", "(", "self", ",", "player_id", ":", "str", ")", "->", "Player", ":", "player_nbt", "=", "self", ".", "_get_raw_player_data", "(", "player_id", ")", "dimension", "=", "player_nbt", "[", "\"Dimension\"", "]", "# TODO: rework this when there is...
https://github.com/Amulet-Team/Amulet-Core/blob/a57aeaa4216806401ff35a2dba38782a35abc42e/amulet/level/formats/anvil_world/format.py#L594-L653
tomplus/kubernetes_asyncio
f028cc793e3a2c519be6a52a49fb77ff0b014c9b
kubernetes_asyncio/client/api/events_v1_api.py
python
EventsV1Api.delete_collection_namespaced_event_with_http_info
(self, namespace, **kwargs)
return self.api_client.call_api( '/apis/events.k8s.io/v1/namespaces/{namespace}/events', 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='V1...
delete_collection_namespaced_event # noqa: E501 delete collection of Event # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_collection_namespaced_event_with_http_info(namespac...
delete_collection_namespaced_event # noqa: E501
[ "delete_collection_namespaced_event", "#", "noqa", ":", "E501" ]
def delete_collection_namespaced_event_with_http_info(self, namespace, **kwargs): # noqa: E501 """delete_collection_namespaced_event # noqa: E501 delete collection of Event # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, ple...
[ "def", "delete_collection_namespaced_event_with_http_info", "(", "self", ",", "namespace", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "local_var_params", "=", "locals", "(", ")", "all_params", "=", "[", "'namespace'", ",", "'pretty'", ",", "'_continue'", "...
https://github.com/tomplus/kubernetes_asyncio/blob/f028cc793e3a2c519be6a52a49fb77ff0b014c9b/kubernetes_asyncio/client/api/events_v1_api.py#L215-L354
rpm-software-management/dnf
a96abad2cde8c46f7f36d7774d9d86f2d94715db
dnf/package.py
python
Package.source_name
(self)
return srcname
returns name of source package e.g. krb5-libs -> krb5
returns name of source package e.g. krb5-libs -> krb5
[ "returns", "name", "of", "source", "package", "e", ".", "g", ".", "krb5", "-", "libs", "-", ">", "krb5" ]
def source_name(self): # :api """ returns name of source package e.g. krb5-libs -> krb5 """ if self.sourcerpm is not None: # trim suffix first srcname = dnf.util.rtrim(self.sourcerpm, ".src.rpm") # sourcerpm should be in form of name-ve...
[ "def", "source_name", "(", "self", ")", ":", "# :api", "if", "self", ".", "sourcerpm", "is", "not", "None", ":", "# trim suffix first", "srcname", "=", "dnf", ".", "util", ".", "rtrim", "(", "self", ".", "sourcerpm", ",", "\".src.rpm\"", ")", "# sourcerpm ...
https://github.com/rpm-software-management/dnf/blob/a96abad2cde8c46f7f36d7774d9d86f2d94715db/dnf/package.py#L130-L147
buke/GreenOdoo
3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df
runtime/python/lib/python2.7/distutils/cmd.py
python
Command.copy_tree
(self, infile, outfile, preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1)
return dir_util.copy_tree( infile, outfile, preserve_mode,preserve_times,preserve_symlinks, not self.force, dry_run=self.dry_run)
Copy an entire directory tree respecting verbose, dry-run, and force flags.
Copy an entire directory tree respecting verbose, dry-run, and force flags.
[ "Copy", "an", "entire", "directory", "tree", "respecting", "verbose", "dry", "-", "run", "and", "force", "flags", "." ]
def copy_tree(self, infile, outfile, preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1): """Copy an entire directory tree respecting verbose, dry-run, and force flags. """ return dir_util.copy_tree( infile, outfile, ...
[ "def", "copy_tree", "(", "self", ",", "infile", ",", "outfile", ",", "preserve_mode", "=", "1", ",", "preserve_times", "=", "1", ",", "preserve_symlinks", "=", "0", ",", "level", "=", "1", ")", ":", "return", "dir_util", ".", "copy_tree", "(", "infile", ...
https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/distutils/cmd.py#L367-L377
Fallen-Breath/MCDReforged
fdb1d2520b35f916123f265dbd94603981bb2b0c
mcdreforged/plugin/builtin/mcdreforged_plugin/commands/sub_command.py
python
SubCommand.on_mcdr_command_permission_denied
(self, source: CommandSource, error: CommandError)
[]
def on_mcdr_command_permission_denied(self, source: CommandSource, error: CommandError): self.mcdr_plugin.on_mcdr_command_permission_denied(source, error)
[ "def", "on_mcdr_command_permission_denied", "(", "self", ",", "source", ":", "CommandSource", ",", "error", ":", "CommandError", ")", ":", "self", ".", "mcdr_plugin", ".", "on_mcdr_command_permission_denied", "(", "source", ",", "error", ")" ]
https://github.com/Fallen-Breath/MCDReforged/blob/fdb1d2520b35f916123f265dbd94603981bb2b0c/mcdreforged/plugin/builtin/mcdreforged_plugin/commands/sub_command.py#L71-L72
mysql/mysql-connector-python
c5460bcbb0dff8e4e48bf4af7a971c89bf486d85
lib/mysql/connector/connection.py
python
MySQLConnection._get_connection
(self, prtcls=None)
return conn
Get connection based on configuration This method will return the appropriated connection object using the connection parameters. Returns subclass of MySQLBaseSocket.
Get connection based on configuration
[ "Get", "connection", "based", "on", "configuration" ]
def _get_connection(self, prtcls=None): """Get connection based on configuration This method will return the appropriated connection object using the connection parameters. Returns subclass of MySQLBaseSocket. """ conn = None if self.unix_socket and os.name != '...
[ "def", "_get_connection", "(", "self", ",", "prtcls", "=", "None", ")", ":", "conn", "=", "None", "if", "self", ".", "unix_socket", "and", "os", ".", "name", "!=", "'nt'", ":", "conn", "=", "MySQLUnixSocket", "(", "unix_socket", "=", "self", ".", "unix...
https://github.com/mysql/mysql-connector-python/blob/c5460bcbb0dff8e4e48bf4af7a971c89bf486d85/lib/mysql/connector/connection.py#L383-L400