repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
dingusdk/PythonIhcSdk
ihcsdk/ihcclient.py
https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihcclient.py#L162-L196
def get_runtime_value(self, resourceid: int): """Get runtime value of specified resource it The returned value will be boolean, integer or float Return None if resource cannot be found or on error """ payload = """<getRuntimeValue1 xmlns="utcs">{id}</getRuntimeValue1> ...
[ "def", "get_runtime_value", "(", "self", ",", "resourceid", ":", "int", ")", ":", "payload", "=", "\"\"\"<getRuntimeValue1 xmlns=\"utcs\">{id}</getRuntimeValue1>\n \"\"\"", ".", "format", "(", "id", "=", "resourceid", ")", "xdoc", "=", "self", ".", "c...
Get runtime value of specified resource it The returned value will be boolean, integer or float Return None if resource cannot be found or on error
[ "Get", "runtime", "value", "of", "specified", "resource", "it", "The", "returned", "value", "will", "be", "boolean", "integer", "or", "float", "Return", "None", "if", "resource", "cannot", "be", "found", "or", "on", "error" ]
python
train
42.742857
saltstack/salt
salt/modules/state.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/state.py#L1991-L2029
def show_top(queue=False, **kwargs): ''' Return the top data that the minion will use for a highstate CLI Example: .. code-block:: bash salt '*' state.show_top ''' if 'env' in kwargs: # "env" is not supported; Use "saltenv". kwargs.pop('env') conflict = _check_que...
[ "def", "show_top", "(", "queue", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "'env'", "in", "kwargs", ":", "# \"env\" is not supported; Use \"saltenv\".", "kwargs", ".", "pop", "(", "'env'", ")", "conflict", "=", "_check_queue", "(", "queue", ",",...
Return the top data that the minion will use for a highstate CLI Example: .. code-block:: bash salt '*' state.show_top
[ "Return", "the", "top", "data", "that", "the", "minion", "will", "use", "for", "a", "highstate" ]
python
train
30.333333
google/grr
grr/core/grr_response_core/lib/config_lib.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1523-L1531
def DEFINE_integer_list(self, name, default, help, constant=False): """A helper for defining lists of integer options.""" self.AddOption( type_info.List( name=name, default=default, description=help, validator=type_info.Integer()), constant=constan...
[ "def", "DEFINE_integer_list", "(", "self", ",", "name", ",", "default", ",", "help", ",", "constant", "=", "False", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "List", "(", "name", "=", "name", ",", "default", "=", "default", ",", "descr...
A helper for defining lists of integer options.
[ "A", "helper", "for", "defining", "lists", "of", "integer", "options", "." ]
python
train
34.888889
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L482-L518
def _return_tables(self, mag, imt, val_type): """ Returns the vector of ground motions or standard deviations corresponding to the specific magnitude and intensity measure type. :param val_type: String indicating the type of data {"IMLs", "Total", "Inter" etc} """ ...
[ "def", "_return_tables", "(", "self", ",", "mag", ",", "imt", ",", "val_type", ")", ":", "if", "imt", ".", "name", "in", "'PGA PGV'", ":", "# Get scalar imt", "if", "val_type", "==", "\"IMLs\"", ":", "iml_table", "=", "self", ".", "imls", "[", "imt", "...
Returns the vector of ground motions or standard deviations corresponding to the specific magnitude and intensity measure type. :param val_type: String indicating the type of data {"IMLs", "Total", "Inter" etc}
[ "Returns", "the", "vector", "of", "ground", "motions", "or", "standard", "deviations", "corresponding", "to", "the", "specific", "magnitude", "and", "intensity", "measure", "type", "." ]
python
train
45.297297
datastax/python-driver
cassandra/io/twistedreactor.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/io/twistedreactor.py#L48-L57
def dataReceived(self, data): """ Callback function that is called when data has been received on the connection. Reaches back to the Connection object and queues the data for processing. """ self.connection._iobuf.write(data) self.connection.handle_read(...
[ "def", "dataReceived", "(", "self", ",", "data", ")", ":", "self", ".", "connection", ".", "_iobuf", ".", "write", "(", "data", ")", "self", ".", "connection", ".", "handle_read", "(", ")" ]
Callback function that is called when data has been received on the connection. Reaches back to the Connection object and queues the data for processing.
[ "Callback", "function", "that", "is", "called", "when", "data", "has", "been", "received", "on", "the", "connection", "." ]
python
train
31.2
elifesciences/elife-tools
elifetools/parseJATS.py
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1913-L1942
def full_award_group_funding_source(tag): """ Given a funding group element Find the award group funding sources, one for each item found in the get_funding_group section """ award_group_funding_sources = [] funding_source_nodes = extract_nodes(tag, "funding-source") for funding_source_n...
[ "def", "full_award_group_funding_source", "(", "tag", ")", ":", "award_group_funding_sources", "=", "[", "]", "funding_source_nodes", "=", "extract_nodes", "(", "tag", ",", "\"funding-source\"", ")", "for", "funding_source_node", "in", "funding_source_nodes", ":", "awar...
Given a funding group element Find the award group funding sources, one for each item found in the get_funding_group section
[ "Given", "a", "funding", "group", "element", "Find", "the", "award", "group", "funding", "sources", "one", "for", "each", "item", "found", "in", "the", "get_funding_group", "section" ]
python
train
43.833333
QuantEcon/QuantEcon.py
quantecon/game_theory/lemke_howson.py
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/lemke_howson.py#L566-L603
def _get_mixed_actions(tableaux, bases): """ From `tableaux` and `bases`, extract non-slack basic variables and return a tuple of the corresponding, normalized mixed actions. Parameters ---------- tableaux : tuple(ndarray(float, ndim=2)) Tuple of two arrays containing the tableaux, of s...
[ "def", "_get_mixed_actions", "(", "tableaux", ",", "bases", ")", ":", "nums_actions", "=", "tableaux", "[", "1", "]", ".", "shape", "[", "0", "]", ",", "tableaux", "[", "0", "]", ".", "shape", "[", "0", "]", "num", "=", "nums_actions", "[", "0", "]...
From `tableaux` and `bases`, extract non-slack basic variables and return a tuple of the corresponding, normalized mixed actions. Parameters ---------- tableaux : tuple(ndarray(float, ndim=2)) Tuple of two arrays containing the tableaux, of shape (n, m+n+1) and (m, m+n+1), respectively....
[ "From", "tableaux", "and", "bases", "extract", "non", "-", "slack", "basic", "variables", "and", "return", "a", "tuple", "of", "the", "corresponding", "normalized", "mixed", "actions", "." ]
python
train
32.447368
qubell/contrib-python-qubell-client
qubell/monitor/monitor.py
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/monitor/monitor.py#L168-L173
def clone(self): """ Do not initialize again since everything is ready to launch app. :return: Initialized monitor instance """ return Monitor(org=self.org, app=self.app, env=self.env)
[ "def", "clone", "(", "self", ")", ":", "return", "Monitor", "(", "org", "=", "self", ".", "org", ",", "app", "=", "self", ".", "app", ",", "env", "=", "self", ".", "env", ")" ]
Do not initialize again since everything is ready to launch app. :return: Initialized monitor instance
[ "Do", "not", "initialize", "again", "since", "everything", "is", "ready", "to", "launch", "app", ".", ":", "return", ":", "Initialized", "monitor", "instance" ]
python
train
36.5
inveniosoftware/invenio-webhooks
invenio_webhooks/views.py
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/views.py#L176-L181
def delete(self, receiver_id=None, event_id=None): """Handle DELETE request.""" event = self._get_event(receiver_id, event_id) event.delete() db.session.commit() return make_response(event)
[ "def", "delete", "(", "self", ",", "receiver_id", "=", "None", ",", "event_id", "=", "None", ")", ":", "event", "=", "self", ".", "_get_event", "(", "receiver_id", ",", "event_id", ")", "event", ".", "delete", "(", ")", "db", ".", "session", ".", "co...
Handle DELETE request.
[ "Handle", "DELETE", "request", "." ]
python
train
37.333333
thombashi/SimpleSQLite
simplesqlite/core.py
https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L719-L756
def fetch_attr_names(self, table_name): """ :return: List of attribute names in the table. :rtype: list :raises simplesqlite.NullDatabaseConnectionError: |raises_check_connection| :raises simplesqlite.TableNotFoundError: |raises_verify_table_existence| ...
[ "def", "fetch_attr_names", "(", "self", ",", "table_name", ")", ":", "self", ".", "verify_table_existence", "(", "table_name", ")", "return", "self", ".", "schema_extractor", ".", "fetch_table_schema", "(", "table_name", ")", ".", "get_attr_names", "(", ")" ]
:return: List of attribute names in the table. :rtype: list :raises simplesqlite.NullDatabaseConnectionError: |raises_check_connection| :raises simplesqlite.TableNotFoundError: |raises_verify_table_existence| :raises simplesqlite.OperationalError: |raises_operatio...
[ ":", "return", ":", "List", "of", "attribute", "names", "in", "the", "table", ".", ":", "rtype", ":", "list", ":", "raises", "simplesqlite", ".", "NullDatabaseConnectionError", ":", "|raises_check_connection|", ":", "raises", "simplesqlite", ".", "TableNotFoundErr...
python
train
33.052632
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_image.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_image.py#L145-L148
def set_menu(self, menu): '''set a MPTopMenu on the frame''' self.menu = menu self.in_queue.put(MPImageMenu(menu))
[ "def", "set_menu", "(", "self", ",", "menu", ")", ":", "self", ".", "menu", "=", "menu", "self", ".", "in_queue", ".", "put", "(", "MPImageMenu", "(", "menu", ")", ")" ]
set a MPTopMenu on the frame
[ "set", "a", "MPTopMenu", "on", "the", "frame" ]
python
train
33.75
StackStorm/pybind
pybind/nos/v6_0_2f/rbridge_id/route_map/content/match/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/route_map/content/match/__init__.py#L339-L362
def _set_route_type(self, v, load=False): """ Setter method for route_type, mapped from YANG variable /rbridge_id/route_map/content/match/route_type (container) If this variable is read-only (config: false) in the source YANG file, then _set_route_type is considered as a private method. Backends loo...
[ "def", "_set_route_type", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "bas...
Setter method for route_type, mapped from YANG variable /rbridge_id/route_map/content/match/route_type (container) If this variable is read-only (config: false) in the source YANG file, then _set_route_type is considered as a private method. Backends looking to populate this variable should do so via ca...
[ "Setter", "method", "for", "route_type", "mapped", "from", "YANG", "variable", "/", "rbridge_id", "/", "route_map", "/", "content", "/", "match", "/", "route_type", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ...
python
train
70
jim-easterbrook/pyctools
src/pyctools/components/deinterlace/hhiprefilter.py
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/components/deinterlace/hhiprefilter.py#L27-L51
def HHIPreFilter(config={}): """HHI pre-interlace filter. A widely used prefilter to prevent line twitter when converting sequential images to interlace. Coefficients taken from: 'Specification of a Generic Format Converter', S. Pigeon, L. Vandendorpe, L. Cuvelier and B. Maison, CEC RACE/HAMLE...
[ "def", "HHIPreFilter", "(", "config", "=", "{", "}", ")", ":", "fil", "=", "numpy", ".", "array", "(", "[", "-", "4", ",", "8", ",", "25", ",", "-", "123", ",", "230", ",", "728", ",", "230", ",", "-", "123", ",", "25", ",", "8", ",", "-"...
HHI pre-interlace filter. A widely used prefilter to prevent line twitter when converting sequential images to interlace. Coefficients taken from: 'Specification of a Generic Format Converter', S. Pigeon, L. Vandendorpe, L. Cuvelier and B. Maison, CEC RACE/HAMLET Deliverable no R2110/WP2/DS/S/006/...
[ "HHI", "pre", "-", "interlace", "filter", "." ]
python
train
34.32
saltstack/salt
salt/modules/openvswitch.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/openvswitch.py#L168-L185
def bridge_exists(br): ''' Tests whether bridge exists as a real or fake bridge. Returns: True if Bridge exists, else False. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' openvswitch.bridge_exists br0 ''' cmd = 'ovs-vsctl br-exists {0}'.format...
[ "def", "bridge_exists", "(", "br", ")", ":", "cmd", "=", "'ovs-vsctl br-exists {0}'", ".", "format", "(", "br", ")", "result", "=", "__salt__", "[", "'cmd.run_all'", "]", "(", "cmd", ")", "retcode", "=", "result", "[", "'retcode'", "]", "return", "_retcode...
Tests whether bridge exists as a real or fake bridge. Returns: True if Bridge exists, else False. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' openvswitch.bridge_exists br0
[ "Tests", "whether", "bridge", "exists", "as", "a", "real", "or", "fake", "bridge", "." ]
python
train
23.222222
NoneGG/aredis
aredis/commands/strings.py
https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/commands/strings.py#L45-L51
def incrby(self, type, offset, increment): """ Increments or decrements (if a negative increment is given) the specified bit field and returns the new value. """ self._command_stack.extend(['INCRBY', type, offset, increment]) return self
[ "def", "incrby", "(", "self", ",", "type", ",", "offset", ",", "increment", ")", ":", "self", ".", "_command_stack", ".", "extend", "(", "[", "'INCRBY'", ",", "type", ",", "offset", ",", "increment", "]", ")", "return", "self" ]
Increments or decrements (if a negative increment is given) the specified bit field and returns the new value.
[ "Increments", "or", "decrements", "(", "if", "a", "negative", "increment", "is", "given", ")", "the", "specified", "bit", "field", "and", "returns", "the", "new", "value", "." ]
python
train
39.857143
iotile/coretools
transport_plugins/native_ble/iotile_transport_native_ble/connection_manager.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/native_ble/iotile_transport_native_ble/connection_manager.py#L312-L335
def add_connection(self, connection_id, internal_id, context): """Add an already created connection. Used to register devices connected before starting the device adapter. Args: connection_id (int): The external connection id internal_id (string): An internal identifier ...
[ "def", "add_connection", "(", "self", ",", "connection_id", ",", "internal_id", ",", "context", ")", ":", "# Make sure we are not reusing an id that is currently connected to something", "if", "self", ".", "_get_connection_state", "(", "connection_id", ")", "!=", "self", ...
Add an already created connection. Used to register devices connected before starting the device adapter. Args: connection_id (int): The external connection id internal_id (string): An internal identifier for the connection context (dict): Additional information to a...
[ "Add", "an", "already", "created", "connection", ".", "Used", "to", "register", "devices", "connected", "before", "starting", "the", "device", "adapter", ".", "Args", ":", "connection_id", "(", "int", ")", ":", "The", "external", "connection", "id", "internal_...
python
train
41.75
odlgroup/odl
doc/source/generate_doc.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/doc/source/generate_doc.py#L57-L96
def import_submodules(package, name=None, recursive=True): """Import all submodules of ``package``. Parameters ---------- package : `module` or string Package whose submodules to import. name : string, optional Override the package name with this value in the full submodule ...
[ "def", "import_submodules", "(", "package", ",", "name", "=", "None", ",", "recursive", "=", "True", ")", ":", "if", "isinstance", "(", "package", ",", "str", ")", ":", "package", "=", "importlib", ".", "import_module", "(", "package", ")", "if", "name",...
Import all submodules of ``package``. Parameters ---------- package : `module` or string Package whose submodules to import. name : string, optional Override the package name with this value in the full submodule names. By default, ``package`` is used. recursive : bool, opti...
[ "Import", "all", "submodules", "of", "package", "." ]
python
train
31.75
kubernetes-client/python
kubernetes/client/apis/certificates_v1beta1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/certificates_v1beta1_api.py#L715-L739
def patch_certificate_signing_request_status(self, name, body, **kwargs): """ partially update status of the specified CertificateSigningRequest This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = ...
[ "def", "patch_certificate_signing_request_status", "(", "self", ",", "name", ",", "body", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "sel...
partially update status of the specified CertificateSigningRequest This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.patch_certificate_signing_request_status(name, body, async_req=True) >>> result = ...
[ "partially", "update", "status", "of", "the", "specified", "CertificateSigningRequest", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=...
python
train
80.32
MonashBI/arcana
arcana/pipeline/base.py
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L827-L871
def _gen_prov(self): """ Extracts provenance information from the pipeline into a PipelineProv object Returns ------- prov : dict[str, *] A dictionary containing the provenance information to record for the pipeline """ # Export wo...
[ "def", "_gen_prov", "(", "self", ")", ":", "# Export worfklow graph to node-link data format", "wf_dict", "=", "nx_json", ".", "node_link_data", "(", "self", ".", "workflow", ".", "_graph", ")", "# Replace references to Node objects with the node's provenance", "# information...
Extracts provenance information from the pipeline into a PipelineProv object Returns ------- prov : dict[str, *] A dictionary containing the provenance information to record for the pipeline
[ "Extracts", "provenance", "information", "from", "the", "pipeline", "into", "a", "PipelineProv", "object" ]
python
train
46.355556
gregmuellegger/django-autofixture
autofixture/placeholder.py
https://github.com/gregmuellegger/django-autofixture/blob/0b696fd3a06747459981e4269aff427676f84ae0/autofixture/placeholder.py#L13-L47
def get_placeholder_image(width, height, name=None, fg_color=get_color('black'), bg_color=get_color('grey'), text=None, font=u'Verdana.ttf', fontsize=42, encoding=u'unic', mode='RGBA', fmt=u'PNG'): """Little spin-off from https://github.com/Visgean/python-placeholder that not saves an image and ...
[ "def", "get_placeholder_image", "(", "width", ",", "height", ",", "name", "=", "None", ",", "fg_color", "=", "get_color", "(", "'black'", ")", ",", "bg_color", "=", "get_color", "(", "'grey'", ")", ",", "text", "=", "None", ",", "font", "=", "u'Verdana.t...
Little spin-off from https://github.com/Visgean/python-placeholder that not saves an image and instead returns it.
[ "Little", "spin", "-", "off", "from", "https", ":", "//", "github", ".", "com", "/", "Visgean", "/", "python", "-", "placeholder", "that", "not", "saves", "an", "image", "and", "instead", "returns", "it", "." ]
python
train
32.885714
jaumebonet/libconfig
libconfig/config.py
https://github.com/jaumebonet/libconfig/blob/9b34cefcbaf9a326e3f3cd517896c2933cf61a3b/libconfig/config.py#L123-L144
def get_option_default(self, key, subkey): """Get the default value of the option. :param str key: First identifier of the option. :param str subkey: Second identifier of the option. :return: Default value of the option (type varies). :raise: :NotRegisteredError: I...
[ "def", "get_option_default", "(", "self", ",", "key", ",", "subkey", ")", ":", "key", ",", "subkey", "=", "_lower_keys", "(", "key", ",", "subkey", ")", "_entry_must_exist", "(", "self", ".", "gc", ",", "key", ",", "subkey", ")", "df", "=", "self", "...
Get the default value of the option. :param str key: First identifier of the option. :param str subkey: Second identifier of the option. :return: Default value of the option (type varies). :raise: :NotRegisteredError: If ``key`` or ``subkey`` do not define ...
[ "Get", "the", "default", "value", "of", "the", "option", "." ]
python
train
35.727273
spyder-ide/spyder
spyder/plugins/outlineexplorer/widgets.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/outlineexplorer/widgets.py#L376-L528
def populate_branch(self, editor, root_item, tree_cache=None): """ Generates an outline of the editor's content and stores the result in a cache. """ if tree_cache is None: tree_cache = {} # Removing cached items for which line is > total line...
[ "def", "populate_branch", "(", "self", ",", "editor", ",", "root_item", ",", "tree_cache", "=", "None", ")", ":", "if", "tree_cache", "is", "None", ":", "tree_cache", "=", "{", "}", "# Removing cached items for which line is > total line nb\r", "for", "_l", "in", ...
Generates an outline of the editor's content and stores the result in a cache.
[ "Generates", "an", "outline", "of", "the", "editor", "s", "content", "and", "stores", "the", "result", "in", "a", "cache", "." ]
python
train
45.581699
openvax/varcode
varcode/variant.py
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant.py#L409-L411
def is_transversion(self): """Is this variant a pyrimidine to purine change or vice versa""" return self.is_snv and is_purine(self.ref) != is_purine(self.alt)
[ "def", "is_transversion", "(", "self", ")", ":", "return", "self", ".", "is_snv", "and", "is_purine", "(", "self", ".", "ref", ")", "!=", "is_purine", "(", "self", ".", "alt", ")" ]
Is this variant a pyrimidine to purine change or vice versa
[ "Is", "this", "variant", "a", "pyrimidine", "to", "purine", "change", "or", "vice", "versa" ]
python
train
57.333333
penguinmenac3/starttf
starttf/utils/image_manipulation.py
https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/utils/image_manipulation.py#L48-L71
def resize_image_with_crop_or_pad(img, target_height, target_width): """ Crops and/or pads an image to a target width and height. Resizes an image to a target width and height by either cropping the image or padding it with zeros. NO CENTER CROP. NO CENTER PAD. (Just fill bottom right or crop bottom r...
[ "def", "resize_image_with_crop_or_pad", "(", "img", ",", "target_height", ",", "target_width", ")", ":", "h", ",", "w", "=", "target_height", ",", "target_width", "max_h", ",", "max_w", ",", "c", "=", "img", ".", "shape", "# crop", "img", "=", "crop_center",...
Crops and/or pads an image to a target width and height. Resizes an image to a target width and height by either cropping the image or padding it with zeros. NO CENTER CROP. NO CENTER PAD. (Just fill bottom right or crop bottom right) :param img: Numpy array representing the image. :param target_heig...
[ "Crops", "and", "/", "or", "pads", "an", "image", "to", "a", "target", "width", "and", "height", "." ]
python
train
32.75
keans/lmnotify
lmnotify/lmnotify.py
https://github.com/keans/lmnotify/blob/b0a5282a582e5090852dc20fea8a135ca258d0d3/lmnotify/lmnotify.py#L599-L614
def alarm_set(self, time, wake_with_radio=False): """ set the alarm clock :param str time: time of the alarm (format: %H:%M:%S) :param bool wake_with_radio: if True, radio will be used for the alarm instead of beep sound """ # TODO: c...
[ "def", "alarm_set", "(", "self", ",", "time", ",", "wake_with_radio", "=", "False", ")", ":", "# TODO: check for correct time format", "log", ".", "debug", "(", "\"alarm => set...\"", ")", "params", "=", "{", "\"enabled\"", ":", "True", ",", "\"time\"", ":", "...
set the alarm clock :param str time: time of the alarm (format: %H:%M:%S) :param bool wake_with_radio: if True, radio will be used for the alarm instead of beep sound
[ "set", "the", "alarm", "clock" ]
python
train
36
instaloader/instaloader
instaloader/instaloader.py
https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloader.py#L370-L384
def save_session_to_file(self, filename: Optional[str] = None) -> None: """Saves internally stored :class:`requests.Session` object. :param filename: Filename, or None to use default filename. """ if filename is None: filename = get_default_session_filename(self.context.user...
[ "def", "save_session_to_file", "(", "self", ",", "filename", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "if", "filename", "is", "None", ":", "filename", "=", "get_default_session_filename", "(", "self", ".", "context", ".", "use...
Saves internally stored :class:`requests.Session` object. :param filename: Filename, or None to use default filename.
[ "Saves", "internally", "stored", ":", "class", ":", "requests", ".", "Session", "object", "." ]
python
train
46.266667
WebarchivCZ/WA-KAT
src/wa_kat/templates/static/js/Lib/site-packages/components/conspect_handler.py
https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/templates/static/js/Lib/site-packages/components/conspect_handler.py#L262-L268
def reset(cls): """ Reset the conspect elements to initial state. """ cls.input_el.value = "" cls.subconspect_el.html = "" cls.show_error(False)
[ "def", "reset", "(", "cls", ")", ":", "cls", ".", "input_el", ".", "value", "=", "\"\"", "cls", ".", "subconspect_el", ".", "html", "=", "\"\"", "cls", ".", "show_error", "(", "False", ")" ]
Reset the conspect elements to initial state.
[ "Reset", "the", "conspect", "elements", "to", "initial", "state", "." ]
python
train
26.571429
librosa/librosa
librosa/filters.py
https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L1104-L1175
def window_sumsquare(window, n_frames, hop_length=512, win_length=None, n_fft=2048, dtype=np.float32, norm=None): ''' Compute the sum-square envelope of a window function at a given hop length. This is used to estimate modulation effects induced by windowing observations in short-t...
[ "def", "window_sumsquare", "(", "window", ",", "n_frames", ",", "hop_length", "=", "512", ",", "win_length", "=", "None", ",", "n_fft", "=", "2048", ",", "dtype", "=", "np", ".", "float32", ",", "norm", "=", "None", ")", ":", "if", "win_length", "is", ...
Compute the sum-square envelope of a window function at a given hop length. This is used to estimate modulation effects induced by windowing observations in short-time fourier transforms. Parameters ---------- window : string, tuple, number, callable, or list-like Window specification, as ...
[ "Compute", "the", "sum", "-", "square", "envelope", "of", "a", "window", "function", "at", "a", "given", "hop", "length", "." ]
python
test
29.694444
tcalmant/ipopo
pelix/rsa/__init__.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/rsa/__init__.py#L910-L926
def fromexportunreg( cls, bundle, exporterid, rsid, export_ref, exception, endpoint ): # type: (Bundle, Tuple[str, str], Tuple[Tuple[str, str], int], ExportReference, Optional[Tuple[Any, Any, Any]], EndpointDescription) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent...
[ "def", "fromexportunreg", "(", "cls", ",", "bundle", ",", "exporterid", ",", "rsid", ",", "export_ref", ",", "exception", ",", "endpoint", ")", ":", "# type: (Bundle, Tuple[str, str], Tuple[Tuple[str, str], int], ExportReference, Optional[Tuple[Any, Any, Any]], EndpointDescriptio...
Creates a RemoteServiceAdminEvent object from the departure of an ExportRegistration
[ "Creates", "a", "RemoteServiceAdminEvent", "object", "from", "the", "departure", "of", "an", "ExportRegistration" ]
python
train
39.117647
cenima-ibama/lc8_download
lc8_download/lc8.py
https://github.com/cenima-ibama/lc8_download/blob/d366e8b42b143597c71663ccb838bf8375c8d817/lc8_download/lc8.py#L44-L65
def fetch(self, url, path, filename): """Verify if the file is already downloaded and complete. If they don't exists or if are not complete, use homura download function to fetch files. Return a list with the path of the downloaded file and the size of the remote file. """ ...
[ "def", "fetch", "(", "self", ",", "url", ",", "path", ",", "filename", ")", ":", "logger", ".", "debug", "(", "'initializing download in '", ",", "url", ")", "remote_file_size", "=", "self", ".", "get_remote_file_size", "(", "url", ")", "if", "exists", "("...
Verify if the file is already downloaded and complete. If they don't exists or if are not complete, use homura download function to fetch files. Return a list with the path of the downloaded file and the size of the remote file.
[ "Verify", "if", "the", "file", "is", "already", "downloaded", "and", "complete", ".", "If", "they", "don", "t", "exists", "or", "if", "are", "not", "complete", "use", "homura", "download", "function", "to", "fetch", "files", ".", "Return", "a", "list", "...
python
valid
45.090909
ajk8/microcache
microcache/__init__.py
https://github.com/ajk8/microcache/blob/24876c2c5f8959a806e2701adb7efbf70a87a1ae/microcache/__init__.py#L158-L173
def get(self, key, default=CACHE_MISS): """ Get a value out of the cache Returns CACHE_DISABLED if the cache is disabled :param key: key to search for :param default: value to return if the key is not found (defaults to CACHE_MISS) """ if not self.options.enable...
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "CACHE_MISS", ")", ":", "if", "not", "self", ".", "options", ".", "enabled", ":", "return", "CACHE_DISABLED", "ret", "=", "default", "if", "self", ".", "has", "(", "key", ")", ":", "ret", ...
Get a value out of the cache Returns CACHE_DISABLED if the cache is disabled :param key: key to search for :param default: value to return if the key is not found (defaults to CACHE_MISS)
[ "Get", "a", "value", "out", "of", "the", "cache" ]
python
train
33.875
archman/beamline
beamline/lattice.py
https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/lattice.py#L359-L365
def getKwConfig(self, kw): """ return the configuration of kw, dict USAGE: rdict = getKwConfig(kw) """ confd = self.getKwAsDict(kw).values()[0].values()[0] return {k.lower(): v for k, v in confd.items()}
[ "def", "getKwConfig", "(", "self", ",", "kw", ")", ":", "confd", "=", "self", ".", "getKwAsDict", "(", "kw", ")", ".", "values", "(", ")", "[", "0", "]", ".", "values", "(", ")", "[", "0", "]", "return", "{", "k", ".", "lower", "(", ")", ":",...
return the configuration of kw, dict USAGE: rdict = getKwConfig(kw)
[ "return", "the", "configuration", "of", "kw", "dict" ]
python
train
34
senaite/senaite.core
bika/lims/content/arimport.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/arimport.py#L778-L828
def validate_samples(self): """Scan through the SampleData values and make sure that each one is correct """ bsc = getToolByName(self, 'bika_setup_catalog') keywords = bsc.uniqueValuesFor('getKeyword') profiles = [] for p in bsc(portal_type='AnalysisProfile'): ...
[ "def", "validate_samples", "(", "self", ")", ":", "bsc", "=", "getToolByName", "(", "self", ",", "'bika_setup_catalog'", ")", "keywords", "=", "bsc", ".", "uniqueValuesFor", "(", "'getKeyword'", ")", "profiles", "=", "[", "]", "for", "p", "in", "bsc", "(",...
Scan through the SampleData values and make sure that each one is correct
[ "Scan", "through", "the", "SampleData", "values", "and", "make", "sure", "that", "each", "one", "is", "correct" ]
python
train
37.196078
AmesCornish/buttersink
buttersink/Store.py
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/Store.py#L443-L450
def hasInfo(self): """ Will have information to write. """ count = len([None for (fromUUID, size) in Diff.theKnownSizes[self.uuid].iteritems() if size is not None and fromUUID is not None ]) return count > 0
[ "def", "hasInfo", "(", "self", ")", ":", "count", "=", "len", "(", "[", "None", "for", "(", "fromUUID", ",", "size", ")", "in", "Diff", ".", "theKnownSizes", "[", "self", ".", "uuid", "]", ".", "iteritems", "(", ")", "if", "size", "is", "not", "N...
Will have information to write.
[ "Will", "have", "information", "to", "write", "." ]
python
train
38.5
crackinglandia/pype32
pype32/directories.py
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/directories.py#L1148-L1173
def parse(readDataInstance, nStreams): """ Returns a new L{NetMetaDataStreams} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataStreams} object. @type nStreams: int @param...
[ "def", "parse", "(", "readDataInstance", ",", "nStreams", ")", ":", "streams", "=", "NetMetaDataStreams", "(", ")", "for", "i", "in", "range", "(", "nStreams", ")", ":", "streamEntry", "=", "NetMetaDataStreamEntry", "(", ")", "streamEntry", ".", "offset", "....
Returns a new L{NetMetaDataStreams} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataStreams} object. @type nStreams: int @param nStreams: The number of L{NetMetaDataStreamEntry} objects i...
[ "Returns", "a", "new", "L", "{", "NetMetaDataStreams", "}", "object", "." ]
python
train
39.076923
mattupstate/flask-security
flask_security/views.py
https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L307-L334
def change_password(): """View function which handles a change password request.""" form_class = _security.change_password_form if request.is_json: form = form_class(MultiDict(request.get_json())) else: form = form_class() if form.validate_on_submit(): after_this_request(_...
[ "def", "change_password", "(", ")", ":", "form_class", "=", "_security", ".", "change_password_form", "if", "request", ".", "is_json", ":", "form", "=", "form_class", "(", "MultiDict", "(", "request", ".", "get_json", "(", ")", ")", ")", "else", ":", "form...
View function which handles a change password request.
[ "View", "function", "which", "handles", "a", "change", "password", "request", "." ]
python
train
31.821429
GetmeUK/MongoFrames
mongoframes/frames.py
https://github.com/GetmeUK/MongoFrames/blob/7d2bd792235dfa77a9deecab5366f5f73480823d/mongoframes/frames.py#L106-L117
def _path_to_value(cls, path, parent_dict): """Return a value from a dictionary at the given path""" keys = cls._path_to_keys(path) # Traverse to the tip of the path child_dict = parent_dict for key in keys[:-1]: child_dict = child_dict.get(key) if child_...
[ "def", "_path_to_value", "(", "cls", ",", "path", ",", "parent_dict", ")", ":", "keys", "=", "cls", ".", "_path_to_keys", "(", "path", ")", "# Traverse to the tip of the path", "child_dict", "=", "parent_dict", "for", "key", "in", "keys", "[", ":", "-", "1",...
Return a value from a dictionary at the given path
[ "Return", "a", "value", "from", "a", "dictionary", "at", "the", "given", "path" ]
python
train
32.166667
PmagPy/PmagPy
programs/di_vgp.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/di_vgp.py#L9-L91
def main(): """ NAME di_vgp.py DESCRIPTION converts declination/inclination to virtual geomagnetic pole SYNTAX di_vgp.py [-h] [options] OPTIONS -h prints help message and quits -i interactive data entry -f FILE to specify intput file -...
[ "def", "main", "(", ")", ":", "if", "'-h'", "in", "sys", ".", "argv", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "if", "'-F'", "in", "sys", ".", "argv", ":", "ind", "=", "sys", ".", "argv", ".", "index", "("...
NAME di_vgp.py DESCRIPTION converts declination/inclination to virtual geomagnetic pole SYNTAX di_vgp.py [-h] [options] OPTIONS -h prints help message and quits -i interactive data entry -f FILE to specify intput file -F FILE to specify output...
[ "NAME", "di_vgp", ".", "py", "DESCRIPTION", "converts", "declination", "/", "inclination", "to", "virtual", "geomagnetic", "pole", "SYNTAX", "di_vgp", ".", "py", "[", "-", "h", "]", "[", "options", "]", "OPTIONS", "-", "h", "prints", "help", "message", "an...
python
train
33.361446
StanfordBioinformatics/loom
utils/loomengine_utils/file_utils.py
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/file_utils.py#L119-L127
def FilePattern(pattern, settings, **kwargs): """Factory method returns LocalFilePattern or GoogleStorageFilePattern """ url = _urlparse(pattern) if url.scheme == 'gs': return GoogleStorageFilePattern(pattern, settings, **kwargs) else: assert url.scheme == 'file' return Local...
[ "def", "FilePattern", "(", "pattern", ",", "settings", ",", "*", "*", "kwargs", ")", ":", "url", "=", "_urlparse", "(", "pattern", ")", "if", "url", ".", "scheme", "==", "'gs'", ":", "return", "GoogleStorageFilePattern", "(", "pattern", ",", "settings", ...
Factory method returns LocalFilePattern or GoogleStorageFilePattern
[ "Factory", "method", "returns", "LocalFilePattern", "or", "GoogleStorageFilePattern" ]
python
train
39.111111
product-definition-center/pdc-client
pdc_client/plugin_helpers.py
https://github.com/product-definition-center/pdc-client/blob/7236fd8b72e675ebb321bbe337289d9fbeb6119f/pdc_client/plugin_helpers.py#L150-L169
def add_create_update_args(parser, required_args, optional_args, create=False): """Wrapper around ``add_parser_arguments``. If ``create`` is True, one argument group will be created for each of ``required_args`` and ``optional_args``. Each required argument will have the ``required`` parameter set to T...
[ "def", "add_create_update_args", "(", "parser", ",", "required_args", ",", "optional_args", ",", "create", "=", "False", ")", ":", "if", "create", ":", "for", "key", "in", "required_args", ":", "required_args", "[", "key", "]", "[", "'required'", "]", "=", ...
Wrapper around ``add_parser_arguments``. If ``create`` is True, one argument group will be created for each of ``required_args`` and ``optional_args``. Each required argument will have the ``required`` parameter set to True automatically. If ``create`` is False, only one group of optional arguments wi...
[ "Wrapper", "around", "add_parser_arguments", "." ]
python
train
40.65
sorgerlab/indra
indra/databases/chebi_client.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/chebi_client.py#L86-L106
def get_chebi_name_from_id(chebi_id, offline=False): """Return a ChEBI name corresponding to the given ChEBI ID. Parameters ---------- chebi_id : str The ChEBI ID whose name is to be returned. offline : Optional[bool] Choose whether to allow an online lookup if the local lookup fail...
[ "def", "get_chebi_name_from_id", "(", "chebi_id", ",", "offline", "=", "False", ")", ":", "chebi_name", "=", "chebi_id_to_name", ".", "get", "(", "chebi_id", ")", "if", "chebi_name", "is", "None", "and", "not", "offline", ":", "chebi_name", "=", "get_chebi_nam...
Return a ChEBI name corresponding to the given ChEBI ID. Parameters ---------- chebi_id : str The ChEBI ID whose name is to be returned. offline : Optional[bool] Choose whether to allow an online lookup if the local lookup fails. If True, the online lookup is not attempted. Defa...
[ "Return", "a", "ChEBI", "name", "corresponding", "to", "the", "given", "ChEBI", "ID", "." ]
python
train
33.190476
Hackerfleet/hfos
modules/robot/hfos/robot/rcmanager.py
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/rcmanager.py#L75-L86
def clientdisconnect(self, event): """Handler to deal with a possibly disconnected remote controlling client :param event: ClientDisconnect Event """ try: if event.clientuuid == self.remote_controller: self.log("Remote controller disconnected!", lvl=c...
[ "def", "clientdisconnect", "(", "self", ",", "event", ")", ":", "try", ":", "if", "event", ".", "clientuuid", "==", "self", ".", "remote_controller", ":", "self", ".", "log", "(", "\"Remote controller disconnected!\"", ",", "lvl", "=", "critical", ")", "self...
Handler to deal with a possibly disconnected remote controlling client :param event: ClientDisconnect Event
[ "Handler", "to", "deal", "with", "a", "possibly", "disconnected", "remote", "controlling", "client", ":", "param", "event", ":", "ClientDisconnect", "Event" ]
python
train
39.166667
pyQode/pyqode.core
pyqode/core/modes/caret_line_highlight.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/caret_line_highlight.py#L14-L23
def background(self): """ Background color of the caret line. Default is to use a color slightly darker/lighter than the background color. You can override the automatic color by setting up this property """ if self._color or not self.editor: return self._colo...
[ "def", "background", "(", "self", ")", ":", "if", "self", ".", "_color", "or", "not", "self", ".", "editor", ":", "return", "self", ".", "_color", "else", ":", "return", "drift_color", "(", "self", ".", "editor", ".", "background", ",", "110", ")" ]
Background color of the caret line. Default is to use a color slightly darker/lighter than the background color. You can override the automatic color by setting up this property
[ "Background", "color", "of", "the", "caret", "line", ".", "Default", "is", "to", "use", "a", "color", "slightly", "darker", "/", "lighter", "than", "the", "background", "color", ".", "You", "can", "override", "the", "automatic", "color", "by", "setting", "...
python
train
38.6
projectshift/shift-boiler
boiler/user/models.py
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/models.py#L282-L287
def require_email_confirmation(self): """ Mark email as unconfirmed""" self.email_confirmed = False self.email_link = self.generate_hash(50) now = datetime.datetime.utcnow() self.email_link_expires = now + datetime.timedelta(hours=24)
[ "def", "require_email_confirmation", "(", "self", ")", ":", "self", ".", "email_confirmed", "=", "False", "self", ".", "email_link", "=", "self", ".", "generate_hash", "(", "50", ")", "now", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "self"...
Mark email as unconfirmed
[ "Mark", "email", "as", "unconfirmed" ]
python
train
45
jobovy/galpy
galpy/util/__init__.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/util/__init__.py#L89-L103
def stable_cho_factor(x,tiny=_TINY): """ NAME: stable_cho_factor PURPOSE: Stable version of the cholesky decomposition INPUT: x - (sc.array) positive definite matrix tiny - (double) tiny number to add to the covariance matrix to make the decomposition stable (has a default) ...
[ "def", "stable_cho_factor", "(", "x", ",", "tiny", "=", "_TINY", ")", ":", "return", "linalg", ".", "cho_factor", "(", "x", "+", "numpy", ".", "sum", "(", "numpy", ".", "diag", "(", "x", ")", ")", "*", "tiny", "*", "numpy", ".", "eye", "(", "x", ...
NAME: stable_cho_factor PURPOSE: Stable version of the cholesky decomposition INPUT: x - (sc.array) positive definite matrix tiny - (double) tiny number to add to the covariance matrix to make the decomposition stable (has a default) OUTPUT: (L,lowerFlag) - output from sci...
[ "NAME", ":", "stable_cho_factor", "PURPOSE", ":", "Stable", "version", "of", "the", "cholesky", "decomposition", "INPUT", ":", "x", "-", "(", "sc", ".", "array", ")", "positive", "definite", "matrix", "tiny", "-", "(", "double", ")", "tiny", "number", "to"...
python
train
37.066667
GeoPyTool/GeoPyTool
geopytool/GLMultiDimension.py
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/GLMultiDimension.py#L125-L291
def create_main_frame(self): self.main_frame = QWidget() #self.main_frame.setFixedSize(self.width(), self.width()) self.dpi = 128 self.ShapeGroups =200 self.view = gl.GLViewWidget() #self.view = pg.PlotWidget() #self.view.setFixedSize(self.width(),self.height(...
[ "def", "create_main_frame", "(", "self", ")", ":", "self", ".", "main_frame", "=", "QWidget", "(", ")", "#self.main_frame.setFixedSize(self.width(), self.width())", "self", ".", "dpi", "=", "128", "self", ".", "ShapeGroups", "=", "200", "self", ".", "view", "=",...
for w in [self.fit_cb,self.fit_label, self.fit_seter,self.xlim_seter_left_label,self.xlim_seter_left,self.xlim_seter_right_label,self.xlim_seter_right,self.ylim_seter_down_label,self.ylim_seter_down,self.ylim_seter_up_label,self.ylim_seter_up,self.shape_cb]: self.hbox0.addWidget(w) self.hbox0.se...
[ "for", "w", "in", "[", "self", ".", "fit_cb", "self", ".", "fit_label", "self", ".", "fit_seter", "self", ".", "xlim_seter_left_label", "self", ".", "xlim_seter_left", "self", ".", "xlim_seter_right_label", "self", ".", "xlim_seter_right", "self", ".", "ylim_set...
python
train
33.413174
h2oai/h2o-3
h2o-py/h2o/utils/typechecks.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/utils/typechecks.py#L283-L286
def name(self, src=None): """Return string representing the name of this type.""" return "{%s}" % ", ".join("%s: %s" % (key, _get_type_name(ktype, src)) for key, ktype in viewitems(self._types))
[ "def", "name", "(", "self", ",", "src", "=", "None", ")", ":", "return", "\"{%s}\"", "%", "\", \"", ".", "join", "(", "\"%s: %s\"", "%", "(", "key", ",", "_get_type_name", "(", "ktype", ",", "src", ")", ")", "for", "key", ",", "ktype", "in", "viewi...
Return string representing the name of this type.
[ "Return", "string", "representing", "the", "name", "of", "this", "type", "." ]
python
test
60.25
RLBot/RLBot
src/main/python/rlbot/training/training.py
https://github.com/RLBot/RLBot/blob/3f9b6bec8b9baf4dcfff0f6cf3103c8744ac6234/src/main/python/rlbot/training/training.py#L114-L162
def run_exercises(setup_manager: SetupManager, exercises: Iterable[Exercise], seed: int) -> Iterator[Result]: """ It is recommended to use setup_manager_context() to generate your setup_manager. """ game_interface = setup_manager.game_interface names = [exercise.get_name() for exercise in exercises]...
[ "def", "run_exercises", "(", "setup_manager", ":", "SetupManager", ",", "exercises", ":", "Iterable", "[", "Exercise", "]", ",", "seed", ":", "int", ")", "->", "Iterator", "[", "Result", "]", ":", "game_interface", "=", "setup_manager", ".", "game_interface", ...
It is recommended to use setup_manager_context() to generate your setup_manager.
[ "It", "is", "recommended", "to", "use", "setup_manager_context", "()", "to", "generate", "your", "setup_manager", "." ]
python
train
43.877551
dbcli/athenacli
athenacli/completer.py
https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/completer.py#L83-L107
def extend_relations(self, data, kind): """Extend metadata for tables or views :param data: list of (rel_name, ) tuples :param kind: either 'tables' or 'views' :return: """ # 'data' is a generator object. It can throw an exception while being # consumed. This coul...
[ "def", "extend_relations", "(", "self", ",", "data", ",", "kind", ")", ":", "# 'data' is a generator object. It can throw an exception while being", "# consumed. This could happen if the user has launched the app without", "# specifying a database name. This exception must be handled to prev...
Extend metadata for tables or views :param data: list of (rel_name, ) tuples :param kind: either 'tables' or 'views' :return:
[ "Extend", "metadata", "for", "tables", "or", "views", ":", "param", "data", ":", "list", "of", "(", "rel_name", ")", "tuples", ":", "param", "kind", ":", "either", "tables", "or", "views", ":", "return", ":" ]
python
train
41.8
SHDShim/pytheos
pytheos/plot/thermal_fit.py
https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/plot/thermal_fit.py#L74-L151
def thermal_fit_result(fit_result, v_residual=None, v_label='Unit-cell volume $(\mathrm{\AA}^3)$', temp_fitline=np.asarray( [300., 1000., 1500., 2000., 2500., 3000.]), figsize=(5, 5), height_ratios=(3, 1), ms_data=50, ...
[ "def", "thermal_fit_result", "(", "fit_result", ",", "v_residual", "=", "None", ",", "v_label", "=", "'Unit-cell volume $(\\mathrm{\\AA}^3)$'", ",", "temp_fitline", "=", "np", ".", "asarray", "(", "[", "300.", ",", "1000.", ",", "1500.", ",", "2000.", ",", "25...
plot P-V-T EOS curve fitting result :param fit_result: lmfit result object, see example jnb file for detail :param v_label: label for volume axis :param temp_fitline: temperatures to calculate isothermal compression curves, default = [300., 1000., 1500., 2000., 2500., 3000.] :param figsize: fig...
[ "plot", "P", "-", "V", "-", "T", "EOS", "curve", "fitting", "result" ]
python
train
47.602564
wonambi-python/wonambi
wonambi/widgets/analysis.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/analysis.py#L1123-L1138
def update_nseg(self): """Update the number of segments, displayed in the dialog.""" self.nseg = 0 if self.one_grp: segments = self.get_segments() if segments is not None: self.nseg = len(segments) self.show_nseg.setText('Number of segment...
[ "def", "update_nseg", "(", "self", ")", ":", "self", ".", "nseg", "=", "0", "if", "self", ".", "one_grp", ":", "segments", "=", "self", ".", "get_segments", "(", ")", "if", "segments", "is", "not", "None", ":", "self", ".", "nseg", "=", "len", "(",...
Update the number of segments, displayed in the dialog.
[ "Update", "the", "number", "of", "segments", "displayed", "in", "the", "dialog", "." ]
python
train
34.8125
saltstack/salt
salt/modules/mac_group.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_group.py#L91-L110
def delete(name): ''' Remove the named group CLI Example: .. code-block:: bash salt '*' group.delete foo ''' if salt.utils.stringutils.contains_whitespace(name): raise SaltInvocationError('Group name cannot contain whitespace') if name.startswith('_'): raise SaltIn...
[ "def", "delete", "(", "name", ")", ":", "if", "salt", ".", "utils", ".", "stringutils", ".", "contains_whitespace", "(", "name", ")", ":", "raise", "SaltInvocationError", "(", "'Group name cannot contain whitespace'", ")", "if", "name", ".", "startswith", "(", ...
Remove the named group CLI Example: .. code-block:: bash salt '*' group.delete foo
[ "Remove", "the", "named", "group" ]
python
train
27.5
Aluriak/tergraw
tergraw/view.py
https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/view.py#L65-L73
def previous_unwrittable_on_col(view, coords): """Return position of the previous (in column) letter that is unwrittable""" x, y = coords miny = -1 for offset in range(y - 1, miny, -1): letter = view[x, offset] if letter not in REWRITABLE_LETTERS: return offset return Non...
[ "def", "previous_unwrittable_on_col", "(", "view", ",", "coords", ")", ":", "x", ",", "y", "=", "coords", "miny", "=", "-", "1", "for", "offset", "in", "range", "(", "y", "-", "1", ",", "miny", ",", "-", "1", ")", ":", "letter", "=", "view", "[",...
Return position of the previous (in column) letter that is unwrittable
[ "Return", "position", "of", "the", "previous", "(", "in", "column", ")", "letter", "that", "is", "unwrittable" ]
python
train
34.777778
CxAalto/gtfspy
gtfspy/shapes.py
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L242-L262
def get_shape_points(cur, shape_id): """ Given a shape_id, return its shape-sequence. Parameters ---------- cur: sqlite3.Cursor cursor to a GTFS database shape_id: str id of the route Returns ------- shape_points: list elements are dictionaries containing th...
[ "def", "get_shape_points", "(", "cur", ",", "shape_id", ")", ":", "cur", ".", "execute", "(", "'''SELECT seq, lat, lon, d FROM shapes where shape_id=?\n ORDER BY seq'''", ",", "(", "shape_id", ",", ")", ")", "shape_points", "=", "[", "dict", "(", "s...
Given a shape_id, return its shape-sequence. Parameters ---------- cur: sqlite3.Cursor cursor to a GTFS database shape_id: str id of the route Returns ------- shape_points: list elements are dictionaries containing the 'seq', 'lat', and 'lon' of the shape
[ "Given", "a", "shape_id", "return", "its", "shape", "-", "sequence", "." ]
python
valid
28.52381
bukun/TorCMS
torcms/core/base_handler.py
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/core/base_handler.py#L36-L43
def get_post_data(self): ''' Get all the arguments from post request. Only get the first argument by default. ''' post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key)[0] return post_data
[ "def", "get_post_data", "(", "self", ")", ":", "post_data", "=", "{", "}", "for", "key", "in", "self", ".", "request", ".", "arguments", ":", "post_data", "[", "key", "]", "=", "self", ".", "get_arguments", "(", "key", ")", "[", "0", "]", "return", ...
Get all the arguments from post request. Only get the first argument by default.
[ "Get", "all", "the", "arguments", "from", "post", "request", ".", "Only", "get", "the", "first", "argument", "by", "default", "." ]
python
train
34.625
edx/XBlock
xblock/mixins.py
https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/mixins.py#L572-L592
def supports(cls, *functionalities): """ A view decorator to indicate that an xBlock view has support for the given functionalities. Arguments: functionalities: String identifiers for the functionalities of the view. For example: "multi_device". """ ...
[ "def", "supports", "(", "cls", ",", "*", "functionalities", ")", ":", "def", "_decorator", "(", "view", ")", ":", "\"\"\"\n Internal decorator that updates the given view's list of supported\n functionalities.\n \"\"\"", "# pylint: disable=protected-a...
A view decorator to indicate that an xBlock view has support for the given functionalities. Arguments: functionalities: String identifiers for the functionalities of the view. For example: "multi_device".
[ "A", "view", "decorator", "to", "indicate", "that", "an", "xBlock", "view", "has", "support", "for", "the", "given", "functionalities", "." ]
python
train
35.761905
drastus/unicover
unicover/unicover.py
https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L147-L151
def _charInfo(self, point, padding): """ Displays character info. """ print('{0:0>4X} '.format(point).rjust(padding), ud.name(chr(point), '<code point {0:0>4X}>'.format(point)))
[ "def", "_charInfo", "(", "self", ",", "point", ",", "padding", ")", ":", "print", "(", "'{0:0>4X} '", ".", "format", "(", "point", ")", ".", "rjust", "(", "padding", ")", ",", "ud", ".", "name", "(", "chr", "(", "point", ")", ",", "'<code point {0:0>...
Displays character info.
[ "Displays", "character", "info", "." ]
python
train
41
wandb/client
wandb/history.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/history.py#L103-L140
def add(self, row={}, step=None): """Adds or updates a history step. If row isn't specified, will write the current state of row. If step is specified, the row will be written only when add() is called with a different step value. run.history.row["duration"] = 1.0 run....
[ "def", "add", "(", "self", ",", "row", "=", "{", "}", ",", "step", "=", "None", ")", ":", "if", "not", "isinstance", "(", "row", ",", "collections", ".", "Mapping", ")", ":", "raise", "wandb", ".", "Error", "(", "'history.add expects dict-like object'", ...
Adds or updates a history step. If row isn't specified, will write the current state of row. If step is specified, the row will be written only when add() is called with a different step value. run.history.row["duration"] = 1.0 run.history.add({"loss": 1}) => {"duratio...
[ "Adds", "or", "updates", "a", "history", "step", "." ]
python
train
35.105263
openego/ding0
ding0/tools/results.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/tools/results.py#L1385-L1575
def parallel_running_stats(districts_list, n_of_processes, n_of_districts=1, source='pkl', mode='', critical=False, save_csv=False, ...
[ "def", "parallel_running_stats", "(", "districts_list", ",", "n_of_processes", ",", "n_of_districts", "=", "1", ",", "source", "=", "'pkl'", ",", "mode", "=", "''", ",", "critical", "=", "False", ",", "save_csv", "=", "False", ",", "save_path", "=", "''", ...
Organize parallel runs of ding0 to calculate stats The function take all districts in a list and divide them into n_of_processes parallel processes. For each process, the assigned districts are given to the function process_runs() with arguments n_of_districts, source, mode, and critical Parameter...
[ "Organize", "parallel", "runs", "of", "ding0", "to", "calculate", "stats" ]
python
train
36.759162
exa-analytics/exa
exa/core/numerical.py
https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L261-L270
def memory_usage(self): """ Get the combined memory usage of the field data and field values. """ data = super(Field, self).memory_usage() values = 0 for value in self.field_values: values += value.memory_usage() data['field_values'] = values r...
[ "def", "memory_usage", "(", "self", ")", ":", "data", "=", "super", "(", "Field", ",", "self", ")", ".", "memory_usage", "(", ")", "values", "=", "0", "for", "value", "in", "self", ".", "field_values", ":", "values", "+=", "value", ".", "memory_usage",...
Get the combined memory usage of the field data and field values.
[ "Get", "the", "combined", "memory", "usage", "of", "the", "field", "data", "and", "field", "values", "." ]
python
train
32.1
websauna/pyramid_notebook
pyramid_notebook/uwsgi.py
https://github.com/websauna/pyramid_notebook/blob/8a7ecfa0259810de1a818e4b415a62811a7b077a/pyramid_notebook/uwsgi.py#L112-L133
def serve_websocket(request, port): """Start UWSGI websocket loop and proxy.""" env = request.environ # Send HTTP response 101 Switch Protocol downstream uwsgi.websocket_handshake(env['HTTP_SEC_WEBSOCKET_KEY'], env.get('HTTP_ORIGIN', '')) # Map the websocket URL to the upstream localhost:4000x Not...
[ "def", "serve_websocket", "(", "request", ",", "port", ")", ":", "env", "=", "request", ".", "environ", "# Send HTTP response 101 Switch Protocol downstream", "uwsgi", ".", "websocket_handshake", "(", "env", "[", "'HTTP_SEC_WEBSOCKET_KEY'", "]", ",", "env", ".", "ge...
Start UWSGI websocket loop and proxy.
[ "Start", "UWSGI", "websocket", "loop", "and", "proxy", "." ]
python
train
39.590909
relekang/python-semantic-release
semantic_release/history/parser_tag.py
https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/parser_tag.py#L17-L60
def parse_commit_message(message: str) -> Tuple[int, str, Optional[str], Tuple[str, str, str]]: """ Parses a commit message according to the 1.0 version of python-semantic-release. It expects a tag of some sort in the commit message and will use the rest of the first line as changelog content. :par...
[ "def", "parse_commit_message", "(", "message", ":", "str", ")", "->", "Tuple", "[", "int", ",", "str", ",", "Optional", "[", "str", "]", ",", "Tuple", "[", "str", ",", "str", ",", "str", "]", "]", ":", "parsed", "=", "re_parser", ".", "match", "(",...
Parses a commit message according to the 1.0 version of python-semantic-release. It expects a tag of some sort in the commit message and will use the rest of the first line as changelog content. :param message: A string of a commit message. :raises UnknownCommitMessageStyleError: If it does not recogni...
[ "Parses", "a", "commit", "message", "according", "to", "the", "1", ".", "0", "version", "of", "python", "-", "semantic", "-", "release", ".", "It", "expects", "a", "tag", "of", "some", "sort", "in", "the", "commit", "message", "and", "will", "use", "th...
python
train
36.75
git-afsantos/bonsai
bonsai/model.py
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L525-L534
def pretty_str(self, indent=0): """Return a human-readable string representation of this object. Kwargs: indent (int): The amount of spaces to use as indentation. """ return '\n\n'.join( codeobj.pretty_str(indent=indent) for codeobj in self.ch...
[ "def", "pretty_str", "(", "self", ",", "indent", "=", "0", ")", ":", "return", "'\\n\\n'", ".", "join", "(", "codeobj", ".", "pretty_str", "(", "indent", "=", "indent", ")", "for", "codeobj", "in", "self", ".", "children", ")" ]
Return a human-readable string representation of this object. Kwargs: indent (int): The amount of spaces to use as indentation.
[ "Return", "a", "human", "-", "readable", "string", "representation", "of", "this", "object", "." ]
python
train
32.7
collectiveacuity/labPack
labpack/platforms/apscheduler.py
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/apscheduler.py#L329-L446
def list_jobs(self, argument_filters=None): ''' a method to list jobs in the scheduler :param argument_filters: list of query criteria dictionaries for class argument keys :return: list of jobs (which satisfy the filters) NOTE: query criteria architecture ...
[ "def", "list_jobs", "(", "self", ",", "argument_filters", "=", "None", ")", ":", "title", "=", "'%s.list_jobs'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs\r", "if", "argument_filters", ":", "self", ".", "fields", ".", "validate", "(", ...
a method to list jobs in the scheduler :param argument_filters: list of query criteria dictionaries for class argument keys :return: list of jobs (which satisfy the filters) NOTE: query criteria architecture each item in the argument filters list must be a dictionary ...
[ "a", "method", "to", "list", "jobs", "in", "the", "scheduler", ":", "param", "argument_filters", ":", "list", "of", "query", "criteria", "dictionaries", "for", "class", "argument", "keys", ":", "return", ":", "list", "of", "jobs", "(", "which", "satisfy", ...
python
train
36.940678
JukeboxPipeline/jukebox-core
src/jukeboxcore/release.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/release.py#L54-L73
def release(self): """Create a release 1. Perform Sanity checks on work file. 2. Copy work file to releasefile location. 3. Perform cleanup actions on releasefile. :returns: True if successfull, False if not. :rtype: bool :raises: None """ log.in...
[ "def", "release", "(", "self", ")", ":", "log", ".", "info", "(", "\"Releasing: %s\"", ",", "self", ".", "_workfile", ".", "get_fullpath", "(", ")", ")", "ac", "=", "self", ".", "build_actions", "(", ")", "ac", ".", "execute", "(", "self", ")", "s", ...
Create a release 1. Perform Sanity checks on work file. 2. Copy work file to releasefile location. 3. Perform cleanup actions on releasefile. :returns: True if successfull, False if not. :rtype: bool :raises: None
[ "Create", "a", "release" ]
python
train
30.25
django-dbbackup/django-dbbackup
dbbackup/db/base.py
https://github.com/django-dbbackup/django-dbbackup/blob/77de209e2d5317e51510d0f888e085ee0c400d66/dbbackup/db/base.py#L31-L46
def get_connector(database_name=None): """ Get a connector from its database key in setttings. """ from django.db import connections, DEFAULT_DB_ALIAS # Get DB database_name = database_name or DEFAULT_DB_ALIAS connection = connections[database_name] engine = connection.settings_dict['ENG...
[ "def", "get_connector", "(", "database_name", "=", "None", ")", ":", "from", "django", ".", "db", "import", "connections", ",", "DEFAULT_DB_ALIAS", "# Get DB", "database_name", "=", "database_name", "or", "DEFAULT_DB_ALIAS", "connection", "=", "connections", "[", ...
Get a connector from its database key in setttings.
[ "Get", "a", "connector", "from", "its", "database", "key", "in", "setttings", "." ]
python
train
46.125
mandiant/ioc_writer
ioc_writer/ioc_common.py
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_common.py#L807-L819
def make_registryitem_valuename(valuename, condition='is', negate=False, preserve_case=False): """ Create a node for RegistryItem/ValueName :return: A IndicatorItem represented as an Element node """ document = 'RegistryItem' search = 'RegistryItem/ValueName' content_type = 'string' ...
[ "def", "make_registryitem_valuename", "(", "valuename", ",", "condition", "=", "'is'", ",", "negate", "=", "False", ",", "preserve_case", "=", "False", ")", ":", "document", "=", "'RegistryItem'", "search", "=", "'RegistryItem/ValueName'", "content_type", "=", "'s...
Create a node for RegistryItem/ValueName :return: A IndicatorItem represented as an Element node
[ "Create", "a", "node", "for", "RegistryItem", "/", "ValueName", ":", "return", ":", "A", "IndicatorItem", "represented", "as", "an", "Element", "node" ]
python
train
41.153846
juju/charm-helpers
charmhelpers/contrib/charmsupport/volumes.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/charmsupport/volumes.py#L143-L173
def configure_volume(before_change=lambda: None, after_change=lambda: None): '''Set up storage (or don't) according to the charm's volume configuration. Returns the mount point or "ephemeral". before_change and after_change are optional functions to be called if the volume configuration changes. '...
[ "def", "configure_volume", "(", "before_change", "=", "lambda", ":", "None", ",", "after_change", "=", "lambda", ":", "None", ")", ":", "config", "=", "get_config", "(", ")", "if", "not", "config", ":", "hookenv", ".", "log", "(", "'Failed to read volume con...
Set up storage (or don't) according to the charm's volume configuration. Returns the mount point or "ephemeral". before_change and after_change are optional functions to be called if the volume configuration changes.
[ "Set", "up", "storage", "(", "or", "don", "t", ")", "according", "to", "the", "charm", "s", "volume", "configuration", ".", "Returns", "the", "mount", "point", "or", "ephemeral", ".", "before_change", "and", "after_change", "are", "optional", "functions", "t...
python
train
36.483871
berkeley-cocosci/Wallace
wallace/recruiters.py
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/recruiters.py#L207-L216
def reward_bonus(self, assignment_id, amount, reason): """Reward the Turker with a bonus.""" from psiturk.amt_services import MTurkServices self.amt_services = MTurkServices( self.aws_access_key_id, self.aws_secret_access_key, self.config.getboolean( ...
[ "def", "reward_bonus", "(", "self", ",", "assignment_id", ",", "amount", ",", "reason", ")", ":", "from", "psiturk", ".", "amt_services", "import", "MTurkServices", "self", ".", "amt_services", "=", "MTurkServices", "(", "self", ".", "aws_access_key_id", ",", ...
Reward the Turker with a bonus.
[ "Reward", "the", "Turker", "with", "a", "bonus", "." ]
python
train
44.2
davidfokkema/artist
demo/demo_fourier_with_legend.py
https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/demo/demo_fourier_with_legend.py#L26-L32
def fourier(x, N): """Fourier approximation with N terms""" term = 0. for n in range(1, N, 2): term += (1. / n) * math.sin(n * math.pi * x / L) return (4. / (math.pi)) * term
[ "def", "fourier", "(", "x", ",", "N", ")", ":", "term", "=", "0.", "for", "n", "in", "range", "(", "1", ",", "N", ",", "2", ")", ":", "term", "+=", "(", "1.", "/", "n", ")", "*", "math", ".", "sin", "(", "n", "*", "math", ".", "pi", "*"...
Fourier approximation with N terms
[ "Fourier", "approximation", "with", "N", "terms" ]
python
train
27.571429
saltstack/salt
salt/proxy/ssh_sample.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/ssh_sample.py#L38-L52
def init(opts): ''' Required. Can be used to initialize the server connection. ''' try: DETAILS['server'] = SSHConnection(host=__opts__['proxy']['host'], username=__opts__['proxy']['username'], password=__opt...
[ "def", "init", "(", "opts", ")", ":", "try", ":", "DETAILS", "[", "'server'", "]", "=", "SSHConnection", "(", "host", "=", "__opts__", "[", "'proxy'", "]", "[", "'host'", "]", ",", "username", "=", "__opts__", "[", "'proxy'", "]", "[", "'username'", ...
Required. Can be used to initialize the server connection.
[ "Required", ".", "Can", "be", "used", "to", "initialize", "the", "server", "connection", "." ]
python
train
33.4
Kane610/axis
axis/param_cgi.py
https://github.com/Kane610/axis/blob/b2b44ce595c7b722b5e13eabcab7b91f048e1808/axis/param_cgi.py#L149-L156
def process_raw(self, raw: str) -> None: """Pre-process raw string. Prepare parameters to work with APIItems. """ raw_params = dict(group.split('=', 1) for group in raw.splitlines()) super().process_raw(raw_params)
[ "def", "process_raw", "(", "self", ",", "raw", ":", "str", ")", "->", "None", ":", "raw_params", "=", "dict", "(", "group", ".", "split", "(", "'='", ",", "1", ")", "for", "group", "in", "raw", ".", "splitlines", "(", ")", ")", "super", "(", ")",...
Pre-process raw string. Prepare parameters to work with APIItems.
[ "Pre", "-", "process", "raw", "string", "." ]
python
train
31.125
seequent/properties
properties/math.py
https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/math.py#L227-L236
def to_json(value, **kwargs): """Convert array to JSON list nan values are converted to string 'nan', inf values to 'inf'. """ def _recurse_list(val): if val and isinstance(val[0], list): return [_recurse_list(v) for v in val] return [str(v) if np...
[ "def", "to_json", "(", "value", ",", "*", "*", "kwargs", ")", ":", "def", "_recurse_list", "(", "val", ")", ":", "if", "val", "and", "isinstance", "(", "val", "[", "0", "]", ",", "list", ")", ":", "return", "[", "_recurse_list", "(", "v", ")", "f...
Convert array to JSON list nan values are converted to string 'nan', inf values to 'inf'.
[ "Convert", "array", "to", "JSON", "list" ]
python
train
40.1
callowayproject/Calloway
calloway/apps/django_ext/templatetags/smart_if.py
https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/django_ext/templatetags/smart_if.py#L304-L329
def smart_if(parser, token): ''' A smarter {% if %} tag for django templates. While retaining current Django functionality, it also handles equality, greater than and less than operators. Some common case examples:: {% if articles|length >= 5 %}...{% endif %} {% if "ifnotequal tag" != ...
[ "def", "smart_if", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "[", "1", ":", "]", "var", "=", "TemplateIfParser", "(", "parser", ",", "bits", ")", ".", "parse", "(", ")", "nodelist_true", "=", "parse...
A smarter {% if %} tag for django templates. While retaining current Django functionality, it also handles equality, greater than and less than operators. Some common case examples:: {% if articles|length >= 5 %}...{% endif %} {% if "ifnotequal tag" != "beautiful" %}...{% endif %} Argumen...
[ "A", "smarter", "{", "%", "if", "%", "}", "tag", "for", "django", "templates", "." ]
python
train
36.884615
wesleybeckner/salty
salty/core.py
https://github.com/wesleybeckner/salty/blob/ef17a97aea3e4f81fcd0359ce85b3438c0e6499b/salty/core.py#L85-L159
def merge_duplicates(model_name, keep_descriptors=False): """ Identifies repeated experimental values and returns mean values for those data along with their standard deviation. Only aggregates experimental values that have been acquired at the same temperature and pressure. Parameters --------...
[ "def", "merge_duplicates", "(", "model_name", ",", "keep_descriptors", "=", "False", ")", ":", "model_outputs", "=", "-", "6", "+", "model_name", ".", "Data_summary", ".", "shape", "[", "0", "]", "devmodel", "=", "model_name", "cols", "=", "devmodel", ".", ...
Identifies repeated experimental values and returns mean values for those data along with their standard deviation. Only aggregates experimental values that have been acquired at the same temperature and pressure. Parameters ---------- model_name: dev_model the dev_model object to be interr...
[ "Identifies", "repeated", "experimental", "values", "and", "returns", "mean", "values", "for", "those", "data", "along", "with", "their", "standard", "deviation", ".", "Only", "aggregates", "experimental", "values", "that", "have", "been", "acquired", "at", "the",...
python
train
44.613333
bcbio/bcbio-nextgen
bcbio/variation/joint.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/joint.py#L145-L158
def _combine_to_jointcaller(processed): """Add joint calling information to variants, while collapsing independent regions. """ by_vrn_file = collections.OrderedDict() for data in (x[0] for x in processed): key = (tz.get_in(("config", "algorithm", "jointcaller"), data), data["vrn_file"]) ...
[ "def", "_combine_to_jointcaller", "(", "processed", ")", ":", "by_vrn_file", "=", "collections", ".", "OrderedDict", "(", ")", "for", "data", "in", "(", "x", "[", "0", "]", "for", "x", "in", "processed", ")", ":", "key", "=", "(", "tz", ".", "get_in", ...
Add joint calling information to variants, while collapsing independent regions.
[ "Add", "joint", "calling", "information", "to", "variants", "while", "collapsing", "independent", "regions", "." ]
python
train
38.285714
Netflix-Skunkworks/cloudaux
cloudaux/orchestration/aws/vpc.py
https://github.com/Netflix-Skunkworks/cloudaux/blob/c4b0870c3ac68b1c69e71d33cf78b6a8bdf437ea/cloudaux/orchestration/aws/vpc.py#L90-L98
def get_subnets(vpc, **conn): """Gets the VPC Subnets""" subnets = describe_subnets(Filters=[{"Name": "vpc-id", "Values": [vpc["id"]]}], **conn) s_ids = [] for s in subnets: s_ids.append(s["SubnetId"]) return s_ids
[ "def", "get_subnets", "(", "vpc", ",", "*", "*", "conn", ")", ":", "subnets", "=", "describe_subnets", "(", "Filters", "=", "[", "{", "\"Name\"", ":", "\"vpc-id\"", ",", "\"Values\"", ":", "[", "vpc", "[", "\"id\"", "]", "]", "}", "]", ",", "*", "*...
Gets the VPC Subnets
[ "Gets", "the", "VPC", "Subnets" ]
python
valid
26.222222
nicolargo/glances
glances/attribute.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L137-L141
def history_mean(self, nb=5): """Return the mean on the <nb> values in the history. """ _, v = zip(*self._history) return sum(v[-nb:]) / float(v[-1] - v[-nb])
[ "def", "history_mean", "(", "self", ",", "nb", "=", "5", ")", ":", "_", ",", "v", "=", "zip", "(", "*", "self", ".", "_history", ")", "return", "sum", "(", "v", "[", "-", "nb", ":", "]", ")", "/", "float", "(", "v", "[", "-", "1", "]", "-...
Return the mean on the <nb> values in the history.
[ "Return", "the", "mean", "on", "the", "<nb", ">", "values", "in", "the", "history", "." ]
python
train
37.2
minorg/pastpy
py/src/pastpy/gen/database/impl/dummy/dummy_database_configuration.py
https://github.com/minorg/pastpy/blob/7d5d6d511629481850216565e7451b5dcb8027a9/py/src/pastpy/gen/database/impl/dummy/dummy_database_configuration.py#L184-L206
def read(cls, iprot): ''' Read a new object from the given input protocol and return the object. :type iprot: thryft.protocol._input_protocol._InputProtocol :rtype: pastpy.gen.database.impl.dummy.dummy_database_configuration.DummyDatabaseConfiguration ''' init_kwds = {}...
[ "def", "read", "(", "cls", ",", "iprot", ")", ":", "init_kwds", "=", "{", "}", "iprot", ".", "read_struct_begin", "(", ")", "while", "True", ":", "ifield_name", ",", "ifield_type", ",", "_ifield_id", "=", "iprot", ".", "read_field_begin", "(", ")", "if",...
Read a new object from the given input protocol and return the object. :type iprot: thryft.protocol._input_protocol._InputProtocol :rtype: pastpy.gen.database.impl.dummy.dummy_database_configuration.DummyDatabaseConfiguration
[ "Read", "a", "new", "object", "from", "the", "given", "input", "protocol", "and", "return", "the", "object", "." ]
python
train
35.217391
angr/angr
angr/state_plugins/inspect.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/inspect.py#L251-L260
def make_breakpoint(self, event_type, *args, **kwargs): """ Creates and adds a breakpoint which would trigger on `event_type`. Additional arguments are passed to the :class:`BP` constructor. :return: The created breakpoint, so that it can be removed later. """ bp = BP...
[ "def", "make_breakpoint", "(", "self", ",", "event_type", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "bp", "=", "BP", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "add_breakpoint", "(", "event_type", ",", "bp", ")", "retur...
Creates and adds a breakpoint which would trigger on `event_type`. Additional arguments are passed to the :class:`BP` constructor. :return: The created breakpoint, so that it can be removed later.
[ "Creates", "and", "adds", "a", "breakpoint", "which", "would", "trigger", "on", "event_type", ".", "Additional", "arguments", "are", "passed", "to", "the", ":", "class", ":", "BP", "constructor", "." ]
python
train
39
has2k1/plotnine
plotnine/facets/facet.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L319-L350
def _create_subplots(self, fig, layout): """ Create suplots and return axs """ num_panels = len(layout) axsarr = np.empty((self.nrow, self.ncol), dtype=object) # Create axes i = 1 for row in range(self.nrow): for col in range(self.ncol): ...
[ "def", "_create_subplots", "(", "self", ",", "fig", ",", "layout", ")", ":", "num_panels", "=", "len", "(", "layout", ")", "axsarr", "=", "np", ".", "empty", "(", "(", "self", ".", "nrow", ",", "self", ".", "ncol", ")", ",", "dtype", "=", "object",...
Create suplots and return axs
[ "Create", "suplots", "and", "return", "axs" ]
python
train
29.1875
danielfrg/datasciencebox
datasciencebox/core/project.py
https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/project.py#L153-L162
def salt_ssh_create_dirs(self): """ Creates the `salt-ssh` required directory structure """ logger.debug('Creating salt-ssh dirs into: %s', self.settings_dir) utils.create_dir(os.path.join(self.settings_dir, 'salt')) utils.create_dir(os.path.join(self.settings_dir, 'pilla...
[ "def", "salt_ssh_create_dirs", "(", "self", ")", ":", "logger", ".", "debug", "(", "'Creating salt-ssh dirs into: %s'", ",", "self", ".", "settings_dir", ")", "utils", ".", "create_dir", "(", "os", ".", "path", ".", "join", "(", "self", ".", "settings_dir", ...
Creates the `salt-ssh` required directory structure
[ "Creates", "the", "salt", "-", "ssh", "required", "directory", "structure" ]
python
train
55
saltstack/salt
salt/utils/network.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1184-L1221
def _subnets(proto='inet', interfaces_=None): ''' Returns a list of subnets to which the host belongs ''' if interfaces_ is None: ifaces = interfaces() elif isinstance(interfaces_, list): ifaces = {} for key, value in six.iteritems(interfaces()): if key in interfa...
[ "def", "_subnets", "(", "proto", "=", "'inet'", ",", "interfaces_", "=", "None", ")", ":", "if", "interfaces_", "is", "None", ":", "ifaces", "=", "interfaces", "(", ")", "elif", "isinstance", "(", "interfaces_", ",", "list", ")", ":", "ifaces", "=", "{...
Returns a list of subnets to which the host belongs
[ "Returns", "a", "list", "of", "subnets", "to", "which", "the", "host", "belongs" ]
python
train
32.526316
Stufinite/djangoApiDec
djangoApiDec/djangoApiDec.py
https://github.com/Stufinite/djangoApiDec/blob/8b2d5776b3413b1b850df12a92f30526c05c0a46/djangoApiDec/djangoApiDec.py#L101-L112
def getJsonFromApi(view, request): """Return json from querying Web Api Args: view: django view function. request: http request object got from django. Returns: json format dictionary """ jsonText = view(request) jsonText = json.loads(jsonText.content.decode('utf-8')) return jsonText
[ "def", "getJsonFromApi", "(", "view", ",", "request", ")", ":", "jsonText", "=", "view", "(", "request", ")", "jsonText", "=", "json", ".", "loads", "(", "jsonText", ".", "content", ".", "decode", "(", "'utf-8'", ")", ")", "return", "jsonText" ]
Return json from querying Web Api Args: view: django view function. request: http request object got from django. Returns: json format dictionary
[ "Return", "json", "from", "querying", "Web", "Api" ]
python
valid
24.583333
klen/peewee_migrate
peewee_migrate/router.py
https://github.com/klen/peewee_migrate/blob/b77895ab1c9be3121bc127e0c2dfb047eed8b24c/peewee_migrate/router.py#L59-L62
def diff(self): """Calculate difference between fs and db.""" done = set(self.done) return [name for name in self.todo if name not in done]
[ "def", "diff", "(", "self", ")", ":", "done", "=", "set", "(", "self", ".", "done", ")", "return", "[", "name", "for", "name", "in", "self", ".", "todo", "if", "name", "not", "in", "done", "]" ]
Calculate difference between fs and db.
[ "Calculate", "difference", "between", "fs", "and", "db", "." ]
python
train
40
silver-castle/mach9
mach9/app.py
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L102-L128
def route(self, uri, methods=frozenset({'GET'}), host=None, strict_slashes=False, stream=False, websocket=False): '''Decorate a function to be registered as a route :param uri: path of the URL :param methods: list or tuple of methods allowed :param host: :param str...
[ "def", "route", "(", "self", ",", "uri", ",", "methods", "=", "frozenset", "(", "{", "'GET'", "}", ")", ",", "host", "=", "None", ",", "strict_slashes", "=", "False", ",", "stream", "=", "False", ",", "websocket", "=", "False", ")", ":", "# Fix case ...
Decorate a function to be registered as a route :param uri: path of the URL :param methods: list or tuple of methods allowed :param host: :param strict_slashes: :param stream: :return: decorated function
[ "Decorate", "a", "function", "to", "be", "registered", "as", "a", "route" ]
python
train
34.703704
numenta/nupic
src/nupic/frameworks/opf/model.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L78-L97
def run(self, inputRecord): """ Run one iteration of this model. :param inputRecord: (object) A record object formatted according to :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecord` or :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecordDict` ...
[ "def", "run", "(", "self", ",", "inputRecord", ")", ":", "# 0-based prediction index for ModelResult", "predictionNumber", "=", "self", ".", "_numPredictions", "self", ".", "_numPredictions", "+=", "1", "result", "=", "opf_utils", ".", "ModelResult", "(", "predictio...
Run one iteration of this model. :param inputRecord: (object) A record object formatted according to :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecord` or :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecordDict` result format. :returns: (:...
[ "Run", "one", "iteration", "of", "this", "model", "." ]
python
valid
44.05
AlecAivazis/graphql-over-kafka
nautilus/network/events/actionHandlers/readHandler.py
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/actionHandlers/readHandler.py#L6-L56
def read_handler(Model, name=None, **kwds): """ This factory returns an action handler that responds to read requests by resolving the payload as a graphql query against the internal schema. Args: Model (nautilus.BaseModel): The model to delete when the action r...
[ "def", "read_handler", "(", "Model", ",", "name", "=", "None", ",", "*", "*", "kwds", ")", ":", "async", "def", "action_handler", "(", "service", ",", "action_type", ",", "payload", ",", "props", ",", "*", "*", "kwds", ")", ":", "# if the payload represe...
This factory returns an action handler that responds to read requests by resolving the payload as a graphql query against the internal schema. Args: Model (nautilus.BaseModel): The model to delete when the action received. Returns: function(type, payloa...
[ "This", "factory", "returns", "an", "action", "handler", "that", "responds", "to", "read", "requests", "by", "resolving", "the", "payload", "as", "a", "graphql", "query", "against", "the", "internal", "schema", "." ]
python
train
37.568627
all-umass/graphs
graphs/mixins/analysis.py
https://github.com/all-umass/graphs/blob/4fbeb025dfe33340335f34300f58dd3809228822/graphs/mixins/analysis.py#L61-L88
def directed_laplacian(self, D=None, eta=0.99, tol=1e-12, max_iter=500): '''Computes the directed combinatorial graph laplacian. http://www-all.cs.umass.edu/pubs/2007/johns_m_ICML07.pdf D: (optional) N-array of degrees eta: probability of not teleporting (see the paper) tol, max_iter: convergence p...
[ "def", "directed_laplacian", "(", "self", ",", "D", "=", "None", ",", "eta", "=", "0.99", ",", "tol", "=", "1e-12", ",", "max_iter", "=", "500", ")", ":", "W", "=", "self", ".", "matrix", "(", "'dense'", ")", "n", "=", "W", ".", "shape", "[", "...
Computes the directed combinatorial graph laplacian. http://www-all.cs.umass.edu/pubs/2007/johns_m_ICML07.pdf D: (optional) N-array of degrees eta: probability of not teleporting (see the paper) tol, max_iter: convergence params for Perron vector calculation
[ "Computes", "the", "directed", "combinatorial", "graph", "laplacian", ".", "http", ":", "//", "www", "-", "all", ".", "cs", ".", "umass", ".", "edu", "/", "pubs", "/", "2007", "/", "johns_m_ICML07", ".", "pdf" ]
python
train
37.857143
PyMySQL/Tornado-MySQL
tornado_mysql/converters.py
https://github.com/PyMySQL/Tornado-MySQL/blob/75d3466e4332e43b2bf853799f1122dec5da60bc/tornado_mysql/converters.py#L222-L252
def convert_mysql_timestamp(timestamp): """Convert a MySQL TIMESTAMP to a Timestamp object. MySQL >= 4.1 returns TIMESTAMP in the same format as DATETIME: >>> mysql_timestamp_converter('2007-02-25 22:32:17') datetime.datetime(2007, 2, 25, 22, 32, 17) MySQL < 4.1 uses a big string of numbers: ...
[ "def", "convert_mysql_timestamp", "(", "timestamp", ")", ":", "if", "timestamp", "[", "4", "]", "==", "'-'", ":", "return", "convert_datetime", "(", "timestamp", ")", "timestamp", "+=", "\"0\"", "*", "(", "14", "-", "len", "(", "timestamp", ")", ")", "# ...
Convert a MySQL TIMESTAMP to a Timestamp object. MySQL >= 4.1 returns TIMESTAMP in the same format as DATETIME: >>> mysql_timestamp_converter('2007-02-25 22:32:17') datetime.datetime(2007, 2, 25, 22, 32, 17) MySQL < 4.1 uses a big string of numbers: >>> mysql_timestamp_converter('200702252...
[ "Convert", "a", "MySQL", "TIMESTAMP", "to", "a", "Timestamp", "object", "." ]
python
train
33.451613
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L392-L437
def makeLys(segID, N, CA, C, O, geo): '''Creates a Lysine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle ...
[ "def", "makeLys", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Lysine residue
[ "Creates", "a", "Lysine", "residue" ]
python
train
36.23913
kubernetes-client/python
kubernetes/client/apis/core_v1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/core_v1_api.py#L13968-L13994
def list_resource_quota_for_all_namespaces(self, **kwargs): """ list or watch objects of kind ResourceQuota This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_resource_quota_for_all_names...
[ "def", "list_resource_quota_for_all_namespaces", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "list_resource_quota_fo...
list or watch objects of kind ResourceQuota This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_resource_quota_for_all_namespaces(async_req=True) >>> result = thread.get() :param async_re...
[ "list", "or", "watch", "objects", "of", "kind", "ResourceQuota", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=", "True", ">>>", ...
python
train
169.666667
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Memoize.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Memoize.py#L195-L213
def CountMethodCall(fn): """ Decorator for counting memoizer hits/misses while retrieving a simple value in a class method. It wraps the given method fn and uses a CountValue object to keep track of the caching statistics. Wrapping gets enabled by calling EnableMemoization(). """...
[ "def", "CountMethodCall", "(", "fn", ")", ":", "if", "use_memoizer", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "global", "CounterList", "key", "=", "self", ".", "__class__", ".", "__name__", "+", "'.'", ...
Decorator for counting memoizer hits/misses while retrieving a simple value in a class method. It wraps the given method fn and uses a CountValue object to keep track of the caching statistics. Wrapping gets enabled by calling EnableMemoization().
[ "Decorator", "for", "counting", "memoizer", "hits", "/", "misses", "while", "retrieving", "a", "simple", "value", "in", "a", "class", "method", ".", "It", "wraps", "the", "given", "method", "fn", "and", "uses", "a", "CountValue", "object", "to", "keep", "t...
python
train
40.578947
jlevy/strif
strif.py
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L149-L164
def move_to_backup(path, backup_suffix=BACKUP_SUFFIX): """ Move the given file or directory to the same name, with a backup suffix. If backup_suffix not supplied, move it to the extension ".bak". NB: If backup_suffix is supplied and is None, don't do anything. """ if backup_suffix and os.path.exists(path): ...
[ "def", "move_to_backup", "(", "path", ",", "backup_suffix", "=", "BACKUP_SUFFIX", ")", ":", "if", "backup_suffix", "and", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "backup_path", "=", "path", "+", "backup_suffix", "# Some messy corner cases need t...
Move the given file or directory to the same name, with a backup suffix. If backup_suffix not supplied, move it to the extension ".bak". NB: If backup_suffix is supplied and is None, don't do anything.
[ "Move", "the", "given", "file", "or", "directory", "to", "the", "same", "name", "with", "a", "backup", "suffix", ".", "If", "backup_suffix", "not", "supplied", "move", "it", "to", "the", "extension", ".", "bak", ".", "NB", ":", "If", "backup_suffix", "is...
python
train
45.8125
python-diamond/Diamond
src/collectors/processresources/processresources.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/processresources/processresources.py#L49-L73
def match_process(pid, name, cmdline, exe, cfg): """ Decides whether a process matches with a given process descriptor :param pid: process pid :param exe: process executable :param name: process name :param cmdline: process cmdline :param cfg: the dictionary from processes that describes wi...
[ "def", "match_process", "(", "pid", ",", "name", ",", "cmdline", ",", "exe", ",", "cfg", ")", ":", "if", "cfg", "[", "'selfmon'", "]", "and", "pid", "==", "os", ".", "getpid", "(", ")", ":", "return", "True", "for", "exe_re", "in", "cfg", "[", "'...
Decides whether a process matches with a given process descriptor :param pid: process pid :param exe: process executable :param name: process name :param cmdline: process cmdline :param cfg: the dictionary from processes that describes with the process group we're testing for :return: T...
[ "Decides", "whether", "a", "process", "matches", "with", "a", "given", "process", "descriptor" ]
python
train
30.68
miguelgrinberg/python-socketio
socketio/client.py
https://github.com/miguelgrinberg/python-socketio/blob/c0c1bf8d21e3597389b18938550a0724dd9676b7/socketio/client.py#L319-L327
def disconnect(self): """Disconnect from the server.""" # here we just request the disconnection # later in _handle_eio_disconnect we invoke the disconnect handler for n in self.namespaces: self._send_packet(packet.Packet(packet.DISCONNECT, namespace=n)) self._send_pa...
[ "def", "disconnect", "(", "self", ")", ":", "# here we just request the disconnection", "# later in _handle_eio_disconnect we invoke the disconnect handler", "for", "n", "in", "self", ".", "namespaces", ":", "self", ".", "_send_packet", "(", "packet", ".", "Packet", "(", ...
Disconnect from the server.
[ "Disconnect", "from", "the", "server", "." ]
python
train
46.444444
rwl/pylon
pylon/estimator.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/estimator.py#L300-L321
def getV0(self, v_mag_guess, buses, generators, type=CASE_GUESS): """ Returns the initial voltage profile. """ if type == CASE_GUESS: Va = array([b.v_angle * (pi / 180.0) for b in buses]) Vm = array([b.v_magnitude for b in buses]) V0 = Vm * exp(1j * Va) ...
[ "def", "getV0", "(", "self", ",", "v_mag_guess", ",", "buses", ",", "generators", ",", "type", "=", "CASE_GUESS", ")", ":", "if", "type", "==", "CASE_GUESS", ":", "Va", "=", "array", "(", "[", "b", ".", "v_angle", "*", "(", "pi", "/", "180.0", ")",...
Returns the initial voltage profile.
[ "Returns", "the", "initial", "voltage", "profile", "." ]
python
train
35.227273
stevelittlefish/easyforms
easyforms/form.py
https://github.com/stevelittlefish/easyforms/blob/f5dd2635b045beec9af970b249909f8429cedc57/easyforms/form.py#L679-L707
def read_form_data(self): """Attempt to read the form data from the request""" if self.processed_data: raise exceptions.AlreadyProcessed('The data has already been processed for this form') if self.readonly: return if request.method == self.method: ...
[ "def", "read_form_data", "(", "self", ")", ":", "if", "self", ".", "processed_data", ":", "raise", "exceptions", ".", "AlreadyProcessed", "(", "'The data has already been processed for this form'", ")", "if", "self", ".", "readonly", ":", "return", "if", "request", ...
Attempt to read the form data from the request
[ "Attempt", "to", "read", "the", "form", "data", "from", "the", "request" ]
python
train
36.482759
Tanganelli/CoAPthon3
coapthon/layers/observelayer.py
https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/layers/observelayer.py#L78-L108
def receive_request(self, transaction): """ Manage the observe option in the request end eventually initialize the client for adding to the list of observers or remove from the list. :type transaction: Transaction :param transaction: the transaction that owns the request ...
[ "def", "receive_request", "(", "self", ",", "transaction", ")", ":", "if", "transaction", ".", "request", ".", "observe", "==", "0", ":", "# Observe request", "host", ",", "port", "=", "transaction", ".", "request", ".", "source", "key_token", "=", "hash", ...
Manage the observe option in the request end eventually initialize the client for adding to the list of observers or remove from the list. :type transaction: Transaction :param transaction: the transaction that owns the request :rtype : Transaction :return: the modified transact...
[ "Manage", "the", "observe", "option", "in", "the", "request", "end", "eventually", "initialize", "the", "client", "for", "adding", "to", "the", "list", "of", "observers", "or", "remove", "from", "the", "list", "." ]
python
train
40
sorgerlab/indra
indra/assemblers/sbgn/assembler.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L71-L106
def make_model(self): """Assemble the SBGN model from the collected INDRA Statements. This method assembles an SBGN model from the set of INDRA Statements. The assembled model is set as the assembler's sbgn attribute (it is represented as an XML ElementTree internally). The model is ret...
[ "def", "make_model", "(", "self", ")", ":", "ppa", "=", "PysbPreassembler", "(", "self", ".", "statements", ")", "ppa", ".", "replace_activities", "(", ")", "self", ".", "statements", "=", "ppa", ".", "statements", "self", ".", "sbgn", "=", "emaker", "."...
Assemble the SBGN model from the collected INDRA Statements. This method assembles an SBGN model from the set of INDRA Statements. The assembled model is set as the assembler's sbgn attribute (it is represented as an XML ElementTree internally). The model is returned as a serialized XML...
[ "Assemble", "the", "SBGN", "model", "from", "the", "collected", "INDRA", "Statements", "." ]
python
train
38.666667