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
pydata/xarray
xarray/core/dataset.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataset.py#L3085-L3108
def bfill(self, dim, limit=None): '''Fill NaN values by propogating values backward *Requires bottleneck.* Parameters ---------- dim : str Specifies the dimension along which to propagate values when filling. limit : int, default None ...
[ "def", "bfill", "(", "self", ",", "dim", ",", "limit", "=", "None", ")", ":", "from", ".", "missing", "import", "bfill", ",", "_apply_over_vars_with_dim", "new", "=", "_apply_over_vars_with_dim", "(", "bfill", ",", "self", ",", "dim", "=", "dim", ",", "l...
Fill NaN values by propogating values backward *Requires bottleneck.* Parameters ---------- dim : str Specifies the dimension along which to propagate values when filling. limit : int, default None The maximum number of consecutive NaN values...
[ "Fill", "NaN", "values", "by", "propogating", "values", "backward" ]
python
train
32.291667
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/zmat_functions.py
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/zmat_functions.py#L75-L98
def apply_grad_cartesian_tensor(grad_X, zmat_dist): """Apply the gradient for transformation to cartesian space onto zmat_dist. Args: grad_X (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array. The mathematical details of the index layout is explained in :meth:`~chemcoord.Cartesi...
[ "def", "apply_grad_cartesian_tensor", "(", "grad_X", ",", "zmat_dist", ")", ":", "columns", "=", "[", "'bond'", ",", "'angle'", ",", "'dihedral'", "]", "C_dist", "=", "zmat_dist", ".", "loc", "[", ":", ",", "columns", "]", ".", "values", ".", "T", "try",...
Apply the gradient for transformation to cartesian space onto zmat_dist. Args: grad_X (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array. The mathematical details of the index layout is explained in :meth:`~chemcoord.Cartesian.get_grad_zmat()`. zmat_dist (:class:`~chemcoord....
[ "Apply", "the", "gradient", "for", "transformation", "to", "cartesian", "space", "onto", "zmat_dist", "." ]
python
train
43.666667
uogbuji/amara3-xml
pylib/uxml/html5.py
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/html5.py#L46-L51
def insertBefore(self, node, refNode): """Insert node as a child of the current node, before refNode in the list of child nodes. Raises ValueError if refNode is not a child of the current node""" offset = self.xml_children.index(refNode) self.xml_insert(node, offset)
[ "def", "insertBefore", "(", "self", ",", "node", ",", "refNode", ")", ":", "offset", "=", "self", ".", "xml_children", ".", "index", "(", "refNode", ")", "self", ".", "xml_insert", "(", "node", ",", "offset", ")" ]
Insert node as a child of the current node, before refNode in the list of child nodes. Raises ValueError if refNode is not a child of the current node
[ "Insert", "node", "as", "a", "child", "of", "the", "current", "node", "before", "refNode", "in", "the", "list", "of", "child", "nodes", ".", "Raises", "ValueError", "if", "refNode", "is", "not", "a", "child", "of", "the", "current", "node" ]
python
test
50.333333
bitesofcode/projexui
projexui/widgets/xganttwidget/xganttwidgetitem.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttwidgetitem.py#L380-L388
def setDateTimeStart(self, dtime): """ Sets the starting date time for this gantt chart. :param dtime | <QDateTime> """ self._dateStart = dtime.date() self._timeStart = dtime.time() self._allDay = False
[ "def", "setDateTimeStart", "(", "self", ",", "dtime", ")", ":", "self", ".", "_dateStart", "=", "dtime", ".", "date", "(", ")", "self", ".", "_timeStart", "=", "dtime", ".", "time", "(", ")", "self", ".", "_allDay", "=", "False" ]
Sets the starting date time for this gantt chart. :param dtime | <QDateTime>
[ "Sets", "the", "starting", "date", "time", "for", "this", "gantt", "chart", ".", ":", "param", "dtime", "|", "<QDateTime", ">" ]
python
train
30.222222
siznax/wptools
wptools/core.py
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L246-L253
def info(self, action=None): """ returns cached request info for given action, or list of cached actions """ if action in self.cache: return self.cache[action]['info'] return self.cache.keys() or None
[ "def", "info", "(", "self", ",", "action", "=", "None", ")", ":", "if", "action", "in", "self", ".", "cache", ":", "return", "self", ".", "cache", "[", "action", "]", "[", "'info'", "]", "return", "self", ".", "cache", ".", "keys", "(", ")", "or"...
returns cached request info for given action, or list of cached actions
[ "returns", "cached", "request", "info", "for", "given", "action", "or", "list", "of", "cached", "actions" ]
python
train
31.625
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/export_data.py
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/export_data.py#L31-L42
def write_matrix_to_tsv(net, filename=None, df=None): ''' This will export the matrix in net.dat or a dataframe (optional df in arguments) as a tsv file. Row/column categories will be saved as tuples in tsv, which can be read back into the network object. ''' import pandas as pd if df is None: df = n...
[ "def", "write_matrix_to_tsv", "(", "net", ",", "filename", "=", "None", ",", "df", "=", "None", ")", ":", "import", "pandas", "as", "pd", "if", "df", "is", "None", ":", "df", "=", "net", ".", "dat_to_df", "(", ")", "return", "df", "[", "'mat'", "]"...
This will export the matrix in net.dat or a dataframe (optional df in arguments) as a tsv file. Row/column categories will be saved as tuples in tsv, which can be read back into the network object.
[ "This", "will", "export", "the", "matrix", "in", "net", ".", "dat", "or", "a", "dataframe", "(", "optional", "df", "in", "arguments", ")", "as", "a", "tsv", "file", ".", "Row", "/", "column", "categories", "will", "be", "saved", "as", "tuples", "in", ...
python
train
30.833333
networks-lab/metaknowledge
metaknowledge/mkCollection.py
https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L665-L747
def timeSeries(self, tag = None, outputFile = None, giveYears = True, greatestFirst = True, limitTo = False, pandasMode = True): """Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by the year the occurred in, multiple year occurrences will create multiple entries. A list c...
[ "def", "timeSeries", "(", "self", ",", "tag", "=", "None", ",", "outputFile", "=", "None", ",", "giveYears", "=", "True", ",", "greatestFirst", "=", "True", ",", "limitTo", "=", "False", ",", "pandasMode", "=", "True", ")", ":", "seriesDict", "=", "{",...
Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by the year the occurred in, multiple year occurrences will create multiple entries. A list can also be returned with the the counts or years added or it can be written to a file. If no _tag_ is given the `Records` in the co...
[ "Creates", "an", "pandas", "dict", "of", "the", "ordered", "list", "of", "all", "the", "values", "of", "_tag_", "with", "and", "ranked", "by", "the", "year", "the", "occurred", "in", "multiple", "year", "occurrences", "will", "create", "multiple", "entries",...
python
train
40.409639
PyCQA/astroid
astroid/decorators.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/decorators.py#L76-L109
def path_wrapper(func): """return the given infer function wrapped to handle the path Used to stop inference if the node has already been looked at for a given `InferenceContext` to prevent infinite recursion """ @functools.wraps(func) def wrapped(node, context=None, _func=func, **kwargs): ...
[ "def", "path_wrapper", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapped", "(", "node", ",", "context", "=", "None", ",", "_func", "=", "func", ",", "*", "*", "kwargs", ")", ":", "\"\"\"wrapper function handling con...
return the given infer function wrapped to handle the path Used to stop inference if the node has already been looked at for a given `InferenceContext` to prevent infinite recursion
[ "return", "the", "given", "infer", "function", "wrapped", "to", "handle", "the", "path" ]
python
train
32.176471
jaysonsantos/python-binary-memcached
bmemcached/client/replicating.py
https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/replicating.py#L141-L161
def set_multi(self, mappings, time=0, compress_level=-1): """ Set multiple keys with it's values on server. :param mappings: A dict with keys/values :type mappings: dict :param time: Time in seconds that your key will expire. :type time: int :param compress_level...
[ "def", "set_multi", "(", "self", ",", "mappings", ",", "time", "=", "0", ",", "compress_level", "=", "-", "1", ")", ":", "returns", "=", "[", "]", "if", "mappings", ":", "for", "server", "in", "self", ".", "servers", ":", "returns", ".", "append", ...
Set multiple keys with it's values on server. :param mappings: A dict with keys/values :type mappings: dict :param time: Time in seconds that your key will expire. :type time: int :param compress_level: How much to compress. 0 = no compression, 1 = fastest, 9 = slowe...
[ "Set", "multiple", "keys", "with", "it", "s", "values", "on", "server", "." ]
python
train
37.047619
tomekwojcik/ForgeryPy
forgery_py/forgery/basic.py
https://github.com/tomekwojcik/ForgeryPy/blob/0d1864e86b4362d8d6c215c618e8451d39a7a567/forgery_py/forgery/basic.py#L42-L76
def text(length=None, at_least=10, at_most=15, lowercase=True, uppercase=True, digits=True, spaces=True, punctuation=False): """ Random text. If `length` is present the text will be exactly this chars long. Else the text will be something between `at_least` and `at_most` chars long. """ ...
[ "def", "text", "(", "length", "=", "None", ",", "at_least", "=", "10", ",", "at_most", "=", "15", ",", "lowercase", "=", "True", ",", "uppercase", "=", "True", ",", "digits", "=", "True", ",", "spaces", "=", "True", ",", "punctuation", "=", "False", ...
Random text. If `length` is present the text will be exactly this chars long. Else the text will be something between `at_least` and `at_most` chars long.
[ "Random", "text", "." ]
python
test
23.571429
jayvdb/flake8-putty
flake8_putty/extension.py
https://github.com/jayvdb/flake8-putty/blob/854b2c6daef409974c2f5e9c5acaf0a069b0ff23/flake8_putty/extension.py#L27-L41
def get_reporter_state(): """Get pep8 reporter state from stack.""" # Stack # 1. get_reporter_state (i.e. this function) # 2. putty_ignore_code # 3. QueueReport.error or pep8.StandardReport.error for flake8 -j 1 # 4. pep8.Checker.check_ast or check_physical or check_logical # locals conta...
[ "def", "get_reporter_state", "(", ")", ":", "# Stack", "# 1. get_reporter_state (i.e. this function)", "# 2. putty_ignore_code", "# 3. QueueReport.error or pep8.StandardReport.error for flake8 -j 1", "# 4. pep8.Checker.check_ast or check_physical or check_logical", "# locals contains `tree` (...
Get pep8 reporter state from stack.
[ "Get", "pep8", "reporter", "state", "from", "stack", "." ]
python
train
40.866667
nnseva/django-access
access/managers.py
https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/managers.py#L172-L176
def visible(self, request): ''' Checks the both, check_visible and apply_visible, against the owned model and it's instance set ''' return self.apply_visible(self.get_queryset(), request) if self.check_visible(self.model, request) is not False else self.get_queryset().none()
[ "def", "visible", "(", "self", ",", "request", ")", ":", "return", "self", ".", "apply_visible", "(", "self", ".", "get_queryset", "(", ")", ",", "request", ")", "if", "self", ".", "check_visible", "(", "self", ".", "model", ",", "request", ")", "is", ...
Checks the both, check_visible and apply_visible, against the owned model and it's instance set
[ "Checks", "the", "both", "check_visible", "and", "apply_visible", "against", "the", "owned", "model", "and", "it", "s", "instance", "set" ]
python
train
60.6
pyannote/pyannote-metrics
pyannote/metrics/base.py
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/base.py#L76-L88
def reset(self): """Reset accumulated components and metric values""" if self.parallel: from pyannote.metrics import manager_ self.accumulated_ = manager_.dict() self.results_ = manager_.list() self.uris_ = manager_.dict() else: self.ac...
[ "def", "reset", "(", "self", ")", ":", "if", "self", ".", "parallel", ":", "from", "pyannote", ".", "metrics", "import", "manager_", "self", ".", "accumulated_", "=", "manager_", ".", "dict", "(", ")", "self", ".", "results_", "=", "manager_", ".", "li...
Reset accumulated components and metric values
[ "Reset", "accumulated", "components", "and", "metric", "values" ]
python
train
36.538462
wonambi-python/wonambi
wonambi/widgets/channels.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/channels.py#L177-L194
def add_channels_to_list(self, l, add_ref=False): """Create list of channels (one for those to plot, one for ref). Parameters ---------- l : instance of QListWidget one of the two lists (chan_to_plot or ref_chan) """ l.clear() l.setSelectionMode(QAbs...
[ "def", "add_channels_to_list", "(", "self", ",", "l", ",", "add_ref", "=", "False", ")", ":", "l", ".", "clear", "(", ")", "l", ".", "setSelectionMode", "(", "QAbstractItemView", ".", "ExtendedSelection", ")", "for", "chan", "in", "self", ".", "chan_name",...
Create list of channels (one for those to plot, one for ref). Parameters ---------- l : instance of QListWidget one of the two lists (chan_to_plot or ref_chan)
[ "Create", "list", "of", "channels", "(", "one", "for", "those", "to", "plot", "one", "for", "ref", ")", "." ]
python
train
30.222222
materialsproject/pymatgen
pymatgen/io/vasp/outputs.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/vasp/outputs.py#L2814-L2835
def linear_add(self, other, scale_factor=1.0): """ Method to do a linear sum of volumetric objects. Used by + and - operators as well. Returns a VolumetricData object containing the linear sum. Args: other (VolumetricData): Another VolumetricData object s...
[ "def", "linear_add", "(", "self", ",", "other", ",", "scale_factor", "=", "1.0", ")", ":", "if", "self", ".", "structure", "!=", "other", ".", "structure", ":", "raise", "ValueError", "(", "\"Adding or subtraction operations can only be \"", "\"performed for volumet...
Method to do a linear sum of volumetric objects. Used by + and - operators as well. Returns a VolumetricData object containing the linear sum. Args: other (VolumetricData): Another VolumetricData object scale_factor (float): Factor to scale the other data by. Re...
[ "Method", "to", "do", "a", "linear", "sum", "of", "volumetric", "objects", ".", "Used", "by", "+", "and", "-", "operators", "as", "well", ".", "Returns", "a", "VolumetricData", "object", "containing", "the", "linear", "sum", "." ]
python
train
41.954545
SwissDataScienceCenter/renku-python
renku/cli/dataset.py
https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/cli/dataset.py#L222-L238
def add(client, name, urls, link, relative_to, target, force): """Add data to a dataset.""" try: with client.with_dataset(name=name) as dataset: target = target if target else None with progressbar(urls, label='Adding data to dataset') as bar: for url in bar: ...
[ "def", "add", "(", "client", ",", "name", ",", "urls", ",", "link", ",", "relative_to", ",", "target", ",", "force", ")", ":", "try", ":", "with", "client", ".", "with_dataset", "(", "name", "=", "name", ")", "as", "dataset", ":", "target", "=", "t...
Add data to a dataset.
[ "Add", "data", "to", "a", "dataset", "." ]
python
train
40.294118
dantezhu/haven
haven/gevent_impl.py
https://github.com/dantezhu/haven/blob/7bf7edab07fa2ade7644a548d6ab9d89cf3d259d/haven/gevent_impl.py#L20-L25
def _read_message(self): """ 必须启动新的greenlet,否则会有内存泄漏 """ job = gevent.spawn(super(GConnection, self)._read_message) job.join()
[ "def", "_read_message", "(", "self", ")", ":", "job", "=", "gevent", ".", "spawn", "(", "super", "(", "GConnection", ",", "self", ")", ".", "_read_message", ")", "job", ".", "join", "(", ")" ]
必须启动新的greenlet,否则会有内存泄漏
[ "必须启动新的greenlet,否则会有内存泄漏" ]
python
train
26.833333
pantsbuild/pants
src/python/pants/java/nailgun_protocol.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/java/nailgun_protocol.py#L254-L289
def iter_chunks(cls, sock, return_bytes=False, timeout_object=None): """Generates chunks from a connected socket until an Exit chunk is sent or a timeout occurs. :param sock: the socket to read from. :param bool return_bytes: If False, decode the payload into a utf-8 string. :param cls.TimeoutProvider ...
[ "def", "iter_chunks", "(", "cls", ",", "sock", ",", "return_bytes", "=", "False", ",", "timeout_object", "=", "None", ")", ":", "assert", "(", "timeout_object", "is", "None", "or", "isinstance", "(", "timeout_object", ",", "cls", ".", "TimeoutProvider", ")",...
Generates chunks from a connected socket until an Exit chunk is sent or a timeout occurs. :param sock: the socket to read from. :param bool return_bytes: If False, decode the payload into a utf-8 string. :param cls.TimeoutProvider timeout_object: If provided, will be checked every iteration for a ...
[ "Generates", "chunks", "from", "a", "connected", "socket", "until", "an", "Exit", "chunk", "is", "sent", "or", "a", "timeout", "occurs", "." ]
python
train
45.416667
ArchiveTeam/wpull
wpull/protocol/ftp/stream.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/protocol/ftp/stream.py#L92-L100
def reconnect(self): '''Connected the stream if needed. Coroutine. ''' if self._connection.closed(): self._connection.reset() yield from self._connection.connect()
[ "def", "reconnect", "(", "self", ")", ":", "if", "self", ".", "_connection", ".", "closed", "(", ")", ":", "self", ".", "_connection", ".", "reset", "(", ")", "yield", "from", "self", ".", "_connection", ".", "connect", "(", ")" ]
Connected the stream if needed. Coroutine.
[ "Connected", "the", "stream", "if", "needed", "." ]
python
train
23.666667
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L33-L47
def makeSequenceRelative(absVSequence): ''' Puts every value in a list on a continuum between 0 and 1 Also returns the min and max values (to reverse the process) ''' if len(absVSequence) < 2 or len(set(absVSequence)) == 1: raise RelativizeSequenceException(absVSequence) minV = min(ab...
[ "def", "makeSequenceRelative", "(", "absVSequence", ")", ":", "if", "len", "(", "absVSequence", ")", "<", "2", "or", "len", "(", "set", "(", "absVSequence", ")", ")", "==", "1", ":", "raise", "RelativizeSequenceException", "(", "absVSequence", ")", "minV", ...
Puts every value in a list on a continuum between 0 and 1 Also returns the min and max values (to reverse the process)
[ "Puts", "every", "value", "in", "a", "list", "on", "a", "continuum", "between", "0", "and", "1" ]
python
train
30.6
ioos/thredds_crawler
thredds_crawler/crawl.py
https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L35-L45
def request_xml(url, auth=None): ''' Returns an etree.XMLRoot object loaded from the url :param str url: URL for the resource to load as an XML ''' try: r = requests.get(url, auth=auth, verify=False) return r.text.encode('utf-8') except BaseException: logger.error("Skippi...
[ "def", "request_xml", "(", "url", ",", "auth", "=", "None", ")", ":", "try", ":", "r", "=", "requests", ".", "get", "(", "url", ",", "auth", "=", "auth", ",", "verify", "=", "False", ")", "return", "r", ".", "text", ".", "encode", "(", "'utf-8'",...
Returns an etree.XMLRoot object loaded from the url :param str url: URL for the resource to load as an XML
[ "Returns", "an", "etree", ".", "XMLRoot", "object", "loaded", "from", "the", "url", ":", "param", "str", "url", ":", "URL", "for", "the", "resource", "to", "load", "as", "an", "XML" ]
python
train
32.545455
watson-developer-cloud/python-sdk
ibm_watson/compare_comply_v1.py
https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/compare_comply_v1.py#L4905-L4910
def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'label') and self.label is not None: _dict['label'] = self.label._to_dict() return _dict
[ "def", "_to_dict", "(", "self", ")", ":", "_dict", "=", "{", "}", "if", "hasattr", "(", "self", ",", "'label'", ")", "and", "self", ".", "label", "is", "not", "None", ":", "_dict", "[", "'label'", "]", "=", "self", ".", "label", ".", "_to_dict", ...
Return a json dictionary representing this model.
[ "Return", "a", "json", "dictionary", "representing", "this", "model", "." ]
python
train
38.5
openstack/networking-cisco
networking_cisco/apps/saf/server/dfa_server.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/dfa_server.py#L538-L604
def project_update_event(self, proj_info): """Process project update event. There could be change in project name. DCNM doesn't allow change in project (a.k.a tenant). This event may be received for the DCI update. If the change is for DCI, update the DCI portion of the project name ...
[ "def", "project_update_event", "(", "self", ",", "proj_info", ")", ":", "LOG", ".", "debug", "(", "\"Processing project_update_event %(proj)s.\"", ",", "{", "'proj'", ":", "proj_info", "}", ")", "proj_id", "=", "proj_info", ".", "get", "(", "'resource_info'", ")...
Process project update event. There could be change in project name. DCNM doesn't allow change in project (a.k.a tenant). This event may be received for the DCI update. If the change is for DCI, update the DCI portion of the project name and send the update event to the DCNM.
[ "Process", "project", "update", "event", "." ]
python
train
50.029851
d0c-s4vage/pfp
pfp/fields.py
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L612-L619
def _pfp__restore_snapshot(self, recurse=True): """Restore the snapshotted value without triggering any events """ super(Struct, self)._pfp__restore_snapshot(recurse=recurse) if recurse: for child in self._pfp__children: child._pfp__restore_snapshot(recurse=r...
[ "def", "_pfp__restore_snapshot", "(", "self", ",", "recurse", "=", "True", ")", ":", "super", "(", "Struct", ",", "self", ")", ".", "_pfp__restore_snapshot", "(", "recurse", "=", "recurse", ")", "if", "recurse", ":", "for", "child", "in", "self", ".", "_...
Restore the snapshotted value without triggering any events
[ "Restore", "the", "snapshotted", "value", "without", "triggering", "any", "events" ]
python
train
40
jtwhite79/pyemu
pyemu/sc.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/sc.py#L39-L59
def pandas(self): """get a pandas dataframe of prior and posterior for all predictions Returns: pandas.DataFrame : pandas.DataFrame a dataframe with prior and posterior uncertainty estimates for all forecasts (predictions) """ names,prior,post...
[ "def", "pandas", "(", "self", ")", ":", "names", ",", "prior", ",", "posterior", "=", "[", "]", ",", "[", "]", ",", "[", "]", "for", "iname", ",", "name", "in", "enumerate", "(", "self", ".", "posterior_parameter", ".", "row_names", ")", ":", "name...
get a pandas dataframe of prior and posterior for all predictions Returns: pandas.DataFrame : pandas.DataFrame a dataframe with prior and posterior uncertainty estimates for all forecasts (predictions)
[ "get", "a", "pandas", "dataframe", "of", "prior", "and", "posterior", "for", "all", "predictions" ]
python
train
46.666667
MartijnBraam/pyElectronics
electronics/gateways/buspirate.py
https://github.com/MartijnBraam/pyElectronics/blob/a20878c9fa190135f1e478e9ea0b54ca43ff308e/electronics/gateways/buspirate.py#L103-L134
def set_peripheral(self, power=None, pullup=None, aux=None, chip_select=None): """ Set the peripheral config at runtime. If a parameter is None then the config will not be changed. :param power: Set to True to enable the power supply or False to disable :param pullup: Set to True to ena...
[ "def", "set_peripheral", "(", "self", ",", "power", "=", "None", ",", "pullup", "=", "None", ",", "aux", "=", "None", ",", "chip_select", "=", "None", ")", ":", "if", "power", "is", "not", "None", ":", "self", ".", "power", "=", "power", "if", "pul...
Set the peripheral config at runtime. If a parameter is None then the config will not be changed. :param power: Set to True to enable the power supply or False to disable :param pullup: Set to True to enable the internal pull-up resistors. False to disable :param aux: Set the AUX pin ou...
[ "Set", "the", "peripheral", "config", "at", "runtime", ".", "If", "a", "parameter", "is", "None", "then", "the", "config", "will", "not", "be", "changed", "." ]
python
train
38.78125
DataBiosphere/dsub
dsub/lib/param_util.py
https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L390-L399
def build_logging_param(logging_uri, util_class=OutputFileParamUtil): """Convenience function simplifies construction of the logging uri.""" if not logging_uri: return job_model.LoggingParam(None, None) recursive = not logging_uri.endswith('.log') oututil = util_class('') _, uri, provider = oututil.parse_...
[ "def", "build_logging_param", "(", "logging_uri", ",", "util_class", "=", "OutputFileParamUtil", ")", ":", "if", "not", "logging_uri", ":", "return", "job_model", ".", "LoggingParam", "(", "None", ",", "None", ")", "recursive", "=", "not", "logging_uri", ".", ...
Convenience function simplifies construction of the logging uri.
[ "Convenience", "function", "simplifies", "construction", "of", "the", "logging", "uri", "." ]
python
valid
48.2
gregreen/dustmaps
dustmaps/json_serializers.py
https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/json_serializers.py#L228-L241
def serialize_quantity(o): """ Serializes an :obj:`astropy.units.Quantity`, for JSONification. Args: o (:obj:`astropy.units.Quantity`): :obj:`Quantity` to be serialized. Returns: A dictionary that can be passed to :obj:`json.dumps`. """ return dict( _type='astropy.units...
[ "def", "serialize_quantity", "(", "o", ")", ":", "return", "dict", "(", "_type", "=", "'astropy.units.Quantity'", ",", "value", "=", "o", ".", "value", ",", "unit", "=", "o", ".", "unit", ".", "to_string", "(", ")", ")" ]
Serializes an :obj:`astropy.units.Quantity`, for JSONification. Args: o (:obj:`astropy.units.Quantity`): :obj:`Quantity` to be serialized. Returns: A dictionary that can be passed to :obj:`json.dumps`.
[ "Serializes", "an", ":", "obj", ":", "astropy", ".", "units", ".", "Quantity", "for", "JSONification", "." ]
python
train
26.714286
emirozer/bowshock
bowshock/temperature_anomalies.py
https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/temperature_anomalies.py#L12-L61
def address(address=None, begin=None, end=None): ''' HTTP REQUEST GET https://api.nasa.gov/planetary/earth/temperature/address QUERY PARAMETERS Parameter Type Default Description text string n/a Address string begin int 1880 beginning year for date range, inclusive end int 2014 end ye...
[ "def", "address", "(", "address", "=", "None", ",", "begin", "=", "None", ",", "end", "=", "None", ")", ":", "base_url", "=", "\"https://api.nasa.gov/planetary/earth/temperature/address?\"", "if", "not", "address", ":", "raise", "ValueError", "(", "\"address is mi...
HTTP REQUEST GET https://api.nasa.gov/planetary/earth/temperature/address QUERY PARAMETERS Parameter Type Default Description text string n/a Address string begin int 1880 beginning year for date range, inclusive end int 2014 end year for date range, inclusive api_key string DEMO_KEY api....
[ "HTTP", "REQUEST" ]
python
train
30.74
optimizely/python-sdk
optimizely/helpers/condition.py
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L328-L342
def _audience_condition_deserializer(obj_dict): """ Deserializer defining how dict objects need to be decoded for audience conditions. Args: obj_dict: Dict representing one audience condition. Returns: List consisting of condition key with corresponding value, type and match. """ return [ obj_di...
[ "def", "_audience_condition_deserializer", "(", "obj_dict", ")", ":", "return", "[", "obj_dict", ".", "get", "(", "'name'", ")", ",", "obj_dict", ".", "get", "(", "'value'", ")", ",", "obj_dict", ".", "get", "(", "'type'", ")", ",", "obj_dict", ".", "get...
Deserializer defining how dict objects need to be decoded for audience conditions. Args: obj_dict: Dict representing one audience condition. Returns: List consisting of condition key with corresponding value, type and match.
[ "Deserializer", "defining", "how", "dict", "objects", "need", "to", "be", "decoded", "for", "audience", "conditions", "." ]
python
train
26.933333
saltstack/salt
salt/cloud/clouds/openstack.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L389-L418
def list_nodes_full(conn=None, call=None): ''' Return a list of VMs with all the information about them CLI Example .. code-block:: bash salt-cloud -f list_nodes_full myopenstack ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_full function mus...
[ "def", "list_nodes_full", "(", "conn", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The list_nodes_full function must be called with -f or --function.'", ")", "if", "conn", "is", "None",...
Return a list of VMs with all the information about them CLI Example .. code-block:: bash salt-cloud -f list_nodes_full myopenstack
[ "Return", "a", "list", "of", "VMs", "with", "all", "the", "information", "about", "them" ]
python
train
32.833333
HPENetworking/PYHPEIMC
build/lib/pyhpeimc/plat/device.py
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/device.py#L283-L323
def get_dev_interface(devid, auth, url): """ Function takes devid as input to RESTFUL call to HP IMC platform and returns list of device interfaces :param devid: requires devid as the only input :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base u...
[ "def", "get_dev_interface", "(", "devid", ",", "auth", ",", "url", ")", ":", "get_dev_interface_url", "=", "\"/imcrs/plat/res/device/\"", "+", "str", "(", "devid", ")", "+", "\"/interface?start=0&size=1000&desc=false&total=false\"", "f_url", "=", "url", "+", "get_dev_...
Function takes devid as input to RESTFUL call to HP IMC platform and returns list of device interfaces :param devid: requires devid as the only input :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeim...
[ "Function", "takes", "devid", "as", "input", "to", "RESTFUL", "call", "to", "HP", "IMC", "platform", "and", "returns", "list", "of", "device", "interfaces" ]
python
train
33.317073
PyCQA/astroid
astroid/scoped_nodes.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/scoped_nodes.py#L1374-L1414
def extra_decorators(self): """The extra decorators that this function can have. Additional decorators are considered when they are used as assignments, as in ``method = staticmethod(method)``. The property will return all the callables that are used for decoration. :ty...
[ "def", "extra_decorators", "(", "self", ")", ":", "frame", "=", "self", ".", "parent", ".", "frame", "(", ")", "if", "not", "isinstance", "(", "frame", ",", "ClassDef", ")", ":", "return", "[", "]", "decorators", "=", "[", "]", "for", "assign", "in",...
The extra decorators that this function can have. Additional decorators are considered when they are used as assignments, as in ``method = staticmethod(method)``. The property will return all the callables that are used for decoration. :type: list(NodeNG)
[ "The", "extra", "decorators", "that", "this", "function", "can", "have", "." ]
python
train
39.341463
twisted/vertex
vertex/q2q.py
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L907-L927
def _listen(self, protocols, From, description): """ Implementation of L{Listen}. """ # The peer is coming from a client-side representation of the user # described by 'From', and talking *to* a server-side representation of # the user described by 'From'. self.ve...
[ "def", "_listen", "(", "self", ",", "protocols", ",", "From", ",", "description", ")", ":", "# The peer is coming from a client-side representation of the user", "# described by 'From', and talking *to* a server-side representation of", "# the user described by 'From'.", "self", ".",...
Implementation of L{Listen}.
[ "Implementation", "of", "L", "{", "Listen", "}", "." ]
python
train
43.857143
coinbase/coinbase-python
coinbase/wallet/client.py
https://github.com/coinbase/coinbase-python/blob/497c28158f529e8c7d0228521b4386a890baf088/coinbase/wallet/client.py#L435-L438
def get_buy(self, account_id, buy_id, **params): """https://developers.coinbase.com/api/v2#show-a-buy""" response = self._get('v2', 'accounts', account_id, 'buys', buy_id, params=params) return self._make_api_object(response, Buy)
[ "def", "get_buy", "(", "self", ",", "account_id", ",", "buy_id", ",", "*", "*", "params", ")", ":", "response", "=", "self", ".", "_get", "(", "'v2'", ",", "'accounts'", ",", "account_id", ",", "'buys'", ",", "buy_id", ",", "params", "=", "params", "...
https://developers.coinbase.com/api/v2#show-a-buy
[ "https", ":", "//", "developers", ".", "coinbase", ".", "com", "/", "api", "/", "v2#show", "-", "a", "-", "buy" ]
python
train
62.75
kgori/treeCl
treeCl/clustering.py
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/clustering.py#L329-L371
def cluster(self, n, embed_dim=None, algo=mds.CLASSICAL, method=methods.KMEANS): """ Cluster the embedded coordinates using multidimensional scaling Parameters ---------- n: int The number of clusters to return embed_dim ...
[ "def", "cluster", "(", "self", ",", "n", ",", "embed_dim", "=", "None", ",", "algo", "=", "mds", ".", "CLASSICAL", ",", "method", "=", "methods", ".", "KMEANS", ")", ":", "if", "n", "==", "1", ":", "return", "Partition", "(", "[", "1", "]", "*", ...
Cluster the embedded coordinates using multidimensional scaling Parameters ---------- n: int The number of clusters to return embed_dim int The dimensionality of the underlying coordinates ...
[ "Cluster", "the", "embedded", "coordinates", "using", "multidimensional", "scaling" ]
python
train
37.093023
fermiPy/fermipy
fermipy/scripts/make_ltcube.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/make_ltcube.py#L26-L102
def main(): usage = "usage: %(prog)s [options] " description = "Run gtselect and gtmktime on one or more FT1 files. " "Note that gtmktime will be skipped if no FT2 file is provided." parser = argparse.ArgumentParser(usage=usage, description=description) add_lsf_args(parser) parser.add_argumen...
[ "def", "main", "(", ")", ":", "usage", "=", "\"usage: %(prog)s [options] \"", "description", "=", "\"Run gtselect and gtmktime on one or more FT1 files. \"", "parser", "=", "argparse", ".", "ArgumentParser", "(", "usage", "=", "usage", ",", "description", "=", "descrip...
Note that gtmktime will be skipped if no FT2 file is provided.
[ "Note", "that", "gtmktime", "will", "be", "skipped", "if", "no", "FT2", "file", "is", "provided", "." ]
python
train
38.87013
samastur/pyimagediet
pyimagediet/process.py
https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/process.py#L58-L101
def parse_configuration(config): ''' Parse and fix configuration: - processed file should end up being same as input - pipelines should contain CLI commands to run - add missing sections :param config: raw configuration object :type config: dict :return: configuration ready ...
[ "def", "parse_configuration", "(", "config", ")", ":", "new_config", "=", "copy", ".", "deepcopy", "(", "config", ")", "required_parts", "=", "(", "'commands'", ",", "'parameters'", ",", "'pipelines'", ")", "for", "part", "in", "required_parts", ":", "new_conf...
Parse and fix configuration: - processed file should end up being same as input - pipelines should contain CLI commands to run - add missing sections :param config: raw configuration object :type config: dict :return: configuration ready for `diet()` :rtype: dict
[ "Parse", "and", "fix", "configuration", ":", "-", "processed", "file", "should", "end", "up", "being", "same", "as", "input", "-", "pipelines", "should", "contain", "CLI", "commands", "to", "run", "-", "add", "missing", "sections" ]
python
train
37.818182
noahbenson/neuropythy
neuropythy/optimize/core.py
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/optimize/core.py#L611-L619
def sum(x, weights=None): ''' sum(x) yields either a potential-sum object if x is a potential function or the sum of x if x is not. If x is not a potential-field then it must be a vector. sum(x, weights=w) uses the given weights to produce a weighted sum. ''' x = to_potential(x) if is_cons...
[ "def", "sum", "(", "x", ",", "weights", "=", "None", ")", ":", "x", "=", "to_potential", "(", "x", ")", "if", "is_const_potential", "(", "x", ")", ":", "return", "PotentialConstant", "(", "np", ".", "sum", "(", "x", ".", "c", ")", ")", "else", ":...
sum(x) yields either a potential-sum object if x is a potential function or the sum of x if x is not. If x is not a potential-field then it must be a vector. sum(x, weights=w) uses the given weights to produce a weighted sum.
[ "sum", "(", "x", ")", "yields", "either", "a", "potential", "-", "sum", "object", "if", "x", "is", "a", "potential", "function", "or", "the", "sum", "of", "x", "if", "x", "is", "not", ".", "If", "x", "is", "not", "a", "potential", "-", "field", "...
python
train
48.333333
aws/aws-xray-sdk-python
aws_xray_sdk/ext/botocore/patch.py
https://github.com/aws/aws-xray-sdk-python/blob/707358cd3a516d51f2ebf71cf34f00e8d906a667/aws_xray_sdk/ext/botocore/patch.py#L8-L27
def patch(): """ Patch botocore client so it generates subsegments when calling AWS services. """ if hasattr(botocore.client, '_xray_enabled'): return setattr(botocore.client, '_xray_enabled', True) wrapt.wrap_function_wrapper( 'botocore.client', 'BaseClient._make_ap...
[ "def", "patch", "(", ")", ":", "if", "hasattr", "(", "botocore", ".", "client", ",", "'_xray_enabled'", ")", ":", "return", "setattr", "(", "botocore", ".", "client", ",", "'_xray_enabled'", ",", "True", ")", "wrapt", ".", "wrap_function_wrapper", "(", "'b...
Patch botocore client so it generates subsegments when calling AWS services.
[ "Patch", "botocore", "client", "so", "it", "generates", "subsegments", "when", "calling", "AWS", "services", "." ]
python
train
23.7
olitheolix/qtmacs
qtmacs/extensions/qtmacstextedit_macros.py
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L483-L492
def enableHook(self, msgObj): """ Enable yank-pop. This method is connected to the 'yank-qtmacs_text_edit' hook (triggered by the yank macro) to ensure that yank-pop only gets activated afterwards. """ self.killListIdx = len(qte_global.kill_list) - 2 self...
[ "def", "enableHook", "(", "self", ",", "msgObj", ")", ":", "self", ".", "killListIdx", "=", "len", "(", "qte_global", ".", "kill_list", ")", "-", "2", "self", ".", "qteMain", ".", "qtesigKeyseqComplete", ".", "connect", "(", "self", ".", "disableHook", "...
Enable yank-pop. This method is connected to the 'yank-qtmacs_text_edit' hook (triggered by the yank macro) to ensure that yank-pop only gets activated afterwards.
[ "Enable", "yank", "-", "pop", "." ]
python
train
36.6
robertpeteuil/aws-shortcuts
awss/core.py
https://github.com/robertpeteuil/aws-shortcuts/blob/cf453ca996978a4d88015d1cf6125bce8ca4873b/awss/core.py#L319-L324
def process_tags(inst_tags): """Create dict of instance tags as only name:value pairs.""" tag_dict = {} for k in range(len(inst_tags)): tag_dict[inst_tags[k]['Key']] = inst_tags[k]['Value'] return tag_dict
[ "def", "process_tags", "(", "inst_tags", ")", ":", "tag_dict", "=", "{", "}", "for", "k", "in", "range", "(", "len", "(", "inst_tags", ")", ")", ":", "tag_dict", "[", "inst_tags", "[", "k", "]", "[", "'Key'", "]", "]", "=", "inst_tags", "[", "k", ...
Create dict of instance tags as only name:value pairs.
[ "Create", "dict", "of", "instance", "tags", "as", "only", "name", ":", "value", "pairs", "." ]
python
train
37.333333
ethpm/py-ethpm
ethpm/utils/deployments.py
https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/deployments.py#L57-L66
def normalize_linked_references( data: List[Dict[str, Any]] ) -> Generator[Tuple[int, str, str], None, None]: """ Return a tuple of information representing all insertions of a linked reference. (offset, type, value) """ for deployment in data: for offset in deployment["offsets"]: ...
[ "def", "normalize_linked_references", "(", "data", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ")", "->", "Generator", "[", "Tuple", "[", "int", ",", "str", ",", "str", "]", ",", "None", ",", "None", "]", ":", "for", "deployment", "...
Return a tuple of information representing all insertions of a linked reference. (offset, type, value)
[ "Return", "a", "tuple", "of", "information", "representing", "all", "insertions", "of", "a", "linked", "reference", ".", "(", "offset", "type", "value", ")" ]
python
train
37
pybel/pybel
src/pybel/struct/filters/node_filters.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/filters/node_filters.py#L71-L76
def filter_nodes(graph: BELGraph, node_predicates: NodePredicates) -> Iterable[BaseEntity]: """Apply a set of predicates to the nodes iterator of a BEL graph.""" concatenated_predicate = concatenate_node_predicates(node_predicates=node_predicates) for node in graph: if concatenated_predicate(graph, ...
[ "def", "filter_nodes", "(", "graph", ":", "BELGraph", ",", "node_predicates", ":", "NodePredicates", ")", "->", "Iterable", "[", "BaseEntity", "]", ":", "concatenated_predicate", "=", "concatenate_node_predicates", "(", "node_predicates", "=", "node_predicates", ")", ...
Apply a set of predicates to the nodes iterator of a BEL graph.
[ "Apply", "a", "set", "of", "predicates", "to", "the", "nodes", "iterator", "of", "a", "BEL", "graph", "." ]
python
train
57.333333
sdispater/eloquent
eloquent/database_manager.py
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/database_manager.py#L65-L77
def purge(self, name=None): """ Disconnect from the given database and remove from local cache :param name: The name of the connection :type name: str :rtype: None """ self.disconnect(name) if name in self._connections: del self._connections...
[ "def", "purge", "(", "self", ",", "name", "=", "None", ")", ":", "self", ".", "disconnect", "(", "name", ")", "if", "name", "in", "self", ".", "_connections", ":", "del", "self", ".", "_connections", "[", "name", "]" ]
Disconnect from the given database and remove from local cache :param name: The name of the connection :type name: str :rtype: None
[ "Disconnect", "from", "the", "given", "database", "and", "remove", "from", "local", "cache" ]
python
train
24.153846
cs01/gdbgui
gdbgui/backend.py
https://github.com/cs01/gdbgui/blob/5367f87554f8f7c671d1f4596c133bf1303154f0/gdbgui/backend.py#L283-L292
def dbprint(*args): """print only if app.debug is truthy""" if app and app.debug: if USING_WINDOWS: print("DEBUG: " + " ".join(args)) else: CYELLOW2 = "\33[93m" NORMAL = "\033[0m" print(CYELLOW2 + "DEBUG: " + " ".join(args) + NORMAL)
[ "def", "dbprint", "(", "*", "args", ")", ":", "if", "app", "and", "app", ".", "debug", ":", "if", "USING_WINDOWS", ":", "print", "(", "\"DEBUG: \"", "+", "\" \"", ".", "join", "(", "args", ")", ")", "else", ":", "CYELLOW2", "=", "\"\\33[93m\"", "NORM...
print only if app.debug is truthy
[ "print", "only", "if", "app", ".", "debug", "is", "truthy" ]
python
train
29.7
kcolford/txt2boil
txt2boil/core/extractor.py
https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/extractor.py#L138-L147
def code(self, text): """Return the code instead of the comments. """ comm = self.nextValidComment(text) while comm: text = text[:comm.start()] + text[comm.end():] comm = self.nextValidComment(text, comm.end(0)) return text
[ "def", "code", "(", "self", ",", "text", ")", ":", "comm", "=", "self", ".", "nextValidComment", "(", "text", ")", "while", "comm", ":", "text", "=", "text", "[", ":", "comm", ".", "start", "(", ")", "]", "+", "text", "[", "comm", ".", "end", "...
Return the code instead of the comments.
[ "Return", "the", "code", "instead", "of", "the", "comments", "." ]
python
train
28
mgoral/subconvert
src/subconvert/parsing/Formats.py
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Formats.py#L130-L142
def createSubtitle(self, fps, section): """Returns a correct 'Subtitle' object from a text given in 'section'. If 'section' cannot be parsed, None is returned. By default 'section' is checked against 'subPattern' regular expression.""" matched = self._pattern.search(section) if m...
[ "def", "createSubtitle", "(", "self", ",", "fps", ",", "section", ")", ":", "matched", "=", "self", ".", "_pattern", ".", "search", "(", "section", ")", "if", "matched", "is", "not", "None", ":", "matchedDict", "=", "matched", ".", "groupdict", "(", ")...
Returns a correct 'Subtitle' object from a text given in 'section'. If 'section' cannot be parsed, None is returned. By default 'section' is checked against 'subPattern' regular expression.
[ "Returns", "a", "correct", "Subtitle", "object", "from", "a", "text", "given", "in", "section", ".", "If", "section", "cannot", "be", "parsed", "None", "is", "returned", ".", "By", "default", "section", "is", "checked", "against", "subPattern", "regular", "e...
python
train
48
zfrenchee/Axial
axial/axial.py
https://github.com/zfrenchee/Axial/blob/69672b4ce46518e0348dedb74a907cc73f71c0fe/axial/axial.py#L430-L489
def graph(networkx_graph, title='Axial Graph Visualization', scripts_mode="CDN", data_mode="directory", output_dir=".", filename="graph.html", version=this_version): """ Arguments: networkx_graph (networkx.Graph): any instance of networkx.Graph title (str): The title of the plot (to be...
[ "def", "graph", "(", "networkx_graph", ",", "title", "=", "'Axial Graph Visualization'", ",", "scripts_mode", "=", "\"CDN\"", ",", "data_mode", "=", "\"directory\"", ",", "output_dir", "=", "\".\"", ",", "filename", "=", "\"graph.html\"", ",", "version", "=", "t...
Arguments: networkx_graph (networkx.Graph): any instance of networkx.Graph title (str): The title of the plot (to be embedded in the html). scripts_mode (str): Choose from [`"CDN"`, `"directory"`, `"inline"`]: - `"CDN"` compiles a single HTML page with links to scripts hosted on a C...
[ "Arguments", ":", "networkx_graph", "(", "networkx", ".", "Graph", ")", ":", "any", "instance", "of", "networkx", ".", "Graph", "title", "(", "str", ")", ":", "The", "title", "of", "the", "plot", "(", "to", "be", "embedded", "in", "the", "html", ")", ...
python
valid
39.516667
ungarj/mapchete
mapchete/formats/default/gtiff.py
https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/formats/default/gtiff.py#L104-L120
def read(self, output_tile, **kwargs): """ Read existing process output. Parameters ---------- output_tile : ``BufferedTile`` must be member of output ``TilePyramid`` Returns ------- NumPy array """ try: return rea...
[ "def", "read", "(", "self", ",", "output_tile", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "read_raster_no_crs", "(", "self", ".", "get_path", "(", "output_tile", ")", ")", "except", "FileNotFoundError", ":", "return", "self", ".", "empty", ...
Read existing process output. Parameters ---------- output_tile : ``BufferedTile`` must be member of output ``TilePyramid`` Returns ------- NumPy array
[ "Read", "existing", "process", "output", "." ]
python
valid
24.941176
pycontribs/pyrax
pyrax/object_storage.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/object_storage.py#L1206-L1213
def set_cdn_log_retention(self, container, enabled): """ Enables or disables whether CDN access logs for the specified container are collected and stored on Cloud Files. """ headers = {"X-Log-Retention": "%s" % enabled} self.api.cdn_request("/%s" % utils.get_name(containe...
[ "def", "set_cdn_log_retention", "(", "self", ",", "container", ",", "enabled", ")", ":", "headers", "=", "{", "\"X-Log-Retention\"", ":", "\"%s\"", "%", "enabled", "}", "self", ".", "api", ".", "cdn_request", "(", "\"/%s\"", "%", "utils", ".", "get_name", ...
Enables or disables whether CDN access logs for the specified container are collected and stored on Cloud Files.
[ "Enables", "or", "disables", "whether", "CDN", "access", "logs", "for", "the", "specified", "container", "are", "collected", "and", "stored", "on", "Cloud", "Files", "." ]
python
train
45.375
dmort27/panphon
panphon/sonority.py
https://github.com/dmort27/panphon/blob/17eaa482e3edb211f3a8138137d76e4b9246d201/panphon/sonority.py#L50-L73
def sonority_from_fts(self, seg): """Given a segment as features, returns the sonority on a scale of 1 to 9. Args: seg (list): collection of (value, feature) pairs representing a segment (vowel or consonant) Returns: int: sonority of `s...
[ "def", "sonority_from_fts", "(", "self", ",", "seg", ")", ":", "def", "match", "(", "m", ")", ":", "return", "self", ".", "fm", ".", "match", "(", "fts", "(", "m", ")", ",", "seg", ")", "minusHi", "=", "BoolTree", "(", "match", "(", "'-hi'", ")",...
Given a segment as features, returns the sonority on a scale of 1 to 9. Args: seg (list): collection of (value, feature) pairs representing a segment (vowel or consonant) Returns: int: sonority of `seg` between 1 and 9
[ "Given", "a", "segment", "as", "features", "returns", "the", "sonority", "on", "a", "scale", "of", "1", "to", "9", "." ]
python
train
36.333333
RI-imaging/qpsphere
qpsphere/edgefit.py
https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/edgefit.py#L227-L354
def contour_canny(image, radius, mult_coarse=.40, mult_fine=.1, clip_rmin=.9, clip_rmax=1.1, maxiter=20, verbose=True): """Heuristic Canny edge detection for circular objects Two Canny-based edge detections with different filter sizes are performed to find the outmost co...
[ "def", "contour_canny", "(", "image", ",", "radius", ",", "mult_coarse", "=", ".40", ",", "mult_fine", "=", ".1", ",", "clip_rmin", "=", ".9", ",", "clip_rmax", "=", "1.1", ",", "maxiter", "=", "20", ",", "verbose", "=", "True", ")", ":", "image", "=...
Heuristic Canny edge detection for circular objects Two Canny-based edge detections with different filter sizes are performed to find the outmost contour of an object in a phase image while keeping artifacts at a minimum. Parameters ---------- image: 2d ndarray Image containing an appr...
[ "Heuristic", "Canny", "edge", "detection", "for", "circular", "objects" ]
python
train
40.53125
benoitkugler/abstractDataLibrary
pyDLib/Core/security.py
https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/security.py#L1-L11
def protege_data(datas_str, sens): """ Used to crypt/decrypt data before saving locally. Override if securit is needed. bytes -> str when decrypting str -> bytes when crypting :param datas_str: When crypting, str. when decrypting bytes :param sens: True to crypt, False to decrypt """ ...
[ "def", "protege_data", "(", "datas_str", ",", "sens", ")", ":", "return", "bytes", "(", "datas_str", ",", "encoding", "=", "\"utf8\"", ")", "if", "sens", "else", "str", "(", "datas_str", ",", "encoding", "=", "\"utf8\"", ")" ]
Used to crypt/decrypt data before saving locally. Override if securit is needed. bytes -> str when decrypting str -> bytes when crypting :param datas_str: When crypting, str. when decrypting bytes :param sens: True to crypt, False to decrypt
[ "Used", "to", "crypt", "/", "decrypt", "data", "before", "saving", "locally", ".", "Override", "if", "securit", "is", "needed", ".", "bytes", "-", ">", "str", "when", "decrypting", "str", "-", ">", "bytes", "when", "crypting" ]
python
train
36.090909
h2oai/h2o-3
h2o-py/h2o/two_dim_table.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/two_dim_table.py#L45-L62
def make(keyvals): """ Create new H2OTwoDimTable object from list of (key,value) tuples which are a pre-cursor to JSON dict. :param keyvals: list of (key, value) tuples :return: new H2OTwoDimTable object """ kwargs = {} for key, value in keyvals: if k...
[ "def", "make", "(", "keyvals", ")", ":", "kwargs", "=", "{", "}", "for", "key", ",", "value", "in", "keyvals", ":", "if", "key", "==", "\"columns\"", ":", "kwargs", "[", "\"col_formats\"", "]", "=", "[", "c", "[", "\"format\"", "]", "for", "c", "in...
Create new H2OTwoDimTable object from list of (key,value) tuples which are a pre-cursor to JSON dict. :param keyvals: list of (key, value) tuples :return: new H2OTwoDimTable object
[ "Create", "new", "H2OTwoDimTable", "object", "from", "list", "of", "(", "key", "value", ")", "tuples", "which", "are", "a", "pre", "-", "cursor", "to", "JSON", "dict", "." ]
python
test
44.833333
googlefonts/fontmake
Lib/fontmake/font_project.py
https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L943-L981
def run_from_ufos(self, ufos, output=(), **kwargs): """Run toolchain from UFO sources. Args: ufos: List of UFO sources, as either paths or opened objects. output: List of output formats to generate. kwargs: Arguments passed along to save_otfs. """ if...
[ "def", "run_from_ufos", "(", "self", ",", "ufos", ",", "output", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "if", "set", "(", "output", ")", "==", "{", "\"ufo\"", "}", ":", "return", "# the `ufos` parameter can be a list of UFO objects", "# or it can ...
Run toolchain from UFO sources. Args: ufos: List of UFO sources, as either paths or opened objects. output: List of output formats to generate. kwargs: Arguments passed along to save_otfs.
[ "Run", "toolchain", "from", "UFO", "sources", "." ]
python
train
35.25641
jupyter-widgets/ipywidgets
ipywidgets/widgets/interaction.py
https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/ipywidgets/widgets/interaction.py#L288-L302
def widgets_from_abbreviations(self, seq): """Given a sequence of (name, abbrev, default) tuples, return a sequence of Widgets.""" result = [] for name, abbrev, default in seq: widget = self.widget_from_abbrev(abbrev, default) if not (isinstance(widget, ValueWidget) or is...
[ "def", "widgets_from_abbreviations", "(", "self", ",", "seq", ")", ":", "result", "=", "[", "]", "for", "name", ",", "abbrev", ",", "default", "in", "seq", ":", "widget", "=", "self", ".", "widget_from_abbrev", "(", "abbrev", ",", "default", ")", "if", ...
Given a sequence of (name, abbrev, default) tuples, return a sequence of Widgets.
[ "Given", "a", "sequence", "of", "(", "name", "abbrev", "default", ")", "tuples", "return", "a", "sequence", "of", "Widgets", "." ]
python
train
48.8
tanghaibao/jcvi
jcvi/assembly/unitig.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/unitig.py#L199-L249
def error(args): """ %prog error version backup_folder Find all errors in ../5-consensus/*.err and pull the error unitigs into backup/ folder. """ p = OptionParser(error.__doc__) opts, args = p.parse_args(args) if len(args) != 2: sys.exit(not p.print_help()) version, backu...
[ "def", "error", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "error", ".", "__doc__", ")", "opts", ",", "args", "=", "p", ".", "parse_args", "(", "args", ")", "if", "len", "(", "args", ")", "!=", "2", ":", "sys", ".", "exit", "(", "not...
%prog error version backup_folder Find all errors in ../5-consensus/*.err and pull the error unitigs into backup/ folder.
[ "%prog", "error", "version", "backup_folder" ]
python
train
25.156863
chaoss/grimoirelab-sortinghat
sortinghat/cmd/unify.py
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/unify.py#L248-L268
def __marshal_matches(matched): """Convert matches to JSON format. :param matched: a list of matched identities :returns json_matches: a list of matches in JSON format """ json_matches = [] for m in matched: identities = [i.uuid for i in m] if l...
[ "def", "__marshal_matches", "(", "matched", ")", ":", "json_matches", "=", "[", "]", "for", "m", "in", "matched", ":", "identities", "=", "[", "i", ".", "uuid", "for", "i", "in", "m", "]", "if", "len", "(", "identities", ")", "==", "1", ":", "conti...
Convert matches to JSON format. :param matched: a list of matched identities :returns json_matches: a list of matches in JSON format
[ "Convert", "matches", "to", "JSON", "format", "." ]
python
train
25.571429
eventbrite/eventbrite-sdk-python
eventbrite/access_methods.py
https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/access_methods.py#L863-L871
def post_user_contact_lists_contacts(self, id, contact_list_id, **data): """ POST /users/:id/contact_lists/:contact_list_id/contacts/ Adds a new contact to the contact list. Returns ``{"created": true}``. There is no way to update entries in the list; just delete the old one and ...
[ "def", "post_user_contact_lists_contacts", "(", "self", ",", "id", ",", "contact_list_id", ",", "*", "*", "data", ")", ":", "return", "self", ".", "post", "(", "\"/users/{0}/contact_lists/{0}/contacts/\"", ".", "format", "(", "id", ",", "contact_list_id", ")", "...
POST /users/:id/contact_lists/:contact_list_id/contacts/ Adds a new contact to the contact list. Returns ``{"created": true}``. There is no way to update entries in the list; just delete the old one and add the updated version.
[ "POST", "/", "users", "/", ":", "id", "/", "contact_lists", "/", ":", "contact_list_id", "/", "contacts", "/", "Adds", "a", "new", "contact", "to", "the", "contact", "list", ".", "Returns", "{", "created", ":", "true", "}", ".", "There", "is", "no", ...
python
train
51.333333
kynikos/lib.py.cmenu
cmenu.py
https://github.com/kynikos/lib.py.cmenu/blob/eb1e806f0b674c4deb24730cbd7cf4604150c461/cmenu.py#L237-L245
def help(self, *args): """ Can be overridden (and for example _Menu does). """ if args: self.messages.error( self.messages.command_does_not_accept_arguments) else: print(self.helpfull)
[ "def", "help", "(", "self", ",", "*", "args", ")", ":", "if", "args", ":", "self", ".", "messages", ".", "error", "(", "self", ".", "messages", ".", "command_does_not_accept_arguments", ")", "else", ":", "print", "(", "self", ".", "helpfull", ")" ]
Can be overridden (and for example _Menu does).
[ "Can", "be", "overridden", "(", "and", "for", "example", "_Menu", "does", ")", "." ]
python
train
29.777778
coleifer/peewee
playhouse/pool.py
https://github.com/coleifer/peewee/blob/ea9403b01acb039adb3a2472186d795c796b77a0/playhouse/pool.py#L190-L206
def manual_close(self): """ Close the underlying connection without returning it to the pool. """ if self.is_closed(): return False # Obtain reference to the connection in-use by the calling thread. conn = self.connection() # A connection will only b...
[ "def", "manual_close", "(", "self", ")", ":", "if", "self", ".", "is_closed", "(", ")", ":", "return", "False", "# Obtain reference to the connection in-use by the calling thread.", "conn", "=", "self", ".", "connection", "(", ")", "# A connection will only be re-added ...
Close the underlying connection without returning it to the pool.
[ "Close", "the", "underlying", "connection", "without", "returning", "it", "to", "the", "pool", "." ]
python
train
39.294118
erikrose/more-itertools
more_itertools/more.py
https://github.com/erikrose/more-itertools/blob/6a91b4e25c8e12fcf9fc2b53cf8ee0fba293e6f9/more_itertools/more.py#L1902-L1937
def difference(iterable, func=sub): """By default, compute the first difference of *iterable* using :func:`operator.sub`. >>> iterable = [0, 1, 3, 6, 10] >>> list(difference(iterable)) [0, 1, 2, 3, 4] This is the opposite of :func:`accumulate`'s default behavior: >>> from ...
[ "def", "difference", "(", "iterable", ",", "func", "=", "sub", ")", ":", "a", ",", "b", "=", "tee", "(", "iterable", ")", "try", ":", "item", "=", "next", "(", "b", ")", "except", "StopIteration", ":", "return", "iter", "(", "[", "]", ")", "retur...
By default, compute the first difference of *iterable* using :func:`operator.sub`. >>> iterable = [0, 1, 3, 6, 10] >>> list(difference(iterable)) [0, 1, 2, 3, 4] This is the opposite of :func:`accumulate`'s default behavior: >>> from itertools import accumulate >>> ite...
[ "By", "default", "compute", "the", "first", "difference", "of", "*", "iterable", "*", "using", ":", "func", ":", "operator", ".", "sub", "." ]
python
train
30.277778
specialunderwear/django-easymode
easymode/tree/xml/serializers.py
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/tree/xml/serializers.py#L123-L130
def start_serialization(self): """ Start serialization -- open the XML document and the root element. """ if (self.root): self.xml = XmlPrinter(self.stream, self.options.get("encoding", settings.DEFAULT_CHARSET)) self.xml.startDocument() self.xml.start...
[ "def", "start_serialization", "(", "self", ")", ":", "if", "(", "self", ".", "root", ")", ":", "self", ".", "xml", "=", "XmlPrinter", "(", "self", ".", "stream", ",", "self", ".", "options", ".", "get", "(", "\"encoding\"", ",", "settings", ".", "DEF...
Start serialization -- open the XML document and the root element.
[ "Start", "serialization", "--", "open", "the", "XML", "document", "and", "the", "root", "element", "." ]
python
train
44.875
snare/scruffy
scruffy/file.py
https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L373-L377
def list(self): """ List the contents of the directory. """ return [File(f, parent=self) for f in os.listdir(self.path)]
[ "def", "list", "(", "self", ")", ":", "return", "[", "File", "(", "f", ",", "parent", "=", "self", ")", "for", "f", "in", "os", ".", "listdir", "(", "self", ".", "path", ")", "]" ]
List the contents of the directory.
[ "List", "the", "contents", "of", "the", "directory", "." ]
python
test
29.6
pybluez/pybluez
bluetooth/btcommon.py
https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/bluetooth/btcommon.py#L199-L232
def is_valid_uuid (uuid): """ is_valid_uuid (uuid) -> bool returns True if uuid is a valid 128-bit UUID. valid UUIDs are always strings taking one of the following forms: XXXX XXXXXXXX XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX where each X is a hexadecimal digit (case insensitiv...
[ "def", "is_valid_uuid", "(", "uuid", ")", ":", "try", ":", "if", "len", "(", "uuid", ")", "==", "4", ":", "if", "int", "(", "uuid", ",", "16", ")", "<", "0", ":", "return", "False", "elif", "len", "(", "uuid", ")", "==", "8", ":", "if", "int"...
is_valid_uuid (uuid) -> bool returns True if uuid is a valid 128-bit UUID. valid UUIDs are always strings taking one of the following forms: XXXX XXXXXXXX XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX where each X is a hexadecimal digit (case insensitive)
[ "is_valid_uuid", "(", "uuid", ")", "-", ">", "bool" ]
python
train
29.705882
raiden-network/raiden
raiden/accounts.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L186-L197
def load(cls, path: str, password: str = None) -> 'Account': """Load an account from a keystore file. Args: path: full path to the keyfile password: the password to decrypt the key file or `None` to leave it encrypted """ with open(path) as f: keystor...
[ "def", "load", "(", "cls", ",", "path", ":", "str", ",", "password", ":", "str", "=", "None", ")", "->", "'Account'", ":", "with", "open", "(", "path", ")", "as", "f", ":", "keystore", "=", "json", ".", "load", "(", "f", ")", "if", "not", "chec...
Load an account from a keystore file. Args: path: full path to the keyfile password: the password to decrypt the key file or `None` to leave it encrypted
[ "Load", "an", "account", "from", "a", "keystore", "file", "." ]
python
train
39.916667
ElsevierDev/elsapy
elsapy/elsclient.py
https://github.com/ElsevierDev/elsapy/blob/a8a8b043816441e3ed0c834e792f7089231092da/elsapy/elsclient.py#L91-L119
def exec_request(self, URL): """Sends the actual request; returns response.""" ## Throttle request, if need be interval = time.time() - self.__ts_last_req if (interval < self.__min_req_interval): time.sleep( self.__min_req_interval - interval ) ## Construct ...
[ "def", "exec_request", "(", "self", ",", "URL", ")", ":", "## Throttle request, if need be", "interval", "=", "time", ".", "time", "(", ")", "-", "self", ".", "__ts_last_req", "if", "(", "interval", "<", "self", ".", "__min_req_interval", ")", ":", "time", ...
Sends the actual request; returns response.
[ "Sends", "the", "actual", "request", ";", "returns", "response", "." ]
python
train
41.62069
crytic/slither
slither/printers/summary/human_summary.py
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/printers/summary/human_summary.py#L122-L140
def output(self, _filename): """ _filename is not used Args: _filename(string) """ txt = "Analyze of {}\n".format(self.slither.filename) txt += self.get_detectors_result() for contract in self.slither.contracts_derived: txt += "\nC...
[ "def", "output", "(", "self", ",", "_filename", ")", ":", "txt", "=", "\"Analyze of {}\\n\"", ".", "format", "(", "self", ".", "slither", ".", "filename", ")", "txt", "+=", "self", ".", "get_detectors_result", "(", ")", "for", "contract", "in", "self", "...
_filename is not used Args: _filename(string)
[ "_filename", "is", "not", "used", "Args", ":", "_filename", "(", "string", ")" ]
python
train
36.526316
yahoo/TensorFlowOnSpark
examples/imagenet/inception/slim/ops.py
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L424-L443
def flatten(inputs, scope=None): """Flattens the input while maintaining the batch_size. Assumes that the first dimension represents the batch. Args: inputs: a tensor of size [batch_size, ...]. scope: Optional scope for name_scope. Returns: a flattened tensor with shape [batch_size, k]. Raise...
[ "def", "flatten", "(", "inputs", ",", "scope", "=", "None", ")", ":", "if", "len", "(", "inputs", ".", "get_shape", "(", ")", ")", "<", "2", ":", "raise", "ValueError", "(", "'Inputs must be have a least 2 dimensions'", ")", "dims", "=", "inputs", ".", "...
Flattens the input while maintaining the batch_size. Assumes that the first dimension represents the batch. Args: inputs: a tensor of size [batch_size, ...]. scope: Optional scope for name_scope. Returns: a flattened tensor with shape [batch_size, k]. Raises: ValueError: if inputs.shape is ...
[ "Flattens", "the", "input", "while", "maintaining", "the", "batch_size", "." ]
python
train
29.85
pytroll/satpy
satpy/readers/maia.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/maia.py#L125-L152
def get_dataset(self, key, info, out=None): """Get a dataset from the file.""" logger.debug("Reading %s.", key.name) values = self.file_content[key.name] selected = np.array(self.selected) if key.name in ("Latitude", "Longitude"): values = values / 10000. if ...
[ "def", "get_dataset", "(", "self", ",", "key", ",", "info", ",", "out", "=", "None", ")", ":", "logger", ".", "debug", "(", "\"Reading %s.\"", ",", "key", ".", "name", ")", "values", "=", "self", ".", "file_content", "[", "key", ".", "name", "]", "...
Get a dataset from the file.
[ "Get", "a", "dataset", "from", "the", "file", "." ]
python
train
35
Cologler/fsoopify-python
fsoopify/nodes.py
https://github.com/Cologler/fsoopify-python/blob/83d45f16ae9abdea4fcc829373c32df501487dda/fsoopify/nodes.py#L66-L78
def from_path(path): ''' create from path. return `None` if path is not exists. ''' if os.path.isdir(path): return DirectoryInfo(path) if os.path.isfile(path): return FileInfo(path) return None
[ "def", "from_path", "(", "path", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "return", "DirectoryInfo", "(", "path", ")", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "return", "FileInfo", "(", "path", ...
create from path. return `None` if path is not exists.
[ "create", "from", "path", "." ]
python
train
20.307692
pyros-dev/pyros-common
pyros_interfaces_common/basenode.py
https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/basenode.py#L186-L232
def setup(self, *args, **kwargs): """ Dynamically reset the interface to expose the services / topics / params whose names are passed as args The interface class can be specified with a module to be dynamically imported :param publishers: :param subscribers: :param servic...
[ "def", "setup", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#BWCOMPAT", "if", "kwargs", ".", "get", "(", "'topics'", ")", ":", "if", "kwargs", ".", "get", "(", "'publishers'", ")", ":", "kwargs", "[", "'publishers'", "]", "="...
Dynamically reset the interface to expose the services / topics / params whose names are passed as args The interface class can be specified with a module to be dynamically imported :param publishers: :param subscribers: :param services: :param topics: BW COMPAT ONLY ! :p...
[ "Dynamically", "reset", "the", "interface", "to", "expose", "the", "services", "/", "topics", "/", "params", "whose", "names", "are", "passed", "as", "args", "The", "interface", "class", "can", "be", "specified", "with", "a", "module", "to", "be", "dynamical...
python
train
48.12766
fossasia/AYABInterface
AYABInterface/utils.py
https://github.com/fossasia/AYABInterface/blob/e2065eed8daf17b2936f6ca5e488c9bfb850914e/AYABInterface/utils.py#L27-L49
def next_line(last_line, next_line_8bit): """Compute the next line based on the last line and a 8bit next line. The behaviour of the function is specified in :ref:`reqline`. :param int last_line: the last line that was processed :param int next_line_8bit: the lower 8 bits of the next line :return:...
[ "def", "next_line", "(", "last_line", ",", "next_line_8bit", ")", ":", "# compute the line without the lowest byte", "base_line", "=", "last_line", "-", "(", "last_line", "&", "255", ")", "# compute the three different lines", "line", "=", "base_line", "+", "next_line_8...
Compute the next line based on the last line and a 8bit next line. The behaviour of the function is specified in :ref:`reqline`. :param int last_line: the last line that was processed :param int next_line_8bit: the lower 8 bits of the next line :return: the next line closest to :paramref:`last_line` ...
[ "Compute", "the", "next", "line", "based", "on", "the", "last", "line", "and", "a", "8bit", "next", "line", "." ]
python
train
35.217391
materialsproject/pymatgen
pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py#L486-L495
def anticlockwise_sort_indices(pps): """ Returns the indices that would sort a list of 2D points in anticlockwise order :param pps: List of points to be sorted :return: Indices of the sorted list of points """ angles = np.zeros(len(pps), np.float) for ipp, pp in enumerate(pps): angle...
[ "def", "anticlockwise_sort_indices", "(", "pps", ")", ":", "angles", "=", "np", ".", "zeros", "(", "len", "(", "pps", ")", ",", "np", ".", "float", ")", "for", "ipp", ",", "pp", "in", "enumerate", "(", "pps", ")", ":", "angles", "[", "ipp", "]", ...
Returns the indices that would sort a list of 2D points in anticlockwise order :param pps: List of points to be sorted :return: Indices of the sorted list of points
[ "Returns", "the", "indices", "that", "would", "sort", "a", "list", "of", "2D", "points", "in", "anticlockwise", "order", ":", "param", "pps", ":", "List", "of", "points", "to", "be", "sorted", ":", "return", ":", "Indices", "of", "the", "sorted", "list",...
python
train
37.4
sammchardy/python-binance
binance/depthcache.py
https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L112-L117
def sort_depth(vals, reverse=False): """Sort bids or asks by price """ lst = [[float(price), quantity] for price, quantity in vals.items()] lst = sorted(lst, key=itemgetter(0), reverse=reverse) return lst
[ "def", "sort_depth", "(", "vals", ",", "reverse", "=", "False", ")", ":", "lst", "=", "[", "[", "float", "(", "price", ")", ",", "quantity", "]", "for", "price", ",", "quantity", "in", "vals", ".", "items", "(", ")", "]", "lst", "=", "sorted", "(...
Sort bids or asks by price
[ "Sort", "bids", "or", "asks", "by", "price" ]
python
train
39.833333
CZ-NIC/yangson
yangson/schemadata.py
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L218-L231
def namespace(self, mid: ModuleId) -> YangIdentifier: """Return the namespace corresponding to a module or submodule. Args: mid: Module identifier. Raises: ModuleNotRegistered: If `mid` is not registered in the data model. """ try: mdata = se...
[ "def", "namespace", "(", "self", ",", "mid", ":", "ModuleId", ")", "->", "YangIdentifier", ":", "try", ":", "mdata", "=", "self", ".", "modules", "[", "mid", "]", "except", "KeyError", ":", "raise", "ModuleNotRegistered", "(", "*", "mid", ")", "from", ...
Return the namespace corresponding to a module or submodule. Args: mid: Module identifier. Raises: ModuleNotRegistered: If `mid` is not registered in the data model.
[ "Return", "the", "namespace", "corresponding", "to", "a", "module", "or", "submodule", "." ]
python
train
31.214286
baverman/covador
covador/utils.py
https://github.com/baverman/covador/blob/1597759f7ba77004efef1b27bf804539663b5488/covador/utils.py#L6-L12
def merge_dicts(*dicts, **kwargs): """Merges dicts and kwargs into one dict""" result = {} for d in dicts: result.update(d) result.update(kwargs) return result
[ "def", "merge_dicts", "(", "*", "dicts", ",", "*", "*", "kwargs", ")", ":", "result", "=", "{", "}", "for", "d", "in", "dicts", ":", "result", ".", "update", "(", "d", ")", "result", ".", "update", "(", "kwargs", ")", "return", "result" ]
Merges dicts and kwargs into one dict
[ "Merges", "dicts", "and", "kwargs", "into", "one", "dict" ]
python
train
25.857143
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2951-L2955
def role_delete(self, role_id, **kwargs): "https://developer.zendesk.com/rest_api/docs/chat/roles#delete-role" api_path = "/api/v2/roles/{role_id}" api_path = api_path.format(role_id=role_id) return self.call(api_path, method="DELETE", **kwargs)
[ "def", "role_delete", "(", "self", ",", "role_id", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/roles/{role_id}\"", "api_path", "=", "api_path", ".", "format", "(", "role_id", "=", "role_id", ")", "return", "self", ".", "call", "(", "api_...
https://developer.zendesk.com/rest_api/docs/chat/roles#delete-role
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "chat", "/", "roles#delete", "-", "role" ]
python
train
54.6
YosaiProject/yosai
yosai/core/subject/subject.py
https://github.com/YosaiProject/yosai/blob/7f96aa6b837ceae9bf3d7387cd7e35f5ab032575/yosai/core/subject/subject.py#L277-L294
def is_permitted_collective(self, permission_s, logical_operator=all): """ :param permission_s: a List of authz_abcs.Permission objects :param logical_operator: indicates whether *all* or at least one permission check is true, *any* :type: any OR all ...
[ "def", "is_permitted_collective", "(", "self", ",", "permission_s", ",", "logical_operator", "=", "all", ")", ":", "sm", "=", "self", ".", "security_manager", "if", "self", ".", "authorized", ":", "return", "sm", ".", "is_permitted_collective", "(", "self", "....
:param permission_s: a List of authz_abcs.Permission objects :param logical_operator: indicates whether *all* or at least one permission check is true, *any* :type: any OR all (functions from python stdlib) :returns: a Boolean
[ ":", "param", "permission_s", ":", "a", "List", "of", "authz_abcs", ".", "Permission", "objects" ]
python
train
41.222222
googleapis/google-cloud-python
bigtable/google/cloud/bigtable_admin_v2/gapic/bigtable_table_admin_client.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable_admin_v2/gapic/bigtable_table_admin_client.py#L780-L864
def drop_row_range( self, name, row_key_prefix=None, delete_all_data_from_table=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Permanently drop/delete a row range from...
[ "def", "drop_row_range", "(", "self", ",", "name", ",", "row_key_prefix", "=", "None", ",", "delete_all_data_from_table", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google"...
Permanently drop/delete a row range from a specified table. The request can specify whether to delete all rows in a table, or only those that match a particular prefix. Example: >>> from google.cloud import bigtable_admin_v2 >>> >>> client = bigtable_admin_v2...
[ "Permanently", "drop", "/", "delete", "a", "row", "range", "from", "a", "specified", "table", ".", "The", "request", "can", "specify", "whether", "to", "delete", "all", "rows", "in", "a", "table", "or", "only", "those", "that", "match", "a", "particular", ...
python
train
42.247059
wandb/client
wandb/vendor/prompt_toolkit/key_binding/defaults.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/key_binding/defaults.py#L105-L119
def load_key_bindings_for_prompt(**kw): """ Create a ``Registry`` object with the defaults key bindings for an input prompt. This activates the key bindings for abort/exit (Ctrl-C/Ctrl-D), incremental search and auto suggestions. (Not for full screen applications.) """ kw.setdefault('e...
[ "def", "load_key_bindings_for_prompt", "(", "*", "*", "kw", ")", ":", "kw", ".", "setdefault", "(", "'enable_abort_and_exit_bindings'", ",", "True", ")", "kw", ".", "setdefault", "(", "'enable_search'", ",", "True", ")", "kw", ".", "setdefault", "(", "'enable_...
Create a ``Registry`` object with the defaults key bindings for an input prompt. This activates the key bindings for abort/exit (Ctrl-C/Ctrl-D), incremental search and auto suggestions. (Not for full screen applications.)
[ "Create", "a", "Registry", "object", "with", "the", "defaults", "key", "bindings", "for", "an", "input", "prompt", "." ]
python
train
31.733333
sdispater/eloquent
eloquent/migrations/migrator.py
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/migrations/migrator.py#L197-L219
def _resolve(self, path, migration_file): """ Resolve a migration instance from a file. :param migration_file: The migration file :type migration_file: str :rtype: eloquent.migrations.migration.Migration """ variables = {} name = '_'.join(migration_file...
[ "def", "_resolve", "(", "self", ",", "path", ",", "migration_file", ")", ":", "variables", "=", "{", "}", "name", "=", "'_'", ".", "join", "(", "migration_file", ".", "split", "(", "'_'", ")", "[", "4", ":", "]", ")", "migration_file", "=", "os", "...
Resolve a migration instance from a file. :param migration_file: The migration file :type migration_file: str :rtype: eloquent.migrations.migration.Migration
[ "Resolve", "a", "migration", "instance", "from", "a", "file", "." ]
python
train
29.26087
botstory/botstory
botstory/chat.py
https://github.com/botstory/botstory/blob/9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3/botstory/chat.py#L13-L30
async def ask(self, body, quick_replies=None, options=None, user=None): """ simple ask with predefined quick replies :param body: :param quick_replies: (optional) in form of {'title': <message>, 'payload': <any json>} :param options: :param user: :return:...
[ "async", "def", "ask", "(", "self", ",", "body", ",", "quick_replies", "=", "None", ",", "options", "=", "None", ",", "user", "=", "None", ")", ":", "await", "self", ".", "send_text_message_to_all_interfaces", "(", "recipient", "=", "user", ",", "text", ...
simple ask with predefined quick replies :param body: :param quick_replies: (optional) in form of {'title': <message>, 'payload': <any json>} :param options: :param user: :return:
[ "simple", "ask", "with", "predefined", "quick", "replies" ]
python
train
29.277778
napalm-automation/napalm
napalm/base/helpers.py
https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/base/helpers.py#L128-L145
def cisco_conf_parse_objects(cfg_section, config): """ Use CiscoConfParse to find and return a section of Cisco IOS config. Similar to "show run | section <cfg_section>" :param cfg_section: The section of the config to return eg. "router bgp" :param config: The running/startup config of the device ...
[ "def", "cisco_conf_parse_objects", "(", "cfg_section", ",", "config", ")", ":", "return_config", "=", "[", "]", "if", "type", "(", "config", ")", "is", "str", ":", "config", "=", "config", ".", "splitlines", "(", ")", "parse", "=", "CiscoConfParse", "(", ...
Use CiscoConfParse to find and return a section of Cisco IOS config. Similar to "show run | section <cfg_section>" :param cfg_section: The section of the config to return eg. "router bgp" :param config: The running/startup config of the device to parse
[ "Use", "CiscoConfParse", "to", "find", "and", "return", "a", "section", "of", "Cisco", "IOS", "config", ".", "Similar", "to", "show", "run", "|", "section", "<cfg_section", ">" ]
python
train
37.166667
marselester/flask-api-utils
api_utils/auth.py
https://github.com/marselester/flask-api-utils/blob/f633e49e883c2f4e2523941e70b2d79ff4e138dc/api_utils/auth.py#L50-L75
def client_key_loader(self, f): """Registers a function to be called to find a client key. Function you set has to take a client id and return a client key:: @hawk.client_key_loader def get_client_key(client_id): if client_id == 'Alice': retu...
[ "def", "client_key_loader", "(", "self", ",", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapped_f", "(", "client_id", ")", ":", "client_key", "=", "f", "(", "client_id", ")", "return", "{", "'id'", ":", "client_id", ",", "'key'", ":", "clie...
Registers a function to be called to find a client key. Function you set has to take a client id and return a client key:: @hawk.client_key_loader def get_client_key(client_id): if client_id == 'Alice': return 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w...
[ "Registers", "a", "function", "to", "be", "called", "to", "find", "a", "client", "key", "." ]
python
train
31.269231
mitsei/dlkit
dlkit/services/assessment.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/assessment.py#L1690-L1698
def use_comparative_assessment_part_bank_view(self): """Pass through to provider AssessmentPartBankSession.use_comparative_assessment_part_bank_view""" self._bank_view = COMPARATIVE # self._get_provider_session('assessment_part_bank_session') # To make sure the session is tracked for ses...
[ "def", "use_comparative_assessment_part_bank_view", "(", "self", ")", ":", "self", ".", "_bank_view", "=", "COMPARATIVE", "# self._get_provider_session('assessment_part_bank_session') # To make sure the session is tracked", "for", "session", "in", "self", ".", "_get_provider_sessio...
Pass through to provider AssessmentPartBankSession.use_comparative_assessment_part_bank_view
[ "Pass", "through", "to", "provider", "AssessmentPartBankSession", ".", "use_comparative_assessment_part_bank_view" ]
python
train
52.777778
Stryker0301/google-image-extractor
giextractor.py
https://github.com/Stryker0301/google-image-extractor/blob/bd227f3f77cc82603b9ad7798c9af9fed6724a05/giextractor.py#L264-L301
def _download_image(self, imageURL): """ Downloads an image file from the given image URL Arguments: imageURL {[str]} -- [Image URL] """ # If the required count of images have been download, # refrain from downloading the remainder of the images if(s...
[ "def", "_download_image", "(", "self", ",", "imageURL", ")", ":", "# If the required count of images have been download,", "# refrain from downloading the remainder of the images", "if", "(", "self", ".", "_imageCounter", ">=", "self", ".", "_imageCount", ")", ":", "return"...
Downloads an image file from the given image URL Arguments: imageURL {[str]} -- [Image URL]
[ "Downloads", "an", "image", "file", "from", "the", "given", "image", "URL" ]
python
train
33.578947
ajenhl/tacl
tacl/sequence.py
https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/sequence.py#L68-L96
def generate(self, output_dir, minimum_size): """Generates sequence reports and writes them to the output directory. :param output_dir: directory to output reports to :type output_dir: `str` :param minimum_size: minimum size of n-grams to create sequences for :type minimum_size:...
[ "def", "generate", "(", "self", ",", "output_dir", ",", "minimum_size", ")", ":", "self", ".", "_output_dir", "=", "output_dir", "# Get a list of the files in the matches, grouped by label", "# (ordered by number of works).", "labels", "=", "list", "(", "self", ".", "_m...
Generates sequence reports and writes them to the output directory. :param output_dir: directory to output reports to :type output_dir: `str` :param minimum_size: minimum size of n-grams to create sequences for :type minimum_size: `int`
[ "Generates", "sequence", "reports", "and", "writes", "them", "to", "the", "output", "directory", "." ]
python
train
47.172414
cltl/KafNafParserPy
KafNafParserPy/text_data.py
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/text_data.py#L212-L220
def to_naf(self): """ Converts the object to NAF """ if self.type == 'KAF': self.type = 'NAF' for node in self.__get_wf_nodes(): node.set('id',node.get('wid')) del node.attrib['wid']
[ "def", "to_naf", "(", "self", ")", ":", "if", "self", ".", "type", "==", "'KAF'", ":", "self", ".", "type", "=", "'NAF'", "for", "node", "in", "self", ".", "__get_wf_nodes", "(", ")", ":", "node", ".", "set", "(", "'id'", ",", "node", ".", "get",...
Converts the object to NAF
[ "Converts", "the", "object", "to", "NAF" ]
python
train
29.111111
merll/docker-map
dockermap/map/runner/base.py
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/runner/base.py#L545-L571
def get_exec_create_kwargs(self, action, container_name, exec_cmd, exec_user, kwargs=None): """ Generates keyword arguments for the Docker client to set up the HostConfig or start a container. :param action: Action configuration. :type action: ActionConfig :param container_name:...
[ "def", "get_exec_create_kwargs", "(", "self", ",", "action", ",", "container_name", ",", "exec_cmd", ",", "exec_user", ",", "kwargs", "=", "None", ")", ":", "c_kwargs", "=", "dict", "(", "container", "=", "container_name", ",", "cmd", "=", "resolve_value", "...
Generates keyword arguments for the Docker client to set up the HostConfig or start a container. :param action: Action configuration. :type action: ActionConfig :param container_name: Container name or id. :type container_name: unicode | str :param kwargs: Additional keyword arg...
[ "Generates", "keyword", "arguments", "for", "the", "Docker", "client", "to", "set", "up", "the", "HostConfig", "or", "start", "a", "container", "." ]
python
train
42.740741
noahbenson/neuropythy
neuropythy/util/core.py
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/util/core.py#L656-L665
def inv(x): ''' inv(x) yields the inverse of x, 1/x. Note that inv supports sparse matrices, but it is forced to reify them. Additionally, because inv raises an error on divide-by-zero, they are unlikely to work. For better sparse-matrix support, see zinv. ''' if sps.issparse(x): return 1.0...
[ "def", "inv", "(", "x", ")", ":", "if", "sps", ".", "issparse", "(", "x", ")", ":", "return", "1.0", "/", "x", ".", "toarray", "(", ")", "else", ":", "return", "1.0", "/", "np", ".", "asarray", "(", "x", ")" ]
inv(x) yields the inverse of x, 1/x. Note that inv supports sparse matrices, but it is forced to reify them. Additionally, because inv raises an error on divide-by-zero, they are unlikely to work. For better sparse-matrix support, see zinv.
[ "inv", "(", "x", ")", "yields", "the", "inverse", "of", "x", "1", "/", "x", "." ]
python
train
38.4
apache/spark
python/pyspark/sql/window.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/window.py#L67-L73
def partitionBy(*cols): """ Creates a :class:`WindowSpec` with the partitioning defined. """ sc = SparkContext._active_spark_context jspec = sc._jvm.org.apache.spark.sql.expressions.Window.partitionBy(_to_java_cols(cols)) return WindowSpec(jspec)
[ "def", "partitionBy", "(", "*", "cols", ")", ":", "sc", "=", "SparkContext", ".", "_active_spark_context", "jspec", "=", "sc", ".", "_jvm", ".", "org", ".", "apache", ".", "spark", ".", "sql", ".", "expressions", ".", "Window", ".", "partitionBy", "(", ...
Creates a :class:`WindowSpec` with the partitioning defined.
[ "Creates", "a", ":", "class", ":", "WindowSpec", "with", "the", "partitioning", "defined", "." ]
python
train
41.142857
CivicSpleen/ambry
ambry/library/__init__.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/__init__.py#L490-L528
def checkin_bundle(self, db_path, replace=True, cb=None): """Add a bundle, as a Sqlite file, to this library""" from ambry.orm.exc import NotFoundError db = Database('sqlite:///{}'.format(db_path)) db.open() if len(db.datasets) == 0: raise NotFoundError("Did not get...
[ "def", "checkin_bundle", "(", "self", ",", "db_path", ",", "replace", "=", "True", ",", "cb", "=", "None", ")", ":", "from", "ambry", ".", "orm", ".", "exc", "import", "NotFoundError", "db", "=", "Database", "(", "'sqlite:///{}'", ".", "format", "(", "...
Add a bundle, as a Sqlite file, to this library
[ "Add", "a", "bundle", "as", "a", "Sqlite", "file", "to", "this", "library" ]
python
train
28.974359
pytroll/satpy
satpy/node.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/node.py#L219-L232
def copy(self): """Copy the this node tree Note all references to readers are removed. This is meant to avoid tree copies accessing readers that would return incompatible (Area) data. Theoretically it should be possible for tree copies to request compositor or modifier informati...
[ "def", "copy", "(", "self", ")", ":", "new_tree", "=", "DependencyTree", "(", "{", "}", ",", "self", ".", "compositors", ",", "self", ".", "modifiers", ")", "for", "c", "in", "self", ".", "children", ":", "c", "=", "c", ".", "copy", "(", "node_cach...
Copy the this node tree Note all references to readers are removed. This is meant to avoid tree copies accessing readers that would return incompatible (Area) data. Theoretically it should be possible for tree copies to request compositor or modifier information as long as they don't de...
[ "Copy", "the", "this", "node", "tree" ]
python
train
46.142857
emilydolson/avida-spatial-tools
avidaspatial/utils.py
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/utils.py#L195-L214
def convert_world_to_phenotype(world): """ Converts sets indicating the resources present in a single cell to binary strings (bit order is based on the order of resources in world.resources). TODO: Figure out how to handle relationship between resources and tasks Inputs: world - an EnvironmentFile...
[ "def", "convert_world_to_phenotype", "(", "world", ")", ":", "if", "set", "(", "world", ".", "resources", ")", "!=", "set", "(", "world", ".", "tasks", ")", ":", "print", "(", "\"Warning: world phenotypes don't correspond to phenotypes\"", ")", "if", "set", "(",...
Converts sets indicating the resources present in a single cell to binary strings (bit order is based on the order of resources in world.resources). TODO: Figure out how to handle relationship between resources and tasks Inputs: world - an EnvironmentFile object with a grid of resource sets Returns: a...
[ "Converts", "sets", "indicating", "the", "resources", "present", "in", "a", "single", "cell", "to", "binary", "strings", "(", "bit", "order", "is", "based", "on", "the", "order", "of", "resources", "in", "world", ".", "resources", ")", "." ]
python
train
42.6
twitterdev/search-tweets-python
searchtweets/utils.py
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/utils.py#L143-L212
def read_config(filename): """Reads and flattens a configuration file into a single dictionary for ease of use. Works with both ``.config`` and ``.yaml`` files. Files should look like this:: search_rules: from-date: 2017-06-01 to-date: 2017-09-01 01:01 pt-rule: k...
[ "def", "read_config", "(", "filename", ")", ":", "file_type", "=", "\"yaml\"", "if", "filename", ".", "endswith", "(", "\".yaml\"", ")", "else", "\"config\"", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "if", "file_type", "==", "\"yaml\"", ...
Reads and flattens a configuration file into a single dictionary for ease of use. Works with both ``.config`` and ``.yaml`` files. Files should look like this:: search_rules: from-date: 2017-06-01 to-date: 2017-09-01 01:01 pt-rule: kanye search_params: ...
[ "Reads", "and", "flattens", "a", "configuration", "file", "into", "a", "single", "dictionary", "for", "ease", "of", "use", ".", "Works", "with", "both", ".", "config", "and", ".", "yaml", "files", ".", "Files", "should", "look", "like", "this", "::" ]
python
train
30.014286
taskcluster/taskcluster-client.py
taskcluster/auth.py
https://github.com/taskcluster/taskcluster-client.py/blob/bcc95217f8bf80bed2ae5885a19fa0035da7ebc9/taskcluster/auth.py#L514-L530
def azureContainerSAS(self, *args, **kwargs): """ Get Shared-Access-Signature for Azure Container Get a shared access signature (SAS) string for use with a specific Azure Blob Storage container. The `level` parameter can be `read-write` or `read-only` and determines whi...
[ "def", "azureContainerSAS", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_makeApiCall", "(", "self", ".", "funcinfo", "[", "\"azureContainerSAS\"", "]", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Get Shared-Access-Signature for Azure Container Get a shared access signature (SAS) string for use with a specific Azure Blob Storage container. The `level` parameter can be `read-write` or `read-only` and determines which type of credentials are returned. If level is read-write, it w...
[ "Get", "Shared", "-", "Access", "-", "Signature", "for", "Azure", "Container" ]
python
train
37.529412
SKA-ScienceDataProcessor/integration-prototype
sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py#L190-L211
def save_image(imager, grid_data, grid_norm, output_file): """Makes an image from gridded visibilities and saves it to a FITS file. Args: imager (oskar.Imager): Handle to configured imager. grid_data (numpy.ndarray): Final visibility grid. grid_norm (float): G...
[ "def", "save_image", "(", "imager", ",", "grid_data", ",", "grid_norm", ",", "output_file", ")", ":", "# Make the image (take the FFT, normalise, and apply grid correction).", "imager", ".", "finalise_plane", "(", "grid_data", ",", "grid_norm", ")", "grid_data", "=", "n...
Makes an image from gridded visibilities and saves it to a FITS file. Args: imager (oskar.Imager): Handle to configured imager. grid_data (numpy.ndarray): Final visibility grid. grid_norm (float): Grid normalisation to apply. output_file (str): ...
[ "Makes", "an", "image", "from", "gridded", "visibilities", "and", "saves", "it", "to", "a", "FITS", "file", "." ]
python
train
40.727273
aichaos/rivescript-python
rivescript/brain.py
https://github.com/aichaos/rivescript-python/blob/b55c820cf02a194605fd66af1f070e239f84ed31/rivescript/brain.py#L548-L782
def process_tags(self, user, msg, reply, st=[], bst=[], depth=0, ignore_object_errors=True): """Post process tags in a message. :param str user: The user ID. :param str msg: The user's formatted message. :param str reply: The raw RiveScript reply for the message. :param []str st...
[ "def", "process_tags", "(", "self", ",", "user", ",", "msg", ",", "reply", ",", "st", "=", "[", "]", ",", "bst", "=", "[", "]", ",", "depth", "=", "0", ",", "ignore_object_errors", "=", "True", ")", ":", "stars", "=", "[", "''", "]", "stars", "...
Post process tags in a message. :param str user: The user ID. :param str msg: The user's formatted message. :param str reply: The raw RiveScript reply for the message. :param []str st: The array of ``<star>`` matches from the trigger. :param []str bst: The array of ``<botstar>``...
[ "Post", "process", "tags", "in", "a", "message", "." ]
python
train
43.4