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
jtriley/StarCluster
bc7c950e73f193eac9aab986b6764939cfdad978
starcluster/cluster.py
python
Cluster.add_node
(self, alias=None, no_create=False, image_id=None, instance_type=None, zone=None, placement_group=None, spot_bid=None)
return self.add_nodes(1, aliases=aliases, image_id=image_id, instance_type=instance_type, zone=zone, placement_group=placement_group, spot_bid=spot_bid, no_create=no_create)
Add a single node to this cluster
Add a single node to this cluster
[ "Add", "a", "single", "node", "to", "this", "cluster" ]
def add_node(self, alias=None, no_create=False, image_id=None, instance_type=None, zone=None, placement_group=None, spot_bid=None): """ Add a single node to this cluster """ aliases = [alias] if alias else None return self.add_nodes(1, aliases=aliases, image_id=image_id, instance_type=instance_type, zone=zone, placement_group=placement_group, spot_bid=spot_bid, no_create=no_create)
[ "def", "add_node", "(", "self", ",", "alias", "=", "None", ",", "no_create", "=", "False", ",", "image_id", "=", "None", ",", "instance_type", "=", "None", ",", "zone", "=", "None", ",", "placement_group", "=", "None", ",", "spot_bid", "=", "None", ")"...
https://github.com/jtriley/StarCluster/blob/bc7c950e73f193eac9aab986b6764939cfdad978/starcluster/cluster.py#L986-L996
fonttools/fonttools
892322aaff6a89bea5927379ec06bc0da3dfb7df
Lib/fontTools/varLib/varStore.py
python
VarStore_optimize
(self)
return varidx_map
Optimize storage. Returns mapping from old VarIdxes to new ones.
Optimize storage. Returns mapping from old VarIdxes to new ones.
[ "Optimize", "storage", ".", "Returns", "mapping", "from", "old", "VarIdxes", "to", "new", "ones", "." ]
def VarStore_optimize(self): """Optimize storage. Returns mapping from old VarIdxes to new ones.""" # TODO # Check that no two VarRegions are the same; if they are, fold them. n = len(self.VarRegionList.Region) # Number of columns zeroes = [0] * n front_mapping = {} # Map from old VarIdxes to full row tuples encodings = _EncodingDict() # Collect all items into a set of full rows (with lots of zeroes.) for major,data in enumerate(self.VarData): regionIndices = data.VarRegionIndex for minor,item in enumerate(data.Item): row = list(zeroes) for regionIdx,v in zip(regionIndices, item): row[regionIdx] += v row = tuple(row) encodings.add_row(row) front_mapping[(major<<16)+minor] = row # Separate encodings that have no gain (are decided) and those having # possible gain (possibly to be merged into others.) encodings = sorted(encodings.values(), key=_Encoding.__len__, reverse=True) done_by_width = defaultdict(list) todo = [] for encoding in encodings: if not encoding.gain: done_by_width[encoding.width].append(encoding) else: todo.append(encoding) # For each encoding that is possibly to be merged, find the best match # in the decided encodings, and record that. todo.sort(key=_Encoding.get_room) for encoding in todo: encoding._find_yourself_best_new_encoding(done_by_width) # Walk through todo encodings, for each, see if merging it with # another todo encoding gains more than each of them merging with # their best decided encoding. If yes, merge them and add resulting # encoding back to todo queue. If not, move the enconding to decided # list. Repeat till done. while todo: encoding = todo.pop() best_idx = None best_gain = 0 for i,other_encoding in enumerate(todo): combined_chars = other_encoding.chars | encoding.chars combined_width = _Encoding._popcount(combined_chars) combined_overhead = _Encoding._characteristic_overhead(combined_chars) combined_gain = ( + encoding.overhead + other_encoding.overhead - combined_overhead - (combined_width - encoding.width) * len(encoding) - (combined_width - other_encoding.width) * len(other_encoding) ) this_gain = 0 if encoding.best_new_encoding is None else ( + encoding.overhead - (encoding.best_new_encoding.width - encoding.width) * len(encoding) ) other_gain = 0 if other_encoding.best_new_encoding is None else ( + other_encoding.overhead - (other_encoding.best_new_encoding.width - other_encoding.width) * len(other_encoding) ) separate_gain = this_gain + other_gain if combined_gain > separate_gain: best_idx = i best_gain = combined_gain - separate_gain if best_idx is None: # Encoding is decided as is done_by_width[encoding.width].append(encoding) else: other_encoding = todo[best_idx] combined_chars = other_encoding.chars | encoding.chars combined_encoding = _Encoding(combined_chars) combined_encoding.extend(encoding.items) combined_encoding.extend(other_encoding.items) combined_encoding._find_yourself_best_new_encoding(done_by_width) del todo[best_idx] todo.append(combined_encoding) # Assemble final store. back_mapping = {} # Mapping from full rows to new VarIdxes encodings = sum(done_by_width.values(), []) encodings.sort(key=_Encoding.sort_key) self.VarData = [] for major,encoding in enumerate(encodings): data = ot.VarData() self.VarData.append(data) data.VarRegionIndex = range(n) data.VarRegionCount = len(data.VarRegionIndex) data.Item = sorted(encoding.items) for minor,item in enumerate(data.Item): back_mapping[item] = (major<<16)+minor # Compile final mapping. varidx_map = {} for k,v in front_mapping.items(): varidx_map[k] = back_mapping[v] # Remove unused regions. self.prune_regions() # Recalculate things and go home. self.VarRegionList.RegionCount = len(self.VarRegionList.Region) self.VarDataCount = len(self.VarData) for data in self.VarData: data.ItemCount = len(data.Item) data.optimize() return varidx_map
[ "def", "VarStore_optimize", "(", "self", ")", ":", "# TODO", "# Check that no two VarRegions are the same; if they are, fold them.", "n", "=", "len", "(", "self", ".", "VarRegionList", ".", "Region", ")", "# Number of columns", "zeroes", "=", "[", "0", "]", "*", "n"...
https://github.com/fonttools/fonttools/blob/892322aaff6a89bea5927379ec06bc0da3dfb7df/Lib/fontTools/varLib/varStore.py#L434-L554
realpython/book2-exercises
cde325eac8e6d8cff2316601c2e5b36bb46af7d0
web2py/venv/lib/python2.7/site-packages/setuptools/dist.py
python
Feature.validate
(self, dist)
Verify that feature makes sense in context of distribution This method is called by the distribution just before it parses its command line. It checks to ensure that the 'remove' attribute, if any, contains only valid package/module names that are present in the base distribution when 'setup()' is called. You may override it in a subclass to perform any other required validation of the feature against a target distribution.
Verify that feature makes sense in context of distribution
[ "Verify", "that", "feature", "makes", "sense", "in", "context", "of", "distribution" ]
def validate(self, dist): """Verify that feature makes sense in context of distribution This method is called by the distribution just before it parses its command line. It checks to ensure that the 'remove' attribute, if any, contains only valid package/module names that are present in the base distribution when 'setup()' is called. You may override it in a subclass to perform any other required validation of the feature against a target distribution. """ for item in self.remove: if not dist.has_contents_for(item): raise DistutilsSetupError( "%s wants to be able to remove %s, but the distribution" " doesn't contain any packages or modules under %s" % (self.description, item, item) )
[ "def", "validate", "(", "self", ",", "dist", ")", ":", "for", "item", "in", "self", ".", "remove", ":", "if", "not", "dist", ".", "has_contents_for", "(", "item", ")", ":", "raise", "DistutilsSetupError", "(", "\"%s wants to be able to remove %s, but the distrib...
https://github.com/realpython/book2-exercises/blob/cde325eac8e6d8cff2316601c2e5b36bb46af7d0/web2py/venv/lib/python2.7/site-packages/setuptools/dist.py#L897-L914
home-assistant/core
265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1
homeassistant/components/hikvision/binary_sensor.py
python
HikvisionData.__init__
(self, hass, url, port, name, username, password)
Initialize the data object.
Initialize the data object.
[ "Initialize", "the", "data", "object", "." ]
def __init__(self, hass, url, port, name, username, password): """Initialize the data object.""" self._url = url self._port = port self._name = name self._username = username self._password = password # Establish camera self.camdata = HikCamera(self._url, self._port, self._username, self._password) if self._name is None: self._name = self.camdata.get_name hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, self.stop_hik) hass.bus.listen_once(EVENT_HOMEASSISTANT_START, self.start_hik)
[ "def", "__init__", "(", "self", ",", "hass", ",", "url", ",", "port", ",", "name", ",", "username", ",", "password", ")", ":", "self", ".", "_url", "=", "url", "self", ".", "_port", "=", "port", "self", ".", "_name", "=", "name", "self", ".", "_u...
https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/hikvision/binary_sensor.py#L149-L164
coala/coala
37af7fd5de3ed148b8096cfc80e4717fb840bf2c
coalib/core/Bear.py
python
Bear.__json__
(cls)
return data
Override JSON export of ``Bear`` class.
Override JSON export of ``Bear`` class.
[ "Override", "JSON", "export", "of", "Bear", "class", "." ]
def __json__(cls): """ Override JSON export of ``Bear`` class. """ # Those members get duplicated if they aren't excluded because they # exist also as fields. excluded_members = {'can_detect', 'maintainers', 'maintainers_emails'} # json cannot serialize properties, so drop them data = { key: value for key, value in get_public_members(cls).items() if not isinstance(value, property) and key not in excluded_members} metadata = cls.get_metadata() non_optional_params = metadata.non_optional_params optional_params = metadata.optional_params data['metadata'] = { 'desc': metadata.desc, 'non_optional_params': {param: non_optional_params[param][0] for param in non_optional_params}, 'optional_params': {param: optional_params[param][0] for param in optional_params}} return data
[ "def", "__json__", "(", "cls", ")", ":", "# Those members get duplicated if they aren't excluded because they", "# exist also as fields.", "excluded_members", "=", "{", "'can_detect'", ",", "'maintainers'", ",", "'maintainers_emails'", "}", "# json cannot serialize properties, so d...
https://github.com/coala/coala/blob/37af7fd5de3ed148b8096cfc80e4717fb840bf2c/coalib/core/Bear.py#L278-L302
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/schemes/toric/variety.py
python
is_ToricVariety
(x)
return isinstance(x, ToricVariety_field)
r""" Check if ``x`` is a toric variety. INPUT: - ``x`` -- anything. OUTPUT: - ``True`` if ``x`` is a :class:`toric variety <ToricVariety_field>` and ``False`` otherwise. .. NOTE:: While projective spaces are toric varieties mathematically, they are not toric varieties in Sage due to efficiency considerations, so this function will return ``False``. EXAMPLES:: sage: from sage.schemes.toric.variety import is_ToricVariety sage: is_ToricVariety(1) False sage: fan = FaceFan(lattice_polytope.cross_polytope(2)) sage: P = ToricVariety(fan) sage: P 2-d toric variety covered by 4 affine patches sage: is_ToricVariety(P) True sage: is_ToricVariety(ProjectiveSpace(2)) False
r""" Check if ``x`` is a toric variety.
[ "r", "Check", "if", "x", "is", "a", "toric", "variety", "." ]
def is_ToricVariety(x): r""" Check if ``x`` is a toric variety. INPUT: - ``x`` -- anything. OUTPUT: - ``True`` if ``x`` is a :class:`toric variety <ToricVariety_field>` and ``False`` otherwise. .. NOTE:: While projective spaces are toric varieties mathematically, they are not toric varieties in Sage due to efficiency considerations, so this function will return ``False``. EXAMPLES:: sage: from sage.schemes.toric.variety import is_ToricVariety sage: is_ToricVariety(1) False sage: fan = FaceFan(lattice_polytope.cross_polytope(2)) sage: P = ToricVariety(fan) sage: P 2-d toric variety covered by 4 affine patches sage: is_ToricVariety(P) True sage: is_ToricVariety(ProjectiveSpace(2)) False """ return isinstance(x, ToricVariety_field)
[ "def", "is_ToricVariety", "(", "x", ")", ":", "return", "isinstance", "(", "x", ",", "ToricVariety_field", ")" ]
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/schemes/toric/variety.py#L343-L376
bendmorris/static-python
2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473
Lib/tkinter/__init__.py
python
Text.scan_dragto
(self, x, y)
Adjust the view of the text to 10 times the difference between X and Y and the coordinates given in scan_mark.
Adjust the view of the text to 10 times the difference between X and Y and the coordinates given in scan_mark.
[ "Adjust", "the", "view", "of", "the", "text", "to", "10", "times", "the", "difference", "between", "X", "and", "Y", "and", "the", "coordinates", "given", "in", "scan_mark", "." ]
def scan_dragto(self, x, y): """Adjust the view of the text to 10 times the difference between X and Y and the coordinates given in scan_mark.""" self.tk.call(self._w, 'scan', 'dragto', x, y)
[ "def", "scan_dragto", "(", "self", ",", "x", ",", "y", ")", ":", "self", ".", "tk", ".", "call", "(", "self", ".", "_w", ",", "'scan'", ",", "'dragto'", ",", "x", ",", "y", ")" ]
https://github.com/bendmorris/static-python/blob/2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473/Lib/tkinter/__init__.py#L3134-L3138
joaoventura/pylibui
2e74db787bfea533f3ae465670963daedcaec344
pylibui/libui/separator.py
python
uiNewHorizontalSeparator
()
return clibui.uiNewHorizontalSeparator()
Returns a horizontal separator. :return: uiHorizontalSeparator
Returns a horizontal separator.
[ "Returns", "a", "horizontal", "separator", "." ]
def uiNewHorizontalSeparator(): """ Returns a horizontal separator. :return: uiHorizontalSeparator """ # Set return type clibui.uiNewHorizontalSeparator.restype = ctypes.POINTER(uiSeparator) return clibui.uiNewHorizontalSeparator()
[ "def", "uiNewHorizontalSeparator", "(", ")", ":", "# Set return type", "clibui", ".", "uiNewHorizontalSeparator", ".", "restype", "=", "ctypes", ".", "POINTER", "(", "uiSeparator", ")", "return", "clibui", ".", "uiNewHorizontalSeparator", "(", ")" ]
https://github.com/joaoventura/pylibui/blob/2e74db787bfea533f3ae465670963daedcaec344/pylibui/libui/separator.py#L28-L38
openedx/edx-platform
68dd185a0ab45862a2a61e0f803d7e03d2be71b5
openedx/core/djangoapps/content_libraries/api.py
python
set_library_block_olx
(usage_key, new_olx_str)
Replace the OLX source of the given XBlock. This is only meant for use by developers or API client applications, as very little validation is done and this can easily result in a broken XBlock that won't load.
Replace the OLX source of the given XBlock. This is only meant for use by developers or API client applications, as very little validation is done and this can easily result in a broken XBlock that won't load.
[ "Replace", "the", "OLX", "source", "of", "the", "given", "XBlock", ".", "This", "is", "only", "meant", "for", "use", "by", "developers", "or", "API", "client", "applications", "as", "very", "little", "validation", "is", "done", "and", "this", "can", "easil...
def set_library_block_olx(usage_key, new_olx_str): """ Replace the OLX source of the given XBlock. This is only meant for use by developers or API client applications, as very little validation is done and this can easily result in a broken XBlock that won't load. """ # because this old pylint can't understand attr.ib() objects, pylint: disable=no-member assert isinstance(usage_key, LibraryUsageLocatorV2) # Make sure the block exists: metadata = get_library_block(usage_key) block_type = usage_key.block_type # Verify that the OLX parses, at least as generic XML: node = etree.fromstring(new_olx_str) if node.tag != block_type: raise ValueError(f"Invalid root tag in OLX, expected {block_type}") # Write the new XML/OLX file into the library bundle's draft draft = get_or_create_bundle_draft(metadata.def_key.bundle_uuid, DRAFT_NAME) write_draft_file(draft.uuid, metadata.def_key.olx_path, new_olx_str.encode('utf-8')) # Clear the bundle cache so everyone sees the new block immediately: BundleCache(metadata.def_key.bundle_uuid, draft_name=DRAFT_NAME).clear() LIBRARY_BLOCK_UPDATED.send(sender=None, library_key=usage_key.context_key, usage_key=usage_key)
[ "def", "set_library_block_olx", "(", "usage_key", ",", "new_olx_str", ")", ":", "# because this old pylint can't understand attr.ib() objects, pylint: disable=no-member", "assert", "isinstance", "(", "usage_key", ",", "LibraryUsageLocatorV2", ")", "# Make sure the block exists:", "...
https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/openedx/core/djangoapps/content_libraries/api.py#L732-L753
Yuliang-Liu/Box_Discretization_Network
5b3a30c97429ef8e5c5e1c4e2476c7d9abdc03e6
setup.py
python
get_extensions
()
return ext_modules
[]
def get_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) extensions_dir = os.path.join(this_dir, "maskrcnn_benchmark", "csrc") main_file = glob.glob(os.path.join(extensions_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(extensions_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(extensions_dir, "cuda", "*.cu")) sources = main_file + source_cpu extension = CppExtension extra_compile_args = {"cxx": []} define_macros = [] if (torch.cuda.is_available() and CUDA_HOME is not None) or os.getenv("FORCE_CUDA", "0") == "1": extension = CUDAExtension sources += source_cuda define_macros += [("WITH_CUDA", None)] extra_compile_args["nvcc"] = [ "-DCUDA_HAS_FP16=1", "-D__CUDA_NO_HALF_OPERATORS__", "-D__CUDA_NO_HALF_CONVERSIONS__", "-D__CUDA_NO_HALF2_OPERATORS__", ] sources = [os.path.join(extensions_dir, s) for s in sources] include_dirs = [extensions_dir] ext_modules = [ extension( "maskrcnn_benchmark._C", sources, include_dirs=include_dirs, define_macros=define_macros, extra_compile_args=extra_compile_args, ) ] return ext_modules
[ "def", "get_extensions", "(", ")", ":", "this_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", "extensions_dir", "=", "os", ".", "path", ".", "join", "(", "this_dir", ",", "\"maskrcnn_benc...
https://github.com/Yuliang-Liu/Box_Discretization_Network/blob/5b3a30c97429ef8e5c5e1c4e2476c7d9abdc03e6/setup.py#L17-L56
conansherry/detectron2
72c935d9aad8935406b1038af408aa06077d950a
detectron2/evaluation/coco_evaluation.py
python
COCOEvaluator._derive_coco_results
(self, coco_eval, iou_type, class_names=None)
return results
Derive the desired score numbers from summarized COCOeval. Args: coco_eval (None or COCOEval): None represents no predictions from model. iou_type (str): class_names (None or list[str]): if provided, will use it to predict per-category AP. Returns: a dict of {metric name: score}
Derive the desired score numbers from summarized COCOeval.
[ "Derive", "the", "desired", "score", "numbers", "from", "summarized", "COCOeval", "." ]
def _derive_coco_results(self, coco_eval, iou_type, class_names=None): """ Derive the desired score numbers from summarized COCOeval. Args: coco_eval (None or COCOEval): None represents no predictions from model. iou_type (str): class_names (None or list[str]): if provided, will use it to predict per-category AP. Returns: a dict of {metric name: score} """ metrics = { "bbox": ["AP", "AP50", "AP75", "APs", "APm", "APl"], "segm": ["AP", "AP50", "AP75", "APs", "APm", "APl"], "keypoints": ["AP", "AP50", "AP75", "APm", "APl"], }[iou_type] if coco_eval is None: self._logger.warn("No predictions from the model! Set scores to -1") return {metric: -1 for metric in metrics} # the standard metrics results = {metric: float(coco_eval.stats[idx] * 100) for idx, metric in enumerate(metrics)} self._logger.info( "Evaluation results for {}: \n".format(iou_type) + create_small_table(results) ) if class_names is None or len(class_names) <= 1: return results # Compute per-category AP # from https://github.com/facebookresearch/Detectron/blob/a6a835f5b8208c45d0dce217ce9bbda915f44df7/detectron/datasets/json_dataset_evaluator.py#L222-L252 # noqa precisions = coco_eval.eval["precision"] # precision has dims (iou, recall, cls, area range, max dets) assert len(class_names) == precisions.shape[2] results_per_category = [] for idx, name in enumerate(class_names): # area range index 0: all area ranges # max dets index -1: typically 100 per image precision = precisions[:, :, idx, 0, -1] precision = precision[precision > -1] ap = np.mean(precision) if precision.size else float("nan") results_per_category.append(("{}".format(name), float(ap * 100))) # tabulate it N_COLS = min(6, len(results_per_category) * 2) results_flatten = list(itertools.chain(*results_per_category)) results_2d = itertools.zip_longest(*[results_flatten[i::N_COLS] for i in range(N_COLS)]) table = tabulate( results_2d, tablefmt="pipe", floatfmt=".3f", headers=["category", "AP"] * (N_COLS // 2), numalign="left", ) self._logger.info("Per-category {} AP: \n".format(iou_type) + table) results.update({"AP-" + name: ap for name, ap in results_per_category}) return results
[ "def", "_derive_coco_results", "(", "self", ",", "coco_eval", ",", "iou_type", ",", "class_names", "=", "None", ")", ":", "metrics", "=", "{", "\"bbox\"", ":", "[", "\"AP\"", ",", "\"AP50\"", ",", "\"AP75\"", ",", "\"APs\"", ",", "\"APm\"", ",", "\"APl\"",...
https://github.com/conansherry/detectron2/blob/72c935d9aad8935406b1038af408aa06077d950a/detectron2/evaluation/coco_evaluation.py#L216-L277
daoluan/decode-Django
d46a858b45b56de48b0355f50dd9e45402d04cfd
Django-1.5.1/django/contrib/formtools/wizard/views.py
python
WizardView.process_step_files
(self, form)
return self.get_form_step_files(form)
This method is used to postprocess the form files. By default, it returns the raw `form.files` dictionary.
This method is used to postprocess the form files. By default, it returns the raw `form.files` dictionary.
[ "This", "method", "is", "used", "to", "postprocess", "the", "form", "files", ".", "By", "default", "it", "returns", "the", "raw", "form", ".", "files", "dictionary", "." ]
def process_step_files(self, form): """ This method is used to postprocess the form files. By default, it returns the raw `form.files` dictionary. """ return self.get_form_step_files(form)
[ "def", "process_step_files", "(", "self", ",", "form", ")", ":", "return", "self", ".", "get_form_step_files", "(", "form", ")" ]
https://github.com/daoluan/decode-Django/blob/d46a858b45b56de48b0355f50dd9e45402d04cfd/Django-1.5.1/django/contrib/formtools/wizard/views.py#L408-L413
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/modules/zfs.py
python
rollback
(name, **kwargs)
return __utils__["zfs.parse_command_result"](res, "rolledback")
Roll back the given dataset to a previous snapshot. name : string name of snapshot recursive : boolean destroy any snapshots and bookmarks more recent than the one specified. recursive_all : boolean destroy any more recent snapshots and bookmarks, as well as any clones of those snapshots. force : boolean used with the -R option to force an unmount of any clone file systems that are to be destroyed. .. warning:: When a dataset is rolled back, all data that has changed since the snapshot is discarded, and the dataset reverts to the state at the time of the snapshot. By default, the command refuses to roll back to a snapshot other than the most recent one. In order to do so, all intermediate snapshots and bookmarks must be destroyed by specifying the -r option. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' zfs.rollback myzpool/mydataset@yesterday
Roll back the given dataset to a previous snapshot.
[ "Roll", "back", "the", "given", "dataset", "to", "a", "previous", "snapshot", "." ]
def rollback(name, **kwargs): """ Roll back the given dataset to a previous snapshot. name : string name of snapshot recursive : boolean destroy any snapshots and bookmarks more recent than the one specified. recursive_all : boolean destroy any more recent snapshots and bookmarks, as well as any clones of those snapshots. force : boolean used with the -R option to force an unmount of any clone file systems that are to be destroyed. .. warning:: When a dataset is rolled back, all data that has changed since the snapshot is discarded, and the dataset reverts to the state at the time of the snapshot. By default, the command refuses to roll back to a snapshot other than the most recent one. In order to do so, all intermediate snapshots and bookmarks must be destroyed by specifying the -r option. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' zfs.rollback myzpool/mydataset@yesterday """ ## Configure command # NOTE: initialize the defaults flags = [] # NOTE: set extra config from kwargs if kwargs.get("recursive_all", False): flags.append("-R") if kwargs.get("recursive", False): flags.append("-r") if kwargs.get("force", False): if kwargs.get("recursive_all", False) or kwargs.get("recursive", False): flags.append("-f") else: log.warning( "zfs.rollback - force=True can only be used with recursive_all=True or" " recursive=True" ) ## Rollback to snapshot res = __salt__["cmd.run_all"]( __utils__["zfs.zfs_command"]( command="rollback", flags=flags, target=name, ), python_shell=False, ) return __utils__["zfs.parse_command_result"](res, "rolledback")
[ "def", "rollback", "(", "name", ",", "*", "*", "kwargs", ")", ":", "## Configure command", "# NOTE: initialize the defaults", "flags", "=", "[", "]", "# NOTE: set extra config from kwargs", "if", "kwargs", ".", "get", "(", "\"recursive_all\"", ",", "False", ")", "...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/modules/zfs.py#L631-L694
olist/correios
5494d7457665fa9a8dffbffa976cdbd2885c54e4
correios/xml_utils.py
python
add_text_argument
(f)
return wrapper
[]
def add_text_argument(f): @wraps(f) def wrapper(*args, **kwargs): text = kwargs.pop("text", None) cdata = kwargs.pop("cdata", None) element = f(*args, **kwargs) if cdata: element.text = etree.CDATA(cdata) elif text: element.text = text else: element.text = None return element return wrapper
[ "def", "add_text_argument", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "text", "=", "kwargs", ".", "pop", "(", "\"text\"", ",", "None", ")", "cdata", "=", "kwargs", ".",...
https://github.com/olist/correios/blob/5494d7457665fa9a8dffbffa976cdbd2885c54e4/correios/xml_utils.py#L20-L34
tendenci/tendenci
0f2c348cc0e7d41bc56f50b00ce05544b083bf1d
tendenci/libs/model_report/utils.py
python
model_lookup_label
(report, field)
return "[%s] %s" % (report.model._meta.verbose_name.title(), field.verbose_name.title())
[]
def model_lookup_label(report, field): return "[%s] %s" % (report.model._meta.verbose_name.title(), field.verbose_name.title())
[ "def", "model_lookup_label", "(", "report", ",", "field", ")", ":", "return", "\"[%s] %s\"", "%", "(", "report", ".", "model", ".", "_meta", ".", "verbose_name", ".", "title", "(", ")", ",", "field", ".", "verbose_name", ".", "title", "(", ")", ")" ]
https://github.com/tendenci/tendenci/blob/0f2c348cc0e7d41bc56f50b00ce05544b083bf1d/tendenci/libs/model_report/utils.py#L28-L29
Pyomo/pyomo
dbd4faee151084f343b893cc2b0c04cf2b76fd92
pyomo/core/expr/logical_expr.py
python
BooleanExpressionBase.nargs
(self)
Returns the number of child nodes.
Returns the number of child nodes.
[ "Returns", "the", "number", "of", "child", "nodes", "." ]
def nargs(self): """ Returns the number of child nodes. """ raise NotImplementedError( "Derived expression (%s) failed to " "implement nargs()" % (str(self.__class__), ))
[ "def", "nargs", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "\"Derived expression (%s) failed to \"", "\"implement nargs()\"", "%", "(", "str", "(", "self", ".", "__class__", ")", ",", ")", ")" ]
https://github.com/Pyomo/pyomo/blob/dbd4faee151084f343b893cc2b0c04cf2b76fd92/pyomo/core/expr/logical_expr.py#L451-L457
weechat/scripts
99ec0e7eceefabb9efb0f11ec26d45d6e8e84335
python/vdm.py
python
vdm_buffer_set_title
()
Set buffer title, using key used by user.
Set buffer title, using key used by user.
[ "Set", "buffer", "title", "using", "key", "used", "by", "user", "." ]
def vdm_buffer_set_title(): """ Set buffer title, using key used by user. """ global vdm_buffer, vdm_key lang = weechat.config_get_plugin("lang") weechat.buffer_set(vdm_buffer, "title", SCRIPT_NAME + " " + SCRIPT_VERSION + " [" + lang + "] | " + "Keys: last, random, top, flop, #, category " + "(current: '" + vdm_key + "') | " + "Get help with /help vdm")
[ "def", "vdm_buffer_set_title", "(", ")", ":", "global", "vdm_buffer", ",", "vdm_key", "lang", "=", "weechat", ".", "config_get_plugin", "(", "\"lang\"", ")", "weechat", ".", "buffer_set", "(", "vdm_buffer", ",", "\"title\"", ",", "SCRIPT_NAME", "+", "\" \"", "...
https://github.com/weechat/scripts/blob/99ec0e7eceefabb9efb0f11ec26d45d6e8e84335/python/vdm.py#L134-L142
boto/boto
b2a6f08122b2f1b89888d2848e730893595cd001
boto/storage_uri.py
python
BucketStorageUri.__init__
(self, scheme, bucket_name=None, object_name=None, debug=0, connection_args=None, suppress_consec_slashes=True, version_id=None, generation=None, is_latest=False)
Instantiate a BucketStorageUri from scheme,bucket,object tuple. @type scheme: string @param scheme: URI scheme naming the storage provider (gs, s3, etc.) @type bucket_name: string @param bucket_name: bucket name @type object_name: string @param object_name: object name, excluding generation/version. @type debug: int @param debug: debug level to pass in to connection (range 0..2) @type connection_args: map @param connection_args: optional map containing args to be passed to {S3,GS}Connection constructor (e.g., to override https_connection_factory). @param suppress_consec_slashes: If provided, controls whether consecutive slashes will be suppressed in key paths. @param version_id: Object version id (S3-specific). @param generation: Object generation number (GCS-specific). @param is_latest: boolean indicating that a versioned object is the current version After instantiation the components are available in the following fields: scheme, bucket_name, object_name, version_id, generation, is_latest, versionless_uri, version_specific_uri, uri. Note: If instantiated without version info, the string representation for a URI stays versionless; similarly, if instantiated with version info, the string representation for a URI stays version-specific. If you call one of the uri.set_contents_from_xyz() methods, a specific object version will be created, and its version-specific URI string can be retrieved from version_specific_uri even if the URI was instantiated without version info.
Instantiate a BucketStorageUri from scheme,bucket,object tuple.
[ "Instantiate", "a", "BucketStorageUri", "from", "scheme", "bucket", "object", "tuple", "." ]
def __init__(self, scheme, bucket_name=None, object_name=None, debug=0, connection_args=None, suppress_consec_slashes=True, version_id=None, generation=None, is_latest=False): """Instantiate a BucketStorageUri from scheme,bucket,object tuple. @type scheme: string @param scheme: URI scheme naming the storage provider (gs, s3, etc.) @type bucket_name: string @param bucket_name: bucket name @type object_name: string @param object_name: object name, excluding generation/version. @type debug: int @param debug: debug level to pass in to connection (range 0..2) @type connection_args: map @param connection_args: optional map containing args to be passed to {S3,GS}Connection constructor (e.g., to override https_connection_factory). @param suppress_consec_slashes: If provided, controls whether consecutive slashes will be suppressed in key paths. @param version_id: Object version id (S3-specific). @param generation: Object generation number (GCS-specific). @param is_latest: boolean indicating that a versioned object is the current version After instantiation the components are available in the following fields: scheme, bucket_name, object_name, version_id, generation, is_latest, versionless_uri, version_specific_uri, uri. Note: If instantiated without version info, the string representation for a URI stays versionless; similarly, if instantiated with version info, the string representation for a URI stays version-specific. If you call one of the uri.set_contents_from_xyz() methods, a specific object version will be created, and its version-specific URI string can be retrieved from version_specific_uri even if the URI was instantiated without version info. """ self.scheme = scheme self.bucket_name = bucket_name self.object_name = object_name self.debug = debug if connection_args: self.connection_args = connection_args self.suppress_consec_slashes = suppress_consec_slashes self.version_id = version_id self.generation = generation and int(generation) self.is_latest = is_latest self.is_version_specific = bool(self.generation) or bool(version_id) self._build_uri_strings()
[ "def", "__init__", "(", "self", ",", "scheme", ",", "bucket_name", "=", "None", ",", "object_name", "=", "None", ",", "debug", "=", "0", ",", "connection_args", "=", "None", ",", "suppress_consec_slashes", "=", "True", ",", "version_id", "=", "None", ",", ...
https://github.com/boto/boto/blob/b2a6f08122b2f1b89888d2848e730893595cd001/boto/storage_uri.py#L252-L299
mautrix/telegram
9f48eca5a6654bc38012cb761ecaaaf416aabdd0
mautrix_telegram/puppet.py
python
Puppet.try_update_info
(self, source: au.AbstractUser, info: User)
[]
async def try_update_info(self, source: au.AbstractUser, info: User) -> None: try: await self.update_info(source, info) except Exception: source.log.exception(f"Failed to update info of {self.tgid}")
[ "async", "def", "try_update_info", "(", "self", ",", "source", ":", "au", ".", "AbstractUser", ",", "info", ":", "User", ")", "->", "None", ":", "try", ":", "await", "self", ".", "update_info", "(", "source", ",", "info", ")", "except", "Exception", ":...
https://github.com/mautrix/telegram/blob/9f48eca5a6654bc38012cb761ecaaaf416aabdd0/mautrix_telegram/puppet.py#L217-L221
anki/cozmo-python-sdk
dd29edef18748fcd816550469195323842a7872e
src/cozmo/usbmux/usbmux.py
python
USBMux.connect
(self)
Opens a connection to the USBMux daemon on the local machine. :func:`connect_to_usbmux` provides a convenient wrapper to this method.
Opens a connection to the USBMux daemon on the local machine.
[ "Opens", "a", "connection", "to", "the", "USBMux", "daemon", "on", "the", "local", "machine", "." ]
async def connect(self): '''Opens a connection to the USBMux daemon on the local machine. :func:`connect_to_usbmux` provides a convenient wrapper to this method. ''' self._waiter = asyncio.Future(loop=self.loop) await self._connect_transport(lambda: self) await self._waiter
[ "async", "def", "connect", "(", "self", ")", ":", "self", ".", "_waiter", "=", "asyncio", ".", "Future", "(", "loop", "=", "self", ".", "loop", ")", "await", "self", ".", "_connect_transport", "(", "lambda", ":", "self", ")", "await", "self", ".", "_...
https://github.com/anki/cozmo-python-sdk/blob/dd29edef18748fcd816550469195323842a7872e/src/cozmo/usbmux/usbmux.py#L196-L203
tensorflow/models
6b8bb0cbeb3e10415c7a87448f08adc3c484c1d3
official/legacy/image_classification/resnet/imagenet_preprocessing.py
python
_resize_image
(image, height, width)
return tf.compat.v1.image.resize( image, [height, width], method=tf.image.ResizeMethod.BILINEAR, align_corners=False)
Simple wrapper around tf.resize_images. This is primarily to make sure we use the same `ResizeMethod` and other details each time. Args: image: A 3-D image `Tensor`. height: The target height for the resized image. width: The target width for the resized image. Returns: resized_image: A 3-D tensor containing the resized image. The first two dimensions have the shape [height, width].
Simple wrapper around tf.resize_images.
[ "Simple", "wrapper", "around", "tf", ".", "resize_images", "." ]
def _resize_image(image, height, width): """Simple wrapper around tf.resize_images. This is primarily to make sure we use the same `ResizeMethod` and other details each time. Args: image: A 3-D image `Tensor`. height: The target height for the resized image. width: The target width for the resized image. Returns: resized_image: A 3-D tensor containing the resized image. The first two dimensions have the shape [height, width]. """ return tf.compat.v1.image.resize( image, [height, width], method=tf.image.ResizeMethod.BILINEAR, align_corners=False)
[ "def", "_resize_image", "(", "image", ",", "height", ",", "width", ")", ":", "return", "tf", ".", "compat", ".", "v1", ".", "image", ".", "resize", "(", "image", ",", "[", "height", ",", "width", "]", ",", "method", "=", "tf", ".", "image", ".", ...
https://github.com/tensorflow/models/blob/6b8bb0cbeb3e10415c7a87448f08adc3c484c1d3/official/legacy/image_classification/resnet/imagenet_preprocessing.py#L515-L533
django-cumulus/django-cumulus
64feb07b857af28f226be4899e875c29405e261d
cumulus/context_processors.py
python
static_cdn_url
(request)
return { "STATIC_URL": cdn_url + static_url, "STATIC_SSL_URL": ssl_url + static_url, "LOCAL_STATIC_URL": static_url, }
A context processor that exposes the full static CDN URL as static URL in templates.
A context processor that exposes the full static CDN URL as static URL in templates.
[ "A", "context", "processor", "that", "exposes", "the", "full", "static", "CDN", "URL", "as", "static", "URL", "in", "templates", "." ]
def static_cdn_url(request): """ A context processor that exposes the full static CDN URL as static URL in templates. """ cdn_url, ssl_url = _get_container_urls(CumulusStaticStorage()) static_url = settings.STATIC_URL return { "STATIC_URL": cdn_url + static_url, "STATIC_SSL_URL": ssl_url + static_url, "LOCAL_STATIC_URL": static_url, }
[ "def", "static_cdn_url", "(", "request", ")", ":", "cdn_url", ",", "ssl_url", "=", "_get_container_urls", "(", "CumulusStaticStorage", "(", ")", ")", "static_url", "=", "settings", ".", "STATIC_URL", "return", "{", "\"STATIC_URL\"", ":", "cdn_url", "+", "static_...
https://github.com/django-cumulus/django-cumulus/blob/64feb07b857af28f226be4899e875c29405e261d/cumulus/context_processors.py#L32-L44
IronLanguages/ironpython3
7a7bb2a872eeab0d1009fc8a6e24dca43f65b693
Src/StdLib/Lib/encodings/uu_codec.py
python
uu_decode
(input, errors='strict')
return (outfile.getvalue(), len(input))
[]
def uu_decode(input, errors='strict'): assert errors == 'strict' infile = BytesIO(input) outfile = BytesIO() readline = infile.readline write = outfile.write # Find start of encoded data while 1: s = readline() if not s: raise ValueError('Missing "begin" line in input data') if s[:5] == b'begin': break # Decode while True: s = readline() if not s or s == b'end\n': break try: data = binascii.a2b_uu(s) except binascii.Error as v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((s[0]-32) & 63) * 4 + 5) // 3 data = binascii.a2b_uu(s[:nbytes]) #sys.stderr.write("Warning: %s\n" % str(v)) write(data) if not s: raise ValueError('Truncated input data') return (outfile.getvalue(), len(input))
[ "def", "uu_decode", "(", "input", ",", "errors", "=", "'strict'", ")", ":", "assert", "errors", "==", "'strict'", "infile", "=", "BytesIO", "(", "input", ")", "outfile", "=", "BytesIO", "(", ")", "readline", "=", "infile", ".", "readline", "write", "=", ...
https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/encodings/uu_codec.py#L33-L64
IJDykeman/wangTiles
7c1ee2095ebdf7f72bce07d94c6484915d5cae8b
experimental_code/tiles_3d/venv_mac_py3/lib/python2.7/site-packages/setuptools/depends.py
python
_update_globals
()
Patch the globals to remove the objects not available on some platforms. XXX it'd be better to test assertions about bytecode instead.
Patch the globals to remove the objects not available on some platforms.
[ "Patch", "the", "globals", "to", "remove", "the", "objects", "not", "available", "on", "some", "platforms", "." ]
def _update_globals(): """ Patch the globals to remove the objects not available on some platforms. XXX it'd be better to test assertions about bytecode instead. """ if not sys.platform.startswith('java') and sys.platform != 'cli': return incompatible = 'extract_constant', 'get_module_constant' for name in incompatible: del globals()[name] __all__.remove(name)
[ "def", "_update_globals", "(", ")", ":", "if", "not", "sys", ".", "platform", ".", "startswith", "(", "'java'", ")", "and", "sys", ".", "platform", "!=", "'cli'", ":", "return", "incompatible", "=", "'extract_constant'", ",", "'get_module_constant'", "for", ...
https://github.com/IJDykeman/wangTiles/blob/7c1ee2095ebdf7f72bce07d94c6484915d5cae8b/experimental_code/tiles_3d/venv_mac_py3/lib/python2.7/site-packages/setuptools/depends.py#L171-L183
chdsbd/kodiak
4c705cea8edaa2792f2a59700a2f7c3d75b6e918
bot/kodiak/dependencies.py
python
compare_match_type
(a: MatchType | None, b: MatchType | None)
return match_rank[a] > match_rank[b]
[]
def compare_match_type(a: MatchType | None, b: MatchType | None) -> bool: return match_rank[a] > match_rank[b]
[ "def", "compare_match_type", "(", "a", ":", "MatchType", "|", "None", ",", "b", ":", "MatchType", "|", "None", ")", "->", "bool", ":", "return", "match_rank", "[", "a", "]", ">", "match_rank", "[", "b", "]" ]
https://github.com/chdsbd/kodiak/blob/4c705cea8edaa2792f2a59700a2f7c3d75b6e918/bot/kodiak/dependencies.py#L99-L100
osmr/imgclsmob
f2993d3ce73a2f7ddba05da3891defb08547d504
gluon/model_stats.py
python
measure_model
(model, in_shapes, ctx=mx.cpu())
return num_flops, num_macs, num_params1
Calculate model statistics. Parameters: ---------- model : HybridBlock Tested model. in_shapes : list of tuple of ints Shapes of the input tensors. ctx : Context, default CPU The context in which to load the pretrained weights.
Calculate model statistics.
[ "Calculate", "model", "statistics", "." ]
def measure_model(model, in_shapes, ctx=mx.cpu()): """ Calculate model statistics. Parameters: ---------- model : HybridBlock Tested model. in_shapes : list of tuple of ints Shapes of the input tensors. ctx : Context, default CPU The context in which to load the pretrained weights. """ global num_flops global num_macs global num_params global names num_flops = 0 num_macs = 0 num_params = 0 names = {} def call_hook(block, x, y): if not (isinstance(block, IRevSplitBlock) or isinstance(block, IRevMergeBlock) or isinstance(block, RiRFinalBlock) or isinstance(block, InterpolationBlock) or isinstance(block, MaskConv1d) or isinstance(block, NemoMelSpecExtractor)): assert (len(x) == 1) assert (len(block._children) == 0) if isinstance(block, nn.Dense): batch = x[0].shape[0] in_units = block._in_units out_units = block._units extra_num_macs = in_units * out_units if block.bias is None: extra_num_flops = (2 * in_units - 1) * out_units else: extra_num_flops = 2 * in_units * out_units extra_num_flops *= batch extra_num_macs *= batch elif isinstance(block, nn.Activation): if block._act_type == "relu": extra_num_flops = x[0].size extra_num_macs = 0 elif block._act_type == "sigmoid": extra_num_flops = 4 * x[0].size extra_num_macs = 0 else: raise TypeError("Unknown activation type: {}".format(block._act_type)) elif isinstance(block, nn.ELU): extra_num_flops = 3 * x[0].size extra_num_macs = 0 elif isinstance(block, nn.LeakyReLU): extra_num_flops = 2 * x[0].size extra_num_macs = 0 elif isinstance(block, ReLU6): extra_num_flops = x[0].size extra_num_macs = 0 elif isinstance(block, PReLU2): extra_num_flops = 3 * x[0].size extra_num_macs = 0 elif isinstance(block, nn.Swish): extra_num_flops = 5 * x[0].size extra_num_macs = 0 elif isinstance(block, HSigmoid): extra_num_flops = x[0].size extra_num_macs = 0 elif isinstance(block, HSwish): extra_num_flops = 2 * x[0].size extra_num_macs = 0 elif type(block) in [nn.Conv2DTranspose]: extra_num_flops = 4 * x[0].size extra_num_macs = 0 elif isinstance(block, nn.Conv2D): batch = x[0].shape[0] x_h = x[0].shape[2] x_w = x[0].shape[3] kernel_size = block._kwargs["kernel"] strides = block._kwargs["stride"] dilation = block._kwargs["dilate"] padding = block._kwargs["pad"] groups = block._kwargs["num_group"] in_channels = block._in_channels out_channels = block._channels y_h = (x_h + 2 * padding[0] - dilation[0] * (kernel_size[0] - 1) - 1) // strides[0] + 1 y_w = (x_w + 2 * padding[1] - dilation[1] * (kernel_size[1] - 1) - 1) // strides[1] + 1 assert (out_channels == y.shape[1]) assert (y_h == y.shape[2]) assert (y_w == y.shape[3]) kernel_total_size = kernel_size[0] * kernel_size[1] y_size = y_h * y_w extra_num_macs = kernel_total_size * in_channels * y_size * out_channels // groups if block.bias is None: extra_num_flops = (2 * kernel_total_size * y_size - 1) * in_channels * out_channels // groups else: extra_num_flops = 2 * kernel_total_size * in_channels * y_size * out_channels // groups extra_num_flops *= batch extra_num_macs *= batch elif isinstance(block, nn.BatchNorm): extra_num_flops = 4 * x[0].size extra_num_macs = 0 elif isinstance(block, nn.InstanceNorm): extra_num_flops = 4 * x[0].size extra_num_macs = 0 elif type(block) in [nn.MaxPool2D, nn.AvgPool2D, nn.GlobalAvgPool2D, nn.GlobalMaxPool2D]: batch = x[0].shape[0] assert (x[0].shape[1] == y.shape[1]) pool_size = block._kwargs["kernel"] y_h = y.shape[2] y_w = y.shape[3] channels = x[0].shape[1] y_size = y_h * y_w pool_total_size = pool_size[0] * pool_size[1] extra_num_flops = channels * y_size * pool_total_size extra_num_macs = 0 extra_num_flops *= batch extra_num_macs *= batch elif isinstance(block, nn.Dropout): extra_num_flops = 0 extra_num_macs = 0 elif type(block) in [nn.Flatten]: extra_num_flops = 0 extra_num_macs = 0 elif isinstance(block, nn.HybridSequential): assert (len(block._children) == 0) extra_num_flops = 0 extra_num_macs = 0 elif type(block) in [ChannelShuffle, ChannelShuffle2]: extra_num_flops = x[0].size extra_num_macs = 0 elif isinstance(block, Identity): extra_num_flops = 0 extra_num_macs = 0 elif isinstance(block, PixelShuffle2D): extra_num_flops = x[0].size extra_num_macs = 0 elif isinstance(block, ChannelSqueeze): extra_num_flops = x[0].size extra_num_macs = 0 elif isinstance(block, IRevDownscale): extra_num_flops = 5 * x[0].size extra_num_macs = 0 elif isinstance(block, IRevSplitBlock): extra_num_flops = x[0].size extra_num_macs = 0 elif isinstance(block, IRevMergeBlock): extra_num_flops = x[0].size extra_num_macs = 0 elif isinstance(block, RiRFinalBlock): extra_num_flops = x[0].size extra_num_macs = 0 elif isinstance(block, ProxylessUnit): extra_num_flops = x[0].size extra_num_macs = 0 elif type(block) in [MaskConv1d, nn.Conv1D]: if isinstance(y, tuple): assert isinstance(block, MaskConv1d) y = y[0] batch = x[0].shape[0] x_h = x[0].shape[2] kernel_size = block._kwargs["kernel"] strides = block._kwargs["stride"] dilation = block._kwargs["dilate"] padding = block._kwargs["pad"] groups = block._kwargs["num_group"] in_channels = block._in_channels out_channels = block._channels y_h = (x_h + 2 * padding[0] - dilation[0] * (kernel_size[0] - 1) - 1) // strides[0] + 1 assert (out_channels == y.shape[1]) assert (y_h == y.shape[2]) kernel_total_size = kernel_size[0] y_size = y_h extra_num_macs = kernel_total_size * in_channels * y_size * out_channels // groups if block.bias is None: extra_num_flops = (2 * kernel_total_size * y_size - 1) * in_channels * out_channels // groups else: extra_num_flops = 2 * kernel_total_size * in_channels * y_size * out_channels // groups extra_num_flops *= batch extra_num_macs *= batch elif type(block) in [InterpolationBlock, HeatmapMaxDetBlock, CenterNetHeatmapMaxDet, ScaleBlock, NemoMelSpecExtractor]: extra_num_flops, extra_num_macs = block.calc_flops(x[0]) elif isinstance(block, LwopDecoderFinalBlock): if not block.calc_3d_features: extra_num_flops = 0 extra_num_macs = 0 else: raise TypeError("LwopDecoderFinalBlock!") else: raise TypeError("Unknown layer type: {}".format(type(block))) global num_flops global num_macs global num_params global names num_flops += extra_num_flops num_macs += extra_num_macs if block.name not in names: names[block.name] = 1 num_params += calc_block_num_params(block) def register_forward_hooks(a_block): if len(a_block._children) > 0: assert (calc_block_num_params(a_block) == 0) children_handles = [] for child_block in a_block._children.values(): child_handles = register_forward_hooks(child_block) children_handles += child_handles return children_handles else: handle = a_block.register_forward_hook(call_hook) return [handle] hook_handles = register_forward_hooks(model) if len(in_shapes) == 1: x = mx.nd.zeros(in_shapes[0], ctx=ctx) model(x) elif len(in_shapes) == 2: x1 = mx.nd.zeros(in_shapes[0], ctx=ctx) x2 = mx.nd.zeros(in_shapes[1], ctx=ctx) model(x1, x2) else: raise NotImplementedError() num_params1 = calc_block_num_params2(model) if num_params != num_params1: logging.warning( "Calculated numbers of parameters are different: standard method: {},\tper-leaf method: {}".format( num_params1, num_params)) [h.detach() for h in hook_handles] return num_flops, num_macs, num_params1
[ "def", "measure_model", "(", "model", ",", "in_shapes", ",", "ctx", "=", "mx", ".", "cpu", "(", ")", ")", ":", "global", "num_flops", "global", "num_macs", "global", "num_params", "global", "names", "num_flops", "=", "0", "num_macs", "=", "0", "num_params"...
https://github.com/osmr/imgclsmob/blob/f2993d3ce73a2f7ddba05da3891defb08547d504/gluon/model_stats.py#L69-L303
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/core/ext-py/Django-1.11.29/django/contrib/admin/options.py
python
BaseModelAdmin.get_queryset
(self, request)
return qs
Returns a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
Returns a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
[ "Returns", "a", "QuerySet", "of", "all", "model", "instances", "that", "can", "be", "edited", "by", "the", "admin", "site", ".", "This", "is", "used", "by", "changelist_view", "." ]
def get_queryset(self, request): """ Returns a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view. """ qs = self.model._default_manager.get_queryset() # TODO: this should be handled by some parameter to the ChangeList. ordering = self.get_ordering(request) if ordering: qs = qs.order_by(*ordering) return qs
[ "def", "get_queryset", "(", "self", ",", "request", ")", ":", "qs", "=", "self", ".", "model", ".", "_default_manager", ".", "get_queryset", "(", ")", "# TODO: this should be handled by some parameter to the ChangeList.", "ordering", "=", "self", ".", "get_ordering", ...
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/Django-1.11.29/django/contrib/admin/options.py#L325-L335
awslabs/aws-lambda-powertools-python
0c6ac0fe183476140ee1df55fe9fa1cc20925577
aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py
python
PreSignUpTriggerEventResponse.auto_confirm_user
(self, value: bool)
Set to true to auto-confirm the user, or false otherwise.
Set to true to auto-confirm the user, or false otherwise.
[ "Set", "to", "true", "to", "auto", "-", "confirm", "the", "user", "or", "false", "otherwise", "." ]
def auto_confirm_user(self, value: bool): """Set to true to auto-confirm the user, or false otherwise.""" self["response"]["autoConfirmUser"] = value
[ "def", "auto_confirm_user", "(", "self", ",", "value", ":", "bool", ")", ":", "self", "[", "\"response\"", "]", "[", "\"autoConfirmUser\"", "]", "=", "value" ]
https://github.com/awslabs/aws-lambda-powertools-python/blob/0c6ac0fe183476140ee1df55fe9fa1cc20925577/aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py#L81-L83
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/wagtail_bak/contrib/postgres_search/backend.py
python
PostgresSearchRebuilder.start
(self)
return self.index
[]
def start(self): self.index.delete_stale_entries() return self.index
[ "def", "start", "(", "self", ")", ":", "self", ".", "index", ".", "delete_stale_entries", "(", ")", "return", "self", ".", "index" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/wagtail_bak/contrib/postgres_search/backend.py#L305-L307
flaskbb/flaskbb
de13a37fcb713b9c627632210ab9a7bb980d591f
flaskbb/user/models.py
python
User.ban
(self)
return False
Bans the user. Returns True upon success.
Bans the user. Returns True upon success.
[ "Bans", "the", "user", ".", "Returns", "True", "upon", "success", "." ]
def ban(self): """Bans the user. Returns True upon success.""" if not self.get_permissions()['banned']: banned_group = Group.query.filter( Group.banned == True ).first() self.primary_group = banned_group self.save() self.invalidate_cache() return True return False
[ "def", "ban", "(", "self", ")", ":", "if", "not", "self", ".", "get_permissions", "(", ")", "[", "'banned'", "]", ":", "banned_group", "=", "Group", ".", "query", ".", "filter", "(", "Group", ".", "banned", "==", "True", ")", ".", "first", "(", ")"...
https://github.com/flaskbb/flaskbb/blob/de13a37fcb713b9c627632210ab9a7bb980d591f/flaskbb/user/models.py#L409-L420
HoloClean/holoclean
d4f5929a8e4d92d4f41eb058c04c96cdcb0af767
dataset/dbengine.py
python
_execute_query
(args, conn_args)
return res
[]
def _execute_query(args, conn_args): query_id = args[0] query = args[1] logging.debug("Starting to execute query %s with id %s", query, query_id) tic = time.clock() con = psycopg2.connect(conn_args) cur = con.cursor() cur.execute(query) res = cur.fetchall() con.close() toc = time.clock() logging.debug('Time to execute query with id %d: %.2f secs', query_id, (toc - tic)) return res
[ "def", "_execute_query", "(", "args", ",", "conn_args", ")", ":", "query_id", "=", "args", "[", "0", "]", "query", "=", "args", "[", "1", "]", "logging", ".", "debug", "(", "\"Starting to execute query %s with id %s\"", ",", "query", ",", "query_id", ")", ...
https://github.com/HoloClean/holoclean/blob/d4f5929a8e4d92d4f41eb058c04c96cdcb0af767/dataset/dbengine.py#L112-L124
dcramer/django-sphinx
0071d1cae5390d0ec8c669786ca3c7275abb6410
djangosphinx/apis/api278/__init__.py
python
SphinxClient._GetResponse
(self, sock, client_ver)
return response
INTERNAL METHOD, DO NOT CALL. Gets and checks response packet from searchd server.
INTERNAL METHOD, DO NOT CALL. Gets and checks response packet from searchd server.
[ "INTERNAL", "METHOD", "DO", "NOT", "CALL", ".", "Gets", "and", "checks", "response", "packet", "from", "searchd", "server", "." ]
def _GetResponse (self, sock, client_ver): """ INTERNAL METHOD, DO NOT CALL. Gets and checks response packet from searchd server. """ (status, ver, length) = unpack('>2HL', sock.recv(8)) response = '' left = length while left>0: chunk = sock.recv(left) if chunk: response += chunk left -= len(chunk) else: break if not self._socket: sock.close() # check response read = len(response) if not response or read!=length: if length: self._error = 'failed to read searchd response (status=%s, ver=%s, len=%s, read=%s)' \ % (status, ver, length, read) else: self._error = 'received zero-sized searchd response' return None # check status if status==SEARCHD_WARNING: wend = 4 + unpack ( '>L', response[0:4] )[0] self._warning = response[4:wend] return response[wend:] if status==SEARCHD_ERROR: self._error = 'searchd error: '+response[4:] return None if status==SEARCHD_RETRY: self._error = 'temporary searchd error: '+response[4:] return None if status!=SEARCHD_OK: self._error = 'unknown status code %d' % status return None # check version if ver<client_ver: self._warning = 'searchd command v.%d.%d older than client\'s v.%d.%d, some options might not work' \ % (ver>>8, ver&0xff, client_ver>>8, client_ver&0xff) return response
[ "def", "_GetResponse", "(", "self", ",", "sock", ",", "client_ver", ")", ":", "(", "status", ",", "ver", ",", "length", ")", "=", "unpack", "(", "'>2HL'", ",", "sock", ".", "recv", "(", "8", ")", ")", "response", "=", "''", "left", "=", "length", ...
https://github.com/dcramer/django-sphinx/blob/0071d1cae5390d0ec8c669786ca3c7275abb6410/djangosphinx/apis/api278/__init__.py#L216-L267
django-wiki/django-wiki
9b05df98b7f1ca24683ff181abe5147c3a2fed86
src/wiki/core/plugins/registry.py
python
get_sidebar
()
return _sidebar
Returns plugin classes that should connect to the sidebar
Returns plugin classes that should connect to the sidebar
[ "Returns", "plugin", "classes", "that", "should", "connect", "to", "the", "sidebar" ]
def get_sidebar(): """Returns plugin classes that should connect to the sidebar""" return _sidebar
[ "def", "get_sidebar", "(", ")", ":", "return", "_sidebar" ]
https://github.com/django-wiki/django-wiki/blob/9b05df98b7f1ca24683ff181abe5147c3a2fed86/src/wiki/core/plugins/registry.py#L59-L61
pandas-dev/pandas
5ba7d714014ae8feaccc0dd4a98890828cf2832d
pandas/io/formats/css.py
python
CSSResolver.parse
(self, declarations_str: str)
Generates (prop, value) pairs from declarations. In a future version may generate parsed tokens from tinycss/tinycss2 Parameters ---------- declarations_str : str
Generates (prop, value) pairs from declarations.
[ "Generates", "(", "prop", "value", ")", "pairs", "from", "declarations", "." ]
def parse(self, declarations_str: str): """ Generates (prop, value) pairs from declarations. In a future version may generate parsed tokens from tinycss/tinycss2 Parameters ---------- declarations_str : str """ for decl in declarations_str.split(";"): if not decl.strip(): continue prop, sep, val = decl.partition(":") prop = prop.strip().lower() # TODO: don't lowercase case sensitive parts of values (strings) val = val.strip().lower() if sep: yield prop, val else: warnings.warn( f"Ill-formatted attribute: expected a colon in {repr(decl)}", CSSWarning, )
[ "def", "parse", "(", "self", ",", "declarations_str", ":", "str", ")", ":", "for", "decl", "in", "declarations_str", ".", "split", "(", "\";\"", ")", ":", "if", "not", "decl", ".", "strip", "(", ")", ":", "continue", "prop", ",", "sep", ",", "val", ...
https://github.com/pandas-dev/pandas/blob/5ba7d714014ae8feaccc0dd4a98890828cf2832d/pandas/io/formats/css.py#L264-L287
mchristopher/PokemonGo-DesktopMap
ec37575f2776ee7d64456e2a1f6b6b78830b4fe0
app/pywin/Lib/logging/__init__.py
python
Logger.warning
(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'WARNING'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.warning("Houston, we have a %s", "bit of a problem", exc_info=1)
Log 'msg % args' with severity 'WARNING'.
[ "Log", "msg", "%", "args", "with", "severity", "WARNING", "." ]
def warning(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'WARNING'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.warning("Houston, we have a %s", "bit of a problem", exc_info=1) """ if self.isEnabledFor(WARNING): self._log(WARNING, msg, args, **kwargs)
[ "def", "warning", "(", "self", ",", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "isEnabledFor", "(", "WARNING", ")", ":", "self", ".", "_log", "(", "WARNING", ",", "msg", ",", "args", ",", "*", "*", "kwargs", ...
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/ec37575f2776ee7d64456e2a1f6b6b78830b4fe0/app/pywin/Lib/logging/__init__.py#L1169-L1179
pypa/pipenv
b21baade71a86ab3ee1429f71fbc14d4f95fb75d
pipenv/patched/notpip/_vendor/resolvelib/structs.py
python
IteratorMapping.__repr__
(self)
return "IteratorMapping({!r}, {!r}, {!r})".format( self._mapping, self._accessor, self._appends, )
[]
def __repr__(self): return "IteratorMapping({!r}, {!r}, {!r})".format( self._mapping, self._accessor, self._appends, )
[ "def", "__repr__", "(", "self", ")", ":", "return", "\"IteratorMapping({!r}, {!r}, {!r})\"", ".", "format", "(", "self", ".", "_mapping", ",", "self", ".", "_accessor", ",", "self", ".", "_appends", ",", ")" ]
https://github.com/pypa/pipenv/blob/b21baade71a86ab3ee1429f71fbc14d4f95fb75d/pipenv/patched/notpip/_vendor/resolvelib/structs.py#L78-L83
LinOTP/LinOTP
bb3940bbaccea99550e6c063ff824f258dd6d6d7
linotp/controllers/monitoring.py
python
MonitoringController.userinfo
(self)
method: monitoring/userinfo description: for each realm, display the resolvers and the number of users per resolver arguments: * realms - optional: takes a realm, only information on this realm will be displayed returns: a json result with: { "head": [], "data": [ [row1], [row2] .. ] }
method: monitoring/userinfo
[ "method", ":", "monitoring", "/", "userinfo" ]
def userinfo(self): """ method: monitoring/userinfo description: for each realm, display the resolvers and the number of users per resolver arguments: * realms - optional: takes a realm, only information on this realm will be displayed returns: a json result with: { "head": [], "data": [ [row1], [row2] .. ] } """ result = {} try: request_realms = self.request_params.get("realms", "").split(",") monit_handler = MonitorHandler() policies = getAdminPolicies("userinfo", scope="monitoring") realm_whitelist = [] if policies["active"] and policies["realms"]: realm_whitelist = policies.get("realms") # if there are no policies for us, we are allowed to see all realms if not realm_whitelist or "*" in realm_whitelist: realm_whitelist = list(request_context["Realms"].keys()) realms = match_realms(request_realms, realm_whitelist) if "/:no realm:/" in realms: realms.remove("/:no realm:/") realm_info = {} for a_realm in realms: realm_info[a_realm] = monit_handler.resolverinfo(a_realm) result["Realms"] = realm_info db.session.commit() return sendResult(response, result) except PolicyException as policy_exception: log.error(policy_exception) db.session.rollback() return sendError(response, policy_exception, 1) except Exception as exc: log.error(exc) db.session.rollback() return sendError(response, exc)
[ "def", "userinfo", "(", "self", ")", ":", "result", "=", "{", "}", "try", ":", "request_realms", "=", "self", ".", "request_params", ".", "get", "(", "\"realms\"", ",", "\"\"", ")", ".", "split", "(", "\",\"", ")", "monit_handler", "=", "MonitorHandler",...
https://github.com/LinOTP/LinOTP/blob/bb3940bbaccea99550e6c063ff824f258dd6d6d7/linotp/controllers/monitoring.py#L314-L372
pymedusa/Medusa
1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38
ext/boto/dynamodb2/table.py
python
Table.delete_item
(self, expected=None, conditional_operator=None, **kwargs)
return True
Deletes a single item. You can perform a conditional delete operation that deletes the item if it exists, or if it has an expected attribute value. Conditional deletes are useful for only deleting items if specific conditions are met. If those conditions are met, DynamoDB performs the delete. Otherwise, the item is not deleted. To specify the expected attribute values of the item, you can pass a dictionary of conditions to ``expected``. Each condition should follow the pattern ``<attributename>__<comparison_operator>=<value_to_expect>``. **IMPORTANT** - Be careful when using this method, there is no undo. To specify the key of the item you'd like to get, you can specify the key attributes as kwargs. Optionally accepts an ``expected`` parameter which is a dictionary of expected attribute value conditions. Optionally accepts a ``conditional_operator`` which applies to the expected attribute value conditions: + `AND` - If all of the conditions evaluate to true (default) + `OR` - True if at least one condition evaluates to true Returns ``True`` on success, ``False`` on failed conditional delete. Example:: # A simple hash key. >>> users.delete_item(username='johndoe') True # A complex hash+range key. >>> users.delete_item(username='jane', last_name='Doe') True # With a key that is an invalid variable name in Python. # Also, assumes a different schema than previous examples. >>> users.delete_item(**{ ... 'date-joined': 127549192, ... }) True # Conditional delete >>> users.delete_item(username='johndoe', ... expected={'balance__eq': 0}) True
Deletes a single item. You can perform a conditional delete operation that deletes the item if it exists, or if it has an expected attribute value.
[ "Deletes", "a", "single", "item", ".", "You", "can", "perform", "a", "conditional", "delete", "operation", "that", "deletes", "the", "item", "if", "it", "exists", "or", "if", "it", "has", "an", "expected", "attribute", "value", "." ]
def delete_item(self, expected=None, conditional_operator=None, **kwargs): """ Deletes a single item. You can perform a conditional delete operation that deletes the item if it exists, or if it has an expected attribute value. Conditional deletes are useful for only deleting items if specific conditions are met. If those conditions are met, DynamoDB performs the delete. Otherwise, the item is not deleted. To specify the expected attribute values of the item, you can pass a dictionary of conditions to ``expected``. Each condition should follow the pattern ``<attributename>__<comparison_operator>=<value_to_expect>``. **IMPORTANT** - Be careful when using this method, there is no undo. To specify the key of the item you'd like to get, you can specify the key attributes as kwargs. Optionally accepts an ``expected`` parameter which is a dictionary of expected attribute value conditions. Optionally accepts a ``conditional_operator`` which applies to the expected attribute value conditions: + `AND` - If all of the conditions evaluate to true (default) + `OR` - True if at least one condition evaluates to true Returns ``True`` on success, ``False`` on failed conditional delete. Example:: # A simple hash key. >>> users.delete_item(username='johndoe') True # A complex hash+range key. >>> users.delete_item(username='jane', last_name='Doe') True # With a key that is an invalid variable name in Python. # Also, assumes a different schema than previous examples. >>> users.delete_item(**{ ... 'date-joined': 127549192, ... }) True # Conditional delete >>> users.delete_item(username='johndoe', ... expected={'balance__eq': 0}) True """ expected = self._build_filters(expected, using=FILTER_OPERATORS) raw_key = self._encode_keys(kwargs) try: self.connection.delete_item(self.table_name, raw_key, expected=expected, conditional_operator=conditional_operator) except exceptions.ConditionalCheckFailedException: return False return True
[ "def", "delete_item", "(", "self", ",", "expected", "=", "None", ",", "conditional_operator", "=", "None", ",", "*", "*", "kwargs", ")", ":", "expected", "=", "self", ".", "_build_filters", "(", "expected", ",", "using", "=", "FILTER_OPERATORS", ")", "raw_...
https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/ext/boto/dynamodb2/table.py#L855-L917
FederatedAI/FATE
32540492623568ecd1afcb367360133616e02fa3
python/federatedml/util/conversion.py
python
bytes_to_bin
(bytes_arr)
return bin_compensate(res)
Convert bytes to a binary number :param bytes_arr: :return: str, whose length must be a multiple of 8
Convert bytes to a binary number :param bytes_arr: :return: str, whose length must be a multiple of 8
[ "Convert", "bytes", "to", "a", "binary", "number", ":", "param", "bytes_arr", ":", ":", "return", ":", "str", "whose", "length", "must", "be", "a", "multiple", "of", "8" ]
def bytes_to_bin(bytes_arr): """ Convert bytes to a binary number :param bytes_arr: :return: str, whose length must be a multiple of 8 """ res = bin(bytes_to_int(bytes_arr))[2:] return bin_compensate(res)
[ "def", "bytes_to_bin", "(", "bytes_arr", ")", ":", "res", "=", "bin", "(", "bytes_to_int", "(", "bytes_arr", ")", ")", "[", "2", ":", "]", "return", "bin_compensate", "(", "res", ")" ]
https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/federatedml/util/conversion.py#L41-L48
usnistgov/fipy
6809b180b41a11de988a48655575df7e142c93b9
fipy/solvers/trilinos/linearPCGSolver.py
python
LinearPCGSolver.__init__
(self, tolerance=1e-10, iterations=1000, precon=MultilevelDDPreconditioner())
Parameters ---------- tolerance : float Required error tolerance. iterations : int Maximum number of iterative steps to perform. precon : ~fipy.solvers.trilinos.preconditioners.preconditioner.Preconditioner
Parameters ---------- tolerance : float Required error tolerance. iterations : int Maximum number of iterative steps to perform. precon : ~fipy.solvers.trilinos.preconditioners.preconditioner.Preconditioner
[ "Parameters", "----------", "tolerance", ":", "float", "Required", "error", "tolerance", ".", "iterations", ":", "int", "Maximum", "number", "of", "iterative", "steps", "to", "perform", ".", "precon", ":", "~fipy", ".", "solvers", ".", "trilinos", ".", "precon...
def __init__(self, tolerance=1e-10, iterations=1000, precon=MultilevelDDPreconditioner()): """ Parameters ---------- tolerance : float Required error tolerance. iterations : int Maximum number of iterative steps to perform. precon : ~fipy.solvers.trilinos.preconditioners.preconditioner.Preconditioner """ TrilinosAztecOOSolver.__init__(self, tolerance=tolerance, iterations=iterations, precon=precon) self.solver = AztecOO.AZ_cg
[ "def", "__init__", "(", "self", ",", "tolerance", "=", "1e-10", ",", "iterations", "=", "1000", ",", "precon", "=", "MultilevelDDPreconditioner", "(", ")", ")", ":", "TrilinosAztecOOSolver", ".", "__init__", "(", "self", ",", "tolerance", "=", "tolerance", "...
https://github.com/usnistgov/fipy/blob/6809b180b41a11de988a48655575df7e142c93b9/fipy/solvers/trilinos/linearPCGSolver.py#L21-L33
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/libs/gap/assigned_names.py
python
list_globals
()
return tuple(sorted(gvars))
Return the GAP reserved keywords OUTPUT: Tuple of strings. EXAMPLES:: sage: from sage.libs.gap.assigned_names import GLOBALS sage: 'ZassenhausIntersection' in GLOBALS # indirect doctest True
Return the GAP reserved keywords
[ "Return", "the", "GAP", "reserved", "keywords" ]
def list_globals(): """ Return the GAP reserved keywords OUTPUT: Tuple of strings. EXAMPLES:: sage: from sage.libs.gap.assigned_names import GLOBALS sage: 'ZassenhausIntersection' in GLOBALS # indirect doctest True """ gvars = set( name.sage() for name in NamesGVars() if IsBoundGlobal(name) ) gvars.difference_update(KEYWORDS) return tuple(sorted(gvars))
[ "def", "list_globals", "(", ")", ":", "gvars", "=", "set", "(", "name", ".", "sage", "(", ")", "for", "name", "in", "NamesGVars", "(", ")", "if", "IsBoundGlobal", "(", "name", ")", ")", "gvars", ".", "difference_update", "(", "KEYWORDS", ")", "return",...
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/libs/gap/assigned_names.py#L94-L113
ethereum/py-evm
026ee20f8d9b70d7c1b6a4fb9484d5489d425e54
eth/db/account.py
python
AccountDB._get_access_list
(self)
Get the list of addresses that were accessed, whether the bytecode was accessed, and which storage slots were accessed.
Get the list of addresses that were accessed, whether the bytecode was accessed, and which storage slots were accessed.
[ "Get", "the", "list", "of", "addresses", "that", "were", "accessed", "whether", "the", "bytecode", "was", "accessed", "and", "which", "storage", "slots", "were", "accessed", "." ]
def _get_access_list(self) -> Iterable[Tuple[Address, AccountQueryTracker]]: """ Get the list of addresses that were accessed, whether the bytecode was accessed, and which storage slots were accessed. """ for address in self._accessed_accounts: did_access_bytecode = address in self._accessed_bytecodes if address in self._account_stores: accessed_storage_slots = self._account_stores[address].get_accessed_slots() else: accessed_storage_slots = frozenset() yield address, AccountQueryTracker(did_access_bytecode, accessed_storage_slots)
[ "def", "_get_access_list", "(", "self", ")", "->", "Iterable", "[", "Tuple", "[", "Address", ",", "AccountQueryTracker", "]", "]", ":", "for", "address", "in", "self", ".", "_accessed_accounts", ":", "did_access_bytecode", "=", "address", "in", "self", ".", ...
https://github.com/ethereum/py-evm/blob/026ee20f8d9b70d7c1b6a4fb9484d5489d425e54/eth/db/account.py#L513-L524
lkiesow/python-feedgen
ffe3e4d752ac76e23c879c35682c310c2b1ccb86
feedgen/entry.py
python
FeedEntry.title
(self, title=None)
return self.__atom_title
Get or set the title value of the entry. It should contain a human readable title for the entry. Title is mandatory for both ATOM and RSS and should not be blank. :param title: The new title of the entry. :returns: The entriess title.
Get or set the title value of the entry. It should contain a human readable title for the entry. Title is mandatory for both ATOM and RSS and should not be blank.
[ "Get", "or", "set", "the", "title", "value", "of", "the", "entry", ".", "It", "should", "contain", "a", "human", "readable", "title", "for", "the", "entry", ".", "Title", "is", "mandatory", "for", "both", "ATOM", "and", "RSS", "and", "should", "not", "...
def title(self, title=None): '''Get or set the title value of the entry. It should contain a human readable title for the entry. Title is mandatory for both ATOM and RSS and should not be blank. :param title: The new title of the entry. :returns: The entriess title. ''' if title is not None: self.__atom_title = title self.__rss_title = title return self.__atom_title
[ "def", "title", "(", "self", ",", "title", "=", "None", ")", ":", "if", "title", "is", "not", "None", ":", "self", ".", "__atom_title", "=", "title", "self", ".", "__rss_title", "=", "title", "return", "self", ".", "__atom_title" ]
https://github.com/lkiesow/python-feedgen/blob/ffe3e4d752ac76e23c879c35682c310c2b1ccb86/feedgen/entry.py#L263-L274
elcodigok/wphardening
634daf3a0b8dcc92484a7775a39abdfa9a846173
lib/checkWordpress.py
python
checkWordpress.isWordPress
(self)
:return: True if successful, False otherwise.
:return: True if successful, False otherwise.
[ ":", "return", ":", "True", "if", "successful", "False", "otherwise", "." ]
def isWordPress(self): """ :return: True if successful, False otherwise. """ value = self.existsFiles() if ((value * 100) / len(self.fileWordPress) > 60): logging.info( self.directory + " This project directory is a WordPress." ) print colored(self.directory, 'yellow') + ' -', \ colored( '\n\tThis project directory is a WordPress.', 'green' ) if self.mode_verbose: self.resumen(value) return True else: logging.error( self.directory + " This Project directory is not a WordPress." ) print colored(self.directory, 'yellow') + ' -', \ colored( '\n\tThis Project directory is not a WordPress.', 'red' ) if self.mode_verbose: self.resumen(value) return False
[ "def", "isWordPress", "(", "self", ")", ":", "value", "=", "self", ".", "existsFiles", "(", ")", "if", "(", "(", "value", "*", "100", ")", "/", "len", "(", "self", ".", "fileWordPress", ")", ">", "60", ")", ":", "logging", ".", "info", "(", "self...
https://github.com/elcodigok/wphardening/blob/634daf3a0b8dcc92484a7775a39abdfa9a846173/lib/checkWordpress.py#L91-L117
OpenEndedGroup/Field
4f7c8edfb01bb0ccc927b78d3c500f018a4ae37c
Contents/lib/python/smtplib.py
python
SMTP.help
(self, args='')
return self.getreply()[1]
SMTP 'help' command. Returns help text from server.
SMTP 'help' command. Returns help text from server.
[ "SMTP", "help", "command", ".", "Returns", "help", "text", "from", "server", "." ]
def help(self, args=''): """SMTP 'help' command. Returns help text from server.""" self.putcmd("help", args) return self.getreply()[1]
[ "def", "help", "(", "self", ",", "args", "=", "''", ")", ":", "self", ".", "putcmd", "(", "\"help\"", ",", "args", ")", "return", "self", ".", "getreply", "(", ")", "[", "1", "]" ]
https://github.com/OpenEndedGroup/Field/blob/4f7c8edfb01bb0ccc927b78d3c500f018a4ae37c/Contents/lib/python/smtplib.py#L445-L449
OpenXenManager/openxenmanager
1cb5c1cb13358ba584856e99a94f9669d17670ff
src/OXM/window_menuitem.py
python
oxcWindowMenuItem.on_menuitem_changepw_activate
(self, widget, data=None)
"Change Server Password" menu item is pressed
"Change Server Password" menu item is pressed
[ "Change", "Server", "Password", "menu", "item", "is", "pressed" ]
def on_menuitem_changepw_activate(self, widget, data=None): """ "Change Server Password" menu item is pressed """ self.builder.get_object("lblwrongpw").hide() self.builder.get_object("changepassword").show() self.builder.get_object("txtcurrentpw").set_text("") self.builder.get_object("txtnewpw").set_text("") self.builder.get_object("txtrenewpw").set_text("") self.builder.get_object("acceptchangepassword").set_sensitive(False) label = self.builder.get_object("lblchangepw").get_label() self.builder.get_object("lblchangepw").set_label(label.replace("{0}", self.selected_name))
[ "def", "on_menuitem_changepw_activate", "(", "self", ",", "widget", ",", "data", "=", "None", ")", ":", "self", ".", "builder", ".", "get_object", "(", "\"lblwrongpw\"", ")", ".", "hide", "(", ")", "self", ".", "builder", ".", "get_object", "(", "\"changep...
https://github.com/OpenXenManager/openxenmanager/blob/1cb5c1cb13358ba584856e99a94f9669d17670ff/src/OXM/window_menuitem.py#L1115-L1126
aiidateam/aiida-core
c743a335480f8bb3a5e4ebd2463a31f9f3b9f9b2
aiida/manage/external/rmq.py
python
get_task_exchange_name
(prefix)
return f'{prefix}.{_TASK_EXCHANGE}'
Return the task exchange name for a given prefix. :returns: task exchange name
Return the task exchange name for a given prefix.
[ "Return", "the", "task", "exchange", "name", "for", "a", "given", "prefix", "." ]
def get_task_exchange_name(prefix): """Return the task exchange name for a given prefix. :returns: task exchange name """ return f'{prefix}.{_TASK_EXCHANGE}'
[ "def", "get_task_exchange_name", "(", "prefix", ")", ":", "return", "f'{prefix}.{_TASK_EXCHANGE}'" ]
https://github.com/aiidateam/aiida-core/blob/c743a335480f8bb3a5e4ebd2463a31f9f3b9f9b2/aiida/manage/external/rmq.py#L114-L119
automl/SMAC3
d4cb7ed76e0fbdd9edf6ab5360ff75de67ac2195
smac/runhistory/runhistory.py
python
RunHistory._cost
( self, config: Configuration, instance_seed_budget_keys: typing.Optional[typing.Iterable[InstSeedBudgetKey]] = None, )
return costs
Return array of all costs for the given config for further calculations. Parameters ---------- config : Configuration Configuration to calculate objective for instance_seed_budget_keys : list, optional (default=None) List of tuples of instance-seeds-budget keys. If None, the run_history is queried for all runs of the given configuration. Returns ------- Costs: list Array of all costs
Return array of all costs for the given config for further calculations.
[ "Return", "array", "of", "all", "costs", "for", "the", "given", "config", "for", "further", "calculations", "." ]
def _cost( self, config: Configuration, instance_seed_budget_keys: typing.Optional[typing.Iterable[InstSeedBudgetKey]] = None, ) -> typing.List[float]: """Return array of all costs for the given config for further calculations. Parameters ---------- config : Configuration Configuration to calculate objective for instance_seed_budget_keys : list, optional (default=None) List of tuples of instance-seeds-budget keys. If None, the run_history is queried for all runs of the given configuration. Returns ------- Costs: list Array of all costs """ try: id_ = self.config_ids[config] except KeyError: # challenger was not running so far return [] if instance_seed_budget_keys is None: instance_seed_budget_keys = self.get_runs_for_config(config, only_max_observed_budget=True) costs = [] for i, r, b in instance_seed_budget_keys: k = RunKey(id_, i, r, b) costs.append(self.data[k].cost) return costs
[ "def", "_cost", "(", "self", ",", "config", ":", "Configuration", ",", "instance_seed_budget_keys", ":", "typing", ".", "Optional", "[", "typing", ".", "Iterable", "[", "InstSeedBudgetKey", "]", "]", "=", "None", ",", ")", "->", "typing", ".", "List", "[",...
https://github.com/automl/SMAC3/blob/d4cb7ed76e0fbdd9edf6ab5360ff75de67ac2195/smac/runhistory/runhistory.py#L615-L647
pyansys/pymapdl
c07291fc062b359abf0e92b95a92d753a95ef3d7
ansys/mapdl/core/_commands/solution/fe_forces.py
python
FeForces.fj
(self, elem="", label="", value="", **kwargs)
return self.run(command, **kwargs)
Specify forces or moments on the components of the relative motion of a APDL Command: FJ joint element. Parameters ---------- elem Element number or ALL to specify all joint elements. label Valid labels: FX - Force in local x direction. FY - Force in local y direction. FZ - Force in local z direction. MX - Moment about local x axis. MY - Moment about local y axis. MZ - Moment about local z axis. value Value of the label. Notes ----- Valid for MPC184 (joint options in KEYOPT(1)). See FJDELE for information on deleting forces and moments.
Specify forces or moments on the components of the relative motion of a
[ "Specify", "forces", "or", "moments", "on", "the", "components", "of", "the", "relative", "motion", "of", "a" ]
def fj(self, elem="", label="", value="", **kwargs): """Specify forces or moments on the components of the relative motion of a APDL Command: FJ joint element. Parameters ---------- elem Element number or ALL to specify all joint elements. label Valid labels: FX - Force in local x direction. FY - Force in local y direction. FZ - Force in local z direction. MX - Moment about local x axis. MY - Moment about local y axis. MZ - Moment about local z axis. value Value of the label. Notes ----- Valid for MPC184 (joint options in KEYOPT(1)). See FJDELE for information on deleting forces and moments. """ command = f"FJ,{elem},{label},{value}" return self.run(command, **kwargs)
[ "def", "fj", "(", "self", ",", "elem", "=", "\"\"", ",", "label", "=", "\"\"", ",", "value", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "command", "=", "f\"FJ,{elem},{label},{value}\"", "return", "self", ".", "run", "(", "command", ",", "*", "*"...
https://github.com/pyansys/pymapdl/blob/c07291fc062b359abf0e92b95a92d753a95ef3d7/ansys/mapdl/core/_commands/solution/fe_forces.py#L178-L214
sightmachine/SimpleCV
6c4d61b6d1d9d856b471910107cad0838954d2b2
SimpleCV/LineScan.py
python
LineScan.ifft
(self,fft)
return retVal
**SUMMARY** Perform an inverse fast Fourier transform on the provided irrationally valued signal and return the results as a LineScan. **PARAMETERS** * *fft* - A one dimensional numpy array of irrational values upon which we will perform the IFFT. **RETURNS** A LineScan object of the reconstructed signal. **EXAMPLE** >>>> img = Image('lenna') >>>> sl = img.getLineScan(pt1=(0,0),pt2=(300,200)) >>>> fft,frq = sl.fft() >>>> fft[30:] = 0 # low pass filter >>>> sl2 = sl.ifft(fft) >>>> import matplotlib.pyplot as plt >>>> plt.plot(sl) >>>> plt.plot(sl2)
**SUMMARY**
[ "**", "SUMMARY", "**" ]
def ifft(self,fft): """ **SUMMARY** Perform an inverse fast Fourier transform on the provided irrationally valued signal and return the results as a LineScan. **PARAMETERS** * *fft* - A one dimensional numpy array of irrational values upon which we will perform the IFFT. **RETURNS** A LineScan object of the reconstructed signal. **EXAMPLE** >>>> img = Image('lenna') >>>> sl = img.getLineScan(pt1=(0,0),pt2=(300,200)) >>>> fft,frq = sl.fft() >>>> fft[30:] = 0 # low pass filter >>>> sl2 = sl.ifft(fft) >>>> import matplotlib.pyplot as plt >>>> plt.plot(sl) >>>> plt.plot(sl2) """ signal = np.fft.ifft(fft) retVal = LineScan(signal.real) retVal.image = self.image retVal.pointLoc = self.pointLoc return retVal
[ "def", "ifft", "(", "self", ",", "fft", ")", ":", "signal", "=", "np", ".", "fft", ".", "ifft", "(", "fft", ")", "retVal", "=", "LineScan", "(", "signal", ".", "real", ")", "retVal", ".", "image", "=", "self", ".", "image", "retVal", ".", "pointL...
https://github.com/sightmachine/SimpleCV/blob/6c4d61b6d1d9d856b471910107cad0838954d2b2/SimpleCV/LineScan.py#L621-L654
awslabs/aws-ec2rescue-linux
8ecf40e7ea0d2563dac057235803fca2221029d2
lib/requests/_internal_utils.py
python
to_native_string
(string, encoding='ascii')
return out
Given a string object, regardless of type, returns a representation of that string in the native string type, encoding and decoding where necessary. This assumes ASCII unless told otherwise.
Given a string object, regardless of type, returns a representation of that string in the native string type, encoding and decoding where necessary. This assumes ASCII unless told otherwise.
[ "Given", "a", "string", "object", "regardless", "of", "type", "returns", "a", "representation", "of", "that", "string", "in", "the", "native", "string", "type", "encoding", "and", "decoding", "where", "necessary", ".", "This", "assumes", "ASCII", "unless", "to...
def to_native_string(string, encoding='ascii'): """Given a string object, regardless of type, returns a representation of that string in the native string type, encoding and decoding where necessary. This assumes ASCII unless told otherwise. """ if isinstance(string, builtin_str): out = string else: if is_py2: out = string.encode(encoding) else: out = string.decode(encoding) return out
[ "def", "to_native_string", "(", "string", ",", "encoding", "=", "'ascii'", ")", ":", "if", "isinstance", "(", "string", ",", "builtin_str", ")", ":", "out", "=", "string", "else", ":", "if", "is_py2", ":", "out", "=", "string", ".", "encode", "(", "enc...
https://github.com/awslabs/aws-ec2rescue-linux/blob/8ecf40e7ea0d2563dac057235803fca2221029d2/lib/requests/_internal_utils.py#L14-L27
sfepy/sfepy
02ec7bb2ab39ee1dfe1eb4cd509f0ffb7dcc8b25
sfepy/discrete/variables.py
python
Variables.check_vector_size
(self, vec, stripped=False)
Check whether the shape of the DOF vector corresponds to the total number of DOFs of the state variables. Parameters ---------- vec : array The vector of DOF values. stripped : bool If True, the size of the DOF vector should be reduced, i.e. without DOFs fixed by boundary conditions.
Check whether the shape of the DOF vector corresponds to the total number of DOFs of the state variables.
[ "Check", "whether", "the", "shape", "of", "the", "DOF", "vector", "corresponds", "to", "the", "total", "number", "of", "DOFs", "of", "the", "state", "variables", "." ]
def check_vector_size(self, vec, stripped=False): """ Check whether the shape of the DOF vector corresponds to the total number of DOFs of the state variables. Parameters ---------- vec : array The vector of DOF values. stripped : bool If True, the size of the DOF vector should be reduced, i.e. without DOFs fixed by boundary conditions. """ if not stripped: n_dof = self.di.get_n_dof_total() if vec.size != n_dof: msg = 'incompatible data size!' \ ' (%d (variables) == %d (DOF vector))' \ % (n_dof, vec.size) raise ValueError(msg) else: if self.has_lcbc: n_dof = self.lcdi.get_n_dof_total() else: n_dof = self.adi.get_n_dof_total() if vec.size != n_dof: msg = 'incompatible data size!' \ ' (%d (active variables) == %d (reduced DOF vector))' \ % (n_dof, vec.size) raise ValueError(msg)
[ "def", "check_vector_size", "(", "self", ",", "vec", ",", "stripped", "=", "False", ")", ":", "if", "not", "stripped", ":", "n_dof", "=", "self", ".", "di", ".", "get_n_dof_total", "(", ")", "if", "vec", ".", "size", "!=", "n_dof", ":", "msg", "=", ...
https://github.com/sfepy/sfepy/blob/02ec7bb2ab39ee1dfe1eb4cd509f0ffb7dcc8b25/sfepy/discrete/variables.py#L615-L648
inspurer/WorkAttendanceSystem
1221e2d67bdf5bb15fe99517cc3ded58ccb066df
V2.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/_vendor/requests/sessions.py
python
Session.close
(self)
Closes all adapters and as such the session
Closes all adapters and as such the session
[ "Closes", "all", "adapters", "and", "as", "such", "the", "session" ]
def close(self): """Closes all adapters and as such the session""" for v in self.adapters.values(): v.close()
[ "def", "close", "(", "self", ")", ":", "for", "v", "in", "self", ".", "adapters", ".", "values", "(", ")", ":", "v", ".", "close", "(", ")" ]
https://github.com/inspurer/WorkAttendanceSystem/blob/1221e2d67bdf5bb15fe99517cc3ded58ccb066df/V2.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/_vendor/requests/sessions.py#L674-L677
TesterlifeRaymond/doraemon
d5cb6e34bd5f2aa97273ce0c0c9303e32beaa333
venv/lib/python3.6/site-packages/pip/_vendor/requests/utils.py
python
select_proxy
(url, proxies)
return proxy
Select a proxy for the url, if applicable. :param url: The url being for the request :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
Select a proxy for the url, if applicable.
[ "Select", "a", "proxy", "for", "the", "url", "if", "applicable", "." ]
def select_proxy(url, proxies): """Select a proxy for the url, if applicable. :param url: The url being for the request :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs """ proxies = proxies or {} urlparts = urlparse(url) if urlparts.hostname is None: return proxies.get('all', proxies.get(urlparts.scheme)) proxy_keys = [ 'all://' + urlparts.hostname, 'all', urlparts.scheme + '://' + urlparts.hostname, urlparts.scheme, ] proxy = None for proxy_key in proxy_keys: if proxy_key in proxies: proxy = proxies[proxy_key] break return proxy
[ "def", "select_proxy", "(", "url", ",", "proxies", ")", ":", "proxies", "=", "proxies", "or", "{", "}", "urlparts", "=", "urlparse", "(", "url", ")", "if", "urlparts", ".", "hostname", "is", "None", ":", "return", "proxies", ".", "get", "(", "'all'", ...
https://github.com/TesterlifeRaymond/doraemon/blob/d5cb6e34bd5f2aa97273ce0c0c9303e32beaa333/venv/lib/python3.6/site-packages/pip/_vendor/requests/utils.py#L611-L634
ycszen/TorchSeg
62eeb159aee77972048d9d7688a28249d3c56735
model/bisenet/cityscapes.bisenet.X39.speed/eval.py
python
SegEvaluator.compute_metric
(self, results)
return result_line
[]
def compute_metric(self, results): hist = np.zeros((config.num_classes, config.num_classes)) correct = 0 labeled = 0 count = 0 for d in results: hist += d['hist'] correct += d['correct'] labeled += d['labeled'] count += 1 iu, mean_IU, _, mean_pixel_acc = compute_score(hist, correct, labeled) result_line = print_iou(iu, mean_pixel_acc, dataset.get_class_names(), True) return result_line
[ "def", "compute_metric", "(", "self", ",", "results", ")", ":", "hist", "=", "np", ".", "zeros", "(", "(", "config", ".", "num_classes", ",", "config", ".", "num_classes", ")", ")", "correct", "=", "0", "labeled", "=", "0", "count", "=", "0", "for", ...
https://github.com/ycszen/TorchSeg/blob/62eeb159aee77972048d9d7688a28249d3c56735/model/bisenet/cityscapes.bisenet.X39.speed/eval.py#L64-L79
joschabach/micropsi2
74a2642d20da9da1d64acc5e4c11aeabee192a27
micropsi_core/nodenet/nodenet.py
python
Nodenet.get_nodespace_uids
(self)
Returns a list of the UIDs of all Nodespace objects that exist in the node net
Returns a list of the UIDs of all Nodespace objects that exist in the node net
[ "Returns", "a", "list", "of", "the", "UIDs", "of", "all", "Nodespace", "objects", "that", "exist", "in", "the", "node", "net" ]
def get_nodespace_uids(self): """ Returns a list of the UIDs of all Nodespace objects that exist in the node net """ pass
[ "def", "get_nodespace_uids", "(", "self", ")", ":", "pass" ]
https://github.com/joschabach/micropsi2/blob/74a2642d20da9da1d64acc5e4c11aeabee192a27/micropsi_core/nodenet/nodenet.py#L288-L292
collinsctk/PyQYT
7af3673955f94ff1b2df2f94220cd2dab2e252af
ExtentionPackages/scapy/layers/ipsec.py
python
CryptAlgo.new_cipher
(self, key, iv)
@param key: the secret key, a byte string @param iv: the initialization vector, a byte string @return: an initialized cipher object for this algo
[]
def new_cipher(self, key, iv): """ @param key: the secret key, a byte string @param iv: the initialization vector, a byte string @return: an initialized cipher object for this algo """ if type(key) is str: key = key.encode('ascii') if (hasattr(self.cipher, 'MODE_CTR') and self.mode == self.cipher.MODE_CTR or hasattr(self.cipher, 'MODE_GCM') and self.mode == self.cipher.MODE_GCM): # in counter mode, the "iv" must be incremented for each block # it is calculated like this: # +---------+------------------+---------+ # | nonce | IV | counter | # +---------+------------------+---------+ # m bytes n bytes 4 bytes # <--------------------------------------> # block_size nonce_size = self.cipher.block_size - self.iv_size - 4 # instead of asking for an extra parameter, we extract the last # nonce_size bytes of the key and use them as the nonce. # +----------------------------+---------+ # | cipher key | nonce | # +----------------------------+---------+ # <---------> # nonce_size cipher_key, nonce = key[:-nonce_size], key[-nonce_size:] return self.cipher.new(cipher_key, self.mode, counter=Counter.new(4 * 8, prefix=nonce + iv)) else: return self.cipher.new(key, self.mode, iv)
[ "def", "new_cipher", "(", "self", ",", "key", ",", "iv", ")", ":", "if", "type", "(", "key", ")", "is", "str", ":", "key", "=", "key", ".", "encode", "(", "'ascii'", ")", "if", "(", "hasattr", "(", "self", ".", "cipher", ",", "'MODE_CTR'", ")", ...
https://github.com/collinsctk/PyQYT/blob/7af3673955f94ff1b2df2f94220cd2dab2e252af/ExtentionPackages/scapy/layers/ipsec.py#L235-L267
volatilityfoundation/volatility3
168b0d0b053ab97a7cb096ef2048795cc54d885f
volatility3/framework/interfaces/context.py
python
ModuleInterface.symbols
(self)
Lists the symbols contained in the symbol table for this module
Lists the symbols contained in the symbol table for this module
[ "Lists", "the", "symbols", "contained", "in", "the", "symbol", "table", "for", "this", "module" ]
def symbols(self) -> List: """Lists the symbols contained in the symbol table for this module"""
[ "def", "symbols", "(", "self", ")", "->", "List", ":" ]
https://github.com/volatilityfoundation/volatility3/blob/168b0d0b053ab97a7cb096ef2048795cc54d885f/volatility3/framework/interfaces/context.py#L280-L281
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/full/xml/dom/minidom.py
python
DocumentType.__init__
(self, qualifiedName)
[]
def __init__(self, qualifiedName): self.entities = ReadOnlySequentialNamedNodeMap() self.notations = ReadOnlySequentialNamedNodeMap() if qualifiedName: prefix, localname = _nssplit(qualifiedName) self.name = localname self.nodeName = self.name
[ "def", "__init__", "(", "self", ",", "qualifiedName", ")", ":", "self", ".", "entities", "=", "ReadOnlySequentialNamedNodeMap", "(", ")", "self", ".", "notations", "=", "ReadOnlySequentialNamedNodeMap", "(", ")", "if", "qualifiedName", ":", "prefix", ",", "local...
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/xml/dom/minidom.py#L1314-L1320
fossasia/x-mario-center
fe67afe28d995dcf4e2498e305825a4859566172
softwarecenter/ui/gtk3/review_gui_helper.py
python
SubmitReviewsApp._get_send_accounts
(self, sel_index)
return the account referenced by the passed in index, or all accounts if the index of the combo points to the pseudo-sc-all string
return the account referenced by the passed in index, or all accounts if the index of the combo points to the pseudo-sc-all string
[ "return", "the", "account", "referenced", "by", "the", "passed", "in", "index", "or", "all", "accounts", "if", "the", "index", "of", "the", "combo", "points", "to", "the", "pseudo", "-", "sc", "-", "all", "string" ]
def _get_send_accounts(self, sel_index): """return the account referenced by the passed in index, or all accounts if the index of the combo points to the pseudo-sc-all string """ if self.gwibber_accounts[sel_index]["id"] == "pseudo-sc-all": return self.gwibber_accounts else: return [self.gwibber_accounts[sel_index]]
[ "def", "_get_send_accounts", "(", "self", ",", "sel_index", ")", ":", "if", "self", ".", "gwibber_accounts", "[", "sel_index", "]", "[", "\"id\"", "]", "==", "\"pseudo-sc-all\"", ":", "return", "self", ".", "gwibber_accounts", "else", ":", "return", "[", "se...
https://github.com/fossasia/x-mario-center/blob/fe67afe28d995dcf4e2498e305825a4859566172/softwarecenter/ui/gtk3/review_gui_helper.py#L1021-L1029
yandex/yandex-tank
b41bcc04396c4ed46fc8b28a261197320854fd33
yandextank/plugins/Autostop/criterions.py
python
TimeLimitCriterion.notify
(self, data, stat)
return (self.end_time - self.start_time) > self.time_limit
[]
def notify(self, data, stat): self.end_time = time.time() return (self.end_time - self.start_time) > self.time_limit
[ "def", "notify", "(", "self", ",", "data", ",", "stat", ")", ":", "self", ".", "end_time", "=", "time", ".", "time", "(", ")", "return", "(", "self", ".", "end_time", "-", "self", ".", "start_time", ")", ">", "self", ".", "time_limit" ]
https://github.com/yandex/yandex-tank/blob/b41bcc04396c4ed46fc8b28a261197320854fd33/yandextank/plugins/Autostop/criterions.py#L446-L448
webcompat/webcompat.com
c3504dffec29b14eaa62ef01aa1ba78f9c2b12ef
webcompat/form.py
python
build_formdata
(form_object)
return rv
Convert HTML form data to GitHub API data. Summary -> title Version -> part of body URL -> part of body Category -> labels Details -> part of body Description -> part of body Browser -> part of body, labels OS -> part of body, labels Tested Elsewhere -> body Image Upload -> part of body We'll try to parse the Browser and come up with a browser label, as well as labels like mobile, desktop, tablet. Here's a description of what the Issues API expects to create an issue -------------------------------------------------------------------------- | title | string | The title of the issue. Required. | | body | string | The contents of the issue. | | labels | array of strings | Labels to associate with this issue. | | milestone| integer | Milestone to associate with this issue. | -------------------------------------------------------------------------- NOTE: Only users with push access can set labels for new issues. Labels are silently dropped otherwise. NOTE: intentionally leaving out `assignee`. NOTE: Add milestone "needstriage" when creating a new issue
Convert HTML form data to GitHub API data.
[ "Convert", "HTML", "form", "data", "to", "GitHub", "API", "data", "." ]
def build_formdata(form_object): """Convert HTML form data to GitHub API data. Summary -> title Version -> part of body URL -> part of body Category -> labels Details -> part of body Description -> part of body Browser -> part of body, labels OS -> part of body, labels Tested Elsewhere -> body Image Upload -> part of body We'll try to parse the Browser and come up with a browser label, as well as labels like mobile, desktop, tablet. Here's a description of what the Issues API expects to create an issue -------------------------------------------------------------------------- | title | string | The title of the issue. Required. | | body | string | The contents of the issue. | | labels | array of strings | Labels to associate with this issue. | | milestone| integer | Milestone to associate with this issue. | -------------------------------------------------------------------------- NOTE: Only users with push access can set labels for new issues. Labels are silently dropped otherwise. NOTE: intentionally leaving out `assignee`. NOTE: Add milestone "needstriage" when creating a new issue """ # Do domain extraction for adding to the summary/title # form_object always returns a unicode string url = form_object.get('url') normalized_url = normalize_url(url) domain = domain_name(normalized_url) problem_summary = get_problem_summary(form_object.get('problem_category')) if domain: summary = '{0} - {1}'.format(domain, problem_summary) else: summary = '{0} - {1}'.format(normalized_url, problem_summary) metadata_keys = ['browser', 'ua_header', 'reported_with'] extra_labels = form_object.get('extra_labels', None) if extra_labels: metadata_keys.append('extra_labels') extra_metadata = form_object.get('extra_metadata', None) if extra_metadata: for key in extra_metadata.keys(): form_object[key] = extra_metadata[key] metadata_keys.append(key) formdata = { 'metadata': get_metadata(metadata_keys, form_object), 'url': normalized_url, 'browser': normalize_metadata(form_object.get('browser')), 'os': normalize_metadata(form_object.get('os')), 'problem_type': get_radio_button_label( form_object.get('problem_category'), problem_choices_wizard), 'browser_test_type': get_radio_button_label(form_object.get( 'browser_test'), tested_elsewhere), 'description': form_object.get('description'), 'steps_reproduce': form_object.get('steps_reproduce'), 'tested_browsers': form_object.get('tested_browsers', ''), } # Preparing the body body = """{metadata} **URL**: {url} **Browser / Version**: {browser} **Operating System**: {os} **Tested Another Browser**: {browser_test_type} {tested_browsers} **Problem type**: {problem_type} **Description**: {description} **Steps to Reproduce**: {steps_reproduce} """.format(**formdata) # Append details info, if any. details = form_object.get('details') if details: body += build_details(details) body += get_console_logs_url(form_object.get('console_logs_url')) # Add the image, if there was one. if form_object.get('image_upload') is not None: body += '\n\n![Screenshot of the site issue]({image_url})'.format( image_url=form_object.get('image_upload').get('url')) # Append "from webcompat.com" message to bottom (for GitHub issue viewers) body += '\n\n{0}'.format(GITHUB_HELP) rv = {'title': summary, 'body': body} return rv
[ "def", "build_formdata", "(", "form_object", ")", ":", "# Do domain extraction for adding to the summary/title", "# form_object always returns a unicode string", "url", "=", "form_object", ".", "get", "(", "'url'", ")", "normalized_url", "=", "normalize_url", "(", "url", ")...
https://github.com/webcompat/webcompat.com/blob/c3504dffec29b14eaa62ef01aa1ba78f9c2b12ef/webcompat/form.py#L441-L535
number5/cloud-init
19948dbaf40309355e1a2dbef116efb0ce66245c
cloudinit/sources/DataSourceMAAS.py
python
get_id_from_ds_cfg
(ds_cfg)
return "v1:" + hashlib.sha256(idstr.encode("utf-8")).hexdigest()
Given a config, generate a unique identifier for this node.
Given a config, generate a unique identifier for this node.
[ "Given", "a", "config", "generate", "a", "unique", "identifier", "for", "this", "node", "." ]
def get_id_from_ds_cfg(ds_cfg): """Given a config, generate a unique identifier for this node.""" fields = ("consumer_key", "token_key", "token_secret") idstr = "\0".join([ds_cfg.get(f, "") for f in fields]) # store the encoding version as part of the hash in the event # that it ever changed we can compute older versions. return "v1:" + hashlib.sha256(idstr.encode("utf-8")).hexdigest()
[ "def", "get_id_from_ds_cfg", "(", "ds_cfg", ")", ":", "fields", "=", "(", "\"consumer_key\"", ",", "\"token_key\"", ",", "\"token_secret\"", ")", "idstr", "=", "\"\\0\"", ".", "join", "(", "[", "ds_cfg", ".", "get", "(", "f", ",", "\"\"", ")", "for", "f"...
https://github.com/number5/cloud-init/blob/19948dbaf40309355e1a2dbef116efb0ce66245c/cloudinit/sources/DataSourceMAAS.py#L177-L183
silverapp/silver
a59dbc7216733ab49dca2fae525d229bdba04420
silver/models/plans.py
python
Plan.__str__
(self)
return "%s (%s)" % (self.name, self.provider.name)
[]
def __str__(self): return "%s (%s)" % (self.name, self.provider.name)
[ "def", "__str__", "(", "self", ")", ":", "return", "\"%s (%s)\"", "%", "(", "self", ".", "name", ",", "self", ".", "provider", ".", "name", ")" ]
https://github.com/silverapp/silver/blob/a59dbc7216733ab49dca2fae525d229bdba04420/silver/models/plans.py#L134-L135
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/bs4/builder/_lxml.py
python
LXMLTreeBuilderForXML.doctype
(self, name, pubid, system)
[]
def doctype(self, name, pubid, system): self.soup.endData() doctype = Doctype.for_name_and_ids(name, pubid, system) self.soup.object_was_parsed(doctype)
[ "def", "doctype", "(", "self", ",", "name", ",", "pubid", ",", "system", ")", ":", "self", ".", "soup", ".", "endData", "(", ")", "doctype", "=", "Doctype", ".", "for_name_and_ids", "(", "name", ",", "pubid", ",", "system", ")", "self", ".", "soup", ...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/bs4/builder/_lxml.py#L218-L221
theislab/anndata
664e32b0aa6625fe593370d37174384c05abfd4e
anndata/_core/sparse_dataset.py
python
BackedSparseMatrix.copy
(self)
[]
def copy(self) -> ss.spmatrix: if isinstance(self.data, h5py.Dataset): return SparseDataset(self.data.parent).to_memory() else: return super().copy()
[ "def", "copy", "(", "self", ")", "->", "ss", ".", "spmatrix", ":", "if", "isinstance", "(", "self", ".", "data", ",", "h5py", ".", "Dataset", ")", ":", "return", "SparseDataset", "(", "self", ".", "data", ".", "parent", ")", ".", "to_memory", "(", ...
https://github.com/theislab/anndata/blob/664e32b0aa6625fe593370d37174384c05abfd4e/anndata/_core/sparse_dataset.py#L48-L52
shiyanhui/FileHeader
f347cc134021fb0b710694b71c57742476f5fd2b
FileHeader.py
python
get_author
()
return get_user_data_from_git('name', getpass.getuser())
Get author
Get author
[ "Get", "author" ]
def get_author(): '''Get author''' return get_user_data_from_git('name', getpass.getuser())
[ "def", "get_author", "(", ")", ":", "return", "get_user_data_from_git", "(", "'name'", ",", "getpass", ".", "getuser", "(", ")", ")" ]
https://github.com/shiyanhui/FileHeader/blob/f347cc134021fb0b710694b71c57742476f5fd2b/FileHeader.py#L231-L234
sightmachine/SimpleCV
6c4d61b6d1d9d856b471910107cad0838954d2b2
SimpleCV/Features/Detection.py
python
ROI.toTLAndBR
(self)
return [(self.xtl,self.ytl),(self.xtl+self.w,self.ytl+self.h)]
**SUMMARY** Get the ROI as a list of tuples of the ROI's top left corner and bottom right corner. **RETURNS** A list of the form [(x,y),(x,y)] **EXAMPLE** >>> roi = ROI(10,10,100,100,img) >>> roi.translate(30,30) >>> print roi.toTLAndBR()
**SUMMARY** Get the ROI as a list of tuples of the ROI's top left corner and bottom right corner.
[ "**", "SUMMARY", "**", "Get", "the", "ROI", "as", "a", "list", "of", "tuples", "of", "the", "ROI", "s", "top", "left", "corner", "and", "bottom", "right", "corner", "." ]
def toTLAndBR(self): """ **SUMMARY** Get the ROI as a list of tuples of the ROI's top left corner and bottom right corner. **RETURNS** A list of the form [(x,y),(x,y)] **EXAMPLE** >>> roi = ROI(10,10,100,100,img) >>> roi.translate(30,30) >>> print roi.toTLAndBR() """ return [(self.xtl,self.ytl),(self.xtl+self.w,self.ytl+self.h)]
[ "def", "toTLAndBR", "(", "self", ")", ":", "return", "[", "(", "self", ".", "xtl", ",", "self", ".", "ytl", ")", ",", "(", "self", ".", "xtl", "+", "self", ".", "w", ",", "self", ".", "ytl", "+", "self", ".", "h", ")", "]" ]
https://github.com/sightmachine/SimpleCV/blob/6c4d61b6d1d9d856b471910107cad0838954d2b2/SimpleCV/Features/Detection.py#L1997-L2015
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/email/message.py
python
Message.add_header
(self, _name, _value, **_params)
Extended header setting. name is the header field to add. keyword arguments can be used to set additional parameters for the header field, with underscores converted to dashes. Normally the parameter will be added as key="value" unless value is None, in which case only the key will be added. If a parameter value contains non-ASCII characters it can be specified as a three-tuple of (charset, language, value), in which case it will be encoded according to RFC2231 rules. Otherwise it will be encoded using the utf-8 charset and a language of ''. Examples: msg.add_header('content-disposition', 'attachment', filename='bud.gif') msg.add_header('content-disposition', 'attachment', filename=('utf-8', '', Fußballer.ppt')) msg.add_header('content-disposition', 'attachment', filename='Fußballer.ppt'))
Extended header setting.
[ "Extended", "header", "setting", "." ]
def add_header(self, _name, _value, **_params): """Extended header setting. name is the header field to add. keyword arguments can be used to set additional parameters for the header field, with underscores converted to dashes. Normally the parameter will be added as key="value" unless value is None, in which case only the key will be added. If a parameter value contains non-ASCII characters it can be specified as a three-tuple of (charset, language, value), in which case it will be encoded according to RFC2231 rules. Otherwise it will be encoded using the utf-8 charset and a language of ''. Examples: msg.add_header('content-disposition', 'attachment', filename='bud.gif') msg.add_header('content-disposition', 'attachment', filename=('utf-8', '', Fußballer.ppt')) msg.add_header('content-disposition', 'attachment', filename='Fußballer.ppt')) """ parts = [] for k, v in _params.items(): if v is None: parts.append(k.replace('_', '-')) else: parts.append(_formatparam(k.replace('_', '-'), v)) if _value is not None: parts.insert(0, _value) self[_name] = SEMISPACE.join(parts)
[ "def", "add_header", "(", "self", ",", "_name", ",", "_value", ",", "*", "*", "_params", ")", ":", "parts", "=", "[", "]", "for", "k", ",", "v", "in", "_params", ".", "items", "(", ")", ":", "if", "v", "is", "None", ":", "parts", ".", "append",...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/email/message.py#L515-L543
biolab/orange3
41685e1c7b1d1babe680113685a2d44bcc9fec0b
Orange/widgets/unsupervised/owsom.py
python
OWSOM.restart_som_pressed
(self)
[]
def restart_som_pressed(self): if self._optimizer_thread is not None: self.stop_optimization = True self._optimizer.stop_optimization = True else: self.start_som()
[ "def", "restart_som_pressed", "(", "self", ")", ":", "if", "self", ".", "_optimizer_thread", "is", "not", "None", ":", "self", ".", "stop_optimization", "=", "True", "self", ".", "_optimizer", ".", "stop_optimization", "=", "True", "else", ":", "self", ".", ...
https://github.com/biolab/orange3/blob/41685e1c7b1d1babe680113685a2d44bcc9fec0b/Orange/widgets/unsupervised/owsom.py#L484-L489
QUVA-Lab/artemis
84d3b1daf0de363cc823d99f978e2861ed400b5b
artemis/ml/predictors/predictor_comparison.py
python
LearningCurveData.add
(self, time, scores)
:param time: Something representing the time at which the record was taken. :param scores: A list of 2-tuples of (score_name, score). It can also be a scalar score. Eg: [('training', 0.104), ('test', 0.119)] :return:
:param time: Something representing the time at which the record was taken. :param scores: A list of 2-tuples of (score_name, score). It can also be a scalar score. Eg: [('training', 0.104), ('test', 0.119)] :return:
[ ":", "param", "time", ":", "Something", "representing", "the", "time", "at", "which", "the", "record", "was", "taken", ".", ":", "param", "scores", ":", "A", "list", "of", "2", "-", "tuples", "of", "(", "score_name", "score", ")", ".", "It", "can", "...
def add(self, time, scores): """ :param time: Something representing the time at which the record was taken. :param scores: A list of 2-tuples of (score_name, score). It can also be a scalar score. Eg: [('training', 0.104), ('test', 0.119)] :return: """ if np.isscalar(scores): scores = [('Score', scores)] elif isinstance(scores, tuple): scores = [scores] else: assert isinstance(scores, list) and all(len(s) == 2 for s in scores) for k, v in scores: if k not in self._scores: self._times[k] = [] self._scores[k] = [] self._times[k].append(time) self._scores[k].append(v)
[ "def", "add", "(", "self", ",", "time", ",", "scores", ")", ":", "if", "np", ".", "isscalar", "(", "scores", ")", ":", "scores", "=", "[", "(", "'Score'", ",", "scores", ")", "]", "elif", "isinstance", "(", "scores", ",", "tuple", ")", ":", "scor...
https://github.com/QUVA-Lab/artemis/blob/84d3b1daf0de363cc823d99f978e2861ed400b5b/artemis/ml/predictors/predictor_comparison.py#L256-L275
cocoakekeyu/autoproxy
c7298b1d46129e7bbb58d5a701be4e01025dde4f
autoproxy.py
python
ProxyValidate.__init__
(self, autoproxy, part)
[]
def __init__(self, autoproxy, part): super(ProxyValidate, self).__init__() self.autoproxy = autoproxy self.part = part
[ "def", "__init__", "(", "self", ",", "autoproxy", ",", "part", ")", ":", "super", "(", "ProxyValidate", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "autoproxy", "=", "autoproxy", "self", ".", "part", "=", "part" ]
https://github.com/cocoakekeyu/autoproxy/blob/c7298b1d46129e7bbb58d5a701be4e01025dde4f/autoproxy.py#L233-L236
oracle/graalpython
577e02da9755d916056184ec441c26e00b70145c
graalpython/lib-python/3/urllib/parse.py
python
urlunparse
(components)
return _coerce_result(urlunsplit((scheme, netloc, url, query, fragment)))
Put a parsed URL back together again. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had redundant delimiters, e.g. a ? with an empty query (the draft states that these are equivalent).
Put a parsed URL back together again. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had redundant delimiters, e.g. a ? with an empty query (the draft states that these are equivalent).
[ "Put", "a", "parsed", "URL", "back", "together", "again", ".", "This", "may", "result", "in", "a", "slightly", "different", "but", "equivalent", "URL", "if", "the", "URL", "that", "was", "parsed", "originally", "had", "redundant", "delimiters", "e", ".", "...
def urlunparse(components): """Put a parsed URL back together again. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had redundant delimiters, e.g. a ? with an empty query (the draft states that these are equivalent).""" scheme, netloc, url, params, query, fragment, _coerce_result = ( _coerce_args(*components)) if params: url = "%s;%s" % (url, params) return _coerce_result(urlunsplit((scheme, netloc, url, query, fragment)))
[ "def", "urlunparse", "(", "components", ")", ":", "scheme", ",", "netloc", ",", "url", ",", "params", ",", "query", ",", "fragment", ",", "_coerce_result", "=", "(", "_coerce_args", "(", "*", "components", ")", ")", "if", "params", ":", "url", "=", "\"...
https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/urllib/parse.py#L474-L483
bhoov/exbert
d27b6236aa51b185f7d3fed904f25cabe3baeb1a
server/data_processing/convenience_corpus.py
python
files_available
(base_dir, glob_pattern="*.faiss")
return True
Determine whether the base_dir contains indexed files
Determine whether the base_dir contains indexed files
[ "Determine", "whether", "the", "base_dir", "contains", "indexed", "files" ]
def files_available(base_dir, glob_pattern="*.faiss"): """Determine whether the base_dir contains indexed files""" if not base_dir.exists() or len(list(base_dir.glob(glob_pattern))) == 0: return False return True
[ "def", "files_available", "(", "base_dir", ",", "glob_pattern", "=", "\"*.faiss\"", ")", ":", "if", "not", "base_dir", ".", "exists", "(", ")", "or", "len", "(", "list", "(", "base_dir", ".", "glob", "(", "glob_pattern", ")", ")", ")", "==", "0", ":", ...
https://github.com/bhoov/exbert/blob/d27b6236aa51b185f7d3fed904f25cabe3baeb1a/server/data_processing/convenience_corpus.py#L21-L26
khanhnamle1994/natural-language-processing
01d450d5ac002b0156ef4cf93a07cb508c1bcdc5
assignment1/.env/lib/python2.7/site-packages/scipy/misc/doccer.py
python
docformat
(docstring, docdict=None)
return docstring % indented
Fill a function docstring from variables in dictionary Adapt the indent of the inserted docs Parameters ---------- docstring : string docstring from function, possibly with dict formatting strings docdict : dict dictionary with keys that match the dict formatting strings and values that are docstring fragments to be inserted. The indentation of the inserted docstrings is set to match the minimum indentation of the ``docstring`` by adding this indentation to all lines of the inserted string, except the first Returns ------- outstring : string string with requested ``docdict`` strings inserted Examples -------- >>> docformat(' Test string with %(value)s', {'value':'inserted value'}) ' Test string with inserted value' >>> docstring = 'First line\\n Second line\\n %(value)s' >>> inserted_string = "indented\\nstring" >>> docdict = {'value': inserted_string} >>> docformat(docstring, docdict) 'First line\\n Second line\\n indented\\n string'
Fill a function docstring from variables in dictionary
[ "Fill", "a", "function", "docstring", "from", "variables", "in", "dictionary" ]
def docformat(docstring, docdict=None): ''' Fill a function docstring from variables in dictionary Adapt the indent of the inserted docs Parameters ---------- docstring : string docstring from function, possibly with dict formatting strings docdict : dict dictionary with keys that match the dict formatting strings and values that are docstring fragments to be inserted. The indentation of the inserted docstrings is set to match the minimum indentation of the ``docstring`` by adding this indentation to all lines of the inserted string, except the first Returns ------- outstring : string string with requested ``docdict`` strings inserted Examples -------- >>> docformat(' Test string with %(value)s', {'value':'inserted value'}) ' Test string with inserted value' >>> docstring = 'First line\\n Second line\\n %(value)s' >>> inserted_string = "indented\\nstring" >>> docdict = {'value': inserted_string} >>> docformat(docstring, docdict) 'First line\\n Second line\\n indented\\n string' ''' if not docstring: return docstring if docdict is None: docdict = {} if not docdict: return docstring lines = docstring.expandtabs().splitlines() # Find the minimum indent of the main docstring, after first line if len(lines) < 2: icount = 0 else: icount = indentcount_lines(lines[1:]) indent = ' ' * icount # Insert this indent to dictionary docstrings indented = {} for name, dstr in docdict.items(): lines = dstr.expandtabs().splitlines() try: newlines = [lines[0]] for line in lines[1:]: newlines.append(indent+line) indented[name] = '\n'.join(newlines) except IndexError: indented[name] = dstr return docstring % indented
[ "def", "docformat", "(", "docstring", ",", "docdict", "=", "None", ")", ":", "if", "not", "docstring", ":", "return", "docstring", "if", "docdict", "is", "None", ":", "docdict", "=", "{", "}", "if", "not", "docdict", ":", "return", "docstring", "lines", ...
https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/scipy/misc/doccer.py#L12-L68
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/cpdp/v20190820/models.py
python
CreateAgentTaxPaymentInfosResponse.__init__
(self)
r""" :param AgentTaxPaymentBatch: 代理商完税证明批次信息 :type AgentTaxPaymentBatch: :class:`tencentcloud.cpdp.v20190820.models.AgentTaxPaymentBatch` :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
r""" :param AgentTaxPaymentBatch: 代理商完税证明批次信息 :type AgentTaxPaymentBatch: :class:`tencentcloud.cpdp.v20190820.models.AgentTaxPaymentBatch` :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
[ "r", ":", "param", "AgentTaxPaymentBatch", ":", "代理商完税证明批次信息", ":", "type", "AgentTaxPaymentBatch", ":", ":", "class", ":", "tencentcloud", ".", "cpdp", ".", "v20190820", ".", "models", ".", "AgentTaxPaymentBatch", ":", "param", "RequestId", ":", "唯一请求", "ID,每次请...
def __init__(self): r""" :param AgentTaxPaymentBatch: 代理商完税证明批次信息 :type AgentTaxPaymentBatch: :class:`tencentcloud.cpdp.v20190820.models.AgentTaxPaymentBatch` :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str """ self.AgentTaxPaymentBatch = None self.RequestId = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "AgentTaxPaymentBatch", "=", "None", "self", ".", "RequestId", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/cpdp/v20190820/models.py#L3606-L3614
IronLanguages/main
a949455434b1fda8c783289e897e78a9a0caabb5
External.LCA_RESTRICTED/Languages/IronPython/27/Doc/sphinx/pycode/pgen2/parse.py
python
Parser.setup
(self, start=None)
Prepare for parsing. This *must* be called before starting to parse. The optional argument is an alternative start symbol; it defaults to the grammar's start symbol. You can use a Parser instance to parse any number of programs; each time you call setup() the parser is reset to an initial state determined by the (implicit or explicit) start symbol.
Prepare for parsing.
[ "Prepare", "for", "parsing", "." ]
def setup(self, start=None): """Prepare for parsing. This *must* be called before starting to parse. The optional argument is an alternative start symbol; it defaults to the grammar's start symbol. You can use a Parser instance to parse any number of programs; each time you call setup() the parser is reset to an initial state determined by the (implicit or explicit) start symbol. """ if start is None: start = self.grammar.start # Each stack entry is a tuple: (dfa, state, node). # A node is a tuple: (type, value, context, children), # where children is a list of nodes or None, and context may be None. newnode = (start, None, None, []) stackentry = (self.grammar.dfas[start], 0, newnode) self.stack = [stackentry] self.rootnode = None self.used_names = set()
[ "def", "setup", "(", "self", ",", "start", "=", "None", ")", ":", "if", "start", "is", "None", ":", "start", "=", "self", ".", "grammar", ".", "start", "# Each stack entry is a tuple: (dfa, state, node).", "# A node is a tuple: (type, value, context, children),", "# w...
https://github.com/IronLanguages/main/blob/a949455434b1fda8c783289e897e78a9a0caabb5/External.LCA_RESTRICTED/Languages/IronPython/27/Doc/sphinx/pycode/pgen2/parse.py#L89-L111
wistbean/fxxkpython
88e16d79d8dd37236ba6ecd0d0ff11d63143968c
vip/qyxuan/projects/Snake/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/urllib3/connectionpool.py
python
HTTPSConnectionPool._prepare_conn
(self, conn)
return conn
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used.
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used.
[ "Prepare", "the", "connection", "for", ":", "meth", ":", "urllib3", ".", "util", ".", "ssl_wrap_socket", "and", "establish", "the", "tunnel", "if", "proxy", "is", "used", "." ]
def _prepare_conn(self, conn): """ Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used. """ if isinstance(conn, VerifiedHTTPSConnection): conn.set_cert(key_file=self.key_file, cert_file=self.cert_file, cert_reqs=self.cert_reqs, ca_certs=self.ca_certs, ca_cert_dir=self.ca_cert_dir, assert_hostname=self.assert_hostname, assert_fingerprint=self.assert_fingerprint) conn.ssl_version = self.ssl_version return conn
[ "def", "_prepare_conn", "(", "self", ",", "conn", ")", ":", "if", "isinstance", "(", "conn", ",", "VerifiedHTTPSConnection", ")", ":", "conn", ".", "set_cert", "(", "key_file", "=", "self", ".", "key_file", ",", "cert_file", "=", "self", ".", "cert_file", ...
https://github.com/wistbean/fxxkpython/blob/88e16d79d8dd37236ba6ecd0d0ff11d63143968c/vip/qyxuan/projects/Snake/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/urllib3/connectionpool.py#L782-L797
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/modules/freebsdkmod.py
python
remove
(mod, persist=False, comment=True)
Remove the specified kernel module mod Name of module to remove persist Also remove module from /boot/loader.conf comment If persist is set don't remove line from /boot/loader.conf but only comment it CLI Example: .. code-block:: bash salt '*' kmod.remove vmm
Remove the specified kernel module
[ "Remove", "the", "specified", "kernel", "module" ]
def remove(mod, persist=False, comment=True): """ Remove the specified kernel module mod Name of module to remove persist Also remove module from /boot/loader.conf comment If persist is set don't remove line from /boot/loader.conf but only comment it CLI Example: .. code-block:: bash salt '*' kmod.remove vmm """ pre_mods = lsmod() res = __salt__["cmd.run_all"]("kldunload {}".format(mod), python_shell=False) if res["retcode"] == 0: post_mods = lsmod() mods = _rm_mods(pre_mods, post_mods) persist_mods = set() if persist: persist_mods = _remove_persistent_module(mod, comment) return sorted(list(mods | persist_mods)) else: return "Error removing module {}: {}".format(mod, res["stderr"])
[ "def", "remove", "(", "mod", ",", "persist", "=", "False", ",", "comment", "=", "True", ")", ":", "pre_mods", "=", "lsmod", "(", ")", "res", "=", "__salt__", "[", "\"cmd.run_all\"", "]", "(", "\"kldunload {}\"", ".", "format", "(", "mod", ")", ",", "...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/modules/freebsdkmod.py#L236-L266
DataBiosphere/toil
2e148eee2114ece8dcc3ec8a83f36333266ece0d
contrib/admin/cleanup_aws_resources.py
python
contains_uuid_with_underscores
(string)
return bool(re.compile('[0-9a-f]{8}_[0-9a-f]{4}_[0-9a-f]{4}_[0-9a-f]{4}_[0-9a-f]{12}').findall(string))
Determines if a string contains a pattern like: '28064c76-a491-43e7-9b50-da424f920354', which toil uses in its test generated IAM role names.
Determines if a string contains a pattern like: '28064c76-a491-43e7-9b50-da424f920354', which toil uses in its test generated IAM role names.
[ "Determines", "if", "a", "string", "contains", "a", "pattern", "like", ":", "28064c76", "-", "a491", "-", "43e7", "-", "9b50", "-", "da424f920354", "which", "toil", "uses", "in", "its", "test", "generated", "IAM", "role", "names", "." ]
def contains_uuid_with_underscores(string): """ Determines if a string contains a pattern like: '28064c76-a491-43e7-9b50-da424f920354', which toil uses in its test generated IAM role names. """ return bool(re.compile('[0-9a-f]{8}_[0-9a-f]{4}_[0-9a-f]{4}_[0-9a-f]{4}_[0-9a-f]{12}').findall(string))
[ "def", "contains_uuid_with_underscores", "(", "string", ")", ":", "return", "bool", "(", "re", ".", "compile", "(", "'[0-9a-f]{8}_[0-9a-f]{4}_[0-9a-f]{4}_[0-9a-f]{4}_[0-9a-f]{12}'", ")", ".", "findall", "(", "string", ")", ")" ]
https://github.com/DataBiosphere/toil/blob/2e148eee2114ece8dcc3ec8a83f36333266ece0d/contrib/admin/cleanup_aws_resources.py#L50-L55
bungnoid/glTools
8ff0899de43784a18bd4543285655e68e28fb5e5
tools/proxyMesh.py
python
proxyParent
(proxyMesh,joint)
return proxyShapes
Parent a proxy mesh shape to a specified parent joint @param proxyMesh: Proxy mesh shape to parent to joint @type proxyMesh: str @param joint: Joint to parent mesh shape to @type joint: str
Parent a proxy mesh shape to a specified parent joint
[ "Parent", "a", "proxy", "mesh", "shape", "to", "a", "specified", "parent", "joint" ]
def proxyParent(proxyMesh,joint): ''' Parent a proxy mesh shape to a specified parent joint @param proxyMesh: Proxy mesh shape to parent to joint @type proxyMesh: str @param joint: Joint to parent mesh shape to @type joint: str ''' # Checks if not mc.objExists(proxyMesh): raise Exception('Proxy mesh "'+proxyMesh+'" does not exist!') if not mc.objExists(joint): raise Exception('Joint "'+joint+'" does not exist!') # Get Proxy Shape(s) proxyShapes = [] if glTools.utils.transform.isTransform(proxyMesh): proxyShapes = mc.listRelatives(proxyMesh,s=True,ni=True,pa=True) elif str(mc.objectType(proxyMesh)) in ['mesh','nurbsSurface']: proxyShapes = [str(proxyMesh)] # Parent Proxy Shapes to Joint for i in range(len(proxyShapes)): proxyShapes[i] = glTools.utils.shape.parent(proxyShapes[i],joint)[0] glTools.utils.base.displayOverride(proxyShapes[i],overrideEnable=1,overrideDisplay=2,overrideLOD=0) # Delete Old Transform mc.delete(proxyMesh) # Tag Shapes proxyAttr = 'proxyJoint' for shape in proxyShapes: if not mc.objExists(shape+'.'+proxyAttr): mc.addAttr(shape,ln=proxyAttr,dt='string') mc.setAttr(shape+'.'+proxyAttr,joint,type='string',l=True) # Return Result return proxyShapes
[ "def", "proxyParent", "(", "proxyMesh", ",", "joint", ")", ":", "# Checks", "if", "not", "mc", ".", "objExists", "(", "proxyMesh", ")", ":", "raise", "Exception", "(", "'Proxy mesh \"'", "+", "proxyMesh", "+", "'\" does not exist!'", ")", "if", "not", "mc", ...
https://github.com/bungnoid/glTools/blob/8ff0899de43784a18bd4543285655e68e28fb5e5/tools/proxyMesh.py#L32-L68
niwinz/djorm-pgarray
2ca5142f235e9c23cfae0b46062cf89d97ed8d7c
djorm_pgarray/fields.py
python
FloatArrayField.__init__
(self, *args, **kwargs)
[]
def __init__(self, *args, **kwargs): kwargs.setdefault("dbtype", "double precision") super(FloatArrayField, self).__init__(*args, **kwargs)
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"dbtype\"", ",", "\"double precision\"", ")", "super", "(", "FloatArrayField", ",", "self", ")", ".", "__init__", "(", "*", "args", ...
https://github.com/niwinz/djorm-pgarray/blob/2ca5142f235e9c23cfae0b46062cf89d97ed8d7c/djorm_pgarray/fields.py#L191-L193
julesontheroad/NSC_BUILDER
e9083e83383281bdd9e167d3141163dcc56b6710
py/ztools/lib/aes128.py
python
AESCBC.encrypt
(self, data, iv=None)
return out
Encrypts some data in CBC mode.
Encrypts some data in CBC mode.
[ "Encrypts", "some", "data", "in", "CBC", "mode", "." ]
def encrypt(self, data, iv=None): '''Encrypts some data in CBC mode.''' if iv is None: iv = self.iv out = b'' while data: encb = self.aes.encrypt_block_ecb(sxor(data[:0x10], iv)) out += encb iv = encb data = data[0x10:] return out
[ "def", "encrypt", "(", "self", ",", "data", ",", "iv", "=", "None", ")", ":", "if", "iv", "is", "None", ":", "iv", "=", "self", ".", "iv", "out", "=", "b''", "while", "data", ":", "encb", "=", "self", ".", "aes", ".", "encrypt_block_ecb", "(", ...
https://github.com/julesontheroad/NSC_BUILDER/blob/e9083e83383281bdd9e167d3141163dcc56b6710/py/ztools/lib/aes128.py#L21-L31
graphcore/examples
46d2b7687b829778369fc6328170a7b14761e5c6
applications/tensorflow/contrastive_divergence_vae/models/vae/vae_base.py
python
VAE.iwae_elbo
(self, X_b, proposal_sampler=None, proposal_log_prob=None)
return iwae_elbo_loop(sample_idx),
More memory-efficient implementation of importance-weighted ELBO which accumulates IWELBO scores over latent samples (rather than storing all values and then doing log-sum-exp). :param X_b: input tensor to calculate model IWELBO for :param proposal_sampler: function, which takes input of the required shape of tensor with samples, and returns samples to evaluate decoder output for :param proposal_log_prob: function, which takes same z_samples as input and returns their log-probability under proposal
More memory-efficient implementation of importance-weighted ELBO which accumulates IWELBO scores over latent samples (rather than storing all values and then doing log-sum-exp). :param X_b: input tensor to calculate model IWELBO for :param proposal_sampler: function, which takes input of the required shape of tensor with samples, and returns samples to evaluate decoder output for :param proposal_log_prob: function, which takes same z_samples as input and returns their log-probability under proposal
[ "More", "memory", "-", "efficient", "implementation", "of", "importance", "-", "weighted", "ELBO", "which", "accumulates", "IWELBO", "scores", "over", "latent", "samples", "(", "rather", "than", "storing", "all", "values", "and", "then", "doing", "log", "-", "...
def iwae_elbo(self, X_b, proposal_sampler=None, proposal_log_prob=None): """ More memory-efficient implementation of importance-weighted ELBO which accumulates IWELBO scores over latent samples (rather than storing all values and then doing log-sum-exp). :param X_b: input tensor to calculate model IWELBO for :param proposal_sampler: function, which takes input of the required shape of tensor with samples, and returns samples to evaluate decoder output for :param proposal_log_prob: function, which takes same z_samples as input and returns their log-probability under proposal """ # Get parameters of approximate latent posterior q(Z|X) Z_cond_X_mu, Z_cond_X_sigma = self.encoder(tf.identity(X_b)) # How many samples to process in each loop? iwae_batch_size = self.iwae_samples_te_batch_size n_iwae_loops = int(self.n_iwae_samples_te / iwae_batch_size) # If no proposal specified use the default (approx posterior) def _default_proposal_log_prob(z_samples, mean, std): return self.gauss_ll(z_samples, mean, std) def _default_proposal_sampler(mean, std, z_samples_shape): return self.reparameterised_samples(mean, std, z_samples_shape) proposal_sampler = proposal_sampler or _default_proposal_sampler proposal_log_prob = proposal_log_prob or _default_proposal_log_prob def online_logsumexp_update(sum_exp_accum, to_add, current_max): """ Updates accumulator for logsumexp given a batch. For more details see http://www.nowozin.net/sebastian/blog/streaming-log-sum-exp-computation.html :param sum_exp_accum: tf.Tensor, length equal to batch size, vector of accumulated sumexps :param to_add: tf.Tensor, length equal to batch size, vector of sumexps to add on :param current_max: tf.Tensor, length equal to batch size, online max for each element in batch, may be updated within function :return: 2-tuple, (updated sum-exps, updated max-value normaliser) """ # Are any of new arguments larger than current max? max_new = tf.maximum(tf.reduce_max(to_add, axis=0), current_max) # Update accumulator exp_accumulator = tf.exp(to_add - max_new) + sum_exp_accum * tf.exp(current_max - max_new) return exp_accumulator, max_new def iwae_elbo_loop(sample_index): """While loop, getting imporance-weighted ELBO for a sample in each iteration""" def _cond(sample_id, exp_elbo_accumulator, max_elbo): return tf.less(sample_id, n_iwae_loops) def _body(sample_id, exp_elbo_accumulator, max_elbo): # Reparameterisation trick: draw samples from standard normal and convert them to samples from q(Z|X) Z_cond_X_samples = proposal_sampler(Z_cond_X_mu, Z_cond_X_sigma, (iwae_batch_size, tf.shape(X_b)[0], self.Z_dim)) # Find log probability of posterior samples according to prior log_p_Z = self.gauss_ll(Z_cond_X_samples, tf.zeros_like(Z_cond_X_mu), tf.ones_like(Z_cond_X_sigma)) # Find log prob of samples according to posterior log_q_Z_cond_X = proposal_log_prob(Z_cond_X_samples, Z_cond_X_mu, Z_cond_X_sigma) # Pass posterior samples through generator network ll_params = self.p_X_cond_Z_params(Z_cond_X_samples) # Find log-likelihood at output log_p_X_cond_Z = self.log_likelihood(X_b, ll_params) # Evaluate elbo for the current sample elbo_batch = log_p_X_cond_Z + log_p_Z - log_q_Z_cond_X # Apply update to sum-exp accumulator exp_elbo_accumulator, max_elbo = online_logsumexp_update(exp_elbo_accumulator, elbo_batch, max_elbo) sample_id += 1 return [sample_id, exp_elbo_accumulator, max_elbo] # Initialise accumulator and maximum tracker exp_elbo_acc = tf.zeros((iwae_batch_size, tf.shape(X_b)[0],), self.experiment.dtype) # Set tracker to minimum possible value (so it will be updated in first step) most_negative_float = np.finfo(self.experiment.dtype_np).min max_elbo_tracker = tf.ones((tf.shape(X_b)[0],), self.experiment.dtype) * most_negative_float # Accumulate exp(ELBO) terms _, sum_exp_elbo, max_elbo_offset = \ tf.while_loop(_cond, _body, loop_vars=[sample_index, exp_elbo_acc, max_elbo_tracker], maximum_iterations=n_iwae_loops, back_prop=False) # Normalise log(sum_i(exp(x_i)/exp(x_max)) -> log(mean_i(exp(x_i))) log_n_cast = tf.log(tf.cast(self.n_iwae_samples_te, self.experiment.dtype)) log_sum_exp_elbo = tf.log(tf.reduce_sum(sum_exp_elbo, axis=0)) return log_sum_exp_elbo - log_n_cast + max_elbo_offset # Execute while loop to get IW-ELBO scores sample_idx = tf.constant(0) return iwae_elbo_loop(sample_idx),
[ "def", "iwae_elbo", "(", "self", ",", "X_b", ",", "proposal_sampler", "=", "None", ",", "proposal_log_prob", "=", "None", ")", ":", "# Get parameters of approximate latent posterior q(Z|X)", "Z_cond_X_mu", ",", "Z_cond_X_sigma", "=", "self", ".", "encoder", "(", "tf...
https://github.com/graphcore/examples/blob/46d2b7687b829778369fc6328170a7b14761e5c6/applications/tensorflow/contrastive_divergence_vae/models/vae/vae_base.py#L151-L251
wistbean/fxxkpython
88e16d79d8dd37236ba6ecd0d0ff11d63143968c
vip/qyxuan/projects/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/logging.py
python
setup_logging
(verbosity, no_color, user_log_file)
return level_number
Configures and sets up all of the logging Returns the requested logging level, as its integer value.
Configures and sets up all of the logging
[ "Configures", "and", "sets", "up", "all", "of", "the", "logging" ]
def setup_logging(verbosity, no_color, user_log_file): """Configures and sets up all of the logging Returns the requested logging level, as its integer value. """ # Determine the level to be logging at. if verbosity >= 1: level = "DEBUG" elif verbosity == -1: level = "WARNING" elif verbosity == -2: level = "ERROR" elif verbosity <= -3: level = "CRITICAL" else: level = "INFO" level_number = getattr(logging, level) # The "root" logger should match the "console" level *unless* we also need # to log to a user log file. include_user_log = user_log_file is not None if include_user_log: additional_log_file = user_log_file root_level = "DEBUG" else: additional_log_file = "/dev/null" root_level = level # Disable any logging besides WARNING unless we have DEBUG level logging # enabled for vendored libraries. vendored_log_level = "WARNING" if level in ["INFO", "ERROR"] else "DEBUG" # Shorthands for clarity log_streams = { "stdout": "ext://sys.stdout", "stderr": "ext://sys.stderr", } handler_classes = { "stream": "pip._internal.utils.logging.ColorizedStreamHandler", "file": "pip._internal.utils.logging.BetterRotatingFileHandler", } logging.config.dictConfig({ "version": 1, "disable_existing_loggers": False, "filters": { "exclude_warnings": { "()": "pip._internal.utils.logging.MaxLevelFilter", "level": logging.WARNING, }, }, "formatters": { "indent": { "()": IndentingFormatter, "format": "%(message)s", }, "indent_with_timestamp": { "()": IndentingFormatter, "format": "%(message)s", "add_timestamp": True, }, }, "handlers": { "console": { "level": level, "class": handler_classes["stream"], "no_color": no_color, "stream": log_streams["stdout"], "filters": ["exclude_warnings"], "formatter": "indent", }, "console_errors": { "level": "WARNING", "class": handler_classes["stream"], "no_color": no_color, "stream": log_streams["stderr"], "formatter": "indent", }, "user_log": { "level": "DEBUG", "class": handler_classes["file"], "filename": additional_log_file, "delay": True, "formatter": "indent_with_timestamp", }, }, "root": { "level": root_level, "handlers": ["console", "console_errors"] + ( ["user_log"] if include_user_log else [] ), }, "loggers": { "pip._vendor": { "level": vendored_log_level } }, }) return level_number
[ "def", "setup_logging", "(", "verbosity", ",", "no_color", ",", "user_log_file", ")", ":", "# Determine the level to be logging at.", "if", "verbosity", ">=", "1", ":", "level", "=", "\"DEBUG\"", "elif", "verbosity", "==", "-", "1", ":", "level", "=", "\"WARNING...
https://github.com/wistbean/fxxkpython/blob/88e16d79d8dd37236ba6ecd0d0ff11d63143968c/vip/qyxuan/projects/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/logging.py#L217-L318
liaohuqiu/btcbot-open
bb46896b5e24449bc41f65a876d8d7c886a340c1
src/btfxwss/client.py
python
BtfxWssClient.orders_update
(self)
return self.queue_processor.account['Order Update']
Return queue containing order updates associated with the user account. :return: Queue()
Return queue containing order updates associated with the user account.
[ "Return", "queue", "containing", "order", "updates", "associated", "with", "the", "user", "account", "." ]
def orders_update(self): """Return queue containing order updates associated with the user account. :return: Queue() """ return self.queue_processor.account['Order Update']
[ "def", "orders_update", "(", "self", ")", ":", "return", "self", ".", "queue_processor", ".", "account", "[", "'Order Update'", "]" ]
https://github.com/liaohuqiu/btcbot-open/blob/bb46896b5e24449bc41f65a876d8d7c886a340c1/src/btfxwss/client.py#L72-L77
keiffster/program-y
8c99b56f8c32f01a7b9887b5daae9465619d0385
src/programy/clients/render/renderer.py
python
RichMediaRenderer.handle_list
(self, client_context, lst)
return None
[]
def handle_list(self, client_context, lst): del client_context del lst return None
[ "def", "handle_list", "(", "self", ",", "client_context", ",", "lst", ")", ":", "del", "client_context", "del", "lst", "return", "None" ]
https://github.com/keiffster/program-y/blob/8c99b56f8c32f01a7b9887b5daae9465619d0385/src/programy/clients/render/renderer.py#L469-L472
ClusterHQ/flocker
eaa586248986d7cd681c99c948546c2b507e44de
flocker/restapi/_infrastructure.py
python
structured
(inputSchema, outputSchema, schema_store=None, ignore_body=False)
return deco
Decorate a Klein-style endpoint method so that the request body is automatically decoded and the response body is automatically encoded. Items in the object encoded in the request body will be passed to C{original} as keyword arguments. For example:: {"foo": "bar"} If this request body is received it will be as if the decorated function were called like:: original(foo="bar") The encoded form of the object returned by C{original} will define the response body. :param inputSchema: JSON Schema describing the request body. :param outputSchema: JSON Schema describing the response body. :param schema_store: A mapping between schema paths (e.g. ``b/v1/types.json``) and the JSON schema structure, allowing input/output schemas to just be references. :param ignore_body: If true, the body is not passed to the endpoint regardless of HTTP method, in particular including ``POST``. By default the body is only ignored for ``GET`` and ``HEAD``.
Decorate a Klein-style endpoint method so that the request body is automatically decoded and the response body is automatically encoded.
[ "Decorate", "a", "Klein", "-", "style", "endpoint", "method", "so", "that", "the", "request", "body", "is", "automatically", "decoded", "and", "the", "response", "body", "is", "automatically", "encoded", "." ]
def structured(inputSchema, outputSchema, schema_store=None, ignore_body=False): """ Decorate a Klein-style endpoint method so that the request body is automatically decoded and the response body is automatically encoded. Items in the object encoded in the request body will be passed to C{original} as keyword arguments. For example:: {"foo": "bar"} If this request body is received it will be as if the decorated function were called like:: original(foo="bar") The encoded form of the object returned by C{original} will define the response body. :param inputSchema: JSON Schema describing the request body. :param outputSchema: JSON Schema describing the response body. :param schema_store: A mapping between schema paths (e.g. ``b/v1/types.json``) and the JSON schema structure, allowing input/output schemas to just be references. :param ignore_body: If true, the body is not passed to the endpoint regardless of HTTP method, in particular including ``POST``. By default the body is only ignored for ``GET`` and ``HEAD``. """ if schema_store is None: schema_store = {} inputValidator = getValidator(inputSchema, schema_store) outputValidator = getValidator(outputSchema, schema_store) def deco(original): @wraps(original) @_remote_logging @_logging @_serialize(outputValidator) def loadAndDispatch(self, request, **routeArguments): if request.method in (b"GET", b"DELETE") or ignore_body: objects = {} else: body = request.content.read() try: objects = loads(body) except ValueError: raise DECODING_ERROR errors = [] for error in inputValidator.iter_errors(objects): errors.append(error.message) if errors: raise InvalidRequestJSON(errors=errors, schema=inputSchema) # Just assume there are no conflicts between these collections # of arguments right now. When there is a schema for the JSON # hopefully we can do some static verification that no routing # arguments conflict with any top-level keys in the request # body and then we can be sure there are no conflicts here. objects.update(routeArguments) return maybeDeferred(original, self, **objects) loadAndDispatch.inputSchema = inputSchema loadAndDispatch.outputSchema = outputSchema return loadAndDispatch return deco
[ "def", "structured", "(", "inputSchema", ",", "outputSchema", ",", "schema_store", "=", "None", ",", "ignore_body", "=", "False", ")", ":", "if", "schema_store", "is", "None", ":", "schema_store", "=", "{", "}", "inputValidator", "=", "getValidator", "(", "i...
https://github.com/ClusterHQ/flocker/blob/eaa586248986d7cd681c99c948546c2b507e44de/flocker/restapi/_infrastructure.py#L203-L269
FederatedAI/FATE
32540492623568ecd1afcb367360133616e02fa3
python/federatedml/callbacks/callback_list.py
python
CallbackList.init_callback_list
(self, callback_param: CallbackParam)
[]
def init_callback_list(self, callback_param: CallbackParam): LOGGER.debug(f"self_model: {self.model}") if "EarlyStopping" in callback_param.callbacks or \ "PerformanceEvaluate" in callback_param.callbacks: has_arbiter = self.model.component_properties.has_arbiter validation_strategy = ValidationStrategy(self.role, self.mode, callback_param.validation_freqs, callback_param.early_stopping_rounds, callback_param.use_first_metric_only, arbiter_comm=has_arbiter) self.callback_list.append(validation_strategy) if "ModelCheckpoint" in callback_param.callbacks: model_checkpoint = ModelCheckpoint(model=self.model, save_freq=callback_param.save_freq) self.callback_list.append(model_checkpoint)
[ "def", "init_callback_list", "(", "self", ",", "callback_param", ":", "CallbackParam", ")", ":", "LOGGER", ".", "debug", "(", "f\"self_model: {self.model}\"", ")", "if", "\"EarlyStopping\"", "in", "callback_param", ".", "callbacks", "or", "\"PerformanceEvaluate\"", "i...
https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/federatedml/callbacks/callback_list.py#L29-L44
ambujraj/hacktoberfest2018
53df2cac8b3404261131a873352ec4f2ffa3544d
MAC_changer/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/distlib/database.py
python
make_graph
(dists, scheme='default')
return graph
Makes a dependency graph from the given distributions. :parameter dists: a list of distributions :type dists: list of :class:`distutils2.database.InstalledDistribution` and :class:`distutils2.database.EggInfoDistribution` instances :rtype: a :class:`DependencyGraph` instance
Makes a dependency graph from the given distributions.
[ "Makes", "a", "dependency", "graph", "from", "the", "given", "distributions", "." ]
def make_graph(dists, scheme='default'): """Makes a dependency graph from the given distributions. :parameter dists: a list of distributions :type dists: list of :class:`distutils2.database.InstalledDistribution` and :class:`distutils2.database.EggInfoDistribution` instances :rtype: a :class:`DependencyGraph` instance """ scheme = get_scheme(scheme) graph = DependencyGraph() provided = {} # maps names to lists of (version, dist) tuples # first, build the graph and find out what's provided for dist in dists: graph.add_distribution(dist) for p in dist.provides: name, version = parse_name_and_version(p) logger.debug('Add to provided: %s, %s, %s', name, version, dist) provided.setdefault(name, []).append((version, dist)) # now make the edges for dist in dists: requires = (dist.run_requires | dist.meta_requires | dist.build_requires | dist.dev_requires) for req in requires: try: matcher = scheme.matcher(req) except UnsupportedVersionError: # XXX compat-mode if cannot read the version logger.warning('could not read version %r - using name only', req) name = req.split()[0] matcher = scheme.matcher(name) name = matcher.key # case-insensitive matched = False if name in provided: for version, provider in provided[name]: try: match = matcher.match(version) except UnsupportedVersionError: match = False if match: graph.add_edge(dist, provider, req) matched = True break if not matched: graph.add_missing(dist, req) return graph
[ "def", "make_graph", "(", "dists", ",", "scheme", "=", "'default'", ")", ":", "scheme", "=", "get_scheme", "(", "scheme", ")", "graph", "=", "DependencyGraph", "(", ")", "provided", "=", "{", "}", "# maps names to lists of (version, dist) tuples", "# first, build ...
https://github.com/ambujraj/hacktoberfest2018/blob/53df2cac8b3404261131a873352ec4f2ffa3544d/MAC_changer/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/distlib/database.py#L1222-L1273
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/Python-2.7.9/Doc/includes/mp_synchronize.py
python
test_join_timeout
()
[]
def test_join_timeout(): p = multiprocessing.Process(target=join_timeout_func) p.start() print 'waiting for process to finish' while 1: p.join(timeout=1) if not p.is_alive(): break print '.', sys.stdout.flush()
[ "def", "test_join_timeout", "(", ")", ":", "p", "=", "multiprocessing", ".", "Process", "(", "target", "=", "join_timeout_func", ")", "p", ".", "start", "(", ")", "print", "'waiting for process to finish'", "while", "1", ":", "p", ".", "join", "(", "timeout"...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Doc/includes/mp_synchronize.py#L153-L164
apache/tvm
6eb4ed813ebcdcd9558f0906a1870db8302ff1e0
python/tvm/relay/op/op.py
python
register_infer_correct_layout
(op_name, infer_layout=None, level=10)
return tvm.ir.register_op_attr(op_name, "FInferCorrectLayout", infer_layout, level)
Register infer op layout function for an op Parameters ---------- op_name : str The name of the operator infer_layout: function (attrs: Attrs, inputs: List[Layout]) -> InferCorrectLayoutOutput The function to infer correct layout level : int The priority level
Register infer op layout function for an op
[ "Register", "infer", "op", "layout", "function", "for", "an", "op" ]
def register_infer_correct_layout(op_name, infer_layout=None, level=10): """Register infer op layout function for an op Parameters ---------- op_name : str The name of the operator infer_layout: function (attrs: Attrs, inputs: List[Layout]) -> InferCorrectLayoutOutput The function to infer correct layout level : int The priority level """ return tvm.ir.register_op_attr(op_name, "FInferCorrectLayout", infer_layout, level)
[ "def", "register_infer_correct_layout", "(", "op_name", ",", "infer_layout", "=", "None", ",", "level", "=", "10", ")", ":", "return", "tvm", ".", "ir", ".", "register_op_attr", "(", "op_name", ",", "\"FInferCorrectLayout\"", ",", "infer_layout", ",", "level", ...
https://github.com/apache/tvm/blob/6eb4ed813ebcdcd9558f0906a1870db8302ff1e0/python/tvm/relay/op/op.py#L344-L358
michael-lazar/rtv
b3d5bf16a70dba685e05db35308cc8a6d2b7f7aa
rtv/packages/praw/handlers.py
python
MultiprocessHandler.request
(self, **kwargs)
return self._relay(method='request', **kwargs)
Forward the request to the server and return its HTTP response.
Forward the request to the server and return its HTTP response.
[ "Forward", "the", "request", "to", "the", "server", "and", "return", "its", "HTTP", "response", "." ]
def request(self, **kwargs): """Forward the request to the server and return its HTTP response.""" return self._relay(method='request', **kwargs)
[ "def", "request", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_relay", "(", "method", "=", "'request'", ",", "*", "*", "kwargs", ")" ]
https://github.com/michael-lazar/rtv/blob/b3d5bf16a70dba685e05db35308cc8a6d2b7f7aa/rtv/packages/praw/handlers.py#L241-L243
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/_choropleth.py
python
Choropleth.ids
(self)
return self["ids"]
Assigns id labels to each datum. These ids for object constancy of data points during animation. Should be an array of strings, not numbers or any other type. The 'ids' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray
Assigns id labels to each datum. These ids for object constancy of data points during animation. Should be an array of strings, not numbers or any other type. The 'ids' property is an array that may be specified as a tuple, list, numpy array, or pandas Series
[ "Assigns", "id", "labels", "to", "each", "datum", ".", "These", "ids", "for", "object", "constancy", "of", "data", "points", "during", "animation", ".", "Should", "be", "an", "array", "of", "strings", "not", "numbers", "or", "any", "other", "type", ".", ...
def ids(self): """ Assigns id labels to each datum. These ids for object constancy of data points during animation. Should be an array of strings, not numbers or any other type. The 'ids' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray """ return self["ids"]
[ "def", "ids", "(", "self", ")", ":", "return", "self", "[", "\"ids\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/_choropleth.py#L758-L771
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/Python-2.7.9/Demo/classes/Complex.py
python
Re
(obj)
return obj
[]
def Re(obj): if IsComplex(obj): return obj.re return obj
[ "def", "Re", "(", "obj", ")", ":", "if", "IsComplex", "(", "obj", ")", ":", "return", "obj", ".", "re", "return", "obj" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Demo/classes/Complex.py#L86-L89
bjmayor/hacker
e3ce2ad74839c2733b27dac6c0f495e0743e1866
venv/lib/python3.5/site-packages/pip/utils/__init__.py
python
captured_output
(stream_name)
Return a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream *stream_name* with a StringIO. Taken from Lib/support/__init__.py in the CPython repo.
Return a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream *stream_name* with a StringIO.
[ "Return", "a", "context", "manager", "used", "by", "captured_stdout", "/", "stdin", "/", "stderr", "that", "temporarily", "replaces", "the", "sys", "stream", "*", "stream_name", "*", "with", "a", "StringIO", "." ]
def captured_output(stream_name): """Return a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream *stream_name* with a StringIO. Taken from Lib/support/__init__.py in the CPython repo. """ orig_stdout = getattr(sys, stream_name) setattr(sys, stream_name, StreamWrapper.from_stream(orig_stdout)) try: yield getattr(sys, stream_name) finally: setattr(sys, stream_name, orig_stdout)
[ "def", "captured_output", "(", "stream_name", ")", ":", "orig_stdout", "=", "getattr", "(", "sys", ",", "stream_name", ")", "setattr", "(", "sys", ",", "stream_name", ",", "StreamWrapper", ".", "from_stream", "(", "orig_stdout", ")", ")", "try", ":", "yield"...
https://github.com/bjmayor/hacker/blob/e3ce2ad74839c2733b27dac6c0f495e0743e1866/venv/lib/python3.5/site-packages/pip/utils/__init__.py#L784-L795
entropy1337/infernal-twin
10995cd03312e39a48ade0f114ebb0ae3a711bb8
Modules/build/pillow/build/scripts-2.7/pildriver.py
python
PILDriver.push
(self, item)
Push an argument onto the evaluation stack.
Push an argument onto the evaluation stack.
[ "Push", "an", "argument", "onto", "the", "evaluation", "stack", "." ]
def push(self, item): "Push an argument onto the evaluation stack." self.stack = [item] + self.stack
[ "def", "push", "(", "self", ",", "item", ")", ":", "self", ".", "stack", "=", "[", "item", "]", "+", "self", ".", "stack" ]
https://github.com/entropy1337/infernal-twin/blob/10995cd03312e39a48ade0f114ebb0ae3a711bb8/Modules/build/pillow/build/scripts-2.7/pildriver.py#L71-L73
pyparallel/pyparallel
11e8c6072d48c8f13641925d17b147bf36ee0ba3
Lib/site-packages/tornado-4.3b2-py3.3-win-amd64.egg/tornado/iostream.py
python
BaseIOStream._find_read_pos
(self)
return None
Attempts to find a position in the read buffer that satisfies the currently-pending read. Returns a position in the buffer if the current read can be satisfied, or None if it cannot.
Attempts to find a position in the read buffer that satisfies the currently-pending read.
[ "Attempts", "to", "find", "a", "position", "in", "the", "read", "buffer", "that", "satisfies", "the", "currently", "-", "pending", "read", "." ]
def _find_read_pos(self): """Attempts to find a position in the read buffer that satisfies the currently-pending read. Returns a position in the buffer if the current read can be satisfied, or None if it cannot. """ if (self._read_bytes is not None and (self._read_buffer_size >= self._read_bytes or (self._read_partial and self._read_buffer_size > 0))): num_bytes = min(self._read_bytes, self._read_buffer_size) return num_bytes elif self._read_delimiter is not None: # Multi-byte delimiters (e.g. '\r\n') may straddle two # chunks in the read buffer, so we can't easily find them # without collapsing the buffer. However, since protocols # using delimited reads (as opposed to reads of a known # length) tend to be "line" oriented, the delimiter is likely # to be in the first few chunks. Merge the buffer gradually # since large merges are relatively expensive and get undone in # _consume(). if self._read_buffer: while True: loc = self._read_buffer[0].find(self._read_delimiter) if loc != -1: delimiter_len = len(self._read_delimiter) self._check_max_bytes(self._read_delimiter, loc + delimiter_len) return loc + delimiter_len if len(self._read_buffer) == 1: break _double_prefix(self._read_buffer) self._check_max_bytes(self._read_delimiter, len(self._read_buffer[0])) elif self._read_regex is not None: if self._read_buffer: while True: m = self._read_regex.search(self._read_buffer[0]) if m is not None: self._check_max_bytes(self._read_regex, m.end()) return m.end() if len(self._read_buffer) == 1: break _double_prefix(self._read_buffer) self._check_max_bytes(self._read_regex, len(self._read_buffer[0])) return None
[ "def", "_find_read_pos", "(", "self", ")", ":", "if", "(", "self", ".", "_read_bytes", "is", "not", "None", "and", "(", "self", ".", "_read_buffer_size", ">=", "self", ".", "_read_bytes", "or", "(", "self", ".", "_read_partial", "and", "self", ".", "_rea...
https://github.com/pyparallel/pyparallel/blob/11e8c6072d48c8f13641925d17b147bf36ee0ba3/Lib/site-packages/tornado-4.3b2-py3.3-win-amd64.egg/tornado/iostream.py#L772-L818
CouchPotato/CouchPotatoV1
135b3331d1b88ef645e29b76f2d4cc4a732c9232
library/sqlalchemy/engine/base.py
python
ExecutionContext.handle_dbapi_exception
(self, e)
Receive a DBAPI exception which occured upon execute, result fetch, etc.
Receive a DBAPI exception which occured upon execute, result fetch, etc.
[ "Receive", "a", "DBAPI", "exception", "which", "occured", "upon", "execute", "result", "fetch", "etc", "." ]
def handle_dbapi_exception(self, e): """Receive a DBAPI exception which occured upon execute, result fetch, etc.""" raise NotImplementedError()
[ "def", "handle_dbapi_exception", "(", "self", ",", "e", ")", ":", "raise", "NotImplementedError", "(", ")" ]
https://github.com/CouchPotato/CouchPotatoV1/blob/135b3331d1b88ef645e29b76f2d4cc4a732c9232/library/sqlalchemy/engine/base.py#L619-L623
Ericsson/codechecker
c4e43f62dc3acbf71d3109b337db7c97f7852f43
web/server/codechecker_server/session_manager.py
python
SessionManager.get_failure_zip_size
(self)
return limit.get('failure_zip_size')
Maximum size of the collected failed zips which can be store on the server.
Maximum size of the collected failed zips which can be store on the server.
[ "Maximum", "size", "of", "the", "collected", "failed", "zips", "which", "can", "be", "store", "on", "the", "server", "." ]
def get_failure_zip_size(self): """ Maximum size of the collected failed zips which can be store on the server. """ limit = self.__store_config.get('limit', {}) return limit.get('failure_zip_size')
[ "def", "get_failure_zip_size", "(", "self", ")", ":", "limit", "=", "self", ".", "__store_config", ".", "get", "(", "'limit'", ",", "{", "}", ")", "return", "limit", ".", "get", "(", "'failure_zip_size'", ")" ]
https://github.com/Ericsson/codechecker/blob/c4e43f62dc3acbf71d3109b337db7c97f7852f43/web/server/codechecker_server/session_manager.py#L668-L674