repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
okpy/ok-client
client/utils/network.py
https://github.com/okpy/ok-client/blob/517f57dd76284af40ba9766e42d9222b644afd9c/client/utils/network.py#L14-L24
def check_ssl(): """Attempts to import SSL or raises an exception.""" try: import ssl except: log.warning('Error importing SSL module', stack_info=True) print(SSL_ERROR_MESSAGE) sys.exit(1) else: log.info('SSL module is available') return ssl
[ "def", "check_ssl", "(", ")", ":", "try", ":", "import", "ssl", "except", ":", "log", ".", "warning", "(", "'Error importing SSL module'", ",", "stack_info", "=", "True", ")", "print", "(", "SSL_ERROR_MESSAGE", ")", "sys", ".", "exit", "(", "1", ")", "el...
Attempts to import SSL or raises an exception.
[ "Attempts", "to", "import", "SSL", "or", "raises", "an", "exception", "." ]
python
train
pyqt/python-qt5
PyQt5/uic/__init__.py
https://github.com/pyqt/python-qt5/blob/c9ed180c56f6fd3521ffe5fb70904bc5d3f50e5f/PyQt5/uic/__init__.py#L206-L226
def loadUi(uifile, baseinstance=None, package='', resource_suffix='_rc'): """loadUi(uifile, baseinstance=None, package='') -> widget Load a Qt Designer .ui file and return an instance of the user interface. uifile is a file name or file-like object containing the .ui file. baseinstance is an optional ...
[ "def", "loadUi", "(", "uifile", ",", "baseinstance", "=", "None", ",", "package", "=", "''", ",", "resource_suffix", "=", "'_rc'", ")", ":", "from", ".", "Loader", ".", "loader", "import", "DynamicUILoader", "return", "DynamicUILoader", "(", "package", ")", ...
loadUi(uifile, baseinstance=None, package='') -> widget Load a Qt Designer .ui file and return an instance of the user interface. uifile is a file name or file-like object containing the .ui file. baseinstance is an optional instance of the Qt base class. If specified then the user interface is creat...
[ "loadUi", "(", "uifile", "baseinstance", "=", "None", "package", "=", ")", "-", ">", "widget" ]
python
train
dj-stripe/dj-stripe
djstripe/models/core.py
https://github.com/dj-stripe/dj-stripe/blob/a5308a3808cd6e2baba49482f7a699f3a8992518/djstripe/models/core.py#L816-L852
def has_active_subscription(self, plan=None): """ Checks to see if this customer has an active subscription to the given plan. :param plan: The plan for which to check for an active subscription. If plan is None and there exists only one active subscription, this method will check if that subscription is v...
[ "def", "has_active_subscription", "(", "self", ",", "plan", "=", "None", ")", ":", "if", "plan", "is", "None", ":", "valid_subscriptions", "=", "self", ".", "_get_valid_subscriptions", "(", ")", "if", "len", "(", "valid_subscriptions", ")", "==", "0", ":", ...
Checks to see if this customer has an active subscription to the given plan. :param plan: The plan for which to check for an active subscription. If plan is None and there exists only one active subscription, this method will check if that subscription is valid. Calling this method with no plan and multiple va...
[ "Checks", "to", "see", "if", "this", "customer", "has", "an", "active", "subscription", "to", "the", "given", "plan", "." ]
python
train
tanghaibao/jcvi
jcvi/assembly/hic.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/hic.py#L268-L273
def evaluate_tour_P(self, tour): """ Use Cythonized version to evaluate the score of a current tour, with better precision on the distance of the contigs. """ from .chic import score_evaluate_P return score_evaluate_P(tour, self.active_sizes, self.P)
[ "def", "evaluate_tour_P", "(", "self", ",", "tour", ")", ":", "from", ".", "chic", "import", "score_evaluate_P", "return", "score_evaluate_P", "(", "tour", ",", "self", ".", "active_sizes", ",", "self", ".", "P", ")" ]
Use Cythonized version to evaluate the score of a current tour, with better precision on the distance of the contigs.
[ "Use", "Cythonized", "version", "to", "evaluate", "the", "score", "of", "a", "current", "tour", "with", "better", "precision", "on", "the", "distance", "of", "the", "contigs", "." ]
python
train
FutunnOpen/futuquant
futuquant/examples/learn/get_realtime_data.py
https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/examples/learn/get_realtime_data.py#L112-L122
def _example_get_trade_days(quote_ctx): """ 获取交易日列表,输出 交易日列表 """ ret_status, ret_data = quote_ctx.get_trading_days("US", None, None) if ret_status != ft.RET_OK: print(ret_data) exit() print("TRADING DAYS") for x in ret_data: print(x)
[ "def", "_example_get_trade_days", "(", "quote_ctx", ")", ":", "ret_status", ",", "ret_data", "=", "quote_ctx", ".", "get_trading_days", "(", "\"US\"", ",", "None", ",", "None", ")", "if", "ret_status", "!=", "ft", ".", "RET_OK", ":", "print", "(", "ret_data"...
获取交易日列表,输出 交易日列表
[ "获取交易日列表,输出", "交易日列表" ]
python
train
projectatomic/atomic-reactor
atomic_reactor/plugins/exit_koji_promote.py
https://github.com/projectatomic/atomic-reactor/blob/fd31c01b964097210bf169960d051e5f04019a80/atomic_reactor/plugins/exit_koji_promote.py#L642-L662
def upload_file(self, session, output, serverdir): """ Upload a file to koji :return: str, pathname on server """ name = output.metadata['filename'] self.log.debug("uploading %r to %r as %r", output.file.name, serverdir, name) kwargs = {} ...
[ "def", "upload_file", "(", "self", ",", "session", ",", "output", ",", "serverdir", ")", ":", "name", "=", "output", ".", "metadata", "[", "'filename'", "]", "self", ".", "log", ".", "debug", "(", "\"uploading %r to %r as %r\"", ",", "output", ".", "file",...
Upload a file to koji :return: str, pathname on server
[ "Upload", "a", "file", "to", "koji" ]
python
train
awslabs/serverless-application-model
samtranslator/intrinsics/actions.py
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L520-L555
def resolve_parameter_refs(self, input_dict, parameters): """ Recursively resolves "Fn::FindInMap"references that are present in the mappings and returns the value. If it is not in mappings, this method simply returns the input unchanged. :param input_dict: Dictionary representing the F...
[ "def", "resolve_parameter_refs", "(", "self", ",", "input_dict", ",", "parameters", ")", ":", "if", "not", "self", ".", "can_handle", "(", "input_dict", ")", ":", "return", "input_dict", "value", "=", "input_dict", "[", "self", ".", "intrinsic_name", "]", "#...
Recursively resolves "Fn::FindInMap"references that are present in the mappings and returns the value. If it is not in mappings, this method simply returns the input unchanged. :param input_dict: Dictionary representing the FindInMap function. Must contain only one key and it ...
[ "Recursively", "resolves", "Fn", "::", "FindInMap", "references", "that", "are", "present", "in", "the", "mappings", "and", "returns", "the", "value", ".", "If", "it", "is", "not", "in", "mappings", "this", "method", "simply", "returns", "the", "input", "unc...
python
train
IEMLdev/ieml
ieml/grammar/parser/parser.py
https://github.com/IEMLdev/ieml/blob/4c842ba7e6165e2f1b4a4e2e98759f9f33af5f25/ieml/grammar/parser/parser.py#L73-L82
def parse(self, s): """Parses the input string, and returns a reference to the created AST's root""" with self.lock: try: return self.parser.parse(s, lexer=self.lexer) except InvalidIEMLObjectArgument as e: raise CannotParse(s, str(e)) ...
[ "def", "parse", "(", "self", ",", "s", ")", ":", "with", "self", ".", "lock", ":", "try", ":", "return", "self", ".", "parser", ".", "parse", "(", "s", ",", "lexer", "=", "self", ".", "lexer", ")", "except", "InvalidIEMLObjectArgument", "as", "e", ...
Parses the input string, and returns a reference to the created AST's root
[ "Parses", "the", "input", "string", "and", "returns", "a", "reference", "to", "the", "created", "AST", "s", "root" ]
python
test
HewlettPackard/python-hpOneView
hpOneView/oneview_client.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L483-L492
def id_pools_vwwn_ranges(self): """ Gets the IdPoolsRanges API Client for VWWN Ranges. Returns: IdPoolsRanges: """ if not self.__id_pools_vwwn_ranges: self.__id_pools_vwwn_ranges = IdPoolsRanges('vwwn', self.__connection) return self.__id_pools_vw...
[ "def", "id_pools_vwwn_ranges", "(", "self", ")", ":", "if", "not", "self", ".", "__id_pools_vwwn_ranges", ":", "self", ".", "__id_pools_vwwn_ranges", "=", "IdPoolsRanges", "(", "'vwwn'", ",", "self", ".", "__connection", ")", "return", "self", ".", "__id_pools_v...
Gets the IdPoolsRanges API Client for VWWN Ranges. Returns: IdPoolsRanges:
[ "Gets", "the", "IdPoolsRanges", "API", "Client", "for", "VWWN", "Ranges", "." ]
python
train
serge-sans-paille/pythran
pythran/tables.py
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/tables.py#L4553-L4583
def save_arguments(module_name, elements): """ Recursively save arguments name and default value. """ for elem, signature in elements.items(): if isinstance(signature, dict): # Submodule case save_arguments(module_name + (elem,), signature) else: # use introspection to g...
[ "def", "save_arguments", "(", "module_name", ",", "elements", ")", ":", "for", "elem", ",", "signature", "in", "elements", ".", "items", "(", ")", ":", "if", "isinstance", "(", "signature", ",", "dict", ")", ":", "# Submodule case", "save_arguments", "(", ...
Recursively save arguments name and default value.
[ "Recursively", "save", "arguments", "name", "and", "default", "value", "." ]
python
train
trailofbits/manticore
manticore/platforms/evm.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1275-L1278
def BYTE(self, offset, value): """Retrieve single byte from word""" offset = Operators.ITEBV(256, offset < 32, (31 - offset) * 8, 256) return Operators.ZEXTEND(Operators.EXTRACT(value, offset, 8), 256)
[ "def", "BYTE", "(", "self", ",", "offset", ",", "value", ")", ":", "offset", "=", "Operators", ".", "ITEBV", "(", "256", ",", "offset", "<", "32", ",", "(", "31", "-", "offset", ")", "*", "8", ",", "256", ")", "return", "Operators", ".", "ZEXTEND...
Retrieve single byte from word
[ "Retrieve", "single", "byte", "from", "word" ]
python
valid
marcomusy/vtkplotter
vtkplotter/vtkio.py
https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/vtkio.py#L281-L289
def loadRectilinearGrid(filename): # not tested """Load a ``vtkRectilinearGrid`` object from file and return a ``Actor(vtkActor)`` object.""" reader = vtk.vtkRectilinearGridReader() reader.SetFileName(filename) reader.Update() gf = vtk.vtkRectilinearGridGeometryFilter() gf.SetInputConnection(re...
[ "def", "loadRectilinearGrid", "(", "filename", ")", ":", "# not tested", "reader", "=", "vtk", ".", "vtkRectilinearGridReader", "(", ")", "reader", ".", "SetFileName", "(", "filename", ")", "reader", ".", "Update", "(", ")", "gf", "=", "vtk", ".", "vtkRectil...
Load a ``vtkRectilinearGrid`` object from file and return a ``Actor(vtkActor)`` object.
[ "Load", "a", "vtkRectilinearGrid", "object", "from", "file", "and", "return", "a", "Actor", "(", "vtkActor", ")", "object", "." ]
python
train
shi-cong/PYSTUDY
PYSTUDY/timelib.py
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/timelib.py#L7-L17
def func_runtime(callback): """ 测试函数执行的时间 :param callback: 函数 :return: 时间 """ now = time.time() print('%s - start: %f' % (callback, now)) callback() now = time.time() - now print('%s - spent: %f Second' % (callback, now))
[ "def", "func_runtime", "(", "callback", ")", ":", "now", "=", "time", ".", "time", "(", ")", "print", "(", "'%s - start: %f'", "%", "(", "callback", ",", "now", ")", ")", "callback", "(", ")", "now", "=", "time", ".", "time", "(", ")", "-", "now", ...
测试函数执行的时间 :param callback: 函数 :return: 时间
[ "测试函数执行的时间", ":", "param", "callback", ":", "函数", ":", "return", ":", "时间" ]
python
train
cwacek/python-jsonschema-objects
python_jsonschema_objects/classbuilder.py
https://github.com/cwacek/python-jsonschema-objects/blob/54c82bfaec9c099c472663742abfc7de373a5e49/python_jsonschema_objects/classbuilder.py#L47-L67
def as_dict(self): """ Return a dictionary containing the current values of the object. Returns: (dict): The object represented as a dictionary """ out = {} for prop in self: propval = getattr(self, prop) if hasattr(propval, 'for_json...
[ "def", "as_dict", "(", "self", ")", ":", "out", "=", "{", "}", "for", "prop", "in", "self", ":", "propval", "=", "getattr", "(", "self", ",", "prop", ")", "if", "hasattr", "(", "propval", ",", "'for_json'", ")", ":", "out", "[", "prop", "]", "=",...
Return a dictionary containing the current values of the object. Returns: (dict): The object represented as a dictionary
[ "Return", "a", "dictionary", "containing", "the", "current", "values", "of", "the", "object", "." ]
python
train
vatlab/SoS
src/sos/actions.py
https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/src/sos/actions.py#L923-L991
def download(URLs, dest_dir='.', dest_file=None, decompress=False, max_jobs=5): '''Download files from specified URL, which should be space, tab or newline separated URLs. The files will be downloaded to specified destination. If `filename.md5` files are downloaded, they are used to validate downloaded ...
[ "def", "download", "(", "URLs", ",", "dest_dir", "=", "'.'", ",", "dest_file", "=", "None", ",", "decompress", "=", "False", ",", "max_jobs", "=", "5", ")", ":", "if", "env", ".", "config", "[", "'run_mode'", "]", "==", "'dryrun'", ":", "print", "(",...
Download files from specified URL, which should be space, tab or newline separated URLs. The files will be downloaded to specified destination. If `filename.md5` files are downloaded, they are used to validate downloaded `filename`. Unless otherwise specified, compressed files are decompressed. If `max_...
[ "Download", "files", "from", "specified", "URL", "which", "should", "be", "space", "tab", "or", "newline", "separated", "URLs", ".", "The", "files", "will", "be", "downloaded", "to", "specified", "destination", ".", "If", "filename", ".", "md5", "files", "ar...
python
train
romanorac/discomll
discomll/regression/locally_weighted_linear_regression.py
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/regression/locally_weighted_linear_regression.py#L83-L139
def fit_predict(training_data, fitting_data, tau=1, samples_per_job=0, save_results=True, show=False): from disco.worker.pipeline.worker import Worker, Stage from disco.core import Job, result_iterator from disco.core import Disco """ training_data - training samples fitting_data - dataset to b...
[ "def", "fit_predict", "(", "training_data", ",", "fitting_data", ",", "tau", "=", "1", ",", "samples_per_job", "=", "0", ",", "save_results", "=", "True", ",", "show", "=", "False", ")", ":", "from", "disco", ".", "worker", ".", "pipeline", ".", "worker"...
training_data - training samples fitting_data - dataset to be fitted to training data. tau - controls how quickly the weight of a training sample falls off with distance of its x(i) from the query point x. samples_per_job - define a number of samples that will be processed in single mapreduce job. If 0, alg...
[ "training_data", "-", "training", "samples", "fitting_data", "-", "dataset", "to", "be", "fitted", "to", "training", "data", ".", "tau", "-", "controls", "how", "quickly", "the", "weight", "of", "a", "training", "sample", "falls", "off", "with", "distance", ...
python
train
marshallward/f90nml
f90nml/namelist.py
https://github.com/marshallward/f90nml/blob/4932cabc5221afc844ee6a5b4a05ceb8bd4a2711/f90nml/namelist.py#L391-L406
def write(self, nml_path, force=False, sort=False): """Write Namelist to a Fortran 90 namelist file. >>> nml = f90nml.read('input.nml') >>> nml.write('out.nml') """ nml_is_file = hasattr(nml_path, 'read') if not force and not nml_is_file and os.path.isfile(nml_path): ...
[ "def", "write", "(", "self", ",", "nml_path", ",", "force", "=", "False", ",", "sort", "=", "False", ")", ":", "nml_is_file", "=", "hasattr", "(", "nml_path", ",", "'read'", ")", "if", "not", "force", "and", "not", "nml_is_file", "and", "os", ".", "p...
Write Namelist to a Fortran 90 namelist file. >>> nml = f90nml.read('input.nml') >>> nml.write('out.nml')
[ "Write", "Namelist", "to", "a", "Fortran", "90", "namelist", "file", "." ]
python
train
tensorflow/tensorboard
tensorboard/plugins/beholder/beholder.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/beholder/beholder.py#L85-L91
def _write_summary(self, session, frame): '''Writes the frame to disk as a tensor summary.''' summary = session.run(self.summary_op, feed_dict={ self.frame_placeholder: frame }) path = '{}/{}'.format(self.PLUGIN_LOGDIR, SUMMARY_FILENAME) write_file(summary, path)
[ "def", "_write_summary", "(", "self", ",", "session", ",", "frame", ")", ":", "summary", "=", "session", ".", "run", "(", "self", ".", "summary_op", ",", "feed_dict", "=", "{", "self", ".", "frame_placeholder", ":", "frame", "}", ")", "path", "=", "'{}...
Writes the frame to disk as a tensor summary.
[ "Writes", "the", "frame", "to", "disk", "as", "a", "tensor", "summary", "." ]
python
train
chrisrink10/basilisp
src/basilisp/lang/compiler/parser.py
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/parser.py#L310-L317
def warn_on_shadowed_var(self) -> bool: """If True, warn when a def'ed Var name is shadowed in an inner scope. Implied by warn_on_shadowed_name. The value of warn_on_shadowed_name supersedes the value of this flag.""" return self.warn_on_shadowed_name or self._opts.entry( WA...
[ "def", "warn_on_shadowed_var", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "warn_on_shadowed_name", "or", "self", ".", "_opts", ".", "entry", "(", "WARN_ON_SHADOWED_VAR", ",", "False", ")" ]
If True, warn when a def'ed Var name is shadowed in an inner scope. Implied by warn_on_shadowed_name. The value of warn_on_shadowed_name supersedes the value of this flag.
[ "If", "True", "warn", "when", "a", "def", "ed", "Var", "name", "is", "shadowed", "in", "an", "inner", "scope", "." ]
python
test
mbj4668/pyang
pyang/statements.py
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/statements.py#L3192-L3204
def get_primitive_type(stmt): """Recurses through the typedefs and returns the most primitive YANG type defined. """ type_obj = stmt.search_one('type') type_name = getattr(type_obj, 'arg', None) typedef_obj = getattr(type_obj, 'i_typedef', None) if typedef_obj: type_name = get_primit...
[ "def", "get_primitive_type", "(", "stmt", ")", ":", "type_obj", "=", "stmt", ".", "search_one", "(", "'type'", ")", "type_name", "=", "getattr", "(", "type_obj", ",", "'arg'", ",", "None", ")", "typedef_obj", "=", "getattr", "(", "type_obj", ",", "'i_typed...
Recurses through the typedefs and returns the most primitive YANG type defined.
[ "Recurses", "through", "the", "typedefs", "and", "returns", "the", "most", "primitive", "YANG", "type", "defined", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xtreewidget/xloaderitem.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xloaderitem.py#L55-L71
def autoload(self, state=True): """ Begins the process for autoloading this item when it becomes visible within the tree. :param state | <bool> """ if state and not self._timer: self._timer = QtCore.QTimer() self._timer.setIn...
[ "def", "autoload", "(", "self", ",", "state", "=", "True", ")", ":", "if", "state", "and", "not", "self", ".", "_timer", ":", "self", ".", "_timer", "=", "QtCore", ".", "QTimer", "(", ")", "self", ".", "_timer", ".", "setInterval", "(", "500", ")",...
Begins the process for autoloading this item when it becomes visible within the tree. :param state | <bool>
[ "Begins", "the", "process", "for", "autoloading", "this", "item", "when", "it", "becomes", "visible", "within", "the", "tree", ".", ":", "param", "state", "|", "<bool", ">" ]
python
train
minio/minio-py
minio/api.py
https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/api.py#L1014-L1028
def remove_object(self, bucket_name, object_name): """ Remove an object from the bucket. :param bucket_name: Bucket of object to remove :param object_name: Name of object to remove :return: None """ is_valid_bucket_name(bucket_name) is_non_empty_string(ob...
[ "def", "remove_object", "(", "self", ",", "bucket_name", ",", "object_name", ")", ":", "is_valid_bucket_name", "(", "bucket_name", ")", "is_non_empty_string", "(", "object_name", ")", "# No reason to store successful response, for errors", "# relevant exceptions are thrown.", ...
Remove an object from the bucket. :param bucket_name: Bucket of object to remove :param object_name: Name of object to remove :return: None
[ "Remove", "an", "object", "from", "the", "bucket", "." ]
python
train
project-rig/rig
rig/machine_control/machine_controller.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2482-L2492
def _if_not_closed(f): """Run the method iff. the memory view hasn't been closed and the parent object has not been freed.""" @add_signature_to_docstring(f) @functools.wraps(f) def f_(self, *args, **kwargs): if self.closed or self._parent._freed: raise OSError return f(se...
[ "def", "_if_not_closed", "(", "f", ")", ":", "@", "add_signature_to_docstring", "(", "f", ")", "@", "functools", ".", "wraps", "(", "f", ")", "def", "f_", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "closed"...
Run the method iff. the memory view hasn't been closed and the parent object has not been freed.
[ "Run", "the", "method", "iff", ".", "the", "memory", "view", "hasn", "t", "been", "closed", "and", "the", "parent", "object", "has", "not", "been", "freed", "." ]
python
train
deathbeds/importnb
src/importnb/loader.py
https://github.com/deathbeds/importnb/blob/ec870d1f8ab99fd5b363267f89787a3e442a779f/src/importnb/loader.py#L213-L233
def load(cls, filename, dir=None, main=False, **kwargs): """Import a notebook as a module from a filename. dir: The directory to load the file from. main: Load the module in the __main__ context. > assert Notebook.load('loader.ipynb') """ name = main and...
[ "def", "load", "(", "cls", ",", "filename", ",", "dir", "=", "None", ",", "main", "=", "False", ",", "*", "*", "kwargs", ")", ":", "name", "=", "main", "and", "\"__main__\"", "or", "Path", "(", "filename", ")", ".", "stem", "loader", "=", "cls", ...
Import a notebook as a module from a filename. dir: The directory to load the file from. main: Load the module in the __main__ context. > assert Notebook.load('loader.ipynb')
[ "Import", "a", "notebook", "as", "a", "module", "from", "a", "filename", ".", "dir", ":", "The", "directory", "to", "load", "the", "file", "from", ".", "main", ":", "Load", "the", "module", "in", "the", "__main__", "context", ".", ">", "assert", "Noteb...
python
train
agile-geoscience/welly
welly/curve.py
https://github.com/agile-geoscience/welly/blob/ed4c991011d6290938fef365553041026ba29f42/welly/curve.py#L159-L169
def describe(self): """ Return basic statistics about the curve. """ stats = {} stats['samples'] = self.shape[0] stats['nulls'] = self[np.isnan(self)].shape[0] stats['mean'] = float(np.nanmean(self.real)) stats['min'] = float(np.nanmin(self.real)) ...
[ "def", "describe", "(", "self", ")", ":", "stats", "=", "{", "}", "stats", "[", "'samples'", "]", "=", "self", ".", "shape", "[", "0", "]", "stats", "[", "'nulls'", "]", "=", "self", "[", "np", ".", "isnan", "(", "self", ")", "]", ".", "shape",...
Return basic statistics about the curve.
[ "Return", "basic", "statistics", "about", "the", "curve", "." ]
python
train
tjcsl/ion
intranet/utils/urls.py
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/utils/urls.py#L6-L28
def add_get_parameters(url, parameters, percent_encode=True): """Utility function to add GET parameters to an existing URL. Args: parameters A dictionary of the parameters that should be added. percent_encode Whether the query parameters should be percent encoded. R...
[ "def", "add_get_parameters", "(", "url", ",", "parameters", ",", "percent_encode", "=", "True", ")", ":", "url_parts", "=", "list", "(", "parse", ".", "urlparse", "(", "url", ")", ")", "query", "=", "dict", "(", "parse", ".", "parse_qs", "(", "url_parts"...
Utility function to add GET parameters to an existing URL. Args: parameters A dictionary of the parameters that should be added. percent_encode Whether the query parameters should be percent encoded. Returns: The updated URL.
[ "Utility", "function", "to", "add", "GET", "parameters", "to", "an", "existing", "URL", "." ]
python
train
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1540-L1570
def parse(self, elt, ps, **kw): '''attempt to parse sequentially. No way to know ahead of time what this instance represents. Must be simple type so it can not have attributes nor children, so this isn't too bad. ''' self.setMemberTypeCodes() (nsuri,typeName) = self.che...
[ "def", "parse", "(", "self", ",", "elt", ",", "ps", ",", "*", "*", "kw", ")", ":", "self", ".", "setMemberTypeCodes", "(", ")", "(", "nsuri", ",", "typeName", ")", "=", "self", ".", "checkname", "(", "elt", ",", "ps", ")", "#if (nsuri,typeName) not i...
attempt to parse sequentially. No way to know ahead of time what this instance represents. Must be simple type so it can not have attributes nor children, so this isn't too bad.
[ "attempt", "to", "parse", "sequentially", ".", "No", "way", "to", "know", "ahead", "of", "time", "what", "this", "instance", "represents", ".", "Must", "be", "simple", "type", "so", "it", "can", "not", "have", "attributes", "nor", "children", "so", "this",...
python
train
saltstack/salt
salt/modules/portage_config.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/portage_config.py#L294-L323
def _merge_flags(new_flags, old_flags=None, conf='any'): ''' Merges multiple lists of flags removing duplicates and resolving conflicts giving priority to lasts lists. ''' if not old_flags: old_flags = [] args = [old_flags, new_flags] if conf == 'accept_keywords': tmp = new_f...
[ "def", "_merge_flags", "(", "new_flags", ",", "old_flags", "=", "None", ",", "conf", "=", "'any'", ")", ":", "if", "not", "old_flags", ":", "old_flags", "=", "[", "]", "args", "=", "[", "old_flags", ",", "new_flags", "]", "if", "conf", "==", "'accept_k...
Merges multiple lists of flags removing duplicates and resolving conflicts giving priority to lasts lists.
[ "Merges", "multiple", "lists", "of", "flags", "removing", "duplicates", "and", "resolving", "conflicts", "giving", "priority", "to", "lasts", "lists", "." ]
python
train
python-openxml/python-docx
docx/opc/package.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/package.py#L149-L155
def relate_to(self, part, reltype): """ Return rId key of relationship to *part*, from the existing relationship if there is one, otherwise a newly created one. """ rel = self.rels.get_or_add(reltype, part) return rel.rId
[ "def", "relate_to", "(", "self", ",", "part", ",", "reltype", ")", ":", "rel", "=", "self", ".", "rels", ".", "get_or_add", "(", "reltype", ",", "part", ")", "return", "rel", ".", "rId" ]
Return rId key of relationship to *part*, from the existing relationship if there is one, otherwise a newly created one.
[ "Return", "rId", "key", "of", "relationship", "to", "*", "part", "*", "from", "the", "existing", "relationship", "if", "there", "is", "one", "otherwise", "a", "newly", "created", "one", "." ]
python
train
heitzmann/gdspy
gdspy/__init__.py
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L3834-L3840
def close(self): """ Finalize the GDSII stream library. """ self._outfile.write(struct.pack('>2h', 4, 0x0400)) if self._close: self._outfile.close()
[ "def", "close", "(", "self", ")", ":", "self", ".", "_outfile", ".", "write", "(", "struct", ".", "pack", "(", "'>2h'", ",", "4", ",", "0x0400", ")", ")", "if", "self", ".", "_close", ":", "self", ".", "_outfile", ".", "close", "(", ")" ]
Finalize the GDSII stream library.
[ "Finalize", "the", "GDSII", "stream", "library", "." ]
python
train
edx/XBlock
xblock/mixins.py
https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/mixins.py#L513-L522
def _set_field_if_present(cls, block, name, value, attrs): """Sets the field block.name, if block have such a field.""" if name in block.fields: value = (block.fields[name]).from_string(value) if "none" in attrs and attrs["none"] == "true": setattr(block, name, No...
[ "def", "_set_field_if_present", "(", "cls", ",", "block", ",", "name", ",", "value", ",", "attrs", ")", ":", "if", "name", "in", "block", ".", "fields", ":", "value", "=", "(", "block", ".", "fields", "[", "name", "]", ")", ".", "from_string", "(", ...
Sets the field block.name, if block have such a field.
[ "Sets", "the", "field", "block", ".", "name", "if", "block", "have", "such", "a", "field", "." ]
python
train
Erotemic/utool
utool/util_dev.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L196-L248
def input_timeout(msg='Waiting for input...', timeout=30): """ FIXME: Function does not work quite right yet. Args: msg (str): timeout (int): Returns: ?: ans References: http://stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python http:/...
[ "def", "input_timeout", "(", "msg", "=", "'Waiting for input...'", ",", "timeout", "=", "30", ")", ":", "import", "sys", "import", "select", "import", "time", "ans", "=", "None", "print", "(", "'You have %d seconds to answer!'", "%", "timeout", ")", "print", "...
FIXME: Function does not work quite right yet. Args: msg (str): timeout (int): Returns: ?: ans References: http://stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python http://home.wlu.edu/~levys/software/kbhit.py http://stackoverflow.com...
[ "FIXME", ":", "Function", "does", "not", "work", "quite", "right", "yet", "." ]
python
train
tcalmant/ipopo
pelix/shell/remote.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/remote.py#L565-L587
def _run_interpreter(variables, banner): """ Runs a Python interpreter console and blocks until the user exits it. :param variables: Interpreters variables (locals) :param banner: Start-up banners """ # Script-only imports import code try: import readline import rlcompl...
[ "def", "_run_interpreter", "(", "variables", ",", "banner", ")", ":", "# Script-only imports", "import", "code", "try", ":", "import", "readline", "import", "rlcompleter", "readline", ".", "set_completer", "(", "rlcompleter", ".", "Completer", "(", "variables", ")...
Runs a Python interpreter console and blocks until the user exits it. :param variables: Interpreters variables (locals) :param banner: Start-up banners
[ "Runs", "a", "Python", "interpreter", "console", "and", "blocks", "until", "the", "user", "exits", "it", "." ]
python
train
choldgraf/download
download/download.py
https://github.com/choldgraf/download/blob/26007bb87751ee35791e30e4dfc54dd088bf15e6/download/download.py#L116-L134
def _convert_url_to_downloadable(url): """Convert a url to the proper style depending on its website.""" if 'drive.google.com' in url: # For future support of google drive file_id = url.split('d/')[1].split('/')[0] base_url = 'https://drive.google.com/uc?export=download&id=' out...
[ "def", "_convert_url_to_downloadable", "(", "url", ")", ":", "if", "'drive.google.com'", "in", "url", ":", "# For future support of google drive", "file_id", "=", "url", ".", "split", "(", "'d/'", ")", "[", "1", "]", ".", "split", "(", "'/'", ")", "[", "0", ...
Convert a url to the proper style depending on its website.
[ "Convert", "a", "url", "to", "the", "proper", "style", "depending", "on", "its", "website", "." ]
python
train
uw-it-aca/uw-restclients
restclients/dao_implementation/mock.py
https://github.com/uw-it-aca/uw-restclients/blob/e12dcd32bf5296b6ebdf71798031594afb7852cb/restclients/dao_implementation/mock.py#L307-L321
def read_resp_data(service_name, implementation_name, url, response): """ Read the (DELETE, PATCH, POST, PUT) response body and header if exist. """ RR = _mockdata_path_root(service_name, implementation_name) for resource_dir in app_resource_dirs: path = os.path.join(resource_dir['path'], ...
[ "def", "read_resp_data", "(", "service_name", ",", "implementation_name", ",", "url", ",", "response", ")", ":", "RR", "=", "_mockdata_path_root", "(", "service_name", ",", "implementation_name", ")", "for", "resource_dir", "in", "app_resource_dirs", ":", "path", ...
Read the (DELETE, PATCH, POST, PUT) response body and header if exist.
[ "Read", "the", "(", "DELETE", "PATCH", "POST", "PUT", ")", "response", "body", "and", "header", "if", "exist", "." ]
python
train
mitsei/dlkit
dlkit/json_/repository/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L622-L652
def get_asset_contents_by_genus_type(self, asset_content_genus_type): """Gets an ``AssetContentList`` corresponding to the given asset content genus ``Type`` which does not include asset contents of types derived from the specified ``Type``. In plenary mode, the returned list contains all known asset c...
[ "def", "get_asset_contents_by_genus_type", "(", "self", ",", "asset_content_genus_type", ")", ":", "collection", "=", "JSONClientValidated", "(", "'repository'", ",", "collection", "=", "'Asset'", ",", "runtime", "=", "self", ".", "_runtime", ")", "results", "=", ...
Gets an ``AssetContentList`` corresponding to the given asset content genus ``Type`` which does not include asset contents of types derived from the specified ``Type``. In plenary mode, the returned list contains all known asset contents or an error results. Otherwise, the returned list may contain onl...
[ "Gets", "an", "AssetContentList", "corresponding", "to", "the", "given", "asset", "content", "genus", "Type", "which", "does", "not", "include", "asset", "contents", "of", "types", "derived", "from", "the", "specified", "Type", "." ]
python
train
peterldowns/djoauth2
example/djoauth2example/api/views.py
https://github.com/peterldowns/djoauth2/blob/151c7619d1d7a91d720397cfecf3a29fcc9747a9/example/djoauth2example/api/views.py#L12-L27
def user_info(access_token, request): """ Return basic information about a user. Limited to OAuth clients that have receieved authorization to the 'user_info' scope. """ user = access_token.user data = { 'username': user.username, 'first_name': user.first_name, 'last_name': user.last_name...
[ "def", "user_info", "(", "access_token", ",", "request", ")", ":", "user", "=", "access_token", ".", "user", "data", "=", "{", "'username'", ":", "user", ".", "username", ",", "'first_name'", ":", "user", ".", "first_name", ",", "'last_name'", ":", "user",...
Return basic information about a user. Limited to OAuth clients that have receieved authorization to the 'user_info' scope.
[ "Return", "basic", "information", "about", "a", "user", "." ]
python
train
mila/pyoo
pyoo.py
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1538-L1546
def __set_formulas(self, formulas): """ Sets formulas in this cell range from an iterable. Any cell values can be set using this method. Actual formulas must start with an equal sign. """ array = tuple((self._clean_formula(v),) for v in formulas) self._get_target...
[ "def", "__set_formulas", "(", "self", ",", "formulas", ")", ":", "array", "=", "tuple", "(", "(", "self", ".", "_clean_formula", "(", "v", ")", ",", ")", "for", "v", "in", "formulas", ")", "self", ".", "_get_target", "(", ")", ".", "setFormulaArray", ...
Sets formulas in this cell range from an iterable. Any cell values can be set using this method. Actual formulas must start with an equal sign.
[ "Sets", "formulas", "in", "this", "cell", "range", "from", "an", "iterable", "." ]
python
train
PonteIneptique/flask-github-proxy
flask_github_proxy/__init__.py
https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L113-L141
def request(self, method, url, **kwargs): """ Unified method to make request to the Github API :param method: HTTP Method to use :param url: URL to reach :param kwargs: dictionary of arguments (params for URL parameters, data for post/put data) :return: Response """ ...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "if", "\"data\"", "in", "kwargs", ":", "kwargs", "[", "\"data\"", "]", "=", "json", ".", "dumps", "(", "kwargs", "[", "\"data\"", "]", ")", "kwargs", "[", ...
Unified method to make request to the Github API :param method: HTTP Method to use :param url: URL to reach :param kwargs: dictionary of arguments (params for URL parameters, data for post/put data) :return: Response
[ "Unified", "method", "to", "make", "request", "to", "the", "Github", "API" ]
python
train
jsommers/switchyard
switchyard/lib/socket/socketemu.py
https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L431-L439
def send(self, data, flags=0): ''' Send data on the socket. A call to connect() must have been previously made for this call to succeed. Flags is currently ignored. ''' if self._remote_addr == (None,None): raise sockerr("ENOTCONN: socket not connected") ...
[ "def", "send", "(", "self", ",", "data", ",", "flags", "=", "0", ")", ":", "if", "self", ".", "_remote_addr", "==", "(", "None", ",", "None", ")", ":", "raise", "sockerr", "(", "\"ENOTCONN: socket not connected\"", ")", "return", "self", ".", "_send", ...
Send data on the socket. A call to connect() must have been previously made for this call to succeed. Flags is currently ignored.
[ "Send", "data", "on", "the", "socket", ".", "A", "call", "to", "connect", "()", "must", "have", "been", "previously", "made", "for", "this", "call", "to", "succeed", ".", "Flags", "is", "currently", "ignored", "." ]
python
train
nanoporetech/ont_fast5_api
ont_fast5_api/helpers.py
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/helpers.py#L26-L41
def compare_hdf_files(file1, file2): """ Compare two hdf files. :param file1: First file to compare. :param file2: Second file to compare. :returns True if they are the same. """ data1 = FileToDict() data2 = FileToDict() scanner1 = data1.scan scanner2 = data2.scan with h5py.File...
[ "def", "compare_hdf_files", "(", "file1", ",", "file2", ")", ":", "data1", "=", "FileToDict", "(", ")", "data2", "=", "FileToDict", "(", ")", "scanner1", "=", "data1", ".", "scan", "scanner2", "=", "data2", ".", "scan", "with", "h5py", ".", "File", "("...
Compare two hdf files. :param file1: First file to compare. :param file2: Second file to compare. :returns True if they are the same.
[ "Compare", "two", "hdf", "files", ".", ":", "param", "file1", ":", "First", "file", "to", "compare", ".", ":", "param", "file2", ":", "Second", "file", "to", "compare", "." ]
python
train
dereneaton/ipyrad
ipyrad/plotting/coverageplots.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/plotting/coverageplots.py#L17-L86
def depthplot(data, samples=None, dims=(None,None), canvas=(None,None), xmax=50, log=False, outprefix=None, use_maxdepth=False): """ plots histogram of coverages across clusters""" ## select samples to be plotted, requires depths info if not samples: samples = data.samples.keys() ...
[ "def", "depthplot", "(", "data", ",", "samples", "=", "None", ",", "dims", "=", "(", "None", ",", "None", ")", ",", "canvas", "=", "(", "None", ",", "None", ")", ",", "xmax", "=", "50", ",", "log", "=", "False", ",", "outprefix", "=", "None", "...
plots histogram of coverages across clusters
[ "plots", "histogram", "of", "coverages", "across", "clusters" ]
python
valid
aetros/aetros-cli
aetros/backend.py
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L65-L101
def Popen(*args, **kwargs): """ Executes a command using subprocess.Popen and redirects output to AETROS and stdout. Parses stdout as well for stdout API calls. Use read_line argument to read stdout of command's stdout line by line. Use returned process stdin to communicate with the command. :...
[ "def", "Popen", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "read_line", "=", "None", "if", "'read_line'", "in", "kwargs", ":", "read_line", "=", "kwargs", "[", "'read_line'", "]", "del", "kwargs", "[", "'read_line'", "]", "p", "=", "subproces...
Executes a command using subprocess.Popen and redirects output to AETROS and stdout. Parses stdout as well for stdout API calls. Use read_line argument to read stdout of command's stdout line by line. Use returned process stdin to communicate with the command. :return: subprocess.Popen
[ "Executes", "a", "command", "using", "subprocess", ".", "Popen", "and", "redirects", "output", "to", "AETROS", "and", "stdout", ".", "Parses", "stdout", "as", "well", "for", "stdout", "API", "calls", "." ]
python
train
linkhub-sdk/popbill.py
popbill/htTaxinvoiceService.py
https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/htTaxinvoiceService.py#L100-L137
def search(self, CorpNum, JobID, Type, TaxType, PurposeType, TaxRegIDType, TaxRegIDYN, TaxRegID, Page, PerPage, Order, UserID=None): """ 수집 결과 조회 args CorpNum : 팝빌회원 사업자번호 JobID : 작업아이디 Type : 문서형태 배열, N-일반전자세금계산서, M-수정전자세금계산서 ...
[ "def", "search", "(", "self", ",", "CorpNum", ",", "JobID", ",", "Type", ",", "TaxType", ",", "PurposeType", ",", "TaxRegIDType", ",", "TaxRegIDYN", ",", "TaxRegID", ",", "Page", ",", "PerPage", ",", "Order", ",", "UserID", "=", "None", ")", ":", "if",...
수집 결과 조회 args CorpNum : 팝빌회원 사업자번호 JobID : 작업아이디 Type : 문서형태 배열, N-일반전자세금계산서, M-수정전자세금계산서 TaxType : 과세형태 배열, T-과세, N-면세, Z-영세 PurposeType : 영수/청구, R-영수, C-청구, N-없음 TaxRegIDType : 종사업장번호 사업자유형, S-공급자, B-공급받는자, T-수...
[ "수집", "결과", "조회", "args", "CorpNum", ":", "팝빌회원", "사업자번호", "JobID", ":", "작업아이디", "Type", ":", "문서형태", "배열", "N", "-", "일반전자세금계산서", "M", "-", "수정전자세금계산서", "TaxType", ":", "과세형태", "배열", "T", "-", "과세", "N", "-", "면세", "Z", "-", "영세", "PurposeType", ...
python
train
OpenKMIP/PyKMIP
kmip/pie/objects.py
https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/pie/objects.py#L424-L493
def key_wrapping_data(self): """ Retrieve all of the relevant key wrapping data fields and return them as a dictionary. """ key_wrapping_data = {} encryption_key_info = { 'unique_identifier': self._kdw_eki_unique_identifier, 'cryptographic_paramete...
[ "def", "key_wrapping_data", "(", "self", ")", ":", "key_wrapping_data", "=", "{", "}", "encryption_key_info", "=", "{", "'unique_identifier'", ":", "self", ".", "_kdw_eki_unique_identifier", ",", "'cryptographic_parameters'", ":", "{", "'block_cipher_mode'", ":", "sel...
Retrieve all of the relevant key wrapping data fields and return them as a dictionary.
[ "Retrieve", "all", "of", "the", "relevant", "key", "wrapping", "data", "fields", "and", "return", "them", "as", "a", "dictionary", "." ]
python
test
taxjar/taxjar-python
taxjar/client.py
https://github.com/taxjar/taxjar-python/blob/be9b30d7dc968d24e066c7c133849fee180f8d95/taxjar/client.py#L121-L124
def validate_address(self, address_deets): """Validates a customer address and returns back a collection of address matches.""" request = self._post('addresses/validate', address_deets) return self.responder(request)
[ "def", "validate_address", "(", "self", ",", "address_deets", ")", ":", "request", "=", "self", ".", "_post", "(", "'addresses/validate'", ",", "address_deets", ")", "return", "self", ".", "responder", "(", "request", ")" ]
Validates a customer address and returns back a collection of address matches.
[ "Validates", "a", "customer", "address", "and", "returns", "back", "a", "collection", "of", "address", "matches", "." ]
python
train
StackStorm/pybind
pybind/slxos/v17s_1_02/isis_state/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/isis_state/__init__.py#L221-L244
def _set_ipv4_routes(self, v, load=False): """ Setter method for ipv4_routes, mapped from YANG variable /isis_state/ipv4_routes (container) If this variable is read-only (config: false) in the source YANG file, then _set_ipv4_routes is considered as a private method. Backends looking to populate thi...
[ "def", "_set_ipv4_routes", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "ba...
Setter method for ipv4_routes, mapped from YANG variable /isis_state/ipv4_routes (container) If this variable is read-only (config: false) in the source YANG file, then _set_ipv4_routes is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_ip...
[ "Setter", "method", "for", "ipv4_routes", "mapped", "from", "YANG", "variable", "/", "isis_state", "/", "ipv4_routes", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YAN...
python
train
bachiraoun/pyrep
OldRepository.py
https://github.com/bachiraoun/pyrep/blob/0449bf2fad3e3e8dda855d4686a8869efeefd433/OldRepository.py#L999-L1060
def create_package(self, path=None, name=None, mode=None): """ Create a tar file package of all the repository files and directories. Only files and directories that are stored in the repository info are stored in the package tar file. **N.B. On some systems packaging requires r...
[ "def", "create_package", "(", "self", ",", "path", "=", "None", ",", "name", "=", "None", ",", "mode", "=", "None", ")", ":", "# check mode", "assert", "mode", "in", "(", "None", ",", "'w'", ",", "'w:'", ",", "'w:gz'", ",", "'w:bz2'", ")", ",", "'u...
Create a tar file package of all the repository files and directories. Only files and directories that are stored in the repository info are stored in the package tar file. **N.B. On some systems packaging requires root permissions.** :Parameters: #. path (None, string): Th...
[ "Create", "a", "tar", "file", "package", "of", "all", "the", "repository", "files", "and", "directories", ".", "Only", "files", "and", "directories", "that", "are", "stored", "in", "the", "repository", "info", "are", "stored", "in", "the", "package", "tar", ...
python
valid
saltstack/salt
salt/states/highstate_doc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/highstate_doc.py#L12-L45
def note(name, source=None, contents=None, **kwargs): ''' Add content to a document generated using `highstate_doc.render`. This state does not preform any tasks on the host. It only is used in highstate_doc lowstate proccessers to include extra documents. .. code-block:: yaml {{sls}} exa...
[ "def", "note", "(", "name", ",", "source", "=", "None", ",", "contents", "=", "None", ",", "*", "*", "kwargs", ")", ":", "comment", "=", "''", "if", "source", ":", "comment", "+=", "'include file: {0}\\n'", ".", "format", "(", "source", ")", "if", "c...
Add content to a document generated using `highstate_doc.render`. This state does not preform any tasks on the host. It only is used in highstate_doc lowstate proccessers to include extra documents. .. code-block:: yaml {{sls}} example note: highstate_doc.note: - name:...
[ "Add", "content", "to", "a", "document", "generated", "using", "highstate_doc", ".", "render", "." ]
python
train
jeroyang/cateye
cateye/cateye.py
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L278-L308
def search(index, query, snippet_folder=SNIPPET_FOLDER, term_freq=term_freq): """ The highest level of search function """ fallback_log = [] code_list = [] tokens = tokenize(query) tokens, abbr_log = abbr_expand(tokens) tokens, correct_log = correct(tokens, term_freq) tokens = lemmat...
[ "def", "search", "(", "index", ",", "query", ",", "snippet_folder", "=", "SNIPPET_FOLDER", ",", "term_freq", "=", "term_freq", ")", ":", "fallback_log", "=", "[", "]", "code_list", "=", "[", "]", "tokens", "=", "tokenize", "(", "query", ")", "tokens", ",...
The highest level of search function
[ "The", "highest", "level", "of", "search", "function" ]
python
train
project-ncl/pnc-cli
pnc_cli/swagger_client/models/build_set_status_changed_event.py
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/build_set_status_changed_event.py#L250-L264
def old_status(self, old_status): """ Sets the old_status of this BuildSetStatusChangedEvent. :param old_status: The old_status of this BuildSetStatusChangedEvent. :type: str """ allowed_values = ["NEW", "DONE", "REJECTED"] if old_status not in allowed_values: ...
[ "def", "old_status", "(", "self", ",", "old_status", ")", ":", "allowed_values", "=", "[", "\"NEW\"", ",", "\"DONE\"", ",", "\"REJECTED\"", "]", "if", "old_status", "not", "in", "allowed_values", ":", "raise", "ValueError", "(", "\"Invalid value for `old_status` (...
Sets the old_status of this BuildSetStatusChangedEvent. :param old_status: The old_status of this BuildSetStatusChangedEvent. :type: str
[ "Sets", "the", "old_status", "of", "this", "BuildSetStatusChangedEvent", "." ]
python
train
pandas-dev/pandas
pandas/io/stata.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L367-L461
def _datetime_to_stata_elapsed_vec(dates, fmt): """ Convert from datetime to SIF. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series Series or array containing datetime.datetime or datetime64[ns] to convert to the Stata Internal Format given by fmt fmt :...
[ "def", "_datetime_to_stata_elapsed_vec", "(", "dates", ",", "fmt", ")", ":", "index", "=", "dates", ".", "index", "NS_PER_DAY", "=", "24", "*", "3600", "*", "1000", "*", "1000", "*", "1000", "US_PER_DAY", "=", "NS_PER_DAY", "/", "1000", "def", "parse_dates...
Convert from datetime to SIF. http://www.stata.com/help.cgi?datetime Parameters ---------- dates : Series Series or array containing datetime.datetime or datetime64[ns] to convert to the Stata Internal Format given by fmt fmt : str The format to convert to. Can be, tc, td, tw, t...
[ "Convert", "from", "datetime", "to", "SIF", ".", "http", ":", "//", "www", ".", "stata", ".", "com", "/", "help", ".", "cgi?datetime" ]
python
train
saltstack/salt
salt/minion.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/minion.py#L847-L880
def gen_modules(self, initial_load=False): ''' Tell the minion to reload the execution modules CLI Example: .. code-block:: bash salt '*' sys.reload_modules ''' self.opts['pillar'] = salt.pillar.get_pillar( self.opts, self.opts['grai...
[ "def", "gen_modules", "(", "self", ",", "initial_load", "=", "False", ")", ":", "self", ".", "opts", "[", "'pillar'", "]", "=", "salt", ".", "pillar", ".", "get_pillar", "(", "self", ".", "opts", ",", "self", ".", "opts", "[", "'grains'", "]", ",", ...
Tell the minion to reload the execution modules CLI Example: .. code-block:: bash salt '*' sys.reload_modules
[ "Tell", "the", "minion", "to", "reload", "the", "execution", "modules" ]
python
train
crs4/pydoop
pydoop/hadut.py
https://github.com/crs4/pydoop/blob/f375be2a06f9c67eaae3ce6f605195dbca143b2b/pydoop/hadut.py#L512-L520
def set_exe(self, pipes_code): """ Dump launcher code to the distributed file system. """ if not self.output: raise RuntimeError("no output directory, can't create launcher") parent = hdfs.path.dirname(hdfs.path.abspath(self.output.rstrip("/"))) self.exe = hdf...
[ "def", "set_exe", "(", "self", ",", "pipes_code", ")", ":", "if", "not", "self", ".", "output", ":", "raise", "RuntimeError", "(", "\"no output directory, can't create launcher\"", ")", "parent", "=", "hdfs", ".", "path", ".", "dirname", "(", "hdfs", ".", "p...
Dump launcher code to the distributed file system.
[ "Dump", "launcher", "code", "to", "the", "distributed", "file", "system", "." ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/process.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/process.py#L1355-L1395
def search(self, pattern, minAddr = None, maxAddr = None): """ Search for the given pattern within the process memory. @type pattern: str, compat.unicode or L{Pattern} @param pattern: Pattern to search for. It may be a byte string, a Unicode string, or an instance of ...
[ "def", "search", "(", "self", ",", "pattern", ",", "minAddr", "=", "None", ",", "maxAddr", "=", "None", ")", ":", "if", "isinstance", "(", "pattern", ",", "str", ")", ":", "return", "self", ".", "search_bytes", "(", "pattern", ",", "minAddr", ",", "m...
Search for the given pattern within the process memory. @type pattern: str, compat.unicode or L{Pattern} @param pattern: Pattern to search for. It may be a byte string, a Unicode string, or an instance of L{Pattern}. The following L{Pattern} subclasses are provided...
[ "Search", "for", "the", "given", "pattern", "within", "the", "process", "memory", "." ]
python
train
mabuchilab/QNET
src/qnet/algebra/core/abstract_algebra.py
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_algebra.py#L262-L295
def show_rules(cls, *names, attr=None): """Print algebraic rules used by :class:`create` Print a summary of the algebraic rules with the given names, or all rules if not names a given. Args: names (str): Names of rules to show attr (None or str): Name of the cla...
[ "def", "show_rules", "(", "cls", ",", "*", "names", ",", "attr", "=", "None", ")", ":", "from", "qnet", ".", "printing", "import", "srepr", "try", ":", "if", "attr", "is", "None", ":", "attr", "=", "cls", ".", "_rules_attr", "(", ")", "rules", "=",...
Print algebraic rules used by :class:`create` Print a summary of the algebraic rules with the given names, or all rules if not names a given. Args: names (str): Names of rules to show attr (None or str): Name of the class attribute from which to get the ...
[ "Print", "algebraic", "rules", "used", "by", ":", "class", ":", "create" ]
python
train
ARMmbed/icetea
icetea_lib/tools/file/SessionFiles.py
https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/tools/file/SessionFiles.py#L218-L228
def _ends_with(self, string_to_edit, end): # pylint: disable=no-self-use """ Check if string ends with characters in end, if not merge end to string. :param string_to_edit: string to check and edit. :param end: str :return: string_to_edit or string_to_edit + end """ ...
[ "def", "_ends_with", "(", "self", ",", "string_to_edit", ",", "end", ")", ":", "# pylint: disable=no-self-use", "if", "not", "string_to_edit", ".", "endswith", "(", "end", ")", ":", "return", "string_to_edit", "+", "end", "return", "string_to_edit" ]
Check if string ends with characters in end, if not merge end to string. :param string_to_edit: string to check and edit. :param end: str :return: string_to_edit or string_to_edit + end
[ "Check", "if", "string", "ends", "with", "characters", "in", "end", "if", "not", "merge", "end", "to", "string", "." ]
python
train
Microsoft/nni
examples/trials/kaggle-tgs-salt/lovasz_losses.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/kaggle-tgs-salt/lovasz_losses.py#L134-L146
def flatten_binary_scores(scores, labels, ignore=None): """ Flattens predictions in the batch (binary case) Remove labels equal to 'ignore' """ scores = scores.view(-1) labels = labels.view(-1) if ignore is None: return scores, labels valid = (labels != ignore) vscores = scor...
[ "def", "flatten_binary_scores", "(", "scores", ",", "labels", ",", "ignore", "=", "None", ")", ":", "scores", "=", "scores", ".", "view", "(", "-", "1", ")", "labels", "=", "labels", ".", "view", "(", "-", "1", ")", "if", "ignore", "is", "None", ":...
Flattens predictions in the batch (binary case) Remove labels equal to 'ignore'
[ "Flattens", "predictions", "in", "the", "batch", "(", "binary", "case", ")", "Remove", "labels", "equal", "to", "ignore" ]
python
train
refenv/cijoe
modules/cij/fio.py
https://github.com/refenv/cijoe/blob/21d7b2ed4ff68e0a1457e7df2db27f6334f1a379/modules/cij/fio.py#L113-L118
def start(self): """Run FIO job in thread""" self.__thread = Threads(target=self.run, args=(True, True, False)) self.__thread.setDaemon(True) self.__thread.start()
[ "def", "start", "(", "self", ")", ":", "self", ".", "__thread", "=", "Threads", "(", "target", "=", "self", ".", "run", ",", "args", "=", "(", "True", ",", "True", ",", "False", ")", ")", "self", ".", "__thread", ".", "setDaemon", "(", "True", ")...
Run FIO job in thread
[ "Run", "FIO", "job", "in", "thread" ]
python
valid
tensorflow/tensor2tensor
tensor2tensor/layers/common_layers.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_layers.py#L715-L721
def noam_norm(x, epsilon=1.0, name=None): """One version of layer normalization.""" with tf.name_scope(name, default_name="noam_norm", values=[x]): shape = x.get_shape() ndims = len(shape) return (tf.nn.l2_normalize(x, ndims - 1, epsilon=epsilon) * tf.sqrt( to_float(shape[-1])))
[ "def", "noam_norm", "(", "x", ",", "epsilon", "=", "1.0", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ",", "default_name", "=", "\"noam_norm\"", ",", "values", "=", "[", "x", "]", ")", ":", "shape", "=", "x", ...
One version of layer normalization.
[ "One", "version", "of", "layer", "normalization", "." ]
python
train
praekeltfoundation/molo
molo/core/api/endpoints.py
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/endpoints.py#L48-L74
def get_queryset(self): ''' This is overwritten in order to not exclude drafts and pages submitted for moderation ''' request = self.request # Allow pages to be filtered to a specific type if 'type' not in request.GET: model = Page else: ...
[ "def", "get_queryset", "(", "self", ")", ":", "request", "=", "self", ".", "request", "# Allow pages to be filtered to a specific type", "if", "'type'", "not", "in", "request", ".", "GET", ":", "model", "=", "Page", "else", ":", "model_name", "=", "request", "...
This is overwritten in order to not exclude drafts and pages submitted for moderation
[ "This", "is", "overwritten", "in", "order", "to", "not", "exclude", "drafts", "and", "pages", "submitted", "for", "moderation" ]
python
train
pyoceans/python-ctd
ctd/read.py
https://github.com/pyoceans/python-ctd/blob/fa9a9d02da3dfed6d1d60db0e52bbab52adfe666/ctd/read.py#L335-L392
def from_cnv(fname): """ DataFrame constructor to open Seabird CTD CNV-ASCII format. Examples -------- >>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") >>> cast = ctd.from_cnv(data_path.joinpath('CTD_big.cnv.bz2')) >>> d...
[ "def", "from_cnv", "(", "fname", ")", ":", "f", "=", "_read_file", "(", "fname", ")", "metadata", "=", "_parse_seabird", "(", "f", ".", "readlines", "(", ")", ",", "ftype", "=", "\"cnv\"", ")", "f", ".", "seek", "(", "0", ")", "df", "=", "pd", "....
DataFrame constructor to open Seabird CTD CNV-ASCII format. Examples -------- >>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") >>> cast = ctd.from_cnv(data_path.joinpath('CTD_big.cnv.bz2')) >>> downcast, upcast = cast.split() ...
[ "DataFrame", "constructor", "to", "open", "Seabird", "CTD", "CNV", "-", "ASCII", "format", "." ]
python
train
ska-sa/spead2
spead2/__init__.py
https://github.com/ska-sa/spead2/blob/cac95fd01d8debaa302d2691bd26da64b7828bc6/spead2/__init__.py#L262-L282
def dynamic_shape(self, max_elements): """Determine the dynamic shape, given incoming data that is big enough to hold `max_elements` elements. """ known = 1 unknown_pos = -1 for i, x in enumerate(self.shape): if x is not None: known *= x ...
[ "def", "dynamic_shape", "(", "self", ",", "max_elements", ")", ":", "known", "=", "1", "unknown_pos", "=", "-", "1", "for", "i", ",", "x", "in", "enumerate", "(", "self", ".", "shape", ")", ":", "if", "x", "is", "not", "None", ":", "known", "*=", ...
Determine the dynamic shape, given incoming data that is big enough to hold `max_elements` elements.
[ "Determine", "the", "dynamic", "shape", "given", "incoming", "data", "that", "is", "big", "enough", "to", "hold", "max_elements", "elements", "." ]
python
train
SheffieldML/GPy
GPy/likelihoods/binomial.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/likelihoods/binomial.py#L78-L102
def dlogpdf_dlink(self, inv_link_f, y, Y_metadata=None): """ Gradient of the pdf at y, given inverse link of f w.r.t inverse link of f. .. math:: \\frac{d^{2}\\ln p(y_{i}|\\lambda(f_{i}))}{d\\lambda(f)^{2}} = \\frac{y_{i}}{\\lambda(f)} - \\frac{(N-y_{i})}{(1-\\lambda(f))} :...
[ "def", "dlogpdf_dlink", "(", "self", ",", "inv_link_f", ",", "y", ",", "Y_metadata", "=", "None", ")", ":", "N", "=", "Y_metadata", "[", "'trials'", "]", "np", ".", "testing", ".", "assert_array_equal", "(", "N", ".", "shape", ",", "y", ".", "shape", ...
Gradient of the pdf at y, given inverse link of f w.r.t inverse link of f. .. math:: \\frac{d^{2}\\ln p(y_{i}|\\lambda(f_{i}))}{d\\lambda(f)^{2}} = \\frac{y_{i}}{\\lambda(f)} - \\frac{(N-y_{i})}{(1-\\lambda(f))} :param inv_link_f: latent variables inverse link of f. :type inv_link_...
[ "Gradient", "of", "the", "pdf", "at", "y", "given", "inverse", "link", "of", "f", "w", ".", "r", ".", "t", "inverse", "link", "of", "f", "." ]
python
train
ThreatResponse/margaritashotgun
margaritashotgun/repository.py
https://github.com/ThreatResponse/margaritashotgun/blob/6dee53ef267959b214953439968244cc46a19690/margaritashotgun/repository.py#L145-L165
def fetch(self, kernel_version, manifest_type): """ Search repository for kernel module matching kernel_version :type kernel_version: str :param kernel_version: kernel version to search repository on :type manifest_type: str :param manifest_type: kernel module manifest t...
[ "def", "fetch", "(", "self", ",", "kernel_version", ",", "manifest_type", ")", ":", "metadata", "=", "self", ".", "get_metadata", "(", ")", "logger", ".", "debug", "(", "\"parsed metadata: {0}\"", ".", "format", "(", "metadata", ")", ")", "manifest", "=", ...
Search repository for kernel module matching kernel_version :type kernel_version: str :param kernel_version: kernel version to search repository on :type manifest_type: str :param manifest_type: kernel module manifest to search on
[ "Search", "repository", "for", "kernel", "module", "matching", "kernel_version" ]
python
train
tariqdaouda/pyGeno
pyGeno/Exon.py
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/Exon.py#L138-L143
def pluck(self) : """Returns a plucked object. Plucks the exon off the tree, set the value of self.transcript into str(self.transcript). This effectively disconnects the object and makes it much more lighter in case you'd like to pickle it""" e = copy.copy(self) e.transcript = str(self.transcript) return e
[ "def", "pluck", "(", "self", ")", ":", "e", "=", "copy", ".", "copy", "(", "self", ")", "e", ".", "transcript", "=", "str", "(", "self", ".", "transcript", ")", "return", "e" ]
Returns a plucked object. Plucks the exon off the tree, set the value of self.transcript into str(self.transcript). This effectively disconnects the object and makes it much more lighter in case you'd like to pickle it
[ "Returns", "a", "plucked", "object", ".", "Plucks", "the", "exon", "off", "the", "tree", "set", "the", "value", "of", "self", ".", "transcript", "into", "str", "(", "self", ".", "transcript", ")", ".", "This", "effectively", "disconnects", "the", "object",...
python
train
EmbodiedCognition/pagoda
pagoda/skeleton.py
https://github.com/EmbodiedCognition/pagoda/blob/8892f847026d98aba8646ecbc4589397e6dec7bd/pagoda/skeleton.py#L319-L338
def enable_motors(self, max_force): '''Enable the joint motors in this skeleton. This method sets the maximum force that can be applied by each joint to attain the desired target velocities. It also enables torque feedback for all joint motors. Parameters ---------- ...
[ "def", "enable_motors", "(", "self", ",", "max_force", ")", ":", "for", "joint", "in", "self", ".", "joints", ":", "amotor", "=", "getattr", "(", "joint", ",", "'amotor'", ",", "joint", ")", "amotor", ".", "max_forces", "=", "max_force", "if", "max_force...
Enable the joint motors in this skeleton. This method sets the maximum force that can be applied by each joint to attain the desired target velocities. It also enables torque feedback for all joint motors. Parameters ---------- max_force : float The maximum ...
[ "Enable", "the", "joint", "motors", "in", "this", "skeleton", "." ]
python
valid
saltstack/salt
salt/states/boto_vpc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_vpc.py#L1458-L1534
def accept_vpc_peering_connection(name=None, conn_id=None, conn_name=None, region=None, key=None, keyid=None, profile=None): ''' Accept a VPC pending requested peering connection between two VPCs. name Name of this state conn_id The connection ID to ac...
[ "def", "accept_vpc_peering_connection", "(", "name", "=", "None", ",", "conn_id", "=", "None", ",", "conn_name", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "log", ...
Accept a VPC pending requested peering connection between two VPCs. name Name of this state conn_id The connection ID to accept. Exclusive with conn_name. String type. conn_name The name of the VPC peering connection to accept. Exclusive with conn_id. String type. region ...
[ "Accept", "a", "VPC", "pending", "requested", "peering", "connection", "between", "two", "VPCs", "." ]
python
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8301-L8306
def cornersphere(self, x): """Sphere (squared norm) test objective function constraint to the corner""" nconstr = len(x) - 0 if any(x[:nconstr] < 1): return np.NaN return sum(x**2) - nconstr
[ "def", "cornersphere", "(", "self", ",", "x", ")", ":", "nconstr", "=", "len", "(", "x", ")", "-", "0", "if", "any", "(", "x", "[", ":", "nconstr", "]", "<", "1", ")", ":", "return", "np", ".", "NaN", "return", "sum", "(", "x", "**", "2", "...
Sphere (squared norm) test objective function constraint to the corner
[ "Sphere", "(", "squared", "norm", ")", "test", "objective", "function", "constraint", "to", "the", "corner" ]
python
train
markovmodel/msmtools
msmtools/analysis/dense/pcca.py
https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/analysis/dense/pcca.py#L322-L457
def pcca(P, m): """ PCCA+ spectral clustering method with optimized memberships [1]_ Clusters the first m eigenvectors of a transition matrix in order to cluster the states. This function does not assume that the transition matrix is fully connected. Disconnected sets will automatically define the ...
[ "def", "pcca", "(", "P", ",", "m", ")", ":", "# imports", "from", "msmtools", ".", "estimation", "import", "connected_sets", "from", "msmtools", ".", "analysis", "import", "eigenvalues", ",", "is_transition_matrix", ",", "hitting_probability", "# validate input", ...
PCCA+ spectral clustering method with optimized memberships [1]_ Clusters the first m eigenvectors of a transition matrix in order to cluster the states. This function does not assume that the transition matrix is fully connected. Disconnected sets will automatically define the first metastable states, wit...
[ "PCCA", "+", "spectral", "clustering", "method", "with", "optimized", "memberships", "[", "1", "]", "_" ]
python
train
census-instrumentation/opencensus-python
contrib/opencensus-ext-pymongo/opencensus/ext/pymongo/trace.py
https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/contrib/opencensus-ext-pymongo/opencensus/ext/pymongo/trace.py#L30-L33
def trace_integration(tracer=None): """Integrate with pymongo to trace it using event listener.""" log.info('Integrated module: {}'.format(MODULE_NAME)) monitoring.register(MongoCommandListener(tracer=tracer))
[ "def", "trace_integration", "(", "tracer", "=", "None", ")", ":", "log", ".", "info", "(", "'Integrated module: {}'", ".", "format", "(", "MODULE_NAME", ")", ")", "monitoring", ".", "register", "(", "MongoCommandListener", "(", "tracer", "=", "tracer", ")", ...
Integrate with pymongo to trace it using event listener.
[ "Integrate", "with", "pymongo", "to", "trace", "it", "using", "event", "listener", "." ]
python
train
alex-kostirin/pyatomac
atomac/AXClasses.py
https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/AXClasses.py#L761-L765
def _generateFind(self, **kwargs): """Generator which yields matches on AXChildren.""" for needle in self._generateChildren(): if needle._match(**kwargs): yield needle
[ "def", "_generateFind", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "needle", "in", "self", ".", "_generateChildren", "(", ")", ":", "if", "needle", ".", "_match", "(", "*", "*", "kwargs", ")", ":", "yield", "needle" ]
Generator which yields matches on AXChildren.
[ "Generator", "which", "yields", "matches", "on", "AXChildren", "." ]
python
valid
TurboGears/gearbox
gearbox/commands/setup_app.py
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commands/setup_app.py#L110-L118
def _import_module(self, s): """ Import a module. """ mod = __import__(s) parts = s.split('.') for part in parts[1:]: mod = getattr(mod, part) return mod
[ "def", "_import_module", "(", "self", ",", "s", ")", ":", "mod", "=", "__import__", "(", "s", ")", "parts", "=", "s", ".", "split", "(", "'.'", ")", "for", "part", "in", "parts", "[", "1", ":", "]", ":", "mod", "=", "getattr", "(", "mod", ",", ...
Import a module.
[ "Import", "a", "module", "." ]
python
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/rbac_authorization_v1_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/rbac_authorization_v1_api.py#L2215-L2243
def list_role_for_all_namespaces(self, **kwargs): # noqa: E501 """list_role_for_all_namespaces # noqa: E501 list or watch objects of kind Role # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True ...
[ "def", "list_role_for_all_namespaces", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "list_role_for_...
list_role_for_all_namespaces # noqa: E501 list or watch objects of kind Role # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_role_for_all_namespaces(async_req=True) >>>...
[ "list_role_for_all_namespaces", "#", "noqa", ":", "E501" ]
python
train
numenta/nupic
src/nupic/swarming/hypersearch/particle.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/particle.py#L332-L366
def copyVarStatesFrom(self, particleState, varNames): """Copy specific variables from particleState into this particle. Parameters: -------------------------------------------------------------- particleState: dict produced by a particle's getState() method varNames: which variab...
[ "def", "copyVarStatesFrom", "(", "self", ",", "particleState", ",", "varNames", ")", ":", "# Set this to false if you don't want the variable to move anymore", "# after we set the state", "allowedToMove", "=", "True", "for", "varName", "in", "particleState", "[", "'varStates...
Copy specific variables from particleState into this particle. Parameters: -------------------------------------------------------------- particleState: dict produced by a particle's getState() method varNames: which variables to copy
[ "Copy", "specific", "variables", "from", "particleState", "into", "this", "particle", "." ]
python
valid
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/collections/collection.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/collection.py#L197-L209
def draw(self, mode=None): """ Draw collection """ if self._need_update: self._update() program = self._programs[0] mode = mode or self._mode if self._indices_list is not None: program.draw(mode, self._indices_buffer) else: program.d...
[ "def", "draw", "(", "self", ",", "mode", "=", "None", ")", ":", "if", "self", ".", "_need_update", ":", "self", ".", "_update", "(", ")", "program", "=", "self", ".", "_programs", "[", "0", "]", "mode", "=", "mode", "or", "self", ".", "_mode", "i...
Draw collection
[ "Draw", "collection" ]
python
train
yyuu/botornado
boto/s3/key.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/s3/key.py#L1143-L1169
def get_torrent_file(self, fp, headers=None, cb=None, num_cb=10): """ Get a torrent file (see to get_file) :type fp: file :param fp: The file pointer of where to put the torrent :type headers: dict :param headers: Headers to be passed :type cb: function ...
[ "def", "get_torrent_file", "(", "self", ",", "fp", ",", "headers", "=", "None", ",", "cb", "=", "None", ",", "num_cb", "=", "10", ")", ":", "return", "self", ".", "get_file", "(", "fp", ",", "headers", ",", "cb", ",", "num_cb", ",", "torrent", "=",...
Get a torrent file (see to get_file) :type fp: file :param fp: The file pointer of where to put the torrent :type headers: dict :param headers: Headers to be passed :type cb: function :param cb: a callback function that will be called to report progr...
[ "Get", "a", "torrent", "file", "(", "see", "to", "get_file", ")" ]
python
train
SystemRDL/systemrdl-compiler
systemrdl/core/properties.py
https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/properties.py#L1198-L1208
def get_default(self, node): """ Unless specified otherwise, intr fields are implicitly stickybit """ if node.inst.properties.get("intr", False): # Interrupt is set! # Default is implicitly stickybit, unless the mutually-exclusive # sticky property was...
[ "def", "get_default", "(", "self", ",", "node", ")", ":", "if", "node", ".", "inst", ".", "properties", ".", "get", "(", "\"intr\"", ",", "False", ")", ":", "# Interrupt is set!", "# Default is implicitly stickybit, unless the mutually-exclusive", "# sticky property w...
Unless specified otherwise, intr fields are implicitly stickybit
[ "Unless", "specified", "otherwise", "intr", "fields", "are", "implicitly", "stickybit" ]
python
train
DerMitch/fritzbox-smarthome
fritzhome/fritz.py
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L83-L87
def calculate_response(self, challenge, password): """Calculate response for the challenge-response authentication""" to_hash = (challenge + "-" + password).encode("UTF-16LE") hashed = hashlib.md5(to_hash).hexdigest() return "{0}-{1}".format(challenge, hashed)
[ "def", "calculate_response", "(", "self", ",", "challenge", ",", "password", ")", ":", "to_hash", "=", "(", "challenge", "+", "\"-\"", "+", "password", ")", ".", "encode", "(", "\"UTF-16LE\"", ")", "hashed", "=", "hashlib", ".", "md5", "(", "to_hash", ")...
Calculate response for the challenge-response authentication
[ "Calculate", "response", "for", "the", "challenge", "-", "response", "authentication" ]
python
train
devricks/soft_drf
soft_drf/api/routers/__init__.py
https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/routers/__init__.py#L36-L78
def register_nested( self, parent_prefix, prefix, viewset, base_name=None, parent_lookup_name=None, depth_level=1 ): """ Register a nested viewset wihtout worrying of instantiate a nested router for registry. """ kwargs = { 'trailing_slash'...
[ "def", "register_nested", "(", "self", ",", "parent_prefix", ",", "prefix", ",", "viewset", ",", "base_name", "=", "None", ",", "parent_lookup_name", "=", "None", ",", "depth_level", "=", "1", ")", ":", "kwargs", "=", "{", "'trailing_slash'", ":", "bool", ...
Register a nested viewset wihtout worrying of instantiate a nested router for registry.
[ "Register", "a", "nested", "viewset", "wihtout", "worrying", "of", "instantiate", "a", "nested", "router", "for", "registry", "." ]
python
train
gem/oq-engine
openquake/commonlib/readinput.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1113-L1142
def get_pmap_from_nrml(oqparam, fname): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fname: an XML file containing hazard curves :returns: site mesh, curve array """ hcurves_by_imt = {} oqparam.hazard_imtls = imtls = {} ...
[ "def", "get_pmap_from_nrml", "(", "oqparam", ",", "fname", ")", ":", "hcurves_by_imt", "=", "{", "}", "oqparam", ".", "hazard_imtls", "=", "imtls", "=", "{", "}", "for", "hcurves", "in", "nrml", ".", "read", "(", "fname", ")", ":", "imt", "=", "hcurves...
:param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fname: an XML file containing hazard curves :returns: site mesh, curve array
[ ":", "param", "oqparam", ":", "an", ":", "class", ":", "openquake", ".", "commonlib", ".", "oqvalidation", ".", "OqParam", "instance", ":", "param", "fname", ":", "an", "XML", "file", "containing", "hazard", "curves", ":", "returns", ":", "site", "mesh", ...
python
train
craffel/mir_eval
mir_eval/separation.py
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L679-L722
def _project(reference_sources, estimated_source, flen): """Least-squares projection of estimated source on the subspace spanned by delayed versions of reference sources, with delays between 0 and flen-1 """ nsrc = reference_sources.shape[0] nsampl = reference_sources.shape[1] # computing coeff...
[ "def", "_project", "(", "reference_sources", ",", "estimated_source", ",", "flen", ")", ":", "nsrc", "=", "reference_sources", ".", "shape", "[", "0", "]", "nsampl", "=", "reference_sources", ".", "shape", "[", "1", "]", "# computing coefficients of least squares ...
Least-squares projection of estimated source on the subspace spanned by delayed versions of reference sources, with delays between 0 and flen-1
[ "Least", "-", "squares", "projection", "of", "estimated", "source", "on", "the", "subspace", "spanned", "by", "delayed", "versions", "of", "reference", "sources", "with", "delays", "between", "0", "and", "flen", "-", "1" ]
python
train
ome/omego
omego/db.py
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/db.py#L206-L218
def dump(self): """ Dump the database using the postgres custom format """ dumpfile = self.args.dumpfile if not dumpfile: db, env = self.get_db_args_env() dumpfile = fileutils.timestamp_filename( 'omero-database-%s' % db['name'], 'pgdump') ...
[ "def", "dump", "(", "self", ")", ":", "dumpfile", "=", "self", ".", "args", ".", "dumpfile", "if", "not", "dumpfile", ":", "db", ",", "env", "=", "self", ".", "get_db_args_env", "(", ")", "dumpfile", "=", "fileutils", ".", "timestamp_filename", "(", "'...
Dump the database using the postgres custom format
[ "Dump", "the", "database", "using", "the", "postgres", "custom", "format" ]
python
train
polyaxon/polyaxon
polyaxon/streams/consumers/consumers.py
https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L157-L165
def setup_queue(self, queue_name): """Setup the queue on RabbitMQ by invoking the Queue.Declare RPC command. When it is complete, the on_queue_declareok method will be invoked by pika. :param str|unicode queue_name: The name of the queue to declare. """ _logger.debug('De...
[ "def", "setup_queue", "(", "self", ",", "queue_name", ")", ":", "_logger", ".", "debug", "(", "'Declaring queue %s'", ",", "queue_name", ")", "self", ".", "_channel", ".", "queue_declare", "(", "self", ".", "on_queue_declareok", ",", "queue_name", ")" ]
Setup the queue on RabbitMQ by invoking the Queue.Declare RPC command. When it is complete, the on_queue_declareok method will be invoked by pika. :param str|unicode queue_name: The name of the queue to declare.
[ "Setup", "the", "queue", "on", "RabbitMQ", "by", "invoking", "the", "Queue", ".", "Declare", "RPC", "command", ".", "When", "it", "is", "complete", "the", "on_queue_declareok", "method", "will", "be", "invoked", "by", "pika", "." ]
python
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L326-L368
def visit_Compare(self, node): """ Boolean are possible index. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 or 3 ... b = 4 or 5 ... c = a < b ... d = b < 3 ...
[ "def", "visit_Compare", "(", "self", ",", "node", ")", ":", "if", "any", "(", "isinstance", "(", "op", ",", "(", "ast", ".", "In", ",", "ast", ".", "NotIn", ",", "ast", ".", "Is", ",", "ast", ".", "IsNot", ")", ")", "for", "op", "in", "node", ...
Boolean are possible index. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 or 3 ... b = 4 or 5 ... c = a < b ... d = b < 3 ... e = b == 4''') >>> pm...
[ "Boolean", "are", "possible", "index", "." ]
python
train
hwmrocker/smtplibaio
smtplibaio/smtp.py
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L846-L859
async def close(self): """ Cleans up after the connection to the SMTP server has been closed (voluntarily or not). """ if self.writer is not None: # Close the transport: try: self.writer.close() except OSError as exc: ...
[ "async", "def", "close", "(", "self", ")", ":", "if", "self", ".", "writer", "is", "not", "None", ":", "# Close the transport:", "try", ":", "self", ".", "writer", ".", "close", "(", ")", "except", "OSError", "as", "exc", ":", "if", "exc", ".", "errn...
Cleans up after the connection to the SMTP server has been closed (voluntarily or not).
[ "Cleans", "up", "after", "the", "connection", "to", "the", "SMTP", "server", "has", "been", "closed", "(", "voluntarily", "or", "not", ")", "." ]
python
train
JnyJny/Geometry
Geometry/point.py
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/point.py#L1420-L1455
def rotate2d(self, theta, origin=None, axis='z', radians=False): ''' :theta: float radians to rotate self around origin :origin: optional Point, defaults to 0,0,0 Returns a Point rotated by :theta: around :origin:. ''' origin = Point._convert(origin) delta = se...
[ "def", "rotate2d", "(", "self", ",", "theta", ",", "origin", "=", "None", ",", "axis", "=", "'z'", ",", "radians", "=", "False", ")", ":", "origin", "=", "Point", ".", "_convert", "(", "origin", ")", "delta", "=", "self", "-", "origin", "p", "=", ...
:theta: float radians to rotate self around origin :origin: optional Point, defaults to 0,0,0 Returns a Point rotated by :theta: around :origin:.
[ ":", "theta", ":", "float", "radians", "to", "rotate", "self", "around", "origin", ":", "origin", ":", "optional", "Point", "defaults", "to", "0", "0", "0" ]
python
train
ChargePoint/pydnp3
examples/outstation.py
https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/outstation.py#L284-L291
def main(): """The Outstation has been started from the command line. Execute ad-hoc tests if desired.""" app = OutstationApplication() _log.debug('Initialization complete. In command loop.') # Ad-hoc tests can be inserted here if desired. See outstation_cmd.py for examples. app.shutdown() _log....
[ "def", "main", "(", ")", ":", "app", "=", "OutstationApplication", "(", ")", "_log", ".", "debug", "(", "'Initialization complete. In command loop.'", ")", "# Ad-hoc tests can be inserted here if desired. See outstation_cmd.py for examples.", "app", ".", "shutdown", "(", ")...
The Outstation has been started from the command line. Execute ad-hoc tests if desired.
[ "The", "Outstation", "has", "been", "started", "from", "the", "command", "line", ".", "Execute", "ad", "-", "hoc", "tests", "if", "desired", "." ]
python
valid
mikedh/trimesh
trimesh/path/simplify.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/path/simplify.py#L364-L411
def simplify_spline(path, smooth=None, verbose=False): """ Replace discrete curves with b-spline or Arc and return the result as a new Path2D object. Parameters ------------ path : trimesh.path.Path2D Input geometry smooth : float Distance to smooth Returns ------------...
[ "def", "simplify_spline", "(", "path", ",", "smooth", "=", "None", ",", "verbose", "=", "False", ")", ":", "new_vertices", "=", "[", "]", "new_entities", "=", "[", "]", "scale", "=", "path", ".", "scale", "for", "discrete", "in", "path", ".", "discrete...
Replace discrete curves with b-spline or Arc and return the result as a new Path2D object. Parameters ------------ path : trimesh.path.Path2D Input geometry smooth : float Distance to smooth Returns ------------ simplified : Path2D Consists of Arc and BSpline entities
[ "Replace", "discrete", "curves", "with", "b", "-", "spline", "or", "Arc", "and", "return", "the", "result", "as", "a", "new", "Path2D", "object", "." ]
python
train
DLR-RM/RAFCON
source/rafcon/gui/controllers/states_editor.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/states_editor.py#L491-L514
def activate_state_tab(self, state_m): """Opens the tab for the specified state model The tab with the given state model is opened or set to foreground. :param state_m: The desired state model (the selected state) """ # The current shown state differs from the desired one ...
[ "def", "activate_state_tab", "(", "self", ",", "state_m", ")", ":", "# The current shown state differs from the desired one", "current_state_m", "=", "self", ".", "get_current_state_m", "(", ")", "if", "current_state_m", "is", "not", "state_m", ":", "state_identifier", ...
Opens the tab for the specified state model The tab with the given state model is opened or set to foreground. :param state_m: The desired state model (the selected state)
[ "Opens", "the", "tab", "for", "the", "specified", "state", "model" ]
python
train
PythonCharmers/python-future
src/libfuturize/fixer_util.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/libfuturize/fixer_util.py#L96-L110
def indentation_step(node): """ Dirty little trick to get the difference between each indentation level Implemented by finding the shortest indentation string (technically, the "least" of all of the indentation strings, but tabs and spaces mixed won't get this far, so those are synonymous.) """ ...
[ "def", "indentation_step", "(", "node", ")", ":", "r", "=", "find_root", "(", "node", ")", "# Collect all indentations into one set.", "all_indents", "=", "set", "(", "i", ".", "value", "for", "i", "in", "r", ".", "pre_order", "(", ")", "if", "i", ".", "...
Dirty little trick to get the difference between each indentation level Implemented by finding the shortest indentation string (technically, the "least" of all of the indentation strings, but tabs and spaces mixed won't get this far, so those are synonymous.)
[ "Dirty", "little", "trick", "to", "get", "the", "difference", "between", "each", "indentation", "level", "Implemented", "by", "finding", "the", "shortest", "indentation", "string", "(", "technically", "the", "least", "of", "all", "of", "the", "indentation", "str...
python
train
wangwenpei/cliez
cliez/conf/__init__.py
https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/conf/__init__.py#L46-L59
def settings(path=None, with_path=None): """ Get or set `Settings._wrapped` :param str path: a python module file, if user set it,write config to `Settings._wrapped` :param str with_path: search path :return: A instance of `Settings` """ if path: Settings.bind(path, with_pa...
[ "def", "settings", "(", "path", "=", "None", ",", "with_path", "=", "None", ")", ":", "if", "path", ":", "Settings", ".", "bind", "(", "path", ",", "with_path", "=", "with_path", ")", "return", "Settings", ".", "_wrapped" ]
Get or set `Settings._wrapped` :param str path: a python module file, if user set it,write config to `Settings._wrapped` :param str with_path: search path :return: A instance of `Settings`
[ "Get", "or", "set", "Settings", ".", "_wrapped" ]
python
valid
totalgood/pugnlp
src/pugnlp/util.py
https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/util.py#L1328-L1347
def update_file_ext(filename, ext='txt', sep='.'): r"""Force the file or path str to end with the indicated extension Note: a dot (".") is assumed to delimit the extension >>> from __future__ import unicode_literals >>> update_file_ext('/home/hobs/extremofile', 'bac') '/home/hobs/extremofile.bac' ...
[ "def", "update_file_ext", "(", "filename", ",", "ext", "=", "'txt'", ",", "sep", "=", "'.'", ")", ":", "path", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "if", "ext", "and", "ext", "[", "0", "]", "==", "sep", ":"...
r"""Force the file or path str to end with the indicated extension Note: a dot (".") is assumed to delimit the extension >>> from __future__ import unicode_literals >>> update_file_ext('/home/hobs/extremofile', 'bac') '/home/hobs/extremofile.bac' >>> update_file_ext('/home/hobs/piano.file/', 'musi...
[ "r", "Force", "the", "file", "or", "path", "str", "to", "end", "with", "the", "indicated", "extension" ]
python
train
cltk/cltk
cltk/utils/philology.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/utils/philology.py#L196-L211
def return_concordance_all(self, tokens: List[str]) -> List[List[str]]: """Take a list of tokens, iteratively run each word through return_concordance_word and build a list of all. This returns a list of lists. """ coll = pyuca.Collator() # type: pyuca.Collator tokens =...
[ "def", "return_concordance_all", "(", "self", ",", "tokens", ":", "List", "[", "str", "]", ")", "->", "List", "[", "List", "[", "str", "]", "]", ":", "coll", "=", "pyuca", ".", "Collator", "(", ")", "# type: pyuca.Collator", "tokens", "=", "sorted", "(...
Take a list of tokens, iteratively run each word through return_concordance_word and build a list of all. This returns a list of lists.
[ "Take", "a", "list", "of", "tokens", "iteratively", "run", "each", "word", "through", "return_concordance_word", "and", "build", "a", "list", "of", "all", ".", "This", "returns", "a", "list", "of", "lists", "." ]
python
train
secure-systems-lab/securesystemslib
securesystemslib/util.py
https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L743-L783
def get_target_hash(target_filepath): """ <Purpose> Compute the hash of 'target_filepath'. This is useful in conjunction with the "path_hash_prefixes" attribute in a delegated targets role, which tells us which paths it is implicitly responsible for. The repository may optionally organize targets i...
[ "def", "get_target_hash", "(", "target_filepath", ")", ":", "# Does 'target_filepath' have the correct format?", "# Ensure the arguments have the appropriate number of objects and object", "# types, and that all dict keys are properly named.", "# Raise 'securesystemslib.exceptions.FormatError' if ...
<Purpose> Compute the hash of 'target_filepath'. This is useful in conjunction with the "path_hash_prefixes" attribute in a delegated targets role, which tells us which paths it is implicitly responsible for. The repository may optionally organize targets into hashed bins to ease target delegations...
[ "<Purpose", ">", "Compute", "the", "hash", "of", "target_filepath", ".", "This", "is", "useful", "in", "conjunction", "with", "the", "path_hash_prefixes", "attribute", "in", "a", "delegated", "targets", "role", "which", "tells", "us", "which", "paths", "it", "...
python
train
jtwhite79/pyemu
pyemu/pst/pst_handler.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/pst/pst_handler.py#L313-L324
def pars_in_groups(self): """ return a dictionary of parameter names in each parameter group. Returns: dictionary """ pargp = self.par_groups allpars = dict() for cpg in pargp: allpars[cpg] = [i for i in self.parameter_data.loc[self.param...
[ "def", "pars_in_groups", "(", "self", ")", ":", "pargp", "=", "self", ".", "par_groups", "allpars", "=", "dict", "(", ")", "for", "cpg", "in", "pargp", ":", "allpars", "[", "cpg", "]", "=", "[", "i", "for", "i", "in", "self", ".", "parameter_data", ...
return a dictionary of parameter names in each parameter group. Returns: dictionary
[ "return", "a", "dictionary", "of", "parameter", "names", "in", "each", "parameter", "group", "." ]
python
train
splunk/splunk-sdk-python
examples/analytics/bottle.py
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L734-L760
def wsgi(self, environ, start_response): """ The bottle WSGI-interface. """ try: environ['bottle.app'] = self request.bind(environ) response.bind() out = self._handle(environ) out = self._cast(out, request, response) # rfc2616 secti...
[ "def", "wsgi", "(", "self", ",", "environ", ",", "start_response", ")", ":", "try", ":", "environ", "[", "'bottle.app'", "]", "=", "self", "request", ".", "bind", "(", "environ", ")", "response", ".", "bind", "(", ")", "out", "=", "self", ".", "_hand...
The bottle WSGI-interface.
[ "The", "bottle", "WSGI", "-", "interface", "." ]
python
train
eaton-lab/toytree
toytree/Coords.py
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L40-L53
def update(self): "Updates cartesian coordinates for drawing tree graph" # get new shape and clear for attrs self.edges = np.zeros((self.ttree.nnodes - 1, 2), dtype=int) self.verts = np.zeros((self.ttree.nnodes, 2), dtype=float) self.lines = [] self.coords =...
[ "def", "update", "(", "self", ")", ":", "# get new shape and clear for attrs", "self", ".", "edges", "=", "np", ".", "zeros", "(", "(", "self", ".", "ttree", ".", "nnodes", "-", "1", ",", "2", ")", ",", "dtype", "=", "int", ")", "self", ".", "verts",...
Updates cartesian coordinates for drawing tree graph
[ "Updates", "cartesian", "coordinates", "for", "drawing", "tree", "graph" ]
python
train
chrisspen/burlap
burlap/vm.py
https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/vm.py#L139-L212
def list_instances(show=1, name=None, group=None, release=None, except_release=None): """ Retrieves all virtual machines instances in the current environment. """ from burlap.common import shelf, OrderedDict, get_verbose verbose = get_verbose() require('vm_type', 'vm_group') assert env.vm_t...
[ "def", "list_instances", "(", "show", "=", "1", ",", "name", "=", "None", ",", "group", "=", "None", ",", "release", "=", "None", ",", "except_release", "=", "None", ")", ":", "from", "burlap", ".", "common", "import", "shelf", ",", "OrderedDict", ",",...
Retrieves all virtual machines instances in the current environment.
[ "Retrieves", "all", "virtual", "machines", "instances", "in", "the", "current", "environment", "." ]
python
valid
abseil/abseil-py
absl/logging/__init__.py
https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L1128-L1159
def _initialize(): """Initializes loggers and handlers.""" global _absl_logger, _absl_handler if _absl_logger: return original_logger_class = logging.getLoggerClass() logging.setLoggerClass(ABSLLogger) _absl_logger = logging.getLogger('absl') logging.setLoggerClass(original_logger_class) python_l...
[ "def", "_initialize", "(", ")", ":", "global", "_absl_logger", ",", "_absl_handler", "if", "_absl_logger", ":", "return", "original_logger_class", "=", "logging", ".", "getLoggerClass", "(", ")", "logging", ".", "setLoggerClass", "(", "ABSLLogger", ")", "_absl_log...
Initializes loggers and handlers.
[ "Initializes", "loggers", "and", "handlers", "." ]
python
train