repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
bokeh/bokeh
bokeh/core/has_props.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/has_props.py#L528-L570
def query_properties_with_values(self, query, include_defaults=True): ''' Query the properties values of |HasProps| instances with a predicate. Args: query (callable) : A callable that accepts property descriptors and returns True or False ...
[ "def", "query_properties_with_values", "(", "self", ",", "query", ",", "include_defaults", "=", "True", ")", ":", "themed_keys", "=", "set", "(", ")", "result", "=", "dict", "(", ")", "if", "include_defaults", ":", "keys", "=", "self", ".", "properties", "...
Query the properties values of |HasProps| instances with a predicate. Args: query (callable) : A callable that accepts property descriptors and returns True or False include_defaults (bool, optional) : Whether to include propertie...
[ "Query", "the", "properties", "values", "of", "|HasProps|", "instances", "with", "a", "predicate", "." ]
python
train
WebarchivCZ/WA-KAT
src/wa_kat/convertors/mrc.py
https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/convertors/mrc.py#L19-L81
def mrc_to_marc(mrc): """ Convert MRC data format to MARC XML. Args: mrc (str): MRC as string. Returns: str: XML with MARC. """ # ignore blank lines lines = [ line for line in mrc.splitlines() if line.strip() ] def split_to_parts(lines): ...
[ "def", "mrc_to_marc", "(", "mrc", ")", ":", "# ignore blank lines", "lines", "=", "[", "line", "for", "line", "in", "mrc", ".", "splitlines", "(", ")", "if", "line", ".", "strip", "(", ")", "]", "def", "split_to_parts", "(", "lines", ")", ":", "for", ...
Convert MRC data format to MARC XML. Args: mrc (str): MRC as string. Returns: str: XML with MARC.
[ "Convert", "MRC", "data", "format", "to", "MARC", "XML", "." ]
python
train
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/flask/wrappers.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/flask/wrappers.py#L82-L92
def module(self): """The name of the current module if the request was dispatched to an actual module. This is deprecated functionality, use blueprints instead. """ from warnings import warn warn(DeprecationWarning('modules were deprecated in favor of ' ...
[ "def", "module", "(", "self", ")", ":", "from", "warnings", "import", "warn", "warn", "(", "DeprecationWarning", "(", "'modules were deprecated in favor of '", "'blueprints. Use request.blueprint '", "'instead.'", ")", ",", "stacklevel", "=", "2", ")", "if", "self", ...
The name of the current module if the request was dispatched to an actual module. This is deprecated functionality, use blueprints instead.
[ "The", "name", "of", "the", "current", "module", "if", "the", "request", "was", "dispatched", "to", "an", "actual", "module", ".", "This", "is", "deprecated", "functionality", "use", "blueprints", "instead", "." ]
python
test
mingchen/django-cas-ng
django_cas_ng/models.py
https://github.com/mingchen/django-cas-ng/blob/202ca92cd770d9679bfe4e9e20b41fd19b81c311/django_cas_ng/models.py#L41-L63
def retrieve_pt(cls, request, service): """`request` should be the current HttpRequest object `service` a string representing the service for witch we want to retrieve a ticket. The function return a Proxy Ticket or raise `ProxyError` """ try: pgt = cls.object...
[ "def", "retrieve_pt", "(", "cls", ",", "request", ",", "service", ")", ":", "try", ":", "pgt", "=", "cls", ".", "objects", ".", "get", "(", "user", "=", "request", ".", "user", ",", "session_key", "=", "request", ".", "session", ".", "session_key", "...
`request` should be the current HttpRequest object `service` a string representing the service for witch we want to retrieve a ticket. The function return a Proxy Ticket or raise `ProxyError`
[ "request", "should", "be", "the", "current", "HttpRequest", "object", "service", "a", "string", "representing", "the", "service", "for", "witch", "we", "want", "to", "retrieve", "a", "ticket", ".", "The", "function", "return", "a", "Proxy", "Ticket", "or", "...
python
train
zerotk/easyfs
zerotk/easyfs/_easyfs.py
https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1930-L1953
def PushPopItem(obj, key, value): ''' A context manager to replace and restore a value using a getter and setter. :param object obj: The object to replace/restore. :param object key: The key to replace/restore in the object. :param object value: The value to replace. Example:: with Push...
[ "def", "PushPopItem", "(", "obj", ",", "key", ",", "value", ")", ":", "if", "key", "in", "obj", ":", "old_value", "=", "obj", "[", "key", "]", "obj", "[", "key", "]", "=", "value", "yield", "value", "obj", "[", "key", "]", "=", "old_value", "else...
A context manager to replace and restore a value using a getter and setter. :param object obj: The object to replace/restore. :param object key: The key to replace/restore in the object. :param object value: The value to replace. Example:: with PushPop2(sys.modules, 'alpha', None): pyte...
[ "A", "context", "manager", "to", "replace", "and", "restore", "a", "value", "using", "a", "getter", "and", "setter", "." ]
python
valid
mrstephenneal/mysql-toolkit
mysql/toolkit/components/structure/schema.py
https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/components/structure/schema.py#L32-L44
def get_schema(self, table, with_headers=False): """Retrieve the database schema for a particular table.""" f = self.fetch('desc ' + wrap(table)) if not isinstance(f[0], list): f = [f] # Replace None with '' schema = [['' if col is None else col for col in row] for r...
[ "def", "get_schema", "(", "self", ",", "table", ",", "with_headers", "=", "False", ")", ":", "f", "=", "self", ".", "fetch", "(", "'desc '", "+", "wrap", "(", "table", ")", ")", "if", "not", "isinstance", "(", "f", "[", "0", "]", ",", "list", ")"...
Retrieve the database schema for a particular table.
[ "Retrieve", "the", "database", "schema", "for", "a", "particular", "table", "." ]
python
train
andreikop/qutepart
qutepart/rectangularselection.py
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/rectangularselection.py#L100-L116
def _visibleToRealColumn(self, text, visiblePos): """If \t is used, real position of symbol in block and visible position differs This function converts visible to real. Bigger value is returned, if visiblePos is in the middle of \t, None if text is too short """ if visiblePos ==...
[ "def", "_visibleToRealColumn", "(", "self", ",", "text", ",", "visiblePos", ")", ":", "if", "visiblePos", "==", "0", ":", "return", "0", "elif", "not", "'\\t'", "in", "text", ":", "return", "visiblePos", "else", ":", "currentIndex", "=", "1", "for", "cur...
If \t is used, real position of symbol in block and visible position differs This function converts visible to real. Bigger value is returned, if visiblePos is in the middle of \t, None if text is too short
[ "If", "\\", "t", "is", "used", "real", "position", "of", "symbol", "in", "block", "and", "visible", "position", "differs", "This", "function", "converts", "visible", "to", "real", ".", "Bigger", "value", "is", "returned", "if", "visiblePos", "is", "in", "t...
python
train
googleads/googleads-python-lib
googleads/adwords.py
https://github.com/googleads/googleads-python-lib/blob/aa3b1b474b0f9789ca55ca46f4b2b57aeae38874/googleads/adwords.py#L1989-L2000
def DoesNotContainIgnoreCase(self, value): """Sets the type of the WHERE clause as "doesn not contain ignore case". Args: value: The value to be used in the WHERE condition. Returns: The query builder that this WHERE builder links to. """ self._awql = self._CreateSingleValueCondition( ...
[ "def", "DoesNotContainIgnoreCase", "(", "self", ",", "value", ")", ":", "self", ".", "_awql", "=", "self", ".", "_CreateSingleValueCondition", "(", "value", ",", "'DOES_NOT_CONTAIN_IGNORE_CASE'", ")", "return", "self", ".", "_query_builder" ]
Sets the type of the WHERE clause as "doesn not contain ignore case". Args: value: The value to be used in the WHERE condition. Returns: The query builder that this WHERE builder links to.
[ "Sets", "the", "type", "of", "the", "WHERE", "clause", "as", "doesn", "not", "contain", "ignore", "case", "." ]
python
train
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/certificates/certificates.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/certificates/certificates.py#L321-L332
def type(self): """Certificate type. :return: The type of the certificate. :rtype: CertificateType """ if self._device_mode == 1 or self._type == CertificateType.developer: return CertificateType.developer elif self._type == CertificateType.bootstrap: ...
[ "def", "type", "(", "self", ")", ":", "if", "self", ".", "_device_mode", "==", "1", "or", "self", ".", "_type", "==", "CertificateType", ".", "developer", ":", "return", "CertificateType", ".", "developer", "elif", "self", ".", "_type", "==", "CertificateT...
Certificate type. :return: The type of the certificate. :rtype: CertificateType
[ "Certificate", "type", "." ]
python
train
quantopian/zipline
zipline/utils/numpy_utils.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/numpy_utils.py#L334-L340
def isnat(obj): """ Check if a value is np.NaT. """ if obj.dtype.kind not in ('m', 'M'): raise ValueError("%s is not a numpy datetime or timedelta") return obj.view(int64_dtype) == iNaT
[ "def", "isnat", "(", "obj", ")", ":", "if", "obj", ".", "dtype", ".", "kind", "not", "in", "(", "'m'", ",", "'M'", ")", ":", "raise", "ValueError", "(", "\"%s is not a numpy datetime or timedelta\"", ")", "return", "obj", ".", "view", "(", "int64_dtype", ...
Check if a value is np.NaT.
[ "Check", "if", "a", "value", "is", "np", ".", "NaT", "." ]
python
train
brbsix/python-batchpath
batchpath.py
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L142-L149
def _sorter(generated): """Return a list of paths sorted by dirname & basename.""" pairs = [(os.path.dirname(f), os.path.basename(f)) for f in set(list(generated))] pairs.sort() return [os.path.join(pair[0], pair[1]) for pair in pairs]
[ "def", "_sorter", "(", "generated", ")", ":", "pairs", "=", "[", "(", "os", ".", "path", ".", "dirname", "(", "f", ")", ",", "os", ".", "path", ".", "basename", "(", "f", ")", ")", "for", "f", "in", "set", "(", "list", "(", "generated", ")", ...
Return a list of paths sorted by dirname & basename.
[ "Return", "a", "list", "of", "paths", "sorted", "by", "dirname", "&", "basename", "." ]
python
train
dslackw/slpkg
slpkg/main.py
https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/main.py#L722-L745
def auto_detect(self, args): """Check for already Slackware binary packages exist """ suffixes = [ ".tgz", ".txz", ".tbz", ".tlz" ] if (not args[0].startswith("-") and args[0] not in self.commands and args[0].endswit...
[ "def", "auto_detect", "(", "self", ",", "args", ")", ":", "suffixes", "=", "[", "\".tgz\"", ",", "\".txz\"", ",", "\".tbz\"", ",", "\".tlz\"", "]", "if", "(", "not", "args", "[", "0", "]", ".", "startswith", "(", "\"-\"", ")", "and", "args", "[", "...
Check for already Slackware binary packages exist
[ "Check", "for", "already", "Slackware", "binary", "packages", "exist" ]
python
train
google/grumpy
third_party/stdlib/base64.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/base64.py#L308-L315
def decode(input, output): """Decode a file.""" while True: line = input.readline() if not line: break s = binascii.a2b_base64(line) output.write(s)
[ "def", "decode", "(", "input", ",", "output", ")", ":", "while", "True", ":", "line", "=", "input", ".", "readline", "(", ")", "if", "not", "line", ":", "break", "s", "=", "binascii", ".", "a2b_base64", "(", "line", ")", "output", ".", "write", "("...
Decode a file.
[ "Decode", "a", "file", "." ]
python
valid
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L92-L96
def write_transaction(self, transaction, mode): # This method offers backward compatibility with the Web API. """Submit a valid transaction to the mempool.""" response = self.post_transaction(transaction, mode) return self._process_post_response(response.json(), mode)
[ "def", "write_transaction", "(", "self", ",", "transaction", ",", "mode", ")", ":", "# This method offers backward compatibility with the Web API.", "response", "=", "self", ".", "post_transaction", "(", "transaction", ",", "mode", ")", "return", "self", ".", "_proces...
Submit a valid transaction to the mempool.
[ "Submit", "a", "valid", "transaction", "to", "the", "mempool", "." ]
python
train
googleapis/gax-python
google/gapic/longrunning/operations_client.py
https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gapic/longrunning/operations_client.py#L215-L264
def list_operations(self, name, filter_, page_size=0, options=None): """ Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns ``UNIMPLEMENTED``. NOTE: the ``name`` binding below allows API services to override the binding ...
[ "def", "list_operations", "(", "self", ",", "name", ",", "filter_", ",", "page_size", "=", "0", ",", "options", "=", "None", ")", ":", "# Create the request object.", "request", "=", "operations_pb2", ".", "ListOperationsRequest", "(", "name", "=", "name", ","...
Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns ``UNIMPLEMENTED``. NOTE: the ``name`` binding below allows API services to override the binding to use different resource name schemes, such as ``users/*/operations``. ...
[ "Lists", "operations", "that", "match", "the", "specified", "filter", "in", "the", "request", ".", "If", "the", "server", "doesn", "t", "support", "this", "method", "it", "returns", "UNIMPLEMENTED", ".", "NOTE", ":", "the", "name", "binding", "below", "allow...
python
train
pymc-devs/pymc
pymc/database/pickle.py
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/database/pickle.py#L77-L100
def load(filename): """Load a pickled database. Return a Database instance. """ file = open(filename, 'rb') container = std_pickle.load(file) file.close() db = Database(file.name) chains = 0 funs = set() for k, v in six.iteritems(container): if k == '_state_': ...
[ "def", "load", "(", "filename", ")", ":", "file", "=", "open", "(", "filename", ",", "'rb'", ")", "container", "=", "std_pickle", ".", "load", "(", "file", ")", "file", ".", "close", "(", ")", "db", "=", "Database", "(", "file", ".", "name", ")", ...
Load a pickled database. Return a Database instance.
[ "Load", "a", "pickled", "database", "." ]
python
train
pgmpy/pgmpy
pgmpy/models/NoisyOrModel.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/NoisyOrModel.py#L91-L113
def del_variables(self, variables): """ Deletes variables from the NoisyOrModel. Parameters ---------- variables: list, tuple, dict (array like) list of variables to be deleted. Examples -------- >>> from pgmpy.models import NoisyOrModel ...
[ "def", "del_variables", "(", "self", ",", "variables", ")", ":", "variables", "=", "[", "variables", "]", "if", "isinstance", "(", "variables", ",", "six", ".", "string_types", ")", "else", "set", "(", "variables", ")", "indices", "=", "[", "index", "for...
Deletes variables from the NoisyOrModel. Parameters ---------- variables: list, tuple, dict (array like) list of variables to be deleted. Examples -------- >>> from pgmpy.models import NoisyOrModel >>> model = NoisyOrModel(['x1', 'x2', 'x3'], [2, 3, ...
[ "Deletes", "variables", "from", "the", "NoisyOrModel", "." ]
python
train
DiamondLightSource/python-workflows
workflows/recipe/wrapper.py
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/recipe/wrapper.py#L130-L151
def checkpoint(self, message, header=None, delay=0, **kwargs): """Send a message to the current recipe destination. This can be used to keep a state for longer processing tasks. :param delay: Delay transport of message by this many seconds """ if not self.transport: r...
[ "def", "checkpoint", "(", "self", ",", "message", ",", "header", "=", "None", ",", "delay", "=", "0", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "transport", ":", "raise", "ValueError", "(", "\"This RecipeWrapper object does not contain \""...
Send a message to the current recipe destination. This can be used to keep a state for longer processing tasks. :param delay: Delay transport of message by this many seconds
[ "Send", "a", "message", "to", "the", "current", "recipe", "destination", ".", "This", "can", "be", "used", "to", "keep", "a", "state", "for", "longer", "processing", "tasks", ".", ":", "param", "delay", ":", "Delay", "transport", "of", "message", "by", "...
python
train
NoviceLive/intellicoder
intellicoder/intellisense/formatters.py
https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/intellisense/formatters.py#L59-L72
def format_info(raw): """Format a string representing the information concerning the name. """ logging.debug(_('raw[0]: %s'), raw[0]) results, sense = raw # A scenario where ORM really stands out. new = '\n'.join( '{} {} {} {}'.format( i[0], sense.kind_id_to_name(i[1]), ...
[ "def", "format_info", "(", "raw", ")", ":", "logging", ".", "debug", "(", "_", "(", "'raw[0]: %s'", ")", ",", "raw", "[", "0", "]", ")", "results", ",", "sense", "=", "raw", "# A scenario where ORM really stands out.", "new", "=", "'\\n'", ".", "join", "...
Format a string representing the information concerning the name.
[ "Format", "a", "string", "representing", "the", "information", "concerning", "the", "name", "." ]
python
train
nilp0inter/cpe
cpe/comp/cpecomp1_1.py
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L333-L354
def set_value(self, comp_str, comp_att): """ Set the value of component. By default, the component has a simple value. :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component TEST:...
[ "def", "set_value", "(", "self", ",", "comp_str", ",", "comp_att", ")", ":", "super", "(", "CPEComponent1_1", ",", "self", ")", ".", "set_value", "(", "comp_str", ",", "comp_att", ")", "self", ".", "_is_negated", "=", "comp_str", ".", "startswith", "(", ...
Set the value of component. By default, the component has a simple value. :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component TEST: >>> val = 'xp!vista' >>> val2 = 'sp2' ...
[ "Set", "the", "value", "of", "component", ".", "By", "default", "the", "component", "has", "a", "simple", "value", "." ]
python
train
Diviyan-Kalainathan/CausalDiscoveryToolbox
cdt/independence/graph/FSRegression.py
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/graph/FSRegression.py#L150-L167
def predict_features(self, df_features, df_target, idx=0, **kwargs): """For one variable, predict its neighbouring nodes. Args: df_features (pandas.DataFrame): df_target (pandas.Series): idx (int): (optional) for printing purposes kwargs (dict): additiona...
[ "def", "predict_features", "(", "self", ",", "df_features", ",", "df_target", ",", "idx", "=", "0", ",", "*", "*", "kwargs", ")", ":", "X", "=", "df_features", ".", "values", "y", "=", "df_target", ".", "values", "[", ":", ",", "0", "]", "rr", "=",...
For one variable, predict its neighbouring nodes. Args: df_features (pandas.DataFrame): df_target (pandas.Series): idx (int): (optional) for printing purposes kwargs (dict): additional options for algorithms Returns: list: scores of each feat...
[ "For", "one", "variable", "predict", "its", "neighbouring", "nodes", "." ]
python
valid
mozilla/django-tidings
tidings/utils.py
https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/utils.py#L110-L127
def import_from_setting(setting_name, fallback): """Return the resolution of an import path stored in a Django setting. :arg setting_name: The name of the setting holding the import path :arg fallback: An alternate object to use if the setting is empty or doesn't exist Raise ImproperlyConfigured...
[ "def", "import_from_setting", "(", "setting_name", ",", "fallback", ")", ":", "path", "=", "getattr", "(", "settings", ",", "setting_name", ",", "None", ")", "if", "path", ":", "try", ":", "return", "import_string", "(", "path", ")", "except", "ImportError",...
Return the resolution of an import path stored in a Django setting. :arg setting_name: The name of the setting holding the import path :arg fallback: An alternate object to use if the setting is empty or doesn't exist Raise ImproperlyConfigured if a path is given that can't be resolved.
[ "Return", "the", "resolution", "of", "an", "import", "path", "stored", "in", "a", "Django", "setting", "." ]
python
train
BerkeleyAutomation/autolab_core
autolab_core/dist_metrics.py
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/dist_metrics.py#L9-L23
def abs_angle_diff(v_i, v_j): """ Returns the absolute value of the angle between two 3D vectors. Parameters ---------- v_i : :obj:`numpy.ndarray` the first 3D array v_j : :obj:`numpy.ndarray` the second 3D array """ # compute angle distance dot_prod = min(max(v...
[ "def", "abs_angle_diff", "(", "v_i", ",", "v_j", ")", ":", "# compute angle distance", "dot_prod", "=", "min", "(", "max", "(", "v_i", ".", "dot", "(", "v_j", ")", ",", "-", "1", ")", ",", "1", ")", "angle_diff", "=", "np", ".", "arccos", "(", "dot...
Returns the absolute value of the angle between two 3D vectors. Parameters ---------- v_i : :obj:`numpy.ndarray` the first 3D array v_j : :obj:`numpy.ndarray` the second 3D array
[ "Returns", "the", "absolute", "value", "of", "the", "angle", "between", "two", "3D", "vectors", ".", "Parameters", "----------", "v_i", ":", ":", "obj", ":", "numpy", ".", "ndarray", "the", "first", "3D", "array", "v_j", ":", ":", "obj", ":", "numpy", ...
python
train
wtsi-hgi/python-hgijson
hgijson/serialization.py
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/serialization.py#L154-L162
def _create_serializer_of_type_with_cache(self, serializer_type: Type) -> "Serializer": """ Creates a deserializer of the given type, exploiting a cache. :param serializer_type: the type of deserializer to create :return: the created serializer """ if serializer_type not ...
[ "def", "_create_serializer_of_type_with_cache", "(", "self", ",", "serializer_type", ":", "Type", ")", "->", "\"Serializer\"", ":", "if", "serializer_type", "not", "in", "self", ".", "_serializers_cache", ":", "self", ".", "_serializers_cache", "[", "serializer_type",...
Creates a deserializer of the given type, exploiting a cache. :param serializer_type: the type of deserializer to create :return: the created serializer
[ "Creates", "a", "deserializer", "of", "the", "given", "type", "exploiting", "a", "cache", ".", ":", "param", "serializer_type", ":", "the", "type", "of", "deserializer", "to", "create", ":", "return", ":", "the", "created", "serializer" ]
python
train
gem/oq-engine
openquake/hazardlib/valid.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L507-L515
def positiveint(value): """ :param value: input string :returns: positive integer """ i = int(not_empty(value)) if i < 0: raise ValueError('integer %d < 0' % i) return i
[ "def", "positiveint", "(", "value", ")", ":", "i", "=", "int", "(", "not_empty", "(", "value", ")", ")", "if", "i", "<", "0", ":", "raise", "ValueError", "(", "'integer %d < 0'", "%", "i", ")", "return", "i" ]
:param value: input string :returns: positive integer
[ ":", "param", "value", ":", "input", "string", ":", "returns", ":", "positive", "integer" ]
python
train
adrn/schwimmbad
schwimmbad/mpi.py
https://github.com/adrn/schwimmbad/blob/d2538b77c821a56096f92eafecd1c08dd02f1f58/schwimmbad/mpi.py#L74-L106
def wait(self, callback=None): """Tell the workers to wait and listen for the master process. This is called automatically when using :meth:`MPIPool.map` and doesn't need to be called by the user. """ if self.is_master(): return worker = self.comm.rank ...
[ "def", "wait", "(", "self", ",", "callback", "=", "None", ")", ":", "if", "self", ".", "is_master", "(", ")", ":", "return", "worker", "=", "self", ".", "comm", ".", "rank", "status", "=", "MPI", ".", "Status", "(", ")", "while", "True", ":", "lo...
Tell the workers to wait and listen for the master process. This is called automatically when using :meth:`MPIPool.map` and doesn't need to be called by the user.
[ "Tell", "the", "workers", "to", "wait", "and", "listen", "for", "the", "master", "process", ".", "This", "is", "called", "automatically", "when", "using", ":", "meth", ":", "MPIPool", ".", "map", "and", "doesn", "t", "need", "to", "be", "called", "by", ...
python
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/core_v1_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/core_v1_api.py#L6747-L6771
def create_namespaced_resource_quota(self, namespace, body, **kwargs): # noqa: E501 """create_namespaced_resource_quota # noqa: E501 create a ResourceQuota # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_re...
[ "def", "create_namespaced_resource_quota", "(", "self", ",", "namespace", ",", "body", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "...
create_namespaced_resource_quota # noqa: E501 create a ResourceQuota # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_namespaced_resource_quota(namespace, body, async_req=True...
[ "create_namespaced_resource_quota", "#", "noqa", ":", "E501" ]
python
train
dmlc/xgboost
python-package/xgboost/training.py
https://github.com/dmlc/xgboost/blob/253fdd8a42d5ec6b819788199584d27bf9ea6253/python-package/xgboost/training.py#L115-L216
def train(params, dtrain, num_boost_round=10, evals=(), obj=None, feval=None, maximize=False, early_stopping_rounds=None, evals_result=None, verbose_eval=True, xgb_model=None, callbacks=None, learning_rates=None): # pylint: disable=too-many-statements,too-many-branches, attribute-defined-outside...
[ "def", "train", "(", "params", ",", "dtrain", ",", "num_boost_round", "=", "10", ",", "evals", "=", "(", ")", ",", "obj", "=", "None", ",", "feval", "=", "None", ",", "maximize", "=", "False", ",", "early_stopping_rounds", "=", "None", ",", "evals_resu...
Train a booster with given parameters. Parameters ---------- params : dict Booster params. dtrain : DMatrix Data to be trained. num_boost_round: int Number of boosting iterations. evals: list of pairs (DMatrix, string) List of items to be evaluated during trainin...
[ "Train", "a", "booster", "with", "given", "parameters", "." ]
python
train
numberoverzero/bloop
bloop/conditions.py
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/conditions.py#L166-L181
def _value_ref(self, column, value, *, dumped=False, inner=False): """inner=True uses column.typedef.inner_type instead of column.typedef""" ref = ":v{}".format(self.next_index) # Need to dump this value if not dumped: typedef = column.typedef for segment in path...
[ "def", "_value_ref", "(", "self", ",", "column", ",", "value", ",", "*", ",", "dumped", "=", "False", ",", "inner", "=", "False", ")", ":", "ref", "=", "\":v{}\"", ".", "format", "(", "self", ".", "next_index", ")", "# Need to dump this value", "if", "...
inner=True uses column.typedef.inner_type instead of column.typedef
[ "inner", "=", "True", "uses", "column", ".", "typedef", ".", "inner_type", "instead", "of", "column", ".", "typedef" ]
python
train
GPflow/GPflow
gpflow/transforms.py
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/transforms.py#L378-L391
def backward_tensor(self, y): """ Transforms a series of triangular matrices y to the packed representation x (tf.tensors) :param y: unpacked tensor with shape self.num_matrices, self.N, self.N :return: packed tensor with shape self.num_matrices, (self.N**2 + self.N) / 2 ...
[ "def", "backward_tensor", "(", "self", ",", "y", ")", ":", "if", "self", ".", "squeeze", ":", "y", "=", "tf", ".", "expand_dims", "(", "y", ",", "axis", "=", "0", ")", "indices", "=", "np", ".", "vstack", "(", "np", ".", "tril_indices", "(", "sel...
Transforms a series of triangular matrices y to the packed representation x (tf.tensors) :param y: unpacked tensor with shape self.num_matrices, self.N, self.N :return: packed tensor with shape self.num_matrices, (self.N**2 + self.N) / 2
[ "Transforms", "a", "series", "of", "triangular", "matrices", "y", "to", "the", "packed", "representation", "x", "(", "tf", ".", "tensors", ")", ":", "param", "y", ":", "unpacked", "tensor", "with", "shape", "self", ".", "num_matrices", "self", ".", "N", ...
python
train
APSL/transmanager
transmanager/utils.py
https://github.com/APSL/transmanager/blob/79157085840008e146b264521681913090197ed1/transmanager/utils.py#L61-L73
def has_field(mc, field_name): """ detect if a model has a given field has :param field_name: :param mc: :return: """ try: mc._meta.get_field(field_name) except FieldDoesNotExist: return False return True
[ "def", "has_field", "(", "mc", ",", "field_name", ")", ":", "try", ":", "mc", ".", "_meta", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", ":", "return", "False", "return", "True" ]
detect if a model has a given field has :param field_name: :param mc: :return:
[ "detect", "if", "a", "model", "has", "a", "given", "field", "has" ]
python
train
rodluger/everest
everest/missions/k2/utils.py
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L627-L641
def SaturationFlux(EPIC, campaign=None, **kwargs): ''' Returns the well depth for the target. If any of the target's pixels have flux larger than this value, they are likely to be saturated and cause charge bleeding. The well depths were obtained from Table 13 of the Kepler instrument handbook. We a...
[ "def", "SaturationFlux", "(", "EPIC", ",", "campaign", "=", "None", ",", "*", "*", "kwargs", ")", ":", "channel", ",", "well_depth", "=", "np", ".", "loadtxt", "(", "os", ".", "path", ".", "join", "(", "EVEREST_SRC", ",", "'missions'", ",", "'k2'", "...
Returns the well depth for the target. If any of the target's pixels have flux larger than this value, they are likely to be saturated and cause charge bleeding. The well depths were obtained from Table 13 of the Kepler instrument handbook. We assume an exposure time of 6.02s.
[ "Returns", "the", "well", "depth", "for", "the", "target", ".", "If", "any", "of", "the", "target", "s", "pixels", "have", "flux", "larger", "than", "this", "value", "they", "are", "likely", "to", "be", "saturated", "and", "cause", "charge", "bleeding", ...
python
train
secdev/scapy
scapy/layers/tls/cert.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L910-L930
def verifyChain(self, anchors, untrusted=None): """ Perform verification of certificate chains for that certificate. A list of anchors is required. The certificates in the optional untrusted list may be used as additional elements to the final chain. On par with chain instantiati...
[ "def", "verifyChain", "(", "self", ",", "anchors", ",", "untrusted", "=", "None", ")", ":", "untrusted", "=", "untrusted", "or", "[", "]", "for", "a", "in", "anchors", ":", "chain", "=", "Chain", "(", "self", "+", "untrusted", ",", "a", ")", "if", ...
Perform verification of certificate chains for that certificate. A list of anchors is required. The certificates in the optional untrusted list may be used as additional elements to the final chain. On par with chain instantiation, only one chain constructed with the untrusted candidates...
[ "Perform", "verification", "of", "certificate", "chains", "for", "that", "certificate", ".", "A", "list", "of", "anchors", "is", "required", ".", "The", "certificates", "in", "the", "optional", "untrusted", "list", "may", "be", "used", "as", "additional", "ele...
python
train
aio-libs/aioftp
aioftp/client.py
https://github.com/aio-libs/aioftp/blob/b45395b1aba41301b898040acade7010e6878a08/aioftp/client.py#L895-L911
def append_stream(self, destination, *, offset=0): """ Create stream for append (write) data to `destination` file. :param destination: destination path of file on server side :type destination: :py:class:`str` or :py:class:`pathlib.PurePosixPath` :param offset: byte offset for...
[ "def", "append_stream", "(", "self", ",", "destination", ",", "*", ",", "offset", "=", "0", ")", ":", "return", "self", ".", "get_stream", "(", "\"APPE \"", "+", "str", "(", "destination", ")", ",", "\"1xx\"", ",", "offset", "=", "offset", ",", ")" ]
Create stream for append (write) data to `destination` file. :param destination: destination path of file on server side :type destination: :py:class:`str` or :py:class:`pathlib.PurePosixPath` :param offset: byte offset for stream start position :type offset: :py:class:`int` :...
[ "Create", "stream", "for", "append", "(", "write", ")", "data", "to", "destination", "file", "." ]
python
valid
diffeo/rejester
rejester/_task_master.py
https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L443-L469
def update(self, lease_time=None): '''Refresh this task's expiration time. This tries to set the task's expiration time to the current time, plus `lease_time` seconds. It requires the job to not already be complete. If `lease_time` is negative, makes the job immediately be ava...
[ "def", "update", "(", "self", ",", "lease_time", "=", "None", ")", ":", "if", "lease_time", "is", "None", ":", "lease_time", "=", "self", ".", "default_lifetime", "with", "self", ".", "registry", ".", "lock", "(", "identifier", "=", "self", ".", "worker_...
Refresh this task's expiration time. This tries to set the task's expiration time to the current time, plus `lease_time` seconds. It requires the job to not already be complete. If `lease_time` is negative, makes the job immediately be available for other workers to run. :par...
[ "Refresh", "this", "task", "s", "expiration", "time", "." ]
python
train
JasonKessler/scattertext
scattertext/__init__.py
https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/__init__.py#L681-L734
def word_similarity_explorer(corpus, category, category_name, not_category_name, target_term, nlp=None, alpha=0.01, m...
[ "def", "word_similarity_explorer", "(", "corpus", ",", "category", ",", "category_name", ",", "not_category_name", ",", "target_term", ",", "nlp", "=", "None", ",", "alpha", "=", "0.01", ",", "max_p_val", "=", "0.1", ",", "*", "*", "kwargs", ")", ":", "if"...
Parameters ---------- corpus : Corpus Corpus to use. category : str Name of category column as it appears in original data frame. category_name : str Name of category to use. E.g., "5-star reviews." not_category_name : str Name of everything that isn't in category. ...
[ "Parameters", "----------", "corpus", ":", "Corpus", "Corpus", "to", "use", ".", "category", ":", "str", "Name", "of", "category", "column", "as", "it", "appears", "in", "original", "data", "frame", ".", "category_name", ":", "str", "Name", "of", "category",...
python
train
bitesofcode/projexui
projexui/widgets/xpopupwidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpopupwidget.py#L1212-L1281
def showToolTip( text, point = None, anchor = None, parent = None, background = None, foreground = None, key = None, seconds = 5 ): ""...
[ "def", "showToolTip", "(", "text", ",", "point", "=", "None", ",", "anchor", "=", "None", ",", "parent", "=", "None", ",", "background", "=", "None", ",", "foreground", "=", "None", ",", "key", "=", "None", ",", "seconds", "=", "5", ")", ":", "if",...
Displays a popup widget as a tooltip bubble. :param text | <str> point | <QPoint> || None anchor | <XPopupWidget.Mode.Anchor> || None parent | <QWidget> || None background | <QColor> || No...
[ "Displays", "a", "popup", "widget", "as", "a", "tooltip", "bubble", ".", ":", "param", "text", "|", "<str", ">", "point", "|", "<QPoint", ">", "||", "None", "anchor", "|", "<XPopupWidget", ".", "Mode", ".", "Anchor", ">", "||", "None", "parent", "|", ...
python
train
lpantano/seqcluster
seqcluster/libs/read.py
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/read.py#L33-L36
def write_data(data, out_file): """write json file from seqcluster cluster""" with open(out_file, 'w') as handle_out: handle_out.write(json.dumps([data], skipkeys=True, indent=2))
[ "def", "write_data", "(", "data", ",", "out_file", ")", ":", "with", "open", "(", "out_file", ",", "'w'", ")", "as", "handle_out", ":", "handle_out", ".", "write", "(", "json", ".", "dumps", "(", "[", "data", "]", ",", "skipkeys", "=", "True", ",", ...
write json file from seqcluster cluster
[ "write", "json", "file", "from", "seqcluster", "cluster" ]
python
train
Azure/azure-cli-extensions
src/interactive/azext_interactive/azclishell/progress.py
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/interactive/azext_interactive/azclishell/progress.py#L67-L118
def progress_view(shell): """ updates the view """ while not ShellProgressView.done: _, col = get_window_dim() col = int(col) progress = get_progress_message() if '\n' in progress: prog_list = progress.split('\n') prog_val = len(prog_list[-1]) else...
[ "def", "progress_view", "(", "shell", ")", ":", "while", "not", "ShellProgressView", ".", "done", ":", "_", ",", "col", "=", "get_window_dim", "(", ")", "col", "=", "int", "(", "col", ")", "progress", "=", "get_progress_message", "(", ")", "if", "'\\n'",...
updates the view
[ "updates", "the", "view" ]
python
train
epfl-idevelop/epfl-ldap
epflldap/utils.py
https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/utils.py#L11-L22
def get_optional_env(key): """ Return the value of an optional environment variable, and use the provided default if it's not set. """ environment_variable_value = os.environ.get(key) if environment_variable_value: return environment_variable_value elif key in CONSTANTS: retu...
[ "def", "get_optional_env", "(", "key", ")", ":", "environment_variable_value", "=", "os", ".", "environ", ".", "get", "(", "key", ")", "if", "environment_variable_value", ":", "return", "environment_variable_value", "elif", "key", "in", "CONSTANTS", ":", "return",...
Return the value of an optional environment variable, and use the provided default if it's not set.
[ "Return", "the", "value", "of", "an", "optional", "environment", "variable", "and", "use", "the", "provided", "default", "if", "it", "s", "not", "set", "." ]
python
train
racitup/static-ranges
static_ranges.py
https://github.com/racitup/static-ranges/blob/a15c2e2bd6f643279ae046494b8714634dd380a4/static_ranges.py#L110-L122
def check_ranges(cls, ranges, length): """Removes errored ranges""" result = [] for start, end in ranges: if isinstance(start, int) or isinstance(end, int): if isinstance(start, int) and not (0 <= start < length): continue elif isin...
[ "def", "check_ranges", "(", "cls", ",", "ranges", ",", "length", ")", ":", "result", "=", "[", "]", "for", "start", ",", "end", "in", "ranges", ":", "if", "isinstance", "(", "start", ",", "int", ")", "or", "isinstance", "(", "end", ",", "int", ")",...
Removes errored ranges
[ "Removes", "errored", "ranges" ]
python
valid
djgagne/hagelslag
hagelslag/evaluation/ProbabilityMetrics.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/ProbabilityMetrics.py#L495-L502
def crps_climo(self): """ Calculate the climatological CRPS. """ o_bar = self.errors["O"].values / float(self.num_forecasts) crps_c = np.sum(self.num_forecasts * (o_bar ** 2) - o_bar * self.errors["O"].values * 2.0 + self.errors["O_2"].values) / float(self...
[ "def", "crps_climo", "(", "self", ")", ":", "o_bar", "=", "self", ".", "errors", "[", "\"O\"", "]", ".", "values", "/", "float", "(", "self", ".", "num_forecasts", ")", "crps_c", "=", "np", ".", "sum", "(", "self", ".", "num_forecasts", "*", "(", "...
Calculate the climatological CRPS.
[ "Calculate", "the", "climatological", "CRPS", "." ]
python
train
Metatab/geoid
geoid/core.py
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L408-L416
def augment(module_name, base_class): """Call the augment() method for all of the derived classes in the module """ for name, cls in inspect.getmembers(sys.modules[module_name], lambda x : inspect.isclass(x) and issubclass(x, base_class) ): if cls == base_class:...
[ "def", "augment", "(", "module_name", ",", "base_class", ")", ":", "for", "name", ",", "cls", "in", "inspect", ".", "getmembers", "(", "sys", ".", "modules", "[", "module_name", "]", ",", "lambda", "x", ":", "inspect", ".", "isclass", "(", "x", ")", ...
Call the augment() method for all of the derived classes in the module
[ "Call", "the", "augment", "()", "method", "for", "all", "of", "the", "derived", "classes", "in", "the", "module" ]
python
train
SheffieldML/GPyOpt
GPyOpt/acquisitions/LP.py
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LP.py#L40-L46
def update_batches(self, X_batch, L, Min): """ Updates the batches internally and pre-computes the """ self.X_batch = X_batch if X_batch is not None: self.r_x0, self.s_x0 = self._hammer_function_precompute(X_batch, L, Min, self.model)
[ "def", "update_batches", "(", "self", ",", "X_batch", ",", "L", ",", "Min", ")", ":", "self", ".", "X_batch", "=", "X_batch", "if", "X_batch", "is", "not", "None", ":", "self", ".", "r_x0", ",", "self", ".", "s_x0", "=", "self", ".", "_hammer_functio...
Updates the batches internally and pre-computes the
[ "Updates", "the", "batches", "internally", "and", "pre", "-", "computes", "the" ]
python
train
astropy/regions
regions/io/core.py
https://github.com/astropy/regions/blob/452d962c417e4ff20d1268f99535c6ff89c83437/regions/io/core.py#L594-L628
def to_region(self): """ Converts to region, ``regions.Region`` object """ coords = self.convert_coords() log.debug(coords) viz_keywords = ['color', 'dash', 'dashlist', 'width', 'font', 'symsize', 'symbol', 'symsize', 'fontsize', 'fontstyle', 'use...
[ "def", "to_region", "(", "self", ")", ":", "coords", "=", "self", ".", "convert_coords", "(", ")", "log", ".", "debug", "(", "coords", ")", "viz_keywords", "=", "[", "'color'", ",", "'dash'", ",", "'dashlist'", ",", "'width'", ",", "'font'", ",", "'sym...
Converts to region, ``regions.Region`` object
[ "Converts", "to", "region", "regions", ".", "Region", "object" ]
python
train
mitsei/dlkit
dlkit/handcar/learning/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/sessions.py#L440-L474
def get_objectives_by_query(self, objective_query=None): """Gets a list of Objectives matching the given objective query. arg: objectiveQuery (osid.learning.ObjectiveQuery): the objective query return: (osid.learning.ObjectiveList) - the returned ObjectiveList...
[ "def", "get_objectives_by_query", "(", "self", ",", "objective_query", "=", "None", ")", ":", "if", "objective_query", "is", "None", ":", "raise", "NullArgument", "(", ")", "if", "'ancestorObjectiveId'", "in", "objective_query", ".", "_query_terms", ":", "url_path...
Gets a list of Objectives matching the given objective query. arg: objectiveQuery (osid.learning.ObjectiveQuery): the objective query return: (osid.learning.ObjectiveList) - the returned ObjectiveList raise: NullArgument - objectiveQuery is null raise...
[ "Gets", "a", "list", "of", "Objectives", "matching", "the", "given", "objective", "query", "." ]
python
train
Toilal/rebulk
rebulk/match.py
https://github.com/Toilal/rebulk/blob/7511a4671f2fd9493e3df1e5177b7656789069e8/rebulk/match.py#L104-L124
def _add_match(self, match): """ Add a match :param match: :type match: Match """ if self.__name_dict is not None: if match.name: _BaseMatches._base_add(self._name_dict[match.name], (match)) if self.__tag_dict is not None: f...
[ "def", "_add_match", "(", "self", ",", "match", ")", ":", "if", "self", ".", "__name_dict", "is", "not", "None", ":", "if", "match", ".", "name", ":", "_BaseMatches", ".", "_base_add", "(", "self", ".", "_name_dict", "[", "match", ".", "name", "]", "...
Add a match :param match: :type match: Match
[ "Add", "a", "match", ":", "param", "match", ":", ":", "type", "match", ":", "Match" ]
python
train
pygobject/pgi
pgi/overrides/Gtk.py
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1502-L1512
def set_value(self, treeiter, column, value): """ {{ all }} `value` can also be a Python value and will be converted to a :obj:`GObject.Value` using the corresponding column type (See :obj:`Gtk.ListStore.set_column_types`\\()). """ value = self._convert_value(co...
[ "def", "set_value", "(", "self", ",", "treeiter", ",", "column", ",", "value", ")", ":", "value", "=", "self", ".", "_convert_value", "(", "column", ",", "value", ")", "Gtk", ".", "ListStore", ".", "set_value", "(", "self", ",", "treeiter", ",", "colum...
{{ all }} `value` can also be a Python value and will be converted to a :obj:`GObject.Value` using the corresponding column type (See :obj:`Gtk.ListStore.set_column_types`\\()).
[ "{{", "all", "}}" ]
python
train
rigetti/pyquil
pyquil/api/_benchmark.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/api/_benchmark.py#L45-L79
def apply_clifford_to_pauli(self, clifford, pauli_in): r""" Given a circuit that consists only of elements of the Clifford group, return its action on a PauliTerm. In particular, for Clifford C, and Pauli P, this returns the PauliTerm representing CPC^{\dagger}. :param ...
[ "def", "apply_clifford_to_pauli", "(", "self", ",", "clifford", ",", "pauli_in", ")", ":", "# do nothing if `pauli_in` is the identity", "if", "is_identity", "(", "pauli_in", ")", ":", "return", "pauli_in", "indices_and_terms", "=", "list", "(", "zip", "(", "*", "...
r""" Given a circuit that consists only of elements of the Clifford group, return its action on a PauliTerm. In particular, for Clifford C, and Pauli P, this returns the PauliTerm representing CPC^{\dagger}. :param Program clifford: A Program that consists only of Clifford oper...
[ "r", "Given", "a", "circuit", "that", "consists", "only", "of", "elements", "of", "the", "Clifford", "group", "return", "its", "action", "on", "a", "PauliTerm", "." ]
python
train
synw/dataswim
dataswim/messages.py
https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/messages.py#L26-L31
def status(self, *msg): """ Prints a status message """ label = colors.yellow("STATUS") self._msg(label, *msg)
[ "def", "status", "(", "self", ",", "*", "msg", ")", ":", "label", "=", "colors", ".", "yellow", "(", "\"STATUS\"", ")", "self", ".", "_msg", "(", "label", ",", "*", "msg", ")" ]
Prints a status message
[ "Prints", "a", "status", "message" ]
python
train
androguard/androguard
androguard/core/bytecodes/dvm.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/dvm.py#L2998-L3033
def get_short_string(self): """ Return a shorter formatted String which encodes this method. The returned name has the form: <classname> <methodname> ([arguments ...])<returntype> * All Class names are condensed to the actual name (no package). * Access flags are not ret...
[ "def", "get_short_string", "(", "self", ")", ":", "def", "_fmt_classname", "(", "cls", ")", ":", "arr", "=", "\"\"", "# Test for arrays", "while", "cls", ".", "startswith", "(", "\"[\"", ")", ":", "arr", "+=", "\"[\"", "cls", "=", "cls", "[", "1", ":",...
Return a shorter formatted String which encodes this method. The returned name has the form: <classname> <methodname> ([arguments ...])<returntype> * All Class names are condensed to the actual name (no package). * Access flags are not returned. * <init> and <clinit> are NOT rep...
[ "Return", "a", "shorter", "formatted", "String", "which", "encodes", "this", "method", ".", "The", "returned", "name", "has", "the", "form", ":", "<classname", ">", "<methodname", ">", "(", "[", "arguments", "...", "]", ")", "<returntype", ">" ]
python
train
elsampsa/valkka-live
valkka/mvision/alpr/base.py
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/base.py#L75-L102
def init(self): """Init alpr The LicensePlateDetector object gets instantiated in the multiprocess, so the library is imported in the multiprocess (i.e. "other side of the fork") as well """ # some modules might need to be imported "on the other side of the fork" # .. bu...
[ "def", "init", "(", "self", ")", ":", "# some modules might need to be imported \"on the other side of the fork\"", "# .. but the, when importing this module, the import is not tested", "#", "# ", "# from openalpr import Alpr", "from", "valkka", ".", "mvision", ".", "alpr", ".", ...
Init alpr The LicensePlateDetector object gets instantiated in the multiprocess, so the library is imported in the multiprocess (i.e. "other side of the fork") as well
[ "Init", "alpr", "The", "LicensePlateDetector", "object", "gets", "instantiated", "in", "the", "multiprocess", "so", "the", "library", "is", "imported", "in", "the", "multiprocess", "(", "i", ".", "e", ".", "other", "side", "of", "the", "fork", ")", "as", "...
python
train
BD2KGenomics/protect
src/protect/pipeline/ProTECT.py
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/pipeline/ProTECT.py#L436-L449
def parse_config_file(job, config_file, max_cores=None): """ Parse the config file and spawn a ProTECT job for every input sample. :param str config_file: Path to the input config file :param int max_cores: The maximum cores to use for any single high-compute job. """ sample_set, univ_options, ...
[ "def", "parse_config_file", "(", "job", ",", "config_file", ",", "max_cores", "=", "None", ")", ":", "sample_set", ",", "univ_options", ",", "processed_tool_inputs", "=", "_parse_config_file", "(", "job", ",", "config_file", ",", "max_cores", ")", "# Start a job f...
Parse the config file and spawn a ProTECT job for every input sample. :param str config_file: Path to the input config file :param int max_cores: The maximum cores to use for any single high-compute job.
[ "Parse", "the", "config", "file", "and", "spawn", "a", "ProTECT", "job", "for", "every", "input", "sample", "." ]
python
train
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L638-L650
def validate_list_of_identical_dicts(self, list_of_dicts): """Check that all dicts within a list are identical.""" hashes = [] for _dict in list_of_dicts: hashes.append(hash(frozenset(_dict.items()))) self.log.debug('Hashes: {}'.format(hashes)) if len(set(hashes)) ==...
[ "def", "validate_list_of_identical_dicts", "(", "self", ",", "list_of_dicts", ")", ":", "hashes", "=", "[", "]", "for", "_dict", "in", "list_of_dicts", ":", "hashes", ".", "append", "(", "hash", "(", "frozenset", "(", "_dict", ".", "items", "(", ")", ")", ...
Check that all dicts within a list are identical.
[ "Check", "that", "all", "dicts", "within", "a", "list", "are", "identical", "." ]
python
train
RI-imaging/qpformat
qpformat/file_formats/series_hdf5_qpimage.py
https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_hdf5_qpimage.py#L49-L60
def get_qpimage_raw(self, idx): """Return QPImage without background correction""" with self._qpseries() as qps: qpi = qps.get_qpimage(index=idx).copy() # Remove previously performed background correction qpi.set_bg_data(None) # Force meta data for key in self...
[ "def", "get_qpimage_raw", "(", "self", ",", "idx", ")", ":", "with", "self", ".", "_qpseries", "(", ")", "as", "qps", ":", "qpi", "=", "qps", ".", "get_qpimage", "(", "index", "=", "idx", ")", ".", "copy", "(", ")", "# Remove previously performed backgro...
Return QPImage without background correction
[ "Return", "QPImage", "without", "background", "correction" ]
python
train
limix/glimix-core
glimix_core/_util/random.py
https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/_util/random.py#L1-L23
def multivariate_normal(random, mean, cov): """ Draw random samples from a multivariate normal distribution. Parameters ---------- random : np.random.RandomState instance Random state. mean : array_like Mean of the n-dimensional distribution. cov : array_like Covaria...
[ "def", "multivariate_normal", "(", "random", ",", "mean", ",", "cov", ")", ":", "from", "numpy", ".", "linalg", "import", "cholesky", "L", "=", "cholesky", "(", "cov", ")", "return", "L", "@", "random", ".", "randn", "(", "L", ".", "shape", "[", "0",...
Draw random samples from a multivariate normal distribution. Parameters ---------- random : np.random.RandomState instance Random state. mean : array_like Mean of the n-dimensional distribution. cov : array_like Covariance matrix of the distribution. It must be symmetric and...
[ "Draw", "random", "samples", "from", "a", "multivariate", "normal", "distribution", "." ]
python
valid
google-research/batch-ppo
agents/tools/in_graph_batch_env.py
https://github.com/google-research/batch-ppo/blob/3d09705977bae4e7c3eb20339a3b384d2a5531e4/agents/tools/in_graph_batch_env.py#L104-L125
def reset(self, indices=None): """Reset the batch of environments. Args: indices: The batch indices of the environments to reset; defaults to all. Returns: Batch tensor of the new observations. """ if indices is None: indices = tf.range(len(self._batch_env)) observ_dtype = se...
[ "def", "reset", "(", "self", ",", "indices", "=", "None", ")", ":", "if", "indices", "is", "None", ":", "indices", "=", "tf", ".", "range", "(", "len", "(", "self", ".", "_batch_env", ")", ")", "observ_dtype", "=", "self", ".", "_parse_dtype", "(", ...
Reset the batch of environments. Args: indices: The batch indices of the environments to reset; defaults to all. Returns: Batch tensor of the new observations.
[ "Reset", "the", "batch", "of", "environments", "." ]
python
train
codeinn/vcs
vcs/backends/git/inmemory.py
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/inmemory.py#L161-L199
def _get_missing_trees(self, path, root_tree): """ Creates missing ``Tree`` objects for the given path. :param path: path given as a string. It may be a path to a file node (i.e. ``foo/bar/baz.txt``) or directory path - in that case it must end with slash (i.e. ``foo/bar/``)...
[ "def", "_get_missing_trees", "(", "self", ",", "path", ",", "root_tree", ")", ":", "dirpath", "=", "posixpath", ".", "split", "(", "path", ")", "[", "0", "]", "dirs", "=", "dirpath", ".", "split", "(", "'/'", ")", "if", "not", "dirs", "or", "dirs", ...
Creates missing ``Tree`` objects for the given path. :param path: path given as a string. It may be a path to a file node (i.e. ``foo/bar/baz.txt``) or directory path - in that case it must end with slash (i.e. ``foo/bar/``). :param root_tree: ``dulwich.objects.Tree`` object from wh...
[ "Creates", "missing", "Tree", "objects", "for", "the", "given", "path", "." ]
python
train
bwohlberg/sporco
sporco/linalg.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/linalg.py#L123-L158
def pyfftw_rfftn_empty_aligned(shape, axes, dtype, order='C', n=None): """ Construct an empty byte-aligned array for efficient use by :mod:`pyfftw` functions :func:`pyfftw.interfaces.numpy_fft.rfftn` and :func:`pyfftw.interfaces.numpy_fft.irfftn`. The shape of the empty array is appropriate for the ...
[ "def", "pyfftw_rfftn_empty_aligned", "(", "shape", ",", "axes", ",", "dtype", ",", "order", "=", "'C'", ",", "n", "=", "None", ")", ":", "ashp", "=", "list", "(", "shape", ")", "raxis", "=", "axes", "[", "-", "1", "]", "ashp", "[", "raxis", "]", ...
Construct an empty byte-aligned array for efficient use by :mod:`pyfftw` functions :func:`pyfftw.interfaces.numpy_fft.rfftn` and :func:`pyfftw.interfaces.numpy_fft.irfftn`. The shape of the empty array is appropriate for the output of :func:`pyfftw.interfaces.numpy_fft.rfftn` applied to an array of ...
[ "Construct", "an", "empty", "byte", "-", "aligned", "array", "for", "efficient", "use", "by", ":", "mod", ":", "pyfftw", "functions", ":", "func", ":", "pyfftw", ".", "interfaces", ".", "numpy_fft", ".", "rfftn", "and", ":", "func", ":", "pyfftw", ".", ...
python
train
boriel/zxbasic
asmparse.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L329-L337
def define(self, value, lineno, namespace=None): """ Defines label value. It can be anything. Even an AST """ if self.defined: error(lineno, "label '%s' already defined at line %i" % (self.name, self.lineno)) self.value = value self.lineno = lineno self.names...
[ "def", "define", "(", "self", ",", "value", ",", "lineno", ",", "namespace", "=", "None", ")", ":", "if", "self", ".", "defined", ":", "error", "(", "lineno", ",", "\"label '%s' already defined at line %i\"", "%", "(", "self", ".", "name", ",", "self", "...
Defines label value. It can be anything. Even an AST
[ "Defines", "label", "value", ".", "It", "can", "be", "anything", ".", "Even", "an", "AST" ]
python
train
Koed00/django-q
django_q/tasks.py
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L222-L246
def fetch_cached(task_id, wait=0, broker=None): """ Return the processed task from the cache backend """ if not broker: broker = get_broker() start = time() while True: r = broker.cache.get('{}:{}'.format(broker.list_key, task_id)) if r: task = SignedPackage.l...
[ "def", "fetch_cached", "(", "task_id", ",", "wait", "=", "0", ",", "broker", "=", "None", ")", ":", "if", "not", "broker", ":", "broker", "=", "get_broker", "(", ")", "start", "=", "time", "(", ")", "while", "True", ":", "r", "=", "broker", ".", ...
Return the processed task from the cache backend
[ "Return", "the", "processed", "task", "from", "the", "cache", "backend" ]
python
train
chrisjrn/registrasion
registrasion/views.py
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L629-L672
def checkout(request, user_id=None): ''' Runs the checkout process for the current cart. If the query string contains ``fix_errors=true``, Registrasion will attempt to fix errors preventing the system from checking out, including by cancelling expired discounts and vouchers, and removing any unavailabl...
[ "def", "checkout", "(", "request", ",", "user_id", "=", "None", ")", ":", "if", "user_id", "is", "not", "None", ":", "if", "request", ".", "user", ".", "is_staff", ":", "user", "=", "User", ".", "objects", ".", "get", "(", "id", "=", "int", "(", ...
Runs the checkout process for the current cart. If the query string contains ``fix_errors=true``, Registrasion will attempt to fix errors preventing the system from checking out, including by cancelling expired discounts and vouchers, and removing any unavailable products. Arguments: user_...
[ "Runs", "the", "checkout", "process", "for", "the", "current", "cart", "." ]
python
test
pachyderm/python-pachyderm
src/python_pachyderm/pfs_client.py
https://github.com/pachyderm/python-pachyderm/blob/1c58cf91d30e03716a4f45213989e890f7b8a78c/src/python_pachyderm/pfs_client.py#L60-L69
def inspect_repo(self, repo_name): """ Returns info about a specific Repo. Params: * repo_name: Name of the repo. """ req = proto.InspectRepoRequest(repo=proto.Repo(name=repo_name)) res = self.stub.InspectRepo(req, metadata=self.metadata) return r...
[ "def", "inspect_repo", "(", "self", ",", "repo_name", ")", ":", "req", "=", "proto", ".", "InspectRepoRequest", "(", "repo", "=", "proto", ".", "Repo", "(", "name", "=", "repo_name", ")", ")", "res", "=", "self", ".", "stub", ".", "InspectRepo", "(", ...
Returns info about a specific Repo. Params: * repo_name: Name of the repo.
[ "Returns", "info", "about", "a", "specific", "Repo", ".", "Params", ":", "*", "repo_name", ":", "Name", "of", "the", "repo", "." ]
python
train
angr/angr
angr/sim_type.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/sim_type.py#L1006-L1015
def do_preprocess(defn): """ Run a string through the C preprocessor that ships with pycparser but is weirdly inaccessible? """ from pycparser.ply import lex, cpp lexer = lex.lex(cpp) p = cpp.Preprocessor(lexer) # p.add_path(dir) will add dir to the include search path p.parse(defn) ...
[ "def", "do_preprocess", "(", "defn", ")", ":", "from", "pycparser", ".", "ply", "import", "lex", ",", "cpp", "lexer", "=", "lex", ".", "lex", "(", "cpp", ")", "p", "=", "cpp", ".", "Preprocessor", "(", "lexer", ")", "# p.add_path(dir) will add dir to the i...
Run a string through the C preprocessor that ships with pycparser but is weirdly inaccessible?
[ "Run", "a", "string", "through", "the", "C", "preprocessor", "that", "ships", "with", "pycparser", "but", "is", "weirdly", "inaccessible?" ]
python
train
matllubos/django-is-core
is_core/utils/__init__.py
https://github.com/matllubos/django-is-core/blob/3f87ec56a814738683c732dce5f07e0328c2300d/is_core/utils/__init__.py#L301-L310
def get_obj_url(request, obj): """ Returns object URL if current logged user has permissions to see the object """ if (is_callable(getattr(obj, 'get_absolute_url', None)) and (not hasattr(obj, 'can_see_edit_link') or (is_callable(getattr(obj, 'can_see_edit_link', None)) and obj....
[ "def", "get_obj_url", "(", "request", ",", "obj", ")", ":", "if", "(", "is_callable", "(", "getattr", "(", "obj", ",", "'get_absolute_url'", ",", "None", ")", ")", "and", "(", "not", "hasattr", "(", "obj", ",", "'can_see_edit_link'", ")", "or", "(", "i...
Returns object URL if current logged user has permissions to see the object
[ "Returns", "object", "URL", "if", "current", "logged", "user", "has", "permissions", "to", "see", "the", "object" ]
python
train
Yelp/uwsgi_metrics
uwsgi_metrics/metrics.py
https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/metrics.py#L208-L216
def counter(module, name, count=1): """ Record an event's occurence in a counter: :: counter(__name__, 'my_counter') """ counter = get_metric('counters', module, name, Counter()) counter.inc(count)
[ "def", "counter", "(", "module", ",", "name", ",", "count", "=", "1", ")", ":", "counter", "=", "get_metric", "(", "'counters'", ",", "module", ",", "name", ",", "Counter", "(", ")", ")", "counter", ".", "inc", "(", "count", ")" ]
Record an event's occurence in a counter: :: counter(__name__, 'my_counter')
[ "Record", "an", "event", "s", "occurence", "in", "a", "counter", ":", "::" ]
python
train
tensorpack/tensorpack
tensorpack/tfutils/dependency.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/tfutils/dependency.py#L16-L38
def dependency_of_targets(targets, op): """ Check that op is in the subgraph induced by the dependencies of targets. The result is memoized. This is useful if some SessionRunHooks should be run only together with certain ops. Args: targets: a tuple of ops or tensors. The targets to find de...
[ "def", "dependency_of_targets", "(", "targets", ",", "op", ")", ":", "# TODO tensorarray? sparsetensor?", "if", "isinstance", "(", "op", ",", "tf", ".", "Tensor", ")", ":", "op", "=", "op", ".", "op", "assert", "isinstance", "(", "op", ",", "tf", ".", "O...
Check that op is in the subgraph induced by the dependencies of targets. The result is memoized. This is useful if some SessionRunHooks should be run only together with certain ops. Args: targets: a tuple of ops or tensors. The targets to find dependencies of. op (tf.Operation or tf.Tensor...
[ "Check", "that", "op", "is", "in", "the", "subgraph", "induced", "by", "the", "dependencies", "of", "targets", ".", "The", "result", "is", "memoized", "." ]
python
train
wmayner/pyphi
pyphi/compute/parallel.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L24-L46
def get_num_processes(): """Return the number of processes to use in parallel.""" cpu_count = multiprocessing.cpu_count() if config.NUMBER_OF_CORES == 0: raise ValueError( 'Invalid NUMBER_OF_CORES; value may not be 0.') if config.NUMBER_OF_CORES > cpu_count: log.info('Reque...
[ "def", "get_num_processes", "(", ")", ":", "cpu_count", "=", "multiprocessing", ".", "cpu_count", "(", ")", "if", "config", ".", "NUMBER_OF_CORES", "==", "0", ":", "raise", "ValueError", "(", "'Invalid NUMBER_OF_CORES; value may not be 0.'", ")", "if", "config", "...
Return the number of processes to use in parallel.
[ "Return", "the", "number", "of", "processes", "to", "use", "in", "parallel", "." ]
python
train
saltstack/salt
salt/utils/gitfs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2146-L2269
def init_remotes(self, remotes, per_remote_overrides=(), per_remote_only=PER_REMOTE_ONLY, global_only=GLOBAL_ONLY): ''' Initialize remotes ''' # The global versions of the auth params (gitfs_user, # gitfs_password, etc.) default to empty ...
[ "def", "init_remotes", "(", "self", ",", "remotes", ",", "per_remote_overrides", "=", "(", ")", ",", "per_remote_only", "=", "PER_REMOTE_ONLY", ",", "global_only", "=", "GLOBAL_ONLY", ")", ":", "# The global versions of the auth params (gitfs_user,", "# gitfs_password, et...
Initialize remotes
[ "Initialize", "remotes" ]
python
train
iskandr/fancyimpute
fancyimpute/iterative_imputer.py
https://github.com/iskandr/fancyimpute/blob/9f0837d387c7303d5c8c925a9989ca77a1a96e3e/fancyimpute/iterative_imputer.py#L817-L863
def _initial_imputation(self, X): """Perform initial imputation for input X. Parameters ---------- X : ndarray, shape (n_samples, n_features) Input data, where "n_samples" is the number of samples and "n_features" is the number of features. Returns ...
[ "def", "_initial_imputation", "(", "self", ",", "X", ")", ":", "# TODO: change False to \"allow-nan\"", "if", "is_scalar_nan", "(", "self", ".", "missing_values", ")", ":", "force_all_finite", "=", "False", "# \"allow-nan\"", "else", ":", "force_all_finite", "=", "T...
Perform initial imputation for input X. Parameters ---------- X : ndarray, shape (n_samples, n_features) Input data, where "n_samples" is the number of samples and "n_features" is the number of features. Returns ------- Xt : ndarray, shape (n_sam...
[ "Perform", "initial", "imputation", "for", "input", "X", "." ]
python
train
autokey/autokey
lib/autokey/scripting.py
https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting.py#L934-L961
def wait_for_exist(self, title, timeOut=5): """ Wait for window with the given title to be created Usage: C{window.wait_for_exist(title, timeOut=5)} If the window is in existence, returns True. Otherwise, returns False if the window has not been created by the time the ...
[ "def", "wait_for_exist", "(", "self", ",", "title", ",", "timeOut", "=", "5", ")", ":", "regex", "=", "re", ".", "compile", "(", "title", ")", "waited", "=", "0", "while", "waited", "<=", "timeOut", ":", "retCode", ",", "output", "=", "self", ".", ...
Wait for window with the given title to be created Usage: C{window.wait_for_exist(title, timeOut=5)} If the window is in existence, returns True. Otherwise, returns False if the window has not been created by the time the timeout has elapsed. @param title: title to mat...
[ "Wait", "for", "window", "with", "the", "given", "title", "to", "be", "created", "Usage", ":", "C", "{", "window", ".", "wait_for_exist", "(", "title", "timeOut", "=", "5", ")", "}" ]
python
train
boriel/zxbasic
asmparse.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1380-L1384
def p_expr_addr(p): """ expr : ADDR """ # The current instruction address p[0] = Expr.makenode(Container(MEMORY.org, p.lineno(1)))
[ "def", "p_expr_addr", "(", "p", ")", ":", "# The current instruction address", "p", "[", "0", "]", "=", "Expr", ".", "makenode", "(", "Container", "(", "MEMORY", ".", "org", ",", "p", ".", "lineno", "(", "1", ")", ")", ")" ]
expr : ADDR
[ "expr", ":", "ADDR" ]
python
train
faucamp/python-gsmmodem
gsmmodem/modem.py
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/modem.py#L568-L573
def smsc(self, smscNumber): """ Set the default SMSC number to use when sending SMS messages """ if smscNumber != self._smscNumber: if self.alive: self.write('AT+CSCA="{0}"'.format(smscNumber)) self._smscNumber = smscNumber
[ "def", "smsc", "(", "self", ",", "smscNumber", ")", ":", "if", "smscNumber", "!=", "self", ".", "_smscNumber", ":", "if", "self", ".", "alive", ":", "self", ".", "write", "(", "'AT+CSCA=\"{0}\"'", ".", "format", "(", "smscNumber", ")", ")", "self", "."...
Set the default SMSC number to use when sending SMS messages
[ "Set", "the", "default", "SMSC", "number", "to", "use", "when", "sending", "SMS", "messages" ]
python
train
craffel/mir_eval
mir_eval/beat.py
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/beat.py#L236-L335
def goto(reference_beats, estimated_beats, goto_threshold=0.35, goto_mu=0.2, goto_sigma=0.2): """Calculate Goto's score, a binary 1 or 0 depending on some specific heuristic criteria Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt')...
[ "def", "goto", "(", "reference_beats", ",", "estimated_beats", ",", "goto_threshold", "=", "0.35", ",", "goto_mu", "=", "0.2", ",", "goto_sigma", "=", "0.2", ")", ":", "validate", "(", "reference_beats", ",", "estimated_beats", ")", "# When estimated beats are emp...
Calculate Goto's score, a binary 1 or 0 depending on some specific heuristic criteria Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> reference_beats = mir_eval.beat.trim_beats(reference_beats) >>> estimated_beats = mir_eval.io.load_events('estimated.txt') ...
[ "Calculate", "Goto", "s", "score", "a", "binary", "1", "or", "0", "depending", "on", "some", "specific", "heuristic", "criteria" ]
python
train
box/rotunicode
rotunicode/rotunicode.py
https://github.com/box/rotunicode/blob/6149b6bb5bb50d322db248acfdb910dc3cb1bcc2/rotunicode/rotunicode.py#L76-L99
def decode(cls, string, errors='strict'): """Return the decoded version of a string. :param string: The input string to decode. :type string: `basestring` :param errors: The error handling scheme. Only 'strict' is supported. :type errors: ...
[ "def", "decode", "(", "cls", ",", "string", ",", "errors", "=", "'strict'", ")", ":", "if", "errors", "!=", "'strict'", ":", "raise", "UnicodeError", "(", "'Unsupported error handling {0}'", ".", "format", "(", "errors", ")", ")", "unicode_string", "=", "cls...
Return the decoded version of a string. :param string: The input string to decode. :type string: `basestring` :param errors: The error handling scheme. Only 'strict' is supported. :type errors: `basestring` :return: T...
[ "Return", "the", "decoded", "version", "of", "a", "string", "." ]
python
train
akfullfo/taskforce
taskforce/task.py
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2456-L2478
def manage(self): """ Manage the task to handle restarts, reconfiguration, etc. Returns True to request a shorter period before the next call, False if nothing special is needed. """ log = self._params.get('log', self._discard) if self._stopping: log.debu...
[ "def", "manage", "(", "self", ")", ":", "log", "=", "self", ".", "_params", ".", "get", "(", "'log'", ",", "self", ".", "_discard", ")", "if", "self", ".", "_stopping", ":", "log", ".", "debug", "(", "\"Task '%s', stopping, retrying stop()\"", ",", "self...
Manage the task to handle restarts, reconfiguration, etc. Returns True to request a shorter period before the next call, False if nothing special is needed.
[ "Manage", "the", "task", "to", "handle", "restarts", "reconfiguration", "etc", "." ]
python
train
tanghaibao/jcvi
jcvi/compara/pad.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/compara/pad.py#L100-L160
def pad(args): """ %prog pad blastfile cdtfile --qbed q.pad.bed --sbed s.pad.bed Test and reconstruct candidate PADs. """ from jcvi.formats.cdt import CDT p = OptionParser(pad.__doc__) p.set_beds() p.add_option("--cutoff", default=.3, type="float", help="The clustering...
[ "def", "pad", "(", "args", ")", ":", "from", "jcvi", ".", "formats", ".", "cdt", "import", "CDT", "p", "=", "OptionParser", "(", "pad", ".", "__doc__", ")", "p", ".", "set_beds", "(", ")", "p", ".", "add_option", "(", "\"--cutoff\"", ",", "default", ...
%prog pad blastfile cdtfile --qbed q.pad.bed --sbed s.pad.bed Test and reconstruct candidate PADs.
[ "%prog", "pad", "blastfile", "cdtfile", "--", "qbed", "q", ".", "pad", ".", "bed", "--", "sbed", "s", ".", "pad", ".", "bed" ]
python
train
SuperCowPowers/workbench
workbench/workers/url.py
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/url.py#L14-L19
def execute(self, input_data): ''' Execute the URL worker ''' string_output = input_data['strings']['string_list'] flatten = ' '.join(string_output) urls = self.url_match.findall(flatten) return {'url_list': urls}
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "string_output", "=", "input_data", "[", "'strings'", "]", "[", "'string_list'", "]", "flatten", "=", "' '", ".", "join", "(", "string_output", ")", "urls", "=", "self", ".", "url_match", ".", "...
Execute the URL worker
[ "Execute", "the", "URL", "worker" ]
python
train
log2timeline/plaso
plaso/output/shared_elastic.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/output/shared_elastic.py#L85-L103
def _CreateIndexIfNotExists(self, index_name, mappings): """Creates an Elasticsearch index if it does not exist. Args: index_name (str): mame of the index. mappings (dict[str, object]): mappings of the index. Raises: RuntimeError: if the Elasticsearch index cannot be created. """ ...
[ "def", "_CreateIndexIfNotExists", "(", "self", ",", "index_name", ",", "mappings", ")", ":", "try", ":", "if", "not", "self", ".", "_client", ".", "indices", ".", "exists", "(", "index_name", ")", ":", "self", ".", "_client", ".", "indices", ".", "create...
Creates an Elasticsearch index if it does not exist. Args: index_name (str): mame of the index. mappings (dict[str, object]): mappings of the index. Raises: RuntimeError: if the Elasticsearch index cannot be created.
[ "Creates", "an", "Elasticsearch", "index", "if", "it", "does", "not", "exist", "." ]
python
train
confluentinc/confluent-kafka-python
tools/download-s3.py
https://github.com/confluentinc/confluent-kafka-python/blob/5a8aeb741609e61eaccafff2a67fa494dd549e8b/tools/download-s3.py#L46-L54
def download(self, dirpath): """ Download artifact from S3 and store in dirpath directory. If the artifact is already downloaded nothing is done. """ if os.path.isfile(self.lpath) and os.path.getsize(self.lpath) > 0: return print('Downloading %s -> %s' % (self.path, self....
[ "def", "download", "(", "self", ",", "dirpath", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "lpath", ")", "and", "os", ".", "path", ".", "getsize", "(", "self", ".", "lpath", ")", ">", "0", ":", "return", "print", "(", "...
Download artifact from S3 and store in dirpath directory. If the artifact is already downloaded nothing is done.
[ "Download", "artifact", "from", "S3", "and", "store", "in", "dirpath", "directory", ".", "If", "the", "artifact", "is", "already", "downloaded", "nothing", "is", "done", "." ]
python
train
mikicz/arca
arca/backend/docker.py
https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/backend/docker.py#L181-L249
def get_image_tag(self, requirements_option: RequirementsOptions, requirements_hash: Optional[str], dependencies: Optional[List[str]]) -> str: """ Returns the tag for images with the dependencies and requirements installed. 64-byte hexad...
[ "def", "get_image_tag", "(", "self", ",", "requirements_option", ":", "RequirementsOptions", ",", "requirements_hash", ":", "Optional", "[", "str", "]", ",", "dependencies", ":", "Optional", "[", "List", "[", "str", "]", "]", ")", "->", "str", ":", "prefix",...
Returns the tag for images with the dependencies and requirements installed. 64-byte hexadecimal strings cannot be used as docker tags, so the prefixes are necessary. Double hashing the dependencies and requirements hash to make the final tag shorter. Prefixes: * Image type: ...
[ "Returns", "the", "tag", "for", "images", "with", "the", "dependencies", "and", "requirements", "installed", "." ]
python
train
pymupdf/PyMuPDF
fitz/fitz.py
https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/fitz.py#L1844-L1868
def close(self): """close(self)""" if self.isClosed: raise ValueError("operation illegal for closed doc") if hasattr(self, '_outline') and self._outline: self._dropOutline(self._outline) self._outline = None self._reset_page_refs() self.metada...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "isClosed", ":", "raise", "ValueError", "(", "\"operation illegal for closed doc\"", ")", "if", "hasattr", "(", "self", ",", "'_outline'", ")", "and", "self", ".", "_outline", ":", "self", ".", "_dr...
close(self)
[ "close", "(", "self", ")" ]
python
train
jumpscale7/python-consistent-toml
contoml/__init__.py
https://github.com/jumpscale7/python-consistent-toml/blob/a0149c65313ccb8170aa99a0cc498e76231292b9/contoml/__init__.py#L26-L38
def dumps(value): """ Dumps a data structure to TOML source code. The given value must be either a dict of dict values, a dict, or a TOML file constructed by this module. """ from contoml.file.file import TOMLFile if not isinstance(value, TOMLFile): raise RuntimeError("Can only dump a...
[ "def", "dumps", "(", "value", ")", ":", "from", "contoml", ".", "file", ".", "file", "import", "TOMLFile", "if", "not", "isinstance", "(", "value", ",", "TOMLFile", ")", ":", "raise", "RuntimeError", "(", "\"Can only dump a TOMLFile instance loaded by load() or lo...
Dumps a data structure to TOML source code. The given value must be either a dict of dict values, a dict, or a TOML file constructed by this module.
[ "Dumps", "a", "data", "structure", "to", "TOML", "source", "code", "." ]
python
train
xapple/fasta
fasta/__init__.py
https://github.com/xapple/fasta/blob/a827c3138812d555203be45187ffae1277dd0d76/fasta/__init__.py#L356-L364
def graphs(self): """Sorry for the black magic. The result is an object whose attributes are all the graphs found in graphs.py initialized with this instance as only argument.""" result = Dummy() for graph in graphs.__all__: cls = getattr(graphs, graph) se...
[ "def", "graphs", "(", "self", ")", ":", "result", "=", "Dummy", "(", ")", "for", "graph", "in", "graphs", ".", "__all__", ":", "cls", "=", "getattr", "(", "graphs", ",", "graph", ")", "setattr", "(", "result", ",", "cls", ".", "short_name", ",", "c...
Sorry for the black magic. The result is an object whose attributes are all the graphs found in graphs.py initialized with this instance as only argument.
[ "Sorry", "for", "the", "black", "magic", ".", "The", "result", "is", "an", "object", "whose", "attributes", "are", "all", "the", "graphs", "found", "in", "graphs", ".", "py", "initialized", "with", "this", "instance", "as", "only", "argument", "." ]
python
train
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L328-L341
def create_vpc(self): """Create a virtual private cloud on Amazon's Web services configured for deploying JupyterHubs. """ self.create_stack( self.vpc_name, 'amazon-eks-vpc.yaml', parameters=define_parameters( VpcBlock="10.42.0.0/16", ...
[ "def", "create_vpc", "(", "self", ")", ":", "self", ".", "create_stack", "(", "self", ".", "vpc_name", ",", "'amazon-eks-vpc.yaml'", ",", "parameters", "=", "define_parameters", "(", "VpcBlock", "=", "\"10.42.0.0/16\"", ",", "Subnet01Block", "=", "\"10.42.1.0/24\"...
Create a virtual private cloud on Amazon's Web services configured for deploying JupyterHubs.
[ "Create", "a", "virtual", "private", "cloud", "on", "Amazon", "s", "Web", "services", "configured", "for", "deploying", "JupyterHubs", "." ]
python
train
PSPC-SPAC-buyandsell/von_anchor
von_anchor/wallet/search.py
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/wallet/search.py#L164-L175
async def close(self) -> None: """ Close search. """ LOGGER.debug('StorageRecordSearch.close >>>') if self._handle: await non_secrets.close_wallet_search(self.handle) self._handle = None LOGGER.debug('StorageRecordSearch.close <<<')
[ "async", "def", "close", "(", "self", ")", "->", "None", ":", "LOGGER", ".", "debug", "(", "'StorageRecordSearch.close >>>'", ")", "if", "self", ".", "_handle", ":", "await", "non_secrets", ".", "close_wallet_search", "(", "self", ".", "handle", ")", "self",...
Close search.
[ "Close", "search", "." ]
python
train
LonamiWebs/Telethon
telethon_examples/gui.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_examples/gui.py#L182-L209
async def sign_in(self, event=None): """ Note the `event` argument. This is required since this callback may be called from a ``widget.bind`` (such as ``'<Return>'``), which sends information about the event we don't care about. This callback logs out if authorized, signs in if ...
[ "async", "def", "sign_in", "(", "self", ",", "event", "=", "None", ")", ":", "self", ".", "sign_in_label", ".", "configure", "(", "text", "=", "'Working...'", ")", "self", ".", "sign_in_entry", ".", "configure", "(", "state", "=", "tkinter", ".", "DISABL...
Note the `event` argument. This is required since this callback may be called from a ``widget.bind`` (such as ``'<Return>'``), which sends information about the event we don't care about. This callback logs out if authorized, signs in if a code was sent or a bot token is input, or sends...
[ "Note", "the", "event", "argument", ".", "This", "is", "required", "since", "this", "callback", "may", "be", "called", "from", "a", "widget", ".", "bind", "(", "such", "as", "<Return", ">", ")", "which", "sends", "information", "about", "the", "event", "...
python
train
RedisJSON/rejson-py
rejson/client.py
https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L89-L98
def setDecoder(self, decoder): """ Sets the client's decoder ``decoder`` should be an instance of a ``json.JSONDecoder`` class """ if not decoder: self._decoder = json.JSONDecoder() else: self._decoder = decoder self._decode = self._decoder...
[ "def", "setDecoder", "(", "self", ",", "decoder", ")", ":", "if", "not", "decoder", ":", "self", ".", "_decoder", "=", "json", ".", "JSONDecoder", "(", ")", "else", ":", "self", ".", "_decoder", "=", "decoder", "self", ".", "_decode", "=", "self", "....
Sets the client's decoder ``decoder`` should be an instance of a ``json.JSONDecoder`` class
[ "Sets", "the", "client", "s", "decoder", "decoder", "should", "be", "an", "instance", "of", "a", "json", ".", "JSONDecoder", "class" ]
python
train
tmontaigu/pylas
pylas/point/format.py
https://github.com/tmontaigu/pylas/blob/8335a1a7d7677f0e4bc391bb6fa3c75b42ed5b06/pylas/point/format.py#L102-L105
def num_extra_bytes(self): """ Returns the number of extra bytes """ return sum(np.dtype(extra_dim[1]).itemsize for extra_dim in self.extra_dims)
[ "def", "num_extra_bytes", "(", "self", ")", ":", "return", "sum", "(", "np", ".", "dtype", "(", "extra_dim", "[", "1", "]", ")", ".", "itemsize", "for", "extra_dim", "in", "self", ".", "extra_dims", ")" ]
Returns the number of extra bytes
[ "Returns", "the", "number", "of", "extra", "bytes" ]
python
test
kubernetes-client/python
kubernetes/client/apis/core_v1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/core_v1_api.py#L2563-L2584
def connect_options_namespaced_service_proxy(self, name, namespace, **kwargs): """ connect OPTIONS requests to proxy of Service This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.connect_optio...
[ "def", "connect_options_namespaced_service_proxy", "(", "self", ",", "name", ",", "namespace", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", ...
connect OPTIONS requests to proxy of Service This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.connect_options_namespaced_service_proxy(name, namespace, async_req=True) >>> result = thread.get() ...
[ "connect", "OPTIONS", "requests", "to", "proxy", "of", "Service", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=", "True", ">>>", ...
python
train
djgagne/hagelslag
hagelslag/util/convert_mrms_grids.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/util/convert_mrms_grids.py#L134-L174
def load_data(self): """ Loads data from MRMS GRIB2 files and handles compression duties if files are compressed. """ data = [] loaded_dates = [] loaded_indices = [] for t, timestamp in enumerate(self.all_dates): date_str = timestamp.date().strftime("%...
[ "def", "load_data", "(", "self", ")", ":", "data", "=", "[", "]", "loaded_dates", "=", "[", "]", "loaded_indices", "=", "[", "]", "for", "t", ",", "timestamp", "in", "enumerate", "(", "self", ".", "all_dates", ")", ":", "date_str", "=", "timestamp", ...
Loads data from MRMS GRIB2 files and handles compression duties if files are compressed.
[ "Loads", "data", "from", "MRMS", "GRIB2", "files", "and", "handles", "compression", "duties", "if", "files", "are", "compressed", "." ]
python
train
commandprompt/Simpycity
simpycity/config.py
https://github.com/commandprompt/Simpycity/blob/a2aa90c31f5ae89f19efcb52025e8088d2205337/simpycity/config.py#L19-L28
def dsn(): """ Return a libpq connection string using the variables defined in this file. """ configs = {'host': host, 'port': port, 'dbname': database, 'user': user, 'password': password} return ' '.join(['{0}={1}'.format(_[0], _[1]) for _...
[ "def", "dsn", "(", ")", ":", "configs", "=", "{", "'host'", ":", "host", ",", "'port'", ":", "port", ",", "'dbname'", ":", "database", ",", "'user'", ":", "user", ",", "'password'", ":", "password", "}", "return", "' '", ".", "join", "(", "[", "'{0...
Return a libpq connection string using the variables defined in this file.
[ "Return", "a", "libpq", "connection", "string", "using", "the", "variables", "defined", "in", "this", "file", "." ]
python
train
msmbuilder/msmbuilder
msmbuilder/msm/core.py
https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/msmbuilder/msm/core.py#L140-L153
def _parse_ergodic_cutoff(self): """Get a numeric value from the ergodic_cutoff input, which can be 'on' or 'off'. """ ec_is_str = isinstance(self.ergodic_cutoff, str) if ec_is_str and self.ergodic_cutoff.lower() == 'on': if self.sliding_window: return...
[ "def", "_parse_ergodic_cutoff", "(", "self", ")", ":", "ec_is_str", "=", "isinstance", "(", "self", ".", "ergodic_cutoff", ",", "str", ")", "if", "ec_is_str", "and", "self", ".", "ergodic_cutoff", ".", "lower", "(", ")", "==", "'on'", ":", "if", "self", ...
Get a numeric value from the ergodic_cutoff input, which can be 'on' or 'off'.
[ "Get", "a", "numeric", "value", "from", "the", "ergodic_cutoff", "input", "which", "can", "be", "on", "or", "off", "." ]
python
train
peo3/cgroup-utils
cgutils/cgroup.py
https://github.com/peo3/cgroup-utils/blob/fd7e99f438ce334bac5669fba0d08a6502fd7a82/cgutils/cgroup.py#L917-L935
def scan_cgroups(subsys_name, filters=list()): """ It returns a control group hierarchy which belong to the subsys_name. When collecting cgroups, filters are applied to the cgroups. See pydoc of apply_filters method of CGroup for more information about the filters. """ status = SubsystemStatus()...
[ "def", "scan_cgroups", "(", "subsys_name", ",", "filters", "=", "list", "(", ")", ")", ":", "status", "=", "SubsystemStatus", "(", ")", "if", "subsys_name", "not", "in", "status", ".", "get_all", "(", ")", ":", "raise", "NoSuchSubsystemError", "(", "\"No s...
It returns a control group hierarchy which belong to the subsys_name. When collecting cgroups, filters are applied to the cgroups. See pydoc of apply_filters method of CGroup for more information about the filters.
[ "It", "returns", "a", "control", "group", "hierarchy", "which", "belong", "to", "the", "subsys_name", ".", "When", "collecting", "cgroups", "filters", "are", "applied", "to", "the", "cgroups", ".", "See", "pydoc", "of", "apply_filters", "method", "of", "CGroup...
python
train
nicolargo/glances
glances/plugins/glances_plugin.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L162-L167
def reset_stats_history(self): """Reset the stats history (dict of GlancesAttribute).""" if self.history_enable(): reset_list = [a['name'] for a in self.get_items_history_list()] logger.debug("Reset history for plugin {} (items: {})".format(self.plugin_name, reset_list)) ...
[ "def", "reset_stats_history", "(", "self", ")", ":", "if", "self", ".", "history_enable", "(", ")", ":", "reset_list", "=", "[", "a", "[", "'name'", "]", "for", "a", "in", "self", ".", "get_items_history_list", "(", ")", "]", "logger", ".", "debug", "(...
Reset the stats history (dict of GlancesAttribute).
[ "Reset", "the", "stats", "history", "(", "dict", "of", "GlancesAttribute", ")", "." ]
python
train
buriburisuri/sugartensor
sugartensor/sg_transform.py
https://github.com/buriburisuri/sugartensor/blob/d2c039954777c7fbe3eb0c2ae40c45c9854deb40/sugartensor/sg_transform.py#L218-L237
def sg_concat(tensor, opt): r"""Concatenates tensors along a axis. See `tf.concat()` in tensorflow. Args: tensor: A `Tensor` (automatically given by chain). opt: target: A `Tensor`. Must have the same rank as `tensor`, and all dimensions except `opt.dim` must be equal. ...
[ "def", "sg_concat", "(", "tensor", ",", "opt", ")", ":", "assert", "opt", ".", "target", "is", "not", "None", ",", "'target is mandatory.'", "opt", "+=", "tf", ".", "sg_opt", "(", "axis", "=", "tensor", ".", "get_shape", "(", ")", ".", "ndims", "-", ...
r"""Concatenates tensors along a axis. See `tf.concat()` in tensorflow. Args: tensor: A `Tensor` (automatically given by chain). opt: target: A `Tensor`. Must have the same rank as `tensor`, and all dimensions except `opt.dim` must be equal. axis : Target axis. Default is...
[ "r", "Concatenates", "tensors", "along", "a", "axis", "." ]
python
train
Telefonica/toolium
toolium/driver_wrappers_pool.py
https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/driver_wrappers_pool.py#L270-L299
def configure_common_directories(cls, tc_config_files): """Configure common config and output folders for all tests :param tc_config_files: test case specific config files """ if cls.config_directory is None: # Get config directory from properties config_director...
[ "def", "configure_common_directories", "(", "cls", ",", "tc_config_files", ")", ":", "if", "cls", ".", "config_directory", "is", "None", ":", "# Get config directory from properties", "config_directory", "=", "cls", ".", "get_configured_value", "(", "'Config_directory'", ...
Configure common config and output folders for all tests :param tc_config_files: test case specific config files
[ "Configure", "common", "config", "and", "output", "folders", "for", "all", "tests" ]
python
train
twisted/epsilon
epsilon/ampauth.py
https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/ampauth.py#L182-L188
def passwordLogin(self, username): """ Generate a new challenge for the given username. """ self.challenge = secureRandom(16) self.username = username return {'challenge': self.challenge}
[ "def", "passwordLogin", "(", "self", ",", "username", ")", ":", "self", ".", "challenge", "=", "secureRandom", "(", "16", ")", "self", ".", "username", "=", "username", "return", "{", "'challenge'", ":", "self", ".", "challenge", "}" ]
Generate a new challenge for the given username.
[ "Generate", "a", "new", "challenge", "for", "the", "given", "username", "." ]
python
train
beregond/super_state_machine
super_state_machine/machines.py
https://github.com/beregond/super_state_machine/blob/31ad527f4e6b7a01e315ce865735ca18957c223e/super_state_machine/machines.py#L103-L122
def _check_state_value(cls): """Check initial state value - if is proper and translate it. Initial state is required. """ state_value = cls.context.get_config('initial_state', None) state_value = state_value or getattr( cls.context.new_class, cls.context.state_name, ...
[ "def", "_check_state_value", "(", "cls", ")", ":", "state_value", "=", "cls", ".", "context", ".", "get_config", "(", "'initial_state'", ",", "None", ")", "state_value", "=", "state_value", "or", "getattr", "(", "cls", ".", "context", ".", "new_class", ",", ...
Check initial state value - if is proper and translate it. Initial state is required.
[ "Check", "initial", "state", "value", "-", "if", "is", "proper", "and", "translate", "it", "." ]
python
train
RedFantom/ttkwidgets
ttkwidgets/font/propertiesframe.py
https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/font/propertiesframe.py#L72-L75
def _on_click(self): """Handles clicks and calls callback.""" if callable(self.__callback): self.__callback((self.bold, self.italic, self.underline, self.overstrike))
[ "def", "_on_click", "(", "self", ")", ":", "if", "callable", "(", "self", ".", "__callback", ")", ":", "self", ".", "__callback", "(", "(", "self", ".", "bold", ",", "self", ".", "italic", ",", "self", ".", "underline", ",", "self", ".", "overstrike"...
Handles clicks and calls callback.
[ "Handles", "clicks", "and", "calls", "callback", "." ]
python
train