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
lisa-lab/pylearn2
af81e5c362f0df4df85c3e54e23b2adeec026055
pylearn2/cross_validation/subset_iterators.py
python
ValidationShuffleSplit.__iter__
(self)
Return train/valid/test splits. The validation set is generated by splitting the training set.
Return train/valid/test splits. The validation set is generated by splitting the training set.
[ "Return", "train", "/", "valid", "/", "test", "splits", ".", "The", "validation", "set", "is", "generated", "by", "splitting", "the", "training", "set", "." ]
def __iter__(self): """ Return train/valid/test splits. The validation set is generated by splitting the training set. """ for train, test in super(ValidationShuffleSplit, self).__iter__(): n = len(np.arange(self.n)[train]) train_cv = ShuffleSplit(n, test_...
[ "def", "__iter__", "(", "self", ")", ":", "for", "train", ",", "test", "in", "super", "(", "ValidationShuffleSplit", ",", "self", ")", ".", "__iter__", "(", ")", ":", "n", "=", "len", "(", "np", ".", "arange", "(", "self", ".", "n", ")", "[", "tr...
https://github.com/lisa-lab/pylearn2/blob/af81e5c362f0df4df85c3e54e23b2adeec026055/pylearn2/cross_validation/subset_iterators.py#L185-L195
grow/grow
97fc21730b6a674d5d33948d94968e79447ce433
grow/preprocessors/google_drive.py
python
GoogleDocsPreprocessor.get_edit_url
(self, doc=None)
return GoogleDocsPreprocessor._edit_url_format.format(id=self.config.id)
Returns the URL to edit in Google Docs.
Returns the URL to edit in Google Docs.
[ "Returns", "the", "URL", "to", "edit", "in", "Google", "Docs", "." ]
def get_edit_url(self, doc=None): """Returns the URL to edit in Google Docs.""" return GoogleDocsPreprocessor._edit_url_format.format(id=self.config.id)
[ "def", "get_edit_url", "(", "self", ",", "doc", "=", "None", ")", ":", "return", "GoogleDocsPreprocessor", ".", "_edit_url_format", ".", "format", "(", "id", "=", "self", ".", "config", ".", "id", ")" ]
https://github.com/grow/grow/blob/97fc21730b6a674d5d33948d94968e79447ce433/grow/preprocessors/google_drive.py#L164-L166
graphcore/examples
46d2b7687b829778369fc6328170a7b14761e5c6
code_examples/popart/block_sparse/examples/sparse_attention/sparse_attention_utils.py
python
Patterns.summary_window
(window_size, n_summary_blocks, blocksize_x)
return local_mask
A summary mask has all but n_summary_block*blocksize_x entries set to 0. The nonzero columns are at the end of the window. Parameters ---------- window_size : the length of the window in terms of tokens n_summary_blocks : how many blocks of non-zero columns to use ...
A summary mask has all but n_summary_block*blocksize_x entries set to 0. The nonzero columns are at the end of the window.
[ "A", "summary", "mask", "has", "all", "but", "n_summary_block", "*", "blocksize_x", "entries", "set", "to", "0", ".", "The", "nonzero", "columns", "are", "at", "the", "end", "of", "the", "window", "." ]
def summary_window(window_size, n_summary_blocks, blocksize_x): """ A summary mask has all but n_summary_block*blocksize_x entries set to 0. The nonzero columns are at the end of the window. Parameters ---------- window_size : the length of the window in terms of...
[ "def", "summary_window", "(", "window_size", ",", "n_summary_blocks", ",", "blocksize_x", ")", ":", "n_summary_tokens", "=", "n_summary_blocks", "*", "blocksize_x", "local_mask", "=", "sparse", ".", "lil_matrix", "(", "(", "window_size", ",", "window_size", ")", "...
https://github.com/graphcore/examples/blob/46d2b7687b829778369fc6328170a7b14761e5c6/code_examples/popart/block_sparse/examples/sparse_attention/sparse_attention_utils.py#L136-L151
selfteaching/selfteaching-python-camp
9982ee964b984595e7d664b07c389cddaf158f1e
exercises/1901080016/d10/mymodule/stats_word.py
python
stats_text
(text,count)
return stats_text_en(text,count)+stats_text_cn(text,count)
合并英文词频和中文字频的结果
合并英文词频和中文字频的结果
[ "合并英文词频和中文字频的结果" ]
def stats_text(text,count): ''' 合并英文词频和中文字频的结果 ''' if not isinstance(text,str): raise ValueError('参数必须是str类型,输入类型%s'%type(text)) return stats_text_en(text,count)+stats_text_cn(text,count)
[ "def", "stats_text", "(", "text", ",", "count", ")", ":", "if", "not", "isinstance", "(", "text", ",", "str", ")", ":", "raise", "ValueError", "(", "'参数必须是str类型,输入类型%s'%type(text))", "", "", "", "", "", "", "return", "stats_text_en", "(", "text", ",", ...
https://github.com/selfteaching/selfteaching-python-camp/blob/9982ee964b984595e7d664b07c389cddaf158f1e/exercises/1901080016/d10/mymodule/stats_word.py#L28-L34
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/sympy/stats/frv_types.py
python
BetaBinomial
(name, n, alpha, beta)
return rv(name, BetaBinomialDistribution, n, alpha, beta)
Create a Finite Random Variable representing a Beta-binomial distribution. Returns a RandomSymbol. Examples ======== >>> from sympy.stats import BetaBinomial, density >>> from sympy import S >>> X = BetaBinomial('X', 2, 1, 1) >>> density(X).dict {0: 1/3, 1: 2*beta(2, 2), 2: 1/3} ...
Create a Finite Random Variable representing a Beta-binomial distribution.
[ "Create", "a", "Finite", "Random", "Variable", "representing", "a", "Beta", "-", "binomial", "distribution", "." ]
def BetaBinomial(name, n, alpha, beta): """ Create a Finite Random Variable representing a Beta-binomial distribution. Returns a RandomSymbol. Examples ======== >>> from sympy.stats import BetaBinomial, density >>> from sympy import S >>> X = BetaBinomial('X', 2, 1, 1) >>> densit...
[ "def", "BetaBinomial", "(", "name", ",", "n", ",", "alpha", ",", "beta", ")", ":", "return", "rv", "(", "name", ",", "BetaBinomialDistribution", ",", "n", ",", "alpha", ",", "beta", ")" ]
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/sympy/stats/frv_types.py#L422-L446
dagster-io/dagster
b27d569d5fcf1072543533a0c763815d96f90b8f
python_modules/dagster/dagster/core/definitions/event_metadata.py
python
EventMetadata.path
(path: str)
return PathMetadataEntryData(path)
Static constructor for a metadata value wrapping a path as :py:class:`PathMetadataEntryData`. For example: .. code-block:: python @op def emit_metadata(context): yield AssetMaterialization( asset_key="my_dataset", metadata...
Static constructor for a metadata value wrapping a path as :py:class:`PathMetadataEntryData`. For example:
[ "Static", "constructor", "for", "a", "metadata", "value", "wrapping", "a", "path", "as", ":", "py", ":", "class", ":", "PathMetadataEntryData", ".", "For", "example", ":" ]
def path(path: str) -> "PathMetadataEntryData": """Static constructor for a metadata value wrapping a path as :py:class:`PathMetadataEntryData`. For example: .. code-block:: python @op def emit_metadata(context): yield AssetMaterialization( ...
[ "def", "path", "(", "path", ":", "str", ")", "->", "\"PathMetadataEntryData\"", ":", "return", "PathMetadataEntryData", "(", "path", ")" ]
https://github.com/dagster-io/dagster/blob/b27d569d5fcf1072543533a0c763815d96f90b8f/python_modules/dagster/dagster/core/definitions/event_metadata.py#L413-L431
wucng/TensorExpand
4ea58f64f5c5082b278229b799c9f679536510b7
TensorExpand/Object detection/SSD/balancap-SSD-Tensorflow/datasets/pascalvoc_to_tfrecords.py
python
_process_image
(directory, name)
return image_data, shape, bboxes, labels, labels_text, difficult, truncated
Process a image and annotation file. Args: filename: string, path to an image file e.g., '/path/to/example.JPG'. coder: instance of ImageCoder to provide TensorFlow image coding utils. Returns: image_buffer: string, JPEG encoding of RGB image. height: integer, image height in pixels. ...
Process a image and annotation file.
[ "Process", "a", "image", "and", "annotation", "file", "." ]
def _process_image(directory, name): """Process a image and annotation file. Args: filename: string, path to an image file e.g., '/path/to/example.JPG'. coder: instance of ImageCoder to provide TensorFlow image coding utils. Returns: image_buffer: string, JPEG encoding of RGB image. ...
[ "def", "_process_image", "(", "directory", ",", "name", ")", ":", "# Read the image file.", "filename", "=", "directory", "+", "DIRECTORY_IMAGES", "+", "name", "+", "'.jpg'", "image_data", "=", "tf", ".", "gfile", ".", "FastGFile", "(", "filename", ",", "'rb'"...
https://github.com/wucng/TensorExpand/blob/4ea58f64f5c5082b278229b799c9f679536510b7/TensorExpand/Object detection/SSD/balancap-SSD-Tensorflow/datasets/pascalvoc_to_tfrecords.py#L70-L121
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/core/ext-py/celery-4.2.1/celery/utils/text.py
python
abbr
(S, max, ellipsis='...')
return S
Abbreviate word.
Abbreviate word.
[ "Abbreviate", "word", "." ]
def abbr(S, max, ellipsis='...'): # type: (str, int, str) -> str """Abbreviate word.""" if S is None: return '???' if len(S) > max: return ellipsis and (S[:max - len(ellipsis)] + ellipsis) or S[:max] return S
[ "def", "abbr", "(", "S", ",", "max", ",", "ellipsis", "=", "'...'", ")", ":", "# type: (str, int, str) -> str", "if", "S", "is", "None", ":", "return", "'???'", "if", "len", "(", "S", ")", ">", "max", ":", "return", "ellipsis", "and", "(", "S", "[", ...
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/celery-4.2.1/celery/utils/text.py#L70-L77
openstack/nova
b49b7663e1c3073917d5844b81d38db8e86d05c4
nova/db/main/api.py
python
_instances_fill_metadata
(context, instances, manual_joins=None)
return filled_instances
Selectively fill instances with manually-joined metadata. Note that instance will be converted to a dict. :param context: security context :param instances: list of instances to fill :param manual_joins: list of tables to manually join (can be any combination of 'metadata' and ...
Selectively fill instances with manually-joined metadata. Note that instance will be converted to a dict.
[ "Selectively", "fill", "instances", "with", "manually", "-", "joined", "metadata", ".", "Note", "that", "instance", "will", "be", "converted", "to", "a", "dict", "." ]
def _instances_fill_metadata(context, instances, manual_joins=None): """Selectively fill instances with manually-joined metadata. Note that instance will be converted to a dict. :param context: security context :param instances: list of instances to fill :param manual_joins: list of tables to manua...
[ "def", "_instances_fill_metadata", "(", "context", ",", "instances", ",", "manual_joins", "=", "None", ")", ":", "uuids", "=", "[", "inst", "[", "'uuid'", "]", "for", "inst", "in", "instances", "]", "if", "manual_joins", "is", "None", ":", "manual_joins", ...
https://github.com/openstack/nova/blob/b49b7663e1c3073917d5844b81d38db8e86d05c4/nova/db/main/api.py#L1448-L1495
huawei-noah/Pretrained-Language-Model
d4694a134bdfacbaef8ff1d99735106bd3b3372b
PanGu-α/utils.py
python
LearningRate.construct
(self, global_step)
return lr
dynamic learning rate
dynamic learning rate
[ "dynamic", "learning", "rate" ]
def construct(self, global_step): """dynamic learning rate""" if not self.use_cosine: decay_lr = self.decay_lr(global_step) else: decay_lr = self.cosine_decay_lr(global_step) if self.warmup_flag: is_warmup = self.cast(self.greater(self.warmup_steps, gl...
[ "def", "construct", "(", "self", ",", "global_step", ")", ":", "if", "not", "self", ".", "use_cosine", ":", "decay_lr", "=", "self", ".", "decay_lr", "(", "global_step", ")", "else", ":", "decay_lr", "=", "self", ".", "cosine_decay_lr", "(", "global_step",...
https://github.com/huawei-noah/Pretrained-Language-Model/blob/d4694a134bdfacbaef8ff1d99735106bd3b3372b/PanGu-α/utils.py#L225-L238
aws-samples/aws-kube-codesuite
ab4e5ce45416b83bffb947ab8d234df5437f4fca
src/networkx/algorithms/traversal/breadth_first_search.py
python
bfs_predecessors
(G, source)
Returns an iterator of predecessors in breadth-first-search from source. Parameters ---------- G : NetworkX graph source : node Specify starting node for breadth-first search and return edges in the component reachable from source. Returns ------- pred: iterator (nod...
Returns an iterator of predecessors in breadth-first-search from source.
[ "Returns", "an", "iterator", "of", "predecessors", "in", "breadth", "-", "first", "-", "search", "from", "source", "." ]
def bfs_predecessors(G, source): """Returns an iterator of predecessors in breadth-first-search from source. Parameters ---------- G : NetworkX graph source : node Specify starting node for breadth-first search and return edges in the component reachable from source. Returns ...
[ "def", "bfs_predecessors", "(", "G", ",", "source", ")", ":", "for", "s", ",", "t", "in", "bfs_edges", "(", "G", ",", "source", ")", ":", "yield", "(", "t", ",", "s", ")" ]
https://github.com/aws-samples/aws-kube-codesuite/blob/ab4e5ce45416b83bffb947ab8d234df5437f4fca/src/networkx/algorithms/traversal/breadth_first_search.py#L167-L200
ppizarror/pygame-menu
da5827a1ad0686e8ff2aa536b74bbfba73967bcf
pygame_menu/widgets/widget/textinput.py
python
TextInputManager.text_input
( self, title: Any, default: Union[str, int, float] = '', copy_paste_enable: bool = True, cursor_selection_enable: bool = True, cursor_size: Optional[Tuple2IntType] = None, input_type: str = INPUT_TEXT, input_underline: str ...
return widget
Add a text input to the Menu: free text area and two functions that execute when changing the text and pressing return button on the element. The callbacks receive the current value and all unknown keyword arguments, where ``current_text=widget.get_value``: .. code-block:: python ...
Add a text input to the Menu: free text area and two functions that execute when changing the text and pressing return button on the element.
[ "Add", "a", "text", "input", "to", "the", "Menu", ":", "free", "text", "area", "and", "two", "functions", "that", "execute", "when", "changing", "the", "text", "and", "pressing", "return", "button", "on", "the", "element", "." ]
def text_input( self, title: Any, default: Union[str, int, float] = '', copy_paste_enable: bool = True, cursor_selection_enable: bool = True, cursor_size: Optional[Tuple2IntType] = None, input_type: str = INPUT_TEXT, input_u...
[ "def", "text_input", "(", "self", ",", "title", ":", "Any", ",", "default", ":", "Union", "[", "str", ",", "int", ",", "float", "]", "=", "''", ",", "copy_paste_enable", ":", "bool", "=", "True", ",", "cursor_selection_enable", ":", "bool", "=", "True"...
https://github.com/ppizarror/pygame-menu/blob/da5827a1ad0686e8ff2aa536b74bbfba73967bcf/pygame_menu/widgets/widget/textinput.py#L1942-L2093
profusion/sgqlc
465a5e800f8b408ceafe25cde45ee0bde4912482
sgqlc/codegen/operation.py
python
NoValidation.validate_type
(self, typ, candidate, value)
return None
[]
def validate_type(self, typ, candidate, value): return None
[ "def", "validate_type", "(", "self", ",", "typ", ",", "candidate", ",", "value", ")", ":", "return", "None" ]
https://github.com/profusion/sgqlc/blob/465a5e800f8b408ceafe25cde45ee0bde4912482/sgqlc/codegen/operation.py#L74-L75
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/networkx/algorithms/planarity.py
python
LRPlanarity.dfs_orientation
(self, v)
Orient the graph by DFS, compute lowpoints and nesting order.
Orient the graph by DFS, compute lowpoints and nesting order.
[ "Orient", "the", "graph", "by", "DFS", "compute", "lowpoints", "and", "nesting", "order", "." ]
def dfs_orientation(self, v): """Orient the graph by DFS, compute lowpoints and nesting order. """ # the recursion stack dfs_stack = [v] # index of next edge to handle in adjacency list of each node ind = defaultdict(lambda: 0) # boolean to indicate whether to ski...
[ "def", "dfs_orientation", "(", "self", ",", "v", ")", ":", "# the recursion stack", "dfs_stack", "=", "[", "v", "]", "# index of next edge to handle in adjacency list of each node", "ind", "=", "defaultdict", "(", "lambda", ":", "0", ")", "# boolean to indicate whether ...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/networkx/algorithms/planarity.py#L372-L424
theevilbit/exploit_generator
ae3cc5c02c9d5e9ee091dbef04158d3bfd23330e
class-minishare.py
python
Exploit.exploit
(self)
This function runs the actual exploit
This function runs the actual exploit
[ "This", "function", "runs", "the", "actual", "exploit" ]
def exploit(self): """ This function runs the actual exploit """ sleep(1) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(('127.0.0.1',80)) #Test 1 message = "GET " + ''.join(self.buffer) + " HTTP/1.1\r\n\r\n" sock.send(message) sock.close()
[ "def", "exploit", "(", "self", ")", ":", "sleep", "(", "1", ")", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "sock", ".", "connect", "(", "(", "'127.0.0.1'", ",", "80", ")", ")", "#Te...
https://github.com/theevilbit/exploit_generator/blob/ae3cc5c02c9d5e9ee091dbef04158d3bfd23330e/class-minishare.py#L50-L60
DataDog/integrations-core
934674b29d94b70ccc008f76ea172d0cdae05e1e
vsphere/datadog_checks/vsphere/config.py
python
VSphereConfig.__init__
(self, instance, init_config, log)
[]
def __init__(self, instance, init_config, log): # type: (InstanceConfig, InitConfigType, CheckLoggingAdapter) -> None self.log = log # Connection parameters self.hostname = instance['host'] self.username = instance['username'] self.password = instance['password'] ...
[ "def", "__init__", "(", "self", ",", "instance", ",", "init_config", ",", "log", ")", ":", "# type: (InstanceConfig, InitConfigType, CheckLoggingAdapter) -> None", "self", ".", "log", "=", "log", "# Connection parameters", "self", ".", "hostname", "=", "instance", "["...
https://github.com/DataDog/integrations-core/blob/934674b29d94b70ccc008f76ea172d0cdae05e1e/vsphere/datadog_checks/vsphere/config.py#L32-L102
OpenNMT/OpenNMT-py
4815f07fcd482af9a1fe1d3b620d144197178bc5
onmt/translate/translation_server.py
python
TranslationServer.__init__
(self)
[]
def __init__(self): self.models = {} self.next_id = 0
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "models", "=", "{", "}", "self", ".", "next_id", "=", "0" ]
https://github.com/OpenNMT/OpenNMT-py/blob/4815f07fcd482af9a1fe1d3b620d144197178bc5/onmt/translate/translation_server.py#L165-L167
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/pluggy/manager.py
python
PluginManager.load_setuptools_entrypoints
(self, entrypoint_name)
return len(self._plugin_distinfo)
Load modules from querying the specified setuptools entrypoint name. Return the number of loaded plugins.
Load modules from querying the specified setuptools entrypoint name. Return the number of loaded plugins.
[ "Load", "modules", "from", "querying", "the", "specified", "setuptools", "entrypoint", "name", ".", "Return", "the", "number", "of", "loaded", "plugins", "." ]
def load_setuptools_entrypoints(self, entrypoint_name): """ Load modules from querying the specified setuptools entrypoint name. Return the number of loaded plugins. """ from pkg_resources import ( iter_entry_points, DistributionNotFound, VersionConflict, ...
[ "def", "load_setuptools_entrypoints", "(", "self", ",", "entrypoint_name", ")", ":", "from", "pkg_resources", "import", "(", "iter_entry_points", ",", "DistributionNotFound", ",", "VersionConflict", ",", ")", "for", "ep", "in", "iter_entry_points", "(", "entrypoint_na...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/pluggy/manager.py#L253-L277
matplotlib/matplotlib
8d7a2b9d2a38f01ee0d6802dd4f9e98aec812322
lib/matplotlib/patches.py
python
CirclePolygon.__init__
(self, xy, radius=5, resolution=20, # the number of vertices ** kwargs)
Create a circle at *xy* = (*x*, *y*) with given *radius*. This circle is approximated by a regular polygon with *resolution* sides. For a smoother circle drawn with splines, see `Circle`. Valid keyword arguments are: %(Patch:kwdoc)s
Create a circle at *xy* = (*x*, *y*) with given *radius*.
[ "Create", "a", "circle", "at", "*", "xy", "*", "=", "(", "*", "x", "*", "*", "y", "*", ")", "with", "given", "*", "radius", "*", "." ]
def __init__(self, xy, radius=5, resolution=20, # the number of vertices ** kwargs): """ Create a circle at *xy* = (*x*, *y*) with given *radius*. This circle is approximated by a regular polygon with *resolution* sides. For a smoother circle drawn wi...
[ "def", "__init__", "(", "self", ",", "xy", ",", "radius", "=", "5", ",", "resolution", "=", "20", ",", "# the number of vertices", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "xy", ",", "resolution", ",", "radius", ",", "or...
https://github.com/matplotlib/matplotlib/blob/8d7a2b9d2a38f01ee0d6802dd4f9e98aec812322/lib/matplotlib/patches.py#L1511-L1524
OpenMDAO/OpenMDAO
f47eb5485a0bb5ea5d2ae5bd6da4b94dc6b296bd
openmdao/core/component.py
python
Component._find_partial_matches
(self, of_pattern, wrt_pattern)
return of_pattern_matches, wrt_pattern_matches
Find all partial derivative matches from of and wrt. Parameters ---------- of_pattern : str or list of str The relative name of the residual(s) that derivatives are being computed for. May also contain a glob pattern. wrt_pattern : str or list of str ...
Find all partial derivative matches from of and wrt.
[ "Find", "all", "partial", "derivative", "matches", "from", "of", "and", "wrt", "." ]
def _find_partial_matches(self, of_pattern, wrt_pattern): """ Find all partial derivative matches from of and wrt. Parameters ---------- of_pattern : str or list of str The relative name of the residual(s) that derivatives are being computed for. May also...
[ "def", "_find_partial_matches", "(", "self", ",", "of_pattern", ",", "wrt_pattern", ")", ":", "of_list", "=", "[", "of_pattern", "]", "if", "isinstance", "(", "of_pattern", ",", "str", ")", "else", "of_pattern", "wrt_list", "=", "[", "wrt_pattern", "]", "if"...
https://github.com/OpenMDAO/OpenMDAO/blob/f47eb5485a0bb5ea5d2ae5bd6da4b94dc6b296bd/openmdao/core/component.py#L1459-L1486
Ehco1996/django-sspanel
c069a4b34bebaa6fc7a7ad389f179e6e5ce96491
apps/mixin.py
python
StaffRequiredMixin.dispatch
(self, request, *args, **kwargs)
return super().dispatch(request, *args, **kwargs)
[]
def dispatch(self, request, *args, **kwargs): if not request.user.is_staff: return redirect_to_login(request.get_full_path()) return super().dispatch(request, *args, **kwargs)
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "request", ".", "user", ".", "is_staff", ":", "return", "redirect_to_login", "(", "request", ".", "get_full_path", "(", ")", ")", "return"...
https://github.com/Ehco1996/django-sspanel/blob/c069a4b34bebaa6fc7a7ad389f179e6e5ce96491/apps/mixin.py#L17-L20
moloch--/RootTheBox
097272332b9f9b7e2df31ca0823ed10c7b66ac81
models/WallOfSheep.py
python
WallOfSheep.leaderboard
(cls, order_by="passwords")
return leaders
Creates an ordered list of tuples, for each user and the number of password they've cracked
Creates an ordered list of tuples, for each user and the number of password they've cracked
[ "Creates", "an", "ordered", "list", "of", "tuples", "for", "each", "user", "and", "the", "number", "of", "password", "they", "ve", "cracked" ]
def leaderboard(cls, order_by="passwords"): """ Creates an ordered list of tuples, for each user and the number of password they've cracked """ orders = {"passwords": 1, "cash": 2} leaders = [] for user in User.all_users(): if 0 < cls.count_cracked_by(...
[ "def", "leaderboard", "(", "cls", ",", "order_by", "=", "\"passwords\"", ")", ":", "orders", "=", "{", "\"passwords\"", ":", "1", ",", "\"cash\"", ":", "2", "}", "leaders", "=", "[", "]", "for", "user", "in", "User", ".", "all_users", "(", ")", ":", ...
https://github.com/moloch--/RootTheBox/blob/097272332b9f9b7e2df31ca0823ed10c7b66ac81/models/WallOfSheep.py#L77-L96
barseghyanartur/django-dash
dc00513b65e017c40f278a0a7df2a18ec8da9bc3
src/dash/base.py
python
BaseDashboardPlugin.save_plugin_data
(self, dashboard_entry, plugin_data)
Save plugin data. Used in bulk update plugin data. :param dash.models.DashboardEntry dashboard_entry: :param dict plugin_data: :return bool: True if all went well.
Save plugin data.
[ "Save", "plugin", "data", "." ]
def save_plugin_data(self, dashboard_entry, plugin_data): """Save plugin data. Used in bulk update plugin data. :param dash.models.DashboardEntry dashboard_entry: :param dict plugin_data: :return bool: True if all went well. """ try: if plugin_data: ...
[ "def", "save_plugin_data", "(", "self", ",", "dashboard_entry", ",", "plugin_data", ")", ":", "try", ":", "if", "plugin_data", ":", "dashboard_entry", ".", "plugin_data", "=", "plugin_data", "dashboard_entry", ".", "save", "(", ")", "return", "True", "except", ...
https://github.com/barseghyanartur/django-dash/blob/dc00513b65e017c40f278a0a7df2a18ec8da9bc3/src/dash/base.py#L1302-L1317
microsoft/ptvsd
99c8513921021d2cc7cd82e132b65c644c256768
src/ptvsd/_vendored/pydevd/stubs/_get_tips.py
python
GenerateImportsTipForModule
(obj_to_complete, dirComps=None, getattr=getattr, filter=lambda name:True)
return ret
@param obj_to_complete: the object from where we should get the completions @param dirComps: if passed, we should not 'dir' the object and should just iterate those passed as a parameter @param getattr: the way to get a given object from the obj_to_complete (used for the completer) @param filter...
[]
def GenerateImportsTipForModule(obj_to_complete, dirComps=None, getattr=getattr, filter=lambda name:True): ''' @param obj_to_complete: the object from where we should get the completions @param dirComps: if passed, we should not 'dir' the object and should just iterate those passed as a parameter ...
[ "def", "GenerateImportsTipForModule", "(", "obj_to_complete", ",", "dirComps", "=", "None", ",", "getattr", "=", "getattr", ",", "filter", "=", "lambda", "name", ":", "True", ")", ":", "ret", "=", "[", "]", "if", "dirComps", "is", "None", ":", "dirComps", ...
https://github.com/microsoft/ptvsd/blob/99c8513921021d2cc7cd82e132b65c644c256768/src/ptvsd/_vendored/pydevd/stubs/_get_tips.py#L125-L259
misterch0c/shadowbroker
e3a069bea47a2c1009697941ac214adc6f90aa8d
windows/Resources/Python/Core/Lib/optparse.py
python
OptionParser.print_help
(self, file=None)
return
print_help(file : file = stdout) Print an extended help message, listing all options and any help text provided with them, to 'file' (default stdout).
print_help(file : file = stdout) Print an extended help message, listing all options and any help text provided with them, to 'file' (default stdout).
[ "print_help", "(", "file", ":", "file", "=", "stdout", ")", "Print", "an", "extended", "help", "message", "listing", "all", "options", "and", "any", "help", "text", "provided", "with", "them", "to", "file", "(", "default", "stdout", ")", "." ]
def print_help(self, file=None): """print_help(file : file = stdout) Print an extended help message, listing all options and any help text provided with them, to 'file' (default stdout). """ if file is None: file = sys.stdout encoding = self._get_enco...
[ "def", "print_help", "(", "self", ",", "file", "=", "None", ")", ":", "if", "file", "is", "None", ":", "file", "=", "sys", ".", "stdout", "encoding", "=", "self", ".", "_get_encoding", "(", "file", ")", "file", ".", "write", "(", "self", ".", "form...
https://github.com/misterch0c/shadowbroker/blob/e3a069bea47a2c1009697941ac214adc6f90aa8d/windows/Resources/Python/Core/Lib/optparse.py#L1351-L1361
bigmlcom/python
35f69d2f3121f1b3dde43495cf145d4992796ad5
bigml/topicmodel.py
python
TopicModel.sample_uniform
(self, document, updates, rng)
return counts
Samples topics for the terms in the given `document` assuming uniform topic assignments for `updates` iterations. Used to initialize the gibbs sampler.
Samples topics for the terms in the given `document` assuming uniform topic assignments for `updates` iterations. Used to initialize the gibbs sampler.
[ "Samples", "topics", "for", "the", "terms", "in", "the", "given", "document", "assuming", "uniform", "topic", "assignments", "for", "updates", "iterations", ".", "Used", "to", "initialize", "the", "gibbs", "sampler", "." ]
def sample_uniform(self, document, updates, rng): """Samples topics for the terms in the given `document` assuming uniform topic assignments for `updates` iterations. Used to initialize the gibbs sampler. """ counts = [0] * self.ntopics for _ in range(updates): ...
[ "def", "sample_uniform", "(", "self", ",", "document", ",", "updates", ",", "rng", ")", ":", "counts", "=", "[", "0", "]", "*", "self", ".", "ntopics", "for", "_", "in", "range", "(", "updates", ")", ":", "for", "term", "in", "document", ":", "for"...
https://github.com/bigmlcom/python/blob/35f69d2f3121f1b3dde43495cf145d4992796ad5/bigml/topicmodel.py#L317-L341
virtualabs/btlejack
4e3014f90a55d0e7068f2580dfd6cac3e149114b
btlejack/jobs.py
python
SingleSnifferInterface.sniff_connection
(self, bd_address, channel=37)
Sniff a specific bd address on a specific channel.
Sniff a specific bd address on a specific channel.
[ "Sniff", "a", "specific", "bd", "address", "on", "a", "specific", "channel", "." ]
def sniff_connection(self, bd_address, channel=37): """ Sniff a specific bd address on a specific channel. """ self.link.write(SniffConnReqCommand(bd_address, channel)) self.link.wait_packet(SniffConnReqResponse) super().sniff_connection()
[ "def", "sniff_connection", "(", "self", ",", "bd_address", ",", "channel", "=", "37", ")", ":", "self", ".", "link", ".", "write", "(", "SniffConnReqCommand", "(", "bd_address", ",", "channel", ")", ")", "self", ".", "link", ".", "wait_packet", "(", "Sni...
https://github.com/virtualabs/btlejack/blob/4e3014f90a55d0e7068f2580dfd6cac3e149114b/btlejack/jobs.py#L119-L125
simple-login/app
4cea47cc27c19ed4d02e5bf835930632059af5af
app/models.py
python
Alias.unsubscribe_link
(self, contact: Optional["Contact"] = None)
return the unsubscribe link along with whether this is via email (mailto:) or Http POST The mailto: method is preferred
return the unsubscribe link along with whether this is via email (mailto:) or Http POST The mailto: method is preferred
[ "return", "the", "unsubscribe", "link", "along", "with", "whether", "this", "is", "via", "email", "(", "mailto", ":", ")", "or", "Http", "POST", "The", "mailto", ":", "method", "is", "preferred" ]
def unsubscribe_link(self, contact: Optional["Contact"] = None) -> (str, bool): """ return the unsubscribe link along with whether this is via email (mailto:) or Http POST The mailto: method is preferred """ if contact: if UNSUBSCRIBER: return f"mailto...
[ "def", "unsubscribe_link", "(", "self", ",", "contact", ":", "Optional", "[", "\"Contact\"", "]", "=", "None", ")", "->", "(", "str", ",", "bool", ")", ":", "if", "contact", ":", "if", "UNSUBSCRIBER", ":", "return", "f\"mailto:{UNSUBSCRIBER}?subject={contact.i...
https://github.com/simple-login/app/blob/4cea47cc27c19ed4d02e5bf835930632059af5af/app/models.py#L1389-L1403
Lonero-Team/Decentralized-Internet
3cb157834fcc19ff8c2316e66bf07b103c137068
clusterpost/bigchaindb/bigchaindb/elections/vote.py
python
Vote.validate_schema
(cls, tx)
Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER` transaction, all the validations for `CREATE` transaction should be inherited
Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER` transaction, all the validations for `CREATE` transaction should be inherited
[ "Validate", "the", "validator", "election", "vote", "transaction", ".", "Since", "VOTE", "extends", "TRANSFER", "transaction", "all", "the", "validations", "for", "CREATE", "transaction", "should", "be", "inherited" ]
def validate_schema(cls, tx): """Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER` transaction, all the validations for `CREATE` transaction should be inherited """ _validate_schema(TX_SCHEMA_COMMON, tx) _validate_schema(TX_SCHEMA_TRANSFER, tx) ...
[ "def", "validate_schema", "(", "cls", ",", "tx", ")", ":", "_validate_schema", "(", "TX_SCHEMA_COMMON", ",", "tx", ")", "_validate_schema", "(", "TX_SCHEMA_TRANSFER", ",", "tx", ")", "_validate_schema", "(", "cls", ".", "TX_SCHEMA_CUSTOM", ",", "tx", ")" ]
https://github.com/Lonero-Team/Decentralized-Internet/blob/3cb157834fcc19ff8c2316e66bf07b103c137068/clusterpost/bigchaindb/bigchaindb/elections/vote.py#L49-L55
emesene/emesene
4548a4098310e21b16437bb36223a7f632a4f7bc
emesene/gui/gtkui/Window.py
python
Window._on_delete_event
(self, widget, event)
call the cb_on_close callback, if the callback return True then dont close the window
call the cb_on_close callback, if the callback return True then dont close the window
[ "call", "the", "cb_on_close", "callback", "if", "the", "callback", "return", "True", "then", "dont", "close", "the", "window" ]
def _on_delete_event(self, widget, event): '''call the cb_on_close callback, if the callback return True then dont close the window''' self.save_dimensions() if self.content_conv and not self.content_main: self.content_conv.close_all() return False else: ...
[ "def", "_on_delete_event", "(", "self", ",", "widget", ",", "event", ")", ":", "self", ".", "save_dimensions", "(", ")", "if", "self", ".", "content_conv", "and", "not", "self", ".", "content_main", ":", "self", ".", "content_conv", ".", "close_all", "(", ...
https://github.com/emesene/emesene/blob/4548a4098310e21b16437bb36223a7f632a4f7bc/emesene/gui/gtkui/Window.py#L250-L258
khanhnamle1994/natural-language-processing
01d450d5ac002b0156ef4cf93a07cb508c1bcdc5
assignment1/.env/lib/python2.7/site-packages/IPython/utils/generics.py
python
inspect_object
(obj)
Called when you do obj?
Called when you do obj?
[ "Called", "when", "you", "do", "obj?" ]
def inspect_object(obj): """Called when you do obj?""" raise TryNext
[ "def", "inspect_object", "(", "obj", ")", ":", "raise", "TryNext" ]
https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/IPython/utils/generics.py#L27-L29
timonwong/OmniMarkupPreviewer
21921ac7a99d2b5924a2219b33679a5b53621392
OmniMarkupLib/Renderers/libs/python3/docutils/utils/math/math2html.py
python
FormulaParser.parsemultiliner
(self, reader, start, ending)
return formula
Parse a formula in multiple lines
Parse a formula in multiple lines
[ "Parse", "a", "formula", "in", "multiple", "lines" ]
def parsemultiliner(self, reader, start, ending): "Parse a formula in multiple lines" formula = '' line = reader.currentline() if not start in line: Trace.error('Line ' + line.strip() + ' does not contain formula start ' + start) return '' index = line.index(start) line = line[index ...
[ "def", "parsemultiliner", "(", "self", ",", "reader", ",", "start", ",", "ending", ")", ":", "formula", "=", "''", "line", "=", "reader", ".", "currentline", "(", ")", "if", "not", "start", "in", "line", ":", "Trace", ".", "error", "(", "'Line '", "+...
https://github.com/timonwong/OmniMarkupPreviewer/blob/21921ac7a99d2b5924a2219b33679a5b53621392/OmniMarkupLib/Renderers/libs/python3/docutils/utils/math/math2html.py#L2443-L2458
DataDog/integrations-core
934674b29d94b70ccc008f76ea172d0cdae05e1e
tokumx/datadog_checks/tokumx/vendor/pymongo/results.py
python
BulkWriteResult.bulk_api_result
(self)
return self.__bulk_api_result
The raw bulk API result.
The raw bulk API result.
[ "The", "raw", "bulk", "API", "result", "." ]
def bulk_api_result(self): """The raw bulk API result.""" return self.__bulk_api_result
[ "def", "bulk_api_result", "(", "self", ")", ":", "return", "self", ".", "__bulk_api_result" ]
https://github.com/DataDog/integrations-core/blob/934674b29d94b70ccc008f76ea172d0cdae05e1e/tokumx/datadog_checks/tokumx/vendor/pymongo/results.py#L180-L182
skylander86/lambda-text-extractor
6da52d077a2fc571e38bfe29c33ae68f6443cd5a
lib-linux_x64/docx/parts/image.py
python
ImagePart.default_cy
(self)
return Emu(height_in_emu)
Native height of this image, calculated from its height in pixels and vertical dots per inch (dpi).
Native height of this image, calculated from its height in pixels and vertical dots per inch (dpi).
[ "Native", "height", "of", "this", "image", "calculated", "from", "its", "height", "in", "pixels", "and", "vertical", "dots", "per", "inch", "(", "dpi", ")", "." ]
def default_cy(self): """ Native height of this image, calculated from its height in pixels and vertical dots per inch (dpi). """ px_height = self.image.px_height horz_dpi = self.image.horz_dpi height_in_emu = 914400 * px_height / horz_dpi return Emu(heigh...
[ "def", "default_cy", "(", "self", ")", ":", "px_height", "=", "self", ".", "image", ".", "px_height", "horz_dpi", "=", "self", ".", "image", ".", "horz_dpi", "height_in_emu", "=", "914400", "*", "px_height", "/", "horz_dpi", "return", "Emu", "(", "height_i...
https://github.com/skylander86/lambda-text-extractor/blob/6da52d077a2fc571e38bfe29c33ae68f6443cd5a/lib-linux_x64/docx/parts/image.py#L39-L47
golismero/golismero
7d605b937e241f51c1ca4f47b20f755eeefb9d76
tools/sqlmap/thirdparty/pydes/pyDes.py
python
des.__des_crypt
(self, block, crypt_type)
return self.final
Crypt the block of data through DES bit-manipulation
Crypt the block of data through DES bit-manipulation
[ "Crypt", "the", "block", "of", "data", "through", "DES", "bit", "-", "manipulation" ]
def __des_crypt(self, block, crypt_type): """Crypt the block of data through DES bit-manipulation""" block = self.__permutate(des.__ip, block) Bn = [0] * 32 self.L = block[:32] self.R = block[32:] # Encryption starts from Kn[1] through to Kn[16] if crypt_type == ...
[ "def", "__des_crypt", "(", "self", ",", "block", ",", "crypt_type", ")", ":", "block", "=", "self", ".", "__permutate", "(", "des", ".", "__ip", ",", "block", ")", "Bn", "=", "[", "0", "]", "*", "32", "self", ".", "L", "=", "block", "[", ":", "...
https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/tools/sqlmap/thirdparty/pydes/pyDes.py#L491-L566
huggingface/transformers
623b4f7c63f60cce917677ee704d6c93ee960b4b
src/transformers/models/albert/modeling_flax_albert.py
python
FlaxAlbertForMaskedLMModule.setup
(self)
[]
def setup(self): self.albert = FlaxAlbertModule(config=self.config, add_pooling_layer=False, dtype=self.dtype) self.predictions = FlaxAlbertOnlyMLMHead(config=self.config, dtype=self.dtype)
[ "def", "setup", "(", "self", ")", ":", "self", ".", "albert", "=", "FlaxAlbertModule", "(", "config", "=", "self", ".", "config", ",", "add_pooling_layer", "=", "False", ",", "dtype", "=", "self", ".", "dtype", ")", "self", ".", "predictions", "=", "Fl...
https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/albert/modeling_flax_albert.py#L775-L777
KinglittleQ/GST-Tacotron
1870f6e1b5b27b556212efd93faa629197e00c46
cutoff.py
python
cutoff
(input_wav, output_wav)
input_wav --- input wav file path output_wav --- output wav file path
input_wav --- input wav file path output_wav --- output wav file path
[ "input_wav", "---", "input", "wav", "file", "path", "output_wav", "---", "output", "wav", "file", "path" ]
def cutoff(input_wav, output_wav): ''' input_wav --- input wav file path output_wav --- output wav file path ''' # read input wave file and get parameters. with wave.open(input_wav, 'r') as fw: params = fw.getparams() # print(params) nchannels, sampwidth, framerate, nfra...
[ "def", "cutoff", "(", "input_wav", ",", "output_wav", ")", ":", "# read input wave file and get parameters.", "with", "wave", ".", "open", "(", "input_wav", ",", "'r'", ")", "as", "fw", ":", "params", "=", "fw", ".", "getparams", "(", ")", "# print(params)", ...
https://github.com/KinglittleQ/GST-Tacotron/blob/1870f6e1b5b27b556212efd93faa629197e00c46/cutoff.py#L5-L34
FederatedAI/FATE
32540492623568ecd1afcb367360133616e02fa3
python/federatedml/framework/weights.py
python
Weights.__iadd__
(self, other)
return self.binary_op(other, operator.add, inplace=True)
[]
def __iadd__(self, other): return self.binary_op(other, operator.add, inplace=True)
[ "def", "__iadd__", "(", "self", ",", "other", ")", ":", "return", "self", ".", "binary_op", "(", "other", ",", "operator", ".", "add", ",", "inplace", "=", "True", ")" ]
https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/federatedml/framework/weights.py#L92-L93
CalebBell/thermo
572a47d1b03d49fe609b8d5f826fa6a7cde00828
thermo/fitting.py
python
alpha_constrain_err
(err, d0, d1, d2, d3, valid=True, debug=False)
return err
[]
def alpha_constrain_err(err, d0, d1, d2, d3, valid=True, debug=False): N = len(d0) zeros = np.zeros(N) d0 = np.min([d0, zeros], axis=0) del_0 = np.abs(d0*100) d1 = np.max([d1, zeros], axis=0) del_1 = np.abs(d1*1000) d2 = np.min([d2, zeros], axis=0) del_2 = np.abs(d2*5000) d3 = np...
[ "def", "alpha_constrain_err", "(", "err", ",", "d0", ",", "d1", ",", "d2", ",", "d3", ",", "valid", "=", "True", ",", "debug", "=", "False", ")", ":", "N", "=", "len", "(", "d0", ")", "zeros", "=", "np", ".", "zeros", "(", "N", ")", "d0", "="...
https://github.com/CalebBell/thermo/blob/572a47d1b03d49fe609b8d5f826fa6a7cde00828/thermo/fitting.py#L500-L529
Jenyay/outwiker
50530cf7b3f71480bb075b2829bc0669773b835b
plugins/webpage/webpage/libs/email/message.py
python
MIMEPart.iter_parts
(self)
Return an iterator over all immediate subparts of a multipart. Return an empty iterator for a non-multipart.
Return an iterator over all immediate subparts of a multipart.
[ "Return", "an", "iterator", "over", "all", "immediate", "subparts", "of", "a", "multipart", "." ]
def iter_parts(self): """Return an iterator over all immediate subparts of a multipart. Return an empty iterator for a non-multipart. """ if self.get_content_maintype() == 'multipart': yield from self.get_payload()
[ "def", "iter_parts", "(", "self", ")", ":", "if", "self", ".", "get_content_maintype", "(", ")", "==", "'multipart'", ":", "yield", "from", "self", ".", "get_payload", "(", ")" ]
https://github.com/Jenyay/outwiker/blob/50530cf7b3f71480bb075b2829bc0669773b835b/plugins/webpage/webpage/libs/email/message.py#L1076-L1082
pyroscope/pyrocore
e8ededb6d9f3702ede6cd5396e6b473915637b64
src/pyrocore/torrent/formatting.py
python
format_item
(format_spec, item, defaults=None)
Format an item according to the given output format. The format can be gioven as either an interpolation string, or a Tempita template (which has to start with "E{lb}E{lb}"), @param format_spec: The output format. @param item: The object, which is automatically wrapped for interpolation...
Format an item according to the given output format. The format can be gioven as either an interpolation string, or a Tempita template (which has to start with "E{lb}E{lb}"),
[ "Format", "an", "item", "according", "to", "the", "given", "output", "format", ".", "The", "format", "can", "be", "gioven", "as", "either", "an", "interpolation", "string", "or", "a", "Tempita", "template", "(", "which", "has", "to", "start", "with", "E", ...
def format_item(format_spec, item, defaults=None): """ Format an item according to the given output format. The format can be gioven as either an interpolation string, or a Tempita template (which has to start with "E{lb}E{lb}"), @param format_spec: The output format. @param item: T...
[ "def", "format_item", "(", "format_spec", ",", "item", ",", "defaults", "=", "None", ")", ":", "template_engine", "=", "getattr", "(", "format_spec", ",", "\"__engine__\"", ",", "None", ")", "# TODO: Make differences between engines transparent", "if", "template_engin...
https://github.com/pyroscope/pyrocore/blob/e8ededb6d9f3702ede6cd5396e6b473915637b64/src/pyrocore/torrent/formatting.py#L299-L338
caserec/CaseRecommender
779bc5dd91ff704ce60c0f3fafd07e2eba689dd7
caserec/utils/process_data.py
python
ReadFile.read
(self)
return dict_file
Method to read files and collect important information. :return: Dictionary with file information :rtype: dict
Method to read files and collect important information.
[ "Method", "to", "read", "files", "and", "collect", "important", "information", "." ]
def read(self): """ Method to read files and collect important information. :return: Dictionary with file information :rtype: dict """ list_users = set() list_items = set() list_feedback = [] dict_feedback = {} # To be filled as: {user_id: [it...
[ "def", "read", "(", "self", ")", ":", "list_users", "=", "set", "(", ")", "list_items", "=", "set", "(", ")", "list_feedback", "=", "[", "]", "dict_feedback", "=", "{", "}", "# To be filled as: {user_id: [item_id_1, item_id_2, ..., item_id_N]}", "items_unobserved", ...
https://github.com/caserec/CaseRecommender/blob/779bc5dd91ff704ce60c0f3fafd07e2eba689dd7/caserec/utils/process_data.py#L52-L120
marcomusy/vedo
246bb78a406c4f97fe6f7d2a4d460909c830de87
vedo/colors.py
python
colorMap
(value, name="jet", vmin=None, vmax=None)
Map a real value in range [vmin, vmax] to a (r,g,b) color scale. :param value: scalar value to transform into a color :type value: float, list :param name: color map name :type name: str, matplotlib.colors.LinearSegmentedColormap :return: (r,g,b) color, or a list of (r,g,b) colors. .. note:: ...
Map a real value in range [vmin, vmax] to a (r,g,b) color scale.
[ "Map", "a", "real", "value", "in", "range", "[", "vmin", "vmax", "]", "to", "a", "(", "r", "g", "b", ")", "color", "scale", "." ]
def colorMap(value, name="jet", vmin=None, vmax=None): """Map a real value in range [vmin, vmax] to a (r,g,b) color scale. :param value: scalar value to transform into a color :type value: float, list :param name: color map name :type name: str, matplotlib.colors.LinearSegmentedColormap :retur...
[ "def", "colorMap", "(", "value", ",", "name", "=", "\"jet\"", ",", "vmin", "=", "None", ",", "vmax", "=", "None", ")", ":", "cut", "=", "_isSequence", "(", "value", ")", "# to speed up later", "if", "cut", ":", "values", "=", "np", ".", "asarray", "(...
https://github.com/marcomusy/vedo/blob/246bb78a406c4f97fe6f7d2a4d460909c830de87/vedo/colors.py#L681-L761
riptano/ccm
ce612ea71587bf263ed513cb8f8d5dfcf7c8dadb
ccmlib/node.py
python
Node.load
(path, name, cluster)
Load a node from from the path on disk to the config files, the node name and the cluster the node is part of.
Load a node from from the path on disk to the config files, the node name and the cluster the node is part of.
[ "Load", "a", "node", "from", "from", "the", "path", "on", "disk", "to", "the", "config", "files", "the", "node", "name", "and", "the", "cluster", "the", "node", "is", "part", "of", "." ]
def load(path, name, cluster): """ Load a node from from the path on disk to the config files, the node name and the cluster the node is part of. """ node_path = os.path.join(path, name) filename = os.path.join(node_path, 'node.conf') with open(filename, 'r') as f...
[ "def", "load", "(", "path", ",", "name", ",", "cluster", ")", ":", "node_path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "name", ")", "filename", "=", "os", ".", "path", ".", "join", "(", "node_path", ",", "'node.conf'", ")", "with", ...
https://github.com/riptano/ccm/blob/ce612ea71587bf263ed513cb8f8d5dfcf7c8dadb/ccmlib/node.py#L170-L214
SteveDoyle2/pyNastran
eda651ac2d4883d95a34951f8a002ff94f642a1a
pyNastran/dev/bdf_vectorized/cards/vectorized_card.py
python
BaseMethods.object_attributes
(self, mode='public', keys_to_skip=None, filter_properties=False)
return object_attributes(self, mode=mode, keys_to_skip=keys_to_skip+my_keys_to_skip, filter_properties=filter_properties)
.. seealso:: `pyNastran.utils.object_attributes(...)`
.. seealso:: `pyNastran.utils.object_attributes(...)`
[ "..", "seealso", "::", "pyNastran", ".", "utils", ".", "object_attributes", "(", "...", ")" ]
def object_attributes(self, mode='public', keys_to_skip=None, filter_properties=False): """.. seealso:: `pyNastran.utils.object_attributes(...)`""" if keys_to_skip is None: keys_to_skip = [] my_keys_to_skip = [ ] return object_attributes(sel...
[ "def", "object_attributes", "(", "self", ",", "mode", "=", "'public'", ",", "keys_to_skip", "=", "None", ",", "filter_properties", "=", "False", ")", ":", "if", "keys_to_skip", "is", "None", ":", "keys_to_skip", "=", "[", "]", "my_keys_to_skip", "=", "[", ...
https://github.com/SteveDoyle2/pyNastran/blob/eda651ac2d4883d95a34951f8a002ff94f642a1a/pyNastran/dev/bdf_vectorized/cards/vectorized_card.py#L10-L19
tobegit3hub/deep_image_model
8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e
java_predict_client/src/main/proto/tensorflow/contrib/learn/python/learn/monitors.py
python
GraphDump.compare
(self, other_dump, step, atol=1e-06)
return matched, non_matched
Compares two `GraphDump` monitors and returns differences. Args: other_dump: Another `GraphDump` monitor. step: `int`, step to compare on. atol: `float`, absolute tolerance in comparison of floating arrays. Returns: Returns tuple: matched: `list` of keys that matched. n...
Compares two `GraphDump` monitors and returns differences.
[ "Compares", "two", "GraphDump", "monitors", "and", "returns", "differences", "." ]
def compare(self, other_dump, step, atol=1e-06): """Compares two `GraphDump` monitors and returns differences. Args: other_dump: Another `GraphDump` monitor. step: `int`, step to compare on. atol: `float`, absolute tolerance in comparison of floating arrays. Returns: Returns tuple:...
[ "def", "compare", "(", "self", ",", "other_dump", ",", "step", ",", "atol", "=", "1e-06", ")", ":", "non_matched", "=", "{", "}", "matched", "=", "[", "]", "this_output", "=", "self", ".", "data", "[", "step", "]", "if", "step", "in", "self", ".", ...
https://github.com/tobegit3hub/deep_image_model/blob/8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e/java_predict_client/src/main/proto/tensorflow/contrib/learn/python/learn/monitors.py#L860-L899
cszn/USRNet
d8d64ebfd29eb343dfcf9095a3565135cb20f9d8
utils/utils_image.py
python
bgr2ycbcr
(img, only_y=True)
return rlt.astype(in_img_type)
bgr version of rgb2ycbcr only_y: only return Y channel Input: uint8, [0, 255] float, [0, 1]
bgr version of rgb2ycbcr only_y: only return Y channel Input: uint8, [0, 255] float, [0, 1]
[ "bgr", "version", "of", "rgb2ycbcr", "only_y", ":", "only", "return", "Y", "channel", "Input", ":", "uint8", "[", "0", "255", "]", "float", "[", "0", "1", "]" ]
def bgr2ycbcr(img, only_y=True): '''bgr version of rgb2ycbcr only_y: only return Y channel Input: uint8, [0, 255] float, [0, 1] ''' in_img_type = img.dtype img.astype(np.float32) if in_img_type != np.uint8: img *= 255. # convert if only_y: rlt = np.dot...
[ "def", "bgr2ycbcr", "(", "img", ",", "only_y", "=", "True", ")", ":", "in_img_type", "=", "img", ".", "dtype", "img", ".", "astype", "(", "np", ".", "float32", ")", "if", "in_img_type", "!=", "np", ".", "uint8", ":", "img", "*=", "255.", "# convert",...
https://github.com/cszn/USRNet/blob/d8d64ebfd29eb343dfcf9095a3565135cb20f9d8/utils/utils_image.py#L440-L461
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/full/distutils/ccompiler.py
python
CCompiler.spawn
(self, cmd)
[]
def spawn(self, cmd): spawn(cmd, dry_run=self.dry_run)
[ "def", "spawn", "(", "self", ",", "cmd", ")", ":", "spawn", "(", "cmd", ",", "dry_run", "=", "self", ".", "dry_run", ")" ]
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/distutils/ccompiler.py#L909-L910
SeldonIO/alibi
ce961caf995d22648a8338857822c90428af4765
alibi/explainers/backends/tensorflow/cfrl_base.py
python
TfCounterfactualRLDataset.__init__
(self, X: np.ndarray, preprocessor: Callable, predictor: Callable, conditional_func: Callable, batch_size: int, shuffle: bool = True)
Constructor. Parameters ---------- X Array of input instances. The input should NOT be preprocessed as it will be preprocessed when calling the `preprocessor` function. preprocessor Preprocessor function. This function correspond to the preprocessing ...
Constructor.
[ "Constructor", "." ]
def __init__(self, X: np.ndarray, preprocessor: Callable, predictor: Callable, conditional_func: Callable, batch_size: int, shuffle: bool = True) -> None: """ Constructor. Parameters --...
[ "def", "__init__", "(", "self", ",", "X", ":", "np", ".", "ndarray", ",", "preprocessor", ":", "Callable", ",", "predictor", ":", "Callable", ",", "conditional_func", ":", "Callable", ",", "batch_size", ":", "int", ",", "shuffle", ":", "bool", "=", "True...
https://github.com/SeldonIO/alibi/blob/ce961caf995d22648a8338857822c90428af4765/alibi/explainers/backends/tensorflow/cfrl_base.py#L23-L78
FanhuaandLuomu/BiLstm_CNN_CRF_CWS
0d1c2f93a0d8c1db5d6617379770f3e269fe7c8a
fenci_server.py
python
word_seg_by_sentences
(text)
return pred_text_all,pred_label_all
# 长度1001切分 不好 如:中国人|寿 count=math.ceil(len(text)/100) text_list=[] text_list2=[] for i in range(count): # text_list.append(text[i*100:(i+1)*100]) tmp=text[i*100:(i+1)*100] tmp2=[] for c in tmp: tmp2.append(lexicon.get(c,len(lexicon)+1)) text_list.append(tmp) text_list2.append(tmp2)
# 长度1001切分 不好 如:中国人|寿 count=math.ceil(len(text)/100) text_list=[] text_list2=[] for i in range(count): # text_list.append(text[i*100:(i+1)*100]) tmp=text[i*100:(i+1)*100] tmp2=[] for c in tmp: tmp2.append(lexicon.get(c,len(lexicon)+1)) text_list.append(tmp) text_list2.append(tmp2)
[ "#", "长度1001切分", "不好", "如:中国人|寿", "count", "=", "math", ".", "ceil", "(", "len", "(", "text", ")", "/", "100", ")", "text_list", "=", "[]", "text_list2", "=", "[]", "for", "i", "in", "range", "(", "count", ")", ":", "#", "text_list", ".", "append",...
def word_seg_by_sentences(text): ''' # 长度1001切分 不好 如:中国人|寿 count=math.ceil(len(text)/100) text_list=[] text_list2=[] for i in range(count): # text_list.append(text[i*100:(i+1)*100]) tmp=text[i*100:(i+1)*100] tmp2=[] for c in tmp: tmp2.append(lexicon.get(c,len(lexicon)+1)) text_list.append(tmp) text...
[ "def", "word_seg_by_sentences", "(", "text", ")", ":", "text_list", "=", "[", "]", "text_list2", "=", "[", "]", "i", "=", "0", "for", "j", "in", "range", "(", "len", "(", "text", ")", ")", ":", "if", "text", "[", "j", "]", "in", "[", "',','", "...
https://github.com/FanhuaandLuomu/BiLstm_CNN_CRF_CWS/blob/0d1c2f93a0d8c1db5d6617379770f3e269fe7c8a/fenci_server.py#L335-L387
openstack/cinder
23494a6d6c51451688191e1847a458f1d3cdcaa5
cinder/api/urlmap.py
python
URLMap._path_strategy
(self, host, port, path_info)
return mime_type, app, app_url
Check path suffix for MIME type and path prefix for API version.
Check path suffix for MIME type and path prefix for API version.
[ "Check", "path", "suffix", "for", "MIME", "type", "and", "path", "prefix", "for", "API", "version", "." ]
def _path_strategy(self, host, port, path_info): """Check path suffix for MIME type and path prefix for API version.""" mime_type = app = app_url = None parts = path_info.rsplit('.', 1) if len(parts) > 1: possible_type = 'application/' + parts[1] if possible_type...
[ "def", "_path_strategy", "(", "self", ",", "host", ",", "port", ",", "path_info", ")", ":", "mime_type", "=", "app", "=", "app_url", "=", "None", "parts", "=", "path_info", ".", "rsplit", "(", "'.'", ",", "1", ")", "if", "len", "(", "parts", ")", "...
https://github.com/openstack/cinder/blob/23494a6d6c51451688191e1847a458f1d3cdcaa5/cinder/api/urlmap.py#L197-L215
google/grr
8ad8a4d2c5a93c92729206b7771af19d92d4f915
grr/core/grr_response_core/lib/config_parser.py
python
GRRConfigParser.config_path
(self)
return self._config_path
[]
def config_path(self) -> str: return self._config_path
[ "def", "config_path", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_config_path" ]
https://github.com/google/grr/blob/8ad8a4d2c5a93c92729206b7771af19d92d4f915/grr/core/grr_response_core/lib/config_parser.py#L51-L52
jiangxinyang227/bert-for-task
3e7aed9e3c757ebc22aabfd4f3fb7b4cd81b010a
bert_task/bert/run_classifier.py
python
InputExample.__init__
(self, guid, text_a, text_b=None, label=None)
Constructs a InputExample. Args: guid: Unique id for the example. text_a: string. The untokenized text of the first sequence. For single sequence tasks, only this sequence must be specified. text_b: (Optional) string. The untokenized text of the second sequence. Only must be speci...
Constructs a InputExample.
[ "Constructs", "a", "InputExample", "." ]
def __init__(self, guid, text_a, text_b=None, label=None): """Constructs a InputExample. Args: guid: Unique id for the example. text_a: string. The untokenized text of the first sequence. For single sequence tasks, only this sequence must be specified. text_b: (Optional) string. The u...
[ "def", "__init__", "(", "self", ",", "guid", ",", "text_a", ",", "text_b", "=", "None", ",", "label", "=", "None", ")", ":", "self", ".", "guid", "=", "guid", "self", ".", "text_a", "=", "text_a", "self", ".", "text_b", "=", "text_b", "self", ".", ...
https://github.com/jiangxinyang227/bert-for-task/blob/3e7aed9e3c757ebc22aabfd4f3fb7b4cd81b010a/bert_task/bert/run_classifier.py#L130-L145
jhorey/ferry
bbaa047df08386e17130a939e20fde5e840d1ffa
ferry/config/openmpi/mpiclientconfig.py
python
OpenMPIClientInitializer.get_working_ports
(self, num_instances)
return self.mpi.get_working_ports(num_instances)
Ports necessary to get things working.
Ports necessary to get things working.
[ "Ports", "necessary", "to", "get", "things", "working", "." ]
def get_working_ports(self, num_instances): """ Ports necessary to get things working. """ return self.mpi.get_working_ports(num_instances)
[ "def", "get_working_ports", "(", "self", ",", "num_instances", ")", ":", "return", "self", ".", "mpi", ".", "get_working_ports", "(", "num_instances", ")" ]
https://github.com/jhorey/ferry/blob/bbaa047df08386e17130a939e20fde5e840d1ffa/ferry/config/openmpi/mpiclientconfig.py#L67-L71
ytisf/PyExfil
0297b46dcbb135b2e2ade07ee040557a31cef04c
pyexfil/network/ICMP/icmp_exfiltration.py
python
init_listener
(ip_addr, saving_location=".")
init_listener will start a listener for incoming ICMP packets on a specified ip_addr to receive the packets. It will then save a log file and the incoming information to the given path. If none given it will generate one itself. :param ip_addr: The local IP address to bind the listener to. :return: Nothing.
init_listener will start a listener for incoming ICMP packets on a specified ip_addr to receive the packets. It will then save a log file and the incoming information to the given path.
[ "init_listener", "will", "start", "a", "listener", "for", "incoming", "ICMP", "packets", "on", "a", "specified", "ip_addr", "to", "receive", "the", "packets", ".", "It", "will", "then", "save", "a", "log", "file", "and", "the", "incoming", "information", "to...
def init_listener(ip_addr, saving_location="."): """ init_listener will start a listener for incoming ICMP packets on a specified ip_addr to receive the packets. It will then save a log file and the incoming information to the given path. If none given it will generate one itself. :param ip_addr: The local IP ad...
[ "def", "init_listener", "(", "ip_addr", ",", "saving_location", "=", "\".\"", ")", ":", "# Trying to open raw ICMP socket.", "# If fails, you're probably just not root", "try", ":", "sock", "=", "socket", "(", "AF_INET", ",", "SOCK_RAW", ",", "IPPROTO_ICMP", ")", "soc...
https://github.com/ytisf/PyExfil/blob/0297b46dcbb135b2e2ade07ee040557a31cef04c/pyexfil/network/ICMP/icmp_exfiltration.py#L122-L219
maartenbreddels/ipyvolume
71eded3085ed5f00a961c90db8b84fde13a6dee3
ipyvolume/pylab.py
python
plot_trisurf
( x, y, z, triangles=None, lines=None, color=default_color, u=None, v=None, texture=None, cast_shadow=True, receive_shadow=True, description=None, **kwargs)
return mesh
Draw a polygon/triangle mesh defined by a coordinate and triangle indices. The following example plots a rectangle in the z==2 plane, consisting of 2 triangles: >>> plot_trisurf([0, 0, 3., 3.], [0, 4., 0, 4.], 2, triangles=[[0, 2, 3], [0, 3, 1]]) Note that the z value is constant, and thus not...
Draw a polygon/triangle mesh defined by a coordinate and triangle indices.
[ "Draw", "a", "polygon", "/", "triangle", "mesh", "defined", "by", "a", "coordinate", "and", "triangle", "indices", "." ]
def plot_trisurf( x, y, z, triangles=None, lines=None, color=default_color, u=None, v=None, texture=None, cast_shadow=True, receive_shadow=True, description=None, **kwargs): """Draw a polygon/triangle mesh define...
[ "def", "plot_trisurf", "(", "x", ",", "y", ",", "z", ",", "triangles", "=", "None", ",", "lines", "=", "None", ",", "color", "=", "default_color", ",", "u", "=", "None", ",", "v", "=", "None", ",", "texture", "=", "None", ",", "cast_shadow", "=", ...
https://github.com/maartenbreddels/ipyvolume/blob/71eded3085ed5f00a961c90db8b84fde13a6dee3/ipyvolume/pylab.py#L449-L522
JiYou/openstack
8607dd488bde0905044b303eb6e52bdea6806923
packages/source/cinder/cinder/openstack/common/rpc/impl_qpid.py
python
call
(conf, context, topic, msg, timeout=None)
return rpc_amqp.call( conf, context, topic, msg, timeout, rpc_amqp.get_connection_pool(conf, Connection))
Sends a message on a topic and wait for a response.
Sends a message on a topic and wait for a response.
[ "Sends", "a", "message", "on", "a", "topic", "and", "wait", "for", "a", "response", "." ]
def call(conf, context, topic, msg, timeout=None): """Sends a message on a topic and wait for a response.""" return rpc_amqp.call( conf, context, topic, msg, timeout, rpc_amqp.get_connection_pool(conf, Connection))
[ "def", "call", "(", "conf", ",", "context", ",", "topic", ",", "msg", ",", "timeout", "=", "None", ")", ":", "return", "rpc_amqp", ".", "call", "(", "conf", ",", "context", ",", "topic", ",", "msg", ",", "timeout", ",", "rpc_amqp", ".", "get_connecti...
https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/cinder/cinder/openstack/common/rpc/impl_qpid.py#L606-L610
GoogleCloudPlatform/professional-services
0c707aa97437f3d154035ef8548109b7882f71da
tools/ml-auto-eda/ml_eda/analysis/qualitative_analysis.py
python
QualitativeAnalysis.run_categorical_numerical_descriptive
( self )
return analyses
Running for descriptive analysis involving categorical and numerical attributes
Running for descriptive analysis involving categorical and numerical attributes
[ "Running", "for", "descriptive", "analysis", "involving", "categorical", "and", "numerical", "attributes" ]
def run_categorical_numerical_descriptive( self ) -> Iterator[analysis_entity_pb2.Analysis]: """Running for descriptive analysis involving categorical and numerical attributes""" categorical_features = self._data_def.low_card_categorical_attributes numerical_features = self._data_def.numerical_a...
[ "def", "run_categorical_numerical_descriptive", "(", "self", ")", "->", "Iterator", "[", "analysis_entity_pb2", ".", "Analysis", "]", ":", "categorical_features", "=", "self", ".", "_data_def", ".", "low_card_categorical_attributes", "numerical_features", "=", "self", "...
https://github.com/GoogleCloudPlatform/professional-services/blob/0c707aa97437f3d154035ef8548109b7882f71da/tools/ml-auto-eda/ml_eda/analysis/qualitative_analysis.py#L162-L175
AppScale/gts
46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9
AppServer/lib/mox/mox.py
python
Mox.CreateMockAnything
(self, description=None)
return new_mock
Create a mock that will accept any method calls. This does not enforce an interface. Args: description: str. Optionally, a descriptive name for the mock object being created, for debugging output purposes.
Create a mock that will accept any method calls.
[ "Create", "a", "mock", "that", "will", "accept", "any", "method", "calls", "." ]
def CreateMockAnything(self, description=None): """Create a mock that will accept any method calls. This does not enforce an interface. Args: description: str. Optionally, a descriptive name for the mock object being created, for debugging output purposes. """ new_mock = MockAnything...
[ "def", "CreateMockAnything", "(", "self", ",", "description", "=", "None", ")", ":", "new_mock", "=", "MockAnything", "(", "description", "=", "description", ")", "self", ".", "_mock_objects", ".", "append", "(", "new_mock", ")", "return", "new_mock" ]
https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/mox/mox.py#L260-L271
planetlabs/planet-client-python
6aa31e873ef40e73c2c49981f6065d05bfc7b56d
planet/api/models.py
python
Response.wait
(self)
return self._body
Await completion of this request. :returns Body: A Body object containing the response.
Await completion of this request.
[ "Await", "completion", "of", "this", "request", "." ]
def wait(self): '''Await completion of this request. :returns Body: A Body object containing the response. ''' if self._future: self._future.result() return self._body
[ "def", "wait", "(", "self", ")", ":", "if", "self", ".", "_future", ":", "self", ".", "_future", ".", "result", "(", ")", "return", "self", ".", "_body" ]
https://github.com/planetlabs/planet-client-python/blob/6aa31e873ef40e73c2c49981f6065d05bfc7b56d/planet/api/models.py#L66-L73
omz/PythonistaAppTemplate
f560f93f8876d82a21d108977f90583df08d55af
PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/matplotlib/offsetbox.py
python
AnchoredOffsetbox.draw
(self, renderer)
draw the artist
draw the artist
[ "draw", "the", "artist" ]
def draw(self, renderer): "draw the artist" if not self.get_visible(): return fontsize = renderer.points_to_pixels(self.prop.get_size_in_points()) self._update_offset_func(renderer, fontsize) if self._drawFrame: # update the location and size of the leg...
[ "def", "draw", "(", "self", ",", "renderer", ")", ":", "if", "not", "self", ".", "get_visible", "(", ")", ":", "return", "fontsize", "=", "renderer", ".", "points_to_pixels", "(", "self", ".", "prop", ".", "get_size_in_points", "(", ")", ")", "self", "...
https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/matplotlib/offsetbox.py#L1037-L1057
stellargraph/stellargraph
3c2c8c18ab4c5c16660f350d8e23d7dc39e738de
stellargraph/core/graph.py
python
StellarGraph.in_nodes
( self, node: Any, include_edge_weight=False, edge_types=None, use_ilocs=False )
return self._to_neighbors(neigh_arrs, include_edge_weight)
Obtains the collection of neighbouring nodes with edges directed to the given node. For an undirected graph, neighbours are treated as both in-nodes and out-nodes. Args: node (any): The node in question. include_edge_weight (bool, default False): If True, each neighbour ...
Obtains the collection of neighbouring nodes with edges directed to the given node. For an undirected graph, neighbours are treated as both in-nodes and out-nodes.
[ "Obtains", "the", "collection", "of", "neighbouring", "nodes", "with", "edges", "directed", "to", "the", "given", "node", ".", "For", "an", "undirected", "graph", "neighbours", "are", "treated", "as", "both", "in", "-", "nodes", "and", "out", "-", "nodes", ...
def in_nodes( self, node: Any, include_edge_weight=False, edge_types=None, use_ilocs=False ) -> Iterable[Any]: """ Obtains the collection of neighbouring nodes with edges directed to the given node. For an undirected graph, neighbours are treated as both in-nodes and out-node...
[ "def", "in_nodes", "(", "self", ",", "node", ":", "Any", ",", "include_edge_weight", "=", "False", ",", "edge_types", "=", "None", ",", "use_ilocs", "=", "False", ")", "->", "Iterable", "[", "Any", "]", ":", "neigh_arrs", "=", "self", ".", "in_node_array...
https://github.com/stellargraph/stellargraph/blob/3c2c8c18ab4c5c16660f350d8e23d7dc39e738de/stellargraph/core/graph.py#L865-L889
SimplySecurity/SimplyEmail
6a42d373a13b258e90d61efc82c527c5b754a9b8
Common/TaskController.py
python
Conducter._task_queue_start
(self)
Private function to start task queue. Allows for better debug.
Private function to start task queue. Allows for better debug.
[ "Private", "function", "to", "start", "task", "queue", ".", "Allows", "for", "better", "debug", "." ]
def _task_queue_start(self): """ Private function to start task queue. Allows for better debug. """ self.logger.debug("_task_queue_start: starting task queue") try: Task_queue = multiprocessing.Queue() return Task_queue except: ...
[ "def", "_task_queue_start", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"_task_queue_start: starting task queue\"", ")", "try", ":", "Task_queue", "=", "multiprocessing", ".", "Queue", "(", ")", "return", "Task_queue", "except", ":", "self...
https://github.com/SimplySecurity/SimplyEmail/blob/6a42d373a13b258e90d61efc82c527c5b754a9b8/Common/TaskController.py#L348-L358
QuarkChain/pyquarkchain
af1dd06a50d918aaf45569d9b0f54f5ecceb6afe
quarkchain/cluster/jsonrpc.py
python
JSONRPCHttpServer.setMining
(self, mining)
return await self.master.set_mining(mining)
Turn on / off mining
Turn on / off mining
[ "Turn", "on", "/", "off", "mining" ]
async def setMining(self, mining): """Turn on / off mining""" return await self.master.set_mining(mining)
[ "async", "def", "setMining", "(", "self", ",", "mining", ")", ":", "return", "await", "self", ".", "master", ".", "set_mining", "(", "mining", ")" ]
https://github.com/QuarkChain/pyquarkchain/blob/af1dd06a50d918aaf45569d9b0f54f5ecceb6afe/quarkchain/cluster/jsonrpc.py#L1315-L1317
yzhao062/pyod
13b0cd5f50d5ea5c5321da88c46232ae6f24dff7
pyod/models/vae.py
python
VAE._build_model
(self)
return vae
Build VAE = encoder + decoder + vae_loss
Build VAE = encoder + decoder + vae_loss
[ "Build", "VAE", "=", "encoder", "+", "decoder", "+", "vae_loss" ]
def _build_model(self): """Build VAE = encoder + decoder + vae_loss""" # Build Encoder inputs = Input(shape=(self.n_features_,)) # Input layer layer = Dense(self.n_features_, activation=self.hidden_activation)( inputs) # Hidden layers for neurons in s...
[ "def", "_build_model", "(", "self", ")", ":", "# Build Encoder", "inputs", "=", "Input", "(", "shape", "=", "(", "self", ".", "n_features_", ",", ")", ")", "# Input layer", "layer", "=", "Dense", "(", "self", ".", "n_features_", ",", "activation", "=", "...
https://github.com/yzhao062/pyod/blob/13b0cd5f50d5ea5c5321da88c46232ae6f24dff7/pyod/models/vae.py#L254-L303
hsokooti/RegNet
28a8b6132677bb58e9fc811c0dd15d78913c7e86
functions/landmarks_utils/landmarks_utils.py
python
tre_from_dvf
(landmarks, exp_list=None)
return landmarks
:param landmarks: :param exp_list: :return:
:param landmarks: :param exp_list: :return:
[ ":", "param", "landmarks", ":", ":", "param", "exp_list", ":", ":", "return", ":" ]
def tre_from_dvf(landmarks, exp_list=None): """ :param landmarks: :param exp_list: :return: """ for exp in exp_list: landmarks[exp]['Error'] = np.array([landmarks[exp]['MovingLandmarksWorld'][i, :] - landmarks[exp]['FixedAfterAffineLandmarksWor...
[ "def", "tre_from_dvf", "(", "landmarks", ",", "exp_list", "=", "None", ")", ":", "for", "exp", "in", "exp_list", ":", "landmarks", "[", "exp", "]", "[", "'Error'", "]", "=", "np", ".", "array", "(", "[", "landmarks", "[", "exp", "]", "[", "'MovingLan...
https://github.com/hsokooti/RegNet/blob/28a8b6132677bb58e9fc811c0dd15d78913c7e86/functions/landmarks_utils/landmarks_utils.py#L876-L889
google/trax
d6cae2067dedd0490b78d831033607357e975015
trax/tf_numpy/numpy_impl/math_ops.py
python
divmod
(x1, x2)
return floor_divide(x1, x2), mod(x1, x2)
[]
def divmod(x1, x2): return floor_divide(x1, x2), mod(x1, x2)
[ "def", "divmod", "(", "x1", ",", "x2", ")", ":", "return", "floor_divide", "(", "x1", ",", "x2", ")", ",", "mod", "(", "x1", ",", "x2", ")" ]
https://github.com/google/trax/blob/d6cae2067dedd0490b78d831033607357e975015/trax/tf_numpy/numpy_impl/math_ops.py#L129-L130
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/tke/v20180525/models.py
python
ClusterVersion.__init__
(self)
r""" :param ClusterId: 集群ID :type ClusterId: str :param Versions: 集群主版本号列表,例如1.18.4 :type Versions: list of str
r""" :param ClusterId: 集群ID :type ClusterId: str :param Versions: 集群主版本号列表,例如1.18.4 :type Versions: list of str
[ "r", ":", "param", "ClusterId", ":", "集群ID", ":", "type", "ClusterId", ":", "str", ":", "param", "Versions", ":", "集群主版本号列表,例如1", ".", "18", ".", "4", ":", "type", "Versions", ":", "list", "of", "str" ]
def __init__(self): r""" :param ClusterId: 集群ID :type ClusterId: str :param Versions: 集群主版本号列表,例如1.18.4 :type Versions: list of str """ self.ClusterId = None self.Versions = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "ClusterId", "=", "None", "self", ".", "Versions", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/tke/v20180525/models.py#L1255-L1263
mrkipling/maraschino
c6be9286937783ae01df2d6d8cebfc8b2734a7d7
lib/sqlalchemy/orm/events.py
python
MapperEvents.after_delete
(self, mapper, connection, target)
Receive an object instance after a DELETE statement has been emitted corresponding to that instance. This event is used to emit additional SQL statements on the given connection as well as to perform application specific bookkeeping related to a deletion event. The event is of...
Receive an object instance after a DELETE statement has been emitted corresponding to that instance.
[ "Receive", "an", "object", "instance", "after", "a", "DELETE", "statement", "has", "been", "emitted", "corresponding", "to", "that", "instance", "." ]
def after_delete(self, mapper, connection, target): """Receive an object instance after a DELETE statement has been emitted corresponding to that instance. This event is used to emit additional SQL statements on the given connection as well as to perform application specific bo...
[ "def", "after_delete", "(", "self", ",", "mapper", ",", "connection", ",", "target", ")", ":" ]
https://github.com/mrkipling/maraschino/blob/c6be9286937783ae01df2d6d8cebfc8b2734a7d7/lib/sqlalchemy/orm/events.py#L765-L797
explosion/srsly
8617ecc099d1f34a60117b5287bef5424ea2c837
srsly/msgpack/util.py
python
ensure_bytes
(string)
Ensure a string is returned as a bytes object, encoded as utf8.
Ensure a string is returned as a bytes object, encoded as utf8.
[ "Ensure", "a", "string", "is", "returned", "as", "a", "bytes", "object", "encoded", "as", "utf8", "." ]
def ensure_bytes(string): """Ensure a string is returned as a bytes object, encoded as utf8.""" if isinstance(string, unicode): return string.encode("utf8") else: return string
[ "def", "ensure_bytes", "(", "string", ")", ":", "if", "isinstance", "(", "string", ",", "unicode", ")", ":", "return", "string", ".", "encode", "(", "\"utf8\"", ")", "else", ":", "return", "string" ]
https://github.com/explosion/srsly/blob/8617ecc099d1f34a60117b5287bef5424ea2c837/srsly/msgpack/util.py#L9-L14
modin-project/modin
0d9d14e6669be3dd6bb3b72222dbe6a6dffe1bee
modin/experimental/cloud/cluster.py
python
BaseCluster._get_connection_details
(self)
Gets the coordinates on how to connect to cluster frontend node.
Gets the coordinates on how to connect to cluster frontend node.
[ "Gets", "the", "coordinates", "on", "how", "to", "connect", "to", "cluster", "frontend", "node", "." ]
def _get_connection_details(self) -> ConnectionDetails: """ Gets the coordinates on how to connect to cluster frontend node. """ raise NotImplementedError()
[ "def", "_get_connection_details", "(", "self", ")", "->", "ConnectionDetails", ":", "raise", "NotImplementedError", "(", ")" ]
https://github.com/modin-project/modin/blob/0d9d14e6669be3dd6bb3b72222dbe6a6dffe1bee/modin/experimental/cloud/cluster.py#L179-L183
mozillazg/pypy
2ff5cd960c075c991389f842c6d59e71cf0cb7d0
lib-python/2.7/plat-mac/aetools.py
python
enumsubst
(arguments, key, edict)
Substitute a single enum keyword argument, if it occurs
Substitute a single enum keyword argument, if it occurs
[ "Substitute", "a", "single", "enum", "keyword", "argument", "if", "it", "occurs" ]
def enumsubst(arguments, key, edict): """Substitute a single enum keyword argument, if it occurs""" if key not in arguments or edict is None: return v = arguments[key] ok = edict.values() if v in edict: arguments[key] = Enum(edict[v]) elif not v in ok: raise TypeError, 'U...
[ "def", "enumsubst", "(", "arguments", ",", "key", ",", "edict", ")", ":", "if", "key", "not", "in", "arguments", "or", "edict", "is", "None", ":", "return", "v", "=", "arguments", "[", "key", "]", "ok", "=", "edict", ".", "values", "(", ")", "if", ...
https://github.com/mozillazg/pypy/blob/2ff5cd960c075c991389f842c6d59e71cf0cb7d0/lib-python/2.7/plat-mac/aetools.py#L120-L129
edisonlz/fastor
342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3
base/site-packages/django/contrib/syndication/views.py
python
Feed.item_extra_kwargs
(self, item)
return {}
Returns an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator.
Returns an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator.
[ "Returns", "an", "extra", "keyword", "arguments", "dictionary", "that", "is", "used", "with", "the", "add_item", "call", "of", "the", "feed", "generator", "." ]
def item_extra_kwargs(self, item): """ Returns an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator. """ return {}
[ "def", "item_extra_kwargs", "(", "self", ",", "item", ")", ":", "return", "{", "}" ]
https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/django/contrib/syndication/views.py#L93-L98
deepset-ai/haystack
79fdda8a7cf393d774803608a4874f2a6e63cf6f
haystack/modeling/data_handler/samples.py
python
Sample.__init__
(self, id: str, clear_text: dict, tokenized: Optional[dict] = None, features: Optional[dict] = None)
:param id: The unique id of the sample :param clear_text: A dictionary containing various human readable fields (e.g. text, label). :param tokenized: A dictionary containing the tokenized version of clear text plus helpful meta data: offsets (start position of each token in the original text) and start_...
:param id: The unique id of the sample :param clear_text: A dictionary containing various human readable fields (e.g. text, label). :param tokenized: A dictionary containing the tokenized version of clear text plus helpful meta data: offsets (start position of each token in the original text) and start_...
[ ":", "param", "id", ":", "The", "unique", "id", "of", "the", "sample", ":", "param", "clear_text", ":", "A", "dictionary", "containing", "various", "human", "readable", "fields", "(", "e", ".", "g", ".", "text", "label", ")", ".", ":", "param", "tokeni...
def __init__(self, id: str, clear_text: dict, tokenized: Optional[dict] = None, features: Optional[dict] = None): """ :param id: The unique id of the sample :param clear_text: A dictionary containing various human readable fields (e.g. text, label). :param tokenized: A dictionary contain...
[ "def", "__init__", "(", "self", ",", "id", ":", "str", ",", "clear_text", ":", "dict", ",", "tokenized", ":", "Optional", "[", "dict", "]", "=", "None", ",", "features", ":", "Optional", "[", "dict", "]", "=", "None", ")", ":", "self", ".", "id", ...
https://github.com/deepset-ai/haystack/blob/79fdda8a7cf393d774803608a4874f2a6e63cf6f/haystack/modeling/data_handler/samples.py#L16-L26
ipython/ipyparallel
d35d4fb9501da5b3280b11e83ed633a95f17be1d
ipyparallel/client/client.py
python
Client.send_execute_request
( self, socket, code, silent=True, metadata=None, ident=None, message_future_hook=None, )
return future
construct and send an execute request via a socket.
construct and send an execute request via a socket.
[ "construct", "and", "send", "an", "execute", "request", "via", "a", "socket", "." ]
def send_execute_request( self, socket, code, silent=True, metadata=None, ident=None, message_future_hook=None, ): """construct and send an execute request via a socket.""" if self._closed: raise RuntimeError( "Clie...
[ "def", "send_execute_request", "(", "self", ",", "socket", ",", "code", ",", "silent", "=", "True", ",", "metadata", "=", "None", ",", "ident", "=", "None", ",", "message_future_hook", "=", "None", ",", ")", ":", "if", "self", ".", "_closed", ":", "rai...
https://github.com/ipython/ipyparallel/blob/d35d4fb9501da5b3280b11e83ed633a95f17be1d/ipyparallel/client/client.py#L1976-L2013
Ciphey/Ciphey
4e5cc80a3cfdd5361ddb2d99322ed9b3ba54dc90
noxfile.py
python
coverage
(session: Session)
Upload coverage data.
Upload coverage data.
[ "Upload", "coverage", "data", "." ]
def coverage(session: Session) -> None: """Upload coverage data.""" install_with_constraints(session, "coverage[toml]", "codecov") session.run("pip3", "install", "cipheydists") session.run("coverage", "xml", "--fail-under=0") session.run("codecov", *session.posargs)
[ "def", "coverage", "(", "session", ":", "Session", ")", "->", "None", ":", "install_with_constraints", "(", "session", ",", "\"coverage[toml]\"", ",", "\"codecov\"", ")", "session", ".", "run", "(", "\"pip3\"", ",", "\"install\"", ",", "\"cipheydists\"", ")", ...
https://github.com/Ciphey/Ciphey/blob/4e5cc80a3cfdd5361ddb2d99322ed9b3ba54dc90/noxfile.py#L47-L52
poljar/weechat-matrix
b88614e557399e8b3b623a3d29b2694acc019a44
matrix/config.py
python
WeechatConfig.read
(self)
return False
Read the config file
Read the config file
[ "Read", "the", "config", "file" ]
def read(self): """Read the config file""" return_code = W.config_read(self._ptr) if return_code == W.WEECHAT_CONFIG_READ_OK: return True if return_code == W.WEECHAT_CONFIG_READ_MEMORY_ERROR: return False if return_code == W.WEECHAT_CONFIG_READ_FILE_NOT_FO...
[ "def", "read", "(", "self", ")", ":", "return_code", "=", "W", ".", "config_read", "(", "self", ".", "_ptr", ")", "if", "return_code", "==", "W", ".", "WEECHAT_CONFIG_READ_OK", ":", "return", "True", "if", "return_code", "==", "W", ".", "WEECHAT_CONFIG_REA...
https://github.com/poljar/weechat-matrix/blob/b88614e557399e8b3b623a3d29b2694acc019a44/matrix/config.py#L314-L323
yuxiaokui/Intranet-Penetration
f57678a204840c83cbf3308e3470ae56c5ff514b
proxy/XX-Net/code/default/python27/1.0/lib/win32/gevent/ssl.py
python
SSLSocket.do_handshake
(self)
Perform a TLS/SSL handshake.
Perform a TLS/SSL handshake.
[ "Perform", "a", "TLS", "/", "SSL", "handshake", "." ]
def do_handshake(self): """Perform a TLS/SSL handshake.""" while True: try: return self._sslobj.do_handshake() except SSLError: ex = sys.exc_info()[1] if ex.args[0] == SSL_ERROR_WANT_READ: if self.timeout == 0.0:...
[ "def", "do_handshake", "(", "self", ")", ":", "while", "True", ":", "try", ":", "return", "self", ".", "_sslobj", ".", "do_handshake", "(", ")", "except", "SSLError", ":", "ex", "=", "sys", ".", "exc_info", "(", ")", "[", "1", "]", "if", "ex", ".",...
https://github.com/yuxiaokui/Intranet-Penetration/blob/f57678a204840c83cbf3308e3470ae56c5ff514b/proxy/XX-Net/code/default/python27/1.0/lib/win32/gevent/ssl.py#L301-L319
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/vms/v20200902/vms_client.py
python
VmsClient.SendCodeVoice
(self, request)
给用户发语音验证码(仅支持数字)。 :param request: Request instance for SendCodeVoice. :type request: :class:`tencentcloud.vms.v20200902.models.SendCodeVoiceRequest` :rtype: :class:`tencentcloud.vms.v20200902.models.SendCodeVoiceResponse`
给用户发语音验证码(仅支持数字)。
[ "给用户发语音验证码(仅支持数字)。" ]
def SendCodeVoice(self, request): """给用户发语音验证码(仅支持数字)。 :param request: Request instance for SendCodeVoice. :type request: :class:`tencentcloud.vms.v20200902.models.SendCodeVoiceRequest` :rtype: :class:`tencentcloud.vms.v20200902.models.SendCodeVoiceResponse` """ try: ...
[ "def", "SendCodeVoice", "(", "self", ",", "request", ")", ":", "try", ":", "params", "=", "request", ".", "_serialize", "(", ")", "body", "=", "self", ".", "call", "(", "\"SendCodeVoice\"", ",", "params", ")", "response", "=", "json", ".", "loads", "("...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/vms/v20200902/vms_client.py#L29-L54
VIDA-NYU/reprozip
67bbe8d2e22e0493ba0ccc78521729b49dd70a1d
reprounzip-docker/reprounzip/unpackers/docker.py
python
test_has_docker
(pack, **kwargs)
return COMPAT_MAYBE, "docker not found in PATH"
Compatibility test: has docker (ok) or not (maybe).
Compatibility test: has docker (ok) or not (maybe).
[ "Compatibility", "test", ":", "has", "docker", "(", "ok", ")", "or", "not", "(", "maybe", ")", "." ]
def test_has_docker(pack, **kwargs): """Compatibility test: has docker (ok) or not (maybe). """ pathlist = os.environ['PATH'].split(os.pathsep) + ['.'] pathexts = os.environ.get('PATHEXT', '').split(os.pathsep) for path in pathlist: for ext in pathexts: fullpath = os.path.join(pa...
[ "def", "test_has_docker", "(", "pack", ",", "*", "*", "kwargs", ")", ":", "pathlist", "=", "os", ".", "environ", "[", "'PATH'", "]", ".", "split", "(", "os", ".", "pathsep", ")", "+", "[", "'.'", "]", "pathexts", "=", "os", ".", "environ", ".", "...
https://github.com/VIDA-NYU/reprozip/blob/67bbe8d2e22e0493ba0ccc78521729b49dd70a1d/reprounzip-docker/reprounzip/unpackers/docker.py#L801-L811
PaddlePaddle/PaddleX
2bab73f81ab54e328204e7871e6ae4a82e719f5d
paddlex/ppdet/metrics/keypoint_metrics.py
python
KeyPointTopDownMPIIEval.evaluate
(self, outputs, savepath=None)
return name_value
Evaluate PCKh for MPII dataset. refer to https://github.com/leoxiaobin/deep-high-resolution-net.pytorch Copyright (c) Microsoft, under the MIT License. Args: outputs(list(preds, boxes)): * preds (np.ndarray[N,K,3]): The first two dimensions are coo...
Evaluate PCKh for MPII dataset. refer to https://github.com/leoxiaobin/deep-high-resolution-net.pytorch Copyright (c) Microsoft, under the MIT License.
[ "Evaluate", "PCKh", "for", "MPII", "dataset", ".", "refer", "to", "https", ":", "//", "github", ".", "com", "/", "leoxiaobin", "/", "deep", "-", "high", "-", "resolution", "-", "net", ".", "pytorch", "Copyright", "(", "c", ")", "Microsoft", "under", "t...
def evaluate(self, outputs, savepath=None): """Evaluate PCKh for MPII dataset. refer to https://github.com/leoxiaobin/deep-high-resolution-net.pytorch Copyright (c) Microsoft, under the MIT License. Args: outputs(list(preds, boxes)): * preds (np.ndarray[N,K,...
[ "def", "evaluate", "(", "self", ",", "outputs", ",", "savepath", "=", "None", ")", ":", "kpts", "=", "[", "]", "for", "output", "in", "outputs", ":", "preds", "=", "output", "[", "'preds'", "]", "batch_size", "=", "preds", ".", "shape", "[", "0", "...
https://github.com/PaddlePaddle/PaddleX/blob/2bab73f81ab54e328204e7871e6ae4a82e719f5d/paddlex/ppdet/metrics/keypoint_metrics.py#L287-L391
huggingface/transformers
623b4f7c63f60cce917677ee704d6c93ee960b4b
src/transformers/utils/dummy_flax_objects.py
python
FlaxPegasusModel.__init__
(self, *args, **kwargs)
[]
def __init__(self, *args, **kwargs): requires_backends(self, ["flax"])
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "requires_backends", "(", "self", ",", "[", "\"flax\"", "]", ")" ]
https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/utils/dummy_flax_objects.py#L1212-L1213
Marten4n6/EvilOSX
033a662030e99b3704a1505244ebc1e6e59fba57
server/modules/bot/slowloris.py
python
UserAgent.get_random
()
return random.choice(UserAgent.USER_AGENTS)
:return A random user agent string.
:return A random user agent string.
[ ":", "return", "A", "random", "user", "agent", "string", "." ]
def get_random(): """:return A random user agent string.""" return random.choice(UserAgent.USER_AGENTS)
[ "def", "get_random", "(", ")", ":", "return", "random", ".", "choice", "(", "UserAgent", ".", "USER_AGENTS", ")" ]
https://github.com/Marten4n6/EvilOSX/blob/033a662030e99b3704a1505244ebc1e6e59fba57/server/modules/bot/slowloris.py#L79-L81
haiwen/seahub
e92fcd44e3e46260597d8faa9347cb8222b8b10d
seahub/utils/__init__.py
python
get_inner_fileserver_root
()
return seahub.settings.INNER_FILE_SERVER_ROOT
Construct inner seafile fileserver address and port. Inner fileserver root allows Seahub access fileserver through local address, thus avoiding the overhead of DNS queries, as well as other related issues, for example, the server can not ping itself, etc. Returns: http://127.0.0.1:<port>
Construct inner seafile fileserver address and port.
[ "Construct", "inner", "seafile", "fileserver", "address", "and", "port", "." ]
def get_inner_fileserver_root(): """Construct inner seafile fileserver address and port. Inner fileserver root allows Seahub access fileserver through local address, thus avoiding the overhead of DNS queries, as well as other related issues, for example, the server can not ping itself, etc. Return...
[ "def", "get_inner_fileserver_root", "(", ")", ":", "return", "seahub", ".", "settings", ".", "INNER_FILE_SERVER_ROOT" ]
https://github.com/haiwen/seahub/blob/e92fcd44e3e46260597d8faa9347cb8222b8b10d/seahub/utils/__init__.py#L189-L200
DataDog/datadog-serverless-functions
2b28937da7cb8e2fdfa007db45e9fb0c7bd472e9
aws/logs_monitoring/enhanced_lambda_metrics.py
python
acquire_s3_cache_lock
()
return True
Acquire cache lock
Acquire cache lock
[ "Acquire", "cache", "lock" ]
def acquire_s3_cache_lock(): """Acquire cache lock""" cache_lock_object = s3_client.Object(DD_S3_BUCKET_NAME, DD_S3_CACHE_LOCK_FILENAME) try: file_content = cache_lock_object.get() # check lock file expiration last_modified_unix_time = get_last_modified_time(file_content) if...
[ "def", "acquire_s3_cache_lock", "(", ")", ":", "cache_lock_object", "=", "s3_client", ".", "Object", "(", "DD_S3_BUCKET_NAME", ",", "DD_S3_CACHE_LOCK_FILENAME", ")", "try", ":", "file_content", "=", "cache_lock_object", ".", "get", "(", ")", "# check lock file expirat...
https://github.com/DataDog/datadog-serverless-functions/blob/2b28937da7cb8e2fdfa007db45e9fb0c7bd472e9/aws/logs_monitoring/enhanced_lambda_metrics.py#L349-L371
plasticityai/magnitude
7ac0baeaf181263b661c3ae00643d21e3fd90216
pymagnitude/third_party/_apsw/tools/shell.py
python
Shell._append_input_description
(self)
When displaying an error in :meth:`handle_exception` we want to give context such as when the commands being executed came from a .read command (which in turn could execute another .read).
When displaying an error in :meth:`handle_exception` we want to give context such as when the commands being executed came from a .read command (which in turn could execute another .read).
[ "When", "displaying", "an", "error", "in", ":", "meth", ":", "handle_exception", "we", "want", "to", "give", "context", "such", "as", "when", "the", "commands", "being", "executed", "came", "from", "a", ".", "read", "command", "(", "which", "in", "turn", ...
def _append_input_description(self): """When displaying an error in :meth:`handle_exception` we want to give context such as when the commands being executed came from a .read command (which in turn could execute another .read). """ if self.interactive: return...
[ "def", "_append_input_description", "(", "self", ")", ":", "if", "self", ".", "interactive", ":", "return", "res", "=", "[", "]", "res", ".", "append", "(", "\"Line %d\"", "%", "(", "self", ".", "input_line_number", ",", ")", ")", "res", ".", "append", ...
https://github.com/plasticityai/magnitude/blob/7ac0baeaf181263b661c3ae00643d21e3fd90216/pymagnitude/third_party/_apsw/tools/shell.py#L2424-L2435
kuri65536/python-for-android
26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891
python-modules/twisted/twisted/protocols/amp.py
python
Command.makeResponse
(cls, objects, proto)
return _objectsToStrings(objects, cls.response, responseType, proto)
Serialize a mapping of arguments using this L{Command}'s response schema. @param objects: a dict with keys matching the names specified in self.response, having values of the types that the Argument objects in self.response can format. @param proto: an L{AMP}. @return:...
Serialize a mapping of arguments using this L{Command}'s response schema.
[ "Serialize", "a", "mapping", "of", "arguments", "using", "this", "L", "{", "Command", "}", "s", "response", "schema", "." ]
def makeResponse(cls, objects, proto): """ Serialize a mapping of arguments using this L{Command}'s response schema. @param objects: a dict with keys matching the names specified in self.response, having values of the types that the Argument objects in self.response can ...
[ "def", "makeResponse", "(", "cls", ",", "objects", ",", "proto", ")", ":", "try", ":", "responseType", "=", "cls", ".", "responseType", "(", ")", "except", ":", "return", "fail", "(", ")", "return", "_objectsToStrings", "(", "objects", ",", "cls", ".", ...
https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python-modules/twisted/twisted/protocols/amp.py#L1570-L1587
golismero/golismero
7d605b937e241f51c1ca4f47b20f755eeefb9d76
thirdparty_libs/nltk/tokenize/punkt.py
python
PunktSentenceTokenizer._ortho_heuristic
(self, aug_tok)
return 'unknown'
Decide whether the given token is the first token in a sentence.
Decide whether the given token is the first token in a sentence.
[ "Decide", "whether", "the", "given", "token", "is", "the", "first", "token", "in", "a", "sentence", "." ]
def _ortho_heuristic(self, aug_tok): """ Decide whether the given token is the first token in a sentence. """ # Sentences don't start with punctuation marks: if aug_tok.tok in self.PUNCTUATION: return False ortho_context = self._params.ortho_context[aug_tok.t...
[ "def", "_ortho_heuristic", "(", "self", ",", "aug_tok", ")", ":", "# Sentences don't start with punctuation marks:", "if", "aug_tok", ".", "tok", "in", "self", ".", "PUNCTUATION", ":", "return", "False", "ortho_context", "=", "self", ".", "_params", ".", "ortho_co...
https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/thirdparty_libs/nltk/tokenize/punkt.py#L1539-L1567
sysdream/pysqli
37418c9b3fbb760b97f28f6583f0d84f66bbff45
pysqli/core/forge.py
python
SQLForge.get_string_char
(self, sql, pos)
return self.ascii(self.get_char(sql, pos))
Forge a piece of SQL returning the ascii code of a string/sql sql: source string or sql pos: character position
Forge a piece of SQL returning the ascii code of a string/sql
[ "Forge", "a", "piece", "of", "SQL", "returning", "the", "ascii", "code", "of", "a", "string", "/", "sql" ]
def get_string_char(self, sql, pos): """ Forge a piece of SQL returning the ascii code of a string/sql sql: source string or sql pos: character position """ return self.ascii(self.get_char(sql, pos))
[ "def", "get_string_char", "(", "self", ",", "sql", ",", "pos", ")", ":", "return", "self", ".", "ascii", "(", "self", ".", "get_char", "(", "sql", ",", "pos", ")", ")" ]
https://github.com/sysdream/pysqli/blob/37418c9b3fbb760b97f28f6583f0d84f66bbff45/pysqli/core/forge.py#L303-L310
python-discord/site
899c304730598812a41be68a037c723d815e95e1
pydis_site/apps/api/admin.py
python
InfractionActorFilter.queryset
(self, request: HttpRequest, queryset: QuerySet)
return queryset.filter(actor__id=self.value())
Query to filter the list of Users against.
Query to filter the list of Users against.
[ "Query", "to", "filter", "the", "list", "of", "Users", "against", "." ]
def queryset(self, request: HttpRequest, queryset: QuerySet) -> Optional[QuerySet]: """Query to filter the list of Users against.""" if not self.value(): return return queryset.filter(actor__id=self.value())
[ "def", "queryset", "(", "self", ",", "request", ":", "HttpRequest", ",", "queryset", ":", "QuerySet", ")", "->", "Optional", "[", "QuerySet", "]", ":", "if", "not", "self", ".", "value", "(", ")", ":", "return", "return", "queryset", ".", "filter", "("...
https://github.com/python-discord/site/blob/899c304730598812a41be68a037c723d815e95e1/pydis_site/apps/api/admin.py#L69-L73
bikalims/bika.lims
35e4bbdb5a3912cae0b5eb13e51097c8b0486349
bika/lims/browser/analysisrequest/publish.py
python
AnalysisRequestPublishView._sorted_attachments
(self, ar, attachments=[])
return sorted(attachments, cmp=att_cmp)
Sorter to return the attachments in the same order as the user defined in the attachments viewlet
Sorter to return the attachments in the same order as the user defined in the attachments viewlet
[ "Sorter", "to", "return", "the", "attachments", "in", "the", "same", "order", "as", "the", "user", "defined", "in", "the", "attachments", "viewlet" ]
def _sorted_attachments(self, ar, attachments=[]): """Sorter to return the attachments in the same order as the user defined in the attachments viewlet """ inf = float("inf") view = ar.restrictedTraverse("attachments_view") order = view.get_attachments_order() de...
[ "def", "_sorted_attachments", "(", "self", ",", "ar", ",", "attachments", "=", "[", "]", ")", ":", "inf", "=", "float", "(", "\"inf\"", ")", "view", "=", "ar", ".", "restrictedTraverse", "(", "\"attachments_view\"", ")", "order", "=", "view", ".", "get_a...
https://github.com/bikalims/bika.lims/blob/35e4bbdb5a3912cae0b5eb13e51097c8b0486349/bika/lims/browser/analysisrequest/publish.py#L459-L474
PyFilesystem/pyfilesystem2
a6ea045e766c76bae2e2fde19294c8275773ffde
fs/path.py
python
combine
(path1, path2)
return "{}/{}".format(path1.rstrip("/"), path2.lstrip("/"))
Join two paths together. This is faster than :func:`~fs.path.join`, but only works when the second path is relative, and there are no back references in either path. Arguments: path1 (str): A PyFilesytem path. path2 (str): A PyFilesytem path. Returns: str: The joint path. ...
Join two paths together.
[ "Join", "two", "paths", "together", "." ]
def combine(path1, path2): # type: (Text, Text) -> Text """Join two paths together. This is faster than :func:`~fs.path.join`, but only works when the second path is relative, and there are no back references in either path. Arguments: path1 (str): A PyFilesytem path. path2 (st...
[ "def", "combine", "(", "path1", ",", "path2", ")", ":", "# type: (Text, Text) -> Text", "if", "not", "path1", ":", "return", "path2", ".", "lstrip", "(", ")", "return", "\"{}/{}\"", ".", "format", "(", "path1", ".", "rstrip", "(", "\"/\"", ")", ",", "pat...
https://github.com/PyFilesystem/pyfilesystem2/blob/a6ea045e766c76bae2e2fde19294c8275773ffde/fs/path.py#L243-L265
krintoxi/NoobSec-Toolkit
38738541cbc03cedb9a3b3ed13b629f781ad64f6
NoobSecToolkit - MAC OSX/tools/sqli/plugins/generic/custom.py
python
Custom.sqlShell
(self)
[]
def sqlShell(self): infoMsg = "calling %s shell. To quit type " % Backend.getIdentifiedDbms() infoMsg += "'x' or 'q' and press ENTER" logger.info(infoMsg) autoCompletion(AUTOCOMPLETE_TYPE.SQL) while True: query = None try: query = raw_in...
[ "def", "sqlShell", "(", "self", ")", ":", "infoMsg", "=", "\"calling %s shell. To quit type \"", "%", "Backend", ".", "getIdentifiedDbms", "(", ")", "infoMsg", "+=", "\"'x' or 'q' and press ENTER\"", "logger", ".", "info", "(", "infoMsg", ")", "autoCompletion", "(",...
https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit - MAC OSX/tools/sqli/plugins/generic/custom.py#L73-L111
openedx/edx-platform
68dd185a0ab45862a2a61e0f803d7e03d2be71b5
openedx/core/djangoapps/content/course_overviews/models.py
python
CourseOverview.update_select_courses
(cls, course_keys, force_update=False)
A side-effecting method that updates CourseOverview objects for the given course_keys. Arguments: course_keys (list[CourseKey]): Identifies for which courses to return CourseOverview objects. force_update (boolean): Optional parameter that indicates ...
A side-effecting method that updates CourseOverview objects for the given course_keys.
[ "A", "side", "-", "effecting", "method", "that", "updates", "CourseOverview", "objects", "for", "the", "given", "course_keys", "." ]
def update_select_courses(cls, course_keys, force_update=False): """ A side-effecting method that updates CourseOverview objects for the given course_keys. Arguments: course_keys (list[CourseKey]): Identifies for which courses to return CourseOverview objects...
[ "def", "update_select_courses", "(", "cls", ",", "course_keys", ",", "force_update", "=", "False", ")", ":", "log", ".", "info", "(", "'Generating course overview for %d courses.'", ",", "len", "(", "course_keys", ")", ")", "log", ".", "debug", "(", "'Generating...
https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/openedx/core/djangoapps/content/course_overviews/models.py#L608-L635
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/jupyter_client/multikernelmanager.py
python
MultiKernelManager.shutdown_all
(self, now=False)
Shutdown all kernels.
Shutdown all kernels.
[ "Shutdown", "all", "kernels", "." ]
def shutdown_all(self, now=False): """Shutdown all kernels.""" kids = self.list_kernel_ids() for kid in kids: self.request_shutdown(kid) for kid in kids: self.finish_shutdown(kid) self.cleanup(kid) self.remove_kernel(kid)
[ "def", "shutdown_all", "(", "self", ",", "now", "=", "False", ")", ":", "kids", "=", "self", ".", "list_kernel_ids", "(", ")", "for", "kid", "in", "kids", ":", "self", ".", "request_shutdown", "(", "kid", ")", "for", "kid", "in", "kids", ":", "self",...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/jupyter_client/multikernelmanager.py#L154-L162
pantsbuild/pex
473c6ac732ed4bc338b4b20a9ec930d1d722c9b4
pex/vendor/_vendored/setuptools/pkg_resources/_vendor/pyparsing.py
python
delimitedList
( expr, delim=",", combine=False )
Helper to define a delimited list of expressions - the delimiter defaults to ','. By default, the list elements and delimiters can have intervening whitespace, and comments, but this can be overridden by passing C{combine=True} in the constructor. If C{combine} is set to C{True}, the matching tokens are ret...
Helper to define a delimited list of expressions - the delimiter defaults to ','. By default, the list elements and delimiters can have intervening whitespace, and comments, but this can be overridden by passing C{combine=True} in the constructor. If C{combine} is set to C{True}, the matching tokens are ret...
[ "Helper", "to", "define", "a", "delimited", "list", "of", "expressions", "-", "the", "delimiter", "defaults", "to", ".", "By", "default", "the", "list", "elements", "and", "delimiters", "can", "have", "intervening", "whitespace", "and", "comments", "but", "thi...
def delimitedList( expr, delim=",", combine=False ): """ Helper to define a delimited list of expressions - the delimiter defaults to ','. By default, the list elements and delimiters can have intervening whitespace, and comments, but this can be overridden by passing C{combine=True} in the constructor....
[ "def", "delimitedList", "(", "expr", ",", "delim", "=", "\",\"", ",", "combine", "=", "False", ")", ":", "dlName", "=", "_ustr", "(", "expr", ")", "+", "\" [\"", "+", "_ustr", "(", "delim", ")", "+", "\" \"", "+", "_ustr", "(", "expr", ")", "+", ...
https://github.com/pantsbuild/pex/blob/473c6ac732ed4bc338b4b20a9ec930d1d722c9b4/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/pyparsing.py#L4450-L4467
ponyriders/django-amazon-price-monitor
c45d9f48a5bf429bfe696fcd9fc3f41f388bac2d
price_monitor/models/Product.py
python
Product.get_prices_for_chart
(self)
return [{'x': str(formats.date_format(p.date_seen, 'SHORT_DATETIME_FORMAT')), 'y': p.value} for p in self.price_set.all().order_by('date_seen')]
Returns all prices of the product. :return: list
Returns all prices of the product.
[ "Returns", "all", "prices", "of", "the", "product", "." ]
def get_prices_for_chart(self): """ Returns all prices of the product. :return: list """ # TODO: be able to specify a range, like last 100 days # TODO: don't select all prices, but a representative representation, like each 5th price aso return [{'x': str(formats...
[ "def", "get_prices_for_chart", "(", "self", ")", ":", "# TODO: be able to specify a range, like last 100 days", "# TODO: don't select all prices, but a representative representation, like each 5th price aso", "return", "[", "{", "'x'", ":", "str", "(", "formats", ".", "date_format"...
https://github.com/ponyriders/django-amazon-price-monitor/blob/c45d9f48a5bf429bfe696fcd9fc3f41f388bac2d/price_monitor/models/Product.py#L60-L68
hubblestack/hubble
763142474edcecdec5fd25591dc29c3536e8f969
hubblestack/modules/iptables.py
python
check_chain
(table="filter", chain=None, family="ipv4")
return out
.. versionadded:: 2014.1.0 Check for the existence of a chain in the table CLI Example: .. code-block:: bash salt '*' iptables.check_chain filter INPUT IPv6: salt '*' iptables.check_chain filter INPUT family=ipv6
.. versionadded:: 2014.1.0
[ "..", "versionadded", "::", "2014", ".", "1", ".", "0" ]
def check_chain(table="filter", chain=None, family="ipv4"): """ .. versionadded:: 2014.1.0 Check for the existence of a chain in the table CLI Example: .. code-block:: bash salt '*' iptables.check_chain filter INPUT IPv6: salt '*' iptables.check_chain filter INPUT family...
[ "def", "check_chain", "(", "table", "=", "\"filter\"", ",", "chain", "=", "None", ",", "family", "=", "\"ipv4\"", ")", ":", "if", "not", "chain", ":", "return", "\"Error: Chain needs to be specified\"", "cmd", "=", "\"{0}-save -t {1}\"", ".", "format", "(", "_...
https://github.com/hubblestack/hubble/blob/763142474edcecdec5fd25591dc29c3536e8f969/hubblestack/modules/iptables.py#L848-L875
edisonlz/fastor
342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3
base/site-packages/django/contrib/messages/storage/cookie.py
python
CookieStorage._decode
(self, data)
return None
Safely decodes a encoded text stream back into a list of messages. If the encoded text stream contained an invalid hash or was in an invalid format, ``None`` is returned.
Safely decodes a encoded text stream back into a list of messages.
[ "Safely", "decodes", "a", "encoded", "text", "stream", "back", "into", "a", "list", "of", "messages", "." ]
def _decode(self, data): """ Safely decodes a encoded text stream back into a list of messages. If the encoded text stream contained an invalid hash or was in an invalid format, ``None`` is returned. """ if not data: return None bits = data.split('$',...
[ "def", "_decode", "(", "self", ",", "data", ")", ":", "if", "not", "data", ":", "return", "None", "bits", "=", "data", ".", "split", "(", "'$'", ",", "1", ")", "if", "len", "(", "bits", ")", "==", "2", ":", "hash", ",", "value", "=", "bits", ...
https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/django/contrib/messages/storage/cookie.py#L136-L158
alastair/python-musicbrainzngs
69068a59072bcfd489dbf973d3ce3e317e6eb36e
musicbrainzngs/musicbrainz.py
python
submit_isrcs
(recording_isrcs)
return _do_mb_post("recording", query)
Submit ISRCs. Submits a set of {recording-id1: [isrc1, ...], ...} or {recording_id1: isrc, ...}.
Submit ISRCs. Submits a set of {recording-id1: [isrc1, ...], ...} or {recording_id1: isrc, ...}.
[ "Submit", "ISRCs", ".", "Submits", "a", "set", "of", "{", "recording", "-", "id1", ":", "[", "isrc1", "...", "]", "...", "}", "or", "{", "recording_id1", ":", "isrc", "...", "}", "." ]
def submit_isrcs(recording_isrcs): """Submit ISRCs. Submits a set of {recording-id1: [isrc1, ...], ...} or {recording_id1: isrc, ...}. """ rec2isrcs = dict() for (rec, isrcs) in recording_isrcs.items(): rec2isrcs[rec] = isrcs if isinstance(isrcs, list) else [isrcs] query = mbxml.make...
[ "def", "submit_isrcs", "(", "recording_isrcs", ")", ":", "rec2isrcs", "=", "dict", "(", ")", "for", "(", "rec", ",", "isrcs", ")", "in", "recording_isrcs", ".", "items", "(", ")", ":", "rec2isrcs", "[", "rec", "]", "=", "isrcs", "if", "isinstance", "("...
https://github.com/alastair/python-musicbrainzngs/blob/69068a59072bcfd489dbf973d3ce3e317e6eb36e/musicbrainzngs/musicbrainz.py#L1262-L1271