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
honeynet/beeswarm
beeswarm/drones/client/models/dispatcher.py
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/models/dispatcher.py#L101-L107
def time_in_range(self): """Return true if current time is in the active range""" curr = datetime.datetime.now().time() if self.start_time <= self.end_time: return self.start_time <= curr <= self.end_time else: return self.start_time <= curr or curr <= self.end_ti...
[ "def", "time_in_range", "(", "self", ")", ":", "curr", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "time", "(", ")", "if", "self", ".", "start_time", "<=", "self", ".", "end_time", ":", "return", "self", ".", "start_time", "<=", "cur...
Return true if current time is in the active range
[ "Return", "true", "if", "current", "time", "is", "in", "the", "active", "range" ]
python
train
45.142857
jaraco/keyring
keyring/core.py
https://github.com/jaraco/keyring/blob/71c798378e365286b7cc03c06e4d7d24c7de8fc4/keyring/core.py#L147-L174
def load_config(): """Load a keyring using the config file in the config root.""" filename = 'keyringrc.cfg' keyring_cfg = os.path.join(platform.config_root(), filename) if not os.path.exists(keyring_cfg): return config = configparser.RawConfigParser() config.read(keyring_cfg) _l...
[ "def", "load_config", "(", ")", ":", "filename", "=", "'keyringrc.cfg'", "keyring_cfg", "=", "os", ".", "path", ".", "join", "(", "platform", ".", "config_root", "(", ")", ",", "filename", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "keyri...
Load a keyring using the config file in the config root.
[ "Load", "a", "keyring", "using", "the", "config", "file", "in", "the", "config", "root", "." ]
python
valid
31.535714
tcalmant/ipopo
samples/rsa/helloimpl.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/samples/rsa/helloimpl.py#L25-L38
def sayHello(self, name="Not given", message="nothing"): """ Synchronous implementation of IHello.sayHello synchronous method. The remote calling thread will be blocked until this is executed and responds. """ print( "Python.sayHello called by: {0} " ...
[ "def", "sayHello", "(", "self", ",", "name", "=", "\"Not given\"", ",", "message", "=", "\"nothing\"", ")", ":", "print", "(", "\"Python.sayHello called by: {0} \"", "\"with message: '{1}'\"", ".", "format", "(", "name", ",", "message", ")", ")", "return", "(", ...
Synchronous implementation of IHello.sayHello synchronous method. The remote calling thread will be blocked until this is executed and responds.
[ "Synchronous", "implementation", "of", "IHello", ".", "sayHello", "synchronous", "method", ".", "The", "remote", "calling", "thread", "will", "be", "blocked", "until", "this", "is", "executed", "and", "responds", "." ]
python
train
35.357143
BlockHub/blockhubdpostools
dpostools/legacy.py
https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L49-L54
def set_connection(host=None, database=None, user=None, password=None): """Set connection parameters. Call set_connection with no arguments to clear.""" c.CONNECTION['HOST'] = host c.CONNECTION['DATABASE'] = database c.CONNECTION['USER'] = user c.CONNECTION['PASSWORD'] = password
[ "def", "set_connection", "(", "host", "=", "None", ",", "database", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ")", ":", "c", ".", "CONNECTION", "[", "'HOST'", "]", "=", "host", "c", ".", "CONNECTION", "[", "'DATABASE'", "]"...
Set connection parameters. Call set_connection with no arguments to clear.
[ "Set", "connection", "parameters", ".", "Call", "set_connection", "with", "no", "arguments", "to", "clear", "." ]
python
valid
49.166667
dcaune/perseus-lib-python-common
majormode/perseus/utils/email_util.py
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/email_util.py#L44-L75
def __build_author_name_expr(author_name, author_email_address): """ Build the name of the author of a message as described in the Internet Message Format specification: https://tools.ietf.org/html/rfc5322#section-3.6.2 @param author_name: complete name of the originator of the message. @param au...
[ "def", "__build_author_name_expr", "(", "author_name", ",", "author_email_address", ")", ":", "assert", "author_name", "or", "author_email_address", ",", "'Both arguments MUST NOT be bull'", "# Use the specified name of the author or the username of his email", "# address.", "author_...
Build the name of the author of a message as described in the Internet Message Format specification: https://tools.ietf.org/html/rfc5322#section-3.6.2 @param author_name: complete name of the originator of the message. @param author_email_address: address of the mailbox to which the author of the...
[ "Build", "the", "name", "of", "the", "author", "of", "a", "message", "as", "described", "in", "the", "Internet", "Message", "Format", "specification", ":", "https", ":", "//", "tools", ".", "ietf", ".", "org", "/", "html", "/", "rfc5322#section", "-", "3...
python
train
40.53125
obriencj/python-javatools
javatools/ziputils.py
https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L357-L375
def zip_entry_rollup(zipfile): """ returns a tuple of (files, dirs, size_uncompressed, size_compressed). files+dirs will equal len(zipfile.infolist) """ files = dirs = 0 total_c = total_u = 0 for i in zipfile.infolist(): if i.filename[-1] == '/': # I wonder if there's a...
[ "def", "zip_entry_rollup", "(", "zipfile", ")", ":", "files", "=", "dirs", "=", "0", "total_c", "=", "total_u", "=", "0", "for", "i", "in", "zipfile", ".", "infolist", "(", ")", ":", "if", "i", ".", "filename", "[", "-", "1", "]", "==", "'/'", ":...
returns a tuple of (files, dirs, size_uncompressed, size_compressed). files+dirs will equal len(zipfile.infolist)
[ "returns", "a", "tuple", "of", "(", "files", "dirs", "size_uncompressed", "size_compressed", ")", ".", "files", "+", "dirs", "will", "equal", "len", "(", "zipfile", ".", "infolist", ")" ]
python
train
26.894737
StanfordVL/robosuite
robosuite/environments/sawyer_stack.py
https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/environments/sawyer_stack.py#L195-L211
def _get_reference(self): """ Sets up references to important components. A reference is typically an index or a list of indices that point to the corresponding elements in a flatten array, which is how MuJoCo stores physical simulation data. """ super()._get_reference() ...
[ "def", "_get_reference", "(", "self", ")", ":", "super", "(", ")", ".", "_get_reference", "(", ")", "self", ".", "cubeA_body_id", "=", "self", ".", "sim", ".", "model", ".", "body_name2id", "(", "\"cubeA\"", ")", "self", ".", "cubeB_body_id", "=", "self"...
Sets up references to important components. A reference is typically an index or a list of indices that point to the corresponding elements in a flatten array, which is how MuJoCo stores physical simulation data.
[ "Sets", "up", "references", "to", "important", "components", ".", "A", "reference", "is", "typically", "an", "index", "or", "a", "list", "of", "indices", "that", "point", "to", "the", "corresponding", "elements", "in", "a", "flatten", "array", "which", "is",...
python
train
48.470588
opendatateam/udata
udata/app.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/app.py#L155-L188
def create_app(config='udata.settings.Defaults', override=None, init_logging=init_logging): '''Factory for a minimal application''' app = UDataApp(APP_NAME) app.config.from_object(config) settings = os.environ.get('UDATA_SETTINGS', join(os.getcwd(), 'udata.cfg')) if exists(settings):...
[ "def", "create_app", "(", "config", "=", "'udata.settings.Defaults'", ",", "override", "=", "None", ",", "init_logging", "=", "init_logging", ")", ":", "app", "=", "UDataApp", "(", "APP_NAME", ")", "app", ".", "config", ".", "from_object", "(", "config", ")"...
Factory for a minimal application
[ "Factory", "for", "a", "minimal", "application" ]
python
train
32.117647
PmagPy/PmagPy
pmagpy/builder2.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/builder2.py#L1193-L1207
def validate_data(self): """ Validate specimen, sample, site, and location data. """ warnings = {} spec_warnings, samp_warnings, site_warnings, loc_warnings = {}, {}, {}, {} if self.specimens: spec_warnings = self.validate_items(self.specimens, 'specimen') ...
[ "def", "validate_data", "(", "self", ")", ":", "warnings", "=", "{", "}", "spec_warnings", ",", "samp_warnings", ",", "site_warnings", ",", "loc_warnings", "=", "{", "}", ",", "{", "}", ",", "{", "}", ",", "{", "}", "if", "self", ".", "specimens", ":...
Validate specimen, sample, site, and location data.
[ "Validate", "specimen", "sample", "site", "and", "location", "data", "." ]
python
train
44.333333
w1ll1am23/pyeconet
src/pyeconet/api.py
https://github.com/w1ll1am23/pyeconet/blob/05abf965f67c7445355508a38f11992d13adac4f/src/pyeconet/api.py#L102-L111
def get_locations(): """ Pull the accounts locations. """ arequest = requests.get(LOCATIONS_URL, headers=HEADERS) status_code = str(arequest.status_code) if status_code == '401': _LOGGER.error("Token expired.") return False return arequest....
[ "def", "get_locations", "(", ")", ":", "arequest", "=", "requests", ".", "get", "(", "LOCATIONS_URL", ",", "headers", "=", "HEADERS", ")", "status_code", "=", "str", "(", "arequest", ".", "status_code", ")", "if", "status_code", "==", "'401'", ":", "_LOGGE...
Pull the accounts locations.
[ "Pull", "the", "accounts", "locations", "." ]
python
valid
31.7
openpaperwork/paperwork-backend
paperwork_backend/index.py
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L475-L487
def guess_labels(self, doc): """ return a prediction of label names """ if doc.nb_pages <= 0: return set() self.label_guesser.total_nb_documents = len(self._docs_by_id.keys()) label_names = self.label_guesser.guess(doc) labels = set() for label...
[ "def", "guess_labels", "(", "self", ",", "doc", ")", ":", "if", "doc", ".", "nb_pages", "<=", "0", ":", "return", "set", "(", ")", "self", ".", "label_guesser", ".", "total_nb_documents", "=", "len", "(", "self", ".", "_docs_by_id", ".", "keys", "(", ...
return a prediction of label names
[ "return", "a", "prediction", "of", "label", "names" ]
python
train
32.692308
Kronuz/pyScss
scss/compiler.py
https://github.com/Kronuz/pyScss/blob/fb32b317f6e2b4b4aad2b86a74844658ac4aa11e/scss/compiler.py#L473-L479
def _at_extend(self, calculator, rule, scope, block): """ Implements @extend """ from scss.selector import Selector selectors = calculator.apply_vars(block.argument) rule.extends_selectors.extend(Selector.parse_many(selectors))
[ "def", "_at_extend", "(", "self", ",", "calculator", ",", "rule", ",", "scope", ",", "block", ")", ":", "from", "scss", ".", "selector", "import", "Selector", "selectors", "=", "calculator", ".", "apply_vars", "(", "block", ".", "argument", ")", "rule", ...
Implements @extend
[ "Implements" ]
python
train
38.428571
ace0/pyrelic
pyrelic/prf.py
https://github.com/ace0/pyrelic/blob/f23d4e6586674675f72304d5938548267d6413bf/pyrelic/prf.py#L46-L71
def wrap(x): """ Wraps an element or integer type by serializing it and base64 encoding the resulting bytes. """ # Detect the type so we can call the proper serialization routine if isinstance(x, G1Element): return _wrap(x, serializeG1) elif isinstance(x, G2Element): return...
[ "def", "wrap", "(", "x", ")", ":", "# Detect the type so we can call the proper serialization routine", "if", "isinstance", "(", "x", ",", "G1Element", ")", ":", "return", "_wrap", "(", "x", ",", "serializeG1", ")", "elif", "isinstance", "(", "x", ",", "G2Elemen...
Wraps an element or integer type by serializing it and base64 encoding the resulting bytes.
[ "Wraps", "an", "element", "or", "integer", "type", "by", "serializing", "it", "and", "base64", "encoding", "the", "resulting", "bytes", "." ]
python
train
28.153846
nanoporetech/ont_fast5_api
ont_fast5_api/analysis_tools/event_detection.py
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/analysis_tools/event_detection.py#L16-L53
def set_event_data(self, data, read_attrs): """ Set event data with the specied attributes. :param data: Event data table. :param read_attrs: Attributes to put on the read group. This must include the read_number, which must refer to a read present in the object. The ...
[ "def", "set_event_data", "(", "self", ",", "data", ",", "read_attrs", ")", ":", "if", "self", ".", "handle", ".", "mode", "==", "'r'", ":", "raise", "Exception", "(", "'File is not open for writing.'", ")", "read_number", "=", "read_attrs", "[", "'read_number'...
Set event data with the specied attributes. :param data: Event data table. :param read_attrs: Attributes to put on the read group. This must include the read_number, which must refer to a read present in the object. The attributes should not include the standard read att...
[ "Set", "event", "data", "with", "the", "specied", "attributes", ".", ":", "param", "data", ":", "Event", "data", "table", ".", ":", "param", "read_attrs", ":", "Attributes", "to", "put", "on", "the", "read", "group", ".", "This", "must", "include", "the"...
python
train
48.394737
deepmind/sonnet
sonnet/python/modules/conv.py
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2631-L2677
def _construct_w(self, inputs): """Connects the module into the graph, with input Tensor `inputs`. Args: inputs: A 4D Tensor of shape: [batch_size, input_height, input_width, input_channels] and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: A tuple of two 4D...
[ "def", "_construct_w", "(", "self", ",", "inputs", ")", ":", "depthwise_weight_shape", "=", "self", ".", "_kernel_shape", "+", "(", "self", ".", "_input_channels", ",", "self", ".", "_channel_multiplier", ")", "pointwise_input_size", "=", "self", ".", "_channel_...
Connects the module into the graph, with input Tensor `inputs`. Args: inputs: A 4D Tensor of shape: [batch_size, input_height, input_width, input_channels] and of type `tf.float16`, `tf.bfloat16` or `tf.float32`. Returns: A tuple of two 4D Tensors, each with the same dtype as `...
[ "Connects", "the", "module", "into", "the", "graph", "with", "input", "Tensor", "inputs", "." ]
python
train
41.361702
sentinel-hub/sentinelhub-py
sentinelhub/geometry.py
https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/geometry.py#L467-L485
def _parse_geometry(geometry): """ Parses given geometry into shapely object :param geometry: :return: Shapely polygon or multipolygon :rtype: shapely.geometry.Polygon or shapely.geometry.MultiPolygon :raises TypeError """ if isinstance(geometry, str): ...
[ "def", "_parse_geometry", "(", "geometry", ")", ":", "if", "isinstance", "(", "geometry", ",", "str", ")", ":", "geometry", "=", "shapely", ".", "wkt", ".", "loads", "(", "geometry", ")", "elif", "isinstance", "(", "geometry", ",", "dict", ")", ":", "g...
Parses given geometry into shapely object :param geometry: :return: Shapely polygon or multipolygon :rtype: shapely.geometry.Polygon or shapely.geometry.MultiPolygon :raises TypeError
[ "Parses", "given", "geometry", "into", "shapely", "object" ]
python
train
43.157895
ThreatConnect-Inc/tcex
tcex/tcex_bin_run.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_run.py#L1820-L1846
def _add_arg_python(self, key, value=None, mask=False): """Add CLI Arg formatted specifically for Python. Args: key (string): The CLI Args key (e.g., --name). value (string): The CLI Args value (e.g., bob). mask (boolean, default:False): Indicates whether no mask val...
[ "def", "_add_arg_python", "(", "self", ",", "key", ",", "value", "=", "None", ",", "mask", "=", "False", ")", ":", "self", ".", "_data", "[", "key", "]", "=", "value", "if", "not", "value", ":", "# both false boolean values (flags) and empty values should not ...
Add CLI Arg formatted specifically for Python. Args: key (string): The CLI Args key (e.g., --name). value (string): The CLI Args value (e.g., bob). mask (boolean, default:False): Indicates whether no mask value.
[ "Add", "CLI", "Arg", "formatted", "specifically", "for", "Python", "." ]
python
train
43.259259
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py#L1036-L1051
def _create_page_control(self): """ Creates and connects the underlying paging widget. """ if self.custom_page_control: control = self.custom_page_control() elif self.kind == 'plain': control = QtGui.QPlainTextEdit() elif self.kind == 'rich': c...
[ "def", "_create_page_control", "(", "self", ")", ":", "if", "self", ".", "custom_page_control", ":", "control", "=", "self", ".", "custom_page_control", "(", ")", "elif", "self", ".", "kind", "==", "'plain'", ":", "control", "=", "QtGui", ".", "QPlainTextEdi...
Creates and connects the underlying paging widget.
[ "Creates", "and", "connects", "the", "underlying", "paging", "widget", "." ]
python
test
38.9375
bohea/sanic-limiter
sanic_limiter/extension.py
https://github.com/bohea/sanic-limiter/blob/54c9fc4a3a3f1a9bb69367262637d07701ae5694/sanic_limiter/extension.py#L297-L316
def limit(self, limit_value, key_func=None, per_method=False, methods=None, error_message=None, exempt_when=None): """ decorator to be used for rate limiting individual routes. :param limit_value: rate limit string or a callable that returns a string. :ref:`ratelimit-stri...
[ "def", "limit", "(", "self", ",", "limit_value", ",", "key_func", "=", "None", ",", "per_method", "=", "False", ",", "methods", "=", "None", ",", "error_message", "=", "None", ",", "exempt_when", "=", "None", ")", ":", "return", "self", ".", "__limit_dec...
decorator to be used for rate limiting individual routes. :param limit_value: rate limit string or a callable that returns a string. :ref:`ratelimit-string` for more details. :param function key_func: function/lambda to extract the unique identifier for the rate limit. defaults to rem...
[ "decorator", "to", "be", "used", "for", "rate", "limiting", "individual", "routes", "." ]
python
train
55.05
crdoconnor/strictyaml
strictyaml/utils.py
https://github.com/crdoconnor/strictyaml/blob/efdac7f89e81679fc95686288cd32b9563fde609/strictyaml/utils.py#L105-L145
def ruamel_structure(data, validator=None): """ Take dicts and lists and return a ruamel.yaml style structure of CommentedMaps, CommentedSeqs and data. If a validator is presented and the type is unknown, it is checked against the validator to see if it will turn it back in to YAML. """...
[ "def", "ruamel_structure", "(", "data", ",", "validator", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "if", "len", "(", "data", ")", "==", "0", ":", "raise", "exceptions", ".", "CannotBuildDocumentsFromEmptyDictOrList", "...
Take dicts and lists and return a ruamel.yaml style structure of CommentedMaps, CommentedSeqs and data. If a validator is presented and the type is unknown, it is checked against the validator to see if it will turn it back in to YAML.
[ "Take", "dicts", "and", "lists", "and", "return", "a", "ruamel", ".", "yaml", "style", "structure", "of", "CommentedMaps", "CommentedSeqs", "and", "data", "." ]
python
train
37.097561
DLR-RM/RAFCON
source/rafcon/gui/controllers/graphical_editor_gaphas.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/graphical_editor_gaphas.py#L231-L237
def _copy_selection(self, *event): """Copies the current selection to the clipboard. """ if react_to_event(self.view, self.view.editor, event): logger.debug("copy selection") global_clipboard.copy(self.model.selection) return True
[ "def", "_copy_selection", "(", "self", ",", "*", "event", ")", ":", "if", "react_to_event", "(", "self", ".", "view", ",", "self", ".", "view", ".", "editor", ",", "event", ")", ":", "logger", ".", "debug", "(", "\"copy selection\"", ")", "global_clipboa...
Copies the current selection to the clipboard.
[ "Copies", "the", "current", "selection", "to", "the", "clipboard", "." ]
python
train
40.571429
tanghaibao/jcvi
jcvi/formats/genbank.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/genbank.py#L429-L478
def getquals(args): """ %prog getquals [--options] gbkfile > qualsfile Read GenBank file and extract all qualifiers per feature type into a tab-delimited file """ p = OptionParser(getquals.__doc__) p.add_option("--types", default="gene,mRNA,CDS", type="str", dest="quals_ftyp...
[ "def", "getquals", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "getquals", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"--types\"", ",", "default", "=", "\"gene,mRNA,CDS\"", ",", "type", "=", "\"str\"", ",", "dest", "=", "\"quals_ftypes\"...
%prog getquals [--options] gbkfile > qualsfile Read GenBank file and extract all qualifiers per feature type into a tab-delimited file
[ "%prog", "getquals", "[", "--", "options", "]", "gbkfile", ">", "qualsfile" ]
python
train
38.04
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#L118-L136
def SetPlatformArchContext(): """Add the running contexts to the config system.""" # Initialize the running platform context: _CONFIG.AddContext("Platform:%s" % platform.system().title()) machine = platform.uname()[4] if machine in ["x86_64", "AMD64", "i686"]: # 32 bit binaries running on AMD64 will sti...
[ "def", "SetPlatformArchContext", "(", ")", ":", "# Initialize the running platform context:", "_CONFIG", ".", "AddContext", "(", "\"Platform:%s\"", "%", "platform", ".", "system", "(", ")", ".", "title", "(", ")", ")", "machine", "=", "platform", ".", "uname", "...
Add the running contexts to the config system.
[ "Add", "the", "running", "contexts", "to", "the", "config", "system", "." ]
python
train
27.842105
titusjan/argos
argos/qt/treeitems.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/qt/treeitems.py#L273-L281
def logBranch(self, indent=0, level=logging.DEBUG): """ Logs the item and all descendants, one line per child """ if 0: print(indent * " " + str(self)) else: logger.log(level, indent * " " + str(self)) for childItems in self.childItems: c...
[ "def", "logBranch", "(", "self", ",", "indent", "=", "0", ",", "level", "=", "logging", ".", "DEBUG", ")", ":", "if", "0", ":", "print", "(", "indent", "*", "\" \"", "+", "str", "(", "self", ")", ")", "else", ":", "logger", ".", "log", "(", ...
Logs the item and all descendants, one line per child
[ "Logs", "the", "item", "and", "all", "descendants", "one", "line", "per", "child" ]
python
train
39.555556
KarchinLab/probabilistic2020
prob2020/python/utils.py
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L174-L191
def rev_comp(seq): """Get reverse complement of sequence. rev_comp will maintain the case of the sequence. Parameters ---------- seq : str nucleotide sequence. valid {a, c, t, g, n} Returns ------- rev_comp_seq : str reverse complement of sequence """ rev_seq =...
[ "def", "rev_comp", "(", "seq", ")", ":", "rev_seq", "=", "seq", "[", ":", ":", "-", "1", "]", "rev_comp_seq", "=", "''", ".", "join", "(", "[", "base_pairing", "[", "s", "]", "for", "s", "in", "rev_seq", "]", ")", "return", "rev_comp_seq" ]
Get reverse complement of sequence. rev_comp will maintain the case of the sequence. Parameters ---------- seq : str nucleotide sequence. valid {a, c, t, g, n} Returns ------- rev_comp_seq : str reverse complement of sequence
[ "Get", "reverse", "complement", "of", "sequence", "." ]
python
train
22.222222
pypa/setuptools
setuptools/package_index.py
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/package_index.py#L1108-L1136
def local_open(url): """Read a local path, with special support for directories""" scheme, server, path, param, query, frag = urllib.parse.urlparse(url) filename = urllib.request.url2pathname(path) if os.path.isfile(filename): return urllib.request.urlopen(url) elif path.endswith('/') and os...
[ "def", "local_open", "(", "url", ")", ":", "scheme", ",", "server", ",", "path", ",", "param", ",", "query", ",", "frag", "=", "urllib", ".", "parse", ".", "urlparse", "(", "url", ")", "filename", "=", "urllib", ".", "request", ".", "url2pathname", "...
Read a local path, with special support for directories
[ "Read", "a", "local", "path", "with", "special", "support", "for", "directories" ]
python
train
40.586207
portantier/habu
habu/cli/cmd_tcpscan.py
https://github.com/portantier/habu/blob/87091e389dc6332fe1b82830c22b2eefc55816f2/habu/cli/cmd_tcpscan.py#L23-L85
def cmd_tcpscan(ip, port, iface, flags, sleeptime, timeout, show_all, verbose): """TCP Port Scanner. Print the ports that generated a response with the SYN flag or (if show use -a) all the ports that generated a response. It's really basic compared with nmap, but who is comparing? Example: \...
[ "def", "cmd_tcpscan", "(", "ip", ",", "port", ",", "iface", ",", "flags", ",", "sleeptime", ",", "timeout", ",", "show_all", ",", "verbose", ")", ":", "if", "verbose", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ",", ...
TCP Port Scanner. Print the ports that generated a response with the SYN flag or (if show use -a) all the ports that generated a response. It's really basic compared with nmap, but who is comparing? Example: \b # habu.tcpscan -p 22,23,80,443 -s 1 45.77.113.133 22 S -> SA 80 S -> SA ...
[ "TCP", "Port", "Scanner", "." ]
python
train
24.47619
hendrix/hendrix
hendrix/options.py
https://github.com/hendrix/hendrix/blob/175af011a7e5822b772bfec0e11a46466bb8688d/hendrix/options.py#L195-L201
def options(argv=[]): """ A helper function that returns a dictionary of the default key-values pairs """ parser = HendrixOptionParser parsed_args = parser.parse_args(argv) return vars(parsed_args[0])
[ "def", "options", "(", "argv", "=", "[", "]", ")", ":", "parser", "=", "HendrixOptionParser", "parsed_args", "=", "parser", ".", "parse_args", "(", "argv", ")", "return", "vars", "(", "parsed_args", "[", "0", "]", ")" ]
A helper function that returns a dictionary of the default key-values pairs
[ "A", "helper", "function", "that", "returns", "a", "dictionary", "of", "the", "default", "key", "-", "values", "pairs" ]
python
train
31.142857
AnthonyBloomer/daftlistings
daftlistings/listing.py
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L627-L649
def ber_code(self): """ This method gets ber code listed in Daft. :return: """ try: alt_text = self._ad_page_content.find( 'span', {'class': 'ber-hover'} ).find('img')['alt'] if ('exempt' in alt_text): return 'e...
[ "def", "ber_code", "(", "self", ")", ":", "try", ":", "alt_text", "=", "self", ".", "_ad_page_content", ".", "find", "(", "'span'", ",", "{", "'class'", ":", "'ber-hover'", "}", ")", ".", "find", "(", "'img'", ")", "[", "'alt'", "]", "if", "(", "'e...
This method gets ber code listed in Daft. :return:
[ "This", "method", "gets", "ber", "code", "listed", "in", "Daft", ".", ":", "return", ":" ]
python
train
30.695652
liminspace/dju-image
dju_image/tools.py
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L156-L171
def is_img_id_valid(img_id): """ Checks if img_id is valid. """ t = re.sub(r'[^a-z0-9_:\-\.]', '', img_id, re.IGNORECASE) t = re.sub(r'\.+', '.', t) if img_id != t or img_id.count(':') != 1: return False profile, base_name = img_id.split(':', 1) if not profile or not base_name: ...
[ "def", "is_img_id_valid", "(", "img_id", ")", ":", "t", "=", "re", ".", "sub", "(", "r'[^a-z0-9_:\\-\\.]'", ",", "''", ",", "img_id", ",", "re", ".", "IGNORECASE", ")", "t", "=", "re", ".", "sub", "(", "r'\\.+'", ",", "'.'", ",", "t", ")", "if", ...
Checks if img_id is valid.
[ "Checks", "if", "img_id", "is", "valid", "." ]
python
train
26.875
thunder-project/thunder
thunder/series/series.py
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L459-L475
def mean_by_panel(self, length): """ Compute the mean across fixed sized panels of each record. Splits each record into panels of size `length`, and then computes the mean across panels. Panel length must subdivide record exactly. Parameters ---------- l...
[ "def", "mean_by_panel", "(", "self", ",", "length", ")", ":", "self", ".", "_check_panel", "(", "length", ")", "func", "=", "lambda", "v", ":", "v", ".", "reshape", "(", "-", "1", ",", "length", ")", ".", "mean", "(", "axis", "=", "0", ")", "newi...
Compute the mean across fixed sized panels of each record. Splits each record into panels of size `length`, and then computes the mean across panels. Panel length must subdivide record exactly. Parameters ---------- length : int Fixed length with which to su...
[ "Compute", "the", "mean", "across", "fixed", "sized", "panels", "of", "each", "record", "." ]
python
train
32.411765
dancsalo/TensorBase
tensorbase/base.py
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L373-L380
def check_str(obj): """ Returns a string for various input types """ if isinstance(obj, str): return obj if isinstance(obj, float): return str(int(obj)) else: return str(obj)
[ "def", "check_str", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "str", ")", ":", "return", "obj", "if", "isinstance", "(", "obj", ",", "float", ")", ":", "return", "str", "(", "int", "(", "obj", ")", ")", "else", ":", "return", "st...
Returns a string for various input types
[ "Returns", "a", "string", "for", "various", "input", "types" ]
python
train
29.375
uber-common/opentracing-python-instrumentation
opentracing_instrumentation/http_server.py
https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/http_server.py#L174-L191
def _parse_wsgi_headers(wsgi_environ): """ HTTP headers are presented in WSGI environment with 'HTTP_' prefix. This method finds those headers, removes the prefix, converts underscores to dashes, and converts to lower case. :param wsgi_environ: :return: returns a diction...
[ "def", "_parse_wsgi_headers", "(", "wsgi_environ", ")", ":", "prefix", "=", "'HTTP_'", "p_len", "=", "len", "(", "prefix", ")", "# use .items() despite suspected memory pressure bc GC occasionally", "# collects wsgi_environ.iteritems() during iteration.", "headers", "=", "{", ...
HTTP headers are presented in WSGI environment with 'HTTP_' prefix. This method finds those headers, removes the prefix, converts underscores to dashes, and converts to lower case. :param wsgi_environ: :return: returns a dictionary of headers
[ "HTTP", "headers", "are", "presented", "in", "WSGI", "environment", "with", "HTTP_", "prefix", ".", "This", "method", "finds", "those", "headers", "removes", "the", "prefix", "converts", "underscores", "to", "dashes", "and", "converts", "to", "lower", "case", ...
python
train
39.555556
python-rope/rope
rope/base/pycore.py
https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/base/pycore.py#L336-L341
def consume_changes(self, start, end): """Clear the changed status of lines from start till end""" left, right = self._get_changed(start, end) if left < right: del self.lines[left:right] return left < right
[ "def", "consume_changes", "(", "self", ",", "start", ",", "end", ")", ":", "left", ",", "right", "=", "self", ".", "_get_changed", "(", "start", ",", "end", ")", "if", "left", "<", "right", ":", "del", "self", ".", "lines", "[", "left", ":", "right...
Clear the changed status of lines from start till end
[ "Clear", "the", "changed", "status", "of", "lines", "from", "start", "till", "end" ]
python
train
40.833333
johnnoone/aioconsul
aioconsul/client/checks_endpoint.py
https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/checks_endpoint.py#L125-L137
async def deregister(self, check): """Deregisters a local check Parameters: check (ObjectID): Check ID Returns: bool: ``True`` on success The agent will take care of deregistering the check from the Catalog. """ check_id = extract_attr(check, key...
[ "async", "def", "deregister", "(", "self", ",", "check", ")", ":", "check_id", "=", "extract_attr", "(", "check", ",", "keys", "=", "[", "\"CheckID\"", ",", "\"ID\"", "]", ")", "response", "=", "await", "self", ".", "_api", ".", "get", "(", "\"/v1/agen...
Deregisters a local check Parameters: check (ObjectID): Check ID Returns: bool: ``True`` on success The agent will take care of deregistering the check from the Catalog.
[ "Deregisters", "a", "local", "check" ]
python
train
34.230769
bitshares/uptick
uptick/cli.py
https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/cli.py#L40-L45
def set(ctx, key, value): """ Set configuration parameters """ if key == "default_account" and value[0] == "@": value = value[1:] ctx.bitshares.config[key] = value
[ "def", "set", "(", "ctx", ",", "key", ",", "value", ")", ":", "if", "key", "==", "\"default_account\"", "and", "value", "[", "0", "]", "==", "\"@\"", ":", "value", "=", "value", "[", "1", ":", "]", "ctx", ".", "bitshares", ".", "config", "[", "ke...
Set configuration parameters
[ "Set", "configuration", "parameters" ]
python
train
30.333333
AnthonyBloomer/daftlistings
daftlistings/listing.py
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L104-L118
def price_change(self): """ This method returns any price change. :return: """ try: if self._data_from_search: return self._data_from_search.find('div', {'class': 'price-changes-sr'}).text else: return self._ad_page_content....
[ "def", "price_change", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_data_from_search", ":", "return", "self", ".", "_data_from_search", ".", "find", "(", "'div'", ",", "{", "'class'", ":", "'price-changes-sr'", "}", ")", ".", "text", "else", "...
This method returns any price change. :return:
[ "This", "method", "returns", "any", "price", "change", ".", ":", "return", ":" ]
python
train
36.066667
Esri/ArcREST
src/arcrest/ags/_gpobjects.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_gpobjects.py#L607-L619
def fromJSON(value): """loads the GP object from a JSON string """ j = json.loads(value) v = GPString() if "defaultValue" in j: v.value = j['defaultValue'] else: v.value = j['value'] if 'paramName' in j: v.paramName = j['paramName'] ...
[ "def", "fromJSON", "(", "value", ")", ":", "j", "=", "json", ".", "loads", "(", "value", ")", "v", "=", "GPString", "(", ")", "if", "\"defaultValue\"", "in", "j", ":", "v", ".", "value", "=", "j", "[", "'defaultValue'", "]", "else", ":", "v", "."...
loads the GP object from a JSON string
[ "loads", "the", "GP", "object", "from", "a", "JSON", "string" ]
python
train
29.461538
atl/py-smartdc
smartdc/datacenter.py
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L999-L1017
def delete_image(self, identifier): """ :: DELETE /:login/images/:id :param identifier: match on the listed image identifier :type identifier: :py:class:`basestring` or :py:class:`dict` A string or a dictionary containing an ``id`` key may b...
[ "def", "delete_image", "(", "self", ",", "identifier", ")", ":", "if", "isinstance", "(", "identifier", ",", "dict", ")", ":", "identifier", "=", "identifier", ".", "get", "(", "'id'", ",", "''", ")", "j", ",", "r", "=", "self", ".", "request", "(", ...
:: DELETE /:login/images/:id :param identifier: match on the listed image identifier :type identifier: :py:class:`basestring` or :py:class:`dict` A string or a dictionary containing an ``id`` key may be passed in. Will raise an error if the response...
[ "::", "DELETE", "/", ":", "login", "/", "images", "/", ":", "id", ":", "param", "identifier", ":", "match", "on", "the", "listed", "image", "identifier", ":", "type", "identifier", ":", ":", "py", ":", "class", ":", "basestring", "or", ":", "py", ":"...
python
train
31.947368
hozn/keepassdb
keepassdb/db.py
https://github.com/hozn/keepassdb/blob/cb24985d1ed04e7d7db99ecdddf80dd1a91ee48b/keepassdb/db.py#L487-L500
def remove_entry(self, entry): """ Remove specified entry. :param entry: The Entry object to remove. :type entry: :class:`keepassdb.model.Entry` """ if not isinstance(entry, Entry): raise TypeError("entry param must be of type Entry.") if not ...
[ "def", "remove_entry", "(", "self", ",", "entry", ")", ":", "if", "not", "isinstance", "(", "entry", ",", "Entry", ")", ":", "raise", "TypeError", "(", "\"entry param must be of type Entry.\"", ")", "if", "not", "entry", "in", "self", ".", "entries", ":", ...
Remove specified entry. :param entry: The Entry object to remove. :type entry: :class:`keepassdb.model.Entry`
[ "Remove", "specified", "entry", ".", ":", "param", "entry", ":", "The", "Entry", "object", "to", "remove", ".", ":", "type", "entry", ":", ":", "class", ":", "keepassdb", ".", "model", ".", "Entry" ]
python
train
35.428571
radjkarl/fancyWidgets
fancywidgets/pyQtBased/Console.py
https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/Console.py#L62-L68
def addText(self, text): """append text in the chosen color""" # move to the end of the doc self.moveCursor(QtGui.QTextCursor.End) # insert the text self.setTextColor(self._currentColor) self.textCursor().insertText(text)
[ "def", "addText", "(", "self", ",", "text", ")", ":", "# move to the end of the doc", "self", ".", "moveCursor", "(", "QtGui", ".", "QTextCursor", ".", "End", ")", "# insert the text", "self", ".", "setTextColor", "(", "self", ".", "_currentColor", ")", "self"...
append text in the chosen color
[ "append", "text", "in", "the", "chosen", "color" ]
python
train
37.571429
boakley/robotframework-lint
rflint/parser/parser.py
https://github.com/boakley/robotframework-lint/blob/3e3578f4e39af9af9961aa0a715f146b74474091/rflint/parser/parser.py#L92-L105
def robot_files(self): '''Return a list of all folders, and test suite files (.txt, .robot) ''' result = [] for name in os.listdir(self.path): fullpath = os.path.join(self.path, name) if os.path.isdir(fullpath): result.append(RobotFactory(fullpath,...
[ "def", "robot_files", "(", "self", ")", ":", "result", "=", "[", "]", "for", "name", "in", "os", ".", "listdir", "(", "self", ".", "path", ")", ":", "fullpath", "=", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "name", ")", "i...
Return a list of all folders, and test suite files (.txt, .robot)
[ "Return", "a", "list", "of", "all", "folders", "and", "test", "suite", "files", "(", ".", "txt", ".", "robot", ")" ]
python
valid
41.357143
fedora-infra/fmn.lib
fmn/lib/__init__.py
https://github.com/fedora-infra/fmn.lib/blob/3120725556153d07c1809530f0fadcf250439110/fmn/lib/__init__.py#L97-L127
def load_preferences(session, config, valid_paths, cull_disabled=False, openid=None, cull_backends=None): """ Every rule for every filter for every context for every user. Any preferences in the DB that are for contexts that are disabled in the config are omitted h...
[ "def", "load_preferences", "(", "session", ",", "config", ",", "valid_paths", ",", "cull_disabled", "=", "False", ",", "openid", "=", "None", ",", "cull_backends", "=", "None", ")", ":", "cull_backends", "=", "cull_backends", "or", "[", "]", "query", "=", ...
Every rule for every filter for every context for every user. Any preferences in the DB that are for contexts that are disabled in the config are omitted here. If the `openid` argument is None, then this is an expensive query that loads, practically, the whole database. However, if an openid string i...
[ "Every", "rule", "for", "every", "filter", "for", "every", "context", "for", "every", "user", "." ]
python
train
34.516129
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L4373-L4388
def GetRowHeaders(self) -> list: """ Call IUIAutomationTablePattern::GetCurrentRowHeaders. Return list, a list of `Control` subclasses, representing all the row headers in a table. Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiauto...
[ "def", "GetRowHeaders", "(", "self", ")", "->", "list", ":", "eleArray", "=", "self", ".", "pattern", ".", "GetCurrentRowHeaders", "(", ")", "if", "eleArray", ":", "controls", "=", "[", "]", "for", "i", "in", "range", "(", "eleArray", ".", "Length", ")...
Call IUIAutomationTablePattern::GetCurrentRowHeaders. Return list, a list of `Control` subclasses, representing all the row headers in a table. Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtablepattern-getcurrentrowheaders
[ "Call", "IUIAutomationTablePattern", "::", "GetCurrentRowHeaders", ".", "Return", "list", "a", "list", "of", "Control", "subclasses", "representing", "all", "the", "row", "headers", "in", "a", "table", ".", "Refer", "https", ":", "//", "docs", ".", "microsoft", ...
python
valid
45.4375
twilio/twilio-python
twilio/rest/api/v2010/account/usage/record/monthly.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/usage/record/monthly.py#L185-L194
def get_instance(self, payload): """ Build an instance of MonthlyInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance ...
[ "def", "get_instance", "(", "self", ",", "payload", ")", ":", "return", "MonthlyInstance", "(", "self", ".", "_version", ",", "payload", ",", "account_sid", "=", "self", ".", "_solution", "[", "'account_sid'", "]", ",", ")" ]
Build an instance of MonthlyInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance
[ "Build", "an", "instance", "of", "MonthlyInstance" ]
python
train
42.1
kubernetes-client/python
kubernetes/client/apis/extensions_v1beta1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/extensions_v1beta1_api.py#L1483-L1509
def delete_collection_pod_security_policy(self, **kwargs): """ delete collection of PodSecurityPolicy This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_collection_pod_security_policy(a...
[ "def", "delete_collection_pod_security_policy", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "delete_collection_pod_s...
delete collection of PodSecurityPolicy This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_collection_pod_security_policy(async_req=True) >>> result = thread.get() :param async_req bool...
[ "delete", "collection", "of", "PodSecurityPolicy", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=", "True", ">>>", "thread", "=", ...
python
train
168.925926
hazelcast/hazelcast-python-client
hazelcast/proxy/multi_map.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/multi_map.py#L81-L94
def contains_entry(self, key, value): """ Returns whether the multimap contains an entry with the value. :param key: (object), the specified key. :param value: (object), the specified value. :return: (bool), ``true`` if this multimap contains the key-value tuple. """ ...
[ "def", "contains_entry", "(", "self", ",", "key", ",", "value", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "value", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key"...
Returns whether the multimap contains an entry with the value. :param key: (object), the specified key. :param value: (object), the specified value. :return: (bool), ``true`` if this multimap contains the key-value tuple.
[ "Returns", "whether", "the", "multimap", "contains", "an", "entry", "with", "the", "value", "." ]
python
train
47.571429
DataONEorg/d1_python
gmn/src/d1_gmn/app/views/util.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/util.py#L179-L196
def parse_and_normalize_url_date(date_str): """Parse a ISO 8601 date-time with optional timezone. - Return as datetime with timezone adjusted to UTC. - Return naive date-time set to UTC. """ if date_str is None: return None try: return d1_common.date_time.dt_from_iso8601_str(da...
[ "def", "parse_and_normalize_url_date", "(", "date_str", ")", ":", "if", "date_str", "is", "None", ":", "return", "None", "try", ":", "return", "d1_common", ".", "date_time", ".", "dt_from_iso8601_str", "(", "date_str", ")", "except", "d1_common", ".", "date_time...
Parse a ISO 8601 date-time with optional timezone. - Return as datetime with timezone adjusted to UTC. - Return naive date-time set to UTC.
[ "Parse", "a", "ISO", "8601", "date", "-", "time", "with", "optional", "timezone", "." ]
python
train
32.111111
projecthamster/hamster
src/hamster/lib/graphics.py
https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/graphics.py#L465-L479
def create_layout(self, size = None): """utility function to create layout with the default font. Size and alignment parameters are shortcuts to according functions of the pango.Layout""" if not self.context: # TODO - this is rather sloppy as far as exception goes ...
[ "def", "create_layout", "(", "self", ",", "size", "=", "None", ")", ":", "if", "not", "self", ".", "context", ":", "# TODO - this is rather sloppy as far as exception goes", "# should explain better", "raise", "Exception", "(", "\"Can not create layout without existi...
utility function to create layout with the default font. Size and alignment parameters are shortcuts to according functions of the pango.Layout
[ "utility", "function", "to", "create", "layout", "with", "the", "default", "font", ".", "Size", "and", "alignment", "parameters", "are", "shortcuts", "to", "according", "functions", "of", "the", "pango", ".", "Layout" ]
python
train
44.133333
obriencj/python-javatools
javatools/classdiff.py
https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/classdiff.py#L917-L940
def merge_code(left_code, right_code): """ { relative_line: ((left_abs_line, ((offset, op, args), ...)), (right_abs_line, ((offset, op, args), ...))), ... } """ data = dict() code_lines = (left_code and left_code.iter_code_by_lines()) or tuple() for abs_line, rel_line, dis i...
[ "def", "merge_code", "(", "left_code", ",", "right_code", ")", ":", "data", "=", "dict", "(", ")", "code_lines", "=", "(", "left_code", "and", "left_code", ".", "iter_code_by_lines", "(", ")", ")", "or", "tuple", "(", ")", "for", "abs_line", ",", "rel_li...
{ relative_line: ((left_abs_line, ((offset, op, args), ...)), (right_abs_line, ((offset, op, args), ...))), ... }
[ "{", "relative_line", ":", "((", "left_abs_line", "((", "offset", "op", "args", ")", "...", "))", "(", "right_abs_line", "((", "offset", "op", "args", ")", "...", ")))", "...", "}" ]
python
train
29.166667
mikedh/trimesh
trimesh/rendering.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/rendering.py#L334-L368
def light_to_gl(light, transform, lightN): """ Convert trimesh.scene.lighting.Light objects into args for gl.glLightFv calls Parameters -------------- light : trimesh.scene.lighting.Light Light object to be converted to GL transform : (4, 4) float Transformation matrix of light ...
[ "def", "light_to_gl", "(", "light", ",", "transform", ",", "lightN", ")", ":", "# convert color to opengl", "gl_color", "=", "vector_to_gl", "(", "light", ".", "color", ".", "astype", "(", "np", ".", "float64", ")", "/", "255.0", ")", "assert", "len", "(",...
Convert trimesh.scene.lighting.Light objects into args for gl.glLightFv calls Parameters -------------- light : trimesh.scene.lighting.Light Light object to be converted to GL transform : (4, 4) float Transformation matrix of light lightN : int Result of gl.GL_LIGHT0, gl.GL_LI...
[ "Convert", "trimesh", ".", "scene", ".", "lighting", ".", "Light", "objects", "into", "args", "for", "gl", ".", "glLightFv", "calls" ]
python
train
28.257143
Cog-Creators/Red-Lavalink
lavalink/player_manager.py
https://github.com/Cog-Creators/Red-Lavalink/blob/5b3fc6eb31ee5db8bd2b633a523cf69749957111/lavalink/player_manager.py#L285-L295
async def pause(self, pause: bool = True): """ Pauses the current song. Parameters ---------- pause : bool Set to ``False`` to resume. """ self._paused = pause await self.node.pause(self.channel.guild.id, pause)
[ "async", "def", "pause", "(", "self", ",", "pause", ":", "bool", "=", "True", ")", ":", "self", ".", "_paused", "=", "pause", "await", "self", ".", "node", ".", "pause", "(", "self", ".", "channel", ".", "guild", ".", "id", ",", "pause", ")" ]
Pauses the current song. Parameters ---------- pause : bool Set to ``False`` to resume.
[ "Pauses", "the", "current", "song", "." ]
python
train
25.272727
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/cameras/arcball.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/arcball.py#L65-L69
def _rotate_tr(self): """Rotate the transformation matrix based on camera parameters""" rot, x, y, z = self._quaternion.get_axis_angle() up, forward, right = self._get_dim_vectors() self.transform.rotate(180 * rot / np.pi, (x, z, y))
[ "def", "_rotate_tr", "(", "self", ")", ":", "rot", ",", "x", ",", "y", ",", "z", "=", "self", ".", "_quaternion", ".", "get_axis_angle", "(", ")", "up", ",", "forward", ",", "right", "=", "self", ".", "_get_dim_vectors", "(", ")", "self", ".", "tra...
Rotate the transformation matrix based on camera parameters
[ "Rotate", "the", "transformation", "matrix", "based", "on", "camera", "parameters" ]
python
train
52.2
raymontag/kppy
kppy/database.py
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L846-L859
def _cbc_decrypt(self, final_key, crypted_content): """This method decrypts the database""" # Just decrypt the content with the created key aes = AES.new(final_key, AES.MODE_CBC, self._enc_iv) decrypted_content = aes.decrypt(crypted_content) padding = decrypted_content[-1] ...
[ "def", "_cbc_decrypt", "(", "self", ",", "final_key", ",", "crypted_content", ")", ":", "# Just decrypt the content with the created key", "aes", "=", "AES", ".", "new", "(", "final_key", ",", "AES", ".", "MODE_CBC", ",", "self", ".", "_enc_iv", ")", "decrypted_...
This method decrypts the database
[ "This", "method", "decrypts", "the", "database" ]
python
train
39.928571
letuananh/chirptext
chirptext/texttaglib.py
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L603-L614
def add_sent(self, sent_obj): ''' Add a ttl.Sentence object to this document ''' if sent_obj is None: raise Exception("Sentence object cannot be None") elif sent_obj.ID is None: # if sentID is None, create a new ID sent_obj.ID = next(self.__idgen) elif...
[ "def", "add_sent", "(", "self", ",", "sent_obj", ")", ":", "if", "sent_obj", "is", "None", ":", "raise", "Exception", "(", "\"Sentence object cannot be None\"", ")", "elif", "sent_obj", ".", "ID", "is", "None", ":", "# if sentID is None, create a new ID", "sent_ob...
Add a ttl.Sentence object to this document
[ "Add", "a", "ttl", ".", "Sentence", "object", "to", "this", "document" ]
python
train
43.166667
klen/muffin-session
muffin_session.py
https://github.com/klen/muffin-session/blob/f1d14d12b7d09d8cc40be14b0dfa0b1e2f4ae8e9/muffin_session.py#L156-L166
def save(self, set_cookie, **params): """Update cookies if the session has been changed.""" if set(self.store.items()) ^ set(self.items()): value = dict(self.items()) value = json.dumps(value) value = self.encrypt(value) if not isinstance(value, str): ...
[ "def", "save", "(", "self", ",", "set_cookie", ",", "*", "*", "params", ")", ":", "if", "set", "(", "self", ".", "store", ".", "items", "(", ")", ")", "^", "set", "(", "self", ".", "items", "(", ")", ")", ":", "value", "=", "dict", "(", "self...
Update cookies if the session has been changed.
[ "Update", "cookies", "if", "the", "session", "has", "been", "changed", "." ]
python
train
41.545455
iotile/coretools
iotilecore/iotile/core/hw/transport/server/standard.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/server/standard.py#L198-L225
async def teardown_client(self, client_id): """Release all resources held by a client. This method must be called and awaited whenever a client is disconnected. It ensures that all of the client's resources are properly released and any devices they have connected to are discon...
[ "async", "def", "teardown_client", "(", "self", ",", "client_id", ")", ":", "client_info", "=", "self", ".", "_client_info", "(", "client_id", ")", "self", ".", "adapter", ".", "remove_monitor", "(", "client_info", "[", "'monitor'", "]", ")", "conns", "=", ...
Release all resources held by a client. This method must be called and awaited whenever a client is disconnected. It ensures that all of the client's resources are properly released and any devices they have connected to are disconnected cleanly. Args: client_id (s...
[ "Release", "all", "resources", "held", "by", "a", "client", "." ]
python
train
40.571429
clalancette/pycdlib
pycdlib/udf.py
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3042-L3080
def set_data_length(self, length): # type: (int) -> None ''' A method to set the length of the data that this UDF File Entry points to. Parameters: length - The new length for the data. Returns: Nothing. ''' if not self._initialized: ...
[ "def", "set_data_length", "(", "self", ",", "length", ")", ":", "# type: (int) -> None", "if", "not", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'Directory Record not yet initialized'", ")", "len_diff", "=", "leng...
A method to set the length of the data that this UDF File Entry points to. Parameters: length - The new length for the data. Returns: Nothing.
[ "A", "method", "to", "set", "the", "length", "of", "the", "data", "that", "this", "UDF", "File", "Entry", "points", "to", "." ]
python
train
39.641026
FutunnOpen/futuquant
futuquant/examples/TinyQuant/TinyQuantBase.py
https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/examples/TinyQuant/TinyQuantBase.py#L154-L159
def rsi(self, n, array=False): """RSI指标""" result = talib.RSI(self.close, n) if array: return result return result[-1]
[ "def", "rsi", "(", "self", ",", "n", ",", "array", "=", "False", ")", ":", "result", "=", "talib", ".", "RSI", "(", "self", ".", "close", ",", "n", ")", "if", "array", ":", "return", "result", "return", "result", "[", "-", "1", "]" ]
RSI指标
[ "RSI指标" ]
python
train
26.166667
alexhayes/django-toolkit
django_toolkit/network.py
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/network.py#L10-L39
def cidr_notation(ip_address, netmask): """ Retrieve the cidr notation given an ip address and netmask. For example: cidr_notation('12.34.56.78', '255.255.255.248') Would return: 12.34.56.72/29 @see http://terminalmage.net/2012/06/10/how-to-find-out-the-cidr-notation-for...
[ "def", "cidr_notation", "(", "ip_address", ",", "netmask", ")", ":", "try", ":", "inet_aton", "(", "ip_address", ")", "except", ":", "raise", "Exception", "(", "\"Invalid ip address '%s'\"", "%", "ip_address", ")", "try", ":", "inet_aton", "(", "netmask", ")",...
Retrieve the cidr notation given an ip address and netmask. For example: cidr_notation('12.34.56.78', '255.255.255.248') Would return: 12.34.56.72/29 @see http://terminalmage.net/2012/06/10/how-to-find-out-the-cidr-notation-for-a-subne-given-an-ip-and-netmask/ @see http://ww...
[ "Retrieve", "the", "cidr", "notation", "given", "an", "ip", "address", "and", "netmask", ".", "For", "example", ":", "cidr_notation", "(", "12", ".", "34", ".", "56", ".", "78", "255", ".", "255", ".", "255", ".", "248", ")", "Would", "return", ":", ...
python
train
30.333333
microhomie/microhomie
homie/device.py
https://github.com/microhomie/microhomie/blob/44de239e05a20026cf7425ee0fe1f10549288fbf/homie/device.py#L79-L95
def subscribe_topics(self): """subscribe to all registered device and node topics""" base = self.topic subscribe = self.mqtt.subscribe # device topics subscribe(b"/".join((base, b"$stats/interval/set"))) subscribe(b"/".join((self.settings.MQTT_BASE_TOPIC, b"$broadcast/#"...
[ "def", "subscribe_topics", "(", "self", ")", ":", "base", "=", "self", ".", "topic", "subscribe", "=", "self", ".", "mqtt", ".", "subscribe", "# device topics", "subscribe", "(", "b\"/\"", ".", "join", "(", "(", "base", ",", "b\"$stats/interval/set\"", ")", ...
subscribe to all registered device and node topics
[ "subscribe", "to", "all", "registered", "device", "and", "node", "topics" ]
python
train
36.882353
qubole/qds-sdk-py
qds_sdk/app.py
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/app.py#L143-L148
def stop(cls, app_id): """ Stops an app by issuing a PUT request to the /apps/ID/stop endpoint. """ conn = Qubole.agent() return conn.put(cls.element_path(app_id) + "/stop")
[ "def", "stop", "(", "cls", ",", "app_id", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "return", "conn", ".", "put", "(", "cls", ".", "element_path", "(", "app_id", ")", "+", "\"/stop\"", ")" ]
Stops an app by issuing a PUT request to the /apps/ID/stop endpoint.
[ "Stops", "an", "app", "by", "issuing", "a", "PUT", "request", "to", "the", "/", "apps", "/", "ID", "/", "stop", "endpoint", "." ]
python
train
34.666667
thebigmunch/google-music
src/google_music/clients/mobileclient.py
https://github.com/thebigmunch/google-music/blob/d8a94dab462a1f063fbc1152187a73dc2f0e2a85/src/google_music/clients/mobileclient.py#L798-L832
def playlist_create( self, name, description='', *, make_public=False, songs=None ): """Create a playlist. Parameters: name (str): Name to give the playlist. description (str): Description to give the playlist. make_public (bool, Optional): If ``True`` and account has a subscription, make...
[ "def", "playlist_create", "(", "self", ",", "name", ",", "description", "=", "''", ",", "*", ",", "make_public", "=", "False", ",", "songs", "=", "None", ")", ":", "share_state", "=", "'PUBLIC'", "if", "make_public", "else", "'PRIVATE'", "playlist", "=", ...
Create a playlist. Parameters: name (str): Name to give the playlist. description (str): Description to give the playlist. make_public (bool, Optional): If ``True`` and account has a subscription, make playlist public. Default: ``False`` songs (list, Optional): A list of song dicts to add to the ...
[ "Create", "a", "playlist", "." ]
python
train
19.828571
materialsvirtuallab/monty
monty/serialization.py
https://github.com/materialsvirtuallab/monty/blob/d99d6f3c68372d83489d28ff515566c93cd569e2/monty/serialization.py#L47-L83
def loadfn(fn, *args, **kwargs): """ Loads json/yaml/msgpack directly from a filename instead of a File-like object. For YAML, ruamel.yaml must be installed. The file type is automatically detected. YAML is assumed if the filename contains "yaml" (lower or upper case). Otherwise, json is always assu...
[ "def", "loadfn", "(", "fn", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "\"mpk\"", "in", "os", ".", "path", ".", "basename", "(", "fn", ")", ".", "lower", "(", ")", ":", "if", "msgpack", "is", "None", ":", "raise", "RuntimeError", ...
Loads json/yaml/msgpack directly from a filename instead of a File-like object. For YAML, ruamel.yaml must be installed. The file type is automatically detected. YAML is assumed if the filename contains "yaml" (lower or upper case). Otherwise, json is always assumed. Args: fn (str/Path): filena...
[ "Loads", "json", "/", "yaml", "/", "msgpack", "directly", "from", "a", "filename", "instead", "of", "a", "File", "-", "like", "object", ".", "For", "YAML", "ruamel", ".", "yaml", "must", "be", "installed", ".", "The", "file", "type", "is", "automatically...
python
train
41.594595
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/__init__.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/__init__.py#L160-L227
def Update(self, env, args=None): """ Update an environment with the option variables. env - the environment to update. """ values = {} # first set the defaults: for option in self.options: if not option.default is None: values[optio...
[ "def", "Update", "(", "self", ",", "env", ",", "args", "=", "None", ")", ":", "values", "=", "{", "}", "# first set the defaults:", "for", "option", "in", "self", ".", "options", ":", "if", "not", "option", ".", "default", "is", "None", ":", "values", ...
Update an environment with the option variables. env - the environment to update.
[ "Update", "an", "environment", "with", "the", "option", "variables", "." ]
python
train
34.794118
CalebBell/fluids
fluids/friction.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/friction.py#L1303-L1346
def Sonnad_Goudar_2006(Re, eD): r'''Calculates Darcy friction factor using the method in Sonnad and Goudar (2006) [2]_ as shown in [1]_. .. math:: \frac{1}{\sqrt{f_d}} = 0.8686\ln\left(\frac{0.4587Re}{S^{S/(S+1)}}\right) .. math:: S = 0.1240\times\frac{\epsilon}{D}\times Re + \ln(0.458...
[ "def", "Sonnad_Goudar_2006", "(", "Re", ",", "eD", ")", ":", "S", "=", "0.124", "*", "eD", "*", "Re", "+", "log", "(", "0.4587", "*", "Re", ")", "return", "(", ".8686", "*", "log", "(", ".4587", "*", "Re", "/", "S", "**", "(", "S", "/", "(", ...
r'''Calculates Darcy friction factor using the method in Sonnad and Goudar (2006) [2]_ as shown in [1]_. .. math:: \frac{1}{\sqrt{f_d}} = 0.8686\ln\left(\frac{0.4587Re}{S^{S/(S+1)}}\right) .. math:: S = 0.1240\times\frac{\epsilon}{D}\times Re + \ln(0.4587Re) Parameters ---------- ...
[ "r", "Calculates", "Darcy", "friction", "factor", "using", "the", "method", "in", "Sonnad", "and", "Goudar", "(", "2006", ")", "[", "2", "]", "_", "as", "shown", "in", "[", "1", "]", "_", "." ]
python
train
29
mikicz/arca
arca/backend/docker.py
https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/backend/docker.py#L412-L436
def build_image_from_inherited_image(self, image_name: str, image_tag: str, repo_path: Path, requirements_option: RequirementsOptions): """ Builds a image with installed requirements from the inherited image. (Or just tags...
[ "def", "build_image_from_inherited_image", "(", "self", ",", "image_name", ":", "str", ",", "image_tag", ":", "str", ",", "repo_path", ":", "Path", ",", "requirements_option", ":", "RequirementsOptions", ")", ":", "base_name", ",", "base_tag", "=", "self", ".", ...
Builds a image with installed requirements from the inherited image. (Or just tags the image if there are no requirements.) See :meth:`build_image` for parameters descriptions. :rtype: docker.models.images.Image
[ "Builds", "a", "image", "with", "installed", "requirements", "from", "the", "inherited", "image", ".", "(", "Or", "just", "tags", "the", "image", "if", "there", "are", "no", "requirements", ".", ")" ]
python
train
42.32
domainaware/parsedmarc
parsedmarc/elastic.py
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/elastic.py#L272-L384
def save_aggregate_report_to_elasticsearch(aggregate_report, index_suffix=None, monthly_indexes=False): """ Saves a parsed DMARC aggregate report to ElasticSearch Args: aggregate_report (OrderedDict): A parsed for...
[ "def", "save_aggregate_report_to_elasticsearch", "(", "aggregate_report", ",", "index_suffix", "=", "None", ",", "monthly_indexes", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Saving aggregate report to Elasticsearch\"", ")", "aggregate_report", "=", "aggregat...
Saves a parsed DMARC aggregate report to ElasticSearch Args: aggregate_report (OrderedDict): A parsed forensic report index_suffix (str): The suffix of the name of the index to save to monthly_indexes (bool): Use monthly indexes instead of daily indexes Raises: AlreadySaved
[ "Saves", "a", "parsed", "DMARC", "aggregate", "report", "to", "ElasticSearch" ]
python
test
45.283186
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_text.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_text.py#L552-L559
def dictlist_convert_to_bool(dict_list: Iterable[Dict], key: str) -> None: """ Process an iterable of dictionaries. For each dictionary ``d``, convert (in place) ``d[key]`` to a bool. If that fails, convert it to ``None``. """ for d in dict_list: # d[key] = True if d[key] == "Y" else False ...
[ "def", "dictlist_convert_to_bool", "(", "dict_list", ":", "Iterable", "[", "Dict", "]", ",", "key", ":", "str", ")", "->", "None", ":", "for", "d", "in", "dict_list", ":", "# d[key] = True if d[key] == \"Y\" else False", "d", "[", "key", "]", "=", "1", "if",...
Process an iterable of dictionaries. For each dictionary ``d``, convert (in place) ``d[key]`` to a bool. If that fails, convert it to ``None``.
[ "Process", "an", "iterable", "of", "dictionaries", ".", "For", "each", "dictionary", "d", "convert", "(", "in", "place", ")", "d", "[", "key", "]", "to", "a", "bool", ".", "If", "that", "fails", "convert", "it", "to", "None", "." ]
python
train
44.25
denisenkom/django-sqlserver
sqlserver/base.py
https://github.com/denisenkom/django-sqlserver/blob/f5d5dc8637799746f1bd11bd8c479d3acd468581/sqlserver/base.py#L216-L220
def _get_new_connection(self, conn_params): """Opens a connection to the database.""" self.__connection_string = conn_params.get('connection_string', '') conn = self.Database.connect(**conn_params) return conn
[ "def", "_get_new_connection", "(", "self", ",", "conn_params", ")", ":", "self", ".", "__connection_string", "=", "conn_params", ".", "get", "(", "'connection_string'", ",", "''", ")", "conn", "=", "self", ".", "Database", ".", "connect", "(", "*", "*", "c...
Opens a connection to the database.
[ "Opens", "a", "connection", "to", "the", "database", "." ]
python
train
44.2
jmgilman/Neolib
neolib/user/Bank.py
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/Bank.py#L51-L64
def load(self): """ Loads the user's account details and Raises parseException """ pg = self.usr.getPage("http://www.neopets.com/bank.phtml") # Verifies account exists if not "great to see you again" in pg.content: logging.getL...
[ "def", "load", "(", "self", ")", ":", "pg", "=", "self", ".", "usr", ".", "getPage", "(", "\"http://www.neopets.com/bank.phtml\"", ")", "# Verifies account exists", "if", "not", "\"great to see you again\"", "in", "pg", ".", "content", ":", "logging", ".", "getL...
Loads the user's account details and Raises parseException
[ "Loads", "the", "user", "s", "account", "details", "and", "Raises", "parseException" ]
python
train
34.714286
manahl/arctic
arctic/store/version_store.py
https://github.com/manahl/arctic/blob/57e110b6e182dbab00e7e214dc26f7d9ec47c120/arctic/store/version_store.py#L420-L440
def get_arctic_version(self, symbol, as_of=None): """ Return the numerical representation of the arctic version used to write the last (or as_of) version for the given symbol. Parameters ---------- symbol : `str` symbol name for the item as_of : `str`...
[ "def", "get_arctic_version", "(", "self", ",", "symbol", ",", "as_of", "=", "None", ")", ":", "return", "self", ".", "_read_metadata", "(", "symbol", ",", "as_of", "=", "as_of", ")", ".", "get", "(", "'arctic_version'", ",", "0", ")" ]
Return the numerical representation of the arctic version used to write the last (or as_of) version for the given symbol. Parameters ---------- symbol : `str` symbol name for the item as_of : `str` or int or `datetime.datetime` Return the data as it was a...
[ "Return", "the", "numerical", "representation", "of", "the", "arctic", "version", "used", "to", "write", "the", "last", "(", "or", "as_of", ")", "version", "for", "the", "given", "symbol", "." ]
python
train
41.047619
eqcorrscan/EQcorrscan
eqcorrscan/utils/clustering.py
https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/clustering.py#L840-L906
def space_cluster(catalog, d_thresh, show=True): """ Cluster a catalog by distance only. Will compute the matrix of physical distances between events and utilize the :mod:`scipy.clustering.hierarchy` module to perform the clustering. :type catalog: obspy.core.event.Catalog :param catalog: Cata...
[ "def", "space_cluster", "(", "catalog", ",", "d_thresh", ",", "show", "=", "True", ")", ":", "# Compute the distance matrix and linkage", "dist_mat", "=", "dist_mat_km", "(", "catalog", ")", "dist_vec", "=", "squareform", "(", "dist_mat", ")", "Z", "=", "linkage...
Cluster a catalog by distance only. Will compute the matrix of physical distances between events and utilize the :mod:`scipy.clustering.hierarchy` module to perform the clustering. :type catalog: obspy.core.event.Catalog :param catalog: Catalog of events to clustered :type d_thresh: float :par...
[ "Cluster", "a", "catalog", "by", "distance", "only", "." ]
python
train
37.940299
daviddrysdale/python-phonenumbers
python/phonenumbers/phonenumberutil.py
https://github.com/daviddrysdale/python-phonenumbers/blob/9cc5bb4ab5e661e70789b4c64bf7a9383c7bdc20/python/phonenumbers/phonenumberutil.py#L1986-L2019
def is_valid_number_for_region(numobj, region_code): """Tests whether a phone number is valid for a certain region. Note this doesn't verify the number is actually in use, which is impossible to tell by just looking at a number itself. If the country calling code is not the same as the country calling ...
[ "def", "is_valid_number_for_region", "(", "numobj", ",", "region_code", ")", ":", "country_code", "=", "numobj", ".", "country_code", "if", "region_code", "is", "None", ":", "return", "False", "metadata", "=", "PhoneMetadata", ".", "metadata_for_region_or_calling_code...
Tests whether a phone number is valid for a certain region. Note this doesn't verify the number is actually in use, which is impossible to tell by just looking at a number itself. If the country calling code is not the same as the country calling code for the region, this immediately exits with false. ...
[ "Tests", "whether", "a", "phone", "number", "is", "valid", "for", "a", "certain", "region", "." ]
python
train
50.970588
roclark/sportsreference
sportsreference/nhl/schedule.py
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/schedule.py#L271-L281
def result(self): """ Returns a ``string`` constant to indicate whether the team lost in regulation, lost in overtime, or won. """ if self._result.lower() == 'w': return WIN if self._result.lower() == 'l' and \ self.overtime != 0: return...
[ "def", "result", "(", "self", ")", ":", "if", "self", ".", "_result", ".", "lower", "(", ")", "==", "'w'", ":", "return", "WIN", "if", "self", ".", "_result", ".", "lower", "(", ")", "==", "'l'", "and", "self", ".", "overtime", "!=", "0", ":", ...
Returns a ``string`` constant to indicate whether the team lost in regulation, lost in overtime, or won.
[ "Returns", "a", "string", "constant", "to", "indicate", "whether", "the", "team", "lost", "in", "regulation", "lost", "in", "overtime", "or", "won", "." ]
python
train
31.272727
gagneurlab/concise
concise/preprocessing/splines.py
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/preprocessing/splines.py#L8-L16
def _trunc(x, minval=None, maxval=None): """Truncate vector values to have values on range [minval, maxval] """ x = np.copy(x) if minval is not None: x[x < minval] = minval if maxval is not None: x[x > maxval] = maxval return x
[ "def", "_trunc", "(", "x", ",", "minval", "=", "None", ",", "maxval", "=", "None", ")", ":", "x", "=", "np", ".", "copy", "(", "x", ")", "if", "minval", "is", "not", "None", ":", "x", "[", "x", "<", "minval", "]", "=", "minval", "if", "maxval...
Truncate vector values to have values on range [minval, maxval]
[ "Truncate", "vector", "values", "to", "have", "values", "on", "range", "[", "minval", "maxval", "]" ]
python
train
28.777778
bslatkin/dpxdt
dpxdt/server/work_queue.py
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L219-L256
def _get_task_with_policy(queue_name, task_id, owner): """Fetches the specified task and enforces ownership policy. Args: queue_name: Name of the queue the work item is on. task_id: ID of the task that is finished. owner: Who or what has the current lease on the task. Returns: ...
[ "def", "_get_task_with_policy", "(", "queue_name", ",", "task_id", ",", "owner", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "task", "=", "(", "WorkQueue", ".", "query", ".", "filter_by", "(", "queue_name", "=", "queue_name"...
Fetches the specified task and enforces ownership policy. Args: queue_name: Name of the queue the work item is on. task_id: ID of the task that is finished. owner: Who or what has the current lease on the task. Returns: The valid WorkQueue task that is currently owned. Rai...
[ "Fetches", "the", "specified", "task", "and", "enforces", "ownership", "policy", "." ]
python
train
35.368421
timothyhahn/rui
rui/rui.py
https://github.com/timothyhahn/rui/blob/ac9f587fb486760d77332866c6e876f78a810f74/rui/rui.py#L52-L65
def register_entity_to_group(self, entity, group): ''' Add entity to a group. If group does not exist, entity will be added as first member entity is of type Entity group is a string that is the name of the group ''' if entity in self._entities: if gro...
[ "def", "register_entity_to_group", "(", "self", ",", "entity", ",", "group", ")", ":", "if", "entity", "in", "self", ".", "_entities", ":", "if", "group", "in", "self", ".", "_groups", ":", "self", ".", "_groups", "[", "group", "]", ".", "append", "(",...
Add entity to a group. If group does not exist, entity will be added as first member entity is of type Entity group is a string that is the name of the group
[ "Add", "entity", "to", "a", "group", ".", "If", "group", "does", "not", "exist", "entity", "will", "be", "added", "as", "first", "member", "entity", "is", "of", "type", "Entity", "group", "is", "a", "string", "that", "is", "the", "name", "of", "the", ...
python
train
35.928571
flo-compbio/goparser
goparser/annotation.py
https://github.com/flo-compbio/goparser/blob/5e27d7d04a26a70a1d9dc113357041abff72be3f/goparser/annotation.py#L199-L213
def get_gaf_format(self): """Return a GAF 2.0-compatible string representation of the annotation. Parameters ---------- Returns ------- str The formatted string. """ sep = '\t' return sep.join( [self.gene, self.db_ref, sel...
[ "def", "get_gaf_format", "(", "self", ")", ":", "sep", "=", "'\\t'", "return", "sep", ".", "join", "(", "[", "self", ".", "gene", ",", "self", ".", "db_ref", ",", "self", ".", "term", ".", "id", ",", "self", ".", "evidence", ",", "'|'", ".", "joi...
Return a GAF 2.0-compatible string representation of the annotation. Parameters ---------- Returns ------- str The formatted string.
[ "Return", "a", "GAF", "2", ".", "0", "-", "compatible", "string", "representation", "of", "the", "annotation", "." ]
python
train
26
cpburnz/python-path-specification
pathspec/patterns/gitwildmatch.py
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/patterns/gitwildmatch.py#L177-L280
def _translate_segment_glob(pattern): """ Translates the glob pattern to a regular expression. This is used in the constructor to translate a path segment glob pattern to its corresponding regular expression. *pattern* (:class:`str`) is the glob pattern. Returns the regular expression (:class:`str`). ""...
[ "def", "_translate_segment_glob", "(", "pattern", ")", ":", "# NOTE: This is derived from `fnmatch.translate()` and is similar to", "# the POSIX function `fnmatch()` with the `FNM_PATHNAME` flag set.", "escape", "=", "False", "regex", "=", "''", "i", ",", "end", "=", "0", ",", ...
Translates the glob pattern to a regular expression. This is used in the constructor to translate a path segment glob pattern to its corresponding regular expression. *pattern* (:class:`str`) is the glob pattern. Returns the regular expression (:class:`str`).
[ "Translates", "the", "glob", "pattern", "to", "a", "regular", "expression", ".", "This", "is", "used", "in", "the", "constructor", "to", "translate", "a", "path", "segment", "glob", "pattern", "to", "its", "corresponding", "regular", "expression", "." ]
python
train
27.432692
blockstack/blockstack-core
blockstack/lib/rpc.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L458-L496
def GET_names( self, path_info ): """ Get all names in existence If `all=true` is set, then include expired names. Returns the list on success Returns 400 on invalid arguments Returns 502 on failure to get names """ include_expired = False qs_val...
[ "def", "GET_names", "(", "self", ",", "path_info", ")", ":", "include_expired", "=", "False", "qs_values", "=", "path_info", "[", "'qs_values'", "]", "page", "=", "qs_values", ".", "get", "(", "'page'", ",", "None", ")", "if", "page", "is", "None", ":", ...
Get all names in existence If `all=true` is set, then include expired names. Returns the list on success Returns 400 on invalid arguments Returns 502 on failure to get names
[ "Get", "all", "names", "in", "existence", "If", "all", "=", "true", "is", "set", "then", "include", "expired", "names", ".", "Returns", "the", "list", "on", "success", "Returns", "400", "on", "invalid", "arguments", "Returns", "502", "on", "failure", "to",...
python
train
35.794872
bcbio/bcbio-nextgen
bcbio/heterogeneity/bubbletree.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L380-L386
def _has_population_germline(rec): """Check if header defines population annotated germline samples for tumor only. """ for k in population_keys: if k in rec.header.info: return True return False
[ "def", "_has_population_germline", "(", "rec", ")", ":", "for", "k", "in", "population_keys", ":", "if", "k", "in", "rec", ".", "header", ".", "info", ":", "return", "True", "return", "False" ]
Check if header defines population annotated germline samples for tumor only.
[ "Check", "if", "header", "defines", "population", "annotated", "germline", "samples", "for", "tumor", "only", "." ]
python
train
32.142857
numenta/htmresearch
projects/nik/hello_ik.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/projects/nik/hello_ik.py#L36-L44
def printSegmentForCell(tm, cell): """Print segment information for this cell""" print "Segments for cell", cell, ":" for seg in tm.basalConnections._cells[cell]._segments: print " ", synapses = seg._synapses for s in synapses: print "%d:%g" %(s.presynapticCell,s.permanence), print
[ "def", "printSegmentForCell", "(", "tm", ",", "cell", ")", ":", "print", "\"Segments for cell\"", ",", "cell", ",", "\":\"", "for", "seg", "in", "tm", ".", "basalConnections", ".", "_cells", "[", "cell", "]", ".", "_segments", ":", "print", "\" \"", ","...
Print segment information for this cell
[ "Print", "segment", "information", "for", "this", "cell" ]
python
train
33.888889
ergoithz/browsepy
browsepy/stream.py
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/stream.py#L98-L133
def read(self, want=0): ''' Read method, gets data from internal buffer while releasing :meth:`write` locks when needed. The lock usage means it must ran on a different thread than :meth:`fill`, ie. the main thread, otherwise will deadlock. The combination of both write...
[ "def", "read", "(", "self", ",", "want", "=", "0", ")", ":", "if", "self", ".", "_finished", ":", "if", "self", ".", "_finished", "==", "1", ":", "self", ".", "_finished", "+=", "1", "return", "\"\"", "return", "EOFError", "(", "\"EOF reached\"", ")"...
Read method, gets data from internal buffer while releasing :meth:`write` locks when needed. The lock usage means it must ran on a different thread than :meth:`fill`, ie. the main thread, otherwise will deadlock. The combination of both write and this method running on different ...
[ "Read", "method", "gets", "data", "from", "internal", "buffer", "while", "releasing", ":", "meth", ":", "write", "locks", "when", "needed", "." ]
python
train
31.083333
napalm-automation/napalm-logs
napalm_logs/serializer/__init__.py
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/serializer/__init__.py#L34-L44
def get_serializer(name): ''' Return the serialize function. ''' try: log.debug('Using %s as serializer', name) return SERIALIZER_LOOKUP[name] except KeyError: msg = 'Serializer {} is not available'.format(name) log.error(msg, exc_info=True) raise InvalidSeria...
[ "def", "get_serializer", "(", "name", ")", ":", "try", ":", "log", ".", "debug", "(", "'Using %s as serializer'", ",", "name", ")", "return", "SERIALIZER_LOOKUP", "[", "name", "]", "except", "KeyError", ":", "msg", "=", "'Serializer {} is not available'", ".", ...
Return the serialize function.
[ "Return", "the", "serialize", "function", "." ]
python
train
29.909091
icometrix/dicom2nifti
scripts/shrink_singleframe.py
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/scripts/shrink_singleframe.py#L16-L72
def _shrink_file(dicom_file_in, subsample_factor): """ Anonimize a single dicomfile :param dicom_file_in: filepath for input file :param dicom_file_out: filepath for output file :param fields_to_keep: dicom tags to keep """ # Default meta_fields # Required fields according to reference ...
[ "def", "_shrink_file", "(", "dicom_file_in", ",", "subsample_factor", ")", ":", "# Default meta_fields", "# Required fields according to reference", "dicom_file_out", "=", "dicom_file_in", "# Load dicom_file_in", "dicom_in", "=", "compressed_dicom", ".", "read_file", "(", "di...
Anonimize a single dicomfile :param dicom_file_in: filepath for input file :param dicom_file_out: filepath for output file :param fields_to_keep: dicom tags to keep
[ "Anonimize", "a", "single", "dicomfile", ":", "param", "dicom_file_in", ":", "filepath", "for", "input", "file", ":", "param", "dicom_file_out", ":", "filepath", "for", "output", "file", ":", "param", "fields_to_keep", ":", "dicom", "tags", "to", "keep" ]
python
train
33.561404
jespino/anillo
anillo/handlers/routing.py
https://github.com/jespino/anillo/blob/901a84fd2b4fa909bc06e8bd76090457990576a7/anillo/handlers/routing.py#L175-L184
def _build_urlmapping(urls, strict_slashes=False, **kwargs): """Convers the anillo urlmappings list into werkzeug Map instance. :return: a werkzeug Map instance :rtype: Map """ rules = _build_rules(urls) return Map(rules=list(rules), strict_slashes=strict_slashes, **kwargs)
[ "def", "_build_urlmapping", "(", "urls", ",", "strict_slashes", "=", "False", ",", "*", "*", "kwargs", ")", ":", "rules", "=", "_build_rules", "(", "urls", ")", "return", "Map", "(", "rules", "=", "list", "(", "rules", ")", ",", "strict_slashes", "=", ...
Convers the anillo urlmappings list into werkzeug Map instance. :return: a werkzeug Map instance :rtype: Map
[ "Convers", "the", "anillo", "urlmappings", "list", "into", "werkzeug", "Map", "instance", "." ]
python
train
29.5
gmr/tinman
tinman/serializers.py
https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/serializers.py#L39-L48
def _deserialize_datetime(self, data): """Take any values coming in as a datetime and deserialize them """ for key in data: if isinstance(data[key], dict): if data[key].get('type') == 'datetime': data[key] = \ datetime.date...
[ "def", "_deserialize_datetime", "(", "self", ",", "data", ")", ":", "for", "key", "in", "data", ":", "if", "isinstance", "(", "data", "[", "key", "]", ",", "dict", ")", ":", "if", "data", "[", "key", "]", ".", "get", "(", "'type'", ")", "==", "'d...
Take any values coming in as a datetime and deserialize them
[ "Take", "any", "values", "coming", "in", "as", "a", "datetime", "and", "deserialize", "them" ]
python
train
36.9
hvac/hvac
hvac/api/auth_methods/github.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/auth_methods/github.py#L191-L216
def login(self, token, use_token=True, mount_point=DEFAULT_MOUNT_POINT): """Login using GitHub access token. Supported methods: POST: /auth/{mount_point}/login. Produces: 200 application/json :param token: GitHub personal API token. :type token: str | unicode :para...
[ "def", "login", "(", "self", ",", "token", ",", "use_token", "=", "True", ",", "mount_point", "=", "DEFAULT_MOUNT_POINT", ")", ":", "params", "=", "{", "'token'", ":", "token", ",", "}", "api_path", "=", "'/v1/auth/{mount_point}/login'", ".", "format", "(", ...
Login using GitHub access token. Supported methods: POST: /auth/{mount_point}/login. Produces: 200 application/json :param token: GitHub personal API token. :type token: str | unicode :param use_token: if True, uses the token in the response received from the auth request ...
[ "Login", "using", "GitHub", "access", "token", "." ]
python
train
39
trevisanj/f311
f311/explorer/gui/a_XFileMainWindow.py
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XFileMainWindow.py#L329-L334
def _on_changed(self): """Slot for changed events""" page = self._get_page() if not page.flag_autosave: page.flag_changed = True self._update_gui_text_tabs()
[ "def", "_on_changed", "(", "self", ")", ":", "page", "=", "self", ".", "_get_page", "(", ")", "if", "not", "page", ".", "flag_autosave", ":", "page", ".", "flag_changed", "=", "True", "self", ".", "_update_gui_text_tabs", "(", ")" ]
Slot for changed events
[ "Slot", "for", "changed", "events" ]
python
train
34.166667
jtwhite79/pyemu
pyemu/utils/smp_utils.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/utils/smp_utils.py#L132-L153
def date_parser(items): """ datetime parser to help load smp files Parameters ---------- items : iterable something or somethings to try to parse into datetimes Returns ------- dt : iterable the cast datetime things """ try: dt = datetime.strptime(items,"%d/...
[ "def", "date_parser", "(", "items", ")", ":", "try", ":", "dt", "=", "datetime", ".", "strptime", "(", "items", ",", "\"%d/%m/%Y %H:%M:%S\"", ")", "except", "Exception", "as", "e", ":", "try", ":", "dt", "=", "datetime", ".", "strptime", "(", "items", ...
datetime parser to help load smp files Parameters ---------- items : iterable something or somethings to try to parse into datetimes Returns ------- dt : iterable the cast datetime things
[ "datetime", "parser", "to", "help", "load", "smp", "files" ]
python
train
27.636364
nuagenetworks/bambou
bambou/nurest_fetcher.py
https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_fetcher.py#L481-L495
def _send_content(self, content, connection): """ Send a content array from the connection """ if connection: if connection.async: callback = connection.callbacks['remote'] if callback: callback(self, self.parent_object, content) ...
[ "def", "_send_content", "(", "self", ",", "content", ",", "connection", ")", ":", "if", "connection", ":", "if", "connection", ".", "async", ":", "callback", "=", "connection", ".", "callbacks", "[", "'remote'", "]", "if", "callback", ":", "callback", "(",...
Send a content array from the connection
[ "Send", "a", "content", "array", "from", "the", "connection" ]
python
train
31.933333
calmjs/calmjs.parse
src/calmjs/parse/parsers/es5.py
https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/parsers/es5.py#L490-L498
def p_new_expr(self, p): """new_expr : member_expr | NEW new_expr """ if len(p) == 2: p[0] = p[1] else: p[0] = self.asttypes.NewExpr(p[2]) p[0].setpos(p)
[ "def", "p_new_expr", "(", "self", ",", "p", ")", ":", "if", "len", "(", "p", ")", "==", "2", ":", "p", "[", "0", "]", "=", "p", "[", "1", "]", "else", ":", "p", "[", "0", "]", "=", "self", ".", "asttypes", ".", "NewExpr", "(", "p", "[", ...
new_expr : member_expr | NEW new_expr
[ "new_expr", ":", "member_expr", "|", "NEW", "new_expr" ]
python
train
25.888889
tensorflow/datasets
tensorflow_datasets/core/utils/py_utils.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/utils/py_utils.py#L122-L143
def map_nested(function, data_struct, dict_only=False, map_tuple=False): """Apply a function recursively to each element of a nested data struct.""" # Could add support for more exotic data_struct, like OrderedDict if isinstance(data_struct, dict): return { k: map_nested(function, v, dict_only, map_t...
[ "def", "map_nested", "(", "function", ",", "data_struct", ",", "dict_only", "=", "False", ",", "map_tuple", "=", "False", ")", ":", "# Could add support for more exotic data_struct, like OrderedDict", "if", "isinstance", "(", "data_struct", ",", "dict", ")", ":", "r...
Apply a function recursively to each element of a nested data struct.
[ "Apply", "a", "function", "recursively", "to", "each", "element", "of", "a", "nested", "data", "struct", "." ]
python
train
33.136364
cuihantao/andes
andes/system.py
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L187-L211
def setup(self): """ Set up the power system object by executing the following workflow: * Sort the loaded models to meet the initialization sequence * Create call strings for routines * Call the ``setup`` function of the loaded models * Assign addresses for the load...
[ "def", "setup", "(", "self", ")", ":", "self", ".", "devman", ".", "sort_device", "(", ")", "self", ".", "call", ".", "setup", "(", ")", "self", ".", "model_setup", "(", ")", "self", ".", "xy_addr0", "(", ")", "self", ".", "dae", ".", "setup", "(...
Set up the power system object by executing the following workflow: * Sort the loaded models to meet the initialization sequence * Create call strings for routines * Call the ``setup`` function of the loaded models * Assign addresses for the loaded models * Call ``dae.setup...
[ "Set", "up", "the", "power", "system", "object", "by", "executing", "the", "following", "workflow", ":" ]
python
train
29.28
ewels/MultiQC
multiqc/modules/rseqc/infer_experiment.py
https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/rseqc/infer_experiment.py#L16-L89
def parse_reports(self): """ Find RSeQC infer_experiment reports and parse their data """ # Set up vars self.infer_exp = dict() regexes = { 'pe_sense': r"\"1\+\+,1--,2\+-,2-\+\": (\d\.\d+)", 'pe_antisense': r"\"1\+-,1-\+,2\+\+,2--\": (\d\.\d+)", 'se_sense': r"\"\+\+,--\": (\d\.\...
[ "def", "parse_reports", "(", "self", ")", ":", "# Set up vars", "self", ".", "infer_exp", "=", "dict", "(", ")", "regexes", "=", "{", "'pe_sense'", ":", "r\"\\\"1\\+\\+,1--,2\\+-,2-\\+\\\": (\\d\\.\\d+)\"", ",", "'pe_antisense'", ":", "r\"\\\"1\\+-,1-\\+,2\\+\\+,2--\\\"...
Find RSeQC infer_experiment reports and parse their data
[ "Find", "RSeQC", "infer_experiment", "reports", "and", "parse", "their", "data" ]
python
train
36.905405
IdentityPython/pysaml2
src/saml2/sigver.py
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/sigver.py#L436-L446
def cert_from_instance(instance): """ Find certificates that are part of an instance :param instance: An instance :return: possible empty list of certificates """ if instance.signature: if instance.signature.key_info: return cert_from_key_info(instance.signature.key_info, ...
[ "def", "cert_from_instance", "(", "instance", ")", ":", "if", "instance", ".", "signature", ":", "if", "instance", ".", "signature", ".", "key_info", ":", "return", "cert_from_key_info", "(", "instance", ".", "signature", ".", "key_info", ",", "ignore_age", "=...
Find certificates that are part of an instance :param instance: An instance :return: possible empty list of certificates
[ "Find", "certificates", "that", "are", "part", "of", "an", "instance" ]
python
train
33.818182
tensorflow/datasets
tensorflow_datasets/image/sun.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/image/sun.py#L65-L102
def _decode_image(fobj, session, filename): """Reads and decodes an image from a file object as a Numpy array. The SUN dataset contains images in several formats (despite the fact that all of them have .jpg extension). Some of them are: - BMP (RGB) - PNG (grayscale, RGBA, RGB interlaced) - JPEG (RGB)...
[ "def", "_decode_image", "(", "fobj", ",", "session", ",", "filename", ")", ":", "buf", "=", "fobj", ".", "read", "(", ")", "image", "=", "tfds", ".", "core", ".", "lazy_imports", ".", "cv2", ".", "imdecode", "(", "np", ".", "fromstring", "(", "buf", ...
Reads and decodes an image from a file object as a Numpy array. The SUN dataset contains images in several formats (despite the fact that all of them have .jpg extension). Some of them are: - BMP (RGB) - PNG (grayscale, RGBA, RGB interlaced) - JPEG (RGB) - GIF (1-frame RGB) Since TFDS assumes tha...
[ "Reads", "and", "decodes", "an", "image", "from", "a", "file", "object", "as", "a", "Numpy", "array", "." ]
python
train
33.5
HewlettPackard/python-hpOneView
hpOneView/oneview_client.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L398-L407
def scopes(self): """ Gets the Scopes API client. Returns: Scopes: """ if not self.__scopes: self.__scopes = Scopes(self.__connection) return self.__scopes
[ "def", "scopes", "(", "self", ")", ":", "if", "not", "self", ".", "__scopes", ":", "self", ".", "__scopes", "=", "Scopes", "(", "self", ".", "__connection", ")", "return", "self", ".", "__scopes" ]
Gets the Scopes API client. Returns: Scopes:
[ "Gets", "the", "Scopes", "API", "client", "." ]
python
train
21.9
awslabs/serverless-application-model
samtranslator/sdk/parameter.py
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/sdk/parameter.py#L19-L59
def add_default_parameter_values(self, sam_template): """ Method to read default values for template parameters and merge with user supplied values. Example: If the template contains the following parameters defined Parameters: Param1: Type: String ...
[ "def", "add_default_parameter_values", "(", "self", ",", "sam_template", ")", ":", "parameter_definition", "=", "sam_template", ".", "get", "(", "\"Parameters\"", ",", "None", ")", "if", "not", "parameter_definition", "or", "not", "isinstance", "(", "parameter_defin...
Method to read default values for template parameters and merge with user supplied values. Example: If the template contains the following parameters defined Parameters: Param1: Type: String Default: default_value Param2: ...
[ "Method", "to", "read", "default", "values", "for", "template", "parameters", "and", "merge", "with", "user", "supplied", "values", "." ]
python
train
32.878049