repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
phodge/homely
homely/_cli.py
https://github.com/phodge/homely/blob/98ddcf3e4f29b0749645817b4866baaea8376085/homely/_cli.py#L146-L174
def forget(identifier): ''' Tells homely to forget about a dotfiles repository that was previously added. You can then run `homely update` to have homely perform automatic cleanup of anything that was installed by that dotfiles repo. REPO This should be the path to a local dotfiles reposito...
[ "def", "forget", "(", "identifier", ")", ":", "errors", "=", "False", "for", "one", "in", "identifier", ":", "cfg", "=", "RepoListConfig", "(", ")", "info", "=", "cfg", ".", "find_by_any", "(", "one", ",", "\"ilc\"", ")", "if", "not", "info", ":", "w...
Tells homely to forget about a dotfiles repository that was previously added. You can then run `homely update` to have homely perform automatic cleanup of anything that was installed by that dotfiles repo. REPO This should be the path to a local dotfiles repository that has already been reg...
[ "Tells", "homely", "to", "forget", "about", "a", "dotfiles", "repository", "that", "was", "previously", "added", ".", "You", "can", "then", "run", "homely", "update", "to", "have", "homely", "perform", "automatic", "cleanup", "of", "anything", "that", "was", ...
python
train
saltstack/salt
salt/utils/vmware.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vmware.py#L755-L874
def get_content(service_instance, obj_type, property_list=None, container_ref=None, traversal_spec=None, local_properties=False): ''' Returns the content of the specified type of object for a Service Instance. For more information, please see: http://pubs.vmware.com/vsph...
[ "def", "get_content", "(", "service_instance", ",", "obj_type", ",", "property_list", "=", "None", ",", "container_ref", "=", "None", ",", "traversal_spec", "=", "None", ",", "local_properties", "=", "False", ")", ":", "# Start at the rootFolder if container starting ...
Returns the content of the specified type of object for a Service Instance. For more information, please see: http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.pg.doc_50%2FPG_Ch5_PropertyCollector.7.6.html service_instance The Service Instance from which to obtain content. ...
[ "Returns", "the", "content", "of", "the", "specified", "type", "of", "object", "for", "a", "Service", "Instance", "." ]
python
train
sdcooke/django_bundles
django_bundles/core.py
https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/core.py#L221-L235
def get_bundle_versions(): """ Used to cache the bundle versions rather than loading them from the bundle versions file every time they're used """ global _cached_versions if not bundles_settings.BUNDLES_VERSION_FILE: _cached_versions = {} if _cached_versions is None: locs = {} ...
[ "def", "get_bundle_versions", "(", ")", ":", "global", "_cached_versions", "if", "not", "bundles_settings", ".", "BUNDLES_VERSION_FILE", ":", "_cached_versions", "=", "{", "}", "if", "_cached_versions", "is", "None", ":", "locs", "=", "{", "}", "try", ":", "ex...
Used to cache the bundle versions rather than loading them from the bundle versions file every time they're used
[ "Used", "to", "cache", "the", "bundle", "versions", "rather", "than", "loading", "them", "from", "the", "bundle", "versions", "file", "every", "time", "they", "re", "used" ]
python
train
emlazzarin/acrylic
acrylic/datatable.py
https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L579-L623
def join(self, right_table, on=None, right_prefix='R.', outer=False): """ Inner-joins another DataTable to this one using `on` (iterable of join keys). If two tables share columns other than the join keys, appends right_prefix to the right table's column name. If `on` is not prov...
[ "def", "join", "(", "self", ",", "right_table", ",", "on", "=", "None", ",", "right_prefix", "=", "'R.'", ",", "outer", "=", "False", ")", ":", "if", "on", "is", "None", ":", "# if no 'on', perform natural join", "on", "=", "list", "(", "set", "(", "se...
Inner-joins another DataTable to this one using `on` (iterable of join keys). If two tables share columns other than the join keys, appends right_prefix to the right table's column name. If `on` is not provided, performs a 'natural join' using all columns of the same name.
[ "Inner", "-", "joins", "another", "DataTable", "to", "this", "one", "using", "on", "(", "iterable", "of", "join", "keys", ")", ".", "If", "two", "tables", "share", "columns", "other", "than", "the", "join", "keys", "appends", "right_prefix", "to", "the", ...
python
train
crytic/slither
slither/printers/summary/require_calls.py
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/printers/summary/require_calls.py#L25-L42
def output(self, _filename): """ _filename is not used Args: _filename(string) """ for contract in self.slither.contracts_derived: txt = "\nContract %s"%contract.name table = PrettyTable(["Function", ...
[ "def", "output", "(", "self", ",", "_filename", ")", ":", "for", "contract", "in", "self", ".", "slither", ".", "contracts_derived", ":", "txt", "=", "\"\\nContract %s\"", "%", "contract", ".", "name", "table", "=", "PrettyTable", "(", "[", "\"Function\"", ...
_filename is not used Args: _filename(string)
[ "_filename", "is", "not", "used", "Args", ":", "_filename", "(", "string", ")" ]
python
train
yougov/pmxbot
pmxbot/irc.py
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/irc.py#L79-L85
def _get_wrapper(): """ Get a socket wrapper based on SSL config. """ if not pmxbot.config.get('use_ssl', False): return lambda x: x return importlib.import_module('ssl').wrap_socket
[ "def", "_get_wrapper", "(", ")", ":", "if", "not", "pmxbot", ".", "config", ".", "get", "(", "'use_ssl'", ",", "False", ")", ":", "return", "lambda", "x", ":", "x", "return", "importlib", ".", "import_module", "(", "'ssl'", ")", ".", "wrap_socket" ]
Get a socket wrapper based on SSL config.
[ "Get", "a", "socket", "wrapper", "based", "on", "SSL", "config", "." ]
python
train
openego/ding0
ding0/core/network/grids.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/core/network/grids.py#L856-L863
def add_station(self, lv_station): """Adds a LV station to _station and grid graph if not already existing""" if not isinstance(lv_station, LVStationDing0): raise Exception('Given LV station is not a LVStationDing0 object.') if self._station is None: self._station = lv_st...
[ "def", "add_station", "(", "self", ",", "lv_station", ")", ":", "if", "not", "isinstance", "(", "lv_station", ",", "LVStationDing0", ")", ":", "raise", "Exception", "(", "'Given LV station is not a LVStationDing0 object.'", ")", "if", "self", ".", "_station", "is"...
Adds a LV station to _station and grid graph if not already existing
[ "Adds", "a", "LV", "station", "to", "_station", "and", "grid", "graph", "if", "not", "already", "existing" ]
python
train
miniconfig/python-openevse-wifi
openevsewifi/__init__.py
https://github.com/miniconfig/python-openevse-wifi/blob/42fabeae052a9f82092fa9220201413732e38bb4/openevsewifi/__init__.py#L92-L97
def getServiceLevel(self): """Returns the service level""" command = '$GE' settings = self.sendCommand(command) flags = int(settings[2], 16) return (flags & 0x0001) + 1
[ "def", "getServiceLevel", "(", "self", ")", ":", "command", "=", "'$GE'", "settings", "=", "self", ".", "sendCommand", "(", "command", ")", "flags", "=", "int", "(", "settings", "[", "2", "]", ",", "16", ")", "return", "(", "flags", "&", "0x0001", ")...
Returns the service level
[ "Returns", "the", "service", "level" ]
python
train
locationlabs/gusset
gusset/colortable.py
https://github.com/locationlabs/gusset/blob/c2e6a58e9eec5a00da2231c1e3e7247c65263edf/gusset/colortable.py#L59-L64
def separator(self): """ Generate a separator row using current column widths. """ cells = dict([(column, "-" * self.column_widths[column]) for column in self.columns]) return ColorRow(self, **cells)
[ "def", "separator", "(", "self", ")", ":", "cells", "=", "dict", "(", "[", "(", "column", ",", "\"-\"", "*", "self", ".", "column_widths", "[", "column", "]", ")", "for", "column", "in", "self", ".", "columns", "]", ")", "return", "ColorRow", "(", ...
Generate a separator row using current column widths.
[ "Generate", "a", "separator", "row", "using", "current", "column", "widths", "." ]
python
train
BoboTiG/python-mss
mss/darwin.py
https://github.com/BoboTiG/python-mss/blob/56347f781edb38a0e7a5104080bd683f49c6f074/mss/darwin.py#L175-L230
def grab(self, monitor): # type: (Monitor) -> ScreenShot """ See :meth:`MSSMixin.grab <mss.base.MSSMixin.grab>` for full details. """ # pylint: disable=too-many-locals # Convert PIL bbox style if isinstance(monitor, tuple): monitor = { ...
[ "def", "grab", "(", "self", ",", "monitor", ")", ":", "# type: (Monitor) -> ScreenShot", "# pylint: disable=too-many-locals", "# Convert PIL bbox style", "if", "isinstance", "(", "monitor", ",", "tuple", ")", ":", "monitor", "=", "{", "\"left\"", ":", "monitor", "["...
See :meth:`MSSMixin.grab <mss.base.MSSMixin.grab>` for full details.
[ "See", ":", "meth", ":", "MSSMixin", ".", "grab", "<mss", ".", "base", ".", "MSSMixin", ".", "grab", ">", "for", "full", "details", "." ]
python
train
nwilming/ocupy
ocupy/utils.py
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L130-L148
def dict_fun(data, function): """ Apply a function to all values in a dictionary, return a dictionary with results. Parameters ---------- data : dict a dictionary whose values are adequate input to the second argument of this function. function : function a function...
[ "def", "dict_fun", "(", "data", ",", "function", ")", ":", "return", "dict", "(", "(", "k", ",", "function", "(", "v", ")", ")", "for", "k", ",", "v", "in", "list", "(", "data", ".", "items", "(", ")", ")", ")" ]
Apply a function to all values in a dictionary, return a dictionary with results. Parameters ---------- data : dict a dictionary whose values are adequate input to the second argument of this function. function : function a function that takes one argument Returns ...
[ "Apply", "a", "function", "to", "all", "values", "in", "a", "dictionary", "return", "a", "dictionary", "with", "results", "." ]
python
train
openstack/python-saharaclient
saharaclient/api/clusters.py
https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/clusters.py#L157-L176
def create(self, name, plugin_name, plugin_version, cluster_template_id=None, default_image_id=None, is_transient=None, description=None, cluster_configs=None, node_groups=None, user_keypair_id=None, anti_affinity=None, net_id=None, count=None, ...
[ "def", "create", "(", "self", ",", "name", ",", "plugin_name", ",", "plugin_version", ",", "cluster_template_id", "=", "None", ",", "default_image_id", "=", "None", ",", "is_transient", "=", "None", ",", "description", "=", "None", ",", "cluster_configs", "=",...
Launch a Cluster.
[ "Launch", "a", "Cluster", "." ]
python
train
Legobot/Legobot
Legobot/Connectors/Slack.py
https://github.com/Legobot/Legobot/blob/d13da172960a149681cb5151ce34b2f3a58ad32b/Legobot/Connectors/Slack.py#L428-L487
def handle(self, message): '''Attempts to send a message to the specified destination in Slack. Extends Legobot.Lego.handle() Args: message (Legobot.Message): message w/ metadata to send. ''' logger.debug(message) if Utilities.isNotEmpty(message['metadata'][...
[ "def", "handle", "(", "self", ",", "message", ")", ":", "logger", ".", "debug", "(", "message", ")", "if", "Utilities", ".", "isNotEmpty", "(", "message", "[", "'metadata'", "]", "[", "'opts'", "]", ")", ":", "target", "=", "message", "[", "'metadata'"...
Attempts to send a message to the specified destination in Slack. Extends Legobot.Lego.handle() Args: message (Legobot.Message): message w/ metadata to send.
[ "Attempts", "to", "send", "a", "message", "to", "the", "specified", "destination", "in", "Slack", ".", "Extends", "Legobot", ".", "Lego", ".", "handle", "()" ]
python
train
lingthio/Flask-User
flask_user/db_manager.py
https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/flask_user/db_manager.py#L99-L105
def add_user(self, **kwargs): """Add a User object, with properties specified in ``**kwargs``.""" user = self.UserClass(**kwargs) if hasattr(user, 'active'): user.active = True self.db_adapter.add_object(user) return user
[ "def", "add_user", "(", "self", ",", "*", "*", "kwargs", ")", ":", "user", "=", "self", ".", "UserClass", "(", "*", "*", "kwargs", ")", "if", "hasattr", "(", "user", ",", "'active'", ")", ":", "user", ".", "active", "=", "True", "self", ".", "db_...
Add a User object, with properties specified in ``**kwargs``.
[ "Add", "a", "User", "object", "with", "properties", "specified", "in", "**", "kwargs", "." ]
python
train
maxpumperla/elephas
elephas/worker.py
https://github.com/maxpumperla/elephas/blob/84605acdc9564673c487637dcb27f5def128bcc7/elephas/worker.py#L26-L49
def train(self, data_iterator): """Train a keras model on a worker """ optimizer = get_optimizer(self.master_optimizer) self.model = model_from_yaml(self.yaml, self.custom_objects) self.model.compile(optimizer=optimizer, loss=self.master_loss, metrics=s...
[ "def", "train", "(", "self", ",", "data_iterator", ")", ":", "optimizer", "=", "get_optimizer", "(", "self", ".", "master_optimizer", ")", "self", ".", "model", "=", "model_from_yaml", "(", "self", ".", "yaml", ",", "self", ".", "custom_objects", ")", "sel...
Train a keras model on a worker
[ "Train", "a", "keras", "model", "on", "a", "worker" ]
python
train
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
gatkin/declxml
declxml.py
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L945-L959
def parse_at_element( self, element, # type: ET.Element state # type: _ProcessorState ): # type: (...) -> Any """Parse the provided element as a dictionary.""" parsed_dict = {} for child in self._child_processors: state.push_location...
[ "def", "parse_at_element", "(", "self", ",", "element", ",", "# type: ET.Element", "state", "# type: _ProcessorState", ")", ":", "# type: (...) -> Any", "parsed_dict", "=", "{", "}", "for", "child", "in", "self", ".", "_child_processors", ":", "state", ".", "push_...
Parse the provided element as a dictionary.
[ "Parse", "the", "provided", "element", "as", "a", "dictionary", "." ]
python
train
oceanprotocol/squid-py
squid_py/ddo/public_key_rsa.py
https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/public_key_rsa.py#L27-L32
def set_encode_key_value(self, value, store_type=PUBLIC_KEY_STORE_TYPE_BASE64): """Set the value based on the type of encoding supported by RSA.""" if store_type == PUBLIC_KEY_STORE_TYPE_PEM: PublicKeyBase.set_encode_key_value(self, value.exportKey('PEM').decode(), store_type) else: ...
[ "def", "set_encode_key_value", "(", "self", ",", "value", ",", "store_type", "=", "PUBLIC_KEY_STORE_TYPE_BASE64", ")", ":", "if", "store_type", "==", "PUBLIC_KEY_STORE_TYPE_PEM", ":", "PublicKeyBase", ".", "set_encode_key_value", "(", "self", ",", "value", ".", "exp...
Set the value based on the type of encoding supported by RSA.
[ "Set", "the", "value", "based", "on", "the", "type", "of", "encoding", "supported", "by", "RSA", "." ]
python
train
psd-tools/psd-tools
src/psd_tools/api/shape.py
https://github.com/psd-tools/psd-tools/blob/4952b57bcf1cf2c1f16fd9d6d51d4fa0b53bce4e/src/psd_tools/api/shape.py#L220-L223
def line_alignment(self): """Alignment, one of `inner`, `outer`, `center`.""" key = self._data.get(b'strokeStyleLineAlignment').enum return self.STROKE_STYLE_LINE_ALIGNMENTS.get(key, str(key))
[ "def", "line_alignment", "(", "self", ")", ":", "key", "=", "self", ".", "_data", ".", "get", "(", "b'strokeStyleLineAlignment'", ")", ".", "enum", "return", "self", ".", "STROKE_STYLE_LINE_ALIGNMENTS", ".", "get", "(", "key", ",", "str", "(", "key", ")", ...
Alignment, one of `inner`, `outer`, `center`.
[ "Alignment", "one", "of", "inner", "outer", "center", "." ]
python
train
bitesofcode/projexui
projexui/xsettings.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xsettings.py#L508-L517
def childKeys(self): """ Returns the list of child keys for this settings instance. :return [<str>, ..] """ if self._customFormat: return self._customFormat.childKeys() else: return super(XSettings, self).childKeys()
[ "def", "childKeys", "(", "self", ")", ":", "if", "self", ".", "_customFormat", ":", "return", "self", ".", "_customFormat", ".", "childKeys", "(", ")", "else", ":", "return", "super", "(", "XSettings", ",", "self", ")", ".", "childKeys", "(", ")" ]
Returns the list of child keys for this settings instance. :return [<str>, ..]
[ "Returns", "the", "list", "of", "child", "keys", "for", "this", "settings", "instance", ".", ":", "return", "[", "<str", ">", "..", "]" ]
python
train
PyPSA/PyPSA
pypsa/graph.py
https://github.com/PyPSA/PyPSA/blob/46954b1b3c21460550f7104681517065279a53b7/pypsa/graph.py#L92-L155
def adjacency_matrix(network, branch_components=None, busorder=None, weights=None): """ Construct a sparse adjacency matrix (directed) Parameters ---------- branch_components : iterable sublist of `branch_components` Buses connected by any of the selected branches are adjacent (defaul...
[ "def", "adjacency_matrix", "(", "network", ",", "branch_components", "=", "None", ",", "busorder", "=", "None", ",", "weights", "=", "None", ")", ":", "from", ".", "import", "components", "if", "isinstance", "(", "network", ",", "components", ".", "Network",...
Construct a sparse adjacency matrix (directed) Parameters ---------- branch_components : iterable sublist of `branch_components` Buses connected by any of the selected branches are adjacent (default: branch_components (network) or passive_branch_components (sub_network)) busorder : pd.Ind...
[ "Construct", "a", "sparse", "adjacency", "matrix", "(", "directed", ")" ]
python
train
apple/turicreate
deps/src/cmake-3.13.4/Source/cmConvertMSBuildXMLToJSON.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/cmake-3.13.4/Source/cmConvertMSBuildXMLToJSON.py#L173-L198
def __merge_json_values(current, previous): """Merges the values between the current and previous run of the script.""" for value in current: name = value['name'] # Find the previous value previous_value = __find_and_remove_value(previous, value) if previous_value is not None: ...
[ "def", "__merge_json_values", "(", "current", ",", "previous", ")", ":", "for", "value", "in", "current", ":", "name", "=", "value", "[", "'name'", "]", "# Find the previous value", "previous_value", "=", "__find_and_remove_value", "(", "previous", ",", "value", ...
Merges the values between the current and previous run of the script.
[ "Merges", "the", "values", "between", "the", "current", "and", "previous", "run", "of", "the", "script", "." ]
python
train
empymod/empymod
empymod/utils.py
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L824-L897
def check_opt(opt, loop, ht, htarg, verb): r"""Check optimization parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- opt : {None, 'parallel...
[ "def", "check_opt", "(", "opt", ",", "loop", ",", "ht", ",", "htarg", ",", "verb", ")", ":", "# Check optimization flag", "use_ne_eval", "=", "False", "if", "opt", "==", "'parallel'", ":", "if", "numexpr", ":", "use_ne_eval", "=", "numexpr", ".", "evaluate...
r"""Check optimization parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- opt : {None, 'parallel'} Optimization flag; use ``numexpr`` o...
[ "r", "Check", "optimization", "parameters", "." ]
python
train
cloud-custodian/cloud-custodian
c7n/actions/network.py
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L184-L198
def resolve_remove_symbols(self, r, target_group_ids, rgroups): """Resolve the resources security groups that need be modified. Specifically handles symbolic names that match annotations from policy filters for groups being removed. """ if 'matched' in target_group_ids: ...
[ "def", "resolve_remove_symbols", "(", "self", ",", "r", ",", "target_group_ids", ",", "rgroups", ")", ":", "if", "'matched'", "in", "target_group_ids", ":", "return", "r", ".", "get", "(", "'c7n:matched-security-groups'", ",", "(", ")", ")", "elif", "'network-...
Resolve the resources security groups that need be modified. Specifically handles symbolic names that match annotations from policy filters for groups being removed.
[ "Resolve", "the", "resources", "security", "groups", "that", "need", "be", "modified", "." ]
python
train
pandas-dev/pandas
pandas/core/indexes/base.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L958-L969
def _format_data(self, name=None): """ Return the formatted data as a unicode string. """ # do we want to justify (only do so for non-objects) is_justify = not (self.inferred_type in ('string', 'unicode') or (self.inferred_type == 'categorical' and ...
[ "def", "_format_data", "(", "self", ",", "name", "=", "None", ")", ":", "# do we want to justify (only do so for non-objects)", "is_justify", "=", "not", "(", "self", ".", "inferred_type", "in", "(", "'string'", ",", "'unicode'", ")", "or", "(", "self", ".", "...
Return the formatted data as a unicode string.
[ "Return", "the", "formatted", "data", "as", "a", "unicode", "string", "." ]
python
train
chrislit/abydos
abydos/distance/_eudex.py
https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/distance/_eudex.py#L202-L236
def dist(self, src, tar, weights='exponential', max_length=8): """Return normalized distance between the Eudex hashes of two terms. This is Eudex distance normalized to [0, 1]. Parameters ---------- src : str Source string for comparison tar : str ...
[ "def", "dist", "(", "self", ",", "src", ",", "tar", ",", "weights", "=", "'exponential'", ",", "max_length", "=", "8", ")", ":", "return", "self", ".", "dist_abs", "(", "src", ",", "tar", ",", "weights", ",", "max_length", ",", "True", ")" ]
Return normalized distance between the Eudex hashes of two terms. This is Eudex distance normalized to [0, 1]. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison weights : str, iterable, or generat...
[ "Return", "normalized", "distance", "between", "the", "Eudex", "hashes", "of", "two", "terms", "." ]
python
valid
LionelR/pyair
pyair/stats.py
https://github.com/LionelR/pyair/blob/467e8a843ca9f882f8bb2958805b7293591996ad/pyair/stats.py#L113-L116
def foex(a, b): """Returns the factor of exceedance """ return (np.sum(a > b, dtype=float) / len(a) - 0.5) * 100
[ "def", "foex", "(", "a", ",", "b", ")", ":", "return", "(", "np", ".", "sum", "(", "a", ">", "b", ",", "dtype", "=", "float", ")", "/", "len", "(", "a", ")", "-", "0.5", ")", "*", "100" ]
Returns the factor of exceedance
[ "Returns", "the", "factor", "of", "exceedance" ]
python
valid
SCIP-Interfaces/PySCIPOpt
examples/finished/flp.py
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/flp.py#L11-L46
def flp(I,J,d,M,f,c): """flp -- model for the capacitated facility location problem Parameters: - I: set of customers - J: set of facilities - d[i]: demand for customer i - M[j]: capacity of facility j - f[j]: fixed cost for using a facility in point j - c[i,j]: u...
[ "def", "flp", "(", "I", ",", "J", ",", "d", ",", "M", ",", "f", ",", "c", ")", ":", "model", "=", "Model", "(", "\"flp\"", ")", "x", ",", "y", "=", "{", "}", ",", "{", "}", "for", "j", "in", "J", ":", "y", "[", "j", "]", "=", "model",...
flp -- model for the capacitated facility location problem Parameters: - I: set of customers - J: set of facilities - d[i]: demand for customer i - M[j]: capacity of facility j - f[j]: fixed cost for using a facility in point j - c[i,j]: unit cost of servicing demand ...
[ "flp", "--", "model", "for", "the", "capacitated", "facility", "location", "problem", "Parameters", ":", "-", "I", ":", "set", "of", "customers", "-", "J", ":", "set", "of", "facilities", "-", "d", "[", "i", "]", ":", "demand", "for", "customer", "i", ...
python
train
openstack/networking-arista
networking_arista/ml2/mechanism_arista.py
https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L117-L130
def get_instance_type(self, port): """Determine the port type based on device owner and vnic type""" if port[portbindings.VNIC_TYPE] == portbindings.VNIC_BAREMETAL: return a_const.BAREMETAL_RESOURCE owner_to_type = { n_const.DEVICE_OWNER_DHCP: a_const.DHCP_RESOURCE, ...
[ "def", "get_instance_type", "(", "self", ",", "port", ")", ":", "if", "port", "[", "portbindings", ".", "VNIC_TYPE", "]", "==", "portbindings", ".", "VNIC_BAREMETAL", ":", "return", "a_const", ".", "BAREMETAL_RESOURCE", "owner_to_type", "=", "{", "n_const", "....
Determine the port type based on device owner and vnic type
[ "Determine", "the", "port", "type", "based", "on", "device", "owner", "and", "vnic", "type" ]
python
train
KungAlex/pbkdf2helper
pbkdf2helper/helper.py
https://github.com/KungAlex/pbkdf2helper/blob/4719878d6f8cada486415b111ed72164b4ac6f57/pbkdf2helper/helper.py#L66-L73
def split(encoded): """ Split a PBKDF2 hashed Password into algorithm, iterations, salt and hash :param encoded: PBKDF2 hashed Password :return: algorithm, iterations, salt, hash """ algorithm, iterations, salt, h = encoded.split('$', 3) return algorithm, iterations, salt, h
[ "def", "split", "(", "encoded", ")", ":", "algorithm", ",", "iterations", ",", "salt", ",", "h", "=", "encoded", ".", "split", "(", "'$'", ",", "3", ")", "return", "algorithm", ",", "iterations", ",", "salt", ",", "h" ]
Split a PBKDF2 hashed Password into algorithm, iterations, salt and hash :param encoded: PBKDF2 hashed Password :return: algorithm, iterations, salt, hash
[ "Split", "a", "PBKDF2", "hashed", "Password", "into", "algorithm", "iterations", "salt", "and", "hash", ":", "param", "encoded", ":", "PBKDF2", "hashed", "Password", ":", "return", ":", "algorithm", "iterations", "salt", "hash" ]
python
train
globocom/GloboNetworkAPI-client-python
networkapiclient/ClientFactory.py
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ClientFactory.py#L352-L358
def create_equipamento(self): """Get an instance of equipamento services facade.""" return Equipamento( self.networkapi_url, self.user, self.password, self.user_ldap)
[ "def", "create_equipamento", "(", "self", ")", ":", "return", "Equipamento", "(", "self", ".", "networkapi_url", ",", "self", ".", "user", ",", "self", ".", "password", ",", "self", ".", "user_ldap", ")" ]
Get an instance of equipamento services facade.
[ "Get", "an", "instance", "of", "equipamento", "services", "facade", "." ]
python
train
vtkiorg/vtki
vtki/renderer.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L61-L126
def add_actor(self, uinput, reset_camera=False, name=None, loc=None, culling=False): """ Adds an actor to render window. Creates an actor if input is a mapper. Parameters ---------- uinput : vtk.vtkMapper or vtk.vtkActor vtk mapper or vtk a...
[ "def", "add_actor", "(", "self", ",", "uinput", ",", "reset_camera", "=", "False", ",", "name", "=", "None", ",", "loc", "=", "None", ",", "culling", "=", "False", ")", ":", "# Remove actor by that name if present", "rv", "=", "self", ".", "remove_actor", ...
Adds an actor to render window. Creates an actor if input is a mapper. Parameters ---------- uinput : vtk.vtkMapper or vtk.vtkActor vtk mapper or vtk actor to be added. reset_camera : bool, optional Resets the camera when true. loc : int, tuple...
[ "Adds", "an", "actor", "to", "render", "window", ".", "Creates", "an", "actor", "if", "input", "is", "a", "mapper", "." ]
python
train
suds-community/suds
suds/sax/enc.py
https://github.com/suds-community/suds/blob/6fb0a829337b5037a66c20aae6f89b41acd77e40/suds/sax/enc.py#L81-L94
def __needs_encoding(self, s): """ Get whether string I{s} contains special characters. @param s: A string to check. @type s: str @return: True if needs encoding. @rtype: boolean """ if isinstance(s, basestring): for c in self.special: ...
[ "def", "__needs_encoding", "(", "self", ",", "s", ")", ":", "if", "isinstance", "(", "s", ",", "basestring", ")", ":", "for", "c", "in", "self", ".", "special", ":", "if", "c", "in", "s", ":", "return", "True" ]
Get whether string I{s} contains special characters. @param s: A string to check. @type s: str @return: True if needs encoding. @rtype: boolean
[ "Get", "whether", "string", "I", "{", "s", "}", "contains", "special", "characters", "." ]
python
train
loli/medpy
medpy/graphcut/energy_label.py
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_label.py#L111-L193
def boundary_stawiaski(graph, label_image, gradient_image): # label image is not required to hold continuous ids or to start from 1 r""" Boundary term based on the sum of border voxel pairs differences. An implementation of the boundary term in [1]_, suitable to be used with the `~medpy.graphcut.gener...
[ "def", "boundary_stawiaski", "(", "graph", ",", "label_image", ",", "gradient_image", ")", ":", "# label image is not required to hold continuous ids or to start from 1", "# convert to arrays if necessary", "label_image", "=", "scipy", ".", "asarray", "(", "label_image", ")", ...
r""" Boundary term based on the sum of border voxel pairs differences. An implementation of the boundary term in [1]_, suitable to be used with the `~medpy.graphcut.generate.graph_from_labels` function. Determines for each two supplied regions the voxels forming their border assuming :math:`n...
[ "r", "Boundary", "term", "based", "on", "the", "sum", "of", "border", "voxel", "pairs", "differences", ".", "An", "implementation", "of", "the", "boundary", "term", "in", "[", "1", "]", "_", "suitable", "to", "be", "used", "with", "the", "~medpy", ".", ...
python
train
tanghaibao/jcvi
jcvi/formats/gff.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/gff.py#L2409-L2462
def note(args): """ %prog note gffile > tabfile Extract certain attribute field for each feature. """ p = OptionParser(note.__doc__) p.add_option("--type", default=None, help="Only process certain types, multiple types allowed with comma") p.add_option("--attribute", default="Pa...
[ "def", "note", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "note", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"--type\"", ",", "default", "=", "None", ",", "help", "=", "\"Only process certain types, multiple types allowed with comma\"", ")", ...
%prog note gffile > tabfile Extract certain attribute field for each feature.
[ "%prog", "note", "gffile", ">", "tabfile" ]
python
train
XuShaohua/bcloud
bcloud/UploadPage.py
https://github.com/XuShaohua/bcloud/blob/4b54e0fdccf2b3013285fef05c97354cfa31697b/bcloud/UploadPage.py#L697-L711
def operate_selected_rows(self, operator): '''对选中的条目进行操作. operator - 处理函数 ''' model, tree_paths = self.selection.get_selected_rows() if not tree_paths: return fids = [] for tree_path in tree_paths: fids.append(model[tree_path][FID_COL]) ...
[ "def", "operate_selected_rows", "(", "self", ",", "operator", ")", ":", "model", ",", "tree_paths", "=", "self", ".", "selection", ".", "get_selected_rows", "(", ")", "if", "not", "tree_paths", ":", "return", "fids", "=", "[", "]", "for", "tree_path", "in"...
对选中的条目进行操作. operator - 处理函数
[ "对选中的条目进行操作", "." ]
python
train
ciena/afkak
afkak/client.py
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/client.py#L803-L846
def _make_request_to_broker(self, broker, requestId, request, **kwArgs): """Send a request to the specified broker.""" def _timeout_request(broker, requestId): """The time we allotted for the request expired, cancel it.""" try: # FIXME: This should be done by call...
[ "def", "_make_request_to_broker", "(", "self", ",", "broker", ",", "requestId", ",", "request", ",", "*", "*", "kwArgs", ")", ":", "def", "_timeout_request", "(", "broker", ",", "requestId", ")", ":", "\"\"\"The time we allotted for the request expired, cancel it.\"\"...
Send a request to the specified broker.
[ "Send", "a", "request", "to", "the", "specified", "broker", "." ]
python
train
pantsbuild/pants
src/python/pants/backend/jvm/tasks/classpath_util.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/tasks/classpath_util.py#L68-L78
def classpath(cls, targets, classpath_products, confs=('default',)): """Return the classpath as a list of paths covering all the passed targets. :param targets: Targets to build an aggregated classpath for. :param ClasspathProducts classpath_products: Product containing classpath elements. :param confs...
[ "def", "classpath", "(", "cls", ",", "targets", ",", "classpath_products", ",", "confs", "=", "(", "'default'", ",", ")", ")", ":", "classpath_iter", "=", "cls", ".", "_classpath_iter", "(", "classpath_products", ".", "get_for_targets", "(", "targets", ")", ...
Return the classpath as a list of paths covering all the passed targets. :param targets: Targets to build an aggregated classpath for. :param ClasspathProducts classpath_products: Product containing classpath elements. :param confs: The list of confs for use by this classpath. :returns: The classpath a...
[ "Return", "the", "classpath", "as", "a", "list", "of", "paths", "covering", "all", "the", "passed", "targets", "." ]
python
train
juju/python-libjuju
juju/model.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L597-L615
async def add_local_charm_dir(self, charm_dir, series): """Upload a local charm to the model. This will automatically generate an archive from the charm dir. :param charm_dir: Path to the charm directory :param series: Charm series """ fh = tempfile.NamedTempor...
[ "async", "def", "add_local_charm_dir", "(", "self", ",", "charm_dir", ",", "series", ")", ":", "fh", "=", "tempfile", ".", "NamedTemporaryFile", "(", ")", "CharmArchiveGenerator", "(", "charm_dir", ")", ".", "make_archive", "(", "fh", ".", "name", ")", "with...
Upload a local charm to the model. This will automatically generate an archive from the charm dir. :param charm_dir: Path to the charm directory :param series: Charm series
[ "Upload", "a", "local", "charm", "to", "the", "model", "." ]
python
train
Accelize/pycosio
pycosio/_core/io_base_raw.py
https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_raw.py#L246-L260
def _peek(self, size=-1): """ Return bytes from the stream without advancing the position. Args: size (int): Number of bytes to read. -1 to read the full stream. Returns: bytes: bytes read """ with self._seek_lock: see...
[ "def", "_peek", "(", "self", ",", "size", "=", "-", "1", ")", ":", "with", "self", ".", "_seek_lock", ":", "seek", "=", "self", ".", "_seek", "with", "handle_os_exceptions", "(", ")", ":", "return", "self", ".", "_read_range", "(", "seek", ",", "seek...
Return bytes from the stream without advancing the position. Args: size (int): Number of bytes to read. -1 to read the full stream. Returns: bytes: bytes read
[ "Return", "bytes", "from", "the", "stream", "without", "advancing", "the", "position", "." ]
python
train
jorahn/icy
icy/icy.py
https://github.com/jorahn/icy/blob/d0bd765c933b2d9bff4d7d646c0938348b9c5c25/icy/icy.py#L543-L550
def _find_key_cols(df): """Identify columns in a DataFrame that could be a unique key""" keys = [] for col in df: if len(df[col].unique()) == len(df[col]): keys.append(col) return keys
[ "def", "_find_key_cols", "(", "df", ")", ":", "keys", "=", "[", "]", "for", "col", "in", "df", ":", "if", "len", "(", "df", "[", "col", "]", ".", "unique", "(", ")", ")", "==", "len", "(", "df", "[", "col", "]", ")", ":", "keys", ".", "appe...
Identify columns in a DataFrame that could be a unique key
[ "Identify", "columns", "in", "a", "DataFrame", "that", "could", "be", "a", "unique", "key" ]
python
train
peri-source/peri
peri/comp/comp.py
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L101-L111
def set_values(self, params, values): """ Directly set the values corresponding to certain parameters. This does not necessarily trigger and update of the calculation, See also -------- :func:`~peri.comp.comp.ParameterGroup.update` : full update func """ ...
[ "def", "set_values", "(", "self", ",", "params", ",", "values", ")", ":", "for", "p", ",", "v", "in", "zip", "(", "util", ".", "listify", "(", "params", ")", ",", "util", ".", "listify", "(", "values", ")", ")", ":", "self", ".", "param_dict", "[...
Directly set the values corresponding to certain parameters. This does not necessarily trigger and update of the calculation, See also -------- :func:`~peri.comp.comp.ParameterGroup.update` : full update func
[ "Directly", "set", "the", "values", "corresponding", "to", "certain", "parameters", ".", "This", "does", "not", "necessarily", "trigger", "and", "update", "of", "the", "calculation", "See", "also", "--------", ":", "func", ":", "~peri", ".", "comp", ".", "co...
python
valid
rigetti/grove
grove/tomography/utils.py
https://github.com/rigetti/grove/blob/dc6bf6ec63e8c435fe52b1e00f707d5ce4cdb9b3/grove/tomography/utils.py#L244-L268
def plot_pauli_transfer_matrix(ptransfermatrix, ax, labels, title): """ Visualize the Pauli Transfer Matrix of a process. :param numpy.ndarray ptransfermatrix: The Pauli Transfer Matrix :param ax: The matplotlib axes. :param labels: The labels for the operator basis states. :param title: The ti...
[ "def", "plot_pauli_transfer_matrix", "(", "ptransfermatrix", ",", "ax", ",", "labels", ",", "title", ")", ":", "im", "=", "ax", ".", "imshow", "(", "ptransfermatrix", ",", "interpolation", "=", "\"nearest\"", ",", "cmap", "=", "rigetti_3_color_cm", ",", "vmin"...
Visualize the Pauli Transfer Matrix of a process. :param numpy.ndarray ptransfermatrix: The Pauli Transfer Matrix :param ax: The matplotlib axes. :param labels: The labels for the operator basis states. :param title: The title for the plot :return: The modified axis object. :rtype: AxesSubplot
[ "Visualize", "the", "Pauli", "Transfer", "Matrix", "of", "a", "process", "." ]
python
train
angr/angr
angr/analyses/cfg/cfg_emulated.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/cfg/cfg_emulated.py#L975-L1016
def _get_one_pending_job(self): """ Retrieve a pending job. :return: A CFGJob instance or None """ pending_job_key, pending_job = self._pending_jobs.popitem() pending_job_state = pending_job.state pending_job_call_stack = pending_job.call_stack pending_j...
[ "def", "_get_one_pending_job", "(", "self", ")", ":", "pending_job_key", ",", "pending_job", "=", "self", ".", "_pending_jobs", ".", "popitem", "(", ")", "pending_job_state", "=", "pending_job", ".", "state", "pending_job_call_stack", "=", "pending_job", ".", "cal...
Retrieve a pending job. :return: A CFGJob instance or None
[ "Retrieve", "a", "pending", "job", "." ]
python
train
tensorpack/tensorpack
tensorpack/tfutils/common.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/tfutils/common.py#L113-L125
def get_tensors_by_names(names): """ Get a list of tensors in the default graph by a list of names. Args: names (list): """ ret = [] G = tfv1.get_default_graph() for n in names: opn, varn = get_op_tensor_name(n) ret.append(G.get_tensor_by_name(varn)) return ret
[ "def", "get_tensors_by_names", "(", "names", ")", ":", "ret", "=", "[", "]", "G", "=", "tfv1", ".", "get_default_graph", "(", ")", "for", "n", "in", "names", ":", "opn", ",", "varn", "=", "get_op_tensor_name", "(", "n", ")", "ret", ".", "append", "("...
Get a list of tensors in the default graph by a list of names. Args: names (list):
[ "Get", "a", "list", "of", "tensors", "in", "the", "default", "graph", "by", "a", "list", "of", "names", "." ]
python
train
saltstack/salt
salt/modules/consul.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/consul.py#L471-L504
def agent_members(consul_url=None, token=None, **kwargs): ''' Returns the members as seen by the local serf agent :param consul_url: The Consul server URL. :return: Returns the members as seen by the local serf agent CLI Example: .. code-block:: bash salt '*' consul.agent_members ...
[ "def", "agent_members", "(", "consul_url", "=", "None", ",", "token", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "}", "query_params", "=", "{", "}", "if", "not", "consul_url", ":", "consul_url", "=", "_get_config", "(", ")", "if...
Returns the members as seen by the local serf agent :param consul_url: The Consul server URL. :return: Returns the members as seen by the local serf agent CLI Example: .. code-block:: bash salt '*' consul.agent_members
[ "Returns", "the", "members", "as", "seen", "by", "the", "local", "serf", "agent" ]
python
train
GoogleCloudPlatform/datastore-ndb-python
demo/app/fibo.py
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/app/fibo.py#L32-L37
def fibonacci(n): """A recursive Fibonacci to exercise task switching.""" if n <= 1: raise ndb.Return(n) a, b = yield fibonacci(n - 1), fibonacci(n - 2) raise ndb.Return(a + b)
[ "def", "fibonacci", "(", "n", ")", ":", "if", "n", "<=", "1", ":", "raise", "ndb", ".", "Return", "(", "n", ")", "a", ",", "b", "=", "yield", "fibonacci", "(", "n", "-", "1", ")", ",", "fibonacci", "(", "n", "-", "2", ")", "raise", "ndb", "...
A recursive Fibonacci to exercise task switching.
[ "A", "recursive", "Fibonacci", "to", "exercise", "task", "switching", "." ]
python
train
ransford/sllurp
sllurp/llrp.py
https://github.com/ransford/sllurp/blob/d744b7e17d7ba64a24d9a31bde6cba65d91ad9b1/sllurp/llrp.py#L408-L699
def handleMessage(self, lmsg): """Implements the LLRP client state machine.""" logger.debug('LLRPMessage received in state %s: %s', self.state, lmsg) msgName = lmsg.getName() lmsg.proto = self lmsg.peername = self.peername # call per-message callbacks logger.debu...
[ "def", "handleMessage", "(", "self", ",", "lmsg", ")", ":", "logger", ".", "debug", "(", "'LLRPMessage received in state %s: %s'", ",", "self", ".", "state", ",", "lmsg", ")", "msgName", "=", "lmsg", ".", "getName", "(", ")", "lmsg", ".", "proto", "=", "...
Implements the LLRP client state machine.
[ "Implements", "the", "LLRP", "client", "state", "machine", "." ]
python
train
Komnomnomnom/swigibpy
swigibpy.py
https://github.com/Komnomnomnom/swigibpy/blob/cfd307fdbfaffabc69a2dc037538d7e34a8b8daf/swigibpy.py#L1250-L1252
def reqScannerSubscription(self, tickerId, subscription, scannerSubscriptionOptions): """reqScannerSubscription(EClient self, int tickerId, ScannerSubscription subscription, TagValueListSPtr const & scannerSubscriptionOptions)""" return _swigibpy.EClient_reqScannerSubscription(self, tickerId, subscripti...
[ "def", "reqScannerSubscription", "(", "self", ",", "tickerId", ",", "subscription", ",", "scannerSubscriptionOptions", ")", ":", "return", "_swigibpy", ".", "EClient_reqScannerSubscription", "(", "self", ",", "tickerId", ",", "subscription", ",", "scannerSubscriptionOpt...
reqScannerSubscription(EClient self, int tickerId, ScannerSubscription subscription, TagValueListSPtr const & scannerSubscriptionOptions)
[ "reqScannerSubscription", "(", "EClient", "self", "int", "tickerId", "ScannerSubscription", "subscription", "TagValueListSPtr", "const", "&", "scannerSubscriptionOptions", ")" ]
python
train
Murali-group/halp
halp/undirected_hypergraph.py
https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/undirected_hypergraph.py#L489-L522
def remove_hyperedge(self, hyperedge_id): """Removes a hyperedge and its attributes from the hypergraph. :param hyperedge_id: ID of the hyperedge to be removed. :raises: ValueError -- No such hyperedge exists. Examples: :: >>> H = UndirectedHypergraph() ...
[ "def", "remove_hyperedge", "(", "self", ",", "hyperedge_id", ")", ":", "if", "not", "self", ".", "has_hyperedge_id", "(", "hyperedge_id", ")", ":", "raise", "ValueError", "(", "\"No such hyperedge exists.\"", ")", "frozen_nodes", "=", "self", ".", "_hyperedge_attr...
Removes a hyperedge and its attributes from the hypergraph. :param hyperedge_id: ID of the hyperedge to be removed. :raises: ValueError -- No such hyperedge exists. Examples: :: >>> H = UndirectedHypergraph() >>> hyperedge_list = (["A", "B", "C"], ...
[ "Removes", "a", "hyperedge", "and", "its", "attributes", "from", "the", "hypergraph", "." ]
python
train
bastikr/boolean.py
boolean/boolean.py
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1031-L1038
def literalize(self): """ Return an expression where NOTs are only occurring as literals. """ expr = self.demorgan() if isinstance(expr, self.__class__): return expr return expr.literalize()
[ "def", "literalize", "(", "self", ")", ":", "expr", "=", "self", ".", "demorgan", "(", ")", "if", "isinstance", "(", "expr", ",", "self", ".", "__class__", ")", ":", "return", "expr", "return", "expr", ".", "literalize", "(", ")" ]
Return an expression where NOTs are only occurring as literals.
[ "Return", "an", "expression", "where", "NOTs", "are", "only", "occurring", "as", "literals", "." ]
python
train
inasafe/inasafe
safe/common/utilities.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L466-L477
def create_label(label_tuple, extra_label=None): """Return a label based on my_tuple (a,b) and extra label. a and b are string. The output will be something like: [a - b] extra_label """ if extra_label is not None: return '[' + ' - '.join(label_tuple) + '] ' + str(extra_lab...
[ "def", "create_label", "(", "label_tuple", ",", "extra_label", "=", "None", ")", ":", "if", "extra_label", "is", "not", "None", ":", "return", "'['", "+", "' - '", ".", "join", "(", "label_tuple", ")", "+", "'] '", "+", "str", "(", "extra_label", ")", ...
Return a label based on my_tuple (a,b) and extra label. a and b are string. The output will be something like: [a - b] extra_label
[ "Return", "a", "label", "based", "on", "my_tuple", "(", "a", "b", ")", "and", "extra", "label", "." ]
python
train
Azure/blobxfer
blobxfer/models/download.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/models/download.py#L132-L149
def ensure_path_exists(self): # type: (LocalDestinationPath) -> None """Ensure path exists :param LocalDestinationPath self: this """ if self._is_dir is None: raise RuntimeError('is_dir not set') if self._is_dir: self._path.mkdir(mode=0o750, parent...
[ "def", "ensure_path_exists", "(", "self", ")", ":", "# type: (LocalDestinationPath) -> None", "if", "self", ".", "_is_dir", "is", "None", ":", "raise", "RuntimeError", "(", "'is_dir not set'", ")", "if", "self", ".", "_is_dir", ":", "self", ".", "_path", ".", ...
Ensure path exists :param LocalDestinationPath self: this
[ "Ensure", "path", "exists", ":", "param", "LocalDestinationPath", "self", ":", "this" ]
python
train
espressif/esptool
esptool.py
https://github.com/espressif/esptool/blob/c583756c118039cfcfe256f7a3285618914d16a5/esptool.py#L888-L904
def read_status(self, num_bytes=2): """Read up to 24 bits (num_bytes) of SPI flash status register contents via RDSR, RDSR2, RDSR3 commands Not all SPI flash supports all three commands. The upper 1 or 2 bytes may be 0xFF. """ SPIFLASH_RDSR = 0x05 SPIFLASH_RDSR2...
[ "def", "read_status", "(", "self", ",", "num_bytes", "=", "2", ")", ":", "SPIFLASH_RDSR", "=", "0x05", "SPIFLASH_RDSR2", "=", "0x35", "SPIFLASH_RDSR3", "=", "0x15", "status", "=", "0", "shift", "=", "0", "for", "cmd", "in", "[", "SPIFLASH_RDSR", ",", "SP...
Read up to 24 bits (num_bytes) of SPI flash status register contents via RDSR, RDSR2, RDSR3 commands Not all SPI flash supports all three commands. The upper 1 or 2 bytes may be 0xFF.
[ "Read", "up", "to", "24", "bits", "(", "num_bytes", ")", "of", "SPI", "flash", "status", "register", "contents", "via", "RDSR", "RDSR2", "RDSR3", "commands" ]
python
train
thiezn/iperf3-python
iperf3/iperf3.py
https://github.com/thiezn/iperf3-python/blob/094a6e043f44fb154988348603661b1473c23a50/iperf3/iperf3.py#L552-L555
def num_streams(self): """The number of streams to use.""" self._num_streams = self.lib.iperf_get_test_num_streams(self._test) return self._num_streams
[ "def", "num_streams", "(", "self", ")", ":", "self", ".", "_num_streams", "=", "self", ".", "lib", ".", "iperf_get_test_num_streams", "(", "self", ".", "_test", ")", "return", "self", ".", "_num_streams" ]
The number of streams to use.
[ "The", "number", "of", "streams", "to", "use", "." ]
python
train
drj11/pypng
code/iccp.py
https://github.com/drj11/pypng/blob/b8220ca9f58e4c5bc1d507e713744fcb8c049225/code/iccp.py#L159-L204
def writeHeader(self, out, size=999): """Add default values to the instance's `d` dictionary, then write a header out onto the file stream. The size of the profile must be specified using the `size` argument. """ def defaultkey(d, key, value): """Add ``[key]==value`...
[ "def", "writeHeader", "(", "self", ",", "out", ",", "size", "=", "999", ")", ":", "def", "defaultkey", "(", "d", ",", "key", ",", "value", ")", ":", "\"\"\"Add ``[key]==value`` to the dictionary `d`, but only if\n it does not have that key already.\n ...
Add default values to the instance's `d` dictionary, then write a header out onto the file stream. The size of the profile must be specified using the `size` argument.
[ "Add", "default", "values", "to", "the", "instance", "s", "d", "dictionary", "then", "write", "a", "header", "out", "onto", "the", "file", "stream", ".", "The", "size", "of", "the", "profile", "must", "be", "specified", "using", "the", "size", "argument", ...
python
train
rGunti/CarPi-OBDDaemon
obddaemon/custom/Obd2DataParser.py
https://github.com/rGunti/CarPi-OBDDaemon/blob/6831c477b2a00617a0d2ea98b28f3bc5c1ba8e5f/obddaemon/custom/Obd2DataParser.py#L266-L280
def parse_0134_013b(v): """ Parses the O2 Sensor Value (0134 - 013B) and returns two values parsed from it: 1. Fuel-Air Equivalence [Ratio] as a float from 0 - 2 2. Current in [mA] as a float from -128 - 128 :param str v: :return tuple of float, float: """ try: trim_val = trim_ob...
[ "def", "parse_0134_013b", "(", "v", ")", ":", "try", ":", "trim_val", "=", "trim_obd_value", "(", "v", ")", "val_ab", "=", "int", "(", "trim_val", "[", "0", ":", "2", "]", ",", "16", ")", "val_cd", "=", "int", "(", "trim_val", "[", "2", ":", "4",...
Parses the O2 Sensor Value (0134 - 013B) and returns two values parsed from it: 1. Fuel-Air Equivalence [Ratio] as a float from 0 - 2 2. Current in [mA] as a float from -128 - 128 :param str v: :return tuple of float, float:
[ "Parses", "the", "O2", "Sensor", "Value", "(", "0134", "-", "013B", ")", "and", "returns", "two", "values", "parsed", "from", "it", ":", "1", ".", "Fuel", "-", "Air", "Equivalence", "[", "Ratio", "]", "as", "a", "float", "from", "0", "-", "2", "2",...
python
train
GiulioRossetti/ndlib
ndlib/models/DynamicCompostiteModel.py
https://github.com/GiulioRossetti/ndlib/blob/23ecf50c0f76ff2714471071ab9ecb600f4a9832/ndlib/models/DynamicCompostiteModel.py#L30-L70
def iteration(self, node_status=True): """ Execute a single model iteration :return: Iteration_id, Incremental node status (dictionary node->status) """ self.clean_initial_status(self.available_statuses.values()) actual_status = {node: nstatus for node, nstatus in future...
[ "def", "iteration", "(", "self", ",", "node_status", "=", "True", ")", ":", "self", ".", "clean_initial_status", "(", "self", ".", "available_statuses", ".", "values", "(", ")", ")", "actual_status", "=", "{", "node", ":", "nstatus", "for", "node", ",", ...
Execute a single model iteration :return: Iteration_id, Incremental node status (dictionary node->status)
[ "Execute", "a", "single", "model", "iteration" ]
python
train
FutunnOpen/futuquant
futuquant/trade/trade_query.py
https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/trade/trade_query.py#L143-L158
def pack_req(cls, code, pl_ratio_min, pl_ratio_max, trd_env, acc_id, trd_mkt, conn_id): """Convert from user request for trading days to PLS request""" from futuquant.common.pb.Trd_GetPositionList_pb2 import Request req = Request() req.c2s.header.trdEnv = TRD_ENV_MAP[trd...
[ "def", "pack_req", "(", "cls", ",", "code", ",", "pl_ratio_min", ",", "pl_ratio_max", ",", "trd_env", ",", "acc_id", ",", "trd_mkt", ",", "conn_id", ")", ":", "from", "futuquant", ".", "common", ".", "pb", ".", "Trd_GetPositionList_pb2", "import", "Request",...
Convert from user request for trading days to PLS request
[ "Convert", "from", "user", "request", "for", "trading", "days", "to", "PLS", "request" ]
python
train
theislab/scanpy
scanpy/_exporting.py
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/_exporting.py#L231-L250
def write_hdf5_genes(E, gene_list, filename): '''SPRING standard: filename = main_spring_dir + "counts_norm_sparse_genes.hdf5"''' E = E.tocsc() hf = h5py.File(filename, 'w') counts_group = hf.create_group('counts') cix_group = hf.create_group('cell_ix') hf.attrs['ncells'] = E.shape[0] hf....
[ "def", "write_hdf5_genes", "(", "E", ",", "gene_list", ",", "filename", ")", ":", "E", "=", "E", ".", "tocsc", "(", ")", "hf", "=", "h5py", ".", "File", "(", "filename", ",", "'w'", ")", "counts_group", "=", "hf", ".", "create_group", "(", "'counts'"...
SPRING standard: filename = main_spring_dir + "counts_norm_sparse_genes.hdf5"
[ "SPRING", "standard", ":", "filename", "=", "main_spring_dir", "+", "counts_norm_sparse_genes", ".", "hdf5" ]
python
train
Unidata/MetPy
metpy/plots/_util.py
https://github.com/Unidata/MetPy/blob/16f68a94919b9a82dcf9cada2169cf039129e67b/metpy/plots/_util.py#L103-L128
def add_metpy_logo(fig, x=10, y=25, zorder=100, size='small', **kwargs): """Add the MetPy logo to a figure. Adds an image of the MetPy logo to the figure. Parameters ---------- fig : `matplotlib.figure` The `figure` instance used for plotting x : int x position padding in pixels ...
[ "def", "add_metpy_logo", "(", "fig", ",", "x", "=", "10", ",", "y", "=", "25", ",", "zorder", "=", "100", ",", "size", "=", "'small'", ",", "*", "*", "kwargs", ")", ":", "return", "_add_logo", "(", "fig", ",", "x", "=", "x", ",", "y", "=", "y...
Add the MetPy logo to a figure. Adds an image of the MetPy logo to the figure. Parameters ---------- fig : `matplotlib.figure` The `figure` instance used for plotting x : int x position padding in pixels y : float y position padding in pixels zorder : int The zo...
[ "Add", "the", "MetPy", "logo", "to", "a", "figure", "." ]
python
train
estnltk/estnltk
estnltk/wordnet/eurown.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2037-L2045
def addInternalLink(self, link): '''Appends InternalLink ''' if isinstance(link, InternalLink): self.internalLinks.append(link) else: raise InternalLinkError( 'link Type should be InternalLink, not %s' % type(link))
[ "def", "addInternalLink", "(", "self", ",", "link", ")", ":", "if", "isinstance", "(", "link", ",", "InternalLink", ")", ":", "self", ".", "internalLinks", ".", "append", "(", "link", ")", "else", ":", "raise", "InternalLinkError", "(", "'link Type should be...
Appends InternalLink
[ "Appends", "InternalLink" ]
python
train
brainiak/brainiak
brainiak/fcma/voxelselector.py
https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/fcma/voxelselector.py#L255-L282
def _worker(self, clf): """Worker node's operation. Receiving tasks from the master to process and sending the result back Parameters ---------- clf: classification function the classifier to be used in cross validation Returns ------- None ...
[ "def", "_worker", "(", "self", ",", "clf", ")", ":", "logger", ".", "debug", "(", "'worker %d is running, waiting for tasks from master at rank %d'", "%", "(", "MPI", ".", "COMM_WORLD", ".", "Get_rank", "(", ")", ",", "self", ".", "master_rank", ")", ")", "com...
Worker node's operation. Receiving tasks from the master to process and sending the result back Parameters ---------- clf: classification function the classifier to be used in cross validation Returns ------- None
[ "Worker", "node", "s", "operation", "." ]
python
train
nugget/python-insteonplm
insteonplm/tools.py
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/tools.py#L127-L131
def async_aldb_loaded_callback(self): """Unlock the ALDB load lock when loading is complete.""" if self.aldb_load_lock.locked(): self.aldb_load_lock.release() _LOGGING.info('ALDB Loaded')
[ "def", "async_aldb_loaded_callback", "(", "self", ")", ":", "if", "self", ".", "aldb_load_lock", ".", "locked", "(", ")", ":", "self", ".", "aldb_load_lock", ".", "release", "(", ")", "_LOGGING", ".", "info", "(", "'ALDB Loaded'", ")" ]
Unlock the ALDB load lock when loading is complete.
[ "Unlock", "the", "ALDB", "load", "lock", "when", "loading", "is", "complete", "." ]
python
train
pytorch/text
torchtext/vocab.py
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/vocab.py#L167-L189
def set_vectors(self, stoi, vectors, dim, unk_init=torch.Tensor.zero_): """ Set the vectors for the Vocab instance from a collection of Tensors. Arguments: stoi: A dictionary of string to the index of the associated vector in the `vectors` input argument. ...
[ "def", "set_vectors", "(", "self", ",", "stoi", ",", "vectors", ",", "dim", ",", "unk_init", "=", "torch", ".", "Tensor", ".", "zero_", ")", ":", "self", ".", "vectors", "=", "torch", ".", "Tensor", "(", "len", "(", "self", ")", ",", "dim", ")", ...
Set the vectors for the Vocab instance from a collection of Tensors. Arguments: stoi: A dictionary of string to the index of the associated vector in the `vectors` input argument. vectors: An indexed iterable (or other structure supporting __getitem__) that ...
[ "Set", "the", "vectors", "for", "the", "Vocab", "instance", "from", "a", "collection", "of", "Tensors", "." ]
python
train
core/uricore
uricore/wkz_wsgi.py
https://github.com/core/uricore/blob/dc5ef4be7bd93da4c39e5c1cbd1ae4f3ad3f1f2a/uricore/wkz_wsgi.py#L119-L134
def readline(self, size=None): """Reads one line from the stream.""" if self._pos >= self.limit: return self.on_exhausted() if size is None: size = self.limit - self._pos else: size = min(size, self.limit - self._pos) try: line = se...
[ "def", "readline", "(", "self", ",", "size", "=", "None", ")", ":", "if", "self", ".", "_pos", ">=", "self", ".", "limit", ":", "return", "self", ".", "on_exhausted", "(", ")", "if", "size", "is", "None", ":", "size", "=", "self", ".", "limit", "...
Reads one line from the stream.
[ "Reads", "one", "line", "from", "the", "stream", "." ]
python
train
ladybug-tools/ladybug
ladybug/datacollection.py
https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/datacollection.py#L540-L551
def from_json(cls, data): """Create a Data Collection from a dictionary. Args: { "header": A Ladybug Header, "values": An array of values, } """ assert 'header' in data, 'Required keyword "header" is missing!' assert 'value...
[ "def", "from_json", "(", "cls", ",", "data", ")", ":", "assert", "'header'", "in", "data", ",", "'Required keyword \"header\" is missing!'", "assert", "'values'", "in", "data", ",", "'Required keyword \"values\" is missing!'", "return", "cls", "(", "Header", ".", "f...
Create a Data Collection from a dictionary. Args: { "header": A Ladybug Header, "values": An array of values, }
[ "Create", "a", "Data", "Collection", "from", "a", "dictionary", "." ]
python
train
mikedh/trimesh
trimesh/base.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/base.py#L1084-L1121
def update_faces(self, mask): """ In many cases, we will want to remove specific faces. However, there is additional bookkeeping to do this cleanly. This function updates the set of faces with a validity mask, as well as keeping track of normals and colors. Parameters ...
[ "def", "update_faces", "(", "self", ",", "mask", ")", ":", "# if the mesh is already empty we can't remove anything", "if", "self", ".", "is_empty", ":", "return", "mask", "=", "np", ".", "asanyarray", "(", "mask", ")", "if", "mask", ".", "dtype", ".", "name",...
In many cases, we will want to remove specific faces. However, there is additional bookkeeping to do this cleanly. This function updates the set of faces with a validity mask, as well as keeping track of normals and colors. Parameters --------- valid : (m) int or (len(se...
[ "In", "many", "cases", "we", "will", "want", "to", "remove", "specific", "faces", ".", "However", "there", "is", "additional", "bookkeeping", "to", "do", "this", "cleanly", ".", "This", "function", "updates", "the", "set", "of", "faces", "with", "a", "vali...
python
train
robotools/fontParts
Lib/fontParts/base/font.py
https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/font.py#L490-L531
def _getFlatKerning(self): """ This is the environment implementation of :meth:`BaseFont.getFlatKerning`. Subclasses may override this method. """ kernOrder = { (True, True): 0, # group group (True, False): 1, # group glyph (False, T...
[ "def", "_getFlatKerning", "(", "self", ")", ":", "kernOrder", "=", "{", "(", "True", ",", "True", ")", ":", "0", ",", "# group group", "(", "True", ",", "False", ")", ":", "1", ",", "# group glyph", "(", "False", ",", "True", ")", ":", "2", ",", ...
This is the environment implementation of :meth:`BaseFont.getFlatKerning`. Subclasses may override this method.
[ "This", "is", "the", "environment", "implementation", "of", ":", "meth", ":", "BaseFont", ".", "getFlatKerning", "." ]
python
train
neighbordog/deviantart
deviantart/api.py
https://github.com/neighbordog/deviantart/blob/5612f1d5e2139a48c9d793d7fd19cde7e162d7b1/deviantart/api.py#L222-L295
def browse(self, endpoint="hot", category_path="", seed="", q="", timerange="24hr", tag="", offset=0, limit=10): """Fetch deviations from public endpoints :param endpoint: The endpoint from which the deviations will be fetched (hot/morelikethis/newest/undiscovered/popular/tags) :param category...
[ "def", "browse", "(", "self", ",", "endpoint", "=", "\"hot\"", ",", "category_path", "=", "\"\"", ",", "seed", "=", "\"\"", ",", "q", "=", "\"\"", ",", "timerange", "=", "\"24hr\"", ",", "tag", "=", "\"\"", ",", "offset", "=", "0", ",", "limit", "=...
Fetch deviations from public endpoints :param endpoint: The endpoint from which the deviations will be fetched (hot/morelikethis/newest/undiscovered/popular/tags) :param category_path: category path to fetch from :param q: Search query term :param timerange: The timerange :param...
[ "Fetch", "deviations", "from", "public", "endpoints" ]
python
train
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L310-L325
def release(self, on_element=None): """ Releasing a held mouse button on an element. :Args: - on_element: The element to mouse up. If None, releases on current mouse position. """ if on_element: self.move_to_element(on_element) if self._dr...
[ "def", "release", "(", "self", ",", "on_element", "=", "None", ")", ":", "if", "on_element", ":", "self", ".", "move_to_element", "(", "on_element", ")", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "pointer_action", "....
Releasing a held mouse button on an element. :Args: - on_element: The element to mouse up. If None, releases on current mouse position.
[ "Releasing", "a", "held", "mouse", "button", "on", "an", "element", "." ]
python
train
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L44-L53
def estimated_position(self): """ Get the estimated cubie of solved pair. """ corner = {"D":self.cube["D"]["D"]} edge = {} for cubie in (corner, edge): for face in self.pair: cubie.update({face:self.cube[face][face]}) return (Corner(**c...
[ "def", "estimated_position", "(", "self", ")", ":", "corner", "=", "{", "\"D\"", ":", "self", ".", "cube", "[", "\"D\"", "]", "[", "\"D\"", "]", "}", "edge", "=", "{", "}", "for", "cubie", "in", "(", "corner", ",", "edge", ")", ":", "for", "face"...
Get the estimated cubie of solved pair.
[ "Get", "the", "estimated", "cubie", "of", "solved", "pair", "." ]
python
train
umutbozkurt/django-rest-framework-mongoengine
rest_framework_mongoengine/generics.py
https://github.com/umutbozkurt/django-rest-framework-mongoengine/blob/2fe6de53907b31a5e8b742e4c6b728942b5fa4f0/rest_framework_mongoengine/generics.py#L8-L13
def get_object_or_404(queryset, *args, **kwargs): """ replacement of rest_framework.generics and django.shrtcuts analogues """ try: return queryset.get(*args, **kwargs) except (ValueError, TypeError, DoesNotExist, ValidationError): raise Http404()
[ "def", "get_object_or_404", "(", "queryset", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "queryset", ".", "get", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "(", "ValueError", ",", "TypeError", ",", "DoesN...
replacement of rest_framework.generics and django.shrtcuts analogues
[ "replacement", "of", "rest_framework", ".", "generics", "and", "django", ".", "shrtcuts", "analogues" ]
python
train
scikit-tda/kepler-mapper
kmapper/visuals.py
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/visuals.py#L212-L236
def build_histogram(data, colorscale=None, nbins=10): """ Build histogram of data based on values of color_function """ if colorscale is None: colorscale = colorscale_default # TODO: we should weave this method of handling colors into the normal build_histogram and combine both functions c...
[ "def", "build_histogram", "(", "data", ",", "colorscale", "=", "None", ",", "nbins", "=", "10", ")", ":", "if", "colorscale", "is", "None", ":", "colorscale", "=", "colorscale_default", "# TODO: we should weave this method of handling colors into the normal build_histogra...
Build histogram of data based on values of color_function
[ "Build", "histogram", "of", "data", "based", "on", "values", "of", "color_function" ]
python
train
kivy/python-for-android
pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py
https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L338-L353
def do_indent(s, width=4, indentfirst=False): """Return a copy of the passed string, each line indented by 4 spaces. The first line is not indented. If you want to change the number of spaces or indent the first line too you can pass additional parameters to the filter: .. sourcecode:: jinja ...
[ "def", "do_indent", "(", "s", ",", "width", "=", "4", ",", "indentfirst", "=", "False", ")", ":", "indention", "=", "u' '", "*", "width", "rv", "=", "(", "u'\\n'", "+", "indention", ")", ".", "join", "(", "s", ".", "splitlines", "(", ")", ")", "i...
Return a copy of the passed string, each line indented by 4 spaces. The first line is not indented. If you want to change the number of spaces or indent the first line too you can pass additional parameters to the filter: .. sourcecode:: jinja {{ mytext|indent(2, true) }} indent by...
[ "Return", "a", "copy", "of", "the", "passed", "string", "each", "line", "indented", "by", "4", "spaces", ".", "The", "first", "line", "is", "not", "indented", ".", "If", "you", "want", "to", "change", "the", "number", "of", "spaces", "or", "indent", "t...
python
train
senaite/senaite.core
bika/lims/browser/batchfolder.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/batchfolder.py#L114-L120
def before_render(self): """Before template render hook """ super(BatchFolderContentsView, self).before_render() if self.context.portal_type == "BatchFolder": self.request.set("disable_border", 1)
[ "def", "before_render", "(", "self", ")", ":", "super", "(", "BatchFolderContentsView", ",", "self", ")", ".", "before_render", "(", ")", "if", "self", ".", "context", ".", "portal_type", "==", "\"BatchFolder\"", ":", "self", ".", "request", ".", "set", "(...
Before template render hook
[ "Before", "template", "render", "hook" ]
python
train
inspirehep/refextract
refextract/documents/text.py
https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/documents/text.py#L139-L164
def remove_and_record_multiple_spaces_in_line(line): """For a given string, locate all ocurrences of multiple spaces together in the line, record the number of spaces found at each position, and replace them with a single space. @param line: (string) the text line to be processed for multiple ...
[ "def", "remove_and_record_multiple_spaces_in_line", "(", "line", ")", ":", "removed_spaces", "=", "{", "}", "# get a collection of match objects for all instances of", "# multiple-spaces found in the line:", "multispace_matches", "=", "re_group_captured_multiple_space", ".", "findite...
For a given string, locate all ocurrences of multiple spaces together in the line, record the number of spaces found at each position, and replace them with a single space. @param line: (string) the text line to be processed for multiple spaces. @return: (tuple) countaining a diction...
[ "For", "a", "given", "string", "locate", "all", "ocurrences", "of", "multiple", "spaces", "together", "in", "the", "line", "record", "the", "number", "of", "spaces", "found", "at", "each", "position", "and", "replace", "them", "with", "a", "single", "space",...
python
train
cloudera/cm_api
python/src/cm_api/http_client.py
https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/http_client.py#L150-L183
def execute(self, http_method, path, params=None, data=None, headers=None): """ Submit an HTTP request. @param http_method: GET, POST, PUT, DELETE @param path: The path of the resource. @param params: Key-value parameter data. @param data: The data to attach to the body of the request. @para...
[ "def", "execute", "(", "self", ",", "http_method", ",", "path", ",", "params", "=", "None", ",", "data", "=", "None", ",", "headers", "=", "None", ")", ":", "# Prepare URL and params", "url", "=", "self", ".", "_make_url", "(", "path", ",", "params", "...
Submit an HTTP request. @param http_method: GET, POST, PUT, DELETE @param path: The path of the resource. @param params: Key-value parameter data. @param data: The data to attach to the body of the request. @param headers: The headers to set for this request. @return: The result of urllib2.urlo...
[ "Submit", "an", "HTTP", "request", ".", "@param", "http_method", ":", "GET", "POST", "PUT", "DELETE", "@param", "path", ":", "The", "path", "of", "the", "resource", ".", "@param", "params", ":", "Key", "-", "value", "parameter", "data", ".", "@param", "d...
python
train
pydata/xarray
xarray/plot/utils.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L624-L649
def _infer_interval_breaks(coord, axis=0, check_monotonic=False): """ >>> _infer_interval_breaks(np.arange(5)) array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5]) >>> _infer_interval_breaks([[0, 1], [3, 4]], axis=1) array([[-0.5, 0.5, 1.5], [ 2.5, 3.5, 4.5]]) """ coord = np.asarray(co...
[ "def", "_infer_interval_breaks", "(", "coord", ",", "axis", "=", "0", ",", "check_monotonic", "=", "False", ")", ":", "coord", "=", "np", ".", "asarray", "(", "coord", ")", "if", "check_monotonic", "and", "not", "_is_monotonic", "(", "coord", ",", "axis", ...
>>> _infer_interval_breaks(np.arange(5)) array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5]) >>> _infer_interval_breaks([[0, 1], [3, 4]], axis=1) array([[-0.5, 0.5, 1.5], [ 2.5, 3.5, 4.5]])
[ ">>>", "_infer_interval_breaks", "(", "np", ".", "arange", "(", "5", "))", "array", "(", "[", "-", "0", ".", "5", "0", ".", "5", "1", ".", "5", "2", ".", "5", "3", ".", "5", "4", ".", "5", "]", ")", ">>>", "_infer_interval_breaks", "(", "[[", ...
python
train
pri22296/beautifultable
beautifultable/beautifultable.py
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L1188-L1205
def get_table_width(self): """Get the width of the table as number of characters. Column width should be set prior to calling this method. Returns ------- int Width of the table as number of characters. """ if self.column_count == 0: retu...
[ "def", "get_table_width", "(", "self", ")", ":", "if", "self", ".", "column_count", "==", "0", ":", "return", "0", "width", "=", "sum", "(", "self", ".", "_column_widths", ")", "width", "+=", "(", "(", "self", ".", "_column_count", "-", "1", ")", "*"...
Get the width of the table as number of characters. Column width should be set prior to calling this method. Returns ------- int Width of the table as number of characters.
[ "Get", "the", "width", "of", "the", "table", "as", "number", "of", "characters", "." ]
python
train
projectshift/shift-boiler
boiler/user/views_social.py
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/views_social.py#L60-L66
def next(self): """ Where to redirect after authorization """ next = request.args.get('next') if next is None: params = self.default_redirect_params next = url_for(self.default_redirect_endpoint, **params) return next
[ "def", "next", "(", "self", ")", ":", "next", "=", "request", ".", "args", ".", "get", "(", "'next'", ")", "if", "next", "is", "None", ":", "params", "=", "self", ".", "default_redirect_params", "next", "=", "url_for", "(", "self", ".", "default_redire...
Where to redirect after authorization
[ "Where", "to", "redirect", "after", "authorization" ]
python
train
tanghaibao/jcvi
jcvi/apps/bwa.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/bwa.py#L208-L233
def sampe(args, opts): """ %prog sampe database.fasta read1.fq read2.fq Wrapper for `bwa sampe`. Output will be read1.sam. """ dbfile, read1file, read2file = args dbfile = check_index(dbfile) sai1file = check_aln(dbfile, read1file, cpus=opts.cpus) sai2file = check_aln(dbfile, read2file,...
[ "def", "sampe", "(", "args", ",", "opts", ")", ":", "dbfile", ",", "read1file", ",", "read2file", "=", "args", "dbfile", "=", "check_index", "(", "dbfile", ")", "sai1file", "=", "check_aln", "(", "dbfile", ",", "read1file", ",", "cpus", "=", "opts", "....
%prog sampe database.fasta read1.fq read2.fq Wrapper for `bwa sampe`. Output will be read1.sam.
[ "%prog", "sampe", "database", ".", "fasta", "read1", ".", "fq", "read2", ".", "fq" ]
python
train
acutesoftware/virtual-AI-simulator
vais/battle.py
https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/battle.py#L129-L145
def show_message(self, c_attack, c_defend, result, dmg, print_console='Yes'): """ function to wrap the display of the battle messages """ perc_health_att = '[' + str(round((c_attack.stats['Health']*100) / c_attack.stats['max_health'] )) + '%]' perc_health_def = '[' + str(round((c...
[ "def", "show_message", "(", "self", ",", "c_attack", ",", "c_defend", ",", "result", ",", "dmg", ",", "print_console", "=", "'Yes'", ")", ":", "perc_health_att", "=", "'['", "+", "str", "(", "round", "(", "(", "c_attack", ".", "stats", "[", "'Health'", ...
function to wrap the display of the battle messages
[ "function", "to", "wrap", "the", "display", "of", "the", "battle", "messages" ]
python
train
blockcypher/blockcypher-python
blockcypher/api.py
https://github.com/blockcypher/blockcypher-python/blob/7601ea21916957ff279384fd699527ff9c28a56e/blockcypher/api.py#L1143-L1171
def get_wallet_addresses(wallet_name, api_key, is_hd_wallet=False, zero_balance=None, used=None, omit_addresses=False, coin_symbol='btc'): ''' Returns a list of wallet addresses as well as some meta-data ''' assert is_valid_coin_symbol(coin_symbol) assert api_key assert len(wallet_name) ...
[ "def", "get_wallet_addresses", "(", "wallet_name", ",", "api_key", ",", "is_hd_wallet", "=", "False", ",", "zero_balance", "=", "None", ",", "used", "=", "None", ",", "omit_addresses", "=", "False", ",", "coin_symbol", "=", "'btc'", ")", ":", "assert", "is_v...
Returns a list of wallet addresses as well as some meta-data
[ "Returns", "a", "list", "of", "wallet", "addresses", "as", "well", "as", "some", "meta", "-", "data" ]
python
train
ynop/audiomate
audiomate/corpus/io/voxforge.py
https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/voxforge.py#L188-L234
def parse_speaker_info(readme_path): """ Parse speaker info and return tuple (idx, gender). """ idx = None gender = issuers.Gender.UNKNOWN age_group = issuers.AgeGroup.UNKNOWN native_lang = None with open(readme_path, 'r', errors='ignore') as f: for raw_line ...
[ "def", "parse_speaker_info", "(", "readme_path", ")", ":", "idx", "=", "None", "gender", "=", "issuers", ".", "Gender", ".", "UNKNOWN", "age_group", "=", "issuers", ".", "AgeGroup", ".", "UNKNOWN", "native_lang", "=", "None", "with", "open", "(", "readme_pat...
Parse speaker info and return tuple (idx, gender).
[ "Parse", "speaker", "info", "and", "return", "tuple", "(", "idx", "gender", ")", "." ]
python
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L320-L345
def _consume_queue(self): """ Continually blocks until data is on the internal queue, then calls the session's registered callback and sends a PublishMessageReceived if callback returned True. """ while True: session, block_id, raw_data = self._queue.get() ...
[ "def", "_consume_queue", "(", "self", ")", ":", "while", "True", ":", "session", ",", "block_id", ",", "raw_data", "=", "self", ".", "_queue", ".", "get", "(", ")", "data", "=", "json", ".", "loads", "(", "raw_data", ".", "decode", "(", "'utf-8'", ")...
Continually blocks until data is on the internal queue, then calls the session's registered callback and sends a PublishMessageReceived if callback returned True.
[ "Continually", "blocks", "until", "data", "is", "on", "the", "internal", "queue", "then", "calls", "the", "session", "s", "registered", "callback", "and", "sends", "a", "PublishMessageReceived", "if", "callback", "returned", "True", "." ]
python
train
kelproject/pykube
pykube/config.py
https://github.com/kelproject/pykube/blob/e8a46298a592ad9037587afb707ac75b3114eff9/pykube/config.py#L184-L188
def user(self): """ Returns the current user set by current context """ return self.users.get(self.contexts[self.current_context].get("user", ""), {})
[ "def", "user", "(", "self", ")", ":", "return", "self", ".", "users", ".", "get", "(", "self", ".", "contexts", "[", "self", ".", "current_context", "]", ".", "get", "(", "\"user\"", ",", "\"\"", ")", ",", "{", "}", ")" ]
Returns the current user set by current context
[ "Returns", "the", "current", "user", "set", "by", "current", "context" ]
python
train
lacava/few
few/variation.py
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/variation.py#L174-L176
def mutate(self,p_i,func_set,term_set): #, max_depth=2 """point mutation, addition, removal""" self.point_mutate(p_i,func_set,term_set)
[ "def", "mutate", "(", "self", ",", "p_i", ",", "func_set", ",", "term_set", ")", ":", "#, max_depth=2", "self", ".", "point_mutate", "(", "p_i", ",", "func_set", ",", "term_set", ")" ]
point mutation, addition, removal
[ "point", "mutation", "addition", "removal" ]
python
train
pivotal-energy-solutions/django-datatable-view
datatableview/helpers.py
https://github.com/pivotal-energy-solutions/django-datatable-view/blob/00b77a9b5051c34e258c51b06c020e92edf15034/datatableview/helpers.py#L289-L399
def make_xeditable(instance=None, extra_attrs=[], *args, **kwargs): """ Converts the contents of the column into an ``<a>`` tag with the required DOM attributes to power the X-Editable UI. The following keyword arguments are all optional, but may be provided when pre-calling the helper, to customiz...
[ "def", "make_xeditable", "(", "instance", "=", "None", ",", "extra_attrs", "=", "[", "]", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "instance", "is", "None", ":", "# Preloading kwargs into the helper for deferred execution", "helper", "=", "pa...
Converts the contents of the column into an ``<a>`` tag with the required DOM attributes to power the X-Editable UI. The following keyword arguments are all optional, but may be provided when pre-calling the helper, to customize the output of the helper once it is run per object record: * ``type``...
[ "Converts", "the", "contents", "of", "the", "column", "into", "an", "<a", ">", "tag", "with", "the", "required", "DOM", "attributes", "to", "power", "the", "X", "-", "Editable", "UI", "." ]
python
train
xolox/python-vcs-repo-mgr
vcs_repo_mgr/backends/git.py
https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/vcs_repo_mgr/backends/git.py#L55-L58
def get_vcs_directory(context, directory): """Get the pathname of the directory containing the version control metadata files.""" nested = os.path.join(directory, '.git') return nested if context.is_directory(nested) else directory
[ "def", "get_vcs_directory", "(", "context", ",", "directory", ")", ":", "nested", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "'.git'", ")", "return", "nested", "if", "context", ".", "is_directory", "(", "nested", ")", "else", "directory" ]
Get the pathname of the directory containing the version control metadata files.
[ "Get", "the", "pathname", "of", "the", "directory", "containing", "the", "version", "control", "metadata", "files", "." ]
python
train
Cologler/fsoopify-python
fsoopify/nodes.py
https://github.com/Cologler/fsoopify-python/blob/83d45f16ae9abdea4fcc829373c32df501487dda/fsoopify/nodes.py#L299-L303
def has_file(self, name: str): ''' check whether this directory contains the file. ''' return os.path.isfile(self._path / name)
[ "def", "has_file", "(", "self", ",", "name", ":", "str", ")", ":", "return", "os", ".", "path", ".", "isfile", "(", "self", ".", "_path", "/", "name", ")" ]
check whether this directory contains the file.
[ "check", "whether", "this", "directory", "contains", "the", "file", "." ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/__init__.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/__init__.py#L79-L92
def show_position(self): '''show map position click information''' pos = self.click_position dms = (mp_util.degrees_to_dms(pos[0]), mp_util.degrees_to_dms(pos[1])) msg = "Coordinates in WGS84\n" msg += "Decimal: %.6f %.6f\n" % (pos[0], pos[1]) msg += "DMS: %s %s\n" %...
[ "def", "show_position", "(", "self", ")", ":", "pos", "=", "self", ".", "click_position", "dms", "=", "(", "mp_util", ".", "degrees_to_dms", "(", "pos", "[", "0", "]", ")", ",", "mp_util", ".", "degrees_to_dms", "(", "pos", "[", "1", "]", ")", ")", ...
show map position click information
[ "show", "map", "position", "click", "information" ]
python
train
vxgmichel/aiostream
aiostream/stream/select.py
https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/select.py#L82-L93
async def filterindex(source, func): """Filter an asynchronous sequence using the index of the elements. The given function is synchronous, takes the index as an argument, and returns ``True`` if the corresponding should be forwarded, ``False`` otherwise. """ source = transform.enumerate.raw(so...
[ "async", "def", "filterindex", "(", "source", ",", "func", ")", ":", "source", "=", "transform", ".", "enumerate", ".", "raw", "(", "source", ")", "async", "with", "streamcontext", "(", "source", ")", "as", "streamer", ":", "async", "for", "i", ",", "i...
Filter an asynchronous sequence using the index of the elements. The given function is synchronous, takes the index as an argument, and returns ``True`` if the corresponding should be forwarded, ``False`` otherwise.
[ "Filter", "an", "asynchronous", "sequence", "using", "the", "index", "of", "the", "elements", "." ]
python
train
Rapptz/discord.py
discord/client.py
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/client.py#L740-L767
def event(self, coro): """A decorator that registers an event to listen to. You can find more info about the events on the :ref:`documentation below <discord-api-events>`. The events must be a |corourl|_, if not, :exc:`TypeError` is raised. Example --------- .. code-b...
[ "def", "event", "(", "self", ",", "coro", ")", ":", "if", "not", "asyncio", ".", "iscoroutinefunction", "(", "coro", ")", ":", "raise", "TypeError", "(", "'event registered must be a coroutine function'", ")", "setattr", "(", "self", ",", "coro", ".", "__name_...
A decorator that registers an event to listen to. You can find more info about the events on the :ref:`documentation below <discord-api-events>`. The events must be a |corourl|_, if not, :exc:`TypeError` is raised. Example --------- .. code-block:: python3 @clien...
[ "A", "decorator", "that", "registers", "an", "event", "to", "listen", "to", "." ]
python
train
sundarnagarajan/cffi_utils
cffi_utils/py2to3.py
https://github.com/sundarnagarajan/cffi_utils/blob/1d5ab2d2fcb962372228033106bc23f1d73d31fa/cffi_utils/py2to3.py#L306-L336
def get_rand_int(encoding='latin1', avoid=[]): ''' encoding-->str: one of ENCODINGS avoid-->list of int: to void (unprintable chars etc) Returns-->int that can be converted to requested encoding which is NOT in avoid ''' UNICODE_LIMIT = 0x10ffff # See: https://en.wikipedia.org/...
[ "def", "get_rand_int", "(", "encoding", "=", "'latin1'", ",", "avoid", "=", "[", "]", ")", ":", "UNICODE_LIMIT", "=", "0x10ffff", "# See: https://en.wikipedia.org/wiki/UTF-8#Invalid_code_points", "SURROGATE_RANGE", "=", "(", "0xD800", ",", "0xDFFF", ")", "if", "enco...
encoding-->str: one of ENCODINGS avoid-->list of int: to void (unprintable chars etc) Returns-->int that can be converted to requested encoding which is NOT in avoid
[ "encoding", "--", ">", "str", ":", "one", "of", "ENCODINGS", "avoid", "--", ">", "list", "of", "int", ":", "to", "void", "(", "unprintable", "chars", "etc", ")", "Returns", "--", ">", "int", "that", "can", "be", "converted", "to", "requested", "encodin...
python
test
cmutel/constructive_geometries
constructive_geometries/cg.py
https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L22-L27
def has_gis(wrapped, instance, args, kwargs): """Skip function execution if there are no presamples""" if gis: return wrapped(*args, **kwargs) else: warn(MISSING_GIS)
[ "def", "has_gis", "(", "wrapped", ",", "instance", ",", "args", ",", "kwargs", ")", ":", "if", "gis", ":", "return", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", "else", ":", "warn", "(", "MISSING_GIS", ")" ]
Skip function execution if there are no presamples
[ "Skip", "function", "execution", "if", "there", "are", "no", "presamples" ]
python
train
lemieuxl/pyGenClean
pyGenClean/SexCheck/sex_check.py
https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L127-L154
def createGenderPlot(bfile, intensities, problematic_samples, format, out_prefix): """Creates the gender plot. :param bfile: the prefix of the input binary file. :param intensities: the file containing the intensities. :param problematic_samples: the file containing the problematic...
[ "def", "createGenderPlot", "(", "bfile", ",", "intensities", ",", "problematic_samples", ",", "format", ",", "out_prefix", ")", ":", "gender_plot_options", "=", "[", "\"--bfile\"", ",", "bfile", ",", "\"--intensities\"", ",", "intensities", ",", "\"--sex-problems\""...
Creates the gender plot. :param bfile: the prefix of the input binary file. :param intensities: the file containing the intensities. :param problematic_samples: the file containing the problematic samples. :param format: the format of the output plot. :param out_prefix: the prefix of the output fil...
[ "Creates", "the", "gender", "plot", "." ]
python
train
Neurita/boyle
boyle/dicom/sets.py
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/sets.py#L151-L171
def get_dcm_reader(store_metadata=True, header_fields=None): """ Creates a lambda function to read DICOM files. If store_store_metadata is False, will only return the file path. Else if you give header_fields, will return only the set of of header_fields within a DicomFile object...
[ "def", "get_dcm_reader", "(", "store_metadata", "=", "True", ",", "header_fields", "=", "None", ")", ":", "if", "not", "store_metadata", ":", "return", "lambda", "fpath", ":", "fpath", "if", "header_fields", "is", "None", ":", "build_dcm", "=", "lambda", "fp...
Creates a lambda function to read DICOM files. If store_store_metadata is False, will only return the file path. Else if you give header_fields, will return only the set of of header_fields within a DicomFile object or the whole DICOM file if None. :return: function This...
[ "Creates", "a", "lambda", "function", "to", "read", "DICOM", "files", ".", "If", "store_store_metadata", "is", "False", "will", "only", "return", "the", "file", "path", ".", "Else", "if", "you", "give", "header_fields", "will", "return", "only", "the", "set"...
python
valid
robhowley/nhlscrapi
nhlscrapi/games/playbyplay.py
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/playbyplay.py#L84-L102
def compute_stats(self): """ Compute the stats defined in ``self.cum_stats``. :returns: collection of all computed :py:class:`.AccumulateStats` :rtype: dict """ if not self.__have_stats: if self.init_cs_teams and self.cum_stats: self._...
[ "def", "compute_stats", "(", "self", ")", ":", "if", "not", "self", ".", "__have_stats", ":", "if", "self", ".", "init_cs_teams", "and", "self", ".", "cum_stats", ":", "self", ".", "__init_cs_teams", "(", ")", "for", "play", "in", "self", ".", "_rep_read...
Compute the stats defined in ``self.cum_stats``. :returns: collection of all computed :py:class:`.AccumulateStats` :rtype: dict
[ "Compute", "the", "stats", "defined", "in", "self", ".", "cum_stats", ".", ":", "returns", ":", "collection", "of", "all", "computed", ":", "py", ":", "class", ":", ".", "AccumulateStats", ":", "rtype", ":", "dict" ]
python
train
Kortemme-Lab/klab
klab/bio/uniprot.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/uniprot.py#L52-L122
def uniprot_map(from_scheme, to_scheme, list_of_from_ids, cache_dir = None, silent = True): '''Maps from one ID scheme to another using the UniProt service. list_of_ids should be a list of strings. This function was adapted from http://www.uniprot.org/faq/28#id_mapping_examples which also gives exam...
[ "def", "uniprot_map", "(", "from_scheme", ",", "to_scheme", ",", "list_of_from_ids", ",", "cache_dir", "=", "None", ",", "silent", "=", "True", ")", ":", "try", ":", "assert", "(", "hasattr", "(", "list_of_from_ids", ",", "'__iter__'", ")", ")", "except", ...
Maps from one ID scheme to another using the UniProt service. list_of_ids should be a list of strings. This function was adapted from http://www.uniprot.org/faq/28#id_mapping_examples which also gives examples of valid values for from_scheme and to_scheme. Note that some conversions are ...
[ "Maps", "from", "one", "ID", "scheme", "to", "another", "using", "the", "UniProt", "service", ".", "list_of_ids", "should", "be", "a", "list", "of", "strings", ".", "This", "function", "was", "adapted", "from", "http", ":", "//", "www", ".", "uniprot", "...
python
train