repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
pyblish/pyblish-qml
pyblish_qml/control.py
https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/control.py#L657-L660
def comment_sync(self, comment): """Update comments to host and notify subscribers""" self.host.update(key="comment", value=comment) self.host.emit("commented", comment=comment)
[ "def", "comment_sync", "(", "self", ",", "comment", ")", ":", "self", ".", "host", ".", "update", "(", "key", "=", "\"comment\"", ",", "value", "=", "comment", ")", "self", ".", "host", ".", "emit", "(", "\"commented\"", ",", "comment", "=", "comment",...
Update comments to host and notify subscribers
[ "Update", "comments", "to", "host", "and", "notify", "subscribers" ]
python
train
49.5
libnano/primer3-py
primer3/bindings.py
https://github.com/libnano/primer3-py/blob/0901c0ef3ac17afd69329d23db71136c00bcb635/primer3/bindings.py#L204-L234
def calcTm(seq, mv_conc=50, dv_conc=0, dntp_conc=0.8, dna_conc=50, max_nn_length=60, tm_method='santalucia', salt_corrections_method='santalucia'): ''' Calculate the melting temperature (Tm) of a DNA sequence. Note that NN thermodynamics will be used to calculate the Tm of sequences u...
[ "def", "calcTm", "(", "seq", ",", "mv_conc", "=", "50", ",", "dv_conc", "=", "0", ",", "dntp_conc", "=", "0.8", ",", "dna_conc", "=", "50", ",", "max_nn_length", "=", "60", ",", "tm_method", "=", "'santalucia'", ",", "salt_corrections_method", "=", "'san...
Calculate the melting temperature (Tm) of a DNA sequence. Note that NN thermodynamics will be used to calculate the Tm of sequences up to 60 bp in length, after which point the following formula will be used:: Tm = 81.5 + 16.6(log10([mv_conc])) + 0.41(%GC) - 600/length Args: seq (str)...
[ "Calculate", "the", "melting", "temperature", "(", "Tm", ")", "of", "a", "DNA", "sequence", "." ]
python
train
46.870968
openai/universe
universe/remotes/compose/container.py
https://github.com/openai/universe/blob/cc9ce6ec241821bfb0f3b85dd455bd36e4ee7a8c/universe/remotes/compose/container.py#L170-L175
def attach_log_stream(self): """A log stream can only be attached if the container uses a json-file log driver. """ if self.has_api_logs: self.log_stream = self.attach(stdout=True, stderr=True, stream=True)
[ "def", "attach_log_stream", "(", "self", ")", ":", "if", "self", ".", "has_api_logs", ":", "self", ".", "log_stream", "=", "self", ".", "attach", "(", "stdout", "=", "True", ",", "stderr", "=", "True", ",", "stream", "=", "True", ")" ]
A log stream can only be attached if the container uses a json-file log driver.
[ "A", "log", "stream", "can", "only", "be", "attached", "if", "the", "container", "uses", "a", "json", "-", "file", "log", "driver", "." ]
python
train
40.833333
tonioo/sievelib
sievelib/managesieve.py
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L535-L548
def havespace(self, scriptname, scriptsize): """Ask for available space. See MANAGESIEVE specifications, section 2.5 :param scriptname: script's name :param scriptsize: script's size :rtype: boolean """ code, data = self.__send_command( "HAVESPACE", ...
[ "def", "havespace", "(", "self", ",", "scriptname", ",", "scriptsize", ")", ":", "code", ",", "data", "=", "self", ".", "__send_command", "(", "\"HAVESPACE\"", ",", "[", "scriptname", ".", "encode", "(", "\"utf-8\"", ")", ",", "scriptsize", "]", ")", "if...
Ask for available space. See MANAGESIEVE specifications, section 2.5 :param scriptname: script's name :param scriptsize: script's size :rtype: boolean
[ "Ask", "for", "available", "space", "." ]
python
train
29.857143
zooniverse/panoptes-python-client
panoptes_client/exportable.py
https://github.com/zooniverse/panoptes-python-client/blob/138d93cb03378501a8d349428e381ad73f928680/panoptes_client/exportable.py#L30-L92
def get_export( self, export_type, generate=False, wait=False, wait_timeout=None, ): """ Downloads a data export over HTTP. Returns a `Requests Response <http://docs.python-requests.org/en/master/api/#requests.Response>`_ object containing the ...
[ "def", "get_export", "(", "self", ",", "export_type", ",", "generate", "=", "False", ",", "wait", "=", "False", ",", "wait_timeout", "=", "None", ",", ")", ":", "if", "generate", ":", "self", ".", "generate_export", "(", "export_type", ")", "if", "genera...
Downloads a data export over HTTP. Returns a `Requests Response <http://docs.python-requests.org/en/master/api/#requests.Response>`_ object containing the content of the export. - **export_type** is a string specifying which type of export should be downloaded. - **generate** ...
[ "Downloads", "a", "data", "export", "over", "HTTP", ".", "Returns", "a", "Requests", "Response", "<http", ":", "//", "docs", ".", "python", "-", "requests", ".", "org", "/", "en", "/", "master", "/", "api", "/", "#requests", ".", "Response", ">", "_", ...
python
train
38.174603
senaite/senaite.core
bika/lims/content/samplinground.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/samplinground.py#L417-L439
def hasUserAddEditPermission(self): """ Checks if the current user has privileges to access to the editing view. From Jira LIMS-1549: - Creation/Edit: Lab manager, Client Contact, Lab Clerk, Client Contact (for Client-specific SRTs) :returns: True/False """ mto...
[ "def", "hasUserAddEditPermission", "(", "self", ")", ":", "mtool", "=", "getToolByName", "(", "self", ",", "'portal_membership'", ")", "checkPermission", "=", "mtool", ".", "checkPermission", "# In bika_samplinground_workflow.csv there are defined the ModifyPortalContent statem...
Checks if the current user has privileges to access to the editing view. From Jira LIMS-1549: - Creation/Edit: Lab manager, Client Contact, Lab Clerk, Client Contact (for Client-specific SRTs) :returns: True/False
[ "Checks", "if", "the", "current", "user", "has", "privileges", "to", "access", "to", "the", "editing", "view", ".", "From", "Jira", "LIMS", "-", "1549", ":", "-", "Creation", "/", "Edit", ":", "Lab", "manager", "Client", "Contact", "Lab", "Clerk", "Clien...
python
train
56.304348
stevearc/dql
dql/expressions/constraint.py
https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/expressions/constraint.py#L269-L282
def from_clause(cls, clause): """ Factory method """ fn_name = clause[0] if fn_name == "size": return SizeConstraint.from_clause(clause) elif fn_name == "attribute_type": return TypeConstraint.from_clause(clause) else: fn_name = clause[0] ...
[ "def", "from_clause", "(", "cls", ",", "clause", ")", ":", "fn_name", "=", "clause", "[", "0", "]", "if", "fn_name", "==", "\"size\"", ":", "return", "SizeConstraint", ".", "from_clause", "(", "clause", ")", "elif", "fn_name", "==", "\"attribute_type\"", "...
Factory method
[ "Factory", "method" ]
python
train
34.785714
Microsoft/ApplicationInsights-Python
applicationinsights/TelemetryClient.py
https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/TelemetryClient.py#L193-L222
def track_request(self, name, url, success, start_time=None, duration=None, response_code=None, http_method=None, properties=None, measurements=None, request_id=None): """Sends a single request that was captured for the application. Args: name (str). the name for this request. All requests ...
[ "def", "track_request", "(", "self", ",", "name", ",", "url", ",", "success", ",", "start_time", "=", "None", ",", "duration", "=", "None", ",", "response_code", "=", "None", ",", "http_method", "=", "None", ",", "properties", "=", "None", ",", "measurem...
Sends a single request that was captured for the application. Args: name (str). the name for this request. All requests with the same name will be grouped together.\n url (str). the actual URL for this request (to show in individual request instances).\n success (bool). true...
[ "Sends", "a", "single", "request", "that", "was", "captured", "for", "the", "application", "." ]
python
train
65.733333
SmokinCaterpillar/pypet
pypet/storageservice.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/storageservice.py#L2867-L2895
def _srn_store_single_run(self, traj, recursive=True, store_data=pypetconstants.STORE_DATA, max_depth=None): """ Stores a single run instance to disk (only meta data)""" if store_data != pypetconstants.STORE_NOTHI...
[ "def", "_srn_store_single_run", "(", "self", ",", "traj", ",", "recursive", "=", "True", ",", "store_data", "=", "pypetconstants", ".", "STORE_DATA", ",", "max_depth", "=", "None", ")", ":", "if", "store_data", "!=", "pypetconstants", ".", "STORE_NOTHING", ":"...
Stores a single run instance to disk (only meta data)
[ "Stores", "a", "single", "run", "instance", "to", "disk", "(", "only", "meta", "data", ")" ]
python
test
55.068966
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L234-L245
def date_director(**kwargs): """Direct which class should be used based on the date qualifier or if the date should be converted at all. """ # If the date is a creation date, return the element object. if kwargs.get('qualifier') == 'creation': return ETD_MSDate(content=kwargs.get('content')....
[ "def", "date_director", "(", "*", "*", "kwargs", ")", ":", "# If the date is a creation date, return the element object.", "if", "kwargs", ".", "get", "(", "'qualifier'", ")", "==", "'creation'", ":", "return", "ETD_MSDate", "(", "content", "=", "kwargs", ".", "ge...
Direct which class should be used based on the date qualifier or if the date should be converted at all.
[ "Direct", "which", "class", "should", "be", "used", "based", "on", "the", "date", "qualifier", "or", "if", "the", "date", "should", "be", "converted", "at", "all", "." ]
python
train
41.5
luiscberrocal/pyjavaprops
pyjavaprops/javaproperties.py
https://github.com/luiscberrocal/pyjavaprops/blob/7d0327b1758b3d907af657e0df3b0618776ac46d/pyjavaprops/javaproperties.py#L250-L264
def load(self, stream): """ Load properties from an open file stream """ # For the time being only accept file input streams if not _is_file(stream): raise TypeError('Argument should be a file object!') # Check for the opened mode if stream.mode != 'r': r...
[ "def", "load", "(", "self", ",", "stream", ")", ":", "# For the time being only accept file input streams", "if", "not", "_is_file", "(", "stream", ")", ":", "raise", "TypeError", "(", "'Argument should be a file object!'", ")", "# Check for the opened mode", "if", "str...
Load properties from an open file stream
[ "Load", "properties", "from", "an", "open", "file", "stream" ]
python
train
32.933333
FujiMakoto/AgentML
agentml/parser/trigger/response/__init__.py
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/trigger/response/__init__.py#L59-L85
def get(self): """ Parse a response into string format and clear out its temporary containers :return: The parsed response message :rtype : str """ self._log.debug('Converting Response object to string format') response = ''.join(map(str, self._response)).strip() ...
[ "def", "get", "(", "self", ")", ":", "self", ".", "_log", ".", "debug", "(", "'Converting Response object to string format'", ")", "response", "=", "''", ".", "join", "(", "map", "(", "str", ",", "self", ".", "_response", ")", ")", ".", "strip", "(", "...
Parse a response into string format and clear out its temporary containers :return: The parsed response message :rtype : str
[ "Parse", "a", "response", "into", "string", "format", "and", "clear", "out", "its", "temporary", "containers", ":", "return", ":", "The", "parsed", "response", "message", ":", "rtype", ":", "str" ]
python
train
35.851852
tanghaibao/goatools
goatools/go_enrichment.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_enrichment.py#L136-L143
def set_goterm(self, go2obj): """Set goterm and copy GOTerm's name and namespace.""" if self.GO in go2obj: goterm = go2obj[self.GO] self.goterm = goterm self.name = goterm.name self.depth = goterm.depth self.NS = self.namespace2NS[self.goterm.n...
[ "def", "set_goterm", "(", "self", ",", "go2obj", ")", ":", "if", "self", ".", "GO", "in", "go2obj", ":", "goterm", "=", "go2obj", "[", "self", ".", "GO", "]", "self", ".", "goterm", "=", "goterm", "self", ".", "name", "=", "goterm", ".", "name", ...
Set goterm and copy GOTerm's name and namespace.
[ "Set", "goterm", "and", "copy", "GOTerm", "s", "name", "and", "namespace", "." ]
python
train
40.25
spyder-ide/conda-manager
conda_manager/api/conda_api.py
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L832-L861
def dependencies(self, name=None, prefix=None, pkgs=None, channels=None, dep=True): """Get dependenciy list for packages to be installed in an env.""" if not pkgs or not isinstance(pkgs, (list, tuple)): raise TypeError('must specify a list of one or more packages to ' ...
[ "def", "dependencies", "(", "self", ",", "name", "=", "None", ",", "prefix", "=", "None", ",", "pkgs", "=", "None", ",", "channels", "=", "None", ",", "dep", "=", "True", ")", ":", "if", "not", "pkgs", "or", "not", "isinstance", "(", "pkgs", ",", ...
Get dependenciy list for packages to be installed in an env.
[ "Get", "dependenciy", "list", "for", "packages", "to", "be", "installed", "in", "an", "env", "." ]
python
train
32.366667
limodou/uliweb
uliweb/orm/__init__.py
https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L1479-L1488
def migrate_tables(tables, engine_name=None): """ Used to migrate dynamic table to database :param tables: tables name list, such as ['user'] """ from alembic.migration import MigrationContext engine = engine_manager[engine_name] mc = MigrationContext.configure(engine.session().connection) ...
[ "def", "migrate_tables", "(", "tables", ",", "engine_name", "=", "None", ")", ":", "from", "alembic", ".", "migration", "import", "MigrationContext", "engine", "=", "engine_manager", "[", "engine_name", "]", "mc", "=", "MigrationContext", ".", "configure", "(", ...
Used to migrate dynamic table to database :param tables: tables name list, such as ['user']
[ "Used", "to", "migrate", "dynamic", "table", "to", "database", ":", "param", "tables", ":", "tables", "name", "list", "such", "as", "[", "user", "]" ]
python
train
40.6
redcap-tools/PyCap
redcap/request.py
https://github.com/redcap-tools/PyCap/blob/f44c9b62a4f62675aa609c06608663f37e12097e/redcap/request.py#L129-L150
def get_content(self, r): """Abstraction for grabbing content from a returned response""" if self.type == 'exp_file': # don't use the decoded r.text return r.content elif self.type == 'version': return r.content else: if self.fmt == 'json':...
[ "def", "get_content", "(", "self", ",", "r", ")", ":", "if", "self", ".", "type", "==", "'exp_file'", ":", "# don't use the decoded r.text", "return", "r", ".", "content", "elif", "self", ".", "type", "==", "'version'", ":", "return", "r", ".", "content", ...
Abstraction for grabbing content from a returned response
[ "Abstraction", "for", "grabbing", "content", "from", "a", "returned", "response" ]
python
train
36.863636
ethereum/py-trie
trie/utils/nibbles.py
https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/nibbles.py#L78-L104
def encode_nibbles(nibbles): """ The Hex Prefix function """ if is_nibbles_terminated(nibbles): flag = HP_FLAG_2 else: flag = HP_FLAG_0 raw_nibbles = remove_nibbles_terminator(nibbles) is_odd = len(raw_nibbles) % 2 if is_odd: flagged_nibbles = tuple(itertools.c...
[ "def", "encode_nibbles", "(", "nibbles", ")", ":", "if", "is_nibbles_terminated", "(", "nibbles", ")", ":", "flag", "=", "HP_FLAG_2", "else", ":", "flag", "=", "HP_FLAG_0", "raw_nibbles", "=", "remove_nibbles_terminator", "(", "nibbles", ")", "is_odd", "=", "l...
The Hex Prefix function
[ "The", "Hex", "Prefix", "function" ]
python
train
20.777778
CamDavidsonPilon/lifetimes
lifetimes/fitters/beta_geo_fitter.py
https://github.com/CamDavidsonPilon/lifetimes/blob/f926308bc03c17c1d12fead729de43885cf13321/lifetimes/fitters/beta_geo_fitter.py#L209-L238
def conditional_probability_alive(self, frequency, recency, T): """ Compute conditional probability alive. Compute the probability that a customer with history (frequency, recency, T) is currently alive. From http://www.brucehardie.com/notes/021/palive_for_BGNBD.pdf Pa...
[ "def", "conditional_probability_alive", "(", "self", ",", "frequency", ",", "recency", ",", "T", ")", ":", "r", ",", "alpha", ",", "a", ",", "b", "=", "self", ".", "_unload_params", "(", "\"r\"", ",", "\"alpha\"", ",", "\"a\"", ",", "\"b\"", ")", "log_...
Compute conditional probability alive. Compute the probability that a customer with history (frequency, recency, T) is currently alive. From http://www.brucehardie.com/notes/021/palive_for_BGNBD.pdf Parameters ---------- frequency: array or scalar historica...
[ "Compute", "conditional", "probability", "alive", "." ]
python
train
31.166667
streeter/pelican-gist
pelican_gist/plugin.py
https://github.com/streeter/pelican-gist/blob/395e619534b404fb2b94456dc400dc2a8a2f934a/pelican_gist/plugin.py#L103-L153
def replace_gist_tags(generator): """Replace gist tags in the article content.""" from jinja2 import Template template = Template(gist_template) should_cache = generator.context.get('GIST_CACHE_ENABLED') cache_location = generator.context.get('GIST_CACHE_LOCATION') pygments_style = generator.co...
[ "def", "replace_gist_tags", "(", "generator", ")", ":", "from", "jinja2", "import", "Template", "template", "=", "Template", "(", "gist_template", ")", "should_cache", "=", "generator", ".", "context", ".", "get", "(", "'GIST_CACHE_ENABLED'", ")", "cache_location"...
Replace gist tags in the article content.
[ "Replace", "gist", "tags", "in", "the", "article", "content", "." ]
python
train
34.980392
ngmarchant/oasis
oasis/sawade.py
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/sawade.py#L145-L151
def _sample_item(self, **kwargs): """Sample an item from the pool according to the instrumental distribution """ loc = np.random.choice(self._n_items, p = self._inst_pmf) weight = (1/self._n_items)/self._inst_pmf[loc] return loc, weight, {}
[ "def", "_sample_item", "(", "self", ",", "*", "*", "kwargs", ")", ":", "loc", "=", "np", ".", "random", ".", "choice", "(", "self", ".", "_n_items", ",", "p", "=", "self", ".", "_inst_pmf", ")", "weight", "=", "(", "1", "/", "self", ".", "_n_item...
Sample an item from the pool according to the instrumental distribution
[ "Sample", "an", "item", "from", "the", "pool", "according", "to", "the", "instrumental", "distribution" ]
python
train
40.285714
gem/oq-engine
openquake/hazardlib/gsim/lin_2009.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/lin_2009.py#L128-L137
def _get_stddevs(self, C, stddev_types, nsites): """ Compute total standard deviation, see table 4.2, page 50. """ stddevs = [] for stddev_type in stddev_types: assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES if stddev_type == const.StdDev....
[ "def", "_get_stddevs", "(", "self", ",", "C", ",", "stddev_types", ",", "nsites", ")", ":", "stddevs", "=", "[", "]", "for", "stddev_type", "in", "stddev_types", ":", "assert", "stddev_type", "in", "self", ".", "DEFINED_FOR_STANDARD_DEVIATION_TYPES", "if", "st...
Compute total standard deviation, see table 4.2, page 50.
[ "Compute", "total", "standard", "deviation", "see", "table", "4", ".", "2", "page", "50", "." ]
python
train
41.5
tensorpack/tensorpack
tensorpack/models/tflayer.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/models/tflayer.py#L73-L89
def rename_get_variable(mapping): """ Args: mapping(dict): an old -> new mapping for variable basename. e.g. {'kernel': 'W'} Returns: A context where the variables are renamed. """ def custom_getter(getter, name, *args, **kwargs): splits = name.split('/') basename = ...
[ "def", "rename_get_variable", "(", "mapping", ")", ":", "def", "custom_getter", "(", "getter", ",", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "splits", "=", "name", ".", "split", "(", "'/'", ")", "basename", "=", "splits", "[", "-"...
Args: mapping(dict): an old -> new mapping for variable basename. e.g. {'kernel': 'W'} Returns: A context where the variables are renamed.
[ "Args", ":", "mapping", "(", "dict", ")", ":", "an", "old", "-", ">", "new", "mapping", "for", "variable", "basename", ".", "e", ".", "g", ".", "{", "kernel", ":", "W", "}" ]
python
train
32.235294
SchroterQuentin/django-search-listview
fabfile.py
https://github.com/SchroterQuentin/django-search-listview/blob/8b027a6908dc30c6ebc613bb4fde6b1ba40124a3/fabfile.py#L68-L85
def dev(): """Define dev stage""" env.roledefs = { 'web': ['192.168.1.2'], 'lb': ['192.168.1.2'], } env.user = 'vagrant' env.backends = env.roledefs['web'] env.server_name = 'django_search_model-dev.net' env.short_server_name = 'django_search_model-dev' env.stat...
[ "def", "dev", "(", ")", ":", "env", ".", "roledefs", "=", "{", "'web'", ":", "[", "'192.168.1.2'", "]", ",", "'lb'", ":", "[", "'192.168.1.2'", "]", ",", "}", "env", ".", "user", "=", "'vagrant'", "env", ".", "backends", "=", "env", ".", "roledefs"...
Define dev stage
[ "Define", "dev", "stage" ]
python
train
29.666667
JNRowe/upoints
upoints/point.py
https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/point.py#L41-L68
def _dms_formatter(latitude, longitude, mode, unistr=False): """Generate a human readable DM/DMS location string. Args: latitude (float): Location's latitude longitude (float): Location's longitude mode (str): Coordinate formatting system to use unistr (bool): Whether to use ext...
[ "def", "_dms_formatter", "(", "latitude", ",", "longitude", ",", "mode", ",", "unistr", "=", "False", ")", ":", "if", "unistr", ":", "chars", "=", "(", "'°',", " ", "′', '", "″", ")", "", "else", ":", "chars", "=", "(", "'°',", " ", "'\",", " ", ...
Generate a human readable DM/DMS location string. Args: latitude (float): Location's latitude longitude (float): Location's longitude mode (str): Coordinate formatting system to use unistr (bool): Whether to use extended character set
[ "Generate", "a", "human", "readable", "DM", "/", "DMS", "location", "string", "." ]
python
train
35.892857
fcvarela/pyremotezip
pyremotezip/remotezip.py
https://github.com/fcvarela/pyremotezip/blob/52cc885b2ed1e690d92d3b41fef7a1a3fcc2b509/pyremotezip/remotezip.py#L138-L192
def extractFile(self, filename): """ This function will extract a single file from the remote zip without downloading the entire zip file. The filename argument should match whatever is in the 'filename' key of the tableOfContents. """ files = [x for x in self.tableOfCont...
[ "def", "extractFile", "(", "self", ",", "filename", ")", ":", "files", "=", "[", "x", "for", "x", "in", "self", ".", "tableOfContents", "if", "x", "[", "'filename'", "]", "==", "filename", "]", "if", "len", "(", "files", ")", "==", "0", ":", "raise...
This function will extract a single file from the remote zip without downloading the entire zip file. The filename argument should match whatever is in the 'filename' key of the tableOfContents.
[ "This", "function", "will", "extract", "a", "single", "file", "from", "the", "remote", "zip", "without", "downloading", "the", "entire", "zip", "file", ".", "The", "filename", "argument", "should", "match", "whatever", "is", "in", "the", "filename", "key", "...
python
valid
40.818182
openstack/proliantutils
proliantutils/redfish/resources/system/storage/logical_drive.py
https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/logical_drive.py#L56-L64
def logical_raid_levels(self): """Gets the raid level for each logical volume :returns the set of list of raid levels configured. """ lg_raid_lvls = set() for member in self.get_members(): lg_raid_lvls.add(mappings.RAID_LEVEL_MAP_REV.get(member.raid)) return ...
[ "def", "logical_raid_levels", "(", "self", ")", ":", "lg_raid_lvls", "=", "set", "(", ")", "for", "member", "in", "self", ".", "get_members", "(", ")", ":", "lg_raid_lvls", ".", "add", "(", "mappings", ".", "RAID_LEVEL_MAP_REV", ".", "get", "(", "member", ...
Gets the raid level for each logical volume :returns the set of list of raid levels configured.
[ "Gets", "the", "raid", "level", "for", "each", "logical", "volume" ]
python
train
36
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/work_item_tracking_process/work_item_tracking_process_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/work_item_tracking_process/work_item_tracking_process_client.py#L650-L661
def delete_process_by_id(self, process_type_id): """DeleteProcessById. [Preview API] Removes a process of a specific ID. :param str process_type_id: """ route_values = {} if process_type_id is not None: route_values['processTypeId'] = self._serialize.url('proc...
[ "def", "delete_process_by_id", "(", "self", ",", "process_type_id", ")", ":", "route_values", "=", "{", "}", "if", "process_type_id", "is", "not", "None", ":", "route_values", "[", "'processTypeId'", "]", "=", "self", ".", "_serialize", ".", "url", "(", "'pr...
DeleteProcessById. [Preview API] Removes a process of a specific ID. :param str process_type_id:
[ "DeleteProcessById", ".", "[", "Preview", "API", "]", "Removes", "a", "process", "of", "a", "specific", "ID", ".", ":", "param", "str", "process_type_id", ":" ]
python
train
45.666667
hendrix/hendrix
hendrix/contrib/cache/resource.py
https://github.com/hendrix/hendrix/blob/175af011a7e5822b772bfec0e11a46466bb8688d/hendrix/contrib/cache/resource.py#L148-L156
def getChild(self, path, request): """ This is necessary because the parent class would call proxy.ReverseProxyResource instead of CacheProxyResource """ return CacheProxyResource( self.host, self.port, self.path + '/' + urlquote(path, safe=""), self.react...
[ "def", "getChild", "(", "self", ",", "path", ",", "request", ")", ":", "return", "CacheProxyResource", "(", "self", ".", "host", ",", "self", ".", "port", ",", "self", ".", "path", "+", "'/'", "+", "urlquote", "(", "path", ",", "safe", "=", "\"\"", ...
This is necessary because the parent class would call proxy.ReverseProxyResource instead of CacheProxyResource
[ "This", "is", "necessary", "because", "the", "parent", "class", "would", "call", "proxy", ".", "ReverseProxyResource", "instead", "of", "CacheProxyResource" ]
python
train
36
wilson-eft/wilson
wilson/util/wetutil.py
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L108-L146
def symmetrize_JMS_dict(C): """For a dictionary with JMS Wilson coefficients but keys that might not be in the non-redundant basis, return a dictionary with keys from the basis and values conjugated if necessary.""" wc_keys = set(wcxf.Basis['WET', 'JMS'].all_wcs) Cs = {} for op, v in C.items(): ...
[ "def", "symmetrize_JMS_dict", "(", "C", ")", ":", "wc_keys", "=", "set", "(", "wcxf", ".", "Basis", "[", "'WET'", ",", "'JMS'", "]", ".", "all_wcs", ")", "Cs", "=", "{", "}", "for", "op", ",", "v", "in", "C", ".", "items", "(", ")", ":", "if", ...
For a dictionary with JMS Wilson coefficients but keys that might not be in the non-redundant basis, return a dictionary with keys from the basis and values conjugated if necessary.
[ "For", "a", "dictionary", "with", "JMS", "Wilson", "coefficients", "but", "keys", "that", "might", "not", "be", "in", "the", "non", "-", "redundant", "basis", "return", "a", "dictionary", "with", "keys", "from", "the", "basis", "and", "values", "conjugated",...
python
train
38.25641
KnowledgeLinks/rdfframework
rdfframework/connections/fedoracommons.py
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/fedoracommons.py#L70-L100
def check_status(self): """ tests both the ext_url and local_url to see if the database is running returns: True if a connection can be made False if the connection cannot me made """ log = logging.getLogger("%s.%s" % (self.log_name, ...
[ "def", "check_status", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "\"%s.%s\"", "%", "(", "self", ".", "log_name", ",", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "3", "]", ")", ")", "log", ".", "setLevel", "(...
tests both the ext_url and local_url to see if the database is running returns: True if a connection can be made False if the connection cannot me made
[ "tests", "both", "the", "ext_url", "and", "local_url", "to", "see", "if", "the", "database", "is", "running" ]
python
train
36.903226
leonidessaguisagjr/unicodeutil
unicodeutil/unicodeutil.py
https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L49-L62
def _unichr(i): """ Helper function for taking a Unicode scalar value and returning a Unicode character. :param s: Unicode scalar value to convert. :return: Unicode character """ if not isinstance(i, int): raise TypeError try: return six.unichr(i) except ValueError: ...
[ "def", "_unichr", "(", "i", ")", ":", "if", "not", "isinstance", "(", "i", ",", "int", ")", ":", "raise", "TypeError", "try", ":", "return", "six", ".", "unichr", "(", "i", ")", "except", "ValueError", ":", "# Workaround the error \"ValueError: unichr() arg ...
Helper function for taking a Unicode scalar value and returning a Unicode character. :param s: Unicode scalar value to convert. :return: Unicode character
[ "Helper", "function", "for", "taking", "a", "Unicode", "scalar", "value", "and", "returning", "a", "Unicode", "character", "." ]
python
train
32.571429
bcbio/bcbio-nextgen
bcbio/variation/mutect.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/mutect.py#L191-L217
def _SID_call_prep(align_bams, items, ref_file, assoc_files, region=None, out_file=None): """Preparation work for SomaticIndelDetector. """ base_config = items[0]["config"] for x in align_bams: bam.index(x, base_config) params = ["-R", ref_file, "-T", "SomaticIndelDetector", "-U", "ALLOW_N_...
[ "def", "_SID_call_prep", "(", "align_bams", ",", "items", ",", "ref_file", ",", "assoc_files", ",", "region", "=", "None", ",", "out_file", "=", "None", ")", ":", "base_config", "=", "items", "[", "0", "]", "[", "\"config\"", "]", "for", "x", "in", "al...
Preparation work for SomaticIndelDetector.
[ "Preparation", "work", "for", "SomaticIndelDetector", "." ]
python
train
49.444444
elifesciences/elife-tools
elifetools/parseJATS.py
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2108-L2126
def body_json(soup, base_url=None): """ Get body json and then alter it with section wrapping and removing boxed-text """ body_content = body(soup, remove_key_info_box=True, base_url=base_url) # Wrap in a section if the first block is not a section if (body_content and len(body_content) > 0 and "type" i...
[ "def", "body_json", "(", "soup", ",", "base_url", "=", "None", ")", ":", "body_content", "=", "body", "(", "soup", ",", "remove_key_info_box", "=", "True", ",", "base_url", "=", "base_url", ")", "# Wrap in a section if the first block is not a section", "if", "(",...
Get body json and then alter it with section wrapping and removing boxed-text
[ "Get", "body", "json", "and", "then", "alter", "it", "with", "section", "wrapping", "and", "removing", "boxed", "-", "text" ]
python
train
49.210526
alorence/django-modern-rpc
modernrpc/handlers/base.py
https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/handlers/base.py#L63-L110
def execute_procedure(self, name, args=None, kwargs=None): """ Call the concrete python function corresponding to given RPC Method `name` and return the result. Raise RPCUnknownMethod, AuthenticationFailed, RPCInvalidParams or any Exception sub-class. """ _method = registry.get...
[ "def", "execute_procedure", "(", "self", ",", "name", ",", "args", "=", "None", ",", "kwargs", "=", "None", ")", ":", "_method", "=", "registry", ".", "get_method", "(", "name", ",", "self", ".", "entry_point", ",", "self", ".", "protocol", ")", "if", ...
Call the concrete python function corresponding to given RPC Method `name` and return the result. Raise RPCUnknownMethod, AuthenticationFailed, RPCInvalidParams or any Exception sub-class.
[ "Call", "the", "concrete", "python", "function", "corresponding", "to", "given", "RPC", "Method", "name", "and", "return", "the", "result", "." ]
python
train
39.479167
binux/pyspider
pyspider/scheduler/scheduler.py
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L263-L280
def _load_tasks(self, project): '''load tasks from database''' task_queue = project.task_queue for task in self.taskdb.load_tasks( self.taskdb.ACTIVE, project.name, self.scheduler_task_fields ): taskid = task['taskid'] _schedule = task.get('schedu...
[ "def", "_load_tasks", "(", "self", ",", "project", ")", ":", "task_queue", "=", "project", ".", "task_queue", "for", "task", "in", "self", ".", "taskdb", ".", "load_tasks", "(", "self", ".", "taskdb", ".", "ACTIVE", ",", "project", ".", "name", ",", "s...
load tasks from database
[ "load", "tasks", "from", "database" ]
python
train
47.055556
cknoll/ipydex
ipydex/core.py
https://github.com/cknoll/ipydex/blob/ca528ce4c97ee934e48efbd5983c1b7cd88bec9d/ipydex/core.py#L701-L719
def publish_attrs(self, upcount=1): """ Magic function which inject all attrs into the callers namespace :param upcount int, how many stack levels we go up :return: """ frame = inspect.currentframe() i = upcount while True: if frame.f_back...
[ "def", "publish_attrs", "(", "self", ",", "upcount", "=", "1", ")", ":", "frame", "=", "inspect", ".", "currentframe", "(", ")", "i", "=", "upcount", "while", "True", ":", "if", "frame", ".", "f_back", "is", "None", ":", "break", "frame", "=", "frame...
Magic function which inject all attrs into the callers namespace :param upcount int, how many stack levels we go up :return:
[ "Magic", "function", "which", "inject", "all", "attrs", "into", "the", "callers", "namespace", ":", "param", "upcount", "int", "how", "many", "stack", "levels", "we", "go", "up", ":", "return", ":" ]
python
train
26.789474
eandersson/amqpstorm
amqpstorm/channel.py
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/channel.py#L197-L209
def confirm_deliveries(self): """Set the channel to confirm that each message has been successfully delivered. :raises AMQPChannelError: Raises if the channel encountered an error. :raises AMQPConnectionError: Raises if the connection encountered an ...
[ "def", "confirm_deliveries", "(", "self", ")", ":", "self", ".", "_confirming_deliveries", "=", "True", "confirm_frame", "=", "specification", ".", "Confirm", ".", "Select", "(", ")", "return", "self", ".", "rpc_request", "(", "confirm_frame", ")" ]
Set the channel to confirm that each message has been successfully delivered. :raises AMQPChannelError: Raises if the channel encountered an error. :raises AMQPConnectionError: Raises if the connection encountered an error. :return:
[ "Set", "the", "channel", "to", "confirm", "that", "each", "message", "has", "been", "successfully", "delivered", "." ]
python
train
37.615385
SeleniumHQ/selenium
py/selenium/webdriver/common/alert.py
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/alert.py#L92-L105
def send_keys(self, keysToSend): """ Send Keys to the Alert. :Args: - keysToSend: The text to be sent to Alert. """ if self.driver.w3c: self.driver.execute(Command.W3C_SET_ALERT_VALUE, {'value': keys_to_typing(keysToSend), ...
[ "def", "send_keys", "(", "self", ",", "keysToSend", ")", ":", "if", "self", ".", "driver", ".", "w3c", ":", "self", ".", "driver", ".", "execute", "(", "Command", ".", "W3C_SET_ALERT_VALUE", ",", "{", "'value'", ":", "keys_to_typing", "(", "keysToSend", ...
Send Keys to the Alert. :Args: - keysToSend: The text to be sent to Alert.
[ "Send", "Keys", "to", "the", "Alert", "." ]
python
train
32.071429
alberanid/python-iplib
iplib.py
https://github.com/alberanid/python-iplib/blob/488b56fe57ad836b27feec9e76f51883db28faa6/iplib.py#L125-L136
def is_bin(ip): """Return true if the IP address is in binary notation.""" try: ip = str(ip) if len(ip) != 32: return False dec = int(ip, 2) except (TypeError, ValueError): return False if dec > 4294967295 or dec < 0: return False return True
[ "def", "is_bin", "(", "ip", ")", ":", "try", ":", "ip", "=", "str", "(", "ip", ")", "if", "len", "(", "ip", ")", "!=", "32", ":", "return", "False", "dec", "=", "int", "(", "ip", ",", "2", ")", "except", "(", "TypeError", ",", "ValueError", "...
Return true if the IP address is in binary notation.
[ "Return", "true", "if", "the", "IP", "address", "is", "in", "binary", "notation", "." ]
python
valid
25.25
adrn/gala
gala/dynamics/orbit.py
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L885-L916
def to_frame(self, frame, current_frame=None, **kwargs): """ TODO: Parameters ---------- frame : `gala.potential.CFrameBase` The frame to transform to. current_frame : `gala.potential.CFrameBase` (optional) If the Orbit has no associated Hamiltoni...
[ "def", "to_frame", "(", "self", ",", "frame", ",", "current_frame", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kw", "=", "kwargs", ".", "copy", "(", ")", "# TODO: need a better way to do this!", "from", ".", ".", "potential", ".", "frame", ".", "bu...
TODO: Parameters ---------- frame : `gala.potential.CFrameBase` The frame to transform to. current_frame : `gala.potential.CFrameBase` (optional) If the Orbit has no associated Hamiltonian, this specifies the current frame of the orbit. Retur...
[ "TODO", ":" ]
python
train
31.125
bitesofcode/projexui
projexui/widgets/xchart/xchart.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchart.py#L154-L168
def _addDatasetAction(self, dataset): """ Adds an action for the inputed dataset to the toolbar :param dataset | <XChartDataset> """ # create the toolbar action action = QAction(dataset.name(), self) action.setIcon(XColorIcon(dataset.color())...
[ "def", "_addDatasetAction", "(", "self", ",", "dataset", ")", ":", "# create the toolbar action\r", "action", "=", "QAction", "(", "dataset", ".", "name", "(", ")", ",", "self", ")", "action", ".", "setIcon", "(", "XColorIcon", "(", "dataset", ".", "color", ...
Adds an action for the inputed dataset to the toolbar :param dataset | <XChartDataset>
[ "Adds", "an", "action", "for", "the", "inputed", "dataset", "to", "the", "toolbar", ":", "param", "dataset", "|", "<XChartDataset", ">" ]
python
train
35.266667
gitpython-developers/GitPython
git/refs/log.py
https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/refs/log.py#L180-L186
def path(cls, ref): """ :return: string to absolute path at which the reflog of the given ref instance would be found. The path is not guaranteed to point to a valid file though. :param ref: SymbolicReference instance""" return osp.join(ref.repo.git_dir, "logs", t...
[ "def", "path", "(", "cls", ",", "ref", ")", ":", "return", "osp", ".", "join", "(", "ref", ".", "repo", ".", "git_dir", ",", "\"logs\"", ",", "to_native_path", "(", "ref", ".", "path", ")", ")" ]
:return: string to absolute path at which the reflog of the given ref instance would be found. The path is not guaranteed to point to a valid file though. :param ref: SymbolicReference instance
[ ":", "return", ":", "string", "to", "absolute", "path", "at", "which", "the", "reflog", "of", "the", "given", "ref", "instance", "would", "be", "found", ".", "The", "path", "is", "not", "guaranteed", "to", "point", "to", "a", "valid", "file", "though", ...
python
train
48.285714
devassistant/devassistant
devassistant/dapi/dapicli.py
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L610-L628
def _get_dependencies_of(name, location=None): ''' Returns list of first level dependencies of the given installed dap or dap from Dapi if not installed If a location is specified, this only checks for dap installed in that path and return [] if the dap is not located there ''' if not locat...
[ "def", "_get_dependencies_of", "(", "name", ",", "location", "=", "None", ")", ":", "if", "not", "location", ":", "detailed_dap_list", "=", "get_installed_daps_detailed", "(", ")", "if", "name", "not", "in", "detailed_dap_list", ":", "return", "_get_api_dependenci...
Returns list of first level dependencies of the given installed dap or dap from Dapi if not installed If a location is specified, this only checks for dap installed in that path and return [] if the dap is not located there
[ "Returns", "list", "of", "first", "level", "dependencies", "of", "the", "given", "installed", "dap", "or", "dap", "from", "Dapi", "if", "not", "installed", "If", "a", "location", "is", "specified", "this", "only", "checks", "for", "dap", "installed", "in", ...
python
train
37.684211
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/parsers.py
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L132-L155
def parse_gene_list(path: str, graph: Graph, anno_type: str = "name") -> list: """Parse a list of genes and return them if they are in the network. :param str path: The path of input file. :param Graph graph: The graph with genes as nodes. :param str anno_type: The type of annotation with two options:n...
[ "def", "parse_gene_list", "(", "path", ":", "str", ",", "graph", ":", "Graph", ",", "anno_type", ":", "str", "=", "\"name\"", ")", "->", "list", ":", "# read the file", "genes", "=", "pd", ".", "read_csv", "(", "path", ",", "header", "=", "None", ")", ...
Parse a list of genes and return them if they are in the network. :param str path: The path of input file. :param Graph graph: The graph with genes as nodes. :param str anno_type: The type of annotation with two options:name-Entrez ID, symbol-HGNC symbol. :return list: A list of genes, all of which are...
[ "Parse", "a", "list", "of", "genes", "and", "return", "them", "if", "they", "are", "in", "the", "network", "." ]
python
train
39.75
olt/scriptine
scriptine/_path.py
https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L561-L596
def text(self, encoding=None, errors='strict'): r""" Open this file, read it in, return the content as a string. This uses 'U' mode in Python 2.3 and later, so '\r\n' and '\r' are automatically translated to '\n'. Optional arguments: encoding - The Unicode encoding (or charact...
[ "def", "text", "(", "self", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ")", ":", "if", "encoding", "is", "None", ":", "# 8-bit", "f", "=", "self", ".", "open", "(", "_textmode", ")", "try", ":", "return", "f", ".", "read", "(", ...
r""" Open this file, read it in, return the content as a string. This uses 'U' mode in Python 2.3 and later, so '\r\n' and '\r' are automatically translated to '\n'. Optional arguments: encoding - The Unicode encoding (or character set) of the file. If present, the conten...
[ "r", "Open", "this", "file", "read", "it", "in", "return", "the", "content", "as", "a", "string", "." ]
python
train
36.75
GoogleCloudPlatform/python-repo-tools
gcp_devrel/tools/pylint.py
https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/pylint.py#L148-L167
def determine_final_config(config_module): """Determines the final additions and replacements. Combines the config module with the defaults. Args: config_module: The loaded local configuration module. Returns: Config: the final configuration. """ config = Config( DEFAU...
[ "def", "determine_final_config", "(", "config_module", ")", ":", "config", "=", "Config", "(", "DEFAULT_LIBRARY_RC_ADDITIONS", ",", "DEFAULT_LIBRARY_RC_REPLACEMENTS", ",", "DEFAULT_TEST_RC_ADDITIONS", ",", "DEFAULT_TEST_RC_REPLACEMENTS", ")", "for", "field", "in", "config",...
Determines the final additions and replacements. Combines the config module with the defaults. Args: config_module: The loaded local configuration module. Returns: Config: the final configuration.
[ "Determines", "the", "final", "additions", "and", "replacements", "." ]
python
train
29.85
PythonicNinja/pydrill
pydrill/connection/base.py
https://github.com/PythonicNinja/pydrill/blob/0713e78c84d44cd438018e4ba1588a8e242f78c4/pydrill/connection/base.py#L62-L83
def log_request_success(self, method, full_url, path, body, status_code, response, duration): """ Log a successful API call. """ if body and not isinstance(body, dict): body = body.decode('utf-8') logger.info( '%s %s [status:%s request:%.3fs]', method, full_url, ...
[ "def", "log_request_success", "(", "self", ",", "method", ",", "full_url", ",", "path", ",", "body", ",", "status_code", ",", "response", ",", "duration", ")", ":", "if", "body", "and", "not", "isinstance", "(", "body", ",", "dict", ")", ":", "body", "...
Log a successful API call.
[ "Log", "a", "successful", "API", "call", "." ]
python
train
41.454545
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/device_directory/device_directory.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/device_directory/device_directory.py#L268-L276
def delete_query(self, query_id): """Delete query in device query service. :param int query_id: ID of the query to delete (Required) :return: void """ api = self._get_api(device_directory.DefaultApi) api.device_query_destroy(query_id) return
[ "def", "delete_query", "(", "self", ",", "query_id", ")", ":", "api", "=", "self", ".", "_get_api", "(", "device_directory", ".", "DefaultApi", ")", "api", ".", "device_query_destroy", "(", "query_id", ")", "return" ]
Delete query in device query service. :param int query_id: ID of the query to delete (Required) :return: void
[ "Delete", "query", "in", "device", "query", "service", "." ]
python
train
32.222222
secdev/scapy
scapy/layers/can.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/can.py#L87-L147
def rdcandump(filename, count=None, is_not_log_file_format=False, interface=None): """Read a candump log file and return a packet list count: read only <count> packets is_not_log_file_format: read input with candumps stdout format interfaces: return only packets from a specified interfa...
[ "def", "rdcandump", "(", "filename", ",", "count", "=", "None", ",", "is_not_log_file_format", "=", "False", ",", "interface", "=", "None", ")", ":", "try", ":", "if", "isinstance", "(", "filename", ",", "six", ".", "string_types", ")", ":", "file", "=",...
Read a candump log file and return a packet list count: read only <count> packets is_not_log_file_format: read input with candumps stdout format interfaces: return only packets from a specified interface
[ "Read", "a", "candump", "log", "file", "and", "return", "a", "packet", "list" ]
python
train
27.180328
treycucco/pyebnf
pyebnf/_hand_written_parser.py
https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/_hand_written_parser.py#L93-L140
def expression(self, text): """expression = number , op_mult , expression | expression_terminal , op_mult , number , [operator , expression] | expression_terminal , op_add , [operator , expression] | expression_terminal , [operator , expression] ; """ se...
[ "def", "expression", "(", "self", ",", "text", ")", ":", "self", ".", "_attempting", "(", "text", ")", "return", "alternation", "(", "[", "# number , op_mult , expression", "concatenation", "(", "[", "self", ".", "number", ",", "self", ".", "op_mult", ",", ...
expression = number , op_mult , expression | expression_terminal , op_mult , number , [operator , expression] | expression_terminal , op_add , [operator , expression] | expression_terminal , [operator , expression] ;
[ "expression", "=", "number", "op_mult", "expression", "|", "expression_terminal", "op_mult", "number", "[", "operator", "expression", "]", "|", "expression_terminal", "op_add", "[", "operator", "expression", "]", "|", "expression_terminal", "[", "operator", "expressio...
python
test
30.770833
Crunch-io/crunch-cube
src/cr/cube/crunch_cube.py
https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/crunch_cube.py#L1490-L1500
def _flat_values(self): """Return tuple of mean values as found in cube response. Mean data may include missing items represented by a dict like {'?': -1} in the cube response. These are replaced by np.nan in the returned value. """ return tuple( np.nan if ty...
[ "def", "_flat_values", "(", "self", ")", ":", "return", "tuple", "(", "np", ".", "nan", "if", "type", "(", "x", ")", "is", "dict", "else", "x", "for", "x", "in", "self", ".", "_cube_dict", "[", "\"result\"", "]", "[", "\"measures\"", "]", "[", "\"m...
Return tuple of mean values as found in cube response. Mean data may include missing items represented by a dict like {'?': -1} in the cube response. These are replaced by np.nan in the returned value.
[ "Return", "tuple", "of", "mean", "values", "as", "found", "in", "cube", "response", "." ]
python
train
37.727273
Gandi/gandi.cli
gandi/cli/core/conf.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/conf.py#L75-L89
def load(cls, filename, name=None): """ Load yaml configuration from filename. """ if not os.path.exists(filename): return {} name = name or filename if name not in cls._conffiles: with open(filename) as fdesc: content = yaml.load(fdesc, YAMLLoade...
[ "def", "load", "(", "cls", ",", "filename", ",", "name", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "return", "{", "}", "name", "=", "name", "or", "filename", "if", "name", "not", "in", "cls",...
Load yaml configuration from filename.
[ "Load", "yaml", "configuration", "from", "filename", "." ]
python
train
33.666667
google/grr
grr/core/grr_response_core/lib/rdfvalues/paths.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/paths.py#L335-L346
def AsRegEx(self): """Return the current glob as a simple regex. Note: No interpolation is performed. Returns: A RegularExpression() object. """ parts = self.__class__.REGEX_SPLIT_PATTERN.split(self._value) result = u"".join(self._ReplaceRegExPart(p) for p in parts) return rdf_stand...
[ "def", "AsRegEx", "(", "self", ")", ":", "parts", "=", "self", ".", "__class__", ".", "REGEX_SPLIT_PATTERN", ".", "split", "(", "self", ".", "_value", ")", "result", "=", "u\"\"", ".", "join", "(", "self", ".", "_ReplaceRegExPart", "(", "p", ")", "for"...
Return the current glob as a simple regex. Note: No interpolation is performed. Returns: A RegularExpression() object.
[ "Return", "the", "current", "glob", "as", "a", "simple", "regex", "." ]
python
train
29.666667
agile-geoscience/welly
welly/project.py
https://github.com/agile-geoscience/welly/blob/ed4c991011d6290938fef365553041026ba29f42/welly/project.py#L145-L172
def add_canstrat_striplogs(self, path, uwi_transform=None, name='canstrat'): """ This may be too specific a method... just move it to the workflow. Requires striplog. """ from striplog import Striplog uwi_transform = uwi_transform or utils...
[ "def", "add_canstrat_striplogs", "(", "self", ",", "path", ",", "uwi_transform", "=", "None", ",", "name", "=", "'canstrat'", ")", ":", "from", "striplog", "import", "Striplog", "uwi_transform", "=", "uwi_transform", "or", "utils", ".", "null", "for", "w", "...
This may be too specific a method... just move it to the workflow. Requires striplog.
[ "This", "may", "be", "too", "specific", "a", "method", "...", "just", "move", "it", "to", "the", "workflow", "." ]
python
train
30.428571
Alignak-monitoring/alignak
alignak/objects/item.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1092-L1101
def old_properties_names_to_new(self): # pragma: no cover, never called """Convert old Nagios2 names to Nagios3 new names TODO: still useful? :return: None """ for i in itertools.chain(iter(list(self.items.values())), iter(list(self.templates.v...
[ "def", "old_properties_names_to_new", "(", "self", ")", ":", "# pragma: no cover, never called", "for", "i", "in", "itertools", ".", "chain", "(", "iter", "(", "list", "(", "self", ".", "items", ".", "values", "(", ")", ")", ")", ",", "iter", "(", "list", ...
Convert old Nagios2 names to Nagios3 new names TODO: still useful? :return: None
[ "Convert", "old", "Nagios2", "names", "to", "Nagios3", "new", "names" ]
python
train
36.6
apache/incubator-mxnet
tools/caffe_converter/convert_symbol.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/convert_symbol.py#L127-L295
def _parse_proto(prototxt_fname): """Parse Caffe prototxt into symbol string """ proto = caffe_parser.read_prototxt(prototxt_fname) # process data layer input_name, input_dim, layers = _get_input(proto) # only support single input, so always use `data` as the input data mapping = {input_nam...
[ "def", "_parse_proto", "(", "prototxt_fname", ")", ":", "proto", "=", "caffe_parser", ".", "read_prototxt", "(", "prototxt_fname", ")", "# process data layer", "input_name", ",", "input_dim", ",", "layers", "=", "_get_input", "(", "proto", ")", "# only support singl...
Parse Caffe prototxt into symbol string
[ "Parse", "Caffe", "prototxt", "into", "symbol", "string" ]
python
train
47.319527
undertheseanlp/languageflow
languageflow/flow.py
https://github.com/undertheseanlp/languageflow/blob/1436e0bf72803e02ccf727f41e8fc85ba167d9fe/languageflow/flow.py#L86-L98
def train(self): """ Train model with transformed data """ for i, model in enumerate(self.models): N = [int(i * len(self.y)) for i in self.lc_range] for n in N: X = self.X[:n] y = self.y[:n] e = Experiment(X, y, mode...
[ "def", "train", "(", "self", ")", ":", "for", "i", ",", "model", "in", "enumerate", "(", "self", ".", "models", ")", ":", "N", "=", "[", "int", "(", "i", "*", "len", "(", "self", ".", "y", ")", ")", "for", "i", "in", "self", ".", "lc_range", ...
Train model with transformed data
[ "Train", "model", "with", "transformed", "data" ]
python
valid
35.461538
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/generators.py
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/generators.py#L28-L43
def first_from_generator(generator): """Pull the first value from a generator and return it, closing the generator :param generator: A generator, this will be mapped onto a list and the first item extracted. :return: None if there are no items, or the first item otherwise. :internal: ...
[ "def", "first_from_generator", "(", "generator", ")", ":", "try", ":", "result", "=", "next", "(", "generator", ")", "except", "StopIteration", ":", "result", "=", "None", "finally", ":", "generator", ".", "close", "(", ")", "return", "result" ]
Pull the first value from a generator and return it, closing the generator :param generator: A generator, this will be mapped onto a list and the first item extracted. :return: None if there are no items, or the first item otherwise. :internal:
[ "Pull", "the", "first", "value", "from", "a", "generator", "and", "return", "it", "closing", "the", "generator" ]
python
train
28.5625
rochacbruno/dynaconf
dynaconf/utils/__init__.py
https://github.com/rochacbruno/dynaconf/blob/5a7cc8f8252251cbdf4f4112965801f9dfe2831d/dynaconf/utils/__init__.py#L148-L154
def deduplicate(list_object): """Rebuild `list_object` removing duplicated and keeping order""" new = [] for item in list_object: if item not in new: new.append(item) return new
[ "def", "deduplicate", "(", "list_object", ")", ":", "new", "=", "[", "]", "for", "item", "in", "list_object", ":", "if", "item", "not", "in", "new", ":", "new", ".", "append", "(", "item", ")", "return", "new" ]
Rebuild `list_object` removing duplicated and keeping order
[ "Rebuild", "list_object", "removing", "duplicated", "and", "keeping", "order" ]
python
train
29.571429
secdev/scapy
scapy/contrib/mac_control.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/mac_control.py#L152-L169
def get_pause_time(self, speed=ETHER_SPEED_MBIT_1000): """ get pause time for given link speed in seconds :param speed: select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501 :return: pause time in seconds :raises MACControlInvalidSpeed...
[ "def", "get_pause_time", "(", "self", ",", "speed", "=", "ETHER_SPEED_MBIT_1000", ")", ":", "try", ":", "return", "self", ".", "pause_time", "*", "{", "ETHER_SPEED_MBIT_10", ":", "(", "0.0000001", "*", "512", ")", ",", "ETHER_SPEED_MBIT_100", ":", "(", "0.00...
get pause time for given link speed in seconds :param speed: select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501 :return: pause time in seconds :raises MACControlInvalidSpeedException: on invalid speed selector
[ "get", "pause", "time", "for", "given", "link", "speed", "in", "seconds" ]
python
train
45.722222
rigetti/pyquil
pyquil/reference_simulator.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/reference_simulator.py#L51-L68
def sample_bitstrings(self, n_samples): """ Sample bitstrings from the distribution defined by the wavefunction. Qubit 0 is at ``out[:, 0]``. :param n_samples: The number of bitstrings to sample :return: An array of shape (n_samples, n_qubits) """ if self.rs is ...
[ "def", "sample_bitstrings", "(", "self", ",", "n_samples", ")", ":", "if", "self", ".", "rs", "is", "None", ":", "raise", "ValueError", "(", "\"You have tried to perform a stochastic operation without setting the \"", "\"random state of the simulator. Might I suggest using a Py...
Sample bitstrings from the distribution defined by the wavefunction. Qubit 0 is at ``out[:, 0]``. :param n_samples: The number of bitstrings to sample :return: An array of shape (n_samples, n_qubits)
[ "Sample", "bitstrings", "from", "the", "distribution", "defined", "by", "the", "wavefunction", "." ]
python
train
47.333333
aio-libs/aioredis
aioredis/commands/generic.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/generic.py#L10-L13
def delete(self, key, *keys): """Delete a key.""" fut = self.execute(b'DEL', key, *keys) return wait_convert(fut, int)
[ "def", "delete", "(", "self", ",", "key", ",", "*", "keys", ")", ":", "fut", "=", "self", ".", "execute", "(", "b'DEL'", ",", "key", ",", "*", "keys", ")", "return", "wait_convert", "(", "fut", ",", "int", ")" ]
Delete a key.
[ "Delete", "a", "key", "." ]
python
train
34.75
LonamiWebs/Telethon
telethon/extensions/binaryreader.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/extensions/binaryreader.py#L108-L116
def tgread_bool(self): """Reads a Telegram boolean value.""" value = self.read_int(signed=False) if value == 0x997275b5: # boolTrue return True elif value == 0xbc799737: # boolFalse return False else: raise RuntimeError('Invalid boolean code ...
[ "def", "tgread_bool", "(", "self", ")", ":", "value", "=", "self", ".", "read_int", "(", "signed", "=", "False", ")", "if", "value", "==", "0x997275b5", ":", "# boolTrue", "return", "True", "elif", "value", "==", "0xbc799737", ":", "# boolFalse", "return",...
Reads a Telegram boolean value.
[ "Reads", "a", "Telegram", "boolean", "value", "." ]
python
train
37.222222
thespacedoctor/sloancone
build/lib/sloancone/cl_utils.py
https://github.com/thespacedoctor/sloancone/blob/106ea6533ad57f5f0ca82bf6db3053132bdb42e1/build/lib/sloancone/cl_utils.py#L178-L258
def main(arguments=None): """ *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* """ # setup the command-line util settings su = tools( arguments=arguments, docString=__doc__, logLevel="DEBUG", option...
[ "def", "main", "(", "arguments", "=", "None", ")", ":", "# setup the command-line util settings", "su", "=", "tools", "(", "arguments", "=", "arguments", ",", "docString", "=", "__doc__", ",", "logLevel", "=", "\"DEBUG\"", ",", "options_first", "=", "False", "...
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
[ "*", "The", "main", "function", "used", "when", "cl_utils", ".", "py", "is", "run", "as", "a", "single", "script", "from", "the", "cl", "or", "when", "installed", "as", "a", "cl", "command", "*" ]
python
train
32.382716
kodexlab/reliure
reliure/engine.py
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L362-L373
def selected(self): """ returns the list of selected component names. if no component selected return the one marked as default. If the block is required and no component where indicated as default, then the first component is selected. """ selected = self._selected ...
[ "def", "selected", "(", "self", ")", ":", "selected", "=", "self", ".", "_selected", "if", "len", "(", "self", ".", "_selected", ")", "==", "0", "and", "self", ".", "required", ":", "# nothing has been selected yet BUT the component is required", "selected", "="...
returns the list of selected component names. if no component selected return the one marked as default. If the block is required and no component where indicated as default, then the first component is selected.
[ "returns", "the", "list", "of", "selected", "component", "names", "." ]
python
train
41.166667
materialsproject/pymatgen
pymatgen/io/qchem/outputs.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/qchem/outputs.py#L651-L696
def _check_completion_errors(self): """ Parses four potential errors that can cause jobs to crash: inability to transform coordinates due to a bad symmetric specification, an input file that fails to pass inspection, and errors reading and writing files. """ if read_patte...
[ "def", "_check_completion_errors", "(", "self", ")", ":", "if", "read_pattern", "(", "self", ".", "text", ",", "{", "\"key\"", ":", "r\"Coordinates do not transform within specified threshold\"", "}", ",", "terminate_on_match", "=", "True", ")", ".", "get", "(", "...
Parses four potential errors that can cause jobs to crash: inability to transform coordinates due to a bad symmetric specification, an input file that fails to pass inspection, and errors reading and writing files.
[ "Parses", "four", "potential", "errors", "that", "can", "cause", "jobs", "to", "crash", ":", "inability", "to", "transform", "coordinates", "due", "to", "a", "bad", "symmetric", "specification", "an", "input", "file", "that", "fails", "to", "pass", "inspection...
python
train
42.065217
OCHA-DAP/hdx-python-utilities
src/hdx/utilities/downloader.py
https://github.com/OCHA-DAP/hdx-python-utilities/blob/9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3/src/hdx/utilities/downloader.py#L135-L152
def get_url_for_get(url, parameters=None): # type: (str, Optional[Dict]) -> str """Get full url for GET request including parameters Args: url (str): URL to download parameters (Optional[Dict]): Parameters to pass. Defaults to None. Returns: str: Ful...
[ "def", "get_url_for_get", "(", "url", ",", "parameters", "=", "None", ")", ":", "# type: (str, Optional[Dict]) -> str", "spliturl", "=", "urlsplit", "(", "url", ")", "getparams", "=", "OrderedDict", "(", "parse_qsl", "(", "spliturl", ".", "query", ")", ")", "i...
Get full url for GET request including parameters Args: url (str): URL to download parameters (Optional[Dict]): Parameters to pass. Defaults to None. Returns: str: Full url
[ "Get", "full", "url", "for", "GET", "request", "including", "parameters" ]
python
train
32.777778
Robin8Put/pmes
storage/rpc_methods.py
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L685-L718
async def set_access_string(self, **params): """Writes content access string to database """ if params.get("message"): params = json.loads(params.get("message", "{}")) cid = int(params.get("cid", "0")) seller_access_string = params.get("seller_access_string") seller_pubkey = params.get("seller_pubkey")...
[ "async", "def", "set_access_string", "(", "self", ",", "*", "*", "params", ")", ":", "if", "params", ".", "get", "(", "\"message\"", ")", ":", "params", "=", "json", ".", "loads", "(", "params", ".", "get", "(", "\"message\"", ",", "\"{}\"", ")", ")"...
Writes content access string to database
[ "Writes", "content", "access", "string", "to", "database" ]
python
train
30
tensorflow/mesh
mesh_tensorflow/auto_mtf/graph_interface.py
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/auto_mtf/graph_interface.py#L292-L299
def set_tensor_final(self, tensor_name): """Denotes a tensor as a final output of the computation. Args: tensor_name: a string, name of a tensor in the graph. """ tensor = self._name_to_tensor(tensor_name) self._final_tensors.add(tensor)
[ "def", "set_tensor_final", "(", "self", ",", "tensor_name", ")", ":", "tensor", "=", "self", ".", "_name_to_tensor", "(", "tensor_name", ")", "self", ".", "_final_tensors", ".", "add", "(", "tensor", ")" ]
Denotes a tensor as a final output of the computation. Args: tensor_name: a string, name of a tensor in the graph.
[ "Denotes", "a", "tensor", "as", "a", "final", "output", "of", "the", "computation", "." ]
python
train
32.125
isislovecruft/python-gnupg
pretty_bad_protocol/_util.py
https://github.com/isislovecruft/python-gnupg/blob/784571449032e811587249743e183fc5e908a673/pretty_bad_protocol/_util.py#L596-L602
def _make_random_string(length): """Returns a random lowercase, uppercase, alphanumerical string. :param int length: The length in bytes of the string to generate. """ chars = string.ascii_lowercase + string.ascii_uppercase + string.digits return ''.join(random.choice(chars) for x in range(length))
[ "def", "_make_random_string", "(", "length", ")", ":", "chars", "=", "string", ".", "ascii_lowercase", "+", "string", ".", "ascii_uppercase", "+", "string", ".", "digits", "return", "''", ".", "join", "(", "random", ".", "choice", "(", "chars", ")", "for",...
Returns a random lowercase, uppercase, alphanumerical string. :param int length: The length in bytes of the string to generate.
[ "Returns", "a", "random", "lowercase", "uppercase", "alphanumerical", "string", "." ]
python
train
44.857143
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/parallel/client/client.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/client/client.py#L1204-L1246
def send_apply_request(self, socket, f, args=None, kwargs=None, subheader=None, track=False, ident=None): """construct and send an apply message via a socket. This is the principal method with which all engine execution is performed by views. """ if self._cl...
[ "def", "send_apply_request", "(", "self", ",", "socket", ",", "f", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "subheader", "=", "None", ",", "track", "=", "False", ",", "ident", "=", "None", ")", ":", "if", "self", ".", "_closed", "...
construct and send an apply message via a socket. This is the principal method with which all engine execution is performed by views.
[ "construct", "and", "send", "an", "apply", "message", "via", "a", "socket", "." ]
python
test
41.604651
treyhunner/django-simple-history
simple_history/models.py
https://github.com/treyhunner/django-simple-history/blob/85758ecfe608279508a3fb5b71654d3e202eb63d/simple_history/models.py#L193-L228
def create_history_model(self, model, inherited): """ Creates a historical model to associate with the model provided. """ attrs = { "__module__": self.module, "_history_excluded_fields": self.excluded_fields, } app_module = "%s.models" % model._m...
[ "def", "create_history_model", "(", "self", ",", "model", ",", "inherited", ")", ":", "attrs", "=", "{", "\"__module__\"", ":", "self", ".", "module", ",", "\"_history_excluded_fields\"", ":", "self", ".", "excluded_fields", ",", "}", "app_module", "=", "\"%s....
Creates a historical model to associate with the model provided.
[ "Creates", "a", "historical", "model", "to", "associate", "with", "the", "model", "provided", "." ]
python
train
39.055556
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L1112-L1170
def _timestamp_regulator(self): """ Makes a dictionary whose keys are audio file basenames and whose values are a list of word blocks from unregulated timestamps and updates the main timestamp attribute. After all done, purges unregulated ones. In case the audio file was ...
[ "def", "_timestamp_regulator", "(", "self", ")", ":", "unified_timestamps", "=", "_PrettyDefaultDict", "(", "list", ")", "staged_files", "=", "self", ".", "_list_audio_files", "(", "sub_dir", "=", "\"staging\"", ")", "for", "timestamp_basename", "in", "self", ".",...
Makes a dictionary whose keys are audio file basenames and whose values are a list of word blocks from unregulated timestamps and updates the main timestamp attribute. After all done, purges unregulated ones. In case the audio file was large enough to be splitted, it adds seconds ...
[ "Makes", "a", "dictionary", "whose", "keys", "are", "audio", "file", "basenames", "and", "whose", "values", "are", "a", "list", "of", "word", "blocks", "from", "unregulated", "timestamps", "and", "updates", "the", "main", "timestamp", "attribute", ".", "After"...
python
train
53.186441
WhyNotHugo/django-afip
django_afip/admin.py
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/admin.py#L24-L59
def catch_errors(f): """ Catches specific errors in admin actions and shows a friendly error. """ @functools.wraps(f) def wrapper(self, request, *args, **kwargs): try: return f(self, request, *args, **kwargs) except exceptions.CertificateExpired: self.message...
[ "def", "catch_errors", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "f", "(", "self", ",", "request", ...
Catches specific errors in admin actions and shows a friendly error.
[ "Catches", "specific", "errors", "in", "admin", "actions", "and", "shows", "a", "friendly", "error", "." ]
python
train
32
log2timeline/plaso
plaso/parsers/sqlite_plugins/mackeeper_cache.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/sqlite_plugins/mackeeper_cache.py#L100-L131
def _ExtractJQuery(self, jquery_raw): """Extracts values from a JQuery string. Args: jquery_raw (str): JQuery string. Returns: dict[str, str]: extracted values. """ data_part = '' if not jquery_raw: return {} if '[' in jquery_raw: _, _, first_part = jquery_raw.part...
[ "def", "_ExtractJQuery", "(", "self", ",", "jquery_raw", ")", ":", "data_part", "=", "''", "if", "not", "jquery_raw", ":", "return", "{", "}", "if", "'['", "in", "jquery_raw", ":", "_", ",", "_", ",", "first_part", "=", "jquery_raw", ".", "partition", ...
Extracts values from a JQuery string. Args: jquery_raw (str): JQuery string. Returns: dict[str, str]: extracted values.
[ "Extracts", "values", "from", "a", "JQuery", "string", "." ]
python
train
23.9375
bapakode/OmMongo
ommongo/fields/fields.py
https://github.com/bapakode/OmMongo/blob/52b5a5420516dc709f2d2eb065818c7973991ce3/ommongo/fields/fields.py#L444-L450
def wrap(self, value, session=None): ''' Validates that ``value`` is an ObjectId (or hex representation of one), then returns it ''' self.validate_wrap(value) if isinstance(value, bytes) or isinstance(value, basestring): return ObjectId(value) return value
[ "def", "wrap", "(", "self", ",", "value", ",", "session", "=", "None", ")", ":", "self", ".", "validate_wrap", "(", "value", ")", "if", "isinstance", "(", "value", ",", "bytes", ")", "or", "isinstance", "(", "value", ",", "basestring", ")", ":", "ret...
Validates that ``value`` is an ObjectId (or hex representation of one), then returns it
[ "Validates", "that", "value", "is", "an", "ObjectId", "(", "or", "hex", "representation", "of", "one", ")", "then", "returns", "it" ]
python
train
43.714286
project-rig/rig
rig/machine_control/machine_controller.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1252-L1262
def _send_ffe(self, pid, app_id, app_flags, fr): """Send a flood-fill end packet. The cores and regions that the application should be loaded to will have been specified by a stream of flood-fill core select packets (FFCS). """ arg1 = (NNCommands.flood_fill_end << 24) | ...
[ "def", "_send_ffe", "(", "self", ",", "pid", ",", "app_id", ",", "app_flags", ",", "fr", ")", ":", "arg1", "=", "(", "NNCommands", ".", "flood_fill_end", "<<", "24", ")", "|", "pid", "arg2", "=", "(", "app_id", "<<", "24", ")", "|", "(", "app_flags...
Send a flood-fill end packet. The cores and regions that the application should be loaded to will have been specified by a stream of flood-fill core select packets (FFCS).
[ "Send", "a", "flood", "-", "fill", "end", "packet", "." ]
python
train
43.272727
PyCQA/prospector
prospector/run.py
https://github.com/PyCQA/prospector/blob/7cfc6d587049a786f935a722d6851cd3b72d7972/prospector/run.py#L150-L157
def get_parser(): """ This is a helper method to return an argparse parser, to be used with the Sphinx argparse plugin for documentation. """ manager = cfg.build_manager() source = cfg.build_command_line_source(prog='prospector', description=None) return source.build_parser(manager.settings,...
[ "def", "get_parser", "(", ")", ":", "manager", "=", "cfg", ".", "build_manager", "(", ")", "source", "=", "cfg", ".", "build_command_line_source", "(", "prog", "=", "'prospector'", ",", "description", "=", "None", ")", "return", "source", ".", "build_parser"...
This is a helper method to return an argparse parser, to be used with the Sphinx argparse plugin for documentation.
[ "This", "is", "a", "helper", "method", "to", "return", "an", "argparse", "parser", "to", "be", "used", "with", "the", "Sphinx", "argparse", "plugin", "for", "documentation", "." ]
python
train
39.875
unt-libraries/pyuntl
pyuntl/dc_structure.py
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/dc_structure.py#L104-L114
def resolver(self, vocab_data, attribute): """Pull the requested attribute based on the given vocabulary and content. """ term_list = vocab_data.get(self.content_vocab, []) # Loop through the terms from the vocabulary. for term_dict in term_list: # Match the n...
[ "def", "resolver", "(", "self", ",", "vocab_data", ",", "attribute", ")", ":", "term_list", "=", "vocab_data", ".", "get", "(", "self", ".", "content_vocab", ",", "[", "]", ")", "# Loop through the terms from the vocabulary.", "for", "term_dict", "in", "term_lis...
Pull the requested attribute based on the given vocabulary and content.
[ "Pull", "the", "requested", "attribute", "based", "on", "the", "given", "vocabulary", "and", "content", "." ]
python
train
41.727273
deepmipt/DeepPavlov
deeppavlov/core/layers/tf_attention_mechanisms.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/core/layers/tf_attention_mechanisms.py#L278-L337
def cs_bahdanau_attention(key, context, hidden_size, depth, projected_align=False): """ It is a implementation of the Bahdanau et al. attention mechanism. Based on the papers: https://arxiv.org/abs/1409.0473 "Neural Machine Translation by Jointly Learning to Align and Translate" https://andre-martin...
[ "def", "cs_bahdanau_attention", "(", "key", ",", "context", ",", "hidden_size", ",", "depth", ",", "projected_align", "=", "False", ")", ":", "if", "hidden_size", "%", "2", "!=", "0", ":", "raise", "ValueError", "(", "\"hidden size must be dividable by two\"", "...
It is a implementation of the Bahdanau et al. attention mechanism. Based on the papers: https://arxiv.org/abs/1409.0473 "Neural Machine Translation by Jointly Learning to Align and Translate" https://andre-martins.github.io/docs/emnlp2017_final.pdf "Learning What's Easy: Fully Differentiable Neural Easy...
[ "It", "is", "a", "implementation", "of", "the", "Bahdanau", "et", "al", ".", "attention", "mechanism", ".", "Based", "on", "the", "papers", ":", "https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1409", ".", "0473", "Neural", "Machine", "Transl...
python
test
53.733333
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/intelc.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/intelc.py#L120-L135
def get_version_from_list(v, vlist): """See if we can match v (string) in vlist (list of strings) Linux has to match in a fuzzy way.""" if is_windows: # Simple case, just find it in the list if v in vlist: return v else: return None else: # Fuzzy match: normalize version ...
[ "def", "get_version_from_list", "(", "v", ",", "vlist", ")", ":", "if", "is_windows", ":", "# Simple case, just find it in the list", "if", "v", "in", "vlist", ":", "return", "v", "else", ":", "return", "None", "else", ":", "# Fuzzy match: normalize version number f...
See if we can match v (string) in vlist (list of strings) Linux has to match in a fuzzy way.
[ "See", "if", "we", "can", "match", "v", "(", "string", ")", "in", "vlist", "(", "list", "of", "strings", ")", "Linux", "has", "to", "match", "in", "a", "fuzzy", "way", "." ]
python
train
35.625
Scoppio/RagnarokEngine3
RagnarokEngine3/RE3.py
https://github.com/Scoppio/RagnarokEngine3/blob/4395d419ccd64fe9327c41f200b72ee0176ad896/RagnarokEngine3/RE3.py#L665-L675
def to_vec3(self): """Convert this vector4 instance into a vector3 instance.""" vec3 = Vector3() vec3.x = self.x vec3.y = self.y vec3.z = self.z if self.w != 0: vec3 /= self.w return vec3
[ "def", "to_vec3", "(", "self", ")", ":", "vec3", "=", "Vector3", "(", ")", "vec3", ".", "x", "=", "self", ".", "x", "vec3", ".", "y", "=", "self", ".", "y", "vec3", ".", "z", "=", "self", ".", "z", "if", "self", ".", "w", "!=", "0", ":", ...
Convert this vector4 instance into a vector3 instance.
[ "Convert", "this", "vector4", "instance", "into", "a", "vector3", "instance", "." ]
python
train
22.454545
ibm-watson-iot/iot-python
tmp/src/things/things.py
https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/tmp/src/things/things.py#L1617-L1649
def updateMappingsOnDeviceType(self, thingTypeId, logicalInterfaceId, mappingsObject, notificationStrategy = "never"): """ Add mappings for a thing type. Parameters: - thingTypeId (string) - the thing type - logicalInterfaceId (string) - the id of the application interfac...
[ "def", "updateMappingsOnDeviceType", "(", "self", ",", "thingTypeId", ",", "logicalInterfaceId", ",", "mappingsObject", ",", "notificationStrategy", "=", "\"never\"", ")", ":", "req", "=", "ApiClient", ".", "oneThingTypeMappingUrl", "%", "(", "self", ".", "host", ...
Add mappings for a thing type. Parameters: - thingTypeId (string) - the thing type - logicalInterfaceId (string) - the id of the application interface these mappings are for - notificationStrategy (string) - the notification strategy to use for these mappings - ma...
[ "Add", "mappings", "for", "a", "thing", "type", ".", "Parameters", ":", "-", "thingTypeId", "(", "string", ")", "-", "the", "thing", "type", "-", "logicalInterfaceId", "(", "string", ")", "-", "the", "id", "of", "the", "application", "interface", "these", ...
python
test
50.818182
agoragames/haigha
haigha/connection.py
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L393-L458
def read_frames(self): ''' Read frames from the transport and process them. Some transports may choose to do this in the background, in several threads, and so on. ''' # It's possible in a concurrent environment that our transport handle # has gone away, so handle that cl...
[ "def", "read_frames", "(", "self", ")", ":", "# It's possible in a concurrent environment that our transport handle", "# has gone away, so handle that cleanly.", "# TODO: Consider moving this block into Translator base class. In many", "# ways it belongs there. One of the problems though is that t...
Read frames from the transport and process them. Some transports may choose to do this in the background, in several threads, and so on.
[ "Read", "frames", "from", "the", "transport", "and", "process", "them", ".", "Some", "transports", "may", "choose", "to", "do", "this", "in", "the", "background", "in", "several", "threads", "and", "so", "on", "." ]
python
train
49.348485
ergoithz/unicategories
unicategories/tools.py
https://github.com/ergoithz/unicategories/blob/70ade9fa3662ac3fc62fb2648a29a360a4d82025/unicategories/tools.py#L133-L161
def generate(categorize=unicodedata.category, group_class=RangeGroup): ''' Generate a dict of RangeGroups for each unicode character category, including general ones. :param categorize: category function, defaults to unicodedata.category. :type categorize: callable :param group_class: class for...
[ "def", "generate", "(", "categorize", "=", "unicodedata", ".", "category", ",", "group_class", "=", "RangeGroup", ")", ":", "categories", "=", "collections", ".", "defaultdict", "(", "list", ")", "last_category", "=", "None", "last_range", "=", "None", "for", ...
Generate a dict of RangeGroups for each unicode character category, including general ones. :param categorize: category function, defaults to unicodedata.category. :type categorize: callable :param group_class: class for range groups, defaults to RangeGroup :type group_class: type :returns: dic...
[ "Generate", "a", "dict", "of", "RangeGroups", "for", "each", "unicode", "character", "category", "including", "general", "ones", "." ]
python
train
37.586207
mikedh/trimesh
trimesh/ray/ray_triangle.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/ray/ray_triangle.py#L28-L64
def intersects_id(self, ray_origins, ray_directions, return_locations=False, multiple_hits=True, **kwargs): """ Find the intersections between the current mesh and a list of rays. Param...
[ "def", "intersects_id", "(", "self", ",", "ray_origins", ",", "ray_directions", ",", "return_locations", "=", "False", ",", "multiple_hits", "=", "True", ",", "*", "*", "kwargs", ")", ":", "(", "index_tri", ",", "index_ray", ",", "locations", ")", "=", "ra...
Find the intersections between the current mesh and a list of rays. Parameters ------------ ray_origins: (m,3) float, ray origin points ray_directions: (m,3) float, ray direction vectors multiple_hits: bool, consider multiple hits of each ray or not return_loca...
[ "Find", "the", "intersections", "between", "the", "current", "mesh", "and", "a", "list", "of", "rays", "." ]
python
train
44.675676
yyuu/botornado
boto/rds/__init__.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/rds/__init__.py#L815-L831
def create_dbsnapshot(self, snapshot_id, dbinstance_id): """ Create a new DB snapshot. :type snapshot_id: string :param snapshot_id: The identifier for the DBSnapshot :type dbinstance_id: string :param dbinstance_id: The source identifier for the RDS instance from ...
[ "def", "create_dbsnapshot", "(", "self", ",", "snapshot_id", ",", "dbinstance_id", ")", ":", "params", "=", "{", "'DBSnapshotIdentifier'", ":", "snapshot_id", ",", "'DBInstanceIdentifier'", ":", "dbinstance_id", "}", "return", "self", ".", "get_object", "(", "'Cre...
Create a new DB snapshot. :type snapshot_id: string :param snapshot_id: The identifier for the DBSnapshot :type dbinstance_id: string :param dbinstance_id: The source identifier for the RDS instance from which the snapshot is created. :rtype: :cla...
[ "Create", "a", "new", "DB", "snapshot", "." ]
python
train
38.764706
Unidata/siphon
siphon/catalog.py
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L622-L650
def subset(self, service=None): """Subset the dataset. Open the remote dataset and get a client for talking to ``service``. Parameters ---------- service : str, optional The name of the service for subsetting the dataset. Defaults to 'NetcdfSubset' or 'N...
[ "def", "subset", "(", "self", ",", "service", "=", "None", ")", ":", "if", "service", "is", "None", ":", "for", "serviceName", "in", "self", ".", "ncssServiceNames", ":", "if", "serviceName", "in", "self", ".", "access_urls", ":", "service", "=", "servic...
Subset the dataset. Open the remote dataset and get a client for talking to ``service``. Parameters ---------- service : str, optional The name of the service for subsetting the dataset. Defaults to 'NetcdfSubset' or 'NetcdfServer', in that order, depending on t...
[ "Subset", "the", "dataset", "." ]
python
train
36
alvations/pywsd
pywsd/semeval.py
https://github.com/alvations/pywsd/blob/4c12394c8adbcfed71dd912bdbef2e36370821bf/pywsd/semeval.py#L112-L147
def sentences(self): """ Returns the instances by sentences, and yields a list of tokens, similar to the pywsd.semcor.sentences. >>> coarse_wsd = SemEval2007_Coarse_WSD() >>> for sent in coarse_wsd.sentences(): >>> for token in sent: >>> print token ...
[ "def", "sentences", "(", "self", ")", ":", "for", "sentid", ",", "ys", "in", "enumerate", "(", "self", ".", "yield_sentences", "(", ")", ")", ":", "sent", ",", "context_sent", ",", "context_doc", ",", "inst2ans", ",", "textid", "=", "ys", "instances", ...
Returns the instances by sentences, and yields a list of tokens, similar to the pywsd.semcor.sentences. >>> coarse_wsd = SemEval2007_Coarse_WSD() >>> for sent in coarse_wsd.sentences(): >>> for token in sent: >>> print token >>> break >>> ...
[ "Returns", "the", "instances", "by", "sentences", "and", "yields", "a", "list", "of", "tokens", "similar", "to", "the", "pywsd", ".", "semcor", ".", "sentences", "." ]
python
train
43.805556
mdsol/rwslib
rwslib/builders/metadata.py
https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/builders/metadata.py#L229-L234
def build(self, builder): """Build XML by appending to builder""" builder.start("Symbol", {}) for child in self.translations: child.build(builder) builder.end("Symbol")
[ "def", "build", "(", "self", ",", "builder", ")", ":", "builder", ".", "start", "(", "\"Symbol\"", ",", "{", "}", ")", "for", "child", "in", "self", ".", "translations", ":", "child", ".", "build", "(", "builder", ")", "builder", ".", "end", "(", "...
Build XML by appending to builder
[ "Build", "XML", "by", "appending", "to", "builder" ]
python
train
34.5
aouyar/PyMunin
pymunin/plugins/nginxstats.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pymunin/plugins/nginxstats.py#L188-L197
def autoconf(self): """Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise. """ nginxInfo = NginxInfo(self._host, self._port, self._user, self._password, ...
[ "def", "autoconf", "(", "self", ")", ":", "nginxInfo", "=", "NginxInfo", "(", "self", ".", "_host", ",", "self", ".", "_port", ",", "self", ".", "_user", ",", "self", ".", "_password", ",", "self", ".", "_statuspath", ",", "self", ".", "_ssl", ")", ...
Implements Munin Plugin Auto-Configuration Option. @return: True if plugin can be auto-configured, False otherwise.
[ "Implements", "Munin", "Plugin", "Auto", "-", "Configuration", "Option", "." ]
python
train
39.8
MattBroach/DjangoRestMultipleModels
drf_multiple_model/pagination.py
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/pagination.py#L13-L31
def paginate_queryset(self, queryset, request, view=None): """ adds `max_count` as a running tally of the largest table size. Used for calculating next/previous links later """ result = super(MultipleModelLimitOffsetPagination, self).paginate_queryset(queryset, request, view) ...
[ "def", "paginate_queryset", "(", "self", ",", "queryset", ",", "request", ",", "view", "=", "None", ")", ":", "result", "=", "super", "(", "MultipleModelLimitOffsetPagination", ",", "self", ")", ".", "paginate_queryset", "(", "queryset", ",", "request", ",", ...
adds `max_count` as a running tally of the largest table size. Used for calculating next/previous links later
[ "adds", "max_count", "as", "a", "running", "tally", "of", "the", "largest", "table", "size", ".", "Used", "for", "calculating", "next", "/", "previous", "links", "later" ]
python
train
32.263158
twilio/twilio-python
twilio/rest/api/v2010/account/message/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/message/__init__.py#L92-L127
def stream(self, to=values.unset, from_=values.unset, date_sent_before=values.unset, date_sent=values.unset, date_sent_after=values.unset, limit=None, page_size=None): """ Streams MessageInstance records from the API as a generator stream. This operation lazily load...
[ "def", "stream", "(", "self", ",", "to", "=", "values", ".", "unset", ",", "from_", "=", "values", ".", "unset", ",", "date_sent_before", "=", "values", ".", "unset", ",", "date_sent", "=", "values", ".", "unset", ",", "date_sent_after", "=", "values", ...
Streams MessageInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode to: Filter by messages sent to th...
[ "Streams", "MessageInstance", "records", "from", "the", "API", "as", "a", "generator", "stream", ".", "This", "operation", "lazily", "loads", "records", "as", "efficiently", "as", "possible", "until", "the", "limit", "is", "reached", ".", "The", "results", "ar...
python
train
50.722222
mardix/Juice
juice/plugins/user/__init__.py
https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/plugins/user/__init__.py#L265-L807
def auth(view, **kwargs): """ This plugin allow user to login to application kwargs: - signin_view - signout_view - template_dir - menu: - name - group_name - ... @plugin(user.login, model=model.User) class MyAccount(Juice...
[ "def", "auth", "(", "view", ",", "*", "*", "kwargs", ")", ":", "endpoint_namespace", "=", "view", ".", "__name__", "+", "\":%s\"", "view_name", "=", "view", ".", "__name__", "UserModel", "=", "kwargs", ".", "pop", "(", "\"model\"", ")", "User", "=", "U...
This plugin allow user to login to application kwargs: - signin_view - signout_view - template_dir - menu: - name - group_name - ... @plugin(user.login, model=model.User) class MyAccount(Juice): pass
[ "This", "plugin", "allow", "user", "to", "login", "to", "application" ]
python
train
41.650092
rsalmaso/django-fluo
fluo/views/decorators.py
https://github.com/rsalmaso/django-fluo/blob/1321c1e7d6a912108f79be02a9e7f2108c57f89f/fluo/views/decorators.py#L34-L51
def ajax_required(func): # taken from djangosnippets.org """ AJAX request required decorator use it in your views: @ajax_required def my_view(request): .... """ def wrap(request, *args, **kwargs): if not request.is_ajax(): return HttpResponseBadRequest ...
[ "def", "ajax_required", "(", "func", ")", ":", "# taken from djangosnippets.org", "def", "wrap", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "request", ".", "is_ajax", "(", ")", ":", "return", "HttpResponseBadRequest", ...
AJAX request required decorator use it in your views: @ajax_required def my_view(request): ....
[ "AJAX", "request", "required", "decorator", "use", "it", "in", "your", "views", ":" ]
python
train
23.611111
basho/riak-python-client
riak/client/transport.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/transport.py#L190-L210
def _choose_pool(self, protocol=None): """ Selects a connection pool according to the default protocol and the passed one. :param protocol: the protocol to use :type protocol: string :rtype: Pool """ if not protocol: protocol = self.protocol ...
[ "def", "_choose_pool", "(", "self", ",", "protocol", "=", "None", ")", ":", "if", "not", "protocol", ":", "protocol", "=", "self", ".", "protocol", "if", "protocol", "==", "'http'", ":", "pool", "=", "self", ".", "_http_pool", "elif", "protocol", "==", ...
Selects a connection pool according to the default protocol and the passed one. :param protocol: the protocol to use :type protocol: string :rtype: Pool
[ "Selects", "a", "connection", "pool", "according", "to", "the", "default", "protocol", "and", "the", "passed", "one", "." ]
python
train
33.47619
jackmaney/python-stdlib-list
stdlib_list/base.py
https://github.com/jackmaney/python-stdlib-list/blob/f343504405435fcc4bc49bc064f70006813f6845/stdlib_list/base.py#L25-L47
def stdlib_list(version=None): """ Given a ``version``, return a ``list`` of names of the Python Standard Libraries for that version. These names are obtained from the Sphinx inventory file (used in :py:mod:`sphinx.ext.intersphinx`). :param str|None version: The version (as a string) whose list of ...
[ "def", "stdlib_list", "(", "version", "=", "None", ")", ":", "version", "=", "get_canonical_version", "(", "version", ")", "if", "version", "is", "not", "None", "else", "'.'", ".", "join", "(", "str", "(", "x", ")", "for", "x", "in", "sys", ".", "ver...
Given a ``version``, return a ``list`` of names of the Python Standard Libraries for that version. These names are obtained from the Sphinx inventory file (used in :py:mod:`sphinx.ext.intersphinx`). :param str|None version: The version (as a string) whose list of libraries you want (one of ``"2.6"``, `...
[ "Given", "a", "version", "return", "a", "list", "of", "names", "of", "the", "Python", "Standard", "Libraries", "for", "that", "version", ".", "These", "names", "are", "obtained", "from", "the", "Sphinx", "inventory", "file", "(", "used", "in", ":", "py", ...
python
train
39.130435
rwl/pylon
pylon/util.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L262-L269
def factorial(n): """ Returns the factorial of n. """ f = 1 while (n > 0): f = f * n n = n - 1 return f
[ "def", "factorial", "(", "n", ")", ":", "f", "=", "1", "while", "(", "n", ">", "0", ")", ":", "f", "=", "f", "*", "n", "n", "=", "n", "-", "1", "return", "f" ]
Returns the factorial of n.
[ "Returns", "the", "factorial", "of", "n", "." ]
python
train
16.5
Erotemic/utool
utool/util_decor.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L601-L651
def memoize(func): """ simple memoization decorator References: https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize Args: func (function): live python function Returns: func: CommandLine: python -m utool.util_decor memoize Example: >>> # ...
[ "def", "memoize", "(", "func", ")", ":", "cache", "=", "func", ".", "_util_decor_memoize_cache", "=", "{", "}", "# @functools.wraps(func)", "def", "memoizer", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "key", "=", "str", "(", "args", ")", "+"...
simple memoization decorator References: https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize Args: func (function): live python function Returns: func: CommandLine: python -m utool.util_decor memoize Example: >>> # ENABLE_DOCTEST >>> from...
[ "simple", "memoization", "decorator" ]
python
train
30.784314
pandas-dev/pandas
pandas/core/frame.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L725-L778
def iteritems(self): r""" Iterator over (column name, Series) pairs. Iterates over the DataFrame columns, returning a tuple with the column name and the content as a Series. Yields ------ label : object The column names for the DataFrame being iterat...
[ "def", "iteritems", "(", "self", ")", ":", "if", "self", ".", "columns", ".", "is_unique", "and", "hasattr", "(", "self", ",", "'_item_cache'", ")", ":", "for", "k", "in", "self", ".", "columns", ":", "yield", "k", ",", "self", ".", "_get_item_cache", ...
r""" Iterator over (column name, Series) pairs. Iterates over the DataFrame columns, returning a tuple with the column name and the content as a Series. Yields ------ label : object The column names for the DataFrame being iterated over. content : Se...
[ "r", "Iterator", "over", "(", "column", "name", "Series", ")", "pairs", "." ]
python
train
31.777778