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
openstack/python-scciclient
scciclient/irmc/elcm.py
https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/elcm.py#L149-L177
def _parse_elcm_response_body_as_json(response): """parse eLCM response body as json data eLCM response should be in form of: _ Key1: value1 <-- optional --> Key2: value2 <-- optional --> KeyN: valueN <-- optional --> - CRLF - JSON string - :param response: eLCM response ...
[ "def", "_parse_elcm_response_body_as_json", "(", "response", ")", ":", "try", ":", "body", "=", "response", ".", "text", "body_parts", "=", "body", ".", "split", "(", "'\\r\\n'", ")", "if", "len", "(", "body_parts", ")", ">", "0", ":", "return", "jsonutils...
parse eLCM response body as json data eLCM response should be in form of: _ Key1: value1 <-- optional --> Key2: value2 <-- optional --> KeyN: valueN <-- optional --> - CRLF - JSON string - :param response: eLCM response :return: json object if success :raise ELCMInvali...
[ "parse", "eLCM", "response", "body", "as", "json", "data" ]
python
train
webadmin87/midnight
midnight_main/views.py
https://github.com/webadmin87/midnight/blob/b60b3b257b4d633550b82a692f3ea3756c62a0a9/midnight_main/views.py#L39-L53
def pages(request, path=None, instance=None): """ Представление для отображения текстовых страниц :param request: запрос :param path: адрес :param instance: страница :return: """ if instance and instance.active: p = instance else: raise Http404() return render(r...
[ "def", "pages", "(", "request", ",", "path", "=", "None", ",", "instance", "=", "None", ")", ":", "if", "instance", "and", "instance", ".", "active", ":", "p", "=", "instance", "else", ":", "raise", "Http404", "(", ")", "return", "render", "(", "requ...
Представление для отображения текстовых страниц :param request: запрос :param path: адрес :param instance: страница :return:
[ "Представление", "для", "отображения", "текстовых", "страниц", ":", "param", "request", ":", "запрос", ":", "param", "path", ":", "адрес", ":", "param", "instance", ":", "страница", ":", "return", ":" ]
python
train
google/grr
grr/client_builder/grr_response_client_builder/builders/osx.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/builders/osx.py#L80-L100
def MakeZip(self, xar_file, output_file): """Add a zip to the end of the .xar containing build.yaml. The build.yaml is already inside the .xar file, but we can't easily open this on linux. To make repacking easier we add a zip to the end of the .xar and add in the build.yaml. The repack step will then ...
[ "def", "MakeZip", "(", "self", ",", "xar_file", ",", "output_file", ")", ":", "logging", ".", "info", "(", "\"Generating zip template file at %s\"", ",", "output_file", ")", "with", "zipfile", ".", "ZipFile", "(", "output_file", ",", "mode", "=", "\"a\"", ")",...
Add a zip to the end of the .xar containing build.yaml. The build.yaml is already inside the .xar file, but we can't easily open this on linux. To make repacking easier we add a zip to the end of the .xar and add in the build.yaml. The repack step will then look at the build.yaml and insert the config....
[ "Add", "a", "zip", "to", "the", "end", "of", "the", ".", "xar", "containing", "build", ".", "yaml", "." ]
python
train
Workiva/furious
example/grep.py
https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/example/grep.py#L60-L64
def build_and_start(query, directory): """This function will create and then start a new Async task with the default callbacks argument defined in the decorator.""" Async(target=grep, args=[query, directory]).start()
[ "def", "build_and_start", "(", "query", ",", "directory", ")", ":", "Async", "(", "target", "=", "grep", ",", "args", "=", "[", "query", ",", "directory", "]", ")", ".", "start", "(", ")" ]
This function will create and then start a new Async task with the default callbacks argument defined in the decorator.
[ "This", "function", "will", "create", "and", "then", "start", "a", "new", "Async", "task", "with", "the", "default", "callbacks", "argument", "defined", "in", "the", "decorator", "." ]
python
train
PaulHancock/Aegean
AegeanTools/BANE.py
https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/BANE.py#L127-L267
def sigma_filter(filename, region, step_size, box_size, shape, domask, sid): """ Calculate the background and rms for a sub region of an image. The results are written to shared memory - irms and ibkg. Parameters ---------- filename : string Fits file to open region : list ...
[ "def", "sigma_filter", "(", "filename", ",", "region", ",", "step_size", ",", "box_size", ",", "shape", ",", "domask", ",", "sid", ")", ":", "ymin", ",", "ymax", "=", "region", "logging", ".", "debug", "(", "'rows {0}-{1} starting at {2}'", ".", "format", ...
Calculate the background and rms for a sub region of an image. The results are written to shared memory - irms and ibkg. Parameters ---------- filename : string Fits file to open region : list Region within the fits file that is to be processed. (row_min, row_max). step_size :...
[ "Calculate", "the", "background", "and", "rms", "for", "a", "sub", "region", "of", "an", "image", ".", "The", "results", "are", "written", "to", "shared", "memory", "-", "irms", "and", "ibkg", "." ]
python
train
joferkington/mplstereonet
mplstereonet/stereonet_axes.py
https://github.com/joferkington/mplstereonet/blob/f6d78ca49807915d4223e864e12bb24d497cc2d6/mplstereonet/stereonet_axes.py#L450-L475
def rake(self, strike, dip, rake_angle, *args, **kwargs): """ Plot points representing lineations along planes on the axes. Additional arguments and keyword arguments are passed on to `plot`. Parameters ---------- strike, dip : number or sequences of numbers ...
[ "def", "rake", "(", "self", ",", "strike", ",", "dip", ",", "rake_angle", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "lon", ",", "lat", "=", "stereonet_math", ".", "rake", "(", "strike", ",", "dip", ",", "rake_angle", ")", "args", ",", ...
Plot points representing lineations along planes on the axes. Additional arguments and keyword arguments are passed on to `plot`. Parameters ---------- strike, dip : number or sequences of numbers The strike and dip of the plane(s) in degrees. The dip direction is ...
[ "Plot", "points", "representing", "lineations", "along", "planes", "on", "the", "axes", ".", "Additional", "arguments", "and", "keyword", "arguments", "are", "passed", "on", "to", "plot", "." ]
python
train
Jammy2211/PyAutoLens
autolens/lens/sensitivity_fit.py
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/sensitivity_fit.py#L5-L35
def fit_lens_data_with_sensitivity_tracers(lens_data, tracer_normal, tracer_sensitive): """Fit lens data with a normal tracer and sensitivity tracer, to determine our sensitivity to a selection of \ galaxy components. This factory automatically determines the type of fit based on the properties of the galaxies...
[ "def", "fit_lens_data_with_sensitivity_tracers", "(", "lens_data", ",", "tracer_normal", ",", "tracer_sensitive", ")", ":", "if", "(", "tracer_normal", ".", "has_light_profile", "and", "tracer_sensitive", ".", "has_light_profile", ")", "and", "(", "not", "tracer_normal"...
Fit lens data with a normal tracer and sensitivity tracer, to determine our sensitivity to a selection of \ galaxy components. This factory automatically determines the type of fit based on the properties of the galaxies \ in the tracers. Parameters ----------- lens_data : lens_data.LensData or le...
[ "Fit", "lens", "data", "with", "a", "normal", "tracer", "and", "sensitivity", "tracer", "to", "determine", "our", "sensitivity", "to", "a", "selection", "of", "\\", "galaxy", "components", ".", "This", "factory", "automatically", "determines", "the", "type", "...
python
valid
summanlp/textrank
summa/preprocessing/snowball.py
https://github.com/summanlp/textrank/blob/6844bbe8c4b2b468020ae0dfd6574a743f9ad442/summa/preprocessing/snowball.py#L2667-L2835
def stem(self, word): """ Stem a Romanian word and return the stemmed form. :param word: The word that is stemmed. :type word: str or unicode :return: The stemmed form. :rtype: unicode """ word = word.lower() step1_success = False step2_...
[ "def", "stem", "(", "self", ",", "word", ")", ":", "word", "=", "word", ".", "lower", "(", ")", "step1_success", "=", "False", "step2_success", "=", "False", "for", "i", "in", "range", "(", "1", ",", "len", "(", "word", ")", "-", "1", ")", ":", ...
Stem a Romanian word and return the stemmed form. :param word: The word that is stemmed. :type word: str or unicode :return: The stemmed form. :rtype: unicode
[ "Stem", "a", "Romanian", "word", "and", "return", "the", "stemmed", "form", "." ]
python
train
Alignak-monitoring/alignak
alignak/objects/macromodulation.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/macromodulation.py#L107-L127
def is_correct(self): """ Check if this object configuration is correct :: * Call our parent class is_correct checker :return: True if the configuration is correct, otherwise False :rtype: bool """ state = True # Ok just put None as modulation_period, m...
[ "def", "is_correct", "(", "self", ")", ":", "state", "=", "True", "# Ok just put None as modulation_period, means 24x7", "if", "not", "hasattr", "(", "self", ",", "'modulation_period'", ")", ":", "self", ".", "modulation_period", "=", "None", "if", "not", "hasattr...
Check if this object configuration is correct :: * Call our parent class is_correct checker :return: True if the configuration is correct, otherwise False :rtype: bool
[ "Check", "if", "this", "object", "configuration", "is", "correct", "::" ]
python
train
sigvaldm/frmt
frmt.py
https://github.com/sigvaldm/frmt/blob/d077af06c83a7a0533ca2218be55ce086df274b7/frmt.py#L143-L277
def format_table(table, align='<', format='{:.3g}', colwidth=None, maxwidth=None, spacing=2, truncate=0, suffix="..." ): """ Formats a table represented as an iterable of iterab...
[ "def", "format_table", "(", "table", ",", "align", "=", "'<'", ",", "format", "=", "'{:.3g}'", ",", "colwidth", "=", "None", ",", "maxwidth", "=", "None", ",", "spacing", "=", "2", ",", "truncate", "=", "0", ",", "suffix", "=", "\"...\"", ")", ":", ...
Formats a table represented as an iterable of iterable into a nice big string suitable for printing. Parameters: ----------- align : string or list of strings Alignment of cell contents. Each character in a string specifies the alignment of one column. * ``<`` - Le...
[ "Formats", "a", "table", "represented", "as", "an", "iterable", "of", "iterable", "into", "a", "nice", "big", "string", "suitable", "for", "printing", "." ]
python
train
YosaiProject/yosai
yosai/web/subject/subject.py
https://github.com/YosaiProject/yosai/blob/7f96aa6b837ceae9bf3d7387cd7e35f5ab032575/yosai/web/subject/subject.py#L232-L246
def requires_authentication(fn): """ Requires that the calling Subject be authenticated before allowing access. """ @functools.wraps(fn) def wrap(*args, **kwargs): subject = WebYosai.get_current_subject() if not subject.authenticated: msg...
[ "def", "requires_authentication", "(", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "wrap", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "subject", "=", "WebYosai", ".", "get_current_subject", "(", ")", "if", "not", ...
Requires that the calling Subject be authenticated before allowing access.
[ "Requires", "that", "the", "calling", "Subject", "be", "authenticated", "before", "allowing", "access", "." ]
python
train
edx/XBlock
xblock/fields.py
https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/fields.py#L683-L688
def is_set_on(self, xblock): """ Return whether this field has a non-default value on the supplied xblock """ # pylint: disable=protected-access return self._is_dirty(xblock) or xblock._field_data.has(xblock, self.name)
[ "def", "is_set_on", "(", "self", ",", "xblock", ")", ":", "# pylint: disable=protected-access", "return", "self", ".", "_is_dirty", "(", "xblock", ")", "or", "xblock", ".", "_field_data", ".", "has", "(", "xblock", ",", "self", ".", "name", ")" ]
Return whether this field has a non-default value on the supplied xblock
[ "Return", "whether", "this", "field", "has", "a", "non", "-", "default", "value", "on", "the", "supplied", "xblock" ]
python
train
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/update_service/apis/default_api.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/update_service/apis/default_api.py#L767-L787
def firmware_manifest_retrieve(self, manifest_id, **kwargs): # noqa: E501 """Get a manifest # noqa: E501 Retrieve a firmware manifest. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asynchronous=True >>>...
[ "def", "firmware_manifest_retrieve", "(", "self", ",", "manifest_id", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'asynchronous'", ")", ":", "return", "self",...
Get a manifest # noqa: E501 Retrieve a firmware manifest. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asynchronous=True >>> thread = api.firmware_manifest_retrieve(manifest_id, asynchronous=True) >>> r...
[ "Get", "a", "manifest", "#", "noqa", ":", "E501" ]
python
train
QualiSystems/cloudshell-networking-devices
cloudshell/devices/driver_helper.py
https://github.com/QualiSystems/cloudshell-networking-devices/blob/009aab33edb30035b52fe10dbb91db61c95ba4d9/cloudshell/devices/driver_helper.py#L45-L72
def get_snmp_parameters_from_command_context(resource_config, api, force_decrypt=False): """ :param ResourceCommandContext resource_config: command context :return: """ if '3' in resource_config.snmp_version: return SNMPV3Parameters(ip=resource_config.address, ...
[ "def", "get_snmp_parameters_from_command_context", "(", "resource_config", ",", "api", ",", "force_decrypt", "=", "False", ")", ":", "if", "'3'", "in", "resource_config", ".", "snmp_version", ":", "return", "SNMPV3Parameters", "(", "ip", "=", "resource_config", ".",...
:param ResourceCommandContext resource_config: command context :return:
[ ":", "param", "ResourceCommandContext", "resource_config", ":", "command", "context", ":", "return", ":" ]
python
train
saltstack/salt
salt/modules/win_timezone.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_timezone.py#L265-L303
def set_zone(timezone): ''' Sets the timezone using the tzutil. Args: timezone (str): A valid timezone Returns: bool: ``True`` if successful, otherwise ``False`` Raises: CommandExecutionError: If invalid timezone is passed CLI Example: .. code-block:: bash ...
[ "def", "set_zone", "(", "timezone", ")", ":", "# if it's one of the key's just use it", "if", "timezone", ".", "lower", "(", ")", "in", "mapper", ".", "win_to_unix", ":", "win_zone", "=", "timezone", "elif", "timezone", ".", "lower", "(", ")", "in", "mapper", ...
Sets the timezone using the tzutil. Args: timezone (str): A valid timezone Returns: bool: ``True`` if successful, otherwise ``False`` Raises: CommandExecutionError: If invalid timezone is passed CLI Example: .. code-block:: bash salt '*' timezone.set_zone 'Ameri...
[ "Sets", "the", "timezone", "using", "the", "tzutil", "." ]
python
train
Metatab/metatab
metatab/terms.py
https://github.com/Metatab/metatab/blob/8336ec3e4bd8da84a9a5cb86de1c1086e14b8b22/metatab/terms.py#L216-L226
def find(self, term, value=False): """Return a terms by name. If the name is not qualified, use this term's record name for the parent. The method will yield all terms with a matching qualified name. """ if '.' in term: parent, term = term.split('.') assert parent.lower()...
[ "def", "find", "(", "self", ",", "term", ",", "value", "=", "False", ")", ":", "if", "'.'", "in", "term", ":", "parent", ",", "term", "=", "term", ".", "split", "(", "'.'", ")", "assert", "parent", ".", "lower", "(", ")", "==", "self", ".", "re...
Return a terms by name. If the name is not qualified, use this term's record name for the parent. The method will yield all terms with a matching qualified name.
[ "Return", "a", "terms", "by", "name", ".", "If", "the", "name", "is", "not", "qualified", "use", "this", "term", "s", "record", "name", "for", "the", "parent", ".", "The", "method", "will", "yield", "all", "terms", "with", "a", "matching", "qualified", ...
python
train
saltstack/salt
salt/modules/logrotate.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logrotate.py#L276-L285
def _dict_to_stanza(key, stanza): ''' Convert a dict to a multi-line stanza ''' ret = '' for skey in stanza: if stanza[skey] is True: stanza[skey] = '' ret += ' {0} {1}\n'.format(skey, stanza[skey]) return '{0} {{\n{1}}}'.format(key, ret)
[ "def", "_dict_to_stanza", "(", "key", ",", "stanza", ")", ":", "ret", "=", "''", "for", "skey", "in", "stanza", ":", "if", "stanza", "[", "skey", "]", "is", "True", ":", "stanza", "[", "skey", "]", "=", "''", "ret", "+=", "' {0} {1}\\n'", ".", "...
Convert a dict to a multi-line stanza
[ "Convert", "a", "dict", "to", "a", "multi", "-", "line", "stanza" ]
python
train
ajenhl/tacl
tacl/tei_corpus.py
https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/tei_corpus.py#L141-L145
def _output_work(self, work, root): """Saves the TEI XML document `root` at the path `work`.""" output_filename = os.path.join(self._output_dir, work) tree = etree.ElementTree(root) tree.write(output_filename, encoding='utf-8', pretty_print=True)
[ "def", "_output_work", "(", "self", ",", "work", ",", "root", ")", ":", "output_filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_output_dir", ",", "work", ")", "tree", "=", "etree", ".", "ElementTree", "(", "root", ")", "tree", "."...
Saves the TEI XML document `root` at the path `work`.
[ "Saves", "the", "TEI", "XML", "document", "root", "at", "the", "path", "work", "." ]
python
train
auth0/auth0-python
auth0/v3/management/users.py
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/users.py#L195-L225
def get_log_events(self, user_id, page=0, per_page=50, sort=None, include_totals=False): """Retrieve every log event for a specific user id Args: user_id (str): The user_id of the logs to retrieve page (int, optional): The result's page number (zero base...
[ "def", "get_log_events", "(", "self", ",", "user_id", ",", "page", "=", "0", ",", "per_page", "=", "50", ",", "sort", "=", "None", ",", "include_totals", "=", "False", ")", ":", "params", "=", "{", "'per_page'", ":", "per_page", ",", "'page'", ":", "...
Retrieve every log event for a specific user id Args: user_id (str): The user_id of the logs to retrieve page (int, optional): The result's page number (zero based). per_page (int, optional): The amount of entries per page. Default: 50. Max value: 100 ...
[ "Retrieve", "every", "log", "event", "for", "a", "specific", "user", "id" ]
python
train
veeti/decent
decent/validators.py
https://github.com/veeti/decent/blob/07b11536953b9cf4402c65f241706ab717b90bff/decent/validators.py#L11-L21
def All(*validators): """ Combines all the given validator callables into one, running all the validators in sequence on the given value. """ @wraps(All) def built(value): for validator in validators: value = validator(value) return value return built
[ "def", "All", "(", "*", "validators", ")", ":", "@", "wraps", "(", "All", ")", "def", "built", "(", "value", ")", ":", "for", "validator", "in", "validators", ":", "value", "=", "validator", "(", "value", ")", "return", "value", "return", "built" ]
Combines all the given validator callables into one, running all the validators in sequence on the given value.
[ "Combines", "all", "the", "given", "validator", "callables", "into", "one", "running", "all", "the", "validators", "in", "sequence", "on", "the", "given", "value", "." ]
python
train
Murali-group/halp
halp/directed_hypergraph.py
https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L1115-L1161
def write(self, file_name, delim=',', sep='\t'): """Write a directed hypergraph to a file, where nodes are represented as strings. Each column is separated by "sep", and the individual tail nodes and head nodes are delimited by "delim". The header line is currently ignored, but c...
[ "def", "write", "(", "self", ",", "file_name", ",", "delim", "=", "','", ",", "sep", "=", "'\\t'", ")", ":", "out_file", "=", "open", "(", "file_name", ",", "'w'", ")", "# write first header line", "out_file", ".", "write", "(", "\"tail\"", "+", "sep", ...
Write a directed hypergraph to a file, where nodes are represented as strings. Each column is separated by "sep", and the individual tail nodes and head nodes are delimited by "delim". The header line is currently ignored, but columns should be of the format: tailnode1[de...
[ "Write", "a", "directed", "hypergraph", "to", "a", "file", "where", "nodes", "are", "represented", "as", "strings", ".", "Each", "column", "is", "separated", "by", "sep", "and", "the", "individual", "tail", "nodes", "and", "head", "nodes", "are", "delimited"...
python
train
oauthlib/oauthlib
oauthlib/oauth1/rfc5849/request_validator.py
https://github.com/oauthlib/oauthlib/blob/30321dd3c0ca784d3508a1970cf90d9f76835c79/oauthlib/oauth1/rfc5849/request_validator.py#L182-L188
def check_nonce(self, nonce): """Checks that the nonce only contains only safe characters and is no shorter than lower and no longer than upper. """ lower, upper = self.nonce_length return (set(nonce) <= self.safe_characters and lower <= len(nonce) <= upper)
[ "def", "check_nonce", "(", "self", ",", "nonce", ")", ":", "lower", ",", "upper", "=", "self", ".", "nonce_length", "return", "(", "set", "(", "nonce", ")", "<=", "self", ".", "safe_characters", "and", "lower", "<=", "len", "(", "nonce", ")", "<=", "...
Checks that the nonce only contains only safe characters and is no shorter than lower and no longer than upper.
[ "Checks", "that", "the", "nonce", "only", "contains", "only", "safe", "characters", "and", "is", "no", "shorter", "than", "lower", "and", "no", "longer", "than", "upper", "." ]
python
train
ttinies/sc2gameLobby
sc2gameLobby/clientManagement.py
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/clientManagement.py#L111-L113
def debug(self, *debugReqs): """send a debug command to control the game state's setup""" return self._client.send(debug=sc2api_pb2.RequestDebug(debug=debugReqs))
[ "def", "debug", "(", "self", ",", "*", "debugReqs", ")", ":", "return", "self", ".", "_client", ".", "send", "(", "debug", "=", "sc2api_pb2", ".", "RequestDebug", "(", "debug", "=", "debugReqs", ")", ")" ]
send a debug command to control the game state's setup
[ "send", "a", "debug", "command", "to", "control", "the", "game", "state", "s", "setup" ]
python
train
aeguana/PyFileMaker
PyFileMaker/FMServer.py
https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L501-L526
def doNew(self, WHAT={}, **params): """This function will perform the command -new.""" if hasattr(WHAT, '_modified'): for key in WHAT: if key not in ['RECORDID','MODID']: if WHAT.__new2old__.has_key(key): self._addDBParam(WHAT.__new2old__[key].encode('utf-8'), WHAT[key]) else: self._ad...
[ "def", "doNew", "(", "self", ",", "WHAT", "=", "{", "}", ",", "*", "*", "params", ")", ":", "if", "hasattr", "(", "WHAT", ",", "'_modified'", ")", ":", "for", "key", "in", "WHAT", ":", "if", "key", "not", "in", "[", "'RECORDID'", ",", "'MODID'", ...
This function will perform the command -new.
[ "This", "function", "will", "perform", "the", "command", "-", "new", "." ]
python
train
datadesk/python-documentcloud
documentcloud/__init__.py
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L92-L136
def put(self, method, params): """ Post changes back to DocumentCloud """ # Prepare the params, first by adding a custom command to # simulate a PUT request even though we are actually POSTing. # This is something DocumentCloud expects. params['_method'] = 'put' ...
[ "def", "put", "(", "self", ",", "method", ",", "params", ")", ":", "# Prepare the params, first by adding a custom command to", "# simulate a PUT request even though we are actually POSTing.", "# This is something DocumentCloud expects.", "params", "[", "'_method'", "]", "=", "'p...
Post changes back to DocumentCloud
[ "Post", "changes", "back", "to", "DocumentCloud" ]
python
train
fiesta/fiesta-python
fiesta/fiesta.py
https://github.com/fiesta/fiesta-python/blob/cfcc11e4ae4c76b1007794604c33dde877f62cfb/fiesta/fiesta.py#L210-L215
def send_message(self, subject=None, text=None, markdown=None, message_dict=None): """ Helper function to send a message to a group """ message = FiestaMessage(self.api, self, subject, text, markdown, message_dict) return message.send()
[ "def", "send_message", "(", "self", ",", "subject", "=", "None", ",", "text", "=", "None", ",", "markdown", "=", "None", ",", "message_dict", "=", "None", ")", ":", "message", "=", "FiestaMessage", "(", "self", ".", "api", ",", "self", ",", "subject", ...
Helper function to send a message to a group
[ "Helper", "function", "to", "send", "a", "message", "to", "a", "group" ]
python
train
EmbodiedCognition/pagoda
pagoda/parser.py
https://github.com/EmbodiedCognition/pagoda/blob/8892f847026d98aba8646ecbc4589397e6dec7bd/pagoda/parser.py#L486-L523
def parse_amc(source): '''Parse an AMC motion capture data file. Parameters ---------- source : file A file-like object that contains AMC motion capture text. Yields ------ frame : dict Yields a series of motion capture frames. Each frame is a dictionary that maps a...
[ "def", "parse_amc", "(", "source", ")", ":", "lines", "=", "0", "frames", "=", "1", "frame", "=", "{", "}", "degrees", "=", "False", "for", "line", "in", "source", ":", "lines", "+=", "1", "line", "=", "line", ".", "split", "(", "'#'", ")", "[", ...
Parse an AMC motion capture data file. Parameters ---------- source : file A file-like object that contains AMC motion capture text. Yields ------ frame : dict Yields a series of motion capture frames. Each frame is a dictionary that maps a bone name to a list of the DO...
[ "Parse", "an", "AMC", "motion", "capture", "data", "file", "." ]
python
valid
cloudera/impyla
impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py
https://github.com/cloudera/impyla/blob/547fa2ba3b6151e2a98b3544301471a643212dc3/impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py#L4003-L4012
def markPartitionForEvent(self, db_name, tbl_name, part_vals, eventType): """ Parameters: - db_name - tbl_name - part_vals - eventType """ self.send_markPartitionForEvent(db_name, tbl_name, part_vals, eventType) self.recv_markPartitionForEvent()
[ "def", "markPartitionForEvent", "(", "self", ",", "db_name", ",", "tbl_name", ",", "part_vals", ",", "eventType", ")", ":", "self", ".", "send_markPartitionForEvent", "(", "db_name", ",", "tbl_name", ",", "part_vals", ",", "eventType", ")", "self", ".", "recv_...
Parameters: - db_name - tbl_name - part_vals - eventType
[ "Parameters", ":", "-", "db_name", "-", "tbl_name", "-", "part_vals", "-", "eventType" ]
python
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L673-L708
def parse_args(): '''Parse args ''' parser = argparse.ArgumentParser(description='Train and Test an Adversarial Variatiional Encoder') parser.add_argument('--train', help='train the network', action='store_true') parser.add_argument('--test', help='test the network', action='store_true') parser...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Train and Test an Adversarial Variatiional Encoder'", ")", "parser", ".", "add_argument", "(", "'--train'", ",", "help", "=", "'train the network'", ",", ...
Parse args
[ "Parse", "args" ]
python
train
F5Networks/f5-common-python
f5/bigip/resource.py
https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L445-L456
def _iter_list_for_dicts(self, check_list): """Iterate over list to find dicts and check for python keywords.""" list_copy = copy.deepcopy(check_list) for index, elem in enumerate(check_list): if isinstance(elem, dict): list_copy[index] = self._check_for_python_keywo...
[ "def", "_iter_list_for_dicts", "(", "self", ",", "check_list", ")", ":", "list_copy", "=", "copy", ".", "deepcopy", "(", "check_list", ")", "for", "index", ",", "elem", "in", "enumerate", "(", "check_list", ")", ":", "if", "isinstance", "(", "elem", ",", ...
Iterate over list to find dicts and check for python keywords.
[ "Iterate", "over", "list", "to", "find", "dicts", "and", "check", "for", "python", "keywords", "." ]
python
train
zvoase/django-relax
relax/viewserver.py
https://github.com/zvoase/django-relax/blob/10bb37bf3a512b290816856a6877c17fa37e930f/relax/viewserver.py#L145-L156
def handle_validate(self, function_name, new_doc, old_doc, user_ctx): """Validate...this function is undocumented, but still in CouchDB.""" try: function = get_function(function_name) except Exception, exc: self.log(repr(exc)) return False try: ...
[ "def", "handle_validate", "(", "self", ",", "function_name", ",", "new_doc", ",", "old_doc", ",", "user_ctx", ")", ":", "try", ":", "function", "=", "get_function", "(", "function_name", ")", "except", "Exception", ",", "exc", ":", "self", ".", "log", "(",...
Validate...this function is undocumented, but still in CouchDB.
[ "Validate", "...", "this", "function", "is", "undocumented", "but", "still", "in", "CouchDB", "." ]
python
valid
ajenhl/tacl
tacl/cli/utils.py
https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/cli/utils.py#L108-L112
def get_ngrams(path): """Returns a list of n-grams read from the file at `path`.""" with open(path, encoding='utf-8') as fh: ngrams = [ngram.strip() for ngram in fh.readlines()] return ngrams
[ "def", "get_ngrams", "(", "path", ")", ":", "with", "open", "(", "path", ",", "encoding", "=", "'utf-8'", ")", "as", "fh", ":", "ngrams", "=", "[", "ngram", ".", "strip", "(", ")", "for", "ngram", "in", "fh", ".", "readlines", "(", ")", "]", "ret...
Returns a list of n-grams read from the file at `path`.
[ "Returns", "a", "list", "of", "n", "-", "grams", "read", "from", "the", "file", "at", "path", "." ]
python
train
delfick/nose-of-yeti
noseOfYeti/tokeniser/containers.py
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/containers.py#L156-L163
def super_kls(self): """ Determine what kls this group inherits from If default kls should be used, then None is returned """ if not self.kls and self.parent and self.parent.name: return self.parent.kls_name return self.kls
[ "def", "super_kls", "(", "self", ")", ":", "if", "not", "self", ".", "kls", "and", "self", ".", "parent", "and", "self", ".", "parent", ".", "name", ":", "return", "self", ".", "parent", ".", "kls_name", "return", "self", ".", "kls" ]
Determine what kls this group inherits from If default kls should be used, then None is returned
[ "Determine", "what", "kls", "this", "group", "inherits", "from", "If", "default", "kls", "should", "be", "used", "then", "None", "is", "returned" ]
python
train
dmwm/DBS
Server/Python/src/dbs/dao/Oracle/FileBuffer/DeleteDuplicates.py
https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/dao/Oracle/FileBuffer/DeleteDuplicates.py#L21-L29
def execute(self, conn, logical_file_name, transaction=False): """ simple execute """ if not conn: dbsExceptionHandler("dbsException-db-conn-failed", "Oracle/FileBuffer/DeleteDupicates. Expects db connection from upper layer.") print(self.sql) self.dbi.processData(self.sql, logical_fil...
[ "def", "execute", "(", "self", ",", "conn", ",", "logical_file_name", ",", "transaction", "=", "False", ")", ":", "if", "not", "conn", ":", "dbsExceptionHandler", "(", "\"dbsException-db-conn-failed\"", ",", "\"Oracle/FileBuffer/DeleteDupicates. Expects db connection from...
simple execute
[ "simple", "execute" ]
python
train
fermiPy/fermipy
fermipy/gtanalysis.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2001-L2016
def free_norm(self, name, free=True, **kwargs): """Free/Fix normalization of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False). """ name = self.get_source_name(nam...
[ "def", "free_norm", "(", "self", ",", "name", ",", "free", "=", "True", ",", "*", "*", "kwargs", ")", ":", "name", "=", "self", ".", "get_source_name", "(", "name", ")", "normPar", "=", "self", ".", "like", ".", "normPar", "(", "name", ")", ".", ...
Free/Fix normalization of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False).
[ "Free", "/", "Fix", "normalization", "of", "a", "source", "." ]
python
train
projecthamster/hamster
src/hamster/lib/graphics.py
https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L321-L323
def curve_to(self, x, y, x2, y2, x3, y3): """draw a curve. (x2, y2) is the middle point of the curve""" self._add_instruction("curve_to", x, y, x2, y2, x3, y3)
[ "def", "curve_to", "(", "self", ",", "x", ",", "y", ",", "x2", ",", "y2", ",", "x3", ",", "y3", ")", ":", "self", ".", "_add_instruction", "(", "\"curve_to\"", ",", "x", ",", "y", ",", "x2", ",", "y2", ",", "x3", ",", "y3", ")" ]
draw a curve. (x2, y2) is the middle point of the curve
[ "draw", "a", "curve", ".", "(", "x2", "y2", ")", "is", "the", "middle", "point", "of", "the", "curve" ]
python
train
mitsei/dlkit
dlkit/json_/assessment/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L684-L694
def get_learning_objectives_metadata(self): """Gets the metadata for learning objectives. return: (osid.Metadata) - metadata for the learning objectives *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.learning.ActivityForm.ge...
[ "def", "get_learning_objectives_metadata", "(", "self", ")", ":", "# Implemented from template for osid.learning.ActivityForm.get_assets_metadata_template", "metadata", "=", "dict", "(", "self", ".", "_mdata", "[", "'learning_objectives'", "]", ")", "metadata", ".", "update",...
Gets the metadata for learning objectives. return: (osid.Metadata) - metadata for the learning objectives *compliance: mandatory -- This method must be implemented.*
[ "Gets", "the", "metadata", "for", "learning", "objectives", "." ]
python
train
log2timeline/plaso
plaso/analysis/interface.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/analysis/interface.py#L251-L265
def _LogProgressUpdateIfReasonable(self): """Prints a progress update if enough time has passed.""" next_log_time = ( self._time_of_last_status_log + self.SECONDS_BETWEEN_STATUS_LOG_MESSAGES) current_time = time.time() if current_time < next_log_time: return completion_time = t...
[ "def", "_LogProgressUpdateIfReasonable", "(", "self", ")", ":", "next_log_time", "=", "(", "self", ".", "_time_of_last_status_log", "+", "self", ".", "SECONDS_BETWEEN_STATUS_LOG_MESSAGES", ")", "current_time", "=", "time", ".", "time", "(", ")", "if", "current_time"...
Prints a progress update if enough time has passed.
[ "Prints", "a", "progress", "update", "if", "enough", "time", "has", "passed", "." ]
python
train
SolutionsCloud/apidoc
apidoc/factory/source/responseCode.py
https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/factory/source/responseCode.py#L54-L71
def create_from_dictionary(self, datas): """Return a populated object ResponseCode from dictionary datas """ if "code" not in datas: raise ValueError("A response code must contain a code in \"%s\"." % repr(datas)) code = ObjectResponseCode() self.set_common_datas(cod...
[ "def", "create_from_dictionary", "(", "self", ",", "datas", ")", ":", "if", "\"code\"", "not", "in", "datas", ":", "raise", "ValueError", "(", "\"A response code must contain a code in \\\"%s\\\".\"", "%", "repr", "(", "datas", ")", ")", "code", "=", "ObjectRespon...
Return a populated object ResponseCode from dictionary datas
[ "Return", "a", "populated", "object", "ResponseCode", "from", "dictionary", "datas" ]
python
train
bcbio/bcbio-nextgen
bcbio/pipeline/config_utils.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/config_utils.py#L84-L110
def _merge_system_configs(host_config, container_config, out_file=None): """Create a merged system configuration from external and internal specification. """ out = copy.deepcopy(container_config) for k, v in host_config.items(): if k in set(["galaxy_config"]): out[k] = v eli...
[ "def", "_merge_system_configs", "(", "host_config", ",", "container_config", ",", "out_file", "=", "None", ")", ":", "out", "=", "copy", ".", "deepcopy", "(", "container_config", ")", "for", "k", ",", "v", "in", "host_config", ".", "items", "(", ")", ":", ...
Create a merged system configuration from external and internal specification.
[ "Create", "a", "merged", "system", "configuration", "from", "external", "and", "internal", "specification", "." ]
python
train
mitsei/dlkit
dlkit/json_/repository/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/managers.py#L1068-L1083
def get_repository_admin_session(self): """Gets the repository administrative session for creating, updating and deleteing repositories. return: (osid.repository.RepositoryAdminSession) - a ``RepositoryAdminSession`` raise: OperationFailed - unable to complete request r...
[ "def", "get_repository_admin_session", "(", "self", ")", ":", "if", "not", "self", ".", "supports_repository_admin", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ".", "RepositoryAdminSession", ...
Gets the repository administrative session for creating, updating and deleteing repositories. return: (osid.repository.RepositoryAdminSession) - a ``RepositoryAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_repository_admin(...
[ "Gets", "the", "repository", "administrative", "session", "for", "creating", "updating", "and", "deleteing", "repositories", "." ]
python
train
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L218-L230
def filler(self): """Returns the pipeline ID that filled this slot's value. Returns: A string that is the pipeline ID. Raises: SlotNotFilledError if the value hasn't been filled yet. """ if not self.filled: raise SlotNotFilledError('Slot with name "%s", key "%s" not yet filled.' ...
[ "def", "filler", "(", "self", ")", ":", "if", "not", "self", ".", "filled", ":", "raise", "SlotNotFilledError", "(", "'Slot with name \"%s\", key \"%s\" not yet filled.'", "%", "(", "self", ".", "name", ",", "self", ".", "key", ")", ")", "return", "self", "....
Returns the pipeline ID that filled this slot's value. Returns: A string that is the pipeline ID. Raises: SlotNotFilledError if the value hasn't been filled yet.
[ "Returns", "the", "pipeline", "ID", "that", "filled", "this", "slot", "s", "value", "." ]
python
train
pyBookshelf/bookshelf
bookshelf/api_v2/os_helpers.py
https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L106-L117
def disable_env_reset_on_sudo(log=False): """ updates /etc/sudoers so that users from %wheel keep their environment when executing a sudo call """ if log: bookshelf2.logging_helpers.log_green('disabling env reset on sudo') file_append('/etc/sudoers', 'Defaults:%wheel !en...
[ "def", "disable_env_reset_on_sudo", "(", "log", "=", "False", ")", ":", "if", "log", ":", "bookshelf2", ".", "logging_helpers", ".", "log_green", "(", "'disabling env reset on sudo'", ")", "file_append", "(", "'/etc/sudoers'", ",", "'Defaults:%wheel !env_reset,!secure_p...
updates /etc/sudoers so that users from %wheel keep their environment when executing a sudo call
[ "updates", "/", "etc", "/", "sudoers", "so", "that", "users", "from", "%wheel", "keep", "their", "environment", "when", "executing", "a", "sudo", "call" ]
python
train
fermiPy/fermipy
fermipy/gtanalysis.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L166-L177
def get_spectral_index(src, egy): """Compute the local spectral index of a source.""" delta = 1E-5 f0 = src.spectrum()(pyLike.dArg(egy * (1 - delta))) f1 = src.spectrum()(pyLike.dArg(egy * (1 + delta))) if f0 > 0 and f1 > 0: gamma = np.log10(f0 / f1) / np.log10((1 - delta) / (1 + delta)) ...
[ "def", "get_spectral_index", "(", "src", ",", "egy", ")", ":", "delta", "=", "1E-5", "f0", "=", "src", ".", "spectrum", "(", ")", "(", "pyLike", ".", "dArg", "(", "egy", "*", "(", "1", "-", "delta", ")", ")", ")", "f1", "=", "src", ".", "spectr...
Compute the local spectral index of a source.
[ "Compute", "the", "local", "spectral", "index", "of", "a", "source", "." ]
python
train
eumis/pyviews
pyviews/core/observable.py
https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/observable.py#L124-L126
def release_all(self, callback: Callable[[str, Any, Any], None]): """Releases callback from all keys changes""" self._all_callbacks.remove(callback)
[ "def", "release_all", "(", "self", ",", "callback", ":", "Callable", "[", "[", "str", ",", "Any", ",", "Any", "]", ",", "None", "]", ")", ":", "self", ".", "_all_callbacks", ".", "remove", "(", "callback", ")" ]
Releases callback from all keys changes
[ "Releases", "callback", "from", "all", "keys", "changes" ]
python
train
pyGrowler/Growler
growler/http/response.py
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L120-L127
def redirect(self, url, status=None): """ Redirect to the specified url, optional status code defaults to 302. """ self.status_code = 302 if status is None else status self.headers = Headers([('location', url)]) self.message = '' self.end()
[ "def", "redirect", "(", "self", ",", "url", ",", "status", "=", "None", ")", ":", "self", ".", "status_code", "=", "302", "if", "status", "is", "None", "else", "status", "self", ".", "headers", "=", "Headers", "(", "[", "(", "'location'", ",", "url",...
Redirect to the specified url, optional status code defaults to 302.
[ "Redirect", "to", "the", "specified", "url", "optional", "status", "code", "defaults", "to", "302", "." ]
python
train
ibis-project/ibis
ibis/expr/groupby.py
https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/expr/groupby.py#L98-L119
def having(self, expr): """ Add a post-aggregation result filter (like the having argument in `aggregate`), for composability with the group_by API Parameters ---------- expr : ibis.expr.types.Expr Returns ------- grouped : GroupedTableExpr ...
[ "def", "having", "(", "self", ",", "expr", ")", ":", "exprs", "=", "util", ".", "promote_list", "(", "expr", ")", "new_having", "=", "self", ".", "_having", "+", "exprs", "return", "GroupedTableExpr", "(", "self", ".", "table", ",", "self", ".", "by", ...
Add a post-aggregation result filter (like the having argument in `aggregate`), for composability with the group_by API Parameters ---------- expr : ibis.expr.types.Expr Returns ------- grouped : GroupedTableExpr
[ "Add", "a", "post", "-", "aggregation", "result", "filter", "(", "like", "the", "having", "argument", "in", "aggregate", ")", "for", "composability", "with", "the", "group_by", "API" ]
python
train
PMEAL/porespy
porespy/tools/__funcs__.py
https://github.com/PMEAL/porespy/blob/1e13875b56787d8f5b7ffdabce8c4342c33ba9f8/porespy/tools/__funcs__.py#L510-L575
def randomize_colors(im, keep_vals=[0]): r''' Takes a greyscale image and randomly shuffles the greyscale values, so that all voxels labeled X will be labelled Y, and all voxels labeled Y will be labeled Z, where X, Y, Z and so on are randomly selected from the values in the input image. This f...
[ "def", "randomize_colors", "(", "im", ",", "keep_vals", "=", "[", "0", "]", ")", ":", "im_flat", "=", "im", ".", "flatten", "(", ")", "keep_vals", "=", "sp", ".", "array", "(", "keep_vals", ")", "swap_vals", "=", "~", "sp", ".", "in1d", "(", "im_fl...
r''' Takes a greyscale image and randomly shuffles the greyscale values, so that all voxels labeled X will be labelled Y, and all voxels labeled Y will be labeled Z, where X, Y, Z and so on are randomly selected from the values in the input image. This function is useful for improving the visibilit...
[ "r", "Takes", "a", "greyscale", "image", "and", "randomly", "shuffles", "the", "greyscale", "values", "so", "that", "all", "voxels", "labeled", "X", "will", "be", "labelled", "Y", "and", "all", "voxels", "labeled", "Y", "will", "be", "labeled", "Z", "where...
python
train
uogbuji/amara3-xml
pylib/uxml/uxpath/functions.py
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L182-L190
def string_length(ctx, s=None): ''' Yields one number ''' if s is None: s = ctx.node elif callable(s): s = next(s.compute(ctx), '') yield len(s)
[ "def", "string_length", "(", "ctx", ",", "s", "=", "None", ")", ":", "if", "s", "is", "None", ":", "s", "=", "ctx", ".", "node", "elif", "callable", "(", "s", ")", ":", "s", "=", "next", "(", "s", ".", "compute", "(", "ctx", ")", ",", "''", ...
Yields one number
[ "Yields", "one", "number" ]
python
test
autokey/autokey
lib/autokey/model.py
https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/model.py#L248-L261
def _case_insensitive_rpartition(input_string: str, separator: str) -> typing.Tuple[str, str, str]: """Same as str.rpartition(), except that the partitioning is done case insensitive.""" lowered_input_string = input_string.lower() lowered_separator = separator.lower() try: sp...
[ "def", "_case_insensitive_rpartition", "(", "input_string", ":", "str", ",", "separator", ":", "str", ")", "->", "typing", ".", "Tuple", "[", "str", ",", "str", ",", "str", "]", ":", "lowered_input_string", "=", "input_string", ".", "lower", "(", ")", "low...
Same as str.rpartition(), except that the partitioning is done case insensitive.
[ "Same", "as", "str", ".", "rpartition", "()", "except", "that", "the", "partitioning", "is", "done", "case", "insensitive", "." ]
python
train
cbclab/MOT
mot/optimize/__init__.py
https://github.com/cbclab/MOT/blob/fb3243b65025705842e82704705c00902f9a35af/mot/optimize/__init__.py#L133-L183
def maximize(func, x0, nmr_observations, **kwargs): """Maximization of a function. This wraps the objective function to take the negative of the computed values and passes it then on to one of the minimization routines. Args: func (mot.lib.cl_function.CLFunction): A CL function with the signat...
[ "def", "maximize", "(", "func", ",", "x0", ",", "nmr_observations", ",", "*", "*", "kwargs", ")", ":", "wrapped_func", "=", "SimpleCLFunction", ".", "from_string", "(", "'''\n double _negate_'''", "+", "func", ".", "get_cl_function_name", "(", ")", "+", ...
Maximization of a function. This wraps the objective function to take the negative of the computed values and passes it then on to one of the minimization routines. Args: func (mot.lib.cl_function.CLFunction): A CL function with the signature: .. code-block:: c double...
[ "Maximization", "of", "a", "function", "." ]
python
train
TomAugspurger/engarde
engarde/generic.py
https://github.com/TomAugspurger/engarde/blob/e7ea040cf0d20aee7ca4375b8c27caa2d9e43945/engarde/generic.py#L40-L52
def verify_all(df, check, *args, **kwargs): """ Verify that all the entries in ``check(df, *args, **kwargs)`` are true. """ result = check(df, *args, **kwargs) try: assert np.all(result) except AssertionError as e: msg = "{} not true for all".format(check.__name__) e....
[ "def", "verify_all", "(", "df", ",", "check", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "check", "(", "df", ",", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "assert", "np", ".", "all", "(", "result", ")", ...
Verify that all the entries in ``check(df, *args, **kwargs)`` are true.
[ "Verify", "that", "all", "the", "entries", "in", "check", "(", "df", "*", "args", "**", "kwargs", ")", "are", "true", "." ]
python
train
DataDog/integrations-core
vsphere/datadog_checks/vsphere/metadata_cache.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/vsphere/datadog_checks/vsphere/metadata_cache.py#L40-L45
def set_metadata(self, key, metadata): """ Store the metadata for the given instance key. """ with self._lock: self._metadata[key] = metadata
[ "def", "set_metadata", "(", "self", ",", "key", ",", "metadata", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_metadata", "[", "key", "]", "=", "metadata" ]
Store the metadata for the given instance key.
[ "Store", "the", "metadata", "for", "the", "given", "instance", "key", "." ]
python
train
wbond/oscrypto
oscrypto/_osx/asymmetric.py
https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_osx/asymmetric.py#L694-L782
def _load_key(key_object): """ Common code to load public and private keys into PublicKey and PrivateKey objects :param key_object: An asn1crypto.keys.PublicKeyInfo or asn1crypto.keys.PrivateKeyInfo object :raises: ValueError - when any of the parameters contain an invalid ...
[ "def", "_load_key", "(", "key_object", ")", ":", "if", "key_object", ".", "algorithm", "==", "'ec'", ":", "curve_type", ",", "details", "=", "key_object", ".", "curve", "if", "curve_type", "!=", "'named'", ":", "raise", "AsymmetricKeyError", "(", "'OS X only s...
Common code to load public and private keys into PublicKey and PrivateKey objects :param key_object: An asn1crypto.keys.PublicKeyInfo or asn1crypto.keys.PrivateKeyInfo object :raises: ValueError - when any of the parameters contain an invalid value TypeError - when any of t...
[ "Common", "code", "to", "load", "public", "and", "private", "keys", "into", "PublicKey", "and", "PrivateKey", "objects" ]
python
valid
vingd/encrypted-pickle-python
encryptedpickle/encryptedpickle.py
https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L594-L621
def _read_header(self, data): '''Read header from data''' # pylint: disable=W0212 version = self._read_version(data) version_info = self._get_version_info(version) header_data = data[:version_info['header_size']] header = version_info['header'] header = header._...
[ "def", "_read_header", "(", "self", ",", "data", ")", ":", "# pylint: disable=W0212", "version", "=", "self", ".", "_read_version", "(", "data", ")", "version_info", "=", "self", ".", "_get_version_info", "(", "version", ")", "header_data", "=", "data", "[", ...
Read header from data
[ "Read", "header", "from", "data" ]
python
valid
python-bonobo/bonobo
bonobo/structs/graphs.py
https://github.com/python-bonobo/bonobo/blob/70c8e62c4a88576976e5b52e58d380d6e3227ab4/bonobo/structs/graphs.py#L78-L83
def outputs_of(self, idx, create=False): """ Get a set of the outputs for a given node index. """ if create and not idx in self.edges: self.edges[idx] = set() return self.edges[idx]
[ "def", "outputs_of", "(", "self", ",", "idx", ",", "create", "=", "False", ")", ":", "if", "create", "and", "not", "idx", "in", "self", ".", "edges", ":", "self", ".", "edges", "[", "idx", "]", "=", "set", "(", ")", "return", "self", ".", "edges"...
Get a set of the outputs for a given node index.
[ "Get", "a", "set", "of", "the", "outputs", "for", "a", "given", "node", "index", "." ]
python
train
Autodesk/aomi
aomi/cli.py
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/cli.py#L117-L140
def template_args(subparsers): """Add command line options for the template operation""" template_parser = subparsers.add_parser('template') template_parser.add_argument('template', help='Template source', nargs='?') template_parser.add_a...
[ "def", "template_args", "(", "subparsers", ")", ":", "template_parser", "=", "subparsers", ".", "add_parser", "(", "'template'", ")", "template_parser", ".", "add_argument", "(", "'template'", ",", "help", "=", "'Template source'", ",", "nargs", "=", "'?'", ")",...
Add command line options for the template operation
[ "Add", "command", "line", "options", "for", "the", "template", "operation" ]
python
train
eugene-eeo/mailthon
mailthon/headers.py
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/headers.py#L59-L70
def receivers(self): """ Returns a list of receivers, obtained from the To, Cc, and Bcc headers, respecting the Resent-* headers if the email was resent. """ attrs = ( ['Resent-To', 'Resent-Cc', 'Resent-Bcc'] if self.resent else ['To', 'Cc', 'Bcc']...
[ "def", "receivers", "(", "self", ")", ":", "attrs", "=", "(", "[", "'Resent-To'", ",", "'Resent-Cc'", ",", "'Resent-Bcc'", "]", "if", "self", ".", "resent", "else", "[", "'To'", ",", "'Cc'", ",", "'Bcc'", "]", ")", "addrs", "=", "(", "v", "for", "v...
Returns a list of receivers, obtained from the To, Cc, and Bcc headers, respecting the Resent-* headers if the email was resent.
[ "Returns", "a", "list", "of", "receivers", "obtained", "from", "the", "To", "Cc", "and", "Bcc", "headers", "respecting", "the", "Resent", "-", "*", "headers", "if", "the", "email", "was", "resent", "." ]
python
train
saltstack/salt
salt/modules/mandrill.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mandrill.py#L101-L132
def _http_request(url, headers=None, data=None): ''' Make the HTTP request and return the body as python object. ''' if not headers: headers = _get_headers() session = requests.session() log.debug('Querying %s', url) req = session.post(url, ...
[ "def", "_http_request", "(", "url", ",", "headers", "=", "None", ",", "data", "=", "None", ")", ":", "if", "not", "headers", ":", "headers", "=", "_get_headers", "(", ")", "session", "=", "requests", ".", "session", "(", ")", "log", ".", "debug", "("...
Make the HTTP request and return the body as python object.
[ "Make", "the", "HTTP", "request", "and", "return", "the", "body", "as", "python", "object", "." ]
python
train
ludeeus/pyhaversion
pyhaversion/__init__.py
https://github.com/ludeeus/pyhaversion/blob/a49d714fce0343657d94faae360a77edf22305dc/pyhaversion/__init__.py#L32-L45
async def get_local_version(self): """Get the local installed version.""" self._version_data["source"] = "Local" try: from homeassistant.const import __version__ as localversion self._version = localversion _LOGGER.debug("Version: %s", self.version) ...
[ "async", "def", "get_local_version", "(", "self", ")", ":", "self", ".", "_version_data", "[", "\"source\"", "]", "=", "\"Local\"", "try", ":", "from", "homeassistant", ".", "const", "import", "__version__", "as", "localversion", "self", ".", "_version", "=", ...
Get the local installed version.
[ "Get", "the", "local", "installed", "version", "." ]
python
train
edx/edx-drf-extensions
edx_rest_framework_extensions/auth/session/authentication.py
https://github.com/edx/edx-drf-extensions/blob/2f4c1682b8471bf894ea566a43fd9f91ba219f83/edx_rest_framework_extensions/auth/session/authentication.py#L20-L50
def authenticate(self, request): """Authenticate the user, requiring a logged-in account and CSRF. This is exactly the same as the `SessionAuthentication` implementation, with the `user.is_active` check removed. Args: request (HttpRequest) Returns: Tupl...
[ "def", "authenticate", "(", "self", ",", "request", ")", ":", "# Get the underlying HttpRequest object", "request", "=", "request", ".", "_request", "# pylint: disable=protected-access", "user", "=", "getattr", "(", "request", ",", "'user'", ",", "None", ")", "# Una...
Authenticate the user, requiring a logged-in account and CSRF. This is exactly the same as the `SessionAuthentication` implementation, with the `user.is_active` check removed. Args: request (HttpRequest) Returns: Tuple of `(user, token)` Raises: ...
[ "Authenticate", "the", "user", "requiring", "a", "logged", "-", "in", "account", "and", "CSRF", "." ]
python
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L979-L1043
def copy_blob( self, blob, destination_bucket, new_name=None, client=None, preserve_acl=True, source_generation=None, ): """Copy the given blob to the given bucket, optionally with a new name. If :attr:`user_project` is set, bills the API requ...
[ "def", "copy_blob", "(", "self", ",", "blob", ",", "destination_bucket", ",", "new_name", "=", "None", ",", "client", "=", "None", ",", "preserve_acl", "=", "True", ",", "source_generation", "=", "None", ",", ")", ":", "client", "=", "self", ".", "_requi...
Copy the given blob to the given bucket, optionally with a new name. If :attr:`user_project` is set, bills the API request to that project. :type blob: :class:`google.cloud.storage.blob.Blob` :param blob: The blob to be copied. :type destination_bucket: :class:`google.cloud.storage.bu...
[ "Copy", "the", "given", "blob", "to", "the", "given", "bucket", "optionally", "with", "a", "new", "name", "." ]
python
train
google/grr
grr/server/grr_response_server/client_index.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L285-L301
def RemoveClientLabels(self, client): """Removes all labels for a given client object. Args: client: A VFSGRRClient record. """ keywords = [] for label in client.GetLabelsNames(): keyword = self._NormalizeKeyword(utils.SmartStr(label)) # This might actually delete a keyword with t...
[ "def", "RemoveClientLabels", "(", "self", ",", "client", ")", ":", "keywords", "=", "[", "]", "for", "label", "in", "client", ".", "GetLabelsNames", "(", ")", ":", "keyword", "=", "self", ".", "_NormalizeKeyword", "(", "utils", ".", "SmartStr", "(", "lab...
Removes all labels for a given client object. Args: client: A VFSGRRClient record.
[ "Removes", "all", "labels", "for", "a", "given", "client", "object", "." ]
python
train
chrisspen/burlap
burlap/settings.py
https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/settings.py#L17-L33
def show(keyword=''): """ Displays a list of all environment key/value pairs for the current role. """ keyword = keyword.strip().lower() max_len = max(len(k) for k in env.iterkeys()) keyword_found = False for k in sorted(env.keys()): if keyword and keyword not in k.lower(): ...
[ "def", "show", "(", "keyword", "=", "''", ")", ":", "keyword", "=", "keyword", ".", "strip", "(", ")", ".", "lower", "(", ")", "max_len", "=", "max", "(", "len", "(", "k", ")", "for", "k", "in", "env", ".", "iterkeys", "(", ")", ")", "keyword_f...
Displays a list of all environment key/value pairs for the current role.
[ "Displays", "a", "list", "of", "all", "environment", "key", "/", "value", "pairs", "for", "the", "current", "role", "." ]
python
valid
saltstack/salt
salt/modules/gentoolkitmod.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoolkitmod.py#L78-L159
def eclean_dist(destructive=False, package_names=False, size_limit=0, time_limit=0, fetch_restricted=False, exclude_file='/etc/eclean/distfiles.exclude'): ''' Clean obsolete portage sources destructive Only keep minimum for reinstallation package_names P...
[ "def", "eclean_dist", "(", "destructive", "=", "False", ",", "package_names", "=", "False", ",", "size_limit", "=", "0", ",", "time_limit", "=", "0", ",", "fetch_restricted", "=", "False", ",", "exclude_file", "=", "'/etc/eclean/distfiles.exclude'", ")", ":", ...
Clean obsolete portage sources destructive Only keep minimum for reinstallation package_names Protect all versions of installed packages. Only meaningful if used with destructive=True size_limit <size> Don't delete distfiles bigger than <size>. <size> is a size spe...
[ "Clean", "obsolete", "portage", "sources" ]
python
train
jpoullet2000/atlasclient
atlasclient/base.py
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L583-L605
def inflate(self): """Load the resource from the server, if not already loaded.""" if not self._is_inflated: if self._is_inflating: # catch infinite recursion when attempting to inflate # an object that doesn't have enough data to inflate msg...
[ "def", "inflate", "(", "self", ")", ":", "if", "not", "self", ".", "_is_inflated", ":", "if", "self", ".", "_is_inflating", ":", "# catch infinite recursion when attempting to inflate", "# an object that doesn't have enough data to inflate", "msg", "=", "(", "\"There is...
Load the resource from the server, if not already loaded.
[ "Load", "the", "resource", "from", "the", "server", "if", "not", "already", "loaded", "." ]
python
train
jic-dtool/dtoolcore
dtoolcore/utils.py
https://github.com/jic-dtool/dtoolcore/blob/eeb9a924dc8fcf543340653748a7877be1f98e0f/dtoolcore/utils.py#L207-L214
def timestamp(datetime_obj): """Return Unix timestamp as float. The number of seconds that have elapsed since January 1, 1970. """ start_of_time = datetime.datetime(1970, 1, 1) diff = datetime_obj - start_of_time return diff.total_seconds()
[ "def", "timestamp", "(", "datetime_obj", ")", ":", "start_of_time", "=", "datetime", ".", "datetime", "(", "1970", ",", "1", ",", "1", ")", "diff", "=", "datetime_obj", "-", "start_of_time", "return", "diff", ".", "total_seconds", "(", ")" ]
Return Unix timestamp as float. The number of seconds that have elapsed since January 1, 1970.
[ "Return", "Unix", "timestamp", "as", "float", "." ]
python
train
Rockhopper-Technologies/enlighten
enlighten/_win_terminal.py
https://github.com/Rockhopper-Technologies/enlighten/blob/857855f940e6c1bb84d0be849b999a18fff5bf5a/enlighten/_win_terminal.py#L218-L227
def create_color_method(color, code): """ Create a function for the given color Done inside this function to keep the variables out of the main scope """ def func(self, content=''): return self._apply_color(code, content) # pylint: disable=protected-access setattr(Terminal, color, fun...
[ "def", "create_color_method", "(", "color", ",", "code", ")", ":", "def", "func", "(", "self", ",", "content", "=", "''", ")", ":", "return", "self", ".", "_apply_color", "(", "code", ",", "content", ")", "# pylint: disable=protected-access", "setattr", "(",...
Create a function for the given color Done inside this function to keep the variables out of the main scope
[ "Create", "a", "function", "for", "the", "given", "color", "Done", "inside", "this", "function", "to", "keep", "the", "variables", "out", "of", "the", "main", "scope" ]
python
train
dereneaton/ipyrad
ipyrad/file_conversion/loci2alleles.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/file_conversion/loci2alleles.py#L12-L48
def make(data, samples): """ reads in .loci and builds alleles from case characters """ #read in loci file outfile = open(os.path.join(data.dirs.outfiles, data.name+".alleles"), 'w') lines = open(os.path.join(data.dirs.outfiles, data.name+".loci"), 'r') ## Get the longest sample name for prett...
[ "def", "make", "(", "data", ",", "samples", ")", ":", "#read in loci file", "outfile", "=", "open", "(", "os", ".", "path", ".", "join", "(", "data", ".", "dirs", ".", "outfiles", ",", "data", ".", "name", "+", "\".alleles\"", ")", ",", "'w'", ")", ...
reads in .loci and builds alleles from case characters
[ "reads", "in", ".", "loci", "and", "builds", "alleles", "from", "case", "characters" ]
python
valid
kejbaly2/members
members/mailman2.py
https://github.com/kejbaly2/members/blob/28e70a25cceade514c550e3ce9963f73167e8572/members/mailman2.py#L48-L75
def extract(list_name, base_url, list_config=None, user=None, password=None): ''' # FIXME DOCS ''' if not (base_url and list_name): raise RuntimeError( "base_url [{}] and list_name [{}] can not be NULL".format( base_url, list_name)) list_config = list_config or {...
[ "def", "extract", "(", "list_name", ",", "base_url", ",", "list_config", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ")", ":", "if", "not", "(", "base_url", "and", "list_name", ")", ":", "raise", "RuntimeError", "(", "\"base_url ...
# FIXME DOCS
[ "#", "FIXME", "DOCS" ]
python
train
Fortran-FOSS-Programmers/ford
ford/utils.py
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/utils.py#L59-L84
def get_parens(line,retlevel=0,retblevel=0): """ By default akes a string starting with an open parenthesis and returns the portion of the string going to the corresponding close parenthesis. If retlevel != 0 then will return when that level (for parentheses) is reached. Same for retblevel. """ ...
[ "def", "get_parens", "(", "line", ",", "retlevel", "=", "0", ",", "retblevel", "=", "0", ")", ":", "if", "len", "(", "line", ")", "==", "0", ":", "return", "line", "parenstr", "=", "''", "level", "=", "0", "blevel", "=", "0", "for", "char", "in",...
By default akes a string starting with an open parenthesis and returns the portion of the string going to the corresponding close parenthesis. If retlevel != 0 then will return when that level (for parentheses) is reached. Same for retblevel.
[ "By", "default", "akes", "a", "string", "starting", "with", "an", "open", "parenthesis", "and", "returns", "the", "portion", "of", "the", "string", "going", "to", "the", "corresponding", "close", "parenthesis", ".", "If", "retlevel", "!", "=", "0", "then", ...
python
train
jbloomlab/phydms
phydmslib/models.py
https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/models.py#L774-L788
def _update_B(self): """Update `B`.""" for param in self.freeparams: if param == 'mu': continue paramval = getattr(self, param) if isinstance(paramval, float): self.B[param] = broadcastMatrixMultiply(self.Ainv, b...
[ "def", "_update_B", "(", "self", ")", ":", "for", "param", "in", "self", ".", "freeparams", ":", "if", "param", "==", "'mu'", ":", "continue", "paramval", "=", "getattr", "(", "self", ",", "param", ")", "if", "isinstance", "(", "paramval", ",", "float"...
Update `B`.
[ "Update", "B", "." ]
python
train
spookey/photon
photon/tools/template.py
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/template.py#L57-L68
def sub(self): ''' :param fields: Set fields to substitute :returns: Substituted Template with given fields. If no fields were set up beforehand, :func:`raw` is used. ''' if self.__fields: return _Template(self.raw).substitute(self...
[ "def", "sub", "(", "self", ")", ":", "if", "self", ".", "__fields", ":", "return", "_Template", "(", "self", ".", "raw", ")", ".", "substitute", "(", "self", ".", "__fields", ")", "return", "self", ".", "raw" ]
:param fields: Set fields to substitute :returns: Substituted Template with given fields. If no fields were set up beforehand, :func:`raw` is used.
[ ":", "param", "fields", ":", "Set", "fields", "to", "substitute", ":", "returns", ":", "Substituted", "Template", "with", "given", "fields", ".", "If", "no", "fields", "were", "set", "up", "beforehand", ":", "func", ":", "raw", "is", "used", "." ]
python
train
quantopian/zipline
zipline/data/hdf5_daily_bars.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/hdf5_daily_bars.py#L800-L831
def load_raw_arrays(self, columns, start_date, end_date, assets): """ Parameters ---------- columns : list of str 'open', 'high', 'low', 'close', or 'volume' start_date: Tim...
[ "def", "load_raw_arrays", "(", "self", ",", "columns", ",", "start_date", ",", "end_date", ",", "assets", ")", ":", "country_code", "=", "self", ".", "_country_code_for_assets", "(", "assets", ")", "return", "self", ".", "_readers", "[", "country_code", "]", ...
Parameters ---------- columns : list of str 'open', 'high', 'low', 'close', or 'volume' start_date: Timestamp Beginning of the window range. end_date: Timestamp End of the window range. assets : list of int The asset identifiers in the ...
[ "Parameters", "----------", "columns", ":", "list", "of", "str", "open", "high", "low", "close", "or", "volume", "start_date", ":", "Timestamp", "Beginning", "of", "the", "window", "range", ".", "end_date", ":", "Timestamp", "End", "of", "the", "window", "ra...
python
train
google/grumpy
third_party/stdlib/dircache.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/dircache.py#L37-L41
def annotate(head, list): """Add '/' suffixes to directories.""" for i in range(len(list)): if os.path.isdir(os.path.join(head, list[i])): list[i] = list[i] + '/'
[ "def", "annotate", "(", "head", ",", "list", ")", ":", "for", "i", "in", "range", "(", "len", "(", "list", ")", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "join", "(", "head", ",", "list", "[", "i", "]", "...
Add '/' suffixes to directories.
[ "Add", "/", "suffixes", "to", "directories", "." ]
python
valid
oscarbranson/latools
latools/filtering/signal_optimiser.py
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/signal_optimiser.py#L14-L31
def calc_windows(fn, s, min_points): """ Apply fn to all contiguous regions in s that have at least min_points. """ max_points = np.sum(~np.isnan(s)) n_points = max_points - min_points out = np.full((n_points, s.size), np.nan) # skip nans, for speed ind = ~np.isnan(s) s = s[ind] ...
[ "def", "calc_windows", "(", "fn", ",", "s", ",", "min_points", ")", ":", "max_points", "=", "np", ".", "sum", "(", "~", "np", ".", "isnan", "(", "s", ")", ")", "n_points", "=", "max_points", "-", "min_points", "out", "=", "np", ".", "full", "(", ...
Apply fn to all contiguous regions in s that have at least min_points.
[ "Apply", "fn", "to", "all", "contiguous", "regions", "in", "s", "that", "have", "at", "least", "min_points", "." ]
python
test
CartoDB/cartoframes
cartoframes/context.py
https://github.com/CartoDB/cartoframes/blob/c94238a545f3dec45963dac3892540942b6f0df8/cartoframes/context.py#L396-L463
def fetch(self, query, decode_geom=False): """Pull the result from an arbitrary SELECT SQL query from a CARTO account into a pandas DataFrame. Args: query (str): SELECT query to run against CARTO user database. This data will then be converted into a pandas DataFrame. ...
[ "def", "fetch", "(", "self", ",", "query", ",", "decode_geom", "=", "False", ")", ":", "copy_query", "=", "'COPY ({query}) TO stdout WITH (FORMAT csv, HEADER true)'", ".", "format", "(", "query", "=", "query", ")", "query_columns", "=", "get_columns", "(", "self",...
Pull the result from an arbitrary SELECT SQL query from a CARTO account into a pandas DataFrame. Args: query (str): SELECT query to run against CARTO user database. This data will then be converted into a pandas DataFrame. decode_geom (bool, optional): Decodes CART...
[ "Pull", "the", "result", "from", "an", "arbitrary", "SELECT", "SQL", "query", "from", "a", "CARTO", "account", "into", "a", "pandas", "DataFrame", "." ]
python
train
nugget/python-insteonplm
insteonplm/states/onOff.py
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L877-L883
def register_led_updates(self, callback, button): """Register a callback when a specific button LED changes.""" button_callbacks = self._button_observer_callbacks.get(button) if not button_callbacks: self._button_observer_callbacks[button] = [] _LOGGER.debug('New callback for...
[ "def", "register_led_updates", "(", "self", ",", "callback", ",", "button", ")", ":", "button_callbacks", "=", "self", ".", "_button_observer_callbacks", ".", "get", "(", "button", ")", "if", "not", "button_callbacks", ":", "self", ".", "_button_observer_callbacks...
Register a callback when a specific button LED changes.
[ "Register", "a", "callback", "when", "a", "specific", "button", "LED", "changes", "." ]
python
train
christian-oudard/htmltreediff
htmltreediff/changes.py
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/changes.py#L67-L79
def remove_nesting(dom, tag_name): """ Unwrap items in the node list that have ancestors with the same tag. """ for node in dom.getElementsByTagName(tag_name): for ancestor in ancestors(node): if ancestor is node: continue if ancestor is dom.documentElemen...
[ "def", "remove_nesting", "(", "dom", ",", "tag_name", ")", ":", "for", "node", "in", "dom", ".", "getElementsByTagName", "(", "tag_name", ")", ":", "for", "ancestor", "in", "ancestors", "(", "node", ")", ":", "if", "ancestor", "is", "node", ":", "continu...
Unwrap items in the node list that have ancestors with the same tag.
[ "Unwrap", "items", "in", "the", "node", "list", "that", "have", "ancestors", "with", "the", "same", "tag", "." ]
python
train
hearsaycorp/normalize
normalize/record/json.py
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/record/json.py#L175-L247
def to_json(record, extraneous=True, prop=None): """JSON conversion function: a 'visitor' function which implements marshall out (to JSON data form), honoring JSON property types/hints but does not require them. To convert to an actual JSON document, pass the return value to ``json.dumps`` or a similar...
[ "def", "to_json", "(", "record", ",", "extraneous", "=", "True", ",", "prop", "=", "None", ")", ":", "if", "prop", ":", "if", "isinstance", "(", "prop", ",", "basestring", ")", ":", "prop", "=", "type", "(", "record", ")", ".", "properties", "[", "...
JSON conversion function: a 'visitor' function which implements marshall out (to JSON data form), honoring JSON property types/hints but does not require them. To convert to an actual JSON document, pass the return value to ``json.dumps`` or a similar function. args: ``record=``\ *anything* ...
[ "JSON", "conversion", "function", ":", "a", "visitor", "function", "which", "implements", "marshall", "out", "(", "to", "JSON", "data", "form", ")", "honoring", "JSON", "property", "types", "/", "hints", "but", "does", "not", "require", "them", ".", "To", ...
python
train
dslackw/slpkg
slpkg/pkg/manager.py
https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/pkg/manager.py#L361-L377
def _reference_rmvs(self, removes): """Prints all removed packages """ print("") self.msg.template(78) msg_pkg = "package" if len(removes) > 1: msg_pkg = "packages" print("| Total {0} {1} removed".format(len(removes), msg_pkg)) self.msg.templat...
[ "def", "_reference_rmvs", "(", "self", ",", "removes", ")", ":", "print", "(", "\"\"", ")", "self", ".", "msg", ".", "template", "(", "78", ")", "msg_pkg", "=", "\"package\"", "if", "len", "(", "removes", ")", ">", "1", ":", "msg_pkg", "=", "\"packag...
Prints all removed packages
[ "Prints", "all", "removed", "packages" ]
python
train
cjdrake/pyeda
pyeda/boolalg/bdd.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/bdd.py#L538-L546
def _dfs_preorder(node, visited): """Iterate through nodes in DFS pre-order.""" if node not in visited: visited.add(node) yield node if node.lo is not None: yield from _dfs_preorder(node.lo, visited) if node.hi is not None: yield from _dfs_preorder(node.hi, visited)
[ "def", "_dfs_preorder", "(", "node", ",", "visited", ")", ":", "if", "node", "not", "in", "visited", ":", "visited", ".", "add", "(", "node", ")", "yield", "node", "if", "node", ".", "lo", "is", "not", "None", ":", "yield", "from", "_dfs_preorder", "...
Iterate through nodes in DFS pre-order.
[ "Iterate", "through", "nodes", "in", "DFS", "pre", "-", "order", "." ]
python
train
abilian/abilian-core
abilian/core/entities.py
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/core/entities.py#L486-L499
def polymorphic_update_timestamp(session, flush_context, instances): """This listener ensures an update statement is emited for "entity" table to update 'updated_at'. With joined-table inheritance if the only modified attributes are subclass's ones, then no update statement will be emitted. """ ...
[ "def", "polymorphic_update_timestamp", "(", "session", ",", "flush_context", ",", "instances", ")", ":", "for", "obj", "in", "session", ".", "dirty", ":", "if", "not", "isinstance", "(", "obj", ",", "Entity", ")", ":", "continue", "state", "=", "sa", ".", ...
This listener ensures an update statement is emited for "entity" table to update 'updated_at'. With joined-table inheritance if the only modified attributes are subclass's ones, then no update statement will be emitted.
[ "This", "listener", "ensures", "an", "update", "statement", "is", "emited", "for", "entity", "table", "to", "update", "updated_at", "." ]
python
train
andialbrecht/sentry-comments
sentry_comments/plugin.py
https://github.com/andialbrecht/sentry-comments/blob/b9319320dc3b25b6d813377e69b2d379bcbf6197/sentry_comments/plugin.py#L38-L47
def get_title(self, group=None): """Adds number of comments to title.""" title = super(CommentsPlugin, self).get_title() if group is not None: count = GroupComments.objects.filter(group=group).count() else: count = None if count: title = u'%s (...
[ "def", "get_title", "(", "self", ",", "group", "=", "None", ")", ":", "title", "=", "super", "(", "CommentsPlugin", ",", "self", ")", ".", "get_title", "(", ")", "if", "group", "is", "not", "None", ":", "count", "=", "GroupComments", ".", "objects", ...
Adds number of comments to title.
[ "Adds", "number", "of", "comments", "to", "title", "." ]
python
train
ipfs/py-ipfs-api
ipfsapi/client.py
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L907-L957
def name_publish(self, ipfs_path, resolve=True, lifetime="24h", ttl=None, key=None, **kwargs): """Publishes an object to IPNS. IPNS is a PKI namespace, where names are the hashes of public keys, and the private key enables publishing new (signed) values. In publish, the ...
[ "def", "name_publish", "(", "self", ",", "ipfs_path", ",", "resolve", "=", "True", ",", "lifetime", "=", "\"24h\"", ",", "ttl", "=", "None", ",", "key", "=", "None", ",", "*", "*", "kwargs", ")", ":", "opts", "=", "{", "\"lifetime\"", ":", "lifetime"...
Publishes an object to IPNS. IPNS is a PKI namespace, where names are the hashes of public keys, and the private key enables publishing new (signed) values. In publish, the default value of *name* is your own identity public key. .. code-block:: python >>> c.name_publish('...
[ "Publishes", "an", "object", "to", "IPNS", "." ]
python
train
inveniosoftware-contrib/json-merger
json_merger/utils.py
https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/utils.py#L107-L120
def dedupe_list(l): """Remove duplicates from a list preserving the order. We might be tempted to use the list(set(l)) idiom, but it doesn't preserve the order, which hinders testability and does not work for lists with unhashable elements. """ result = [] for el in l: if el not in...
[ "def", "dedupe_list", "(", "l", ")", ":", "result", "=", "[", "]", "for", "el", "in", "l", ":", "if", "el", "not", "in", "result", ":", "result", ".", "append", "(", "el", ")", "return", "result" ]
Remove duplicates from a list preserving the order. We might be tempted to use the list(set(l)) idiom, but it doesn't preserve the order, which hinders testability and does not work for lists with unhashable elements.
[ "Remove", "duplicates", "from", "a", "list", "preserving", "the", "order", "." ]
python
train
O365/python-o365
O365/connection.py
https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/connection.py#L538-L546
def _check_delay(self): """ Checks if a delay is needed between requests and sleeps if True """ if self._previous_request_at: dif = round(time.time() - self._previous_request_at, 2) * 1000 # difference in miliseconds if dif < self.requests_delay: ...
[ "def", "_check_delay", "(", "self", ")", ":", "if", "self", ".", "_previous_request_at", ":", "dif", "=", "round", "(", "time", ".", "time", "(", ")", "-", "self", ".", "_previous_request_at", ",", "2", ")", "*", "1000", "# difference in miliseconds", "if"...
Checks if a delay is needed between requests and sleeps if True
[ "Checks", "if", "a", "delay", "is", "needed", "between", "requests", "and", "sleeps", "if", "True" ]
python
train
jalanb/pysyte
pysyte/bash/git.py
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L299-L305
def add(path=None, force=False, quiet=False): """Add that path to git's staging area (default current dir) so that it will be included in next commit """ option = '-f' if force else '' return run('add %s %s' % (option, path) or '.', quiet=quiet)
[ "def", "add", "(", "path", "=", "None", ",", "force", "=", "False", ",", "quiet", "=", "False", ")", ":", "option", "=", "'-f'", "if", "force", "else", "''", "return", "run", "(", "'add %s %s'", "%", "(", "option", ",", "path", ")", "or", "'.'", ...
Add that path to git's staging area (default current dir) so that it will be included in next commit
[ "Add", "that", "path", "to", "git", "s", "staging", "area", "(", "default", "current", "dir", ")" ]
python
train
linkhub-sdk/popbill.py
popbill/statementService.py
https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/statementService.py#L109-L134
def FAXSend(self, CorpNum, statement, SendNum, ReceiveNum, UserID=None): """ 선팩스 전송 args CorpNum : 팝빌회원 사업자번호 statement : 전자명세서 객체 SendNum : 팩스 발신번호 ReceiveNum : 팩스 수신번호 UserID : 팝빌회원 아이디 return ...
[ "def", "FAXSend", "(", "self", ",", "CorpNum", ",", "statement", ",", "SendNum", ",", "ReceiveNum", ",", "UserID", "=", "None", ")", ":", "if", "statement", "==", "None", ":", "raise", "PopbillException", "(", "-", "99999999", ",", "\"전송할 전자명세서 정보가 입력되지 않았습니...
선팩스 전송 args CorpNum : 팝빌회원 사업자번호 statement : 전자명세서 객체 SendNum : 팩스 발신번호 ReceiveNum : 팩스 수신번호 UserID : 팝빌회원 아이디 return 팩스전송 접수번호(receiptNum) raise PopbillException
[ "선팩스", "전송", "args", "CorpNum", ":", "팝빌회원", "사업자번호", "statement", ":", "전자명세서", "객체", "SendNum", ":", "팩스", "발신번호", "ReceiveNum", ":", "팩스", "수신번호", "UserID", ":", "팝빌회원", "아이디", "return", "팩스전송", "접수번호", "(", "receiptNum", ")", "raise", "PopbillException...
python
train
KE-works/pykechain
pykechain/models/scope.py
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/scope.py#L179-L197
def members(self, is_manager=None): """ Retrieve members of the scope. :param is_manager: (optional) set to True to return only Scope members that are also managers. :type is_manager: bool :return: List of members (usernames) Examples -------- >>> member...
[ "def", "members", "(", "self", ",", "is_manager", "=", "None", ")", ":", "if", "not", "is_manager", ":", "return", "[", "member", "for", "member", "in", "self", ".", "_json_data", "[", "'members'", "]", "if", "member", "[", "'is_active'", "]", "]", "el...
Retrieve members of the scope. :param is_manager: (optional) set to True to return only Scope members that are also managers. :type is_manager: bool :return: List of members (usernames) Examples -------- >>> members = project.members() >>> managers = project.mem...
[ "Retrieve", "members", "of", "the", "scope", "." ]
python
train
idlesign/pysyge
pysyge/pysyge.py
https://github.com/idlesign/pysyge/blob/24a3d9c9a82438f3327a3dc801984b50fd1f0fee/pysyge/pysyge.py#L408-L420
def get_location(self, ip, detailed=False): """Returns a dictionary with location data or False on failure. Amount of information about IP contained in the dictionary depends upon `detailed` flag state. """ seek = self._get_pos(ip) if seek > 0: return self....
[ "def", "get_location", "(", "self", ",", "ip", ",", "detailed", "=", "False", ")", ":", "seek", "=", "self", ".", "_get_pos", "(", "ip", ")", "if", "seek", ">", "0", ":", "return", "self", ".", "_parse_location", "(", "seek", ",", "detailed", "=", ...
Returns a dictionary with location data or False on failure. Amount of information about IP contained in the dictionary depends upon `detailed` flag state.
[ "Returns", "a", "dictionary", "with", "location", "data", "or", "False", "on", "failure", "." ]
python
train
lesscpy/lesscpy
lesscpy/plib/block.py
https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/plib/block.py#L139-L149
def raw(self, clean=False): """Raw block name args: clean (bool): clean name returns: str """ try: return self.tokens[0].raw(clean) except (AttributeError, TypeError): pass
[ "def", "raw", "(", "self", ",", "clean", "=", "False", ")", ":", "try", ":", "return", "self", ".", "tokens", "[", "0", "]", ".", "raw", "(", "clean", ")", "except", "(", "AttributeError", ",", "TypeError", ")", ":", "pass" ]
Raw block name args: clean (bool): clean name returns: str
[ "Raw", "block", "name", "args", ":", "clean", "(", "bool", ")", ":", "clean", "name", "returns", ":", "str" ]
python
valid
sahilchinoy/django-irs-filings
irs/management/commands/loadIRS.py
https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/loadIRS.py#L50-L76
def clean_cell(self, cell, cell_type): """ Uses the type of field (from the mapping) to determine how to clean and format the cell. """ try: # Get rid of non-ASCII characters cell = cell.encode('ascii', 'ignore').decode() if cell_type == 'D': ...
[ "def", "clean_cell", "(", "self", ",", "cell", ",", "cell_type", ")", ":", "try", ":", "# Get rid of non-ASCII characters", "cell", "=", "cell", ".", "encode", "(", "'ascii'", ",", "'ignore'", ")", ".", "decode", "(", ")", "if", "cell_type", "==", "'D'", ...
Uses the type of field (from the mapping) to determine how to clean and format the cell.
[ "Uses", "the", "type", "of", "field", "(", "from", "the", "mapping", ")", "to", "determine", "how", "to", "clean", "and", "format", "the", "cell", "." ]
python
train
cisco-sas/kitty
kitty/data/data_manager.py
https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/data/data_manager.py#L497-L513
def set_session_info(self, info): ''' :type info: :class:`~kitty.data.data_manager.SessionInfo` :param info: info to set ''' if not self.info: self.info = SessionInfo() info_d = self.info.as_dict() ks = [] vs = [] for k,...
[ "def", "set_session_info", "(", "self", ",", "info", ")", ":", "if", "not", "self", ".", "info", ":", "self", ".", "info", "=", "SessionInfo", "(", ")", "info_d", "=", "self", ".", "info", ".", "as_dict", "(", ")", "ks", "=", "[", "]", "vs", "=",...
:type info: :class:`~kitty.data.data_manager.SessionInfo` :param info: info to set
[ ":", "type", "info", ":", ":", "class", ":", "~kitty", ".", "data", ".", "data_manager", ".", "SessionInfo", ":", "param", "info", ":", "info", "to", "set" ]
python
train
tensorlayer/tensorlayer
tensorlayer/prepro.py
https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L237-L261
def affine_rotation_matrix(angle=(-20, 20)): """Create an affine transform matrix for image rotation. NOTE: In OpenCV, x is width and y is height. Parameters ----------- angle : int/float or tuple of two int/float Degree to rotate, usually -180 ~ 180. - int/float, a fixed angle....
[ "def", "affine_rotation_matrix", "(", "angle", "=", "(", "-", "20", ",", "20", ")", ")", ":", "if", "isinstance", "(", "angle", ",", "tuple", ")", ":", "theta", "=", "np", ".", "pi", "/", "180", "*", "np", ".", "random", ".", "uniform", "(", "ang...
Create an affine transform matrix for image rotation. NOTE: In OpenCV, x is width and y is height. Parameters ----------- angle : int/float or tuple of two int/float Degree to rotate, usually -180 ~ 180. - int/float, a fixed angle. - tuple of 2 floats/ints, randomly samp...
[ "Create", "an", "affine", "transform", "matrix", "for", "image", "rotation", ".", "NOTE", ":", "In", "OpenCV", "x", "is", "width", "and", "y", "is", "height", "." ]
python
valid
scour-project/scour
scour/scour.py
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L524-L539
def findElementsWithId(node, elems=None): """ Returns all elements with id attributes """ if elems is None: elems = {} id = node.getAttribute('id') if id != '': elems[id] = node if node.hasChildNodes(): for child in node.childNodes: # from http://www.w3.or...
[ "def", "findElementsWithId", "(", "node", ",", "elems", "=", "None", ")", ":", "if", "elems", "is", "None", ":", "elems", "=", "{", "}", "id", "=", "node", ".", "getAttribute", "(", "'id'", ")", "if", "id", "!=", "''", ":", "elems", "[", "id", "]...
Returns all elements with id attributes
[ "Returns", "all", "elements", "with", "id", "attributes" ]
python
train
PythonRails/rails
rails/views/jinja.py
https://github.com/PythonRails/rails/blob/1e199b9da4da5b24fef39fc6212d71fc9fbb18a5/rails/views/jinja.py#L26-L33
def render_source(self, source, variables=None): """ Render a source with the passed variables. """ if variables is None: variables = {} template = self._engine.from_string(source) return template.render(**variables)
[ "def", "render_source", "(", "self", ",", "source", ",", "variables", "=", "None", ")", ":", "if", "variables", "is", "None", ":", "variables", "=", "{", "}", "template", "=", "self", ".", "_engine", ".", "from_string", "(", "source", ")", "return", "t...
Render a source with the passed variables.
[ "Render", "a", "source", "with", "the", "passed", "variables", "." ]
python
train
SBRG/ssbio
ssbio/utils.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/utils.py#L854-L874
def conv_to_float(indata, inf_str=''): """Try to convert an arbitrary string to a float. Specify what will be replaced with "Inf". Args: indata (str): String which contains a float inf_str (str): If string contains something other than a float, and you want to replace it with float("Inf"), ...
[ "def", "conv_to_float", "(", "indata", ",", "inf_str", "=", "''", ")", ":", "if", "indata", ".", "strip", "(", ")", "==", "inf_str", ":", "outdata", "=", "float", "(", "'Inf'", ")", "else", ":", "try", ":", "outdata", "=", "float", "(", "indata", "...
Try to convert an arbitrary string to a float. Specify what will be replaced with "Inf". Args: indata (str): String which contains a float inf_str (str): If string contains something other than a float, and you want to replace it with float("Inf"), specify that string here. Re...
[ "Try", "to", "convert", "an", "arbitrary", "string", "to", "a", "float", ".", "Specify", "what", "will", "be", "replaced", "with", "Inf", ".", "Args", ":", "indata", "(", "str", ")", ":", "String", "which", "contains", "a", "float", "inf_str", "(", "st...
python
train
Azure/azure-sdk-for-python
azure-servicemanagement-legacy/azure/servicemanagement/servicemanagementservice.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/servicemanagementservice.py#L890-L902
def list_service_certificates(self, service_name): ''' Lists all of the service certificates associated with the specified hosted service. service_name: Name of the hosted service. ''' _validate_not_none('service_name', service_name) return self._perf...
[ "def", "list_service_certificates", "(", "self", ",", "service_name", ")", ":", "_validate_not_none", "(", "'service_name'", ",", "service_name", ")", "return", "self", ".", "_perform_get", "(", "'/'", "+", "self", ".", "subscription_id", "+", "'/services/hostedserv...
Lists all of the service certificates associated with the specified hosted service. service_name: Name of the hosted service.
[ "Lists", "all", "of", "the", "service", "certificates", "associated", "with", "the", "specified", "hosted", "service", "." ]
python
test
DarkEnergySurvey/ugali
ugali/utils/stats.py
https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L294-L299
def median(self, name, **kwargs): """ Median of the distribution. """ data = self.get(name,**kwargs) return np.percentile(data,[50])
[ "def", "median", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "data", "=", "self", ".", "get", "(", "name", ",", "*", "*", "kwargs", ")", "return", "np", ".", "percentile", "(", "data", ",", "[", "50", "]", ")" ]
Median of the distribution.
[ "Median", "of", "the", "distribution", "." ]
python
train