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
adewes/blitzdb
blitzdb/backends/file/index.py
https://github.com/adewes/blitzdb/blob/4b459e0bcde9e1f6224dd4e3bea74194586864b0/blitzdb/backends/file/index.py#L111-L121
def get_all_keys(self): """Get all keys indexed. :return: All keys :rtype: list(str) """ all_keys = [] for keys in self._index.values(): all_keys.extend(keys) return all_keys
[ "def", "get_all_keys", "(", "self", ")", ":", "all_keys", "=", "[", "]", "for", "keys", "in", "self", ".", "_index", ".", "values", "(", ")", ":", "all_keys", ".", "extend", "(", "keys", ")", "return", "all_keys" ]
Get all keys indexed. :return: All keys :rtype: list(str)
[ "Get", "all", "keys", "indexed", "." ]
python
train
21.272727
larsyencken/csvdiff
csvdiff/__init__.py
https://github.com/larsyencken/csvdiff/blob/163dd9da676a8e5f926a935803726340261f03ae/csvdiff/__init__.py#L28-L38
def diff_files(from_file, to_file, index_columns, sep=',', ignored_columns=None): """ Diff two CSV files, returning the patch which transforms one into the other. """ with open(from_file) as from_stream: with open(to_file) as to_stream: from_records = records.load(from_stream, se...
[ "def", "diff_files", "(", "from_file", ",", "to_file", ",", "index_columns", ",", "sep", "=", "','", ",", "ignored_columns", "=", "None", ")", ":", "with", "open", "(", "from_file", ")", "as", "from_stream", ":", "with", "open", "(", "to_file", ")", "as"...
Diff two CSV files, returning the patch which transforms one into the other.
[ "Diff", "two", "CSV", "files", "returning", "the", "patch", "which", "transforms", "one", "into", "the", "other", "." ]
python
train
46.454545
hvac/hvac
hvac/api/secrets_engines/kv_v2.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/secrets_engines/kv_v2.py#L126-L157
def patch(self, path, secret, mount_point=DEFAULT_MOUNT_POINT): """Set or update data in the KV store without overwriting. :param path: Path :type path: str | unicode :param secret: The contents of the "secret" dict will be stored and returned on read. :type secret: dict ...
[ "def", "patch", "(", "self", ",", "path", ",", "secret", ",", "mount_point", "=", "DEFAULT_MOUNT_POINT", ")", ":", "# First, do a read.", "try", ":", "current_secret_version", "=", "self", ".", "read_secret_version", "(", "path", "=", "path", ",", "mount_point",...
Set or update data in the KV store without overwriting. :param path: Path :type path: str | unicode :param secret: The contents of the "secret" dict will be stored and returned on read. :type secret: dict :param mount_point: The "path" the secret engine was mounted on. :...
[ "Set", "or", "update", "data", "in", "the", "KV", "store", "without", "overwriting", "." ]
python
train
39.1875
raphaelvallat/pingouin
pingouin/external/tabulate.py
https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/external/tabulate.py#L463-L475
def _isbool(string): """ >>> _isbool(True) True >>> _isbool("False") True >>> _isbool(1) False """ return isinstance(string, _bool_type) or\ (isinstance(string, (_binary_type, _text_type)) and string in ("True", "False"))
[ "def", "_isbool", "(", "string", ")", ":", "return", "isinstance", "(", "string", ",", "_bool_type", ")", "or", "(", "isinstance", "(", "string", ",", "(", "_binary_type", ",", "_text_type", ")", ")", "and", "string", "in", "(", "\"True\"", ",", "\"False...
>>> _isbool(True) True >>> _isbool("False") True >>> _isbool(1) False
[ ">>>", "_isbool", "(", "True", ")", "True", ">>>", "_isbool", "(", "False", ")", "True", ">>>", "_isbool", "(", "1", ")", "False" ]
python
train
20.846154
materialsproject/pymatgen
pymatgen/io/abinit/tasks.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L2286-L2301
def build(self, *args, **kwargs): """ Creates the working directory and the input files of the :class:`Task`. It does not overwrite files if they already exist. """ # Create dirs for input, output and tmp data. self.indir.makedirs() self.outdir.makedirs() ...
[ "def", "build", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Create dirs for input, output and tmp data.", "self", ".", "indir", ".", "makedirs", "(", ")", "self", ".", "outdir", ".", "makedirs", "(", ")", "self", ".", "tmpdir", "...
Creates the working directory and the input files of the :class:`Task`. It does not overwrite files if they already exist.
[ "Creates", "the", "working", "directory", "and", "the", "input", "files", "of", "the", ":", "class", ":", "Task", ".", "It", "does", "not", "overwrite", "files", "if", "they", "already", "exist", "." ]
python
train
34.875
tjwalch/django-livereload-server
livereload/watcher.py
https://github.com/tjwalch/django-livereload-server/blob/ea3edaa1a5b2f8cb49761dd32f2fcc4554c4aa0c/livereload/watcher.py#L67-L88
def examine(self): """Check if there are changes, if true, run the given task.""" if self._changes: return self._changes.pop() # clean filepath self.filepath = None delays = set([0]) for path in self._tasks: item = self._tasks[path] if...
[ "def", "examine", "(", "self", ")", ":", "if", "self", ".", "_changes", ":", "return", "self", ".", "_changes", ".", "pop", "(", ")", "# clean filepath", "self", ".", "filepath", "=", "None", "delays", "=", "set", "(", "[", "0", "]", ")", "for", "p...
Check if there are changes, if true, run the given task.
[ "Check", "if", "there", "are", "changes", "if", "true", "run", "the", "given", "task", "." ]
python
train
29.681818
saltstack/salt
salt/cloud/clouds/gce.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L728-L807
def create_subnetwork(kwargs=None, call=None): ''' ... versionadded:: 2017.7.0 Create a GCE Subnetwork. Must specify name, cidr, network, and region. CLI Example: .. code-block:: bash salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 descrip...
[ "def", "create_subnetwork", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_subnetwork function must be called with -f or --function.'", ")", "if", "not", "kwargs"...
... versionadded:: 2017.7.0 Create a GCE Subnetwork. Must specify name, cidr, network, and region. CLI Example: .. code-block:: bash salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 description=optional
[ "...", "versionadded", "::", "2017", ".", "7", ".", "0", "Create", "a", "GCE", "Subnetwork", ".", "Must", "specify", "name", "cidr", "network", "and", "region", "." ]
python
train
25.7
twilio/twilio-python
twilio/rest/api/v2010/account/address/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/address/__init__.py#L357-L370
def dependent_phone_numbers(self): """ Access the dependent_phone_numbers :returns: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList """ if ...
[ "def", "dependent_phone_numbers", "(", "self", ")", ":", "if", "self", ".", "_dependent_phone_numbers", "is", "None", ":", "self", ".", "_dependent_phone_numbers", "=", "DependentPhoneNumberList", "(", "self", ".", "_version", ",", "account_sid", "=", "self", ".",...
Access the dependent_phone_numbers :returns: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList
[ "Access", "the", "dependent_phone_numbers" ]
python
train
43.928571
pypa/pipenv
pipenv/core.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1639-L1695
def format_help(help): """Formats the help string.""" help = help.replace("Options:", str(crayons.normal("Options:", bold=True))) help = help.replace( "Usage: pipenv", str("Usage: {0}".format(crayons.normal("pipenv", bold=True))) ) help = help.replace(" check", str(crayons.red(" check", bo...
[ "def", "format_help", "(", "help", ")", ":", "help", "=", "help", ".", "replace", "(", "\"Options:\"", ",", "str", "(", "crayons", ".", "normal", "(", "\"Options:\"", ",", "bold", "=", "True", ")", ")", ")", "help", "=", "help", ".", "replace", "(", ...
Formats the help string.
[ "Formats", "the", "help", "string", "." ]
python
train
37.087719
OCR-D/core
ocrd_models/ocrd_models/ocrd_exif.py
https://github.com/OCR-D/core/blob/57e68c578526cb955fd2e368207f5386c459d91d/ocrd_models/ocrd_models/ocrd_exif.py#L42-L50
def to_xml(self): """ Serialize all properties as XML """ ret = '<exif>' for k in self.__dict__: ret += '<%s>%s</%s>' % (k, self.__dict__[k], k) ret += '</exif>' return ret
[ "def", "to_xml", "(", "self", ")", ":", "ret", "=", "'<exif>'", "for", "k", "in", "self", ".", "__dict__", ":", "ret", "+=", "'<%s>%s</%s>'", "%", "(", "k", ",", "self", ".", "__dict__", "[", "k", "]", ",", "k", ")", "ret", "+=", "'</exif>'", "re...
Serialize all properties as XML
[ "Serialize", "all", "properties", "as", "XML" ]
python
train
25.777778
miniconfig/python-openevse-wifi
openevsewifi/__init__.py
https://github.com/miniconfig/python-openevse-wifi/blob/42fabeae052a9f82092fa9220201413732e38bb4/openevsewifi/__init__.py#L141-L146
def getSerialDebugEnabled(self): """Returns True if enabled, False if disabled""" command = '$GE' settings = self.sendCommand(command) flags = int(settings[2], 16) return not (flags & 0x0080)
[ "def", "getSerialDebugEnabled", "(", "self", ")", ":", "command", "=", "'$GE'", "settings", "=", "self", ".", "sendCommand", "(", "command", ")", "flags", "=", "int", "(", "settings", "[", "2", "]", ",", "16", ")", "return", "not", "(", "flags", "&", ...
Returns True if enabled, False if disabled
[ "Returns", "True", "if", "enabled", "False", "if", "disabled" ]
python
train
34.333333
gem/oq-engine
openquake/hazardlib/mfd/base.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/mfd/base.py#L34-L56
def modify(self, modification, parameters): """ Apply a single modification to an MFD parameters. Reflects the modification method and calls it passing ``parameters`` as keyword arguments. See also :attr:`MODIFICATIONS`. Modifications can be applied one on top of another. The l...
[ "def", "modify", "(", "self", ",", "modification", ",", "parameters", ")", ":", "if", "modification", "not", "in", "self", ".", "MODIFICATIONS", ":", "raise", "ValueError", "(", "'Modification %s is not supported by %s'", "%", "(", "modification", ",", "type", "...
Apply a single modification to an MFD parameters. Reflects the modification method and calls it passing ``parameters`` as keyword arguments. See also :attr:`MODIFICATIONS`. Modifications can be applied one on top of another. The logic of stacking modifications is up to a specific MFD i...
[ "Apply", "a", "single", "modification", "to", "an", "MFD", "parameters", "." ]
python
train
42.391304
materialsproject/pymatgen
pymatgen/io/abinit/abiobjects.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/abiobjects.py#L95-L157
def structure_from_abivars(cls=None, *args, **kwargs): """ Build a :class:`Structure` object from a dictionary with ABINIT variables. Args: cls: Structure class to be instantiated. pymatgen.core.structure.Structure if cls is None example: al_structure = structure_from_abivars( ...
[ "def", "structure_from_abivars", "(", "cls", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "dict", "(", "*", "args", ")", ")", "d", "=", "kwargs", "cls", "=", "Structure", "if", "cls", "is", "None",...
Build a :class:`Structure` object from a dictionary with ABINIT variables. Args: cls: Structure class to be instantiated. pymatgen.core.structure.Structure if cls is None example: al_structure = structure_from_abivars( acell=3*[7.5], rprim=[0.0, 0.5, 0.5, ...
[ "Build", "a", ":", "class", ":", "Structure", "object", "from", "a", "dictionary", "with", "ABINIT", "variables", "." ]
python
train
30.809524
odlgroup/odl
odl/util/npy_compat.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/util/npy_compat.py#L56-L73
def flip(a, axis): """Reverse the order of elements in an array along the given axis. This function is a backport of `numpy.flip` introduced in NumPy 1.12. See Also -------- numpy.flip """ if not hasattr(a, 'ndim'): a = np.asarray(a) indexer = [slice(None)] * a.ndim try: ...
[ "def", "flip", "(", "a", ",", "axis", ")", ":", "if", "not", "hasattr", "(", "a", ",", "'ndim'", ")", ":", "a", "=", "np", ".", "asarray", "(", "a", ")", "indexer", "=", "[", "slice", "(", "None", ")", "]", "*", "a", ".", "ndim", "try", ":"...
Reverse the order of elements in an array along the given axis. This function is a backport of `numpy.flip` introduced in NumPy 1.12. See Also -------- numpy.flip
[ "Reverse", "the", "order", "of", "elements", "in", "an", "array", "along", "the", "given", "axis", "." ]
python
train
29.388889
project-rig/rig
rig/machine_control/machine_controller.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1197-L1208
def _send_ffs(self, pid, n_blocks, fr): """Send a flood-fill start packet. The cores and regions that the application should be loaded to will be specified by a stream of flood-fill core select packets (FFCS). """ sfr = fr | (1 << 31) self._send_scp( 255, 255...
[ "def", "_send_ffs", "(", "self", ",", "pid", ",", "n_blocks", ",", "fr", ")", ":", "sfr", "=", "fr", "|", "(", "1", "<<", "31", ")", "self", ".", "_send_scp", "(", "255", ",", "255", ",", "0", ",", "SCPCommands", ".", "nearest_neighbour_packet", ",...
Send a flood-fill start packet. The cores and regions that the application should be loaded to will be specified by a stream of flood-fill core select packets (FFCS).
[ "Send", "a", "flood", "-", "fill", "start", "packet", "." ]
python
train
38.583333
tamasgal/km3pipe
km3pipe/db.py
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L422-L427
def restore_session(self, cookie): """Establish databse connection using permanent session cookie""" log.debug("Restoring session from cookie: {}".format(cookie)) opener = build_opener() opener.addheaders.append(('Cookie', cookie)) self._opener = opener
[ "def", "restore_session", "(", "self", ",", "cookie", ")", ":", "log", ".", "debug", "(", "\"Restoring session from cookie: {}\"", ".", "format", "(", "cookie", ")", ")", "opener", "=", "build_opener", "(", ")", "opener", ".", "addheaders", ".", "append", "(...
Establish databse connection using permanent session cookie
[ "Establish", "databse", "connection", "using", "permanent", "session", "cookie" ]
python
train
48
pypa/pipenv
pipenv/vendor/click/core.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/core.py#L886-L899
def format_help(self, ctx, formatter): """Writes the help into the formatter if it exists. This calls into the following methods: - :meth:`format_usage` - :meth:`format_help_text` - :meth:`format_options` - :meth:`format_epilog` """ self.format_u...
[ "def", "format_help", "(", "self", ",", "ctx", ",", "formatter", ")", ":", "self", ".", "format_usage", "(", "ctx", ",", "formatter", ")", "self", ".", "format_help_text", "(", "ctx", ",", "formatter", ")", "self", ".", "format_options", "(", "ctx", ",",...
Writes the help into the formatter if it exists. This calls into the following methods: - :meth:`format_usage` - :meth:`format_help_text` - :meth:`format_options` - :meth:`format_epilog`
[ "Writes", "the", "help", "into", "the", "formatter", "if", "it", "exists", "." ]
python
train
32.857143
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1001-L1016
def get_events_with_cluster_size(event_number, cluster_size, condition='cluster_size==1'): '''Selects the events with cluster of a given cluster size. Parameters ---------- event_number : numpy.array cluster_size : numpy.array condition : string Returns ------- numpy.array ''' ...
[ "def", "get_events_with_cluster_size", "(", "event_number", ",", "cluster_size", ",", "condition", "=", "'cluster_size==1'", ")", ":", "logging", ".", "debug", "(", "\"Calculate events with clusters with \"", "+", "condition", ")", "return", "np", ".", "unique", "(", ...
Selects the events with cluster of a given cluster size. Parameters ---------- event_number : numpy.array cluster_size : numpy.array condition : string Returns ------- numpy.array
[ "Selects", "the", "events", "with", "cluster", "of", "a", "given", "cluster", "size", "." ]
python
train
27.125
markovmodel/PyEMMA
pyemma/coordinates/util/patches.py
https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/util/patches.py#L377-L401
def trajectory_set_item(self, idx, value): """ :param self: mdtraj.Trajectory :param idx: possible slices over frames, :param value: :return: """ import mdtraj assert isinstance(self, mdtraj.Trajectory), type(self) if not isinstance(value, mdtraj.Trajectory): raise TypeError(...
[ "def", "trajectory_set_item", "(", "self", ",", "idx", ",", "value", ")", ":", "import", "mdtraj", "assert", "isinstance", "(", "self", ",", "mdtraj", ".", "Trajectory", ")", ",", "type", "(", "self", ")", "if", "not", "isinstance", "(", "value", ",", ...
:param self: mdtraj.Trajectory :param idx: possible slices over frames, :param value: :return:
[ ":", "param", "self", ":", "mdtraj", ".", "Trajectory", ":", "param", "idx", ":", "possible", "slices", "over", "frames", ":", "param", "value", ":", ":", "return", ":" ]
python
train
37.16
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/parallel/controller/dictdb.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/controller/dictdb.py#L182-L185
def get_history(self): """get all msg_ids, ordered by time submitted.""" msg_ids = self._records.keys() return sorted(msg_ids, key=lambda m: self._records[m]['submitted'])
[ "def", "get_history", "(", "self", ")", ":", "msg_ids", "=", "self", ".", "_records", ".", "keys", "(", ")", "return", "sorted", "(", "msg_ids", ",", "key", "=", "lambda", "m", ":", "self", ".", "_records", "[", "m", "]", "[", "'submitted'", "]", "...
get all msg_ids, ordered by time submitted.
[ "get", "all", "msg_ids", "ordered", "by", "time", "submitted", "." ]
python
test
48
ethan92429/onshapepy
onshapepy/part.py
https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/part.py#L72-L94
def update(self, params=None, client=c): """Push params to OnShape and synchronize the local copy """ uri = self.parent.uri if not params or not self.res: self.get_params() return d = self.payload for k, v in params.items(): m = d["curr...
[ "def", "update", "(", "self", ",", "params", "=", "None", ",", "client", "=", "c", ")", ":", "uri", "=", "self", ".", "parent", ".", "uri", "if", "not", "params", "or", "not", "self", ".", "res", ":", "self", ".", "get_params", "(", ")", "return"...
Push params to OnShape and synchronize the local copy
[ "Push", "params", "to", "OnShape", "and", "synchronize", "the", "local", "copy" ]
python
train
35.826087
google/grumpy
third_party/stdlib/difflib.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L647-L695
def get_grouped_opcodes(self, n=3): """ Isolate change clusters by eliminating ranges with no changes. Return a generator of groups with up to n lines of context. Each group is in the same format as returned by get_opcodes(). >>> from pprint import pprint >>> a = map(str, range...
[ "def", "get_grouped_opcodes", "(", "self", ",", "n", "=", "3", ")", ":", "codes", "=", "self", ".", "get_opcodes", "(", ")", "if", "not", "codes", ":", "codes", "=", "[", "(", "\"equal\"", ",", "0", ",", "1", ",", "0", ",", "1", ")", "]", "# Fi...
Isolate change clusters by eliminating ranges with no changes. Return a generator of groups with up to n lines of context. Each group is in the same format as returned by get_opcodes(). >>> from pprint import pprint >>> a = map(str, range(1,40)) >>> b = a[:] >>> b[8:8] ...
[ "Isolate", "change", "clusters", "by", "eliminating", "ranges", "with", "no", "changes", "." ]
python
valid
41.061224
tanghaibao/goatools
goatools/rpt/nts_xfrm.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/nts_xfrm.py#L35-L44
def add_f2str(self, dcts, srcfld, dstfld, dstfmt): """Add a namedtuple field of type string generated from an existing namedtuple field.""" # Example: f2str = objntmgr.add_f2str(dcts, "p_fdr_bh", "s_fdr_bh", "{:8.2e}") # ntobj = self.get_ntobj() # print(ntobj) assert len(dcts) ==...
[ "def", "add_f2str", "(", "self", ",", "dcts", ",", "srcfld", ",", "dstfld", ",", "dstfmt", ")", ":", "# Example: f2str = objntmgr.add_f2str(dcts, \"p_fdr_bh\", \"s_fdr_bh\", \"{:8.2e}\")", "# ntobj = self.get_ntobj()", "# print(ntobj)", "assert", "len", "(", "dcts", ")", ...
Add a namedtuple field of type string generated from an existing namedtuple field.
[ "Add", "a", "namedtuple", "field", "of", "type", "string", "generated", "from", "an", "existing", "namedtuple", "field", "." ]
python
train
49.6
briancappello/flask-sqlalchemy-bundle
flask_sqlalchemy_bundle/meta/model_meta_factory.py
https://github.com/briancappello/flask-sqlalchemy-bundle/blob/8150896787907ef0001839b5a6ef303edccb9b6c/flask_sqlalchemy_bundle/meta/model_meta_factory.py#L30-L63
def _get_model_meta_options(self) -> List[MetaOption]: """" Define fields allowed in the Meta class on end-user models, and the behavior of each. Custom ModelMetaOptions classes should override this method to customize the options supported on class Meta of end-user models. ...
[ "def", "_get_model_meta_options", "(", "self", ")", "->", "List", "[", "MetaOption", "]", ":", "# we can't use current_app to determine if we're under test, because it", "# doesn't exist yet", "testing_options", "=", "(", "[", "]", "if", "os", ".", "getenv", "(", "'FLAS...
Define fields allowed in the Meta class on end-user models, and the behavior of each. Custom ModelMetaOptions classes should override this method to customize the options supported on class Meta of end-user models.
[ "Define", "fields", "allowed", "in", "the", "Meta", "class", "on", "end", "-", "user", "models", "and", "the", "behavior", "of", "each", "." ]
python
train
44.882353
apache/incubator-mxnet
docs/mxdoc.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/docs/mxdoc.py#L84-L87
def generate_doxygen(app): """Run the doxygen make commands""" _run_cmd("cd %s/.. && make doxygen" % app.builder.srcdir) _run_cmd("cp -rf doxygen/html %s/doxygen" % app.builder.outdir)
[ "def", "generate_doxygen", "(", "app", ")", ":", "_run_cmd", "(", "\"cd %s/.. && make doxygen\"", "%", "app", ".", "builder", ".", "srcdir", ")", "_run_cmd", "(", "\"cp -rf doxygen/html %s/doxygen\"", "%", "app", ".", "builder", ".", "outdir", ")" ]
Run the doxygen make commands
[ "Run", "the", "doxygen", "make", "commands" ]
python
train
48.25
janpipek/physt
physt/plotting/vega.py
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L673-L680
def _create_axes(hist: HistogramBase, vega: dict, kwargs: dict): """Create axes in the figure.""" xlabel = kwargs.pop("xlabel", hist.axis_names[0]) ylabel = kwargs.pop("ylabel", hist.axis_names[1] if len(hist.axis_names) >= 2 else None) vega["axes"] = [ {"orient": "bottom", "scale": "xscale", "t...
[ "def", "_create_axes", "(", "hist", ":", "HistogramBase", ",", "vega", ":", "dict", ",", "kwargs", ":", "dict", ")", ":", "xlabel", "=", "kwargs", ".", "pop", "(", "\"xlabel\"", ",", "hist", ".", "axis_names", "[", "0", "]", ")", "ylabel", "=", "kwar...
Create axes in the figure.
[ "Create", "axes", "in", "the", "figure", "." ]
python
train
49.625
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L4566-L4571
def setTreeDoc(self, tree): """update all nodes under the tree to point to the right document """ if tree is None: tree__o = None else: tree__o = tree._o libxml2mod.xmlSetTreeDoc(tree__o, self._o)
[ "def", "setTreeDoc", "(", "self", ",", "tree", ")", ":", "if", "tree", "is", "None", ":", "tree__o", "=", "None", "else", ":", "tree__o", "=", "tree", ".", "_o", "libxml2mod", ".", "xmlSetTreeDoc", "(", "tree__o", ",", "self", ".", "_o", ")" ]
update all nodes under the tree to point to the right document
[ "update", "all", "nodes", "under", "the", "tree", "to", "point", "to", "the", "right", "document" ]
python
train
39
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py#L613-L637
def _finish_operation_action(self, action): """Finish an attempted operation. Args: action (ConnectionAction): the action object describing the result of the operation that we are finishing """ success = action.data['success'] conn_key = action.data[...
[ "def", "_finish_operation_action", "(", "self", ",", "action", ")", ":", "success", "=", "action", ".", "data", "[", "'success'", "]", "conn_key", "=", "action", ".", "data", "[", "'id'", "]", "if", "self", ".", "_get_connection_state", "(", "conn_key", ")...
Finish an attempted operation. Args: action (ConnectionAction): the action object describing the result of the operation that we are finishing
[ "Finish", "an", "attempted", "operation", "." ]
python
train
35.28
saltstack/salt
salt/utils/ssdp.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/ssdp.py#L355-L364
def _query(self): ''' Query the broadcast for defined services. :return: ''' query = salt.utils.stringutils.to_bytes( "{}{}".format(self.signature, time.time())) self._socket.sendto(query, ('<broadcast>', self.port)) return query
[ "def", "_query", "(", "self", ")", ":", "query", "=", "salt", ".", "utils", ".", "stringutils", ".", "to_bytes", "(", "\"{}{}\"", ".", "format", "(", "self", ".", "signature", ",", "time", ".", "time", "(", ")", ")", ")", "self", ".", "_socket", "....
Query the broadcast for defined services. :return:
[ "Query", "the", "broadcast", "for", "defined", "services", ".", ":", "return", ":" ]
python
train
28.9
oscarlazoarjona/fast
fast/electric_field.py
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/electric_field.py#L307-L315
def plot(self, **kwds): r"""The plotting function for MOT fields.""" plo = self.lx.plot(dist_to_center=3, **kwds) plo += self.ly.plot(dist_to_center=3, **kwds) plo += self.lz.plot(dist_to_center=3, **kwds) plo += self.lx_r.plot(dist_to_center=3, **kwds) plo += self....
[ "def", "plot", "(", "self", ",", "*", "*", "kwds", ")", ":", "plo", "=", "self", ".", "lx", ".", "plot", "(", "dist_to_center", "=", "3", ",", "*", "*", "kwds", ")", "plo", "+=", "self", ".", "ly", ".", "plot", "(", "dist_to_center", "=", "3", ...
r"""The plotting function for MOT fields.
[ "r", "The", "plotting", "function", "for", "MOT", "fields", "." ]
python
train
47.111111
rix0rrr/gcl
gcl/ast_util.py
https://github.com/rix0rrr/gcl/blob/4e3bccc978a9c60aaaffd20f6f291c4d23775cdf/gcl/ast_util.py#L171-L181
def find_inherited_key_completions(rootpath, root_env): """Return completion keys from INHERITED tuples. Easiest way to get those is to evaluate the tuple, check if it is a CompositeTuple, then enumerate the keys that are NOT in the rightmost tuple. """ tup = inflate_context_tuple(rootpath, root_env) if is...
[ "def", "find_inherited_key_completions", "(", "rootpath", ",", "root_env", ")", ":", "tup", "=", "inflate_context_tuple", "(", "rootpath", ",", "root_env", ")", "if", "isinstance", "(", "tup", ",", "runtime", ".", "CompositeTuple", ")", ":", "keys", "=", "set"...
Return completion keys from INHERITED tuples. Easiest way to get those is to evaluate the tuple, check if it is a CompositeTuple, then enumerate the keys that are NOT in the rightmost tuple.
[ "Return", "completion", "keys", "from", "INHERITED", "tuples", "." ]
python
train
43.090909
inasafe/inasafe
safe/gui/tools/wizard/step_fc55_agglayer_from_canvas.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc55_agglayer_from_canvas.py#L112-L130
def set_widgets(self): """Set widgets on the Aggregation Layer from Canvas tab.""" # The list is already populated in the previous step, but now we # need to do it again in case we're back from the Keyword Wizard. # First, preserve self.parent.layer before clearing the list last_...
[ "def", "set_widgets", "(", "self", ")", ":", "# The list is already populated in the previous step, but now we", "# need to do it again in case we're back from the Keyword Wizard.", "# First, preserve self.parent.layer before clearing the list", "last_layer", "=", "self", ".", "parent", ...
Set widgets on the Aggregation Layer from Canvas tab.
[ "Set", "widgets", "on", "the", "Aggregation", "Layer", "from", "Canvas", "tab", "." ]
python
train
52.473684
trailofbits/manticore
manticore/native/memory.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/memory.py#L120-L127
def _set_perms(self, perms): """ Sets the access permissions of the map. :param perms: the new permissions. """ assert isinstance(perms, str) and len(perms) <= 3 and perms.strip() in ['', 'r', 'w', 'x', 'rw', 'r x', 'rx', 'rwx', 'wx', ] self._perms = perms
[ "def", "_set_perms", "(", "self", ",", "perms", ")", ":", "assert", "isinstance", "(", "perms", ",", "str", ")", "and", "len", "(", "perms", ")", "<=", "3", "and", "perms", ".", "strip", "(", ")", "in", "[", "''", ",", "'r'", ",", "'w'", ",", "...
Sets the access permissions of the map. :param perms: the new permissions.
[ "Sets", "the", "access", "permissions", "of", "the", "map", "." ]
python
valid
37.25
awslabs/aws-sam-cli
samcli/local/docker/lambda_image.py
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_image.py#L73-L115
def build(self, runtime, layers): """ Build the image if one is not already on the system that matches the runtime and layers Parameters ---------- runtime str Name of the Lambda runtime layers list(samcli.commands.local.lib.provider.Layer) List o...
[ "def", "build", "(", "self", ",", "runtime", ",", "layers", ")", ":", "base_image", "=", "\"{}:{}\"", ".", "format", "(", "self", ".", "_DOCKER_LAMBDA_REPO_NAME", ",", "runtime", ")", "# Don't build the image if there are no layers.", "if", "not", "layers", ":", ...
Build the image if one is not already on the system that matches the runtime and layers Parameters ---------- runtime str Name of the Lambda runtime layers list(samcli.commands.local.lib.provider.Layer) List of layers Returns ------- str ...
[ "Build", "the", "image", "if", "one", "is", "not", "already", "on", "the", "system", "that", "matches", "the", "runtime", "and", "layers" ]
python
train
33.976744
spacetelescope/synphot_refactor
synphot/spectrum.py
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1719-L1738
def efficiency(self, wavelengths=None): """Calculate :ref:`dimensionless efficiency <synphot-formula-qtlam>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed ...
[ "def", "efficiency", "(", "self", ",", "wavelengths", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", ".", "value", "y", "=", "self", "(", "x", ")", ".", "value", "qtlam", "=", "abs", "(", "np", ".", ...
Calculate :ref:`dimensionless efficiency <synphot-formula-qtlam>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If `None`, ``self.wa...
[ "Calculate", ":", "ref", ":", "dimensionless", "efficiency", "<synphot", "-", "formula", "-", "qtlam", ">", "." ]
python
train
33.85
pygobject/pgi
pgi/util.py
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/util.py#L134-L139
def lookup_name_slow(self, name): """Returns a struct if one exists""" for index in xrange(self.__get_count_cached()): if self.__get_name_cached(index) == name: return self.__get_info_cached(index)
[ "def", "lookup_name_slow", "(", "self", ",", "name", ")", ":", "for", "index", "in", "xrange", "(", "self", ".", "__get_count_cached", "(", ")", ")", ":", "if", "self", ".", "__get_name_cached", "(", "index", ")", "==", "name", ":", "return", "self", "...
Returns a struct if one exists
[ "Returns", "a", "struct", "if", "one", "exists" ]
python
train
39.5
sludgedesk/metoffer
metoffer.py
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L179-L188
def _query(self, data_category, resource_category, field, request, step, isotime=None): """ Request and return data from DataPoint RESTful API. """ rest_url = "/".join([HOST, data_category, resource_category, field, DATA_TYPE, request]) query_string = "?" + "&".join(["res=" + ste...
[ "def", "_query", "(", "self", ",", "data_category", ",", "resource_category", ",", "field", ",", "request", ",", "step", ",", "isotime", "=", "None", ")", ":", "rest_url", "=", "\"/\"", ".", "join", "(", "[", "HOST", ",", "data_category", ",", "resource_...
Request and return data from DataPoint RESTful API.
[ "Request", "and", "return", "data", "from", "DataPoint", "RESTful", "API", "." ]
python
train
50
phalt/beckett
beckett/resources.py
https://github.com/phalt/beckett/blob/555a7b1744d0063023fecd70a81ae090096362f3/beckett/resources.py#L207-L232
def set_related_method(self, resource, full_resource_url): """ Using reflection, generate the related method and return it. """ method_name = self.get_method_name(resource, 'get') def get(self, **kwargs): return self._call_api_single_related_resource( ...
[ "def", "set_related_method", "(", "self", ",", "resource", ",", "full_resource_url", ")", ":", "method_name", "=", "self", ".", "get_method_name", "(", "resource", ",", "'get'", ")", "def", "get", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", ...
Using reflection, generate the related method and return it.
[ "Using", "reflection", "generate", "the", "related", "method", "and", "return", "it", "." ]
python
train
32.076923
twilio/twilio-python
twilio/rest/preview/bulk_exports/export_configuration.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/bulk_exports/export_configuration.py#L279-L291
def update(self, enabled=values.unset, webhook_url=values.unset, webhook_method=values.unset): """ Update the ExportConfigurationInstance :param bool enabled: The enabled :param unicode webhook_url: The webhook_url :param unicode webhook_method: The webhook_method...
[ "def", "update", "(", "self", ",", "enabled", "=", "values", ".", "unset", ",", "webhook_url", "=", "values", ".", "unset", ",", "webhook_method", "=", "values", ".", "unset", ")", ":", "return", "self", ".", "_proxy", ".", "update", "(", "enabled", "=...
Update the ExportConfigurationInstance :param bool enabled: The enabled :param unicode webhook_url: The webhook_url :param unicode webhook_method: The webhook_method :returns: Updated ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_exports.export_configuration.Expo...
[ "Update", "the", "ExportConfigurationInstance" ]
python
train
44.769231
crytic/slither
slither/detectors/operations/block_timestamp.py
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/operations/block_timestamp.py#L49-L61
def detect_dangerous_timestamp(self, contract): """ Args: contract (Contract) Returns: list((Function), (list (Node))) """ ret = [] for f in [f for f in contract.functions if f.contract == contract]: nodes = self.timestamp(f) ...
[ "def", "detect_dangerous_timestamp", "(", "self", ",", "contract", ")", ":", "ret", "=", "[", "]", "for", "f", "in", "[", "f", "for", "f", "in", "contract", ".", "functions", "if", "f", ".", "contract", "==", "contract", "]", ":", "nodes", "=", "self...
Args: contract (Contract) Returns: list((Function), (list (Node)))
[ "Args", ":", "contract", "(", "Contract", ")", "Returns", ":", "list", "((", "Function", ")", "(", "list", "(", "Node", ")))" ]
python
train
29
daler/trackhub
trackhub/helpers.py
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L12-L22
def dimensions_from_subgroups(s): """ Given a sorted list of subgroups, return a string appropriate to provide as a composite track's `dimensions` arg. Parameters ---------- s : list of SubGroup objects (or anything with a `name` attribute) """ letters = 'XYABCDEFGHIJKLMNOPQRSTUVWZ' ...
[ "def", "dimensions_from_subgroups", "(", "s", ")", ":", "letters", "=", "'XYABCDEFGHIJKLMNOPQRSTUVWZ'", "return", "' '", ".", "join", "(", "[", "'dim{0}={1}'", ".", "format", "(", "dim", ",", "sg", ".", "name", ")", "for", "dim", ",", "sg", "in", "zip", ...
Given a sorted list of subgroups, return a string appropriate to provide as a composite track's `dimensions` arg. Parameters ---------- s : list of SubGroup objects (or anything with a `name` attribute)
[ "Given", "a", "sorted", "list", "of", "subgroups", "return", "a", "string", "appropriate", "to", "provide", "as", "a", "composite", "track", "s", "dimensions", "arg", "." ]
python
train
35.818182
SmokinCaterpillar/pypet
pypet/storageservice.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/storageservice.py#L3480-L3514
def _ann_store_annotations(self, item_with_annotations, node, overwrite=False): """Stores annotations into an hdf5 file.""" # If we overwrite delete all annotations first if overwrite is True or overwrite == 'v_annotations': annotated = self._all_get_from_attrs(node, HDF5StorageServ...
[ "def", "_ann_store_annotations", "(", "self", ",", "item_with_annotations", ",", "node", ",", "overwrite", "=", "False", ")", ":", "# If we overwrite delete all annotations first", "if", "overwrite", "is", "True", "or", "overwrite", "==", "'v_annotations'", ":", "anno...
Stores annotations into an hdf5 file.
[ "Stores", "annotations", "into", "an", "hdf5", "file", "." ]
python
test
43.571429
horazont/aioxmpp
aioxmpp/pubsub/service.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L852-L891
def get_nodes(self, jid, node=None): """ Request all nodes at a service or collection node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the collection node to query :type node: :class:`str` or :data:`None` :rais...
[ "def", "get_nodes", "(", "self", ",", "jid", ",", "node", "=", "None", ")", ":", "response", "=", "yield", "from", "self", ".", "_disco", ".", "query_items", "(", "jid", ",", "node", "=", "node", ",", ")", "result", "=", "[", "]", "for", "item", ...
Request all nodes at a service or collection node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the collection node to query :type node: :class:`str` or :data:`None` :raises aioxmpp.errors.XMPPError: as returned by the service ...
[ "Request", "all", "nodes", "at", "a", "service", "or", "collection", "node", "." ]
python
train
35.475
rorr73/LifeSOSpy
lifesospy/device.py
https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L379-L387
def high_limit(self) -> Optional[Union[int, float]]: """ High limit setting for a special sensor. For LS-10/LS-20 base units this is the alarm high limit. For LS-30 base units, this is either alarm OR control high limit, as indicated by special_status ControlAlarm bit flag. ...
[ "def", "high_limit", "(", "self", ")", "->", "Optional", "[", "Union", "[", "int", ",", "float", "]", "]", ":", "return", "self", ".", "_get_field_value", "(", "SpecialDevice", ".", "PROP_HIGH_LIMIT", ")" ]
High limit setting for a special sensor. For LS-10/LS-20 base units this is the alarm high limit. For LS-30 base units, this is either alarm OR control high limit, as indicated by special_status ControlAlarm bit flag.
[ "High", "limit", "setting", "for", "a", "special", "sensor", "." ]
python
train
43
nickjj/ansigenome
ansigenome/utils.py
https://github.com/nickjj/ansigenome/blob/70cd98d7a23d36c56f4e713ea820cfb4c485c81c/ansigenome/utils.py#L71-L82
def file_to_list(path): """ Return the contents of a file as a list when given a path. """ if not os.path.exists(path): ui.error(c.MESSAGES["path_missing"], path) sys.exit(1) with codecs.open(path, "r", "UTF-8") as contents: lines = contents.read().splitlines() return l...
[ "def", "file_to_list", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "ui", ".", "error", "(", "c", ".", "MESSAGES", "[", "\"path_missing\"", "]", ",", "path", ")", "sys", ".", "exit", "(", "1", ")", ...
Return the contents of a file as a list when given a path.
[ "Return", "the", "contents", "of", "a", "file", "as", "a", "list", "when", "given", "a", "path", "." ]
python
train
26.083333
port-zero/mite
mite/mite.py
https://github.com/port-zero/mite/blob/b5fa941f60bf43e04ef654ed580ed7ef91211c22/mite/mite.py#L229-L237
def create_customer(self, name, **kwargs): """ Creates a customer with a name. All other parameters are optional. They are: `note`, `active_hourly_rate`, `hourly_rate`, `hourly_rates_per_service`, and `archived`. """ data = self._wrap_dict("customer", kwargs) data...
[ "def", "create_customer", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "data", "=", "self", ".", "_wrap_dict", "(", "\"customer\"", ",", "kwargs", ")", "data", "[", "\"customer\"", "]", "[", "\"name\"", "]", "=", "name", "return", "self...
Creates a customer with a name. All other parameters are optional. They are: `note`, `active_hourly_rate`, `hourly_rate`, `hourly_rates_per_service`, and `archived`.
[ "Creates", "a", "customer", "with", "a", "name", ".", "All", "other", "parameters", "are", "optional", ".", "They", "are", ":", "note", "active_hourly_rate", "hourly_rate", "hourly_rates_per_service", "and", "archived", "." ]
python
train
43.777778
steveYeah/PyBomb
pybomb/clients/base_client.py
https://github.com/steveYeah/PyBomb/blob/54045d74e642f8a1c4366c24bd6a330ae3da6257/pybomb/clients/base_client.py#L78-L87
def _validate_return_fields(self, return_fields): """ :param return_fields: tuple :raises: pybomb.exceptions.InvalidReturnFieldException """ for return_field in return_fields: if return_field not in self.RESPONSE_FIELD_MAP: raise InvalidReturnFieldExce...
[ "def", "_validate_return_fields", "(", "self", ",", "return_fields", ")", ":", "for", "return_field", "in", "return_fields", ":", "if", "return_field", "not", "in", "self", ".", "RESPONSE_FIELD_MAP", ":", "raise", "InvalidReturnFieldException", "(", "'\"{0}\" is an in...
:param return_fields: tuple :raises: pybomb.exceptions.InvalidReturnFieldException
[ ":", "param", "return_fields", ":", "tuple", ":", "raises", ":", "pybomb", ".", "exceptions", ".", "InvalidReturnFieldException" ]
python
train
41.1
mikedh/trimesh
trimesh/util.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/util.py#L1914-L1938
def isclose(a, b, atol): """ A replacement for np.isclose that does fewer checks and validation and as a result is roughly 4x faster. Note that this is used in tight loops, and as such a and b MUST be np.ndarray, not list or "array-like" Parameters ---------- a : np.ndarray To be...
[ "def", "isclose", "(", "a", ",", "b", ",", "atol", ")", ":", "diff", "=", "a", "-", "b", "close", "=", "np", ".", "logical_and", "(", "diff", ">", "-", "atol", ",", "diff", "<", "atol", ")", "return", "close" ]
A replacement for np.isclose that does fewer checks and validation and as a result is roughly 4x faster. Note that this is used in tight loops, and as such a and b MUST be np.ndarray, not list or "array-like" Parameters ---------- a : np.ndarray To be compared b : np.ndarray To...
[ "A", "replacement", "for", "np", ".", "isclose", "that", "does", "fewer", "checks", "and", "validation", "and", "as", "a", "result", "is", "roughly", "4x", "faster", "." ]
python
train
24.2
tamasgal/km3pipe
km3pipe/db.py
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L488-L502
def add_datetime(dataframe, timestamp_key='UNIXTIME'): """Add an additional DATETIME column with standar datetime format. This currently manipulates the incoming DataFrame! """ def convert_data(timestamp): return datetime.fromtimestamp(float(timestamp) / 1e3, UTC_TZ) try: log.debu...
[ "def", "add_datetime", "(", "dataframe", ",", "timestamp_key", "=", "'UNIXTIME'", ")", ":", "def", "convert_data", "(", "timestamp", ")", ":", "return", "datetime", ".", "fromtimestamp", "(", "float", "(", "timestamp", ")", "/", "1e3", ",", "UTC_TZ", ")", ...
Add an additional DATETIME column with standar datetime format. This currently manipulates the incoming DataFrame!
[ "Add", "an", "additional", "DATETIME", "column", "with", "standar", "datetime", "format", "." ]
python
train
35.066667
pytroll/satpy
satpy/readers/slstr_l1b.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/slstr_l1b.py#L283-L295
def get_dataset(self, key, info): """Load a dataset.""" logger.debug('Reading %s.', key.name) variable = self.nc[key.name] info.update(variable.attrs) info.update(key.to_dict()) info.update(dict(platform_name=self.platform_name, sensor=self.sens...
[ "def", "get_dataset", "(", "self", ",", "key", ",", "info", ")", ":", "logger", ".", "debug", "(", "'Reading %s.'", ",", "key", ".", "name", ")", "variable", "=", "self", ".", "nc", "[", "key", ".", "name", "]", "info", ".", "update", "(", "variabl...
Load a dataset.
[ "Load", "a", "dataset", "." ]
python
train
28.230769
shichao-an/115wangpan
u115/api.py
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1648-L1659
def list(self, count=30, order='user_ptime', asc=False, show_dir=True, natsort=True): """ List files of the associated directory to this task. :param int count: number of entries to be listed :param str order: originally named `o` :param bool asc: whether in ascendi...
[ "def", "list", "(", "self", ",", "count", "=", "30", ",", "order", "=", "'user_ptime'", ",", "asc", "=", "False", ",", "show_dir", "=", "True", ",", "natsort", "=", "True", ")", ":", "return", "self", ".", "directory", ".", "list", "(", "count", ",...
List files of the associated directory to this task. :param int count: number of entries to be listed :param str order: originally named `o` :param bool asc: whether in ascending order :param bool show_dir: whether to show directories
[ "List", "files", "of", "the", "associated", "directory", "to", "this", "task", "." ]
python
train
38.416667
ottogroup/palladium
palladium/util.py
https://github.com/ottogroup/palladium/blob/f3a4372fba809efbd8da7c979a8c6faff04684dd/palladium/util.py#L227-L245
def upgrade_cmd(argv=sys.argv[1:]): # pragma: no cover """\ Upgrade the database to the latest version. Usage: pld-ugprade [options] Options: --from=<v> Upgrade from a specific version, overriding the version stored in the database. --to=<v> Upgrade...
[ "def", "upgrade_cmd", "(", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", ")", ":", "# pragma: no cover", "arguments", "=", "docopt", "(", "upgrade_cmd", ".", "__doc__", ",", "argv", "=", "argv", ")", "initialize_config", "(", "__mode__", "=", "'fi...
\ Upgrade the database to the latest version. Usage: pld-ugprade [options] Options: --from=<v> Upgrade from a specific version, overriding the version stored in the database. --to=<v> Upgrade to a specific version instead of the ...
[ "\\", "Upgrade", "the", "database", "to", "the", "latest", "version", "." ]
python
train
31.631579
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/amazon/api.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/amazon/api.py#L433-L468
def price_and_currency(self): """Get Offer Price and Currency. Return price according to the following process: * If product has a sale return Sales Price, otherwise, * Return Price, otherwise, * Return lowest offer price, otherwise, * Return None. :return: ...
[ "def", "price_and_currency", "(", "self", ")", ":", "price", "=", "self", ".", "_safe_get_element_text", "(", "'Offers.Offer.OfferListing.SalePrice.Amount'", ")", "if", "price", ":", "currency", "=", "self", ".", "_safe_get_element_text", "(", "'Offers.Offer.OfferListin...
Get Offer Price and Currency. Return price according to the following process: * If product has a sale return Sales Price, otherwise, * Return Price, otherwise, * Return lowest offer price, otherwise, * Return None. :return: A tuple containing: ...
[ "Get", "Offer", "Price", "and", "Currency", "." ]
python
test
35.833333
materialsproject/custodian
custodian/custodian.py
https://github.com/materialsproject/custodian/blob/b33b01574fc899f959acb3c495398fd3d0fc41d0/custodian/custodian.py#L489-L596
def run_interrupted(self): """ Runs custodian in a interuppted mode, which sets up and validates jobs but doesn't run the executable Returns: number of remaining jobs Raises: ValidationError: if a job fails validation ReturnCodeError: if the ...
[ "def", "run_interrupted", "(", "self", ")", ":", "start", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "try", ":", "cwd", "=", "os", ".", "getcwd", "(", ")", "v", "=", "sys", ".", "version", ".", "replace", "(", "\"\\n\"", ",", "\" \"", ...
Runs custodian in a interuppted mode, which sets up and validates jobs but doesn't run the executable Returns: number of remaining jobs Raises: ValidationError: if a job fails validation ReturnCodeError: if the process has a return code different from 0 ...
[ "Runs", "custodian", "in", "a", "interuppted", "mode", "which", "sets", "up", "and", "validates", "jobs", "but", "doesn", "t", "run", "the", "executable" ]
python
train
43.5
arviz-devs/arviz
arviz/stats/stats.py
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L48-L251
def compare( dataset_dict, ic="waic", method="BB-pseudo-BMA", b_samples=1000, alpha=1, seed=None, scale="deviance", ): r"""Compare models based on WAIC or LOO cross validation. WAIC is Widely applicable information criterion, and LOO is leave-one-out (LOO) cross-validation. Read...
[ "def", "compare", "(", "dataset_dict", ",", "ic", "=", "\"waic\"", ",", "method", "=", "\"BB-pseudo-BMA\"", ",", "b_samples", "=", "1000", ",", "alpha", "=", "1", ",", "seed", "=", "None", ",", "scale", "=", "\"deviance\"", ",", ")", ":", "names", "=",...
r"""Compare models based on WAIC or LOO cross validation. WAIC is Widely applicable information criterion, and LOO is leave-one-out (LOO) cross-validation. Read more theory here - in a paper by some of the leading authorities on model selection - dx.doi.org/10.1111/1467-9868.00353 Parameters -----...
[ "r", "Compare", "models", "based", "on", "WAIC", "or", "LOO", "cross", "validation", "." ]
python
train
37.77451
dsoprea/pytzPure
pytzpure/tz_descriptor.py
https://github.com/dsoprea/pytzPure/blob/ec8f7803ca1025d363ba954905ae7717a0524a0e/pytzpure/tz_descriptor.py#L36-L76
def create_from_pytz(cls, tz_info): """Create an instance using the result of the timezone() call in "pytz". """ zone_name = tz_info.zone utc_transition_times_list_raw = getattr(tz_info, '_utc_transition_times', ...
[ "def", "create_from_pytz", "(", "cls", ",", "tz_info", ")", ":", "zone_name", "=", "tz_info", ".", "zone", "utc_transition_times_list_raw", "=", "getattr", "(", "tz_info", ",", "'_utc_transition_times'", ",", "None", ")", "utc_transition_times_list", "=", "[", "tu...
Create an instance using the result of the timezone() call in "pytz".
[ "Create", "an", "instance", "using", "the", "result", "of", "the", "timezone", "()", "call", "in", "pytz", "." ]
python
test
40.341463
Fizzadar/pyinfra
pyinfra/api/util.py
https://github.com/Fizzadar/pyinfra/blob/006f751f7db2e07d32522c0285160783de2feb79/pyinfra/api/util.py#L202-L224
def get_template(filename_or_string, is_string=False): ''' Gets a jinja2 ``Template`` object for the input filename or string, with caching based on the filename of the template, or the SHA1 of the input string. ''' # Cache against string sha or just the filename cache_key = sha1_hash(filename_...
[ "def", "get_template", "(", "filename_or_string", ",", "is_string", "=", "False", ")", ":", "# Cache against string sha or just the filename", "cache_key", "=", "sha1_hash", "(", "filename_or_string", ")", "if", "is_string", "else", "filename_or_string", "if", "cache_key"...
Gets a jinja2 ``Template`` object for the input filename or string, with caching based on the filename of the template, or the SHA1 of the input string.
[ "Gets", "a", "jinja2", "Template", "object", "for", "the", "input", "filename", "or", "string", "with", "caching", "based", "on", "the", "filename", "of", "the", "template", "or", "the", "SHA1", "of", "the", "input", "string", "." ]
python
train
34.347826
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py#L3370-L3398
def get_users_of_account_group(self, account_id, group_id, **kwargs): # noqa: E501 """Get users of a group. # noqa: E501 An endpoint for listing users of the group with details. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/policy-groups/{groupID}/users -H 'Au...
[ "def", "get_users_of_account_group", "(", "self", ",", "account_id", ",", "group_id", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'asynchronous'", ")", ":", ...
Get users of a group. # noqa: E501 An endpoint for listing users of the group with details. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/policy-groups/{groupID}/users -H 'Authorization: Bearer API_KEY'` # noqa: E501 This method makes a synchronous HTTP reques...
[ "Get", "users", "of", "a", "group", ".", "#", "noqa", ":", "E501" ]
python
train
66.310345
jhuapl-boss/intern
intern/service/boss/volume.py
https://github.com/jhuapl-boss/intern/blob/d8fc6df011d8f212c87e6a1fd4cc21cfb5d103ed/intern/service/boss/volume.py#L174-L192
def get_neuroglancer_link(self, resource, resolution, x_range, y_range, z_range, **kwargs): """ Get a neuroglancer link of the cutout specified from the host specified in the remote configuration step. Args: resource (intern.resource.Resource): Resource compatible with cutout opera...
[ "def", "get_neuroglancer_link", "(", "self", ",", "resource", ",", "resolution", ",", "x_range", ",", "y_range", ",", "z_range", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "get_neuroglancer_link", "(", "resource", ",", "resolut...
Get a neuroglancer link of the cutout specified from the host specified in the remote configuration step. Args: resource (intern.resource.Resource): Resource compatible with cutout operations. resolution (int): 0 indicates native resolution. x_range (list[int]): x range suc...
[ "Get", "a", "neuroglancer", "link", "of", "the", "cutout", "specified", "from", "the", "host", "specified", "in", "the", "remote", "configuration", "step", "." ]
python
train
52.368421
google/grr
grr/core/grr_response_core/lib/type_info.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/type_info.py#L285-L316
def ParseArgs(self, args): """Parse and validate the args. Note we pop all the args we consume here - so if there are any args we dont know about, args will not be an empty dict after this. This allows the same args to be parsed by several TypeDescriptorSets. Args: args: A dictionary of argu...
[ "def", "ParseArgs", "(", "self", ",", "args", ")", ":", "for", "descriptor", "in", "self", ":", "# Get the value from the kwargs or, if not specified, the default.", "value", "=", "args", ".", "pop", "(", "descriptor", ".", "name", ",", "None", ")", "if", "value...
Parse and validate the args. Note we pop all the args we consume here - so if there are any args we dont know about, args will not be an empty dict after this. This allows the same args to be parsed by several TypeDescriptorSets. Args: args: A dictionary of arguments that this TypeDescriptorSet ...
[ "Parse", "and", "validate", "the", "args", "." ]
python
train
34.75
aio-libs/aioredis
aioredis/commands/streams.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/streams.py#L101-L108
def xrange(self, stream, start='-', stop='+', count=None): """Retrieve messages from a stream.""" if count is not None: extra = ['COUNT', count] else: extra = [] fut = self.execute(b'XRANGE', stream, start, stop, *extra) return wait_convert(fut, parse_mess...
[ "def", "xrange", "(", "self", ",", "stream", ",", "start", "=", "'-'", ",", "stop", "=", "'+'", ",", "count", "=", "None", ")", ":", "if", "count", "is", "not", "None", ":", "extra", "=", "[", "'COUNT'", ",", "count", "]", "else", ":", "extra", ...
Retrieve messages from a stream.
[ "Retrieve", "messages", "from", "a", "stream", "." ]
python
train
39.75
oubiga/respect
respect/spelling.py
https://github.com/oubiga/respect/blob/550554ec4d3139379d03cb8f82a8cd2d80c3ad62/respect/spelling.py#L15-L31
def spellchecker(word): """ Looks for possible typos, i.e., deletion, insertion, transposition and alteration. If the target is 'audreyr': deletion is 'adreyr', insertion is 'audreeyr', transposition is 'aurdeyr' and alteration is 'audriyr'. Returns a list of possible words sorted by matching the s...
[ "def", "spellchecker", "(", "word", ")", ":", "splits", "=", "[", "(", "word", "[", ":", "i", "]", ",", "word", "[", "i", ":", "]", ")", "for", "i", "in", "range", "(", "len", "(", "word", ")", "+", "1", ")", "]", "deletes", "=", "[", "a", ...
Looks for possible typos, i.e., deletion, insertion, transposition and alteration. If the target is 'audreyr': deletion is 'adreyr', insertion is 'audreeyr', transposition is 'aurdeyr' and alteration is 'audriyr'. Returns a list of possible words sorted by matching the same length.
[ "Looks", "for", "possible", "typos", "i", ".", "e", ".", "deletion", "insertion", "transposition", "and", "alteration", ".", "If", "the", "target", "is", "audreyr", ":", "deletion", "is", "adreyr", "insertion", "is", "audreeyr", "transposition", "is", "aurdeyr...
python
train
50.117647
bitlabstudio/python-server-metrics
server_metrics/memory.py
https://github.com/bitlabstudio/python-server-metrics/blob/5f61e02db549a727d3d1d8e11ad2672728da3c4a/server_metrics/memory.py#L5-L31
def get_memory_usage(user=None): """ Returns a three-tupel with memory usage for the given user. The result contains:: (total memory, largest process' memory, largest process name) :param user: String representing the user. If `None`, the total size of all processes for all users will b...
[ "def", "get_memory_usage", "(", "user", "=", "None", ")", ":", "total", "=", "0", "largest_process", "=", "0", "largest_process_name", "=", "None", "for", "p", "in", "psutil", ".", "process_iter", "(", ")", ":", "p_user", "=", "p", ".", "username", "(", ...
Returns a three-tupel with memory usage for the given user. The result contains:: (total memory, largest process' memory, largest process name) :param user: String representing the user. If `None`, the total size of all processes for all users will be returned.
[ "Returns", "a", "three", "-", "tupel", "with", "memory", "usage", "for", "the", "given", "user", "." ]
python
train
32.037037
Jajcus/pyxmpp2
pyxmpp2/xmppserializer.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/xmppserializer.py#L88-L104
def add_prefix(self, namespace, prefix): """Add a new namespace prefix. If the root element has not yet been emitted the prefix will be declared there, otherwise the prefix will be declared on the top-most element using this namespace in every stanza. :Parameters: -...
[ "def", "add_prefix", "(", "self", ",", "namespace", ",", "prefix", ")", ":", "if", "prefix", "==", "\"xml\"", "and", "namespace", "!=", "XML_NS", ":", "raise", "ValueError", ",", "\"Cannot change 'xml' prefix meaning\"", "self", ".", "_prefixes", "[", "namespace...
Add a new namespace prefix. If the root element has not yet been emitted the prefix will be declared there, otherwise the prefix will be declared on the top-most element using this namespace in every stanza. :Parameters: - `namespace`: the namespace URI - `prefi...
[ "Add", "a", "new", "namespace", "prefix", "." ]
python
valid
37.529412
saltstack/salt
salt/modules/boto3_route53.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto3_route53.py#L703-L721
def delete_hosted_zone_by_domain(Name, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ''' Delete a Route53 hosted zone by domain name, and PrivateZone status if provided. CLI Example:: salt myminion boto3_route53.delete_hosted_zone_by_domain ex...
[ "def", "delete_hosted_zone_by_domain", "(", "Name", ",", "PrivateZone", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "args", "=", "{", "'Name'", ":", "Name", ",", ...
Delete a Route53 hosted zone by domain name, and PrivateZone status if provided. CLI Example:: salt myminion boto3_route53.delete_hosted_zone_by_domain example.org.
[ "Delete", "a", "Route53", "hosted", "zone", "by", "domain", "name", "and", "PrivateZone", "status", "if", "provided", "." ]
python
train
47.947368
Neurita/boyle
boyle/nifti/check.py
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/check.py#L94-L111
def is_valid_coordinate(img, i, j, k): """Return True if the given (i, j, k) voxel grid coordinate values are within the img boundaries. Parameters ---------- @param img: @param i: @param j: @param k: Returns ------- bool """ imgx, imgy, imgz = get_shape(img) return...
[ "def", "is_valid_coordinate", "(", "img", ",", "i", ",", "j", ",", "k", ")", ":", "imgx", ",", "imgy", ",", "imgz", "=", "get_shape", "(", "img", ")", "return", "(", "i", ">=", "0", "and", "i", "<", "imgx", ")", "and", "(", "j", ">=", "0", "a...
Return True if the given (i, j, k) voxel grid coordinate values are within the img boundaries. Parameters ---------- @param img: @param i: @param j: @param k: Returns ------- bool
[ "Return", "True", "if", "the", "given", "(", "i", "j", "k", ")", "voxel", "grid", "coordinate", "values", "are", "within", "the", "img", "boundaries", "." ]
python
valid
22.388889
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/drivers/dev_mgr.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/drivers/dev_mgr.py#L65-L75
def populate_fw_dev(self, fw_id, mgmt_ip, new): """Populate the class after a restart. """ for cnt in self.res: used = self.res.get(cnt).get('used') if mgmt_ip == self.res[cnt].get('mgmt_ip'): if new: self.res[cnt]['used'] = used + 1 ...
[ "def", "populate_fw_dev", "(", "self", ",", "fw_id", ",", "mgmt_ip", ",", "new", ")", ":", "for", "cnt", "in", "self", ".", "res", ":", "used", "=", "self", ".", "res", ".", "get", "(", "cnt", ")", ".", "get", "(", "'used'", ")", "if", "mgmt_ip",...
Populate the class after a restart.
[ "Populate", "the", "class", "after", "a", "restart", "." ]
python
train
44.363636
CS207-Final-Project-Group-10/cs207-FinalProject
fluxions/fluxion_jacobian.py
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_jacobian.py#L49-L74
def jacobian(f, v, v_mapping): """ f: single fluxion object or an array or list of fluxions, representing a scalar or vector function v: vector of variables in f with respect to which the Jacobian will be calculated v_mapping: dict mapping variables in f to scalar or vector of values ""...
[ "def", "jacobian", "(", "f", ",", "v", ",", "v_mapping", ")", ":", "# make sure f is in the form np.array([fl1, ...])", "if", "isinstance", "(", "f", ",", "Fluxion", ")", ":", "f", "=", "[", "f", "]", "f", "=", "np", ".", "asarray", "(", "f", ")", "v",...
f: single fluxion object or an array or list of fluxions, representing a scalar or vector function v: vector of variables in f with respect to which the Jacobian will be calculated v_mapping: dict mapping variables in f to scalar or vector of values
[ "f", ":", "single", "fluxion", "object", "or", "an", "array", "or", "list", "of", "fluxions", "representing", "a", "scalar", "or", "vector", "function", "v", ":", "vector", "of", "variables", "in", "f", "with", "respect", "to", "which", "the", "Jacobian", ...
python
train
30.846154
Bearle/django-private-chat
django_private_chat/handlers.py
https://github.com/Bearle/django-private-chat/blob/5b51e65875795c5c0ce21bb631c53bd3aac4c26b/django_private_chat/handlers.py#L169-L188
def users_changed_handler(stream): """ Sends connected client list of currently active users in the chatroom """ while True: yield from stream.get() # Get list list of current active users users = [ {'username': username, 'uuid': uuid_str} for u...
[ "def", "users_changed_handler", "(", "stream", ")", ":", "while", "True", ":", "yield", "from", "stream", ".", "get", "(", ")", "# Get list list of current active users\r", "users", "=", "[", "{", "'username'", ":", "username", ",", "'uuid'", ":", "uuid_str", ...
Sends connected client list of currently active users in the chatroom
[ "Sends", "connected", "client", "list", "of", "currently", "active", "users", "in", "the", "chatroom" ]
python
train
32.75
ANTsX/ANTsPy
ants/viz/plot.py
https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/viz/plot.py#L345-L619
def plot_ortho_stack(images, overlays=None, reorient=True, # xyz arguments xyz=None, xyz_lines=False, xyz_color='red', xyz_alpha=0.6, xyz_linewidth=2, xyz_pad=5, # base image arguments cmap='Greys_r', alpha=1, # overlay arguments overlay_cmap='jet', overlay_alpha=0.9, # background arguments...
[ "def", "plot_ortho_stack", "(", "images", ",", "overlays", "=", "None", ",", "reorient", "=", "True", ",", "# xyz arguments", "xyz", "=", "None", ",", "xyz_lines", "=", "False", ",", "xyz_color", "=", "'red'", ",", "xyz_alpha", "=", "0.6", ",", "xyz_linewi...
Example ------- >>> import ants >>> mni = ants.image_read(ants.get_data('mni')) >>> ch2 = ants.image_read(ants.get_data('ch2')) >>> ants.plot_ortho_stack([mni,mni,mni])
[ "Example", "-------", ">>>", "import", "ants", ">>>", "mni", "=", "ants", ".", "image_read", "(", "ants", ".", "get_data", "(", "mni", "))", ">>>", "ch2", "=", "ants", ".", "image_read", "(", "ants", ".", "get_data", "(", "ch2", "))", ">>>", "ants", ...
python
train
38.865455
MKLab-ITI/reveal-user-annotation
reveal_user_annotation/mongo/preprocess_data.py
https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/mongo/preprocess_data.py#L149-L512
def extract_graphs_and_lemmas_from_tweets(tweet_generator): """ Given a tweet python generator, we encode the information into mention and retweet graphs and a lemma matrix. We assume that the tweets are given in increasing timestamp. Inputs: - tweet_generator: A python generator of tweets in python ...
[ "def", "extract_graphs_and_lemmas_from_tweets", "(", "tweet_generator", ")", ":", "####################################################################################################################", "# Prepare for iterating over tweets.", "#########################################################...
Given a tweet python generator, we encode the information into mention and retweet graphs and a lemma matrix. We assume that the tweets are given in increasing timestamp. Inputs: - tweet_generator: A python generator of tweets in python dictionary (json) format. Outputs: - mention_graph: The mention gra...
[ "Given", "a", "tweet", "python", "generator", "we", "encode", "the", "information", "into", "mention", "and", "retweet", "graphs", "and", "a", "lemma", "matrix", "." ]
python
train
50.151099
splunk/splunk-sdk-python
examples/analytics/bottle.py
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L1611-L1627
def validate(**vkargs): """ Validates and manipulates keyword arguments by user defined callables. Handles ValueError and missing arguments by raising HTTPError(403). """ def decorator(func): def wrapper(**kargs): for key, value in six.iteritems(vkargs): if key no...
[ "def", "validate", "(", "*", "*", "vkargs", ")", ":", "def", "decorator", "(", "func", ")", ":", "def", "wrapper", "(", "*", "*", "kargs", ")", ":", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "vkargs", ")", ":", "if", "key", ...
Validates and manipulates keyword arguments by user defined callables. Handles ValueError and missing arguments by raising HTTPError(403).
[ "Validates", "and", "manipulates", "keyword", "arguments", "by", "user", "defined", "callables", ".", "Handles", "ValueError", "and", "missing", "arguments", "by", "raising", "HTTPError", "(", "403", ")", "." ]
python
train
37.176471
tensorflow/probability
tensorflow_probability/python/bijectors/transpose.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/transpose.py#L291-L318
def _maybe_validate_perm(perm, validate_args, name=None): """Checks that `perm` is valid.""" with tf.name_scope(name or 'maybe_validate_perm'): assertions = [] if not dtype_util.is_integer(perm.dtype): raise TypeError('`perm` must be integer type') msg = '`perm` must be a vector.' if tensorsh...
[ "def", "_maybe_validate_perm", "(", "perm", ",", "validate_args", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "'maybe_validate_perm'", ")", ":", "assertions", "=", "[", "]", "if", "not", "dtype_util", ".", "is_in...
Checks that `perm` is valid.
[ "Checks", "that", "perm", "is", "valid", "." ]
python
test
36.785714
jrief/djangocms-cascade
cmsplugin_cascade/plugin_base.py
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/plugin_base.py#L35-L53
def create_proxy_model(name, model_mixins, base_model, attrs=None, module=None): """ Create a Django Proxy Model on the fly, to be used by any Cascade Plugin. """ from django.apps import apps class Meta: proxy = True app_label = 'cmsplugin_cascade' name = str(name + 'Model') ...
[ "def", "create_proxy_model", "(", "name", ",", "model_mixins", ",", "base_model", ",", "attrs", "=", "None", ",", "module", "=", "None", ")", ":", "from", "django", ".", "apps", "import", "apps", "class", "Meta", ":", "proxy", "=", "True", "app_label", "...
Create a Django Proxy Model on the fly, to be used by any Cascade Plugin.
[ "Create", "a", "Django", "Proxy", "Model", "on", "the", "fly", "to", "be", "used", "by", "any", "Cascade", "Plugin", "." ]
python
train
31.736842
brutasse/graphite-api
graphite_api/functions.py
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L3473-L3496
def identity(requestContext, name, step=60): """ Identity function: Returns datapoints where the value equals the timestamp of the datapoint. Useful when you have another series where the value is a timestamp, and you want to compare it to the time of the datapoint, to render an age Example:: ...
[ "def", "identity", "(", "requestContext", ",", "name", ",", "step", "=", "60", ")", ":", "start", "=", "int", "(", "epoch", "(", "requestContext", "[", "\"startTime\"", "]", ")", ")", "end", "=", "int", "(", "epoch", "(", "requestContext", "[", "\"endT...
Identity function: Returns datapoints where the value equals the timestamp of the datapoint. Useful when you have another series where the value is a timestamp, and you want to compare it to the time of the datapoint, to render an age Example:: &target=identity("The.time.series") This wou...
[ "Identity", "function", ":", "Returns", "datapoints", "where", "the", "value", "equals", "the", "timestamp", "of", "the", "datapoint", ".", "Useful", "when", "you", "have", "another", "series", "where", "the", "value", "is", "a", "timestamp", "and", "you", "...
python
train
33.291667
adammck/djtables
lib/djtables/urls.py
https://github.com/adammck/djtables/blob/8fa279e7088123f00cca9c838fe028ebf327325e/lib/djtables/urls.py#L8-L28
def extract(query_dict, prefix=""): """ Extract the *order_by*, *per_page*, and *page* parameters from `query_dict` (a Django QueryDict), and return a dict suitable for instantiating a preconfigured Table object. """ strs = ['order_by'] ints = ['per_page', 'page'] extracted = { } ...
[ "def", "extract", "(", "query_dict", ",", "prefix", "=", "\"\"", ")", ":", "strs", "=", "[", "'order_by'", "]", "ints", "=", "[", "'per_page'", ",", "'page'", "]", "extracted", "=", "{", "}", "for", "key", "in", "(", "strs", "+", "ints", ")", ":", ...
Extract the *order_by*, *per_page*, and *page* parameters from `query_dict` (a Django QueryDict), and return a dict suitable for instantiating a preconfigured Table object.
[ "Extract", "the", "*", "order_by", "*", "*", "per_page", "*", "and", "*", "page", "*", "parameters", "from", "query_dict", "(", "a", "Django", "QueryDict", ")", "and", "return", "a", "dict", "suitable", "for", "instantiating", "a", "preconfigured", "Table", ...
python
train
25.52381
duniter/duniter-python-api
duniterpy/api/endpoint.py
https://github.com/duniter/duniter-python-api/blob/3a1e5d61a2f72f5afaf29d010c6cf4dff3648165/duniterpy/api/endpoint.py#L270-L283
def conn_handler(self, session: ClientSession, proxy: str = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint :param session: AIOHTTP client session instance :param proxy: Proxy url :return: """ if self.server: return...
[ "def", "conn_handler", "(", "self", ",", "session", ":", "ClientSession", ",", "proxy", ":", "str", "=", "None", ")", "->", "ConnectionHandler", ":", "if", "self", ".", "server", ":", "return", "ConnectionHandler", "(", "\"https\"", ",", "\"wss\"", ",", "s...
Return connection handler instance for the endpoint :param session: AIOHTTP client session instance :param proxy: Proxy url :return:
[ "Return", "connection", "handler", "instance", "for", "the", "endpoint" ]
python
train
45.214286
pyvisa/pyvisa-sim
pyvisa-sim/parser.py
https://github.com/pyvisa/pyvisa-sim/blob/9836166b6b57c165fc63a276f87fe81f106a4e26/pyvisa-sim/parser.py#L71-L79
def _get_triplet(dd): """Return a triplet from a dialogue dictionary. :param dd: Dialogue dictionary. :type dd: Dict[str, str] :return: (query, response, error response) :rtype: (str, str | NoResponse, str | NoResponse) """ return _s(dd['q']), _s(dd.get('r', NoResponse)), _s(dd.get('e', NoR...
[ "def", "_get_triplet", "(", "dd", ")", ":", "return", "_s", "(", "dd", "[", "'q'", "]", ")", ",", "_s", "(", "dd", ".", "get", "(", "'r'", ",", "NoResponse", ")", ")", ",", "_s", "(", "dd", ".", "get", "(", "'e'", ",", "NoResponse", ")", ")" ...
Return a triplet from a dialogue dictionary. :param dd: Dialogue dictionary. :type dd: Dict[str, str] :return: (query, response, error response) :rtype: (str, str | NoResponse, str | NoResponse)
[ "Return", "a", "triplet", "from", "a", "dialogue", "dictionary", "." ]
python
train
35.666667
TeamHG-Memex/eli5
eli5/lime/utils.py
https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/utils.py#L51-L70
def fix_multiclass_predict_proba(y_proba, # type: np.ndarray seen_classes, complete_classes ): # type: (...) -> np.ndarray """ Add missing columns to predict_proba result. When a multiclass class...
[ "def", "fix_multiclass_predict_proba", "(", "y_proba", ",", "# type: np.ndarray", "seen_classes", ",", "complete_classes", ")", ":", "# type: (...) -> np.ndarray", "assert", "set", "(", "complete_classes", ")", ">=", "set", "(", "seen_classes", ")", "y_proba_fixed", "="...
Add missing columns to predict_proba result. When a multiclass classifier is fit on a dataset which only contains a subset of possible classes its predict_proba result only has columns corresponding to seen classes. This function adds missing columns.
[ "Add", "missing", "columns", "to", "predict_proba", "result", "." ]
python
train
40.75
NicolasLM/spinach
spinach/brokers/redis.py
https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/redis.py#L145-L158
def get_jobs_from_queue(self, queue: str, max_jobs: int) -> List[Job]: """Get jobs from a queue.""" jobs_json_string = self._run_script( self._get_jobs_from_queue, self._to_namespaced(queue), self._to_namespaced(RUNNING_JOBS_KEY.format(self._id)), JobStatu...
[ "def", "get_jobs_from_queue", "(", "self", ",", "queue", ":", "str", ",", "max_jobs", ":", "int", ")", "->", "List", "[", "Job", "]", ":", "jobs_json_string", "=", "self", ".", "_run_script", "(", "self", ".", "_get_jobs_from_queue", ",", "self", ".", "_...
Get jobs from a queue.
[ "Get", "jobs", "from", "a", "queue", "." ]
python
train
34.5
carpedm20/fbchat
fbchat/_client.py
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1879-L1888
def changeGroupImageRemote(self, image_url, thread_id=None): """ Changes a thread image from a URL :param image_url: URL of an image to upload and change :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed ...
[ "def", "changeGroupImageRemote", "(", "self", ",", "image_url", ",", "thread_id", "=", "None", ")", ":", "(", "image_id", ",", "mimetype", ")", ",", "=", "self", ".", "_upload", "(", "get_files_from_urls", "(", "[", "image_url", "]", ")", ")", "return", ...
Changes a thread image from a URL :param image_url: URL of an image to upload and change :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed
[ "Changes", "a", "thread", "image", "from", "a", "URL" ]
python
train
45.2
bububa/pyTOP
pyTOP/simba.py
https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/simba.py#L310-L322
def add(self, campaign_id, item_id, default_price, title, img_url, nick=None): '''xxxxx.xxxxx.adgroup.add =================================== 创建一个推广组''' request = TOPRequest('xxxxx.xxxxx.adgroup.add') request['campaign_id'] = campaign_id request['item_id'] = item_id ...
[ "def", "add", "(", "self", ",", "campaign_id", ",", "item_id", ",", "default_price", ",", "title", ",", "img_url", ",", "nick", "=", "None", ")", ":", "request", "=", "TOPRequest", "(", "'xxxxx.xxxxx.adgroup.add'", ")", "request", "[", "'campaign_id'", "]", ...
xxxxx.xxxxx.adgroup.add =================================== 创建一个推广组
[ "xxxxx", ".", "xxxxx", ".", "adgroup", ".", "add", "===================================", "创建一个推广组" ]
python
train
48.769231
scanny/python-pptx
pptx/oxml/table.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/oxml/table.py#L485-L489
def in_same_table(self): """True if both cells provided to constructor are in same table.""" if self._tc.tbl is self._other_tc.tbl: return True return False
[ "def", "in_same_table", "(", "self", ")", ":", "if", "self", ".", "_tc", ".", "tbl", "is", "self", ".", "_other_tc", ".", "tbl", ":", "return", "True", "return", "False" ]
True if both cells provided to constructor are in same table.
[ "True", "if", "both", "cells", "provided", "to", "constructor", "are", "in", "same", "table", "." ]
python
train
37.6
hazelcast/hazelcast-python-client
hazelcast/connection.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/connection.py#L167-L180
def close_connection(self, address, cause): """ Closes the connection with given address. :param address: (:class:`~hazelcast.core.Address`), address of the connection to be closed. :param cause: (Exception), the cause for closing the connection. :return: (bool), ``true`` if the...
[ "def", "close_connection", "(", "self", ",", "address", ",", "cause", ")", ":", "try", ":", "connection", "=", "self", ".", "connections", "[", "address", "]", "connection", ".", "close", "(", "cause", ")", "except", "KeyError", ":", "self", ".", "logger...
Closes the connection with given address. :param address: (:class:`~hazelcast.core.Address`), address of the connection to be closed. :param cause: (Exception), the cause for closing the connection. :return: (bool), ``true`` if the connection is closed, ``false`` otherwise.
[ "Closes", "the", "connection", "with", "given", "address", "." ]
python
train
44.642857
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/tfvc/tfvc_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/tfvc/tfvc_client.py#L699-L731
def get_shelvesets(self, request_data=None, top=None, skip=None): """GetShelvesets. Return a collection of shallow shelveset references. :param :class:`<TfvcShelvesetRequestData> <azure.devops.v5_0.tfvc.models.TfvcShelvesetRequestData>` request_data: name, owner, and maxCommentLength :pa...
[ "def", "get_shelvesets", "(", "self", ",", "request_data", "=", "None", ",", "top", "=", "None", ",", "skip", "=", "None", ")", ":", "query_parameters", "=", "{", "}", "if", "request_data", "is", "not", "None", ":", "if", "request_data", ".", "name", "...
GetShelvesets. Return a collection of shallow shelveset references. :param :class:`<TfvcShelvesetRequestData> <azure.devops.v5_0.tfvc.models.TfvcShelvesetRequestData>` request_data: name, owner, and maxCommentLength :param int top: Max number of shelvesets to return :param int skip: Numb...
[ "GetShelvesets", ".", "Return", "a", "collection", "of", "shallow", "shelveset", "references", ".", ":", "param", ":", "class", ":", "<TfvcShelvesetRequestData", ">", "<azure", ".", "devops", ".", "v5_0", ".", "tfvc", ".", "models", ".", "TfvcShelvesetRequestDat...
python
train
62.484848
CodyKochmann/stricttuple
build/lib/stricttuple/__init__.py
https://github.com/CodyKochmann/stricttuple/blob/072cbd6f7b90f3f666dc0f2c10ab6056d86dfc72/build/lib/stricttuple/__init__.py#L45-L56
def validate_fields(self, **kwargs): """ ensures that all incoming fields are the types that were specified """ for field in self.fields: value = kwargs[field] required_type = self.fields[field] if type(value) != required_type: raise TypeError('{}.{} n...
[ "def", "validate_fields", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "field", "in", "self", ".", "fields", ":", "value", "=", "kwargs", "[", "field", "]", "required_type", "=", "self", ".", "fields", "[", "field", "]", "if", "type", "(", ...
ensures that all incoming fields are the types that were specified
[ "ensures", "that", "all", "incoming", "fields", "are", "the", "types", "that", "were", "specified" ]
python
train
44.5
aouyar/PyMunin
pysysinfo/postgresql.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/postgresql.py#L275-L306
def getXlogStatus(self): """Returns Transaction Logging or Recovery Status. @return: Dictionary of status items. """ inRecovery = None if self.checkVersion('9.0'): inRecovery = self._simpleQuery("SELECT pg_is_in_recovery();") cur = self._conn...
[ "def", "getXlogStatus", "(", "self", ")", ":", "inRecovery", "=", "None", "if", "self", ".", "checkVersion", "(", "'9.0'", ")", ":", "inRecovery", "=", "self", ".", "_simpleQuery", "(", "\"SELECT pg_is_in_recovery();\"", ")", "cur", "=", "self", ".", "_conn"...
Returns Transaction Logging or Recovery Status. @return: Dictionary of status items.
[ "Returns", "Transaction", "Logging", "or", "Recovery", "Status", "." ]
python
train
41.8125
StackStorm/pybind
pybind/slxos/v17s_1_02/rule/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/rule/__init__.py#L134-L155
def _set_action(self, v, load=False): """ Setter method for action, mapped from YANG variable /rule/action (rule-action) If this variable is read-only (config: false) in the source YANG file, then _set_action is considered as a private method. Backends looking to populate this variable should do...
[ "def", "_set_action", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base", ...
Setter method for action, mapped from YANG variable /rule/action (rule-action) If this variable is read-only (config: false) in the source YANG file, then _set_action is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_action() directly.
[ "Setter", "method", "for", "action", "mapped", "from", "YANG", "variable", "/", "rule", "/", "action", "(", "rule", "-", "action", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG"...
python
train
86.227273
tomnor/channelpack
channelpack/pack.py
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L948-L984
def set_basefilemtime(self): """Set attributes mtimestamp and mtimefs. If the global list ORIGINEXTENSIONS include any items, try and look for files (in the directory where self.filename is sitting) with the same base name as the loaded file, but with an extension specified in OR...
[ "def", "set_basefilemtime", "(", "self", ")", ":", "dirpath", "=", "os", ".", "path", ".", "split", "(", "self", ".", "filename", ")", "[", "0", "]", "name", "=", "os", ".", "path", ".", "basename", "(", "self", ".", "fs", ")", ".", "split", "(",...
Set attributes mtimestamp and mtimefs. If the global list ORIGINEXTENSIONS include any items, try and look for files (in the directory where self.filename is sitting) with the same base name as the loaded file, but with an extension specified in ORIGINEXTENSIONS. mtimestamp is a...
[ "Set", "attributes", "mtimestamp", "and", "mtimefs", ".", "If", "the", "global", "list", "ORIGINEXTENSIONS", "include", "any", "items", "try", "and", "look", "for", "files", "(", "in", "the", "directory", "where", "self", ".", "filename", "is", "sitting", ")...
python
train
45.297297
dcramer/django-ratings
djangoratings/fields.py
https://github.com/dcramer/django-ratings/blob/4d00dedc920a4e32d650dc12d5f480c51fc6216c/djangoratings/fields.py#L62-L66
def get_ratings(self): """get_ratings() Returns a Vote QuerySet for this rating field.""" return Vote.objects.filter(content_type=self.get_content_type(), object_id=self.instance.pk, key=self.field.key)
[ "def", "get_ratings", "(", "self", ")", ":", "return", "Vote", ".", "objects", ".", "filter", "(", "content_type", "=", "self", ".", "get_content_type", "(", ")", ",", "object_id", "=", "self", ".", "instance", ".", "pk", ",", "key", "=", "self", ".", ...
get_ratings() Returns a Vote QuerySet for this rating field.
[ "get_ratings", "()", "Returns", "a", "Vote", "QuerySet", "for", "this", "rating", "field", "." ]
python
train
46.2
acutesoftware/AIKIF
aikif/web_app/web_utils.py
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L10-L28
def list2html(lst): """ convert a list to html using table formatting """ txt = '<TABLE width=100% border=0>' for l in lst: txt += '<TR>\n' if type(l) is str: txt+= '<TD>' + l + '</TD>\n' elif type(l) is list: txt+= '<TD>' for i in l: ...
[ "def", "list2html", "(", "lst", ")", ":", "txt", "=", "'<TABLE width=100% border=0>'", "for", "l", "in", "lst", ":", "txt", "+=", "'<TR>\\n'", "if", "type", "(", "l", ")", "is", "str", ":", "txt", "+=", "'<TD>'", "+", "l", "+", "'</TD>\\n'", "elif", ...
convert a list to html using table formatting
[ "convert", "a", "list", "to", "html", "using", "table", "formatting" ]
python
train
25.473684
UCBerkeleySETI/blimpy
blimpy/calib_utils/calib_plots.py
https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/calib_plots.py#L34-L74
def plot_Stokes_diode(dio_cross,diff=True,feedtype='l',**kwargs): ''' Plots the uncalibrated full stokes spectrum of the noise diode. Use diff=False to plot both ON and OFF, or diff=True for ON-OFF ''' #If diff=True, get ON-OFF. If not get ON and OFF separately if diff==True: Idiff,Qdif...
[ "def", "plot_Stokes_diode", "(", "dio_cross", ",", "diff", "=", "True", ",", "feedtype", "=", "'l'", ",", "*", "*", "kwargs", ")", ":", "#If diff=True, get ON-OFF. If not get ON and OFF separately", "if", "diff", "==", "True", ":", "Idiff", ",", "Qdiff", ",", ...
Plots the uncalibrated full stokes spectrum of the noise diode. Use diff=False to plot both ON and OFF, or diff=True for ON-OFF
[ "Plots", "the", "uncalibrated", "full", "stokes", "spectrum", "of", "the", "noise", "diode", ".", "Use", "diff", "=", "False", "to", "plot", "both", "ON", "and", "OFF", "or", "diff", "=", "True", "for", "ON", "-", "OFF" ]
python
test
36.365854
Clinical-Genomics/scout
scout/server/blueprints/variants/controllers.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/variants/controllers.py#L205-L277
def parse_variant(store, institute_obj, case_obj, variant_obj, update=False, genome_build='37', get_compounds = True): """Parse information about variants. - Adds information about compounds - Updates the information about compounds if necessary and 'update=True' Args: store(...
[ "def", "parse_variant", "(", "store", ",", "institute_obj", ",", "case_obj", ",", "variant_obj", ",", "update", "=", "False", ",", "genome_build", "=", "'37'", ",", "get_compounds", "=", "True", ")", ":", "has_changed", "=", "False", "compounds", "=", "varia...
Parse information about variants. - Adds information about compounds - Updates the information about compounds if necessary and 'update=True' Args: store(scout.adapter.MongoAdapter) institute_obj(scout.models.Institute) case_obj(scout.models.Case) variant_obj(scout.models.V...
[ "Parse", "information", "about", "variants", "." ]
python
test
41.506849
T-002/pycast
pycast/methods/regression.py
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/regression.py#L153-L168
def match_time_series(self, timeseries1, timeseries2): """Return two lists of the two input time series with matching dates :param TimeSeries timeseries1: The first timeseries :param TimeSeries timeseries2: The second timeseries :return: Two two dimensional lists containing the match...
[ "def", "match_time_series", "(", "self", ",", "timeseries1", ",", "timeseries2", ")", ":", "time1", "=", "map", "(", "lambda", "item", ":", "item", "[", "0", "]", ",", "timeseries1", ".", "to_twodim_list", "(", ")", ")", "time2", "=", "map", "(", "lamb...
Return two lists of the two input time series with matching dates :param TimeSeries timeseries1: The first timeseries :param TimeSeries timeseries2: The second timeseries :return: Two two dimensional lists containing the matched values, :rtype: two List
[ "Return", "two", "lists", "of", "the", "two", "input", "time", "series", "with", "matching", "dates" ]
python
train
47
hydpy-dev/hydpy
hydpy/models/dam/dam_model.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/dam/dam_model.py#L1994-L2092
def calc_flooddischarge_v1(self): """Calculate the discharge during and after a flood event based on an |anntools.SeasonalANN| describing the relationship(s) between discharge and water stage. Required control parameter: |WaterLevel2FloodDischarge| Required derived parameter: |dam_deri...
[ "def", "calc_flooddischarge_v1", "(", "self", ")", ":", "con", "=", "self", ".", "parameters", ".", "control", ".", "fastaccess", "der", "=", "self", ".", "parameters", ".", "derived", ".", "fastaccess", "flu", "=", "self", ".", "sequences", ".", "fluxes",...
Calculate the discharge during and after a flood event based on an |anntools.SeasonalANN| describing the relationship(s) between discharge and water stage. Required control parameter: |WaterLevel2FloodDischarge| Required derived parameter: |dam_derived.TOY| Required aide sequence: ...
[ "Calculate", "the", "discharge", "during", "and", "after", "a", "flood", "event", "based", "on", "an", "|anntools", ".", "SeasonalANN|", "describing", "the", "relationship", "(", "s", ")", "between", "discharge", "and", "water", "stage", "." ]
python
train
42.585859
jasonkeene/python-ubersmith
ubersmith/calls/__init__.py
https://github.com/jasonkeene/python-ubersmith/blob/0c594e2eb41066d1fe7860e3a6f04b14c14f6e6a/ubersmith/calls/__init__.py#L54-L62
def validate(self): """Validate request data before sending it out. Return True/False.""" # check if required_fields aren't present for field in set(self.required_fields) - set(self.request_data): if not isinstance(field, string_types): # field was a collection, itera...
[ "def", "validate", "(", "self", ")", ":", "# check if required_fields aren't present", "for", "field", "in", "set", "(", "self", ".", "required_fields", ")", "-", "set", "(", "self", ".", "request_data", ")", ":", "if", "not", "isinstance", "(", "field", ","...
Validate request data before sending it out. Return True/False.
[ "Validate", "request", "data", "before", "sending", "it", "out", ".", "Return", "True", "/", "False", "." ]
python
train
49.777778
podio/podio-py
pypodio2/areas.py
https://github.com/podio/podio-py/blob/5ce956034a06c98b0ef18fcd940b36da0908ad6c/pypodio2/areas.py#L82-L94
def find(self, item_id, basic=False, **kwargs): """ Get item :param item_id: Item ID :param basic: ? :type item_id: int :return: Item info :rtype: dict """ if basic: return self.transport.GET(url='/item/%d/basic' % item_id) ...
[ "def", "find", "(", "self", ",", "item_id", ",", "basic", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "basic", ":", "return", "self", ".", "transport", ".", "GET", "(", "url", "=", "'/item/%d/basic'", "%", "item_id", ")", "return", "self",...
Get item :param item_id: Item ID :param basic: ? :type item_id: int :return: Item info :rtype: dict
[ "Get", "item", ":", "param", "item_id", ":", "Item", "ID", ":", "param", "basic", ":", "?", ":", "type", "item_id", ":", "int", ":", "return", ":", "Item", "info", ":", "rtype", ":", "dict" ]
python
train
28.615385
senaite/senaite.core
bika/lims/controlpanel/bika_analysiscategories.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/controlpanel/bika_analysiscategories.py#L118-L139
def folderitem(self, obj, item, index): """Service triggered each time an item is iterated in folderitems. The use of this service prevents the extra-loops in child objects. :obj: the instance of the class to be foldered :item: dict containing the properties of the object to be used by ...
[ "def", "folderitem", "(", "self", ",", "obj", ",", "item", ",", "index", ")", ":", "title", "=", "obj", ".", "Title", "(", ")", "description", "=", "obj", ".", "Description", "(", ")", "url", "=", "obj", ".", "absolute_url", "(", ")", "item", "[", ...
Service triggered each time an item is iterated in folderitems. The use of this service prevents the extra-loops in child objects. :obj: the instance of the class to be foldered :item: dict containing the properties of the object to be used by the template :index: current ind...
[ "Service", "triggered", "each", "time", "an", "item", "is", "iterated", "in", "folderitems", ".", "The", "use", "of", "this", "service", "prevents", "the", "extra", "-", "loops", "in", "child", "objects", ".", ":", "obj", ":", "the", "instance", "of", "t...
python
train
37.363636
alefnula/tea
tea/shell/__init__.py
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L73-L91
def chdir(directory): """Change the current working directory. Args: directory (str): Directory to go to. """ directory = os.path.abspath(directory) logger.info("chdir -> %s" % directory) try: if not os.path.isdir(directory): logger.error( "chdir -> %...
[ "def", "chdir", "(", "directory", ")", ":", "directory", "=", "os", ".", "path", ".", "abspath", "(", "directory", ")", "logger", ".", "info", "(", "\"chdir -> %s\"", "%", "directory", ")", "try", ":", "if", "not", "os", ".", "path", ".", "isdir", "(...
Change the current working directory. Args: directory (str): Directory to go to.
[ "Change", "the", "current", "working", "directory", "." ]
python
train
28.842105
fermiPy/fermipy
fermipy/diffuse/source_factory.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L86-L135
def make_sources(comp_key, comp_dict): """Make dictionary mapping component keys to a source or set of sources Parameters ---------- comp_key : str Key used to access sources comp_dict : dict Information used to build sources return `OrderedDict` maping comp_key to `fermi...
[ "def", "make_sources", "(", "comp_key", ",", "comp_dict", ")", ":", "srcdict", "=", "OrderedDict", "(", ")", "try", ":", "comp_info", "=", "comp_dict", ".", "info", "except", "AttributeError", ":", "comp_info", "=", "comp_dict", "try", ":", "spectrum", "=", ...
Make dictionary mapping component keys to a source or set of sources Parameters ---------- comp_key : str Key used to access sources comp_dict : dict Information used to build sources return `OrderedDict` maping comp_key to `fermipy.roi_model.Source`
[ "Make", "dictionary", "mapping", "component", "keys", "to", "a", "source", "or", "set", "of", "sources" ]
python
train
38.54